| 1 |
SET @max_row = 20; |
| 2 |
drop table if exists t1; |
| 3 |
create table t1 (a bit(65), primary key (a)) engine='MyISAM' partition by key (a); |
| 4 |
ERROR 42000: Display width out of range for 'a' (max = 64) |
| 5 |
create table t1 (a bit(0), primary key (a)) engine='MyISAM' partition by key (a); |
| 6 |
show create table t1; |
| 7 |
Table Create Table |
| 8 |
t1 CREATE TABLE `t1` ( |
| 9 |
`a` bit(1) NOT NULL, |
| 10 |
PRIMARY KEY (`a`) |
| 11 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 12 |
PARTITION BY KEY (`a`) |
| 13 |
drop table t1; |
| 14 |
create table t1 (a bit(0), primary key (a)) engine='MyISAM' |
| 15 |
partition by key (a) ( |
| 16 |
partition pa1, |
| 17 |
partition pa2); |
| 18 |
show create table t1; |
| 19 |
Table Create Table |
| 20 |
t1 CREATE TABLE `t1` ( |
| 21 |
`a` bit(1) NOT NULL, |
| 22 |
PRIMARY KEY (`a`) |
| 23 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 24 |
PARTITION BY KEY (`a`) |
| 25 |
(PARTITION `pa1` ENGINE = MyISAM, |
| 26 |
PARTITION `pa2` ENGINE = MyISAM) |
| 27 |
drop table t1; |
| 28 |
create table t1 (a bit(64), primary key (a)) engine='MyISAM' |
| 29 |
partition by key (a) partitions 2; |
| 30 |
show create table t1; |
| 31 |
Table Create Table |
| 32 |
t1 CREATE TABLE `t1` ( |
| 33 |
`a` bit(64) NOT NULL, |
| 34 |
PRIMARY KEY (`a`) |
| 35 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 36 |
PARTITION BY KEY (`a`) |
| 37 |
PARTITIONS 2 |
| 38 |
insert into t1 values |
| 39 |
(b'1111111111111111111111111111111111111111111111111111111111111111'), |
| 40 |
(b'1000000000000000000000000000000000000000000000000000000000000000'), |
| 41 |
(b'0000000000000000000000000000000000000000000000000000000000000001'), |
| 42 |
(b'1010101010101010101010101010101010101010101010101010101010101010'), |
| 43 |
(b'0101010101010101010101010101010101010101010101010101010101010101'); |
| 44 |
select hex(a) from t1; |
| 45 |
hex(a) |
| 46 |
1 |
| 47 |
5555555555555555 |
| 48 |
8000000000000000 |
| 49 |
AAAAAAAAAAAAAAAA |
| 50 |
FFFFFFFFFFFFFFFF |
| 51 |
drop table t1; |
| 52 |
create table t1 (a bit(64), primary key (a)) engine='MyISAM' |
| 53 |
partition by key (a) ( |
| 54 |
partition pa1 max_rows=20 min_rows=2, |
| 55 |
partition pa2 max_rows=30 min_rows=3, |
| 56 |
partition pa3 max_rows=30 min_rows=4, |
| 57 |
partition pa4 max_rows=40 min_rows=2); |
| 58 |
show create table t1; |
| 59 |
Table Create Table |
| 60 |
t1 CREATE TABLE `t1` ( |
| 61 |
`a` bit(64) NOT NULL, |
| 62 |
PRIMARY KEY (`a`) |
| 63 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 64 |
PARTITION BY KEY (`a`) |
| 65 |
(PARTITION `pa1` MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM, |
| 66 |
PARTITION `pa2` MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM, |
| 67 |
PARTITION `pa3` MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM, |
| 68 |
PARTITION `pa4` MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) |
| 69 |
insert into t1 values |
| 70 |
(b'1111111111111111111111111111111111111111111111111111111111111111'), |
| 71 |
(b'1000000000000000000000000000000000000000000000000000000000000000'), |
| 72 |
(b'0000000000000000000000000000000000000000000000000000000000000001'), |
| 73 |
(b'1010101010101010101010101010101010101010101010101010101010101010'), |
| 74 |
(b'0101010101010101010101010101010101010101010101010101010101010101'); |
| 75 |
select hex(a) from t1 where a=b'0101010101010101010101010101010101010101010101010101010101010101'; |
| 76 |
hex(a) |
| 77 |
5555555555555555 |
| 78 |
delete from t1 where a=b'0101010101010101010101010101010101010101010101010101010101010101'; |
| 79 |
select hex(a) from t1; |
| 80 |
hex(a) |
| 81 |
1 |
| 82 |
8000000000000000 |
| 83 |
AAAAAAAAAAAAAAAA |
| 84 |
FFFFFFFFFFFFFFFF |
| 85 |
drop table t1; |
| 86 |
create table t2 (a bit, primary key (a)) engine='MyISAM' |
| 87 |
partition by key (a) partitions 4; |
| 88 |
show create table t2; |
| 89 |
Table Create Table |
| 90 |
t2 CREATE TABLE `t2` ( |
| 91 |
`a` bit(1) NOT NULL, |
| 92 |
PRIMARY KEY (`a`) |
| 93 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 94 |
PARTITION BY KEY (`a`) |
| 95 |
PARTITIONS 4 |
| 96 |
insert into t2 values (b'0'), (b'1'); |
| 97 |
select hex(a) from t2; |
| 98 |
hex(a) |
| 99 |
0 |
| 100 |
1 |
| 101 |
alter table t2 drop primary key; |
| 102 |
show create table t2; |
| 103 |
Table Create Table |
| 104 |
t2 CREATE TABLE `t2` ( |
| 105 |
`a` bit(1) NOT NULL |
| 106 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 107 |
PARTITION BY KEY (`a`) |
| 108 |
PARTITIONS 4 |
| 109 |
select hex(a) from t2; |
| 110 |
hex(a) |
| 111 |
0 |
| 112 |
1 |
| 113 |
alter table t2 add primary key (a); |
| 114 |
show create table t2; |
| 115 |
Table Create Table |
| 116 |
t2 CREATE TABLE `t2` ( |
| 117 |
`a` bit(1) NOT NULL, |
| 118 |
PRIMARY KEY (`a`) |
| 119 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 120 |
PARTITION BY KEY (`a`) |
| 121 |
PARTITIONS 4 |
| 122 |
select hex(a) from t2; |
| 123 |
hex(a) |
| 124 |
0 |
| 125 |
1 |
| 126 |
drop table t2; |
| 127 |
create table t3 (a bit(8), primary key (a)) engine='MyISAM' |
| 128 |
partition by range (a) subpartition by key (a) subpartitions 2 ( |
| 129 |
partition pa1 values less than (3), |
| 130 |
partition pa2 values less than (16), |
| 131 |
partition pa3 values less than (64), |
| 132 |
partition pa4 values less than (256)); |
| 133 |
show create table t3; |
| 134 |
Table Create Table |
| 135 |
t3 CREATE TABLE `t3` ( |
| 136 |
`a` bit(8) NOT NULL, |
| 137 |
PRIMARY KEY (`a`) |
| 138 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 139 |
PARTITION BY RANGE (`a`) |
| 140 |
SUBPARTITION BY KEY (`a`) |
| 141 |
SUBPARTITIONS 2 |
| 142 |
(PARTITION `pa1` VALUES LESS THAN (3) ENGINE = MyISAM, |
| 143 |
PARTITION `pa2` VALUES LESS THAN (16) ENGINE = MyISAM, |
| 144 |
PARTITION `pa3` VALUES LESS THAN (64) ENGINE = MyISAM, |
| 145 |
PARTITION `pa4` VALUES LESS THAN (256) ENGINE = MyISAM) |
| 146 |
255 inserts; |
| 147 |
select hex(a) from t3 where a=b'01010101'; |
| 148 |
hex(a) |
| 149 |
55 |
| 150 |
delete from t3 where a=b'01010101'; |
| 151 |
select count(*) from t3; |
| 152 |
count(*) |
| 153 |
254 |
| 154 |
select hex(a) from t3; |
| 155 |
hex(a) |
| 156 |
1 |
| 157 |
10 |
| 158 |
11 |
| 159 |
12 |
| 160 |
13 |
| 161 |
14 |
| 162 |
15 |
| 163 |
16 |
| 164 |
17 |
| 165 |
18 |
| 166 |
19 |
| 167 |
1A |
| 168 |
1B |
| 169 |
1C |
| 170 |
1D |
| 171 |
1E |
| 172 |
1F |
| 173 |
2 |
| 174 |
20 |
| 175 |
21 |
| 176 |
22 |
| 177 |
23 |
| 178 |
24 |
| 179 |
25 |
| 180 |
26 |
| 181 |
27 |
| 182 |
28 |
| 183 |
29 |
| 184 |
2A |
| 185 |
2B |
| 186 |
2C |
| 187 |
2D |
| 188 |
2E |
| 189 |
2F |
| 190 |
3 |
| 191 |
30 |
| 192 |
31 |
| 193 |
32 |
| 194 |
33 |
| 195 |
34 |
| 196 |
35 |
| 197 |
36 |
| 198 |
37 |
| 199 |
38 |
| 200 |
39 |
| 201 |
3A |
| 202 |
3B |
| 203 |
3C |
| 204 |
3D |
| 205 |
3E |
| 206 |
3F |
| 207 |
4 |
| 208 |
40 |
| 209 |
41 |
| 210 |
42 |
| 211 |
43 |
| 212 |
44 |
| 213 |
45 |
| 214 |
46 |
| 215 |
47 |
| 216 |
48 |
| 217 |
49 |
| 218 |
4A |
| 219 |
4B |
| 220 |
4C |
| 221 |
4D |
| 222 |
4E |
| 223 |
4F |
| 224 |
5 |
| 225 |
50 |
| 226 |
51 |
| 227 |
52 |
| 228 |
53 |
| 229 |
54 |
| 230 |
56 |
| 231 |
57 |
| 232 |
58 |
| 233 |
59 |
| 234 |
5A |
| 235 |
5B |
| 236 |
5C |
| 237 |
5D |
| 238 |
5E |
| 239 |
5F |
| 240 |
6 |
| 241 |
60 |
| 242 |
61 |
| 243 |
62 |
| 244 |
63 |
| 245 |
64 |
| 246 |
65 |
| 247 |
66 |
| 248 |
67 |
| 249 |
68 |
| 250 |
69 |
| 251 |
6A |
| 252 |
6B |
| 253 |
6C |
| 254 |
6D |
| 255 |
6E |
| 256 |
6F |
| 257 |
7 |
| 258 |
70 |
| 259 |
71 |
| 260 |
72 |
| 261 |
73 |
| 262 |
74 |
| 263 |
75 |
| 264 |
76 |
| 265 |
77 |
| 266 |
78 |
| 267 |
79 |
| 268 |
7A |
| 269 |
7B |
| 270 |
7C |
| 271 |
7D |
| 272 |
7E |
| 273 |
7F |
| 274 |
8 |
| 275 |
80 |
| 276 |
81 |
| 277 |
82 |
| 278 |
83 |
| 279 |
84 |
| 280 |
85 |
| 281 |
86 |
| 282 |
87 |
| 283 |
88 |
| 284 |
89 |
| 285 |
8A |
| 286 |
8B |
| 287 |
8C |
| 288 |
8D |
| 289 |
8E |
| 290 |
8F |
| 291 |
9 |
| 292 |
90 |
| 293 |
91 |
| 294 |
92 |
| 295 |
93 |
| 296 |
94 |
| 297 |
95 |
| 298 |
96 |
| 299 |
97 |
| 300 |
98 |
| 301 |
99 |
| 302 |
9A |
| 303 |
9B |
| 304 |
9C |
| 305 |
9D |
| 306 |
9E |
| 307 |
9F |
| 308 |
A |
| 309 |
A0 |
| 310 |
A1 |
| 311 |
A2 |
| 312 |
A3 |
| 313 |
A4 |
| 314 |
A5 |
| 315 |
A6 |
| 316 |
A7 |
| 317 |
A8 |
| 318 |
A9 |
| 319 |
AA |
| 320 |
AB |
| 321 |
AC |
| 322 |
AD |
| 323 |
AE |
| 324 |
AF |
| 325 |
B |
| 326 |
B0 |
| 327 |
B1 |
| 328 |
B2 |
| 329 |
B3 |
| 330 |
B4 |
| 331 |
B5 |
| 332 |
B6 |
| 333 |
B7 |
| 334 |
B8 |
| 335 |
B9 |
| 336 |
BA |
| 337 |
BB |
| 338 |
BC |
| 339 |
BD |
| 340 |
BE |
| 341 |
BF |
| 342 |
C |
| 343 |
C0 |
| 344 |
C1 |
| 345 |
C2 |
| 346 |
C3 |
| 347 |
C4 |
| 348 |
C5 |
| 349 |
C6 |
| 350 |
C7 |
| 351 |
C8 |
| 352 |
C9 |
| 353 |
CA |
| 354 |
CB |
| 355 |
CC |
| 356 |
CD |
| 357 |
CE |
| 358 |
CF |
| 359 |
D |
| 360 |
D0 |
| 361 |
D1 |
| 362 |
D2 |
| 363 |
D3 |
| 364 |
D4 |
| 365 |
D5 |
| 366 |
D6 |
| 367 |
D7 |
| 368 |
D8 |
| 369 |
D9 |
| 370 |
DA |
| 371 |
DB |
| 372 |
DC |
| 373 |
DD |
| 374 |
DE |
| 375 |
DF |
| 376 |
E |
| 377 |
E0 |
| 378 |
E1 |
| 379 |
E2 |
| 380 |
E3 |
| 381 |
E4 |
| 382 |
E5 |
| 383 |
E6 |
| 384 |
E7 |
| 385 |
E8 |
| 386 |
E9 |
| 387 |
EA |
| 388 |
EB |
| 389 |
EC |
| 390 |
ED |
| 391 |
EE |
| 392 |
EF |
| 393 |
F |
| 394 |
F0 |
| 395 |
F1 |
| 396 |
F2 |
| 397 |
F3 |
| 398 |
F4 |
| 399 |
F5 |
| 400 |
F6 |
| 401 |
F7 |
| 402 |
F8 |
| 403 |
F9 |
| 404 |
FA |
| 405 |
FB |
| 406 |
FC |
| 407 |
FD |
| 408 |
FE |
| 409 |
FF |
| 410 |
drop table t3; |
| 411 |
create table t4 (a bit(8), primary key (a)) engine='MyISAM' |
| 412 |
partition by list (a) subpartition by key (a) subpartitions 2 ( |
| 413 |
partition pa1 values in (0,1,2,3), |
| 414 |
partition pa2 values in (4,5,6,7,8,9,10,11,12,13,14,15,16), |
| 415 |
partition pa3 values in (17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32)); |
| 416 |
show create table t4; |
| 417 |
Table Create Table |
| 418 |
t4 CREATE TABLE `t4` ( |
| 419 |
`a` bit(8) NOT NULL, |
| 420 |
PRIMARY KEY (`a`) |
| 421 |
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 422 |
PARTITION BY LIST (`a`) |
| 423 |
SUBPARTITION BY KEY (`a`) |
| 424 |
SUBPARTITIONS 2 |
| 425 |
(PARTITION `pa1` VALUES IN (0,1,2,3) ENGINE = MyISAM, |
| 426 |
PARTITION `pa2` VALUES IN (4,5,6,7,8,9,10,11,12,13,14,15,16) ENGINE = MyISAM, |
| 427 |
PARTITION `pa3` VALUES IN (17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32) ENGINE = MyISAM) |
| 428 |
32 inserts; |
| 429 |
select hex(a) from t4 where a=b'00000001'; |
| 430 |
hex(a) |
| 431 |
1 |
| 432 |
delete from t4 where a=b'00000001'; |
| 433 |
select count(*) from t4; |
| 434 |
count(*) |
| 435 |
31 |
| 436 |
select hex(a) from t4; |
| 437 |
hex(a) |
| 438 |
10 |
| 439 |
11 |
| 440 |
12 |
| 441 |
13 |
| 442 |
14 |
| 443 |
15 |
| 444 |
16 |
| 445 |
17 |
| 446 |
18 |
| 447 |
19 |
| 448 |
1A |
| 449 |
1B |
| 450 |
1C |
| 451 |
1D |
| 452 |
1E |
| 453 |
1F |
| 454 |
2 |
| 455 |
20 |
| 456 |
3 |
| 457 |
4 |
| 458 |
5 |
| 459 |
6 |
| 460 |
7 |
| 461 |
8 |
| 462 |
9 |
| 463 |
A |
| 464 |
B |
| 465 |
C |
| 466 |
D |
| 467 |
E |
| 468 |
F |
| 469 |
drop table t4; |