~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/r/myisam.result

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1,t2;
 
2
SET SQL_WARNINGS=1;
 
3
CREATE TABLE t1 (
 
4
STRING_DATA char(255) default NULL,
 
5
KEY string_data (STRING_DATA)
 
6
) ENGINE=MyISAM;
 
7
INSERT INTO t1 VALUES ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
 
8
INSERT INTO t1 VALUES ('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD');
 
9
INSERT INTO t1 VALUES ('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');
 
10
INSERT INTO t1 VALUES ('FGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG');
 
11
INSERT INTO t1 VALUES ('HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH');
 
12
INSERT INTO t1 VALUES ('WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW');
 
13
CHECK TABLE t1;
 
14
Table   Op      Msg_type        Msg_text
 
15
test.t1 check   status  OK
 
16
drop table t1;
 
17
create table t1 (a tinyint not null auto_increment, b blob not null, primary key (a));
 
18
check table t1;
 
19
Table   Op      Msg_type        Msg_text
 
20
test.t1 check   status  OK
 
21
repair table t1;
 
22
Table   Op      Msg_type        Msg_text
 
23
test.t1 repair  status  OK
 
24
delete from t1 where (a & 1);
 
25
check table t1;
 
26
Table   Op      Msg_type        Msg_text
 
27
test.t1 check   status  OK
 
28
repair table t1;
 
29
Table   Op      Msg_type        Msg_text
 
30
test.t1 repair  status  OK
 
31
check table t1;
 
32
Table   Op      Msg_type        Msg_text
 
33
test.t1 check   status  OK
 
34
drop table t1;
 
35
create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b));
 
36
insert into t1 (b) values (1),(2),(2),(2),(2);
 
37
optimize table t1;
 
38
Table   Op      Msg_type        Msg_text
 
39
test.t1 optimize        status  OK
 
40
show index from t1;
 
41
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
42
t1      0       PRIMARY 1       a       A       5       NULL    NULL            BTREE           
 
43
t1      1       b       1       b       A       1       NULL    NULL            BTREE           
 
44
optimize table t1;
 
45
Table   Op      Msg_type        Msg_text
 
46
test.t1 optimize        status  Table is already up to date
 
47
show index from t1;
 
48
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
49
t1      0       PRIMARY 1       a       A       5       NULL    NULL            BTREE           
 
50
t1      1       b       1       b       A       1       NULL    NULL            BTREE           
 
51
drop table t1;
 
52
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
 
53
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
 
54
explain select * from t1 order by a;
 
55
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
56
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    4       Using filesort
 
57
explain select * from t1 order by b;
 
58
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
59
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    4       Using filesort
 
60
explain select * from t1 order by c;
 
61
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
62
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    4       Using filesort
 
63
explain select a from t1 order by a;
 
64
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
65
1       SIMPLE  t1      index   NULL    PRIMARY 4       NULL    4       Using index
 
66
explain select b from t1 order by b;
 
67
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
68
1       SIMPLE  t1      index   NULL    b       4       NULL    4       Using index
 
69
explain select a,b from t1 order by b;
 
70
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
71
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    4       Using filesort
 
72
explain select a,b from t1;
 
73
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
74
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    4       
 
75
explain select a,b,c from t1;
 
76
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
77
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    4       
 
78
drop table t1;
 
79
CREATE TABLE t1 (a INT);
 
80
INSERT INTO  t1 VALUES (1), (2), (3);
 
81
LOCK TABLES t1 WRITE;
 
82
INSERT INTO  t1 VALUES (1), (2), (3);
 
83
OPTIMIZE TABLE t1;
 
84
Table   Op      Msg_type        Msg_text
 
85
test.t1 optimize        status  OK
 
86
DROP TABLE t1;
 
87
create table t1 ( t1 char(255), key(t1(250)));
 
88
insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169');
 
89
insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203');
 
90
insert t1 values ('213872387238723872387238723872387238723867376737673767376737673767376737673767');
 
91
insert t1 values ('242624262426242624262426242624262426242607890789078907890789078907890789078907');
 
92
insert t1 values ('256025602560256025602560256025602560256011701170117011701170117011701170117011');
 
93
insert t1 values ('276027602760276027602760276027602760276001610161016101610161016101610161016101');
 
94
insert t1 values ('281528152815281528152815281528152815281564956495649564956495649564956495649564');
 
95
insert t1 values ('292129212921292129212921292129212921292102100210021002100210021002100210021002');
 
96
insert t1 values ('380638063806380638063806380638063806380634483448344834483448344834483448344834');
 
97
insert t1 values ('411641164116411641164116411641164116411616301630163016301630163016301630163016');
 
98
insert t1 values ('420842084208420842084208420842084208420899889988998899889988998899889988998899');
 
99
insert t1 values ('438443844384438443844384438443844384438482448244824482448244824482448244824482');
 
100
insert t1 values ('443244324432443244324432443244324432443239613961396139613961396139613961396139');
 
101
insert t1 values ('485448544854485448544854485448544854485477847784778477847784778477847784778477');
 
102
insert t1 values ('494549454945494549454945494549454945494555275527552755275527552755275527552755');
 
103
insert t1 values ('538647864786478647864786478647864786478688918891889188918891889188918891889188');
 
104
insert t1 values ('565556555655565556555655565556555655565554845484548454845484548454845484548454');
 
105
insert t1 values ('607860786078607860786078607860786078607856665666566656665666566656665666566656');
 
106
insert t1 values ('640164016401640164016401640164016401640141274127412741274127412741274127412741');
 
107
insert t1 values ('719471947194719471947194719471947194719478717871787178717871787178717871787178');
 
108
insert t1 values ('742574257425742574257425742574257425742549604960496049604960496049604960496049');
 
109
insert t1 values ('887088708870887088708870887088708870887035963596359635963596359635963596359635');
 
110
insert t1 values ('917791779177917791779177917791779177917773857385738573857385738573857385738573');
 
111
insert t1 values ('933293329332933293329332933293329332933278987898789878987898789878987898789878');
 
112
insert t1 values ('963896389638963896389638963896389638963877807780778077807780778077807780778077');
 
113
delete from t1 where t1>'2';
 
114
insert t1 values ('70'), ('84'), ('60'), ('20'), ('76'), ('89'), ('49'), ('50'),
 
115
('88'), ('61'), ('42'), ('98'), ('39'), ('30'), ('25'), ('66'), ('61'), ('48'),
 
116
('80'), ('84'), ('98'), ('19'), ('91'), ('42'), ('47');
 
117
optimize table t1;
 
118
Table   Op      Msg_type        Msg_text
 
119
test.t1 optimize        status  OK
 
120
check table t1;
 
121
Table   Op      Msg_type        Msg_text
 
122
test.t1 check   status  OK
 
123
drop table t1;
 
124
create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
 
125
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
 
126
int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
 
127
i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
 
128
int, i35 int, i36 int, i37 int, i38 int, i39 int, i40 int, i41 int, i42 int,
 
129
i43 int, i44 int, i45 int, i46 int, i47 int, i48 int, i49 int, i50 int, i51
 
130
int, i52 int, i53 int, i54 int, i55 int, i56 int, i57 int, i58 int, i59 int,
 
131
i60 int, i61 int, i62 int, i63 int, i64 int, i65 int, i66 int, i67 int, i68
 
132
int, i69 int, i70 int, i71 int, i72 int, i73 int, i74 int, i75 int, i76 int,
 
133
i77 int, i78 int, i79 int, i80 int, i81 int, i82 int, i83 int, i84 int, i85
 
134
int, i86 int, i87 int, i88 int, i89 int, i90 int, i91 int, i92 int, i93 int,
 
135
i94 int, i95 int, i96 int, i97 int, i98 int, i99 int, i100 int, i101 int, i102
 
136
int, i103 int, i104 int, i105 int, i106 int, i107 int, i108 int, i109 int, i110
 
137
int, i111 int, i112 int, i113 int, i114 int, i115 int, i116 int, i117 int, i118
 
138
int, i119 int, i120 int, i121 int, i122 int, i123 int, i124 int, i125 int, i126
 
139
int, i127 int, i128 int, i129 int, i130 int, i131 int, i132 int, i133 int, i134
 
140
int, i135 int, i136 int, i137 int, i138 int, i139 int, i140 int, i141 int, i142
 
141
int, i143 int, i144 int, i145 int, i146 int, i147 int, i148 int, i149 int, i150
 
142
int, i151 int, i152 int, i153 int, i154 int, i155 int, i156 int, i157 int, i158
 
143
int, i159 int, i160 int, i161 int, i162 int, i163 int, i164 int, i165 int, i166
 
144
int, i167 int, i168 int, i169 int, i170 int, i171 int, i172 int, i173 int, i174
 
145
int, i175 int, i176 int, i177 int, i178 int, i179 int, i180 int, i181 int, i182
 
146
int, i183 int, i184 int, i185 int, i186 int, i187 int, i188 int, i189 int, i190
 
147
int, i191 int, i192 int, i193 int, i194 int, i195 int, i196 int, i197 int, i198
 
148
int, i199 int, i200 int, i201 int, i202 int, i203 int, i204 int, i205 int, i206
 
149
int, i207 int, i208 int, i209 int, i210 int, i211 int, i212 int, i213 int, i214
 
150
int, i215 int, i216 int, i217 int, i218 int, i219 int, i220 int, i221 int, i222
 
151
int, i223 int, i224 int, i225 int, i226 int, i227 int, i228 int, i229 int, i230
 
152
int, i231 int, i232 int, i233 int, i234 int, i235 int, i236 int, i237 int, i238
 
153
int, i239 int, i240 int, i241 int, i242 int, i243 int, i244 int, i245 int, i246
 
154
int, i247 int, i248 int, i249 int, i250 int, i251 int, i252 int, i253 int, i254
 
155
int, i255 int, i256 int, i257 int, i258 int, i259 int, i260 int, i261 int, i262
 
156
int, i263 int, i264 int, i265 int, i266 int, i267 int, i268 int, i269 int, i270
 
157
int, i271 int, i272 int, i273 int, i274 int, i275 int, i276 int, i277 int, i278
 
158
int, i279 int, i280 int, i281 int, i282 int, i283 int, i284 int, i285 int, i286
 
159
int, i287 int, i288 int, i289 int, i290 int, i291 int, i292 int, i293 int, i294
 
160
int, i295 int, i296 int, i297 int, i298 int, i299 int, i300 int, i301 int, i302
 
161
int, i303 int, i304 int, i305 int, i306 int, i307 int, i308 int, i309 int, i310
 
162
int, i311 int, i312 int, i313 int, i314 int, i315 int, i316 int, i317 int, i318
 
163
int, i319 int, i320 int, i321 int, i322 int, i323 int, i324 int, i325 int, i326
 
164
int, i327 int, i328 int, i329 int, i330 int, i331 int, i332 int, i333 int, i334
 
165
int, i335 int, i336 int, i337 int, i338 int, i339 int, i340 int, i341 int, i342
 
166
int, i343 int, i344 int, i345 int, i346 int, i347 int, i348 int, i349 int, i350
 
167
int, i351 int, i352 int, i353 int, i354 int, i355 int, i356 int, i357 int, i358
 
168
int, i359 int, i360 int, i361 int, i362 int, i363 int, i364 int, i365 int, i366
 
169
int, i367 int, i368 int, i369 int, i370 int, i371 int, i372 int, i373 int, i374
 
170
int, i375 int, i376 int, i377 int, i378 int, i379 int, i380 int, i381 int, i382
 
171
int, i383 int, i384 int, i385 int, i386 int, i387 int, i388 int, i389 int, i390
 
172
int, i391 int, i392 int, i393 int, i394 int, i395 int, i396 int, i397 int, i398
 
173
int, i399 int, i400 int, i401 int, i402 int, i403 int, i404 int, i405 int, i406
 
174
int, i407 int, i408 int, i409 int, i410 int, i411 int, i412 int, i413 int, i414
 
175
int, i415 int, i416 int, i417 int, i418 int, i419 int, i420 int, i421 int, i422
 
176
int, i423 int, i424 int, i425 int, i426 int, i427 int, i428 int, i429 int, i430
 
177
int, i431 int, i432 int, i433 int, i434 int, i435 int, i436 int, i437 int, i438
 
178
int, i439 int, i440 int, i441 int, i442 int, i443 int, i444 int, i445 int, i446
 
179
int, i447 int, i448 int, i449 int, i450 int, i451 int, i452 int, i453 int, i454
 
180
int, i455 int, i456 int, i457 int, i458 int, i459 int, i460 int, i461 int, i462
 
181
int, i463 int, i464 int, i465 int, i466 int, i467 int, i468 int, i469 int, i470
 
182
int, i471 int, i472 int, i473 int, i474 int, i475 int, i476 int, i477 int, i478
 
183
int, i479 int, i480 int, i481 int, i482 int, i483 int, i484 int, i485 int, i486
 
184
int, i487 int, i488 int, i489 int, i490 int, i491 int, i492 int, i493 int, i494
 
185
int, i495 int, i496 int, i497 int, i498 int, i499 int, i500 int, i501 int, i502
 
186
int, i503 int, i504 int, i505 int, i506 int, i507 int, i508 int, i509 int, i510
 
187
int, i511 int, i512 int, i513 int, i514 int, i515 int, i516 int, i517 int, i518
 
188
int, i519 int, i520 int, i521 int, i522 int, i523 int, i524 int, i525 int, i526
 
189
int, i527 int, i528 int, i529 int, i530 int, i531 int, i532 int, i533 int, i534
 
190
int, i535 int, i536 int, i537 int, i538 int, i539 int, i540 int, i541 int, i542
 
191
int, i543 int, i544 int, i545 int, i546 int, i547 int, i548 int, i549 int, i550
 
192
int, i551 int, i552 int, i553 int, i554 int, i555 int, i556 int, i557 int, i558
 
193
int, i559 int, i560 int, i561 int, i562 int, i563 int, i564 int, i565 int, i566
 
194
int, i567 int, i568 int, i569 int, i570 int, i571 int, i572 int, i573 int, i574
 
195
int, i575 int, i576 int, i577 int, i578 int, i579 int, i580 int, i581 int, i582
 
196
int, i583 int, i584 int, i585 int, i586 int, i587 int, i588 int, i589 int, i590
 
197
int, i591 int, i592 int, i593 int, i594 int, i595 int, i596 int, i597 int, i598
 
198
int, i599 int, i600 int, i601 int, i602 int, i603 int, i604 int, i605 int, i606
 
199
int, i607 int, i608 int, i609 int, i610 int, i611 int, i612 int, i613 int, i614
 
200
int, i615 int, i616 int, i617 int, i618 int, i619 int, i620 int, i621 int, i622
 
201
int, i623 int, i624 int, i625 int, i626 int, i627 int, i628 int, i629 int, i630
 
202
int, i631 int, i632 int, i633 int, i634 int, i635 int, i636 int, i637 int, i638
 
203
int, i639 int, i640 int, i641 int, i642 int, i643 int, i644 int, i645 int, i646
 
204
int, i647 int, i648 int, i649 int, i650 int, i651 int, i652 int, i653 int, i654
 
205
int, i655 int, i656 int, i657 int, i658 int, i659 int, i660 int, i661 int, i662
 
206
int, i663 int, i664 int, i665 int, i666 int, i667 int, i668 int, i669 int, i670
 
207
int, i671 int, i672 int, i673 int, i674 int, i675 int, i676 int, i677 int, i678
 
208
int, i679 int, i680 int, i681 int, i682 int, i683 int, i684 int, i685 int, i686
 
209
int, i687 int, i688 int, i689 int, i690 int, i691 int, i692 int, i693 int, i694
 
210
int, i695 int, i696 int, i697 int, i698 int, i699 int, i700 int, i701 int, i702
 
211
int, i703 int, i704 int, i705 int, i706 int, i707 int, i708 int, i709 int, i710
 
212
int, i711 int, i712 int, i713 int, i714 int, i715 int, i716 int, i717 int, i718
 
213
int, i719 int, i720 int, i721 int, i722 int, i723 int, i724 int, i725 int, i726
 
214
int, i727 int, i728 int, i729 int, i730 int, i731 int, i732 int, i733 int, i734
 
215
int, i735 int, i736 int, i737 int, i738 int, i739 int, i740 int, i741 int, i742
 
216
int, i743 int, i744 int, i745 int, i746 int, i747 int, i748 int, i749 int, i750
 
217
int, i751 int, i752 int, i753 int, i754 int, i755 int, i756 int, i757 int, i758
 
218
int, i759 int, i760 int, i761 int, i762 int, i763 int, i764 int, i765 int, i766
 
219
int, i767 int, i768 int, i769 int, i770 int, i771 int, i772 int, i773 int, i774
 
220
int, i775 int, i776 int, i777 int, i778 int, i779 int, i780 int, i781 int, i782
 
221
int, i783 int, i784 int, i785 int, i786 int, i787 int, i788 int, i789 int, i790
 
222
int, i791 int, i792 int, i793 int, i794 int, i795 int, i796 int, i797 int, i798
 
223
int, i799 int, i800 int, i801 int, i802 int, i803 int, i804 int, i805 int, i806
 
224
int, i807 int, i808 int, i809 int, i810 int, i811 int, i812 int, i813 int, i814
 
225
int, i815 int, i816 int, i817 int, i818 int, i819 int, i820 int, i821 int, i822
 
226
int, i823 int, i824 int, i825 int, i826 int, i827 int, i828 int, i829 int, i830
 
227
int, i831 int, i832 int, i833 int, i834 int, i835 int, i836 int, i837 int, i838
 
228
int, i839 int, i840 int, i841 int, i842 int, i843 int, i844 int, i845 int, i846
 
229
int, i847 int, i848 int, i849 int, i850 int, i851 int, i852 int, i853 int, i854
 
230
int, i855 int, i856 int, i857 int, i858 int, i859 int, i860 int, i861 int, i862
 
231
int, i863 int, i864 int, i865 int, i866 int, i867 int, i868 int, i869 int, i870
 
232
int, i871 int, i872 int, i873 int, i874 int, i875 int, i876 int, i877 int, i878
 
233
int, i879 int, i880 int, i881 int, i882 int, i883 int, i884 int, i885 int, i886
 
234
int, i887 int, i888 int, i889 int, i890 int, i891 int, i892 int, i893 int, i894
 
235
int, i895 int, i896 int, i897 int, i898 int, i899 int, i900 int, i901 int, i902
 
236
int, i903 int, i904 int, i905 int, i906 int, i907 int, i908 int, i909 int, i910
 
237
int, i911 int, i912 int, i913 int, i914 int, i915 int, i916 int, i917 int, i918
 
238
int, i919 int, i920 int, i921 int, i922 int, i923 int, i924 int, i925 int, i926
 
239
int, i927 int, i928 int, i929 int, i930 int, i931 int, i932 int, i933 int, i934
 
240
int, i935 int, i936 int, i937 int, i938 int, i939 int, i940 int, i941 int, i942
 
241
int, i943 int, i944 int, i945 int, i946 int, i947 int, i948 int, i949 int, i950
 
242
int, i951 int, i952 int, i953 int, i954 int, i955 int, i956 int, i957 int, i958
 
243
int, i959 int, i960 int, i961 int, i962 int, i963 int, i964 int, i965 int, i966
 
244
int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974
 
245
int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
 
246
int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
 
247
int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
 
248
int, i999 int, i1000 int, b blob) row_format=dynamic;
 
249
insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
250
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
251
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
252
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
253
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
254
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
255
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
256
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
257
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
258
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
259
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
260
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
261
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
262
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
263
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
264
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
265
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
266
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
267
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
268
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
269
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
270
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
271
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
272
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
273
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
274
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
275
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
276
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
277
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
278
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
279
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
280
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
281
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
282
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
283
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
284
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
285
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
286
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
287
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "Sergei");
 
288
update t1 set b=repeat('a',256);
 
289
update t1 set i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0;
 
290
check table t1;
 
291
Table   Op      Msg_type        Msg_text
 
292
test.t1 check   status  OK
 
293
delete from t1 where i8=1;
 
294
select i1,i2 from t1;
 
295
i1      i2
 
296
check table t1;
 
297
Table   Op      Msg_type        Msg_text
 
298
test.t1 check   status  OK
 
299
drop table t1;
 
300
CREATE TABLE `t1` (
 
301
`post_id` mediumint(8) unsigned NOT NULL auto_increment,
 
302
`topic_id` mediumint(8) unsigned NOT NULL default '0',
 
303
`post_time` datetime NOT NULL default '0000-00-00 00:00:00',
 
304
`post_text` text NOT NULL,
 
305
`icon_url` varchar(10) NOT NULL default '',
 
306
`sign` tinyint(1) unsigned NOT NULL default '0',
 
307
`post_edit` varchar(150) NOT NULL default '',
 
308
`poster_login` varchar(35) NOT NULL default '',
 
309
`ip` varchar(15) NOT NULL default '',
 
310
PRIMARY KEY  (`post_id`),
 
311
KEY `post_time` (`post_time`),
 
312
KEY `ip` (`ip`),
 
313
KEY `poster_login` (`poster_login`),
 
314
KEY `topic_id` (`topic_id`),
 
315
FULLTEXT KEY `post_text` (`post_text`)
 
316
) ENGINE=MyISAM;
 
317
INSERT INTO t1 (post_text) VALUES ('ceci est un test'),('ceci est un test'),('ceci est un test'),('ceci est un test'),('ceci est un test');
 
318
REPAIR TABLE t1;
 
319
Table   Op      Msg_type        Msg_text
 
320
test.t1 repair  status  OK
 
321
CHECK TABLE t1;
 
322
Table   Op      Msg_type        Msg_text
 
323
test.t1 check   status  OK
 
324
drop table t1;
 
325
CREATE TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300), KEY t1 (a, b, c, d, e));
 
326
ERROR 42000: Specified key was too long; max key length is 1332 bytes
 
327
CREATE TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300));
 
328
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
 
329
ERROR 42000: Specified key was too long; max key length is 1332 bytes
 
330
DROP TABLE t1;
 
331
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a));
 
332
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
 
333
create table t2 (a int not null, b int, c int, key(b), key(c), key(a));
 
334
INSERT into t2 values (1,1,1), (2,2,2);
 
335
optimize table t1;
 
336
Table   Op      Msg_type        Msg_text
 
337
test.t1 optimize        status  OK
 
338
show index from t1;
 
339
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
340
t1      1       b       1       b       A       5       NULL    NULL    YES     BTREE           
 
341
t1      1       c       1       c       A       5       NULL    NULL    YES     BTREE           
 
342
t1      1       a       1       a       A       1       NULL    NULL            BTREE           
 
343
t1      1       a       2       b       A       5       NULL    NULL    YES     BTREE           
 
344
t1      1       c_2     1       c       A       5       NULL    NULL    YES     BTREE           
 
345
t1      1       c_2     2       a       A       5       NULL    NULL            BTREE           
 
346
explain select * from t1,t2 where t1.a=t2.a;
 
347
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
348
1       SIMPLE  t2      ALL     a       NULL    NULL    NULL    2       
 
349
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    5       Using where; Using join buffer
 
350
explain select * from t1,t2 force index(a) where t1.a=t2.a;
 
351
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
352
1       SIMPLE  t2      ALL     a       NULL    NULL    NULL    2       
 
353
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    5       Using where; Using join buffer
 
354
explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a;
 
355
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
356
1       SIMPLE  t2      ALL     a       NULL    NULL    NULL    2       
 
357
1       SIMPLE  t1      ref     a       a       4       test.t2.a       3       
 
358
explain select * from t1,t2 where t1.b=t2.b;
 
359
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
360
1       SIMPLE  t2      ALL     b       NULL    NULL    NULL    2       
 
361
1       SIMPLE  t1      ref     b       b       5       test.t2.b       1       
 
362
explain select * from t1,t2 force index(c) where t1.a=t2.a;
 
363
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
364
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    2       
 
365
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    5       Using where; Using join buffer
 
366
explain select * from t1 where a=0 or a=2;
 
367
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
368
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    5       Using where
 
369
explain select * from t1 force index (a) where a=0 or a=2;
 
370
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
371
1       SIMPLE  t1      range   a       a       4       NULL    4       Using index condition; Using MRR
 
372
explain select * from t1 where c=1;
 
373
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
374
1       SIMPLE  t1      ref     c,c_2   c       5       const   1       
 
375
explain select * from t1 use index() where c=1;
 
376
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
377
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    5       Using where
 
378
drop table t1,t2;
 
379
create table t1 (a int not null auto_increment primary key, b varchar(255));
 
380
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
 
381
update t1 set b=repeat(left(b,1),200) where a=1;
 
382
delete from t1 where (a & 1)= 0;
 
383
update t1 set b=repeat('e',200) where a=1;
 
384
flush tables;
 
385
check table t1;
 
386
Table   Op      Msg_type        Msg_text
 
387
test.t1 check   status  OK
 
388
update t1 set b=repeat(left(b,1),255) where a between 1 and 5;
 
389
update t1 set b=repeat(left(b,1),10) where a between 32 and 43;
 
390
update t1 set b=repeat(left(b,1),2) where a between 64 and 66;
 
391
update t1 set b=repeat(left(b,1),65) where a between 67 and 70;
 
392
check table t1;
 
393
Table   Op      Msg_type        Msg_text
 
394
test.t1 check   status  OK
 
395
insert into t1 (b) values (repeat('z',100));
 
396
update t1 set b="test" where left(b,1) > 'n';
 
397
check table t1;
 
398
Table   Op      Msg_type        Msg_text
 
399
test.t1 check   status  OK
 
400
drop table t1;
 
401
create table t1 ( a text not null, key a (a(20)));
 
402
insert into t1 values ('aaa   '),('aaa'),('aa');
 
403
check table t1;
 
404
Table   Op      Msg_type        Msg_text
 
405
test.t1 check   status  OK
 
406
repair table t1;
 
407
Table   Op      Msg_type        Msg_text
 
408
test.t1 repair  status  OK
 
409
select concat(a,'.') from t1 where a='aaa';
 
410
concat(a,'.')
 
411
aaa   .
 
412
aaa.
 
413
select concat(a,'.') from t1 where binary a='aaa';
 
414
concat(a,'.')
 
415
aaa.
 
416
update t1 set a='bbb' where a='aaa';
 
417
select concat(a,'.') from t1;
 
418
concat(a,'.')
 
419
bbb.
 
420
bbb.
 
421
aa.
 
422
drop table t1;
 
423
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10)));
 
424
insert into t1 values('807780', '477', '165');
 
425
insert into t1 values('807780', '477', '162');
 
426
insert into t1 values('807780', '472', '162');
 
427
select * from t1 where a='807780' and b='477' and c='165';
 
428
a       b       c
 
429
807780  477     165
 
430
drop table t1;
 
431
DROP TABLE IF EXISTS t1;
 
432
Warnings:
 
433
Note    1051    Unknown table 't1'
 
434
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a));
 
435
INSERT t1 VALUES ("can \tcan");
 
436
INSERT t1 VALUES ("can   can");
 
437
INSERT t1 VALUES ("can");
 
438
SELECT * FROM t1;
 
439
a
 
440
can     can
 
441
can
 
442
can   can
 
443
CHECK TABLE t1;
 
444
Table   Op      Msg_type        Msg_text
 
445
test.t1 check   status  OK
 
446
DROP TABLE t1;
 
447
create table t1 (a blob);
 
448
insert into t1 values('a '),('a');
 
449
select concat(a,'.') from t1 where a='a';
 
450
concat(a,'.')
 
451
a.
 
452
select concat(a,'.') from t1 where a='a ';
 
453
concat(a,'.')
 
454
a .
 
455
alter table t1 add key(a(2));
 
456
select concat(a,'.') from t1 where a='a';
 
457
concat(a,'.')
 
458
a.
 
459
select concat(a,'.') from t1 where a='a ';
 
460
concat(a,'.')
 
461
a .
 
462
drop table t1;
 
463
create table t1 (a int not null auto_increment primary key, b text not null, unique b (b(20)));
 
464
insert into t1 (b) values ('a'),('b'),('c');
 
465
select concat(b,'.') from t1;
 
466
concat(b,'.')
 
467
a.
 
468
b.
 
469
c.
 
470
update t1 set b='b ' where a=2;
 
471
update t1 set b='b  ' where a > 1;
 
472
ERROR 23000: Duplicate entry 'b  ' for key 'b'
 
473
insert into t1 (b) values ('b');
 
474
ERROR 23000: Duplicate entry 'b' for key 'b'
 
475
select * from t1;
 
476
a       b
 
477
1       a
 
478
2       b  
 
479
3       c
 
480
delete from t1 where b='b';
 
481
select a,concat(b,'.') from t1;
 
482
a       concat(b,'.')
 
483
1       a.
 
484
3       c.
 
485
drop table t1;
 
486
create table t1 (a int not null);
 
487
create table t2 (a int not null, primary key (a));
 
488
insert into t1 values (1);
 
489
insert into t2 values (1),(2);
 
490
select sql_big_result distinct t1.a from t1,t2 order by t2.a;
 
491
a
 
492
1
 
493
select distinct t1.a from t1,t2 order by t2.a;
 
494
a
 
495
1
 
496
select sql_big_result distinct t1.a from t1,t2;
 
497
a
 
498
1
 
499
explain select sql_big_result distinct t1.a from t1,t2 order by t2.a;
 
500
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
501
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       Using temporary
 
502
1       SIMPLE  t2      index   NULL    PRIMARY 4       NULL    2       Using index; Distinct
 
503
explain select distinct t1.a from t1,t2 order by t2.a;
 
504
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
505
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       Using temporary
 
506
1       SIMPLE  t2      index   NULL    PRIMARY 4       NULL    2       Using index; Distinct
 
507
drop table t1,t2;
 
508
create table t1 (
 
509
c1 varchar(32),
 
510
key (c1)
 
511
) engine=myisam;
 
512
alter table t1 disable keys;
 
513
insert into t1 values ('a'), ('b');
 
514
select c1 from t1 order by c1 limit 1;
 
515
c1
 
516
a
 
517
drop table t1;
 
518
create table t1 (a int not null, primary key(a));
 
519
create table t2 (a int not null, b int not null, primary key(a,b));
 
520
insert into t1 values (1),(2),(3),(4),(5),(6);
 
521
insert into t2 values (1,1),(2,1);
 
522
lock tables t1 read local, t2 read local;
 
523
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
 
524
a       a       b
 
525
1       1       1
 
526
2       2       1
 
527
insert into t2 values(2,0);
 
528
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
 
529
a       a       b
 
530
1       1       1
 
531
2       2       1
 
532
unlock tables;
 
533
drop table t1,t2;
 
534
CREATE TABLE t1 (c1 varchar(250) NOT NULL);
 
535
CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
 
536
INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
 
537
INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
 
538
LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
 
539
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
 
540
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
 
541
t1c1    t2c1
 
542
INSERT INTO t2 VALUES ('test000001'), ('test000005');
 
543
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
 
544
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
 
545
t1c1    t2c1
 
546
UNLOCK TABLES;
 
547
DROP TABLE t1,t2;
 
548
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM;
 
549
Got one of the listed errors
 
550
create table t1 (a int, b varchar(200), c text not null) checksum=1;
 
551
create table t2 (a int, b varchar(200), c text not null) checksum=0;
 
552
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
 
553
insert t2 select * from t1;
 
554
checksum table t1, t2, t3 quick;
 
555
Table   Checksum
 
556
test.t1 2948697075
 
557
test.t2 NULL
 
558
test.t3 NULL
 
559
Warnings:
 
560
Error   1146    Table 'test.t3' doesn't exist
 
561
checksum table t1, t2, t3;
 
562
Table   Checksum
 
563
test.t1 2948697075
 
564
test.t2 2948697075
 
565
test.t3 NULL
 
566
Warnings:
 
567
Error   1146    Table 'test.t3' doesn't exist
 
568
checksum table t1, t2, t3 extended;
 
569
Table   Checksum
 
570
test.t1 2948697075
 
571
test.t2 2948697075
 
572
test.t3 NULL
 
573
Warnings:
 
574
Error   1146    Table 'test.t3' doesn't exist
 
575
drop table t1,t2;
 
576
create table t1 (a int, key (a));
 
577
show keys from t1;
 
578
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
579
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
 
580
alter table t1 disable keys;
 
581
show keys from t1;
 
582
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
583
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE   disabled        
 
584
create table t2 (a int);
 
585
set @@rand_seed1=31415926,@@rand_seed2=2718281828;
 
586
insert t1 select * from t2;
 
587
show keys from t1;
 
588
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
589
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE   disabled        
 
590
alter table t1 enable keys;
 
591
show keys from t1;
 
592
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
593
t1      1       a       1       a       A       1000    NULL    NULL    YES     BTREE           
 
594
alter table t1 engine=heap;
 
595
alter table t1 disable keys;
 
596
Warnings:
 
597
Note    1031    Table storage engine for 't1' doesn't have this option
 
598
show keys from t1;
 
599
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
600
t1      1       a       1       a       NULL    500     NULL    NULL    YES     HASH            
 
601
drop table t1,t2;
 
602
create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
 
603
insert into t1 values (null,''), (null,'');
 
604
explain select count(*) from t1 where a is null;
 
605
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
606
1       SIMPLE  t1      ref     idx     idx     4       const   1       Using where
 
607
select count(*) from t1 where a is null;
 
608
count(*)
 
609
2
 
610
drop table t1;
 
611
create table t1 (c1 int, c2 varchar(4) not null default '',
 
612
key(c2(3))) default charset=utf8;
 
613
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
 
614
update t1 set c2='A  B' where c1=2;
 
615
check table t1;
 
616
Table   Op      Msg_type        Msg_text
 
617
test.t1 check   status  OK
 
618
drop table t1;
 
619
create table t1 (c1 int);
 
620
insert into t1 values (1),(2),(3),(4);
 
621
checksum table t1;
 
622
Table   Checksum
 
623
test.t1 149057747
 
624
delete from t1 where c1 = 1;
 
625
create table t2 as select * from t1;
 
626
checksum table t1;
 
627
Table   Checksum
 
628
test.t1 984116287
 
629
checksum table t2;
 
630
Table   Checksum
 
631
test.t2 984116287
 
632
drop table t1, t2;
 
633
show variables like 'myisam_stats_method';
 
634
Variable_name   Value
 
635
myisam_stats_method     nulls_unequal
 
636
create table t1 (a int, key(a));
 
637
insert into t1 values (0),(1),(2),(3),(4);
 
638
insert into t1 select NULL from t1;
 
639
analyze table t1;
 
640
Table   Op      Msg_type        Msg_text
 
641
test.t1 analyze status  OK
 
642
show index from t1;
 
643
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
644
t1      1       a       1       a       A       10      NULL    NULL    YES     BTREE           
 
645
insert into t1 values (11);
 
646
delete from t1 where a=11;
 
647
check table t1;
 
648
Table   Op      Msg_type        Msg_text
 
649
test.t1 check   status  OK
 
650
show index from t1;
 
651
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
652
t1      1       a       1       a       A       10      NULL    NULL    YES     BTREE           
 
653
set myisam_stats_method=nulls_equal;
 
654
show variables like 'myisam_stats_method';
 
655
Variable_name   Value
 
656
myisam_stats_method     nulls_equal
 
657
insert into t1 values (11);
 
658
delete from t1 where a=11;
 
659
analyze table t1;
 
660
Table   Op      Msg_type        Msg_text
 
661
test.t1 analyze status  OK
 
662
show index from t1;
 
663
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
664
t1      1       a       1       a       A       5       NULL    NULL    YES     BTREE           
 
665
insert into t1 values (11);
 
666
delete from t1 where a=11;
 
667
check table t1;
 
668
Table   Op      Msg_type        Msg_text
 
669
test.t1 check   status  OK
 
670
show index from t1;
 
671
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
672
t1      1       a       1       a       A       5       NULL    NULL    YES     BTREE           
 
673
set myisam_stats_method=DEFAULT;
 
674
show variables like 'myisam_stats_method';
 
675
Variable_name   Value
 
676
myisam_stats_method     nulls_unequal
 
677
insert into t1 values (11);
 
678
delete from t1 where a=11;
 
679
analyze table t1;
 
680
Table   Op      Msg_type        Msg_text
 
681
test.t1 analyze status  OK
 
682
show index from t1;
 
683
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
684
t1      1       a       1       a       A       10      NULL    NULL    YES     BTREE           
 
685
insert into t1 values (11);
 
686
delete from t1 where a=11;
 
687
check table t1;
 
688
Table   Op      Msg_type        Msg_text
 
689
test.t1 check   status  OK
 
690
show index from t1;
 
691
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
692
t1      1       a       1       a       A       10      NULL    NULL    YES     BTREE           
 
693
drop table t1;
 
694
set myisam_stats_method=nulls_ignored;
 
695
show variables like 'myisam_stats_method';
 
696
Variable_name   Value
 
697
myisam_stats_method     nulls_ignored
 
698
create table t1 (
 
699
a char(3), b char(4), c char(5), d char(6),
 
700
key(a,b,c,d)
 
701
);
 
702
insert into t1 values ('bcd','def1', NULL, 'zz');
 
703
insert into t1 values ('bcd','def2', NULL, 'zz');
 
704
insert into t1 values ('bce','def1', 'yuu', NULL);
 
705
insert into t1 values ('bce','def2', NULL, 'quux');
 
706
analyze table t1;
 
707
Table   Op      Msg_type        Msg_text
 
708
test.t1 analyze status  OK
 
709
show index from t1;
 
710
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
711
t1      1       a       1       a       A       2       NULL    NULL    YES     BTREE           
 
712
t1      1       a       2       b       A       4       NULL    NULL    YES     BTREE           
 
713
t1      1       a       3       c       A       4       NULL    NULL    YES     BTREE           
 
714
t1      1       a       4       d       A       4       NULL    NULL    YES     BTREE           
 
715
delete from t1;
 
716
analyze table t1;
 
717
Table   Op      Msg_type        Msg_text
 
718
test.t1 analyze status  OK
 
719
show index from t1;
 
720
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
721
t1      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
 
722
t1      1       a       2       b       A       0       NULL    NULL    YES     BTREE           
 
723
t1      1       a       3       c       A       0       NULL    NULL    YES     BTREE           
 
724
t1      1       a       4       d       A       0       NULL    NULL    YES     BTREE           
 
725
set myisam_stats_method=DEFAULT;
 
726
drop table t1;
 
727
create table t1(
 
728
cip INT NOT NULL,
 
729
time TIME NOT NULL,
 
730
score INT NOT NULL DEFAULT 0,
 
731
bob TINYBLOB
 
732
);
 
733
insert into t1 (cip, time) VALUES (1, '00:01'), (2, '00:02'), (3,'00:03');
 
734
insert into t1 (cip, bob, time) VALUES (4, 'a', '00:04'), (5, 'b', '00:05'), 
 
735
(6, 'c', '00:06');
 
736
select * from t1 where bob is null and cip=1;
 
737
cip     time    score   bob
 
738
1       00:01:00        0       NULL
 
739
create index bug on t1 (bob(22), cip, time);
 
740
select * from t1 where bob is null and cip=1;
 
741
cip     time    score   bob
 
742
1       00:01:00        0       NULL
 
743
drop table t1;
 
744
create table t1 (
 
745
id1 int not null auto_increment,
 
746
id2 int not null default '0',
 
747
t text not null,
 
748
primary key  (id1),
 
749
key x (id2, t(32))
 
750
) engine=myisam;
 
751
insert into t1 (id2, t) values
 
752
(10, 'abc'), (10, 'abc'), (10, 'abc'),
 
753
(20, 'abc'), (20, 'abc'), (20, 'def'),
 
754
(10, 'abc'), (10, 'abc');
 
755
select count(*)   from t1 where id2 = 10;
 
756
count(*)
 
757
5
 
758
select count(id1) from t1 where id2 = 10;
 
759
count(id1)
 
760
5
 
761
drop table t1;
 
762
CREATE TABLE t1(a TINYINT, KEY(a)) ENGINE=MyISAM;
 
763
INSERT INTO t1 VALUES(1);
 
764
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
 
765
MAX(a)
 
766
1
 
767
ALTER TABLE t1 DISABLE KEYS;
 
768
SELECT MAX(a) FROM t1;
 
769
MAX(a)
 
770
1
 
771
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
 
772
MAX(a)
 
773
1
 
774
DROP TABLE t1;
 
775
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
 
776
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
 
777
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
 
778
SELECT * FROM t1;
 
779
a       b
 
780
xxxxxxxxx       bbbbbb
 
781
xxxxxxxxx       bbbbbb
 
782
DROP TABLE t1;
 
783
SET @@myisam_repair_threads=2;
 
784
SHOW VARIABLES LIKE 'myisam_repair%';
 
785
Variable_name   Value
 
786
myisam_repair_threads   2
 
787
CREATE TABLE t1 (
 
788
`_id` int(11) NOT NULL default '0',
 
789
`url` text,
 
790
`email` text,
 
791
`description` text,
 
792
`loverlap` int(11) default NULL,
 
793
`roverlap` int(11) default NULL,
 
794
`lneighbor_id` int(11) default NULL,
 
795
`rneighbor_id` int(11) default NULL,
 
796
`length_` int(11) default NULL,
 
797
`sequence` mediumtext,
 
798
`name` text,
 
799
`_obj_class` text NOT NULL,
 
800
PRIMARY KEY  (`_id`),
 
801
UNIQUE KEY `sequence_name_index` (`name`(50)),
 
802
KEY (`length_`)
 
803
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
804
INSERT INTO t1 VALUES
 
805
(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
 
806
(2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
 
807
(3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
 
808
(4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
 
809
(5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
 
810
(6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
 
811
(7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
 
812
(8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
 
813
(9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
 
814
SELECT _id FROM t1;
 
815
_id
 
816
1
 
817
2
 
818
3
 
819
4
 
820
5
 
821
6
 
822
7
 
823
8
 
824
9
 
825
DELETE FROM t1 WHERE _id < 8;
 
826
SHOW TABLE STATUS LIKE 't1';
 
827
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
828
t1      MyISAM  10      Dynamic 2       #       #       #       #       140     #       #       #       #       #       #               
 
829
CHECK TABLE t1 EXTENDED;
 
830
Table   Op      Msg_type        Msg_text
 
831
test.t1 check   status  OK
 
832
OPTIMIZE TABLE t1;
 
833
Table   Op      Msg_type        Msg_text
 
834
test.t1 optimize        status  OK
 
835
CHECK TABLE t1 EXTENDED;
 
836
Table   Op      Msg_type        Msg_text
 
837
test.t1 check   status  OK
 
838
SHOW TABLE STATUS LIKE 't1';
 
839
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
840
t1      MyISAM  10      Dynamic 2       #       #       #       #       0       #       #       #       #       #       #               
 
841
SELECT _id FROM t1;
 
842
_id
 
843
8
 
844
9
 
845
DROP TABLE t1;
 
846
CREATE TABLE t1 (
 
847
`_id` int(11) NOT NULL default '0',
 
848
`url` text,
 
849
`email` text,
 
850
`description` text,
 
851
`loverlap` int(11) default NULL,
 
852
`roverlap` int(11) default NULL,
 
853
`lneighbor_id` int(11) default NULL,
 
854
`rneighbor_id` int(11) default NULL,
 
855
`length_` int(11) default NULL,
 
856
`sequence` mediumtext,
 
857
`name` text,
 
858
`_obj_class` text NOT NULL,
 
859
PRIMARY KEY  (`_id`),
 
860
UNIQUE KEY `sequence_name_index` (`name`(50)),
 
861
KEY (`length_`)
 
862
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
863
INSERT INTO t1 VALUES
 
864
(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
 
865
(2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
 
866
(3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
 
867
(4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
 
868
(5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
 
869
(6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
 
870
(7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
 
871
(8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
 
872
(9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
 
873
SELECT _id FROM t1;
 
874
_id
 
875
1
 
876
2
 
877
3
 
878
4
 
879
5
 
880
6
 
881
7
 
882
8
 
883
9
 
884
DELETE FROM t1 WHERE _id < 8;
 
885
SHOW TABLE STATUS LIKE 't1';
 
886
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
887
t1      MyISAM  10      Dynamic 2       #       #       #       #       140     #       #       #       #       #       #               
 
888
CHECK TABLE t1 EXTENDED;
 
889
Table   Op      Msg_type        Msg_text
 
890
test.t1 check   status  OK
 
891
REPAIR TABLE t1 QUICK;
 
892
Table   Op      Msg_type        Msg_text
 
893
test.t1 repair  status  OK
 
894
CHECK TABLE t1 EXTENDED;
 
895
Table   Op      Msg_type        Msg_text
 
896
test.t1 check   status  OK
 
897
SHOW TABLE STATUS LIKE 't1';
 
898
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
899
t1      MyISAM  10      Dynamic 2       #       #       #       #       140     #       #       #       #       #       #               
 
900
SELECT _id FROM t1;
 
901
_id
 
902
8
 
903
9
 
904
DROP TABLE t1;
 
905
SET @@myisam_repair_threads=1;
 
906
SHOW VARIABLES LIKE 'myisam_repair%';
 
907
Variable_name   Value
 
908
myisam_repair_threads   1
 
909
CREATE TABLE t1(a VARCHAR(16));
 
910
INSERT INTO t1 VALUES('aaaaaaaa'),(NULL);
 
911
UPDATE t1 AS ta1, t1 AS ta2 SET ta1.a='aaaaaaaaaaaaaaaa';
 
912
SELECT * FROM t1;
 
913
a
 
914
aaaaaaaaaaaaaaaa
 
915
aaaaaaaaaaaaaaaa
 
916
DROP TABLE t1;
 
917
CREATE TABLE t1(a INT);
 
918
INSERT INTO t1 VALUES(1),(2);
 
919
UPDATE t1,t1 AS t2 SET t1.a=t1.a+2 WHERE t1.a=t2.a-1;
 
920
SELECT * FROM t1 ORDER BY a;
 
921
a
 
922
2
 
923
3
 
924
DROP TABLE t1;
 
925
CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
 
926
SHOW TABLE STATUS LIKE 't1';
 
927
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
928
t1      MyISAM  10      Dynamic X       X       X       72057594037927935       X       X       X       X       X       X       latin1_swedish_ci       X       max_rows=4100100100 avg_row_length=70100        
 
929
DROP TABLE t1;
 
930
CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
 
931
INSERT INTO t1 VALUES
 
932
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
933
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
934
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
935
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
936
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
937
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
938
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
939
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
940
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
941
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
942
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
943
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
944
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
945
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
946
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
947
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
948
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
949
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
950
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
951
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
952
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
953
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
954
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
955
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
956
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
957
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
958
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
959
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
960
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
961
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
962
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
963
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
964
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
965
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
966
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
967
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
968
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
969
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
970
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
971
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
972
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
973
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
974
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
975
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
976
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
977
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
978
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
979
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
980
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
981
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
982
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
983
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
984
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
985
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
986
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
987
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
988
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
989
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
990
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
991
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
992
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
993
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
994
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
995
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
996
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
997
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
998
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
999
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1000
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1001
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1002
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1003
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1004
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1005
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1006
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1007
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1008
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1009
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1010
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1011
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1012
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1013
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1014
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1015
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1016
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1017
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1018
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1019
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1020
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1021
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1022
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1023
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1024
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1025
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1026
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1027
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1028
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1029
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1030
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1031
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1032
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1033
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1034
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1035
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1036
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1037
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1038
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1039
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1040
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1041
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1042
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1043
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1044
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1045
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1046
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1047
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1048
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1049
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1050
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1051
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1052
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1053
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1054
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1055
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1056
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1057
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1058
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1059
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
 
1060
(''), (''), (''), (''),
 
1061
(' B'), (' B'), (' B'), (' B');
 
1062
SELECT DISTINCT COUNT(*) FROM t1 WHERE c1 = '';
 
1063
COUNT(*)
 
1064
4
 
1065
SELECT DISTINCT length(c1), c1 FROM t1 WHERE c1 = '';
 
1066
length(c1)      c1
 
1067
0       
 
1068
SELECT DISTINCT COUNT(*) FROM t1 IGNORE INDEX (c1) WHERE c1 = '';
 
1069
COUNT(*)
 
1070
4
 
1071
SELECT DISTINCT length(c1), c1 FROM t1 IGNORE INDEX (c1) WHERE c1 = '';
 
1072
length(c1)      c1
 
1073
0       
 
1074
SELECT DISTINCT length(c1), c1 FROM t1 ORDER BY c1;
 
1075
length(c1)      c1
 
1076
0       
 
1077
2               A
 
1078
2        B
 
1079
DROP TABLE t1;
 
1080
End of 4.1 tests
 
1081
set storage_engine=MyISAM;
 
1082
drop table if exists t1,t2,t3;
 
1083
--- Testing varchar ---
 
1084
--- Testing varchar ---
 
1085
create table t1 (v varchar(10), c char(10), t text);
 
1086
insert into t1 values('+ ', '+ ', '+ ');
 
1087
set @a=repeat(' ',20);
 
1088
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
 
1089
Warnings:
 
1090
Note    1265    Data truncated for column 'v' at row 1
 
1091
Note    1265    Data truncated for column 'c' at row 1
 
1092
select concat('*',v,'*',c,'*',t,'*') from t1;
 
1093
concat('*',v,'*',c,'*',t,'*')
 
1094
*+ *+*+ *
 
1095
*+         *+*+                    *
 
1096
show create table t1;
 
1097
Table   Create Table
 
1098
t1      CREATE TABLE `t1` (
 
1099
  `v` varchar(10) DEFAULT NULL,
 
1100
  `c` char(10) DEFAULT NULL,
 
1101
  `t` text
 
1102
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1103
create table t2 like t1;
 
1104
show create table t2;
 
1105
Table   Create Table
 
1106
t2      CREATE TABLE `t2` (
 
1107
  `v` varchar(10) DEFAULT NULL,
 
1108
  `c` char(10) DEFAULT NULL,
 
1109
  `t` text
 
1110
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1111
create table t3 select * from t1;
 
1112
show create table t3;
 
1113
Table   Create Table
 
1114
t3      CREATE TABLE `t3` (
 
1115
  `v` varchar(10) DEFAULT NULL,
 
1116
  `c` char(10) DEFAULT NULL,
 
1117
  `t` text
 
1118
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1119
alter table t1 modify c varchar(10);
 
1120
show create table t1;
 
1121
Table   Create Table
 
1122
t1      CREATE TABLE `t1` (
 
1123
  `v` varchar(10) DEFAULT NULL,
 
1124
  `c` varchar(10) DEFAULT NULL,
 
1125
  `t` text
 
1126
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1127
alter table t1 modify v char(10);
 
1128
show create table t1;
 
1129
Table   Create Table
 
1130
t1      CREATE TABLE `t1` (
 
1131
  `v` char(10) DEFAULT NULL,
 
1132
  `c` varchar(10) DEFAULT NULL,
 
1133
  `t` text
 
1134
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1135
alter table t1 modify t varchar(10);
 
1136
Warnings:
 
1137
Note    1265    Data truncated for column 't' at row 2
 
1138
show create table t1;
 
1139
Table   Create Table
 
1140
t1      CREATE TABLE `t1` (
 
1141
  `v` char(10) DEFAULT NULL,
 
1142
  `c` varchar(10) DEFAULT NULL,
 
1143
  `t` varchar(10) DEFAULT NULL
 
1144
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1145
select concat('*',v,'*',c,'*',t,'*') from t1;
 
1146
concat('*',v,'*',c,'*',t,'*')
 
1147
*+*+*+ *
 
1148
*+*+*+         *
 
1149
drop table t1,t2,t3;
 
1150
create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
 
1151
show create table t1;
 
1152
Table   Create Table
 
1153
t1      CREATE TABLE `t1` (
 
1154
  `v` varchar(10) DEFAULT NULL,
 
1155
  `c` char(10) DEFAULT NULL,
 
1156
  `t` text,
 
1157
  KEY `v` (`v`),
 
1158
  KEY `c` (`c`),
 
1159
  KEY `t` (`t`(10))
 
1160
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1161
select count(*) from t1;
 
1162
count(*)
 
1163
270
 
1164
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
 
1165
select count(*) from t1 where v='a';
 
1166
count(*)
 
1167
10
 
1168
select count(*) from t1 where c='a';
 
1169
count(*)
 
1170
10
 
1171
select count(*) from t1 where t='a';
 
1172
count(*)
 
1173
10
 
1174
select count(*) from t1 where v='a  ';
 
1175
count(*)
 
1176
10
 
1177
select count(*) from t1 where c='a  ';
 
1178
count(*)
 
1179
10
 
1180
select count(*) from t1 where t='a  ';
 
1181
count(*)
 
1182
10
 
1183
select count(*) from t1 where v between 'a' and 'a ';
 
1184
count(*)
 
1185
10
 
1186
select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
1187
count(*)
 
1188
10
 
1189
select count(*) from t1 where v like 'a%';
 
1190
count(*)
 
1191
11
 
1192
select count(*) from t1 where c like 'a%';
 
1193
count(*)
 
1194
11
 
1195
select count(*) from t1 where t like 'a%';
 
1196
count(*)
 
1197
11
 
1198
select count(*) from t1 where v like 'a %';
 
1199
count(*)
 
1200
9
 
1201
explain select count(*) from t1 where v='a  ';
 
1202
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1203
1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
 
1204
explain select count(*) from t1 where c='a  ';
 
1205
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1206
1       SIMPLE  t1      ref     c       c       11      const   #       Using where; Using index
 
1207
explain select count(*) from t1 where t='a  ';
 
1208
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1209
1       SIMPLE  t1      ref     t       t       13      const   #       Using where
 
1210
explain select count(*) from t1 where v like 'a%';
 
1211
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1212
1       SIMPLE  t1      range   v       v       13      NULL    #       Using where; Using index
 
1213
explain select count(*) from t1 where v between 'a' and 'a ';
 
1214
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1215
1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
 
1216
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
1217
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1218
1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
 
1219
alter table t1 add unique(v);
 
1220
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
 
1221
alter table t1 add key(v);
 
1222
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
 
1223
qq
 
1224
*a*a*a*
 
1225
*a *a*a *
 
1226
*a  *a*a  *
 
1227
*a   *a*a   *
 
1228
*a    *a*a    *
 
1229
*a     *a*a     *
 
1230
*a      *a*a      *
 
1231
*a       *a*a       *
 
1232
*a        *a*a        *
 
1233
*a         *a*a         *
 
1234
explain select * from t1 where v='a';
 
1235
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1236
1       SIMPLE  t1      ref     v,v_2   #       13      const   #       Using index condition
 
1237
select v,count(*) from t1 group by v limit 10;
 
1238
v       count(*)
 
1239
a      1
 
1240
a       10
 
1241
b       10
 
1242
c       10
 
1243
d       10
 
1244
e       10
 
1245
f       10
 
1246
g       10
 
1247
h       10
 
1248
i       10
 
1249
select v,count(t) from t1 group by v limit 10;
 
1250
v       count(t)
 
1251
a      1
 
1252
a       10
 
1253
b       10
 
1254
c       10
 
1255
d       10
 
1256
e       10
 
1257
f       10
 
1258
g       10
 
1259
h       10
 
1260
i       10
 
1261
select v,count(c) from t1 group by v limit 10;
 
1262
v       count(c)
 
1263
a      1
 
1264
a       10
 
1265
b       10
 
1266
c       10
 
1267
d       10
 
1268
e       10
 
1269
f       10
 
1270
g       10
 
1271
h       10
 
1272
i       10
 
1273
select sql_big_result v,count(t) from t1 group by v limit 10;
 
1274
v       count(t)
 
1275
a      1
 
1276
a       10
 
1277
b       10
 
1278
c       10
 
1279
d       10
 
1280
e       10
 
1281
f       10
 
1282
g       10
 
1283
h       10
 
1284
i       10
 
1285
select sql_big_result v,count(c) from t1 group by v limit 10;
 
1286
v       count(c)
 
1287
a      1
 
1288
a       10
 
1289
b       10
 
1290
c       10
 
1291
d       10
 
1292
e       10
 
1293
f       10
 
1294
g       10
 
1295
h       10
 
1296
i       10
 
1297
select c,count(*) from t1 group by c limit 10;
 
1298
c       count(*)
 
1299
a      1
 
1300
a       10
 
1301
b       10
 
1302
c       10
 
1303
d       10
 
1304
e       10
 
1305
f       10
 
1306
g       10
 
1307
h       10
 
1308
i       10
 
1309
select c,count(t) from t1 group by c limit 10;
 
1310
c       count(t)
 
1311
a      1
 
1312
a       10
 
1313
b       10
 
1314
c       10
 
1315
d       10
 
1316
e       10
 
1317
f       10
 
1318
g       10
 
1319
h       10
 
1320
i       10
 
1321
select sql_big_result c,count(t) from t1 group by c limit 10;
 
1322
c       count(t)
 
1323
a      1
 
1324
a       10
 
1325
b       10
 
1326
c       10
 
1327
d       10
 
1328
e       10
 
1329
f       10
 
1330
g       10
 
1331
h       10
 
1332
i       10
 
1333
select t,count(*) from t1 group by t limit 10;
 
1334
t       count(*)
 
1335
a      1
 
1336
a       10
 
1337
b       10
 
1338
c       10
 
1339
d       10
 
1340
e       10
 
1341
f       10
 
1342
g       10
 
1343
h       10
 
1344
i       10
 
1345
select t,count(t) from t1 group by t limit 10;
 
1346
t       count(t)
 
1347
a      1
 
1348
a       10
 
1349
b       10
 
1350
c       10
 
1351
d       10
 
1352
e       10
 
1353
f       10
 
1354
g       10
 
1355
h       10
 
1356
i       10
 
1357
select sql_big_result t,count(t) from t1 group by t limit 10;
 
1358
t       count(t)
 
1359
a      1
 
1360
a       10
 
1361
b       10
 
1362
c       10
 
1363
d       10
 
1364
e       10
 
1365
f       10
 
1366
g       10
 
1367
h       10
 
1368
i       10
 
1369
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
 
1370
show create table t1;
 
1371
Table   Create Table
 
1372
t1      CREATE TABLE `t1` (
 
1373
  `v` varchar(300) DEFAULT NULL,
 
1374
  `c` char(10) DEFAULT NULL,
 
1375
  `t` text,
 
1376
  KEY `c` (`c`),
 
1377
  KEY `t` (`t`(10)),
 
1378
  KEY `v` (`v`)
 
1379
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1380
select count(*) from t1 where v='a';
 
1381
count(*)
 
1382
10
 
1383
select count(*) from t1 where v='a  ';
 
1384
count(*)
 
1385
10
 
1386
select count(*) from t1 where v between 'a' and 'a ';
 
1387
count(*)
 
1388
10
 
1389
select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
1390
count(*)
 
1391
10
 
1392
select count(*) from t1 where v like 'a%';
 
1393
count(*)
 
1394
11
 
1395
select count(*) from t1 where v like 'a %';
 
1396
count(*)
 
1397
9
 
1398
explain select count(*) from t1 where v='a  ';
 
1399
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1400
1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
 
1401
explain select count(*) from t1 where v like 'a%';
 
1402
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1403
1       SIMPLE  t1      range   v       v       303     NULL    #       Using where; Using index
 
1404
explain select count(*) from t1 where v between 'a' and 'a ';
 
1405
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1406
1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
 
1407
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
1408
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1409
1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
 
1410
explain select * from t1 where v='a';
 
1411
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1412
1       SIMPLE  t1      ref     v       v       303     const   #       Using index condition
 
1413
select v,count(*) from t1 group by v limit 10;
 
1414
v       count(*)
 
1415
a      1
 
1416
a       10
 
1417
b       10
 
1418
c       10
 
1419
d       10
 
1420
e       10
 
1421
f       10
 
1422
g       10
 
1423
h       10
 
1424
i       10
 
1425
select v,count(t) from t1 group by v limit 10;
 
1426
v       count(t)
 
1427
a      1
 
1428
a       10
 
1429
b       10
 
1430
c       10
 
1431
d       10
 
1432
e       10
 
1433
f       10
 
1434
g       10
 
1435
h       10
 
1436
i       10
 
1437
select sql_big_result v,count(t) from t1 group by v limit 10;
 
1438
v       count(t)
 
1439
a      1
 
1440
a       10
 
1441
b       10
 
1442
c       10
 
1443
d       10
 
1444
e       10
 
1445
f       10
 
1446
g       10
 
1447
h       10
 
1448
i       10
 
1449
alter table t1 drop key v, add key v (v(30));
 
1450
show create table t1;
 
1451
Table   Create Table
 
1452
t1      CREATE TABLE `t1` (
 
1453
  `v` varchar(300) DEFAULT NULL,
 
1454
  `c` char(10) DEFAULT NULL,
 
1455
  `t` text,
 
1456
  KEY `c` (`c`),
 
1457
  KEY `t` (`t`(10)),
 
1458
  KEY `v` (`v`(30))
 
1459
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1460
select count(*) from t1 where v='a';
 
1461
count(*)
 
1462
10
 
1463
select count(*) from t1 where v='a  ';
 
1464
count(*)
 
1465
10
 
1466
select count(*) from t1 where v between 'a' and 'a ';
 
1467
count(*)
 
1468
10
 
1469
select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
1470
count(*)
 
1471
10
 
1472
select count(*) from t1 where v like 'a%';
 
1473
count(*)
 
1474
11
 
1475
select count(*) from t1 where v like 'a %';
 
1476
count(*)
 
1477
9
 
1478
explain select count(*) from t1 where v='a  ';
 
1479
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1480
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1481
explain select count(*) from t1 where v like 'a%';
 
1482
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1483
1       SIMPLE  t1      range   v       v       33      NULL    #       Using where
 
1484
explain select count(*) from t1 where v between 'a' and 'a ';
 
1485
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1486
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1487
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
1488
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1489
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1490
explain select * from t1 where v='a';
 
1491
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1492
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1493
select v,count(*) from t1 group by v limit 10;
 
1494
v       count(*)
 
1495
a      1
 
1496
a       10
 
1497
b       10
 
1498
c       10
 
1499
d       10
 
1500
e       10
 
1501
f       10
 
1502
g       10
 
1503
h       10
 
1504
i       10
 
1505
select v,count(t) from t1 group by v limit 10;
 
1506
v       count(t)
 
1507
a      1
 
1508
a       10
 
1509
b       10
 
1510
c       10
 
1511
d       10
 
1512
e       10
 
1513
f       10
 
1514
g       10
 
1515
h       10
 
1516
i       10
 
1517
select sql_big_result v,count(t) from t1 group by v limit 10;
 
1518
v       count(t)
 
1519
a      1
 
1520
a       10
 
1521
b       10
 
1522
c       10
 
1523
d       10
 
1524
e       10
 
1525
f       10
 
1526
g       10
 
1527
h       10
 
1528
i       10
 
1529
alter table t1 modify v varchar(600), drop key v, add key v (v);
 
1530
show create table t1;
 
1531
Table   Create Table
 
1532
t1      CREATE TABLE `t1` (
 
1533
  `v` varchar(600) DEFAULT NULL,
 
1534
  `c` char(10) DEFAULT NULL,
 
1535
  `t` text,
 
1536
  KEY `c` (`c`),
 
1537
  KEY `t` (`t`(10)),
 
1538
  KEY `v` (`v`)
 
1539
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1540
select v,count(*) from t1 group by v limit 10;
 
1541
v       count(*)
 
1542
a      1
 
1543
a       10
 
1544
b       10
 
1545
c       10
 
1546
d       10
 
1547
e       10
 
1548
f       10
 
1549
g       10
 
1550
h       10
 
1551
i       10
 
1552
select v,count(t) from t1 group by v limit 10;
 
1553
v       count(t)
 
1554
a      1
 
1555
a       10
 
1556
b       10
 
1557
c       10
 
1558
d       10
 
1559
e       10
 
1560
f       10
 
1561
g       10
 
1562
h       10
 
1563
i       10
 
1564
select sql_big_result v,count(t) from t1 group by v limit 10;
 
1565
v       count(t)
 
1566
a      1
 
1567
a       10
 
1568
b       10
 
1569
c       10
 
1570
d       10
 
1571
e       10
 
1572
f       10
 
1573
g       10
 
1574
h       10
 
1575
i       10
 
1576
drop table t1;
 
1577
create table t1 (a char(10), unique (a));
 
1578
insert into t1 values ('a   ');
 
1579
insert into t1 values ('a ');
 
1580
ERROR 23000: Duplicate entry 'a' for key 'a'
 
1581
alter table t1 modify a varchar(10);
 
1582
insert into t1 values ('a '),('a  '),('a   '),('a         ');
 
1583
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
1584
insert into t1 values ('a     ');
 
1585
ERROR 23000: Duplicate entry 'a     ' for key 'a'
 
1586
insert into t1 values ('a          ');
 
1587
ERROR 23000: Duplicate entry 'a         ' for key 'a'
 
1588
insert into t1 values ('a ');
 
1589
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
1590
update t1 set a='a  ' where a like 'a%';
 
1591
select concat(a,'.') from t1;
 
1592
concat(a,'.')
 
1593
a  .
 
1594
update t1 set a='abc    ' where a like 'a ';
 
1595
select concat(a,'.') from t1;
 
1596
concat(a,'.')
 
1597
a  .
 
1598
update t1 set a='a      ' where a like 'a %';
 
1599
select concat(a,'.') from t1;
 
1600
concat(a,'.')
 
1601
a      .
 
1602
update t1 set a='a  ' where a like 'a      ';
 
1603
select concat(a,'.') from t1;
 
1604
concat(a,'.')
 
1605
a  .
 
1606
drop table t1;
 
1607
create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5)));
 
1608
show create table t1;
 
1609
Table   Create Table
 
1610
t1      CREATE TABLE `t1` (
 
1611
  `v` varchar(10) DEFAULT NULL,
 
1612
  `c` char(10) DEFAULT NULL,
 
1613
  `t` text,
 
1614
  KEY `v` (`v`(5)),
 
1615
  KEY `c` (`c`(5)),
 
1616
  KEY `t` (`t`(5))
 
1617
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1618
drop table t1;
 
1619
create table t1 (v char(10) character set utf8);
 
1620
show create table t1;
 
1621
Table   Create Table
 
1622
t1      CREATE TABLE `t1` (
 
1623
  `v` char(10) CHARACTER SET utf8 DEFAULT NULL
 
1624
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1625
drop table t1;
 
1626
create table t1 (v varchar(10), c char(10)) row_format=fixed;
 
1627
show create table t1;
 
1628
Table   Create Table
 
1629
t1      CREATE TABLE `t1` (
 
1630
  `v` varchar(10) DEFAULT NULL,
 
1631
  `c` char(10) DEFAULT NULL
 
1632
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
 
1633
insert into t1 values('a','a'),('a ','a ');
 
1634
select concat('*',v,'*',c,'*') from t1;
 
1635
concat('*',v,'*',c,'*')
 
1636
*a*a*
 
1637
*a *a*
 
1638
drop table t1;
 
1639
create table t1 (v varchar(65530), key(v(10)));
 
1640
insert into t1 values(repeat('a',65530));
 
1641
select length(v) from t1 where v=repeat('a',65530);
 
1642
length(v)
 
1643
65530
 
1644
drop table t1;
 
1645
create table t1(a int, b varchar(12), key ba(b, a));
 
1646
insert into t1 values (1, 'A'), (20, NULL);
 
1647
explain select * from t1 where a=20 and b is null;
 
1648
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1649
1       SIMPLE  t1      ref     ba      ba      20      const,const     1       Using where; Using index
 
1650
select * from t1 where a=20 and b is null;
 
1651
a       b
 
1652
20      NULL
 
1653
drop table t1;
 
1654
create table t1 (v varchar(65530), key(v));
 
1655
Warnings:
 
1656
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1657
drop table if exists t1;
 
1658
create table t1 (v varchar(65536));
 
1659
Warnings:
 
1660
Note    1246    Converting column 'v' from VARCHAR to TEXT
 
1661
show create table t1;
 
1662
Table   Create Table
 
1663
t1      CREATE TABLE `t1` (
 
1664
  `v` mediumtext
 
1665
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1666
drop table t1;
 
1667
create table t1 (v varchar(65530) character set utf8);
 
1668
Warnings:
 
1669
Note    1246    Converting column 'v' from VARCHAR to TEXT
 
1670
show create table t1;
 
1671
Table   Create Table
 
1672
t1      CREATE TABLE `t1` (
 
1673
  `v` mediumtext CHARACTER SET utf8
 
1674
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1675
drop table t1;
 
1676
create table t1 (v varchar(65535));
 
1677
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
 
1678
set storage_engine=MyISAM;
 
1679
set @save_concurrent_insert=@@concurrent_insert;
 
1680
set global concurrent_insert=1;
 
1681
create table t1 (a int);
 
1682
insert into t1 values (1),(2),(3),(4),(5);
 
1683
lock table t1 read local;
 
1684
insert into t1 values(6),(7);
 
1685
unlock tables;
 
1686
delete from t1 where a>=3 and a<=4;
 
1687
lock table t1 read local;
 
1688
set global concurrent_insert=2;
 
1689
insert into t1 values (8),(9);
 
1690
unlock tables;
 
1691
insert into t1 values (10),(11),(12);
 
1692
select * from t1;
 
1693
a
 
1694
1
 
1695
2
 
1696
11
 
1697
10
 
1698
5
 
1699
6
 
1700
7
 
1701
8
 
1702
9
 
1703
12
 
1704
check table t1;
 
1705
Table   Op      Msg_type        Msg_text
 
1706
test.t1 check   status  OK
 
1707
drop table t1;
 
1708
create table t1 (a int, b varchar(30) default "hello");
 
1709
insert into t1 (a) values (1),(2),(3),(4),(5);
 
1710
lock table t1 read local;
 
1711
insert into t1 (a) values(6),(7);
 
1712
unlock tables;
 
1713
delete from t1 where a>=3 and a<=4;
 
1714
lock table t1 read local;
 
1715
set global concurrent_insert=2;
 
1716
insert into t1 (a) values (8),(9);
 
1717
unlock tables;
 
1718
insert into t1 (a) values (10),(11),(12);
 
1719
select a from t1;
 
1720
a
 
1721
1
 
1722
2
 
1723
11
 
1724
10
 
1725
5
 
1726
6
 
1727
7
 
1728
8
 
1729
9
 
1730
12
 
1731
check table t1;
 
1732
Table   Op      Msg_type        Msg_text
 
1733
test.t1 check   status  OK
 
1734
drop table t1;
 
1735
set global concurrent_insert=@save_concurrent_insert;
 
1736
create table t1 (a int, key(a));
 
1737
insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
 
1738
analyze table t1;
 
1739
Table   Op      Msg_type        Msg_text
 
1740
test.t1 analyze status  OK
 
1741
show keys from t1;
 
1742
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
1743
t1      1       a       1       a       A       8       NULL    NULL    YES     BTREE           
 
1744
alter table t1 disable keys;
 
1745
alter table t1 enable keys;
 
1746
show keys from t1;
 
1747
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
1748
t1      1       a       1       a       A       8       NULL    NULL    YES     BTREE           
 
1749
drop table t1;
 
1750
create table t1 (c1 int) engine=myisam pack_keys=0;
 
1751
create table t2 (c1 int) engine=myisam pack_keys=1;
 
1752
create table t3 (c1 int) engine=myisam pack_keys=default;
 
1753
create table t4 (c1 int) engine=myisam pack_keys=2;
 
1754
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2' at line 1
 
1755
drop table t1, t2, t3;
 
1756
CREATE TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
 
1757
INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
 
1758
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
 
1759
a
 
1760
1
 
1761
ALTER TABLE t1 DISABLE KEYS;
 
1762
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
 
1763
a
 
1764
1
 
1765
SELECT a FROM t1 USE INDEX (inx) WHERE a=1;
 
1766
a
 
1767
1
 
1768
SELECT b FROM t1 FORCE INDEX (uinx) WHERE b=1;
 
1769
b
 
1770
1
 
1771
SELECT b FROM t1 USE INDEX (uinx) WHERE b=1;
 
1772
b
 
1773
1
 
1774
SELECT a FROM t1 FORCE INDEX (inx,uinx) WHERE a=1;
 
1775
a
 
1776
1
 
1777
ALTER TABLE t1 ENABLE KEYS;
 
1778
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
 
1779
a
 
1780
1
 
1781
DROP TABLE t1;
 
1782
CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
 
1783
SHOW TABLE STATUS LIKE 't1';
 
1784
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
1785
t1      MyISAM  10      Fixed   0       #       #       #       1024    #       #       #       #       #       #       #               
 
1786
INSERT INTO t1 VALUES (1,1);
 
1787
SHOW TABLE STATUS LIKE 't1';
 
1788
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
1789
t1      MyISAM  10      Fixed   1       #       #       #       3072    #       #       #       #       #       #       #               
 
1790
ALTER TABLE t1 DISABLE KEYS;
 
1791
SHOW TABLE STATUS LIKE 't1';
 
1792
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
1793
t1      MyISAM  10      Fixed   1       #       #       #       3072    #       #       #       #       #       #       #               
 
1794
ALTER TABLE t1 ENABLE KEYS;
 
1795
SHOW TABLE STATUS LIKE 't1';
 
1796
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
1797
t1      MyISAM  10      Fixed   1       #       #       #       3072    #       #       #       #       #       #       #               
 
1798
ALTER TABLE t1 DISABLE KEYS;
 
1799
SHOW TABLE STATUS LIKE 't1';
 
1800
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
1801
t1      MyISAM  10      Fixed   1       #       #       #       3072    #       #       #       #       #       #       #               
 
1802
ALTER TABLE t1 ENABLE KEYS;
 
1803
SHOW TABLE STATUS LIKE 't1';
 
1804
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
1805
t1      MyISAM  10      Fixed   1       #       #       #       3072    #       #       #       #       #       #       #               
 
1806
# Enable keys with parallel repair
 
1807
SET @@myisam_repair_threads=2;
 
1808
ALTER TABLE t1 DISABLE KEYS;
 
1809
ALTER TABLE t1 ENABLE KEYS;
 
1810
SET @@myisam_repair_threads=1;
 
1811
CHECK TABLE t1 EXTENDED;
 
1812
Table   Op      Msg_type        Msg_text
 
1813
test.t1 check   status  OK
 
1814
DROP TABLE t1;
 
1815
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
 
1816
CREATE TABLE t2 LIKE t1;
 
1817
INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
 
1818
INSERT INTO t1 SELECT * FROM t2;
 
1819
SELECT * FROM t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
 
1820
id      ref     ref
 
1821
4       4       5
 
1822
SELECT * FROM t1;
 
1823
id      ref
 
1824
1       3
 
1825
2       1
 
1826
3       2
 
1827
4       5
 
1828
4       4
 
1829
DELETE FROM a USING t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
 
1830
SELECT * FROM t1;
 
1831
id      ref
 
1832
1       3
 
1833
2       1
 
1834
3       2
 
1835
4       5
 
1836
DROP TABLE t1, t2;
 
1837
End of 5.0 tests
 
1838
create table t1 (a int not null, key `a` (a) key_block_size=1024);
 
1839
show create table t1;
 
1840
Table   Create Table
 
1841
t1      CREATE TABLE `t1` (
 
1842
  `a` int(11) NOT NULL,
 
1843
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024
 
1844
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1845
drop table t1;
 
1846
create table t1 (a int not null, key `a` (a) key_block_size=2048);
 
1847
show create table t1;
 
1848
Table   Create Table
 
1849
t1      CREATE TABLE `t1` (
 
1850
  `a` int(11) NOT NULL,
 
1851
  KEY `a` (`a`) KEY_BLOCK_SIZE=2048
 
1852
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1853
drop table t1;
 
1854
create table t1 (a varchar(2048), key `a` (a));
 
1855
Warnings:
 
1856
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1857
show create table t1;
 
1858
Table   Create Table
 
1859
t1      CREATE TABLE `t1` (
 
1860
  `a` varchar(2048) DEFAULT NULL,
 
1861
  KEY `a` (`a`(1332))
 
1862
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1863
drop table t1;
 
1864
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024);
 
1865
Warnings:
 
1866
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1867
show create table t1;
 
1868
Table   Create Table
 
1869
t1      CREATE TABLE `t1` (
 
1870
  `a` varchar(2048) DEFAULT NULL,
 
1871
  KEY `a` (`a`(1332)) KEY_BLOCK_SIZE=6144
 
1872
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1873
drop table t1;
 
1874
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=1024;
 
1875
Warnings:
 
1876
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1877
show create table t1;
 
1878
Table   Create Table
 
1879
t1      CREATE TABLE `t1` (
 
1880
  `a` int(11) NOT NULL,
 
1881
  `b` varchar(2048) DEFAULT NULL,
 
1882
  KEY `a` (`a`),
 
1883
  KEY `b` (`b`(1332)) KEY_BLOCK_SIZE=6144
 
1884
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=1024
 
1885
alter table t1 key_block_size=2048;
 
1886
show create table t1;
 
1887
Table   Create Table
 
1888
t1      CREATE TABLE `t1` (
 
1889
  `a` int(11) NOT NULL,
 
1890
  `b` varchar(2048) DEFAULT NULL,
 
1891
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
 
1892
  KEY `b` (`b`(1332)) KEY_BLOCK_SIZE=8192
 
1893
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2048
 
1894
alter table t1 add c int, add key (c);
 
1895
show create table t1;
 
1896
Table   Create Table
 
1897
t1      CREATE TABLE `t1` (
 
1898
  `a` int(11) NOT NULL,
 
1899
  `b` varchar(2048) DEFAULT NULL,
 
1900
  `c` int(11) DEFAULT NULL,
 
1901
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
 
1902
  KEY `b` (`b`(1332)) KEY_BLOCK_SIZE=8192,
 
1903
  KEY `c` (`c`)
 
1904
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2048
 
1905
alter table t1 key_block_size=0;
 
1906
alter table t1 add d int, add key (d);
 
1907
show create table t1;
 
1908
Table   Create Table
 
1909
t1      CREATE TABLE `t1` (
 
1910
  `a` int(11) NOT NULL,
 
1911
  `b` varchar(2048) DEFAULT NULL,
 
1912
  `c` int(11) DEFAULT NULL,
 
1913
  `d` int(11) DEFAULT NULL,
 
1914
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
 
1915
  KEY `b` (`b`(1332)) KEY_BLOCK_SIZE=8192,
 
1916
  KEY `c` (`c`) KEY_BLOCK_SIZE=2048,
 
1917
  KEY `d` (`d`)
 
1918
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1919
drop table t1;
 
1920
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=8192;
 
1921
Warnings:
 
1922
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1923
show create table t1;
 
1924
Table   Create Table
 
1925
t1      CREATE TABLE `t1` (
 
1926
  `a` int(11) NOT NULL,
 
1927
  `b` varchar(2048) DEFAULT NULL,
 
1928
  KEY `a` (`a`),
 
1929
  KEY `b` (`b`(1332))
 
1930
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=8192
 
1931
drop table t1;
 
1932
create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) key_block_size=8192;
 
1933
Warnings:
 
1934
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1935
show create table t1;
 
1936
Table   Create Table
 
1937
t1      CREATE TABLE `t1` (
 
1938
  `a` int(11) NOT NULL,
 
1939
  `b` varchar(2048) DEFAULT NULL,
 
1940
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
 
1941
  KEY `b` (`b`(1332))
 
1942
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=8192
 
1943
drop table t1;
 
1944
create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_block_size=8192) key_block_size=16384;
 
1945
show create table t1;
 
1946
Table   Create Table
 
1947
t1      CREATE TABLE `t1` (
 
1948
  `a` int(11) NOT NULL,
 
1949
  `b` int(11) DEFAULT NULL,
 
1950
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
 
1951
  KEY `b` (`b`) KEY_BLOCK_SIZE=8192
 
1952
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=16384
 
1953
drop table t1;
 
1954
create table t1 (a int not null, key `a` (a) key_block_size=512);
 
1955
show create table t1;
 
1956
Table   Create Table
 
1957
t1      CREATE TABLE `t1` (
 
1958
  `a` int(11) NOT NULL,
 
1959
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024
 
1960
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1961
drop table t1;
 
1962
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
 
1963
Warnings:
 
1964
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1965
show create table t1;
 
1966
Table   Create Table
 
1967
t1      CREATE TABLE `t1` (
 
1968
  `a` varchar(2048) DEFAULT NULL,
 
1969
  KEY `a` (`a`(1332)) KEY_BLOCK_SIZE=6144
 
1970
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1971
drop table t1;
 
1972
create table t1 (a int not null, key `a` (a) key_block_size=1025);
 
1973
show create table t1;
 
1974
Table   Create Table
 
1975
t1      CREATE TABLE `t1` (
 
1976
  `a` int(11) NOT NULL,
 
1977
  KEY `a` (`a`) KEY_BLOCK_SIZE=2048
 
1978
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1979
drop table t1;
 
1980
create table t1 (a int not null, key key_block_size=1024 (a));
 
1981
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=1024 (a))' at line 1
 
1982
create table t1 (a int not null, key `a` key_block_size=1024 (a));
 
1983
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key_block_size=1024 (a))' at line 1
 
1984
CREATE TABLE t1 (
 
1985
c1 INT,
 
1986
c2 VARCHAR(300),
 
1987
KEY (c1) KEY_BLOCK_SIZE 1024,
 
1988
KEY (c2) KEY_BLOCK_SIZE 8192
 
1989
);
 
1990
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
 
1991
(11, REPEAT('b', CEIL(RAND() * 300))),
 
1992
(12, REPEAT('c', CEIL(RAND() * 300))),
 
1993
(13, REPEAT('d', CEIL(RAND() * 300))),
 
1994
(14, REPEAT('e', CEIL(RAND() * 300))),
 
1995
(15, REPEAT('f', CEIL(RAND() * 300))),
 
1996
(16, REPEAT('g', CEIL(RAND() * 300))),
 
1997
(17, REPEAT('h', CEIL(RAND() * 300))),
 
1998
(18, REPEAT('i', CEIL(RAND() * 300))),
 
1999
(19, REPEAT('j', CEIL(RAND() * 300))),
 
2000
(20, REPEAT('k', CEIL(RAND() * 300))),
 
2001
(21, REPEAT('l', CEIL(RAND() * 300))),
 
2002
(22, REPEAT('m', CEIL(RAND() * 300))),
 
2003
(23, REPEAT('n', CEIL(RAND() * 300))),
 
2004
(24, REPEAT('o', CEIL(RAND() * 300))),
 
2005
(25, REPEAT('p', CEIL(RAND() * 300))),
 
2006
(26, REPEAT('q', CEIL(RAND() * 300))),
 
2007
(27, REPEAT('r', CEIL(RAND() * 300))),
 
2008
(28, REPEAT('s', CEIL(RAND() * 300))),
 
2009
(29, REPEAT('t', CEIL(RAND() * 300))),
 
2010
(30, REPEAT('u', CEIL(RAND() * 300))),
 
2011
(31, REPEAT('v', CEIL(RAND() * 300))),
 
2012
(32, REPEAT('w', CEIL(RAND() * 300))),
 
2013
(33, REPEAT('x', CEIL(RAND() * 300))),
 
2014
(34, REPEAT('y', CEIL(RAND() * 300))),
 
2015
(35, REPEAT('z', CEIL(RAND() * 300)));
 
2016
INSERT INTO t1 SELECT * FROM t1;
 
2017
INSERT INTO t1 SELECT * FROM t1;
 
2018
CHECK TABLE t1;
 
2019
Table   Op      Msg_type        Msg_text
 
2020
test.t1 check   status  OK
 
2021
REPAIR TABLE t1;
 
2022
Table   Op      Msg_type        Msg_text
 
2023
test.t1 repair  status  OK
 
2024
DELETE FROM t1 WHERE c1 >= 10;
 
2025
CHECK TABLE t1;
 
2026
Table   Op      Msg_type        Msg_text
 
2027
test.t1 check   status  OK
 
2028
DROP TABLE t1;
 
2029
CREATE TABLE t1 (
 
2030
c1 CHAR(130),
 
2031
c2 VARCHAR(1)
 
2032
) ENGINE=MyISAM;
 
2033
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
 
2034
SELECT COUNT(*) FROM t1;
 
2035
COUNT(*)
 
2036
1
 
2037
CHECK TABLE t1;
 
2038
Table   Op      Msg_type        Msg_text
 
2039
test.t1 check   status  OK
 
2040
REPAIR TABLE t1;
 
2041
Table   Op      Msg_type        Msg_text
 
2042
test.t1 repair  status  OK
 
2043
SELECT COUNT(*) FROM t1;
 
2044
COUNT(*)
 
2045
1
 
2046
CHECK TABLE t1;
 
2047
Table   Op      Msg_type        Msg_text
 
2048
test.t1 check   status  OK
 
2049
DROP TABLE t1;
 
2050
CREATE TABLE t1 (
 
2051
c1 CHAR(130),
 
2052
c2 VARCHAR(1)
 
2053
) ENGINE=MyISAM;
 
2054
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
 
2055
SELECT COUNT(*) FROM t1;
 
2056
COUNT(*)
 
2057
1
 
2058
CHECK TABLE t1 EXTENDED;
 
2059
Table   Op      Msg_type        Msg_text
 
2060
test.t1 check   status  OK
 
2061
REPAIR TABLE t1 EXTENDED;
 
2062
Table   Op      Msg_type        Msg_text
 
2063
test.t1 repair  status  OK
 
2064
SELECT COUNT(*) FROM t1;
 
2065
COUNT(*)
 
2066
1
 
2067
CHECK TABLE t1 EXTENDED;
 
2068
Table   Op      Msg_type        Msg_text
 
2069
test.t1 check   status  OK
 
2070
DROP TABLE t1;
 
2071
CREATE TABLE t1 (
 
2072
c1 CHAR(130),
 
2073
c2 VARCHAR(1)
 
2074
) ENGINE=MyISAM;
 
2075
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
 
2076
INSERT INTO t1 VALUES('b', 'b');
 
2077
INSERT INTO t1 VALUES('c', 'b');
 
2078
DELETE FROM t1 WHERE c1='b';
 
2079
SELECT COUNT(*) FROM t1;
 
2080
COUNT(*)
 
2081
2
 
2082
OPTIMIZE TABLE t1;
 
2083
Table   Op      Msg_type        Msg_text
 
2084
test.t1 optimize        status  OK
 
2085
SELECT COUNT(*) FROM t1;
 
2086
COUNT(*)
 
2087
2
 
2088
DROP TABLE t1;
 
2089
CREATE TABLE t1 (
 
2090
c1 CHAR(130),
 
2091
c2 VARCHAR(1),
 
2092
KEY (c1)
 
2093
) ENGINE=MyISAM;
 
2094
# Insert 100 rows. Query log disabled.
 
2095
UPDATE t1 SET c1=REPEAT("a",128) LIMIT 90;
 
2096
SELECT COUNT(*) FROM t1;
 
2097
COUNT(*)
 
2098
100
 
2099
ALTER TABLE t1 ENGINE=MyISAM;
 
2100
SELECT COUNT(*) FROM t1;
 
2101
COUNT(*)
 
2102
100
 
2103
CHECK TABLE t1;
 
2104
Table   Op      Msg_type        Msg_text
 
2105
test.t1 check   status  OK
 
2106
CHECK TABLE t1 EXTENDED;
 
2107
Table   Op      Msg_type        Msg_text
 
2108
test.t1 check   status  OK
 
2109
DROP TABLE t1;
 
2110
CREATE TABLE t1 (
 
2111
c1 CHAR(50),
 
2112
c2 VARCHAR(1)
 
2113
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
2114
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
2115
SELECT COUNT(*) FROM t1;
 
2116
COUNT(*)
 
2117
1
 
2118
CHECK TABLE t1;
 
2119
Table   Op      Msg_type        Msg_text
 
2120
test.t1 check   status  OK
 
2121
REPAIR TABLE t1;
 
2122
Table   Op      Msg_type        Msg_text
 
2123
test.t1 repair  status  OK
 
2124
SELECT COUNT(*) FROM t1;
 
2125
COUNT(*)
 
2126
1
 
2127
CHECK TABLE t1;
 
2128
Table   Op      Msg_type        Msg_text
 
2129
test.t1 check   status  OK
 
2130
DROP TABLE t1;
 
2131
CREATE TABLE t1 (
 
2132
c1 CHAR(50),
 
2133
c2 VARCHAR(1)
 
2134
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
2135
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
2136
SELECT COUNT(*) FROM t1;
 
2137
COUNT(*)
 
2138
1
 
2139
CHECK TABLE t1 EXTENDED;
 
2140
Table   Op      Msg_type        Msg_text
 
2141
test.t1 check   status  OK
 
2142
REPAIR TABLE t1 EXTENDED;
 
2143
Table   Op      Msg_type        Msg_text
 
2144
test.t1 repair  status  OK
 
2145
SELECT COUNT(*) FROM t1;
 
2146
COUNT(*)
 
2147
1
 
2148
CHECK TABLE t1 EXTENDED;
 
2149
Table   Op      Msg_type        Msg_text
 
2150
test.t1 check   status  OK
 
2151
DROP TABLE t1;
 
2152
CREATE TABLE t1 (
 
2153
c1 CHAR(50),
 
2154
c2 VARCHAR(1)
 
2155
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
2156
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
2157
INSERT INTO t1 VALUES('b', 'b');
 
2158
INSERT INTO t1 VALUES('c', 'b');
 
2159
DELETE FROM t1 WHERE c1='b';
 
2160
SELECT COUNT(*) FROM t1;
 
2161
COUNT(*)
 
2162
2
 
2163
OPTIMIZE TABLE t1;
 
2164
Table   Op      Msg_type        Msg_text
 
2165
test.t1 optimize        status  OK
 
2166
SELECT COUNT(*) FROM t1;
 
2167
COUNT(*)
 
2168
2
 
2169
DROP TABLE t1;
 
2170
CREATE TABLE t1 (
 
2171
c1 CHAR(50),
 
2172
c2 VARCHAR(1),
 
2173
KEY (c1)
 
2174
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
2175
# Insert 100 rows. Query log disabled.
 
2176
UPDATE t1 SET c1=REPEAT(_utf8 x'e0ae85',43) LIMIT 90;
 
2177
SELECT COUNT(*) FROM t1;
 
2178
COUNT(*)
 
2179
100
 
2180
ALTER TABLE t1 ENGINE=MyISAM;
 
2181
SELECT COUNT(*) FROM t1;
 
2182
COUNT(*)
 
2183
100
 
2184
CHECK TABLE t1;
 
2185
Table   Op      Msg_type        Msg_text
 
2186
test.t1 check   status  OK
 
2187
CHECK TABLE t1 EXTENDED;
 
2188
Table   Op      Msg_type        Msg_text
 
2189
test.t1 check   status  OK
 
2190
DROP TABLE t1;
 
2191
CREATE TABLE t1 (
 
2192
c1 VARCHAR(10) NOT NULL,
 
2193
c2 CHAR(10) DEFAULT NULL,
 
2194
c3 VARCHAR(10) NOT NULL,
 
2195
KEY (c1),
 
2196
KEY (c2)
 
2197
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;
 
2198
 
 
2199
MyISAM file:         MYSQLTEST_VARDIR/master-data/test/t1
 
2200
Record format:       Packed
 
2201
Character set:       utf8_general_ci (45)
 
2202
Data records:                    0  Deleted blocks:                 0
 
2203
Recordlength:                  124
 
2204
 
 
2205
table description:
 
2206
Key Start Len Index   Type
 
2207
1   2     40  multip. varchar              
 
2208
2   43    40  multip. char NULL            
 
2209
DROP TABLE t1;
 
2210
End of 5.1 tests