| 1 |
# ndb_import tests with auto inc columns: |
| 2 |
set ndb_autoincrement_prefetch_sz = 1; |
| 3 |
create table t10 ( |
| 4 |
a tinyint not null auto_increment primary key, |
| 5 |
b int, |
| 6 |
c bigint |
| 7 |
) engine ndb; |
| 8 |
create table t10ver like t10; |
| 9 |
Warnings: |
| 10 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 4 |
| 11 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 7 |
| 12 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10ver"; |
| 13 |
AUTO_INCREMENT |
| 14 |
123 |
| 15 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10"; |
| 16 |
AUTO_INCREMENT |
| 17 |
1025 |
| 18 |
select count(*) from t10ver; |
| 19 |
count(*) |
| 20 |
8 |
| 21 |
select count(*) from t10; |
| 22 |
count(*) |
| 23 |
8 |
| 24 |
select count(*) from t10 x, t10ver y |
| 25 |
where x.b = y.b; |
| 26 |
count(*) |
| 27 |
8 |
| 28 |
drop table t10, t10ver; |
| 29 |
create table t10 ( |
| 30 |
a tinyint unsigned not null auto_increment primary key, |
| 31 |
b int, |
| 32 |
c bigint |
| 33 |
) engine ndb; |
| 34 |
create table t10ver like t10; |
| 35 |
Warnings: |
| 36 |
Warning 1264 Out of range value for column 'a' at row 1 |
| 37 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 4 |
| 38 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 7 |
| 39 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10ver"; |
| 40 |
AUTO_INCREMENT |
| 41 |
123 |
| 42 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10"; |
| 43 |
AUTO_INCREMENT |
| 44 |
1025 |
| 45 |
select count(*) from t10ver; |
| 46 |
count(*) |
| 47 |
8 |
| 48 |
select count(*) from t10; |
| 49 |
count(*) |
| 50 |
7 |
| 51 |
select count(*) from t10 x, t10ver y |
| 52 |
where x.b = y.b; |
| 53 |
count(*) |
| 54 |
7 |
| 55 |
drop table t10, t10ver; |
| 56 |
create table t10 ( |
| 57 |
a smallint not null auto_increment primary key, |
| 58 |
b int, |
| 59 |
c bigint |
| 60 |
) engine ndb; |
| 61 |
create table t10ver like t10; |
| 62 |
Warnings: |
| 63 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 4 |
| 64 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 7 |
| 65 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10ver"; |
| 66 |
AUTO_INCREMENT |
| 67 |
123 |
| 68 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10"; |
| 69 |
AUTO_INCREMENT |
| 70 |
1025 |
| 71 |
select count(*) from t10ver; |
| 72 |
count(*) |
| 73 |
8 |
| 74 |
select count(*) from t10; |
| 75 |
count(*) |
| 76 |
8 |
| 77 |
select count(*) from t10 x, t10ver y |
| 78 |
where x.b = y.b; |
| 79 |
count(*) |
| 80 |
8 |
| 81 |
drop table t10, t10ver; |
| 82 |
create table t10 ( |
| 83 |
a smallint unsigned not null auto_increment primary key, |
| 84 |
b int, |
| 85 |
c bigint |
| 86 |
) engine ndb; |
| 87 |
create table t10ver like t10; |
| 88 |
Warnings: |
| 89 |
Warning 1264 Out of range value for column 'a' at row 1 |
| 90 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 4 |
| 91 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 7 |
| 92 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10ver"; |
| 93 |
AUTO_INCREMENT |
| 94 |
123 |
| 95 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10"; |
| 96 |
AUTO_INCREMENT |
| 97 |
1025 |
| 98 |
select count(*) from t10ver; |
| 99 |
count(*) |
| 100 |
8 |
| 101 |
select count(*) from t10; |
| 102 |
count(*) |
| 103 |
7 |
| 104 |
select count(*) from t10 x, t10ver y |
| 105 |
where x.b = y.b; |
| 106 |
count(*) |
| 107 |
7 |
| 108 |
drop table t10, t10ver; |
| 109 |
create table t10 ( |
| 110 |
a mediumint not null auto_increment primary key, |
| 111 |
b int, |
| 112 |
c bigint |
| 113 |
) engine ndb; |
| 114 |
create table t10ver like t10; |
| 115 |
Warnings: |
| 116 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 4 |
| 117 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 7 |
| 118 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10ver"; |
| 119 |
AUTO_INCREMENT |
| 120 |
123 |
| 121 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10"; |
| 122 |
AUTO_INCREMENT |
| 123 |
1025 |
| 124 |
select count(*) from t10ver; |
| 125 |
count(*) |
| 126 |
8 |
| 127 |
select count(*) from t10; |
| 128 |
count(*) |
| 129 |
8 |
| 130 |
select count(*) from t10 x, t10ver y |
| 131 |
where x.b = y.b; |
| 132 |
count(*) |
| 133 |
8 |
| 134 |
drop table t10, t10ver; |
| 135 |
create table t10 ( |
| 136 |
a mediumint unsigned not null auto_increment primary key, |
| 137 |
b int, |
| 138 |
c bigint |
| 139 |
) engine ndb; |
| 140 |
create table t10ver like t10; |
| 141 |
Warnings: |
| 142 |
Warning 1264 Out of range value for column 'a' at row 1 |
| 143 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 4 |
| 144 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 7 |
| 145 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10ver"; |
| 146 |
AUTO_INCREMENT |
| 147 |
123 |
| 148 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10"; |
| 149 |
AUTO_INCREMENT |
| 150 |
1025 |
| 151 |
select count(*) from t10ver; |
| 152 |
count(*) |
| 153 |
8 |
| 154 |
select count(*) from t10; |
| 155 |
count(*) |
| 156 |
7 |
| 157 |
select count(*) from t10 x, t10ver y |
| 158 |
where x.b = y.b; |
| 159 |
count(*) |
| 160 |
7 |
| 161 |
drop table t10, t10ver; |
| 162 |
create table t10 ( |
| 163 |
a int not null auto_increment primary key, |
| 164 |
b int, |
| 165 |
c bigint |
| 166 |
) engine ndb; |
| 167 |
create table t10ver like t10; |
| 168 |
Warnings: |
| 169 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 4 |
| 170 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 7 |
| 171 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10ver"; |
| 172 |
AUTO_INCREMENT |
| 173 |
123 |
| 174 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10"; |
| 175 |
AUTO_INCREMENT |
| 176 |
1025 |
| 177 |
select count(*) from t10ver; |
| 178 |
count(*) |
| 179 |
8 |
| 180 |
select count(*) from t10; |
| 181 |
count(*) |
| 182 |
8 |
| 183 |
select count(*) from t10 x, t10ver y |
| 184 |
where x.b = y.b; |
| 185 |
count(*) |
| 186 |
8 |
| 187 |
drop table t10, t10ver; |
| 188 |
create table t10 ( |
| 189 |
a int unsigned not null auto_increment primary key, |
| 190 |
b int, |
| 191 |
c bigint |
| 192 |
) engine ndb; |
| 193 |
create table t10ver like t10; |
| 194 |
Warnings: |
| 195 |
Warning 1264 Out of range value for column 'a' at row 1 |
| 196 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 4 |
| 197 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 7 |
| 198 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10ver"; |
| 199 |
AUTO_INCREMENT |
| 200 |
123 |
| 201 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10"; |
| 202 |
AUTO_INCREMENT |
| 203 |
1025 |
| 204 |
select count(*) from t10ver; |
| 205 |
count(*) |
| 206 |
8 |
| 207 |
select count(*) from t10; |
| 208 |
count(*) |
| 209 |
7 |
| 210 |
select count(*) from t10 x, t10ver y |
| 211 |
where x.b = y.b; |
| 212 |
count(*) |
| 213 |
7 |
| 214 |
drop table t10, t10ver; |
| 215 |
create table t10 ( |
| 216 |
a bigint not null auto_increment primary key, |
| 217 |
b int, |
| 218 |
c bigint |
| 219 |
) engine ndb; |
| 220 |
create table t10ver like t10; |
| 221 |
Warnings: |
| 222 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 4 |
| 223 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 7 |
| 224 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10ver"; |
| 225 |
AUTO_INCREMENT |
| 226 |
123 |
| 227 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10"; |
| 228 |
AUTO_INCREMENT |
| 229 |
1025 |
| 230 |
select count(*) from t10ver; |
| 231 |
count(*) |
| 232 |
8 |
| 233 |
select count(*) from t10; |
| 234 |
count(*) |
| 235 |
8 |
| 236 |
select count(*) from t10 x, t10ver y |
| 237 |
where x.b = y.b; |
| 238 |
count(*) |
| 239 |
8 |
| 240 |
drop table t10, t10ver; |
| 241 |
create table t10 ( |
| 242 |
a bigint unsigned not null auto_increment primary key, |
| 243 |
b int, |
| 244 |
c bigint |
| 245 |
) engine ndb; |
| 246 |
create table t10ver like t10; |
| 247 |
Warnings: |
| 248 |
Warning 1264 Out of range value for column 'a' at row 1 |
| 249 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 4 |
| 250 |
Warning 1366 Incorrect integer value: '' for column 'a' at row 7 |
| 251 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10ver"; |
| 252 |
AUTO_INCREMENT |
| 253 |
123 |
| 254 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t10"; |
| 255 |
AUTO_INCREMENT |
| 256 |
1025 |
| 257 |
select count(*) from t10ver; |
| 258 |
count(*) |
| 259 |
8 |
| 260 |
select count(*) from t10; |
| 261 |
count(*) |
| 262 |
7 |
| 263 |
select count(*) from t10 x, t10ver y |
| 264 |
where x.b = y.b; |
| 265 |
count(*) |
| 266 |
7 |
| 267 |
# Simple hidden-pk test |
| 268 |
create table t3 ( |
| 269 |
b int not null, |
| 270 |
# unique key would turn into pk |
| 271 |
key bx (b) |
| 272 |
) engine=ndb; |
| 273 |
create table t3ver like t3; |
| 274 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t3ver"; |
| 275 |
AUTO_INCREMENT |
| 276 |
NULL |
| 277 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t3"; |
| 278 |
AUTO_INCREMENT |
| 279 |
NULL |
| 280 |
select count(*) from t3ver; |
| 281 |
count(*) |
| 282 |
1000 |
| 283 |
select count(*) from t3; |
| 284 |
count(*) |
| 285 |
1000 |
| 286 |
select count(*) from t3 x, t3ver y |
| 287 |
where x.b = y.b; |
| 288 |
count(*) |
| 289 |
1000 |
| 290 |
Test auto inc PK works when it is the middle column |
| 291 |
create table t12 ( |
| 292 |
a smallint, |
| 293 |
b mediumint not null auto_increment primary key, |
| 294 |
c int |
| 295 |
) engine ndb; |
| 296 |
create table t12ver like t12; |
| 297 |
Warnings: |
| 298 |
Warning 1366 Incorrect integer value: '' for column 'b' at row 2 |
| 299 |
Warning 1366 Incorrect integer value: '' for column 'b' at row 5 |
| 300 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t12ver"; |
| 301 |
AUTO_INCREMENT |
| 302 |
90 |
| 303 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t12"; |
| 304 |
AUTO_INCREMENT |
| 305 |
1025 |
| 306 |
select count(*) from t12ver; |
| 307 |
count(*) |
| 308 |
6 |
| 309 |
select count(*) from t12; |
| 310 |
count(*) |
| 311 |
6 |
| 312 |
select count(*) from t12 x, t12ver y |
| 313 |
where x.a = y.a; |
| 314 |
count(*) |
| 315 |
6 |
| 316 |
Test auto inc PK works when it is the last column |
| 317 |
create table t13 ( |
| 318 |
a int, |
| 319 |
b int, |
| 320 |
c smallint unsigned not null auto_increment primary key |
| 321 |
) engine ndb; |
| 322 |
create table t13ver like t13; |
| 323 |
Warnings: |
| 324 |
Warning 1366 Incorrect integer value: '' for column 'c' at row 2 |
| 325 |
Warning 1366 Incorrect integer value: '' for column 'c' at row 5 |
| 326 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t13ver"; |
| 327 |
AUTO_INCREMENT |
| 328 |
50003 |
| 329 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t13"; |
| 330 |
AUTO_INCREMENT |
| 331 |
1025 |
| 332 |
select count(*) from t13ver; |
| 333 |
count(*) |
| 334 |
7 |
| 335 |
select count(*) from t13; |
| 336 |
count(*) |
| 337 |
7 |
| 338 |
select count(*) from t13 x, t13ver y |
| 339 |
where x.a = y.a; |
| 340 |
count(*) |
| 341 |
7 |
| 342 |
Test when all input rows have user-provided auto inc PK. |
| 343 |
create table t14 ( |
| 344 |
a mediumint unsigned not null auto_increment primary key, |
| 345 |
b int |
| 346 |
) engine ndb; |
| 347 |
create table t14ver like t14; |
| 348 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t14ver"; |
| 349 |
AUTO_INCREMENT |
| 350 |
1889 |
| 351 |
select AUTO_INCREMENT from information_schema.tables where table_schema="test" and table_name="t14"; |
| 352 |
AUTO_INCREMENT |
| 353 |
1 |
| 354 |
select * from t14ver order by a; |
| 355 |
a b |
| 356 |
1288 20000 |
| 357 |
1388 30000 |
| 358 |
1488 40000 |
| 359 |
1588 56 |
| 360 |
1688 50000 |
| 361 |
1788 60000 |
| 362 |
1888 89 |
| 363 |
select * from t14 order by a; |
| 364 |
a b |
| 365 |
1288 20000 |
| 366 |
1388 30000 |
| 367 |
1488 40000 |
| 368 |
1588 56 |
| 369 |
1688 50000 |
| 370 |
1788 60000 |
| 371 |
1888 89 |
| 372 |
select count(*) from t14ver; |
| 373 |
count(*) |
| 374 |
7 |
| 375 |
select count(*) from t14; |
| 376 |
count(*) |
| 377 |
7 |
| 378 |
select count(*) from t14 x, t14ver y |
| 379 |
where x.b = y.b; |
| 380 |
count(*) |
| 381 |
7 |
| 382 |
drop table t10, t10ver, t3, t3ver, t12, t12ver, t13, t13ver, t14, t14ver; |