~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# Test bugs in the MyISAM code
3
#
4
5
# Initialise
6
--disable_warnings
7
drop table if exists t1,t2;
8
--enable_warnings
9
SET SQL_WARNINGS=1;
10
11
#
12
# Test problem with CHECK TABLE;
13
#
14
15
CREATE TABLE t1 (
16
  STRING_DATA char(255) default NULL,
17
  KEY string_data (STRING_DATA)
18
) ENGINE=MyISAM;
19
20
INSERT INTO t1 VALUES ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
21
INSERT INTO t1 VALUES ('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD');
22
INSERT INTO t1 VALUES ('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');
23
INSERT INTO t1 VALUES ('FGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG');
24
INSERT INTO t1 VALUES ('HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH');
25
INSERT INTO t1 VALUES ('WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW');
26
CHECK TABLE t1;
27
drop table t1;
28
29
#
30
# Test problem with rows that are 65517-65520 bytes long
31
#
32
33
create table t1 (a tinyint not null auto_increment, b blob not null, primary key (a));
34
35
let $1=100;
36
disable_query_log;
37
--disable_warnings
38
SET SQL_WARNINGS=0;
39
while ($1)
40
{
41
  eval insert into t1 (b) values(repeat(char(65+$1),65550-$1));
42
  dec $1;
43
}
44
SET SQL_WARNINGS=1;
45
--enable_warnings
46
enable_query_log;
47
check table t1;
48
repair table t1;
49
delete from t1 where (a & 1);
50
check table t1;
51
repair table t1;
52
check table t1;
53
drop table t1;
54
55
#
56
# Test bug: Two optimize in a row reset index cardinality
57
#
58
59
create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b));
60
insert into t1 (b) values (1),(2),(2),(2),(2);
61
optimize table t1;
62
show index from t1;
63
optimize table t1;
64
show index from t1;
65
drop table t1;
66
67
#
68
# Test of how ORDER BY works when doing it on the whole table
69
#
70
71
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
72
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
73
explain select * from t1 order by a;
74
explain select * from t1 order by b;
75
explain select * from t1 order by c;
76
explain select a from t1 order by a;
77
explain select b from t1 order by b;
78
explain select a,b from t1 order by b;
79
explain select a,b from t1;
80
explain select a,b,c from t1;
81
drop table t1;
82
83
#
84
# Test of OPTIMIZE of locked and modified tables
85
#
86
CREATE TABLE t1 (a INT);
87
INSERT INTO  t1 VALUES (1), (2), (3);
88
LOCK TABLES t1 WRITE;
89
INSERT INTO  t1 VALUES (1), (2), (3);
90
OPTIMIZE TABLE t1;
91
DROP TABLE t1;
92
93
#
94
# Test of optimize, when only mi_sort_index (but not mi_repair*) is done
95
# in ha_myisam::repair, and index size is changed (decreased).
96
#
97
98
create table t1 ( t1 char(255), key(t1(250)));
99
insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169');
100
insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203');
101
insert t1 values ('213872387238723872387238723872387238723867376737673767376737673767376737673767');
102
insert t1 values ('242624262426242624262426242624262426242607890789078907890789078907890789078907');
103
insert t1 values ('256025602560256025602560256025602560256011701170117011701170117011701170117011');
104
insert t1 values ('276027602760276027602760276027602760276001610161016101610161016101610161016101');
105
insert t1 values ('281528152815281528152815281528152815281564956495649564956495649564956495649564');
106
insert t1 values ('292129212921292129212921292129212921292102100210021002100210021002100210021002');
107
insert t1 values ('380638063806380638063806380638063806380634483448344834483448344834483448344834');
108
insert t1 values ('411641164116411641164116411641164116411616301630163016301630163016301630163016');
109
insert t1 values ('420842084208420842084208420842084208420899889988998899889988998899889988998899');
110
insert t1 values ('438443844384438443844384438443844384438482448244824482448244824482448244824482');
111
insert t1 values ('443244324432443244324432443244324432443239613961396139613961396139613961396139');
112
insert t1 values ('485448544854485448544854485448544854485477847784778477847784778477847784778477');
113
insert t1 values ('494549454945494549454945494549454945494555275527552755275527552755275527552755');
114
insert t1 values ('538647864786478647864786478647864786478688918891889188918891889188918891889188');
115
insert t1 values ('565556555655565556555655565556555655565554845484548454845484548454845484548454');
116
insert t1 values ('607860786078607860786078607860786078607856665666566656665666566656665666566656');
117
insert t1 values ('640164016401640164016401640164016401640141274127412741274127412741274127412741');
118
insert t1 values ('719471947194719471947194719471947194719478717871787178717871787178717871787178');
119
insert t1 values ('742574257425742574257425742574257425742549604960496049604960496049604960496049');
120
insert t1 values ('887088708870887088708870887088708870887035963596359635963596359635963596359635');
121
insert t1 values ('917791779177917791779177917791779177917773857385738573857385738573857385738573');
122
insert t1 values ('933293329332933293329332933293329332933278987898789878987898789878987898789878');
123
insert t1 values ('963896389638963896389638963896389638963877807780778077807780778077807780778077');
124
delete from t1 where t1>'2';
125
insert t1 values ('70'), ('84'), ('60'), ('20'), ('76'), ('89'), ('49'), ('50'),
126
('88'), ('61'), ('42'), ('98'), ('39'), ('30'), ('25'), ('66'), ('61'), ('48'),
127
('80'), ('84'), ('98'), ('19'), ('91'), ('42'), ('47');
128
optimize table t1;
129
check table t1;
130
drop table t1;
131
132
#
133
# test of myisam with huge number of packed fields
134
#
135
136
create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
137
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
138
int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
139
i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
140
int, i35 int, i36 int, i37 int, i38 int, i39 int, i40 int, i41 int, i42 int,
141
i43 int, i44 int, i45 int, i46 int, i47 int, i48 int, i49 int, i50 int, i51
142
int, i52 int, i53 int, i54 int, i55 int, i56 int, i57 int, i58 int, i59 int,
143
i60 int, i61 int, i62 int, i63 int, i64 int, i65 int, i66 int, i67 int, i68
144
int, i69 int, i70 int, i71 int, i72 int, i73 int, i74 int, i75 int, i76 int,
145
i77 int, i78 int, i79 int, i80 int, i81 int, i82 int, i83 int, i84 int, i85
146
int, i86 int, i87 int, i88 int, i89 int, i90 int, i91 int, i92 int, i93 int,
147
i94 int, i95 int, i96 int, i97 int, i98 int, i99 int, i100 int, i101 int, i102
148
int, i103 int, i104 int, i105 int, i106 int, i107 int, i108 int, i109 int, i110
149
int, i111 int, i112 int, i113 int, i114 int, i115 int, i116 int, i117 int, i118
150
int, i119 int, i120 int, i121 int, i122 int, i123 int, i124 int, i125 int, i126
151
int, i127 int, i128 int, i129 int, i130 int, i131 int, i132 int, i133 int, i134
152
int, i135 int, i136 int, i137 int, i138 int, i139 int, i140 int, i141 int, i142
153
int, i143 int, i144 int, i145 int, i146 int, i147 int, i148 int, i149 int, i150
154
int, i151 int, i152 int, i153 int, i154 int, i155 int, i156 int, i157 int, i158
155
int, i159 int, i160 int, i161 int, i162 int, i163 int, i164 int, i165 int, i166
156
int, i167 int, i168 int, i169 int, i170 int, i171 int, i172 int, i173 int, i174
157
int, i175 int, i176 int, i177 int, i178 int, i179 int, i180 int, i181 int, i182
158
int, i183 int, i184 int, i185 int, i186 int, i187 int, i188 int, i189 int, i190
159
int, i191 int, i192 int, i193 int, i194 int, i195 int, i196 int, i197 int, i198
160
int, i199 int, i200 int, i201 int, i202 int, i203 int, i204 int, i205 int, i206
161
int, i207 int, i208 int, i209 int, i210 int, i211 int, i212 int, i213 int, i214
162
int, i215 int, i216 int, i217 int, i218 int, i219 int, i220 int, i221 int, i222
163
int, i223 int, i224 int, i225 int, i226 int, i227 int, i228 int, i229 int, i230
164
int, i231 int, i232 int, i233 int, i234 int, i235 int, i236 int, i237 int, i238
165
int, i239 int, i240 int, i241 int, i242 int, i243 int, i244 int, i245 int, i246
166
int, i247 int, i248 int, i249 int, i250 int, i251 int, i252 int, i253 int, i254
167
int, i255 int, i256 int, i257 int, i258 int, i259 int, i260 int, i261 int, i262
168
int, i263 int, i264 int, i265 int, i266 int, i267 int, i268 int, i269 int, i270
169
int, i271 int, i272 int, i273 int, i274 int, i275 int, i276 int, i277 int, i278
170
int, i279 int, i280 int, i281 int, i282 int, i283 int, i284 int, i285 int, i286
171
int, i287 int, i288 int, i289 int, i290 int, i291 int, i292 int, i293 int, i294
172
int, i295 int, i296 int, i297 int, i298 int, i299 int, i300 int, i301 int, i302
173
int, i303 int, i304 int, i305 int, i306 int, i307 int, i308 int, i309 int, i310
174
int, i311 int, i312 int, i313 int, i314 int, i315 int, i316 int, i317 int, i318
175
int, i319 int, i320 int, i321 int, i322 int, i323 int, i324 int, i325 int, i326
176
int, i327 int, i328 int, i329 int, i330 int, i331 int, i332 int, i333 int, i334
177
int, i335 int, i336 int, i337 int, i338 int, i339 int, i340 int, i341 int, i342
178
int, i343 int, i344 int, i345 int, i346 int, i347 int, i348 int, i349 int, i350
179
int, i351 int, i352 int, i353 int, i354 int, i355 int, i356 int, i357 int, i358
180
int, i359 int, i360 int, i361 int, i362 int, i363 int, i364 int, i365 int, i366
181
int, i367 int, i368 int, i369 int, i370 int, i371 int, i372 int, i373 int, i374
182
int, i375 int, i376 int, i377 int, i378 int, i379 int, i380 int, i381 int, i382
183
int, i383 int, i384 int, i385 int, i386 int, i387 int, i388 int, i389 int, i390
184
int, i391 int, i392 int, i393 int, i394 int, i395 int, i396 int, i397 int, i398
185
int, i399 int, i400 int, i401 int, i402 int, i403 int, i404 int, i405 int, i406
186
int, i407 int, i408 int, i409 int, i410 int, i411 int, i412 int, i413 int, i414
187
int, i415 int, i416 int, i417 int, i418 int, i419 int, i420 int, i421 int, i422
188
int, i423 int, i424 int, i425 int, i426 int, i427 int, i428 int, i429 int, i430
189
int, i431 int, i432 int, i433 int, i434 int, i435 int, i436 int, i437 int, i438
190
int, i439 int, i440 int, i441 int, i442 int, i443 int, i444 int, i445 int, i446
191
int, i447 int, i448 int, i449 int, i450 int, i451 int, i452 int, i453 int, i454
192
int, i455 int, i456 int, i457 int, i458 int, i459 int, i460 int, i461 int, i462
193
int, i463 int, i464 int, i465 int, i466 int, i467 int, i468 int, i469 int, i470
194
int, i471 int, i472 int, i473 int, i474 int, i475 int, i476 int, i477 int, i478
195
int, i479 int, i480 int, i481 int, i482 int, i483 int, i484 int, i485 int, i486
196
int, i487 int, i488 int, i489 int, i490 int, i491 int, i492 int, i493 int, i494
197
int, i495 int, i496 int, i497 int, i498 int, i499 int, i500 int, i501 int, i502
198
int, i503 int, i504 int, i505 int, i506 int, i507 int, i508 int, i509 int, i510
199
int, i511 int, i512 int, i513 int, i514 int, i515 int, i516 int, i517 int, i518
200
int, i519 int, i520 int, i521 int, i522 int, i523 int, i524 int, i525 int, i526
201
int, i527 int, i528 int, i529 int, i530 int, i531 int, i532 int, i533 int, i534
202
int, i535 int, i536 int, i537 int, i538 int, i539 int, i540 int, i541 int, i542
203
int, i543 int, i544 int, i545 int, i546 int, i547 int, i548 int, i549 int, i550
204
int, i551 int, i552 int, i553 int, i554 int, i555 int, i556 int, i557 int, i558
205
int, i559 int, i560 int, i561 int, i562 int, i563 int, i564 int, i565 int, i566
206
int, i567 int, i568 int, i569 int, i570 int, i571 int, i572 int, i573 int, i574
207
int, i575 int, i576 int, i577 int, i578 int, i579 int, i580 int, i581 int, i582
208
int, i583 int, i584 int, i585 int, i586 int, i587 int, i588 int, i589 int, i590
209
int, i591 int, i592 int, i593 int, i594 int, i595 int, i596 int, i597 int, i598
210
int, i599 int, i600 int, i601 int, i602 int, i603 int, i604 int, i605 int, i606
211
int, i607 int, i608 int, i609 int, i610 int, i611 int, i612 int, i613 int, i614
212
int, i615 int, i616 int, i617 int, i618 int, i619 int, i620 int, i621 int, i622
213
int, i623 int, i624 int, i625 int, i626 int, i627 int, i628 int, i629 int, i630
214
int, i631 int, i632 int, i633 int, i634 int, i635 int, i636 int, i637 int, i638
215
int, i639 int, i640 int, i641 int, i642 int, i643 int, i644 int, i645 int, i646
216
int, i647 int, i648 int, i649 int, i650 int, i651 int, i652 int, i653 int, i654
217
int, i655 int, i656 int, i657 int, i658 int, i659 int, i660 int, i661 int, i662
218
int, i663 int, i664 int, i665 int, i666 int, i667 int, i668 int, i669 int, i670
219
int, i671 int, i672 int, i673 int, i674 int, i675 int, i676 int, i677 int, i678
220
int, i679 int, i680 int, i681 int, i682 int, i683 int, i684 int, i685 int, i686
221
int, i687 int, i688 int, i689 int, i690 int, i691 int, i692 int, i693 int, i694
222
int, i695 int, i696 int, i697 int, i698 int, i699 int, i700 int, i701 int, i702
223
int, i703 int, i704 int, i705 int, i706 int, i707 int, i708 int, i709 int, i710
224
int, i711 int, i712 int, i713 int, i714 int, i715 int, i716 int, i717 int, i718
225
int, i719 int, i720 int, i721 int, i722 int, i723 int, i724 int, i725 int, i726
226
int, i727 int, i728 int, i729 int, i730 int, i731 int, i732 int, i733 int, i734
227
int, i735 int, i736 int, i737 int, i738 int, i739 int, i740 int, i741 int, i742
228
int, i743 int, i744 int, i745 int, i746 int, i747 int, i748 int, i749 int, i750
229
int, i751 int, i752 int, i753 int, i754 int, i755 int, i756 int, i757 int, i758
230
int, i759 int, i760 int, i761 int, i762 int, i763 int, i764 int, i765 int, i766
231
int, i767 int, i768 int, i769 int, i770 int, i771 int, i772 int, i773 int, i774
232
int, i775 int, i776 int, i777 int, i778 int, i779 int, i780 int, i781 int, i782
233
int, i783 int, i784 int, i785 int, i786 int, i787 int, i788 int, i789 int, i790
234
int, i791 int, i792 int, i793 int, i794 int, i795 int, i796 int, i797 int, i798
235
int, i799 int, i800 int, i801 int, i802 int, i803 int, i804 int, i805 int, i806
236
int, i807 int, i808 int, i809 int, i810 int, i811 int, i812 int, i813 int, i814
237
int, i815 int, i816 int, i817 int, i818 int, i819 int, i820 int, i821 int, i822
238
int, i823 int, i824 int, i825 int, i826 int, i827 int, i828 int, i829 int, i830
239
int, i831 int, i832 int, i833 int, i834 int, i835 int, i836 int, i837 int, i838
240
int, i839 int, i840 int, i841 int, i842 int, i843 int, i844 int, i845 int, i846
241
int, i847 int, i848 int, i849 int, i850 int, i851 int, i852 int, i853 int, i854
242
int, i855 int, i856 int, i857 int, i858 int, i859 int, i860 int, i861 int, i862
243
int, i863 int, i864 int, i865 int, i866 int, i867 int, i868 int, i869 int, i870
244
int, i871 int, i872 int, i873 int, i874 int, i875 int, i876 int, i877 int, i878
245
int, i879 int, i880 int, i881 int, i882 int, i883 int, i884 int, i885 int, i886
246
int, i887 int, i888 int, i889 int, i890 int, i891 int, i892 int, i893 int, i894
247
int, i895 int, i896 int, i897 int, i898 int, i899 int, i900 int, i901 int, i902
248
int, i903 int, i904 int, i905 int, i906 int, i907 int, i908 int, i909 int, i910
249
int, i911 int, i912 int, i913 int, i914 int, i915 int, i916 int, i917 int, i918
250
int, i919 int, i920 int, i921 int, i922 int, i923 int, i924 int, i925 int, i926
251
int, i927 int, i928 int, i929 int, i930 int, i931 int, i932 int, i933 int, i934
252
int, i935 int, i936 int, i937 int, i938 int, i939 int, i940 int, i941 int, i942
253
int, i943 int, i944 int, i945 int, i946 int, i947 int, i948 int, i949 int, i950
254
int, i951 int, i952 int, i953 int, i954 int, i955 int, i956 int, i957 int, i958
255
int, i959 int, i960 int, i961 int, i962 int, i963 int, i964 int, i965 int, i966
256
int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974
257
int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
258
int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
259
int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
260
int, i999 int, i1000 int, b blob) row_format=dynamic;
261
insert into t1 values (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, 1, 1, 1, 1, 1, 1, 1,
288
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,
289
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,
290
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,
291
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,
292
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,
293
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,
294
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,
295
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,
296
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,
297
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,
298
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,
299
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "Sergei");
300
update t1 set b=repeat('a',256);
301
update t1 set i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0;
302
check table t1;
303
delete from t1 where i8=1;
304
select i1,i2 from t1;
305
check table t1;
306
drop table t1;
307
308
#
309
# Test of REPAIR that once failed
310
#
311
CREATE TABLE `t1` (
312
  `post_id` mediumint(8) unsigned NOT NULL auto_increment,
313
  `topic_id` mediumint(8) unsigned NOT NULL default '0',
314
  `post_time` datetime NOT NULL default '0000-00-00 00:00:00',
315
  `post_text` text NOT NULL,
316
  `icon_url` varchar(10) NOT NULL default '',
317
  `sign` tinyint(1) unsigned NOT NULL default '0',
318
  `post_edit` varchar(150) NOT NULL default '',
319
  `poster_login` varchar(35) NOT NULL default '',
320
  `ip` varchar(15) NOT NULL default '',
321
  PRIMARY KEY  (`post_id`),
322
  KEY `post_time` (`post_time`),
323
  KEY `ip` (`ip`),
324
  KEY `poster_login` (`poster_login`),
325
  KEY `topic_id` (`topic_id`),
326
  FULLTEXT KEY `post_text` (`post_text`)
327
) ENGINE=MyISAM;
328
329
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');
330
331
REPAIR TABLE t1;
332
CHECK TABLE t1;
333
drop table t1;
334
335
#
336
# Test of creating table with too long key
337
#
338
339
--error 1071
340
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));
341
CREATE TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300));
342
--error 1071
343
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
344
DROP TABLE t1;
345
346
#
347
# Test of cardinality of keys with NULL
348
#
349
350
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a));
351
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
352
create table t2 (a int not null, b int, c int, key(b), key(c), key(a));
353
INSERT into t2 values (1,1,1), (2,2,2);
354
optimize table t1;
355
show index from t1;
356
explain select * from t1,t2 where t1.a=t2.a;
357
explain select * from t1,t2 force index(a) where t1.a=t2.a;
358
explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a;
359
explain select * from t1,t2 where t1.b=t2.b;
360
explain select * from t1,t2 force index(c) where t1.a=t2.a;
361
explain select * from t1 where a=0 or a=2;
362
explain select * from t1 force index (a) where a=0 or a=2;
363
explain select * from t1 where c=1;
364
explain select * from t1 use index() where c=1;
365
drop table t1,t2;
366
367
#
368
# Test bug when updating a split dynamic row where keys are not changed
369
#
370
371
create table t1 (a int not null auto_increment primary key, b varchar(255));
372
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
373
update t1 set b=repeat(left(b,1),200) where a=1;
374
delete from t1 where (a & 1)= 0;
375
update t1 set b=repeat('e',200) where a=1;
376
flush tables;
377
check table t1;
378
379
#
380
# check updating with keys
381
#
382
383
disable_query_log;
384
let $1 = 100;
385
while ($1)
386
{
387
  eval insert into t1 (b) values (repeat(char(($1 & 32)+65), $1));
388
  dec $1;
389
}
390
enable_query_log;
391
update t1 set b=repeat(left(b,1),255) where a between 1 and 5;
392
update t1 set b=repeat(left(b,1),10) where a between 32 and 43;
393
update t1 set b=repeat(left(b,1),2) where a between 64 and 66;
394
update t1 set b=repeat(left(b,1),65) where a between 67 and 70;
395
check table t1;
396
insert into t1 (b) values (repeat('z',100));
397
update t1 set b="test" where left(b,1) > 'n';
398
check table t1;
399
drop table t1;
400
401
#
402
# two bugs in myisam-space-stripping feature
403
#
404
create table t1 ( a text not null, key a (a(20)));
405
insert into t1 values ('aaa   '),('aaa'),('aa');
406
check table t1;
407
repair table t1;
408
select concat(a,'.') from t1 where a='aaa';
409
select concat(a,'.') from t1 where binary a='aaa';
410
update t1 set a='bbb' where a='aaa';
411
select concat(a,'.') from t1;
412
drop table t1;
413
414
#
415
# Third bug in the same code (BUG#2295)
416
#
417
418
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10)));
419
insert into t1 values('807780', '477', '165');
420
insert into t1 values('807780', '477', '162');
421
insert into t1 values('807780', '472', '162');
422
select * from t1 where a='807780' and b='477' and c='165';
423
drop table t1;
424
425
#
426
# space-stripping in _mi_prefix_search: BUG#5284
427
#
428
DROP TABLE IF EXISTS t1;
429
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a)); 
430
INSERT t1 VALUES ("can \tcan"); 
431
INSERT t1 VALUES ("can   can"); 
432
INSERT t1 VALUES ("can"); 
433
SELECT * FROM t1;
434
CHECK TABLE t1;
435
DROP TABLE t1;
436
437
#
438
# Verify blob handling
439
#
440
create table t1 (a blob);
441
insert into t1 values('a '),('a');
442
select concat(a,'.') from t1 where a='a';
443
select concat(a,'.') from t1 where a='a ';
444
alter table t1 add key(a(2));
445
select concat(a,'.') from t1 where a='a';
446
select concat(a,'.') from t1 where a='a ';
447
drop table t1;
448
449
#
450
# Test text and unique
451
#
452
create table t1 (a int not null auto_increment primary key, b text not null, unique b (b(20)));
453
insert into t1 (b) values ('a'),('b'),('c');
454
select concat(b,'.') from t1;
455
update t1 set b='b ' where a=2;
456
--error ER_DUP_ENTRY
457
update t1 set b='b  ' where a > 1;
458
--error ER_DUP_ENTRY
459
insert into t1 (b) values ('b');
460
select * from t1;
461
delete from t1 where b='b';
462
select a,concat(b,'.') from t1;
463
drop table t1;
464
465
#
466
# Test keys with 0 segments. (Bug #3203)
467
#
468
create table t1 (a int not null);
469
create table t2 (a int not null, primary key (a));
470
insert into t1 values (1);
471
insert into t2 values (1),(2);
472
select sql_big_result distinct t1.a from t1,t2 order by t2.a;
473
select distinct t1.a from t1,t2 order by t2.a;
474
select sql_big_result distinct t1.a from t1,t2;
475
explain select sql_big_result distinct t1.a from t1,t2 order by t2.a;
476
explain select distinct t1.a from t1,t2 order by t2.a;
477
drop table t1,t2;
478
479
#
480
# Bug#14616 - Freshly imported table returns error 124 when using LIMIT
481
#
482
create table t1 (
483
  c1 varchar(32),
484
  key (c1)
485
) engine=myisam;
486
alter table t1 disable keys;
487
insert into t1 values ('a'), ('b');
488
select c1 from t1 order by c1 limit 1;
489
drop table t1;
490
491
#
492
# Bug #14400  Join could miss concurrently inserted row
493
#
494
# Partial key.
495
create table t1 (a int not null, primary key(a));
496
create table t2 (a int not null, b int not null, primary key(a,b));
497
insert into t1 values (1),(2),(3),(4),(5),(6);
498
insert into t2 values (1,1),(2,1);
499
lock tables t1 read local, t2 read local;
500
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
501
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
502
insert into t2 values(2,0);
503
disconnect root;
504
connection default;
505
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
506
unlock tables;
507
drop table t1,t2;
508
#
509
# Full key.
510
CREATE TABLE t1 (c1 varchar(250) NOT NULL);
511
CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
512
INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
513
INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
514
LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
515
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
516
  WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
517
connect (con1,localhost,root,,);
518
connection con1;
519
INSERT INTO t2 VALUES ('test000001'), ('test000005');
520
disconnect con1;
521
connection default;
522
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
523
  WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
524
UNLOCK TABLES;
525
DROP TABLE t1,t2;
526
527
# End of 4.0 tests
528
529
#
530
# Test RTREE index
531
#
532
--error 1235, 1289
533
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;
534
# INSERT INTO t1 VALUES (1,1),(1,1);
535
# DELETE FROM rt WHERE a<1;
536
# DROP TABLE IF EXISTS t1;
537
538
create table t1 (a int, b varchar(200), c text not null) checksum=1;
539
create table t2 (a int, b varchar(200), c text not null) checksum=0;
540
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
541
insert t2 select * from t1;
542
checksum table t1, t2, t3 quick;
543
checksum table t1, t2, t3;
544
checksum table t1, t2, t3 extended;
545
#show table status;
546
drop table t1,t2;
547
548
create table t1 (a int, key (a));
549
show keys from t1;
550
alter table t1 disable keys;
551
show keys from t1;
552
create table t2 (a int);
553
let $i=1000;
554
set @@rand_seed1=31415926,@@rand_seed2=2718281828;
555
--disable_query_log
556
while ($i)
557
{
558
  dec $i;
559
  insert t2 values (rand()*100000);
560
}
561
--enable_query_log
562
insert t1 select * from t2;
563
show keys from t1;
564
alter table t1 enable keys;
565
show keys from t1;
566
alter table t1 engine=heap;
567
alter table t1 disable keys;
568
show keys from t1;
569
drop table t1,t2;
570
571
#
572
# index search for NULL in blob. Bug #4816
573
#
574
create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
575
insert into t1 values (null,''), (null,'');
576
explain select count(*) from t1 where a is null;
577
select count(*) from t1 where a is null;
578
drop table t1;
579
580
#
581
# bug9188 - Corruption Can't open file: 'table.MYI' (errno: 145)
582
#
583
create table t1 (c1 int, c2 varchar(4) not null default '',
584
                 key(c2(3))) default charset=utf8;
585
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
586
update t1 set c2='A  B' where c1=2;
587
check table t1;
588
drop table t1;
589
590
591
#
592
# Bug#12296 - CHECKSUM TABLE reports 0 for the table
593
# This happened if the first record was marked as deleted.
594
#
595
create table t1 (c1 int);
596
insert into t1 values (1),(2),(3),(4);
597
checksum table t1;
598
delete from t1 where c1 = 1;
599
create table t2 as select * from t1;
600
# The following returns 0 with the bug in place.
601
checksum table t1;
602
# The above should give the same number as the following.
603
checksum table t2;
604
drop table t1, t2;
605
606
#
607
# BUG#12232: New myisam_stats_method variable.
608
#
609
610
show variables like 'myisam_stats_method';
611
612
create table t1 (a int, key(a));
613
insert into t1 values (0),(1),(2),(3),(4);
614
insert into t1 select NULL from t1;
615
616
# default: NULLs considered inequal
617
analyze table t1; 
618
show index from t1;
619
insert into t1 values (11);
620
delete from t1 where a=11;
621
check table t1;
622
show index from t1;
623
624
# Set nulls to be equal:
625
set myisam_stats_method=nulls_equal;
626
show variables like 'myisam_stats_method';
627
insert into t1 values (11);
628
delete from t1 where a=11;
629
630
analyze table t1; 
631
show index from t1;
632
633
insert into t1 values (11);
634
delete from t1 where a=11;
635
636
check table t1;
637
show index from t1;
638
639
# Set nulls back to be equal 
640
set myisam_stats_method=DEFAULT;
641
show variables like 'myisam_stats_method';
642
insert into t1 values (11);
643
delete from t1 where a=11;
644
645
analyze table t1; 
646
show index from t1;
647
648
insert into t1 values (11);
649
delete from t1 where a=11;
650
651
check table t1;
652
show index from t1;
653
654
drop table t1;
655
656
# WL#2609, CSC#XXXX: MyISAM 
657
set myisam_stats_method=nulls_ignored;
658
show variables like 'myisam_stats_method';
659
660
create table t1 (
661
  a char(3), b char(4), c char(5), d char(6),
662
  key(a,b,c,d)
663
);
664
insert into t1 values ('bcd','def1', NULL, 'zz');
665
insert into t1 values ('bcd','def2', NULL, 'zz');
666
insert into t1 values ('bce','def1', 'yuu', NULL);
667
insert into t1 values ('bce','def2', NULL, 'quux');
668
analyze table t1;
669
show index from t1;
670
delete from t1;
671
analyze table t1;
672
show index from t1;
673
674
set myisam_stats_method=DEFAULT;
675
drop table t1;
676
677
# BUG#13814 - key value packed incorrectly for TINYBLOBs
678
679
create table t1(
680
  cip INT NOT NULL,
681
  time TIME NOT NULL,
682
  score INT NOT NULL DEFAULT 0,
683
  bob TINYBLOB
684
);
685
686
insert into t1 (cip, time) VALUES (1, '00:01'), (2, '00:02'), (3,'00:03');
687
insert into t1 (cip, bob, time) VALUES (4, 'a', '00:04'), (5, 'b', '00:05'), 
688
                                       (6, 'c', '00:06');
689
select * from t1 where bob is null and cip=1;
690
create index bug on t1 (bob(22), cip, time);
691
select * from t1 where bob is null and cip=1;
692
drop table t1;
693
694
#
695
# Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
696
#
697
create table t1 (
698
  id1 int not null auto_increment,
699
  id2 int not null default '0',
700
  t text not null,
701
  primary key  (id1),
702
  key x (id2, t(32))
703
) engine=myisam;
704
insert into t1 (id2, t) values
705
(10, 'abc'), (10, 'abc'), (10, 'abc'),
706
(20, 'abc'), (20, 'abc'), (20, 'def'),
707
(10, 'abc'), (10, 'abc');
708
select count(*)   from t1 where id2 = 10;
709
select count(id1) from t1 where id2 = 10;
710
drop table t1;
711
712
#
713
# BUG##20357 - Got error 124 from storage engine using MIN and MAX functions
714
#              in queries
715
#
716
CREATE TABLE t1(a TINYINT, KEY(a)) ENGINE=MyISAM;
717
INSERT INTO t1 VALUES(1);
718
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
719
ALTER TABLE t1 DISABLE KEYS;
720
SELECT MAX(a) FROM t1;
721
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
722
DROP TABLE t1;
723
724
#
725
# BUG#18036 - update of table joined to self reports table as crashed
726
#
727
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
728
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
729
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
730
SELECT * FROM t1;
731
DROP TABLE t1;
732
733
#
734
# Bug#8283 - OPTIMIZE TABLE causes data loss
735
#
736
SET @@myisam_repair_threads=2;
737
SHOW VARIABLES LIKE 'myisam_repair%';
738
#
739
# Test OPTIMIZE. This creates a new data file.
740
CREATE TABLE t1 (
741
  `_id` int(11) NOT NULL default '0',
742
  `url` text,
743
  `email` text,
744
  `description` text,
745
  `loverlap` int(11) default NULL,
746
  `roverlap` int(11) default NULL,
747
  `lneighbor_id` int(11) default NULL,
748
  `rneighbor_id` int(11) default NULL,
749
  `length_` int(11) default NULL,
750
  `sequence` mediumtext,
751
  `name` text,
752
  `_obj_class` text NOT NULL,
753
  PRIMARY KEY  (`_id`),
754
  UNIQUE KEY `sequence_name_index` (`name`(50)),
755
  KEY (`length_`)
756
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
757
#
758
INSERT INTO t1 VALUES
759
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
760
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
761
  (3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
762
  (4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
763
  (5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
764
  (6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
765
  (7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
766
  (8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
767
  (9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
768
#
769
SELECT _id FROM t1;
770
DELETE FROM t1 WHERE _id < 8;
771
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
772
SHOW TABLE STATUS LIKE 't1';
773
CHECK TABLE t1 EXTENDED;
774
OPTIMIZE TABLE t1;
775
CHECK TABLE t1 EXTENDED;
776
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
777
SHOW TABLE STATUS LIKE 't1';
778
SELECT _id FROM t1;
779
DROP TABLE t1;
780
#
781
# Test REPAIR QUICK. This retains the old data file.
782
CREATE TABLE t1 (
783
  `_id` int(11) NOT NULL default '0',
784
  `url` text,
785
  `email` text,
786
  `description` text,
787
  `loverlap` int(11) default NULL,
788
  `roverlap` int(11) default NULL,
789
  `lneighbor_id` int(11) default NULL,
790
  `rneighbor_id` int(11) default NULL,
791
  `length_` int(11) default NULL,
792
  `sequence` mediumtext,
793
  `name` text,
794
  `_obj_class` text NOT NULL,
795
  PRIMARY KEY  (`_id`),
796
  UNIQUE KEY `sequence_name_index` (`name`(50)),
797
  KEY (`length_`)
798
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
799
#
800
INSERT INTO t1 VALUES
801
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
802
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
803
  (3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
804
  (4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
805
  (5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
806
  (6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
807
  (7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
808
  (8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
809
  (9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
810
#
811
SELECT _id FROM t1;
812
DELETE FROM t1 WHERE _id < 8;
813
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
814
SHOW TABLE STATUS LIKE 't1';
815
CHECK TABLE t1 EXTENDED;
816
REPAIR TABLE t1 QUICK;
817
CHECK TABLE t1 EXTENDED;
818
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
819
SHOW TABLE STATUS LIKE 't1';
820
SELECT _id FROM t1;
821
DROP TABLE t1;
822
#
823
SET @@myisam_repair_threads=1;
824
SHOW VARIABLES LIKE 'myisam_repair%';
825
826
#
827
# BUG#21310 - Trees in SQL causing a "crashed" table with MyISAM storage
828
#             engine
829
#
830
831
# A simplified test case that reflect crashed table issue.
832
CREATE TABLE t1(a VARCHAR(16));
833
INSERT INTO t1 VALUES('aaaaaaaa'),(NULL);
834
UPDATE t1 AS ta1, t1 AS ta2 SET ta1.a='aaaaaaaaaaaaaaaa';
835
SELECT * FROM t1;
836
DROP TABLE t1;
837
838
# A test case that reflect wrong result set.
839
CREATE TABLE t1(a INT);
840
INSERT INTO t1 VALUES(1),(2);
841
UPDATE t1,t1 AS t2 SET t1.a=t1.a+2 WHERE t1.a=t2.a-1;
842
SELECT * FROM t1 ORDER BY a;
843
DROP TABLE t1;
844
845
#
846
# Bug#24607 - MyISAM pointer size determined incorrectly
847
#
848
CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
849
--replace_column 5 X 6 X 7 X 9 X 10 X 11 X 12 X 13 X 14 X 16 X
850
SHOW TABLE STATUS LIKE 't1';
851
DROP TABLE t1;
852
853
#
854
# Bug#26231 - select count(*) on myisam table returns wrong value
855
#             when index is used
856
#
857
CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
858
# Fill at least two key blocks. "Tab, A" must be in both blocks. 
859
INSERT INTO t1 VALUES
860
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
861
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
862
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
863
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
864
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
865
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
866
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
867
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
868
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
869
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
870
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
871
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
872
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
873
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
874
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
875
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
876
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
877
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
878
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
879
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
880
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
881
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
882
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
883
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
884
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
885
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
886
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
887
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
888
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
889
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
890
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
891
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
892
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
893
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
894
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
895
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
896
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
897
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
898
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
899
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
900
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
901
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
902
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
903
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
904
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
905
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
906
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
907
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
908
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
909
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
910
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
911
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
912
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
913
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
914
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
915
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
916
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
917
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
918
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
919
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
920
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
921
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
922
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
923
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
924
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
925
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
926
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
927
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
928
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
929
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
930
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
931
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
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
  (''), (''), (''), (''),
989
  (' B'), (' B'), (' B'), (' B');
990
SELECT DISTINCT COUNT(*) FROM t1 WHERE c1 = '';
991
SELECT DISTINCT length(c1), c1 FROM t1 WHERE c1 = '';
992
SELECT DISTINCT COUNT(*) FROM t1 IGNORE INDEX (c1) WHERE c1 = '';
993
SELECT DISTINCT length(c1), c1 FROM t1 IGNORE INDEX (c1) WHERE c1 = '';
994
SELECT DISTINCT length(c1), c1 FROM t1 ORDER BY c1;
995
DROP TABLE t1;
996
997
--echo End of 4.1 tests
998
999
1000
# Test varchar
1001
#
1002
1003
let $default=`select @@storage_engine`;
1004
set storage_engine=MyISAM;
1005
source include/varchar.inc;
1006
1007
#
1008
# Some errors/warnings on create
1009
#
1010
1011
create table t1 (v varchar(65530), key(v));
1012
drop table if exists t1;
1013
create table t1 (v varchar(65536));
1014
show create table t1;
1015
drop table t1;
1016
create table t1 (v varchar(65530) character set utf8);
1017
show create table t1;
1018
drop table t1;
1019
1020
# MyISAM specific varchar tests
1021
--error 1118
1022
create table t1 (v varchar(65535));
1023
1024
eval set storage_engine=$default;
1025
1026
#
1027
# Test concurrent insert
1028
# First with static record length
1029
#
1030
set @save_concurrent_insert=@@concurrent_insert;
1031
set global concurrent_insert=1;
1032
create table t1 (a int);
1033
insert into t1 values (1),(2),(3),(4),(5);
1034
lock table t1 read local;
1035
connect (con1,localhost,root,,);
1036
connection con1;
1037
# Insert in table without hole
1038
insert into t1 values(6),(7);
1039
connection default;
1040
unlock tables;
1041
delete from t1 where a>=3 and a<=4;
1042
lock table t1 read local;
1043
connection con1;
1044
set global concurrent_insert=2;
1045
# Insert in table with hole -> Should insert at end
1046
insert into t1 values (8),(9);
1047
connection default;
1048
unlock tables;
1049
# Insert into hole
1050
insert into t1 values (10),(11),(12);
1051
select * from t1;
1052
check table t1;
1053
drop table t1;
1054
disconnect con1;
1055
1056
# Same test with dynamic record length
1057
create table t1 (a int, b varchar(30) default "hello");
1058
insert into t1 (a) values (1),(2),(3),(4),(5);
1059
lock table t1 read local;
1060
connect (con1,localhost,root,,);
1061
connection con1;
1062
# Insert in table without hole
1063
insert into t1 (a) values(6),(7);
1064
connection default;
1065
unlock tables;
1066
delete from t1 where a>=3 and a<=4;
1067
lock table t1 read local;
1068
connection con1;
1069
set global concurrent_insert=2;
1070
# Insert in table with hole -> Should insert at end
1071
insert into t1 (a) values (8),(9);
1072
connection default;
1073
unlock tables;
1074
# Insert into hole
1075
insert into t1 (a) values (10),(11),(12);
1076
select a from t1;
1077
check table t1;
1078
drop table t1;
1079
disconnect con1;
1080
set global concurrent_insert=@save_concurrent_insert;
1081
1082
1083
# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
1084
# different statistics on the same table with NULL values.
1085
create table t1 (a int, key(a));
1086
1087
insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
1088
analyze table t1;
1089
show keys from t1;
1090
1091
alter table t1 disable keys;
1092
alter table t1 enable keys;
1093
show keys from t1;
1094
1095
drop table t1;
1096
1097
1098
#
1099
# Bug#10056 - PACK_KEYS option take values greater than 1 while creating table
1100
#
1101
create table t1 (c1 int) engine=myisam pack_keys=0;
1102
create table t2 (c1 int) engine=myisam pack_keys=1;
1103
create table t3 (c1 int) engine=myisam pack_keys=default;
1104
--error 1064
1105
create table t4 (c1 int) engine=myisam pack_keys=2;
1106
drop table t1, t2, t3;
1107
1108
1109
#
1110
# Bug#28476: force index on a disabled myisam index gives error 124
1111
#
1112
CREATE TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
1113
INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
1114
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
1115
ALTER TABLE t1 DISABLE KEYS;
1116
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
1117
SELECT a FROM t1 USE INDEX (inx) WHERE a=1;
1118
SELECT b FROM t1 FORCE INDEX (uinx) WHERE b=1;
1119
SELECT b FROM t1 USE INDEX (uinx) WHERE b=1;
1120
SELECT a FROM t1 FORCE INDEX (inx,uinx) WHERE a=1;
1121
ALTER TABLE t1 ENABLE KEYS;
1122
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
1123
DROP TABLE t1;
1124
1125
#
1126
# Bug#4692 - DISABLE/ENABLE KEYS waste a space
1127
#
1128
CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
1129
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1130
SHOW TABLE STATUS LIKE 't1';
1131
INSERT INTO t1 VALUES (1,1);
1132
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1133
SHOW TABLE STATUS LIKE 't1';
1134
ALTER TABLE t1 DISABLE KEYS;
1135
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1136
SHOW TABLE STATUS LIKE 't1';
1137
ALTER TABLE t1 ENABLE KEYS;
1138
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1139
SHOW TABLE STATUS LIKE 't1';
1140
ALTER TABLE t1 DISABLE KEYS;
1141
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1142
SHOW TABLE STATUS LIKE 't1';
1143
ALTER TABLE t1 ENABLE KEYS;
1144
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1145
SHOW TABLE STATUS LIKE 't1';
1146
#--exec ls -log var/master-data/test/t1.MYI
1147
#--exec myisamchk -dvv var/master-data/test/t1.MYI
1148
#--exec myisamchk -iev var/master-data/test/t1.MYI
1149
--echo # Enable keys with parallel repair
1150
SET @@myisam_repair_threads=2;
1151
ALTER TABLE t1 DISABLE KEYS;
1152
ALTER TABLE t1 ENABLE KEYS;
1153
SET @@myisam_repair_threads=1;
1154
CHECK TABLE t1 EXTENDED;
1155
DROP TABLE t1;
1156
1157
#
1158
# Bug#28837: MyISAM storage engine error (134) doing delete with self-join
1159
#
1160
1161
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
1162
CREATE TABLE t2 LIKE t1;
1163
1164
INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
1165
INSERT INTO t1 SELECT * FROM t2;
1166
1167
SELECT * FROM t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
1168
SELECT * FROM t1;
1169
DELETE FROM a USING t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
1170
SELECT * FROM t1;
1171
1172
DROP TABLE t1, t2;
1173
1174
--echo End of 5.0 tests
1175
1176
1177
#
1178
# Test of key_block_size
1179
#
1180
1181
create table t1 (a int not null, key `a` (a) key_block_size=1024);
1182
show create table t1;
1183
drop table t1;
1184
1185
create table t1 (a int not null, key `a` (a) key_block_size=2048);
1186
show create table t1;
1187
drop table t1;
1188
1189
create table t1 (a varchar(2048), key `a` (a));
1190
show create table t1;
1191
drop table t1;
1192
1193
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024);
1194
show create table t1;
1195
drop table t1;
1196
1197
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=1024;
1198
show create table t1;
1199
alter table t1 key_block_size=2048;
1200
show create table t1;
1201
alter table t1 add c int, add key (c);
1202
show create table t1;
1203
alter table t1 key_block_size=0;
1204
alter table t1 add d int, add key (d);
1205
show create table t1;
1206
drop table t1;
1207
1208
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=8192;
1209
show create table t1;
1210
drop table t1;
1211
1212
create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) key_block_size=8192;
1213
show create table t1;
1214
drop table t1;
1215
1216
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;
1217
show create table t1;
1218
drop table t1;
1219
1220
1221
# Test limits and errors of key_block_size
1222
1223
create table t1 (a int not null, key `a` (a) key_block_size=512);
1224
show create table t1;
1225
drop table t1;
1226
1227
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
1228
show create table t1;
1229
drop table t1;
1230
1231
create table t1 (a int not null, key `a` (a) key_block_size=1025);
1232
show create table t1;
1233
drop table t1;
1234
1235
--error 1064
1236
create table t1 (a int not null, key key_block_size=1024 (a));
1237
--error 1064
1238
create table t1 (a int not null, key `a` key_block_size=1024 (a));
1239
1240
#
1241
# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk
1242
#
1243
CREATE TABLE t1 (
1244
  c1 INT,
1245
  c2 VARCHAR(300),
1246
  KEY (c1) KEY_BLOCK_SIZE 1024,
1247
  KEY (c2) KEY_BLOCK_SIZE 8192
1248
  );
1249
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
1250
  (11, REPEAT('b', CEIL(RAND() * 300))),
1251
  (12, REPEAT('c', CEIL(RAND() * 300))),
1252
  (13, REPEAT('d', CEIL(RAND() * 300))),
1253
  (14, REPEAT('e', CEIL(RAND() * 300))),
1254
  (15, REPEAT('f', CEIL(RAND() * 300))),
1255
  (16, REPEAT('g', CEIL(RAND() * 300))),
1256
  (17, REPEAT('h', CEIL(RAND() * 300))),
1257
  (18, REPEAT('i', CEIL(RAND() * 300))),
1258
  (19, REPEAT('j', CEIL(RAND() * 300))),
1259
  (20, REPEAT('k', CEIL(RAND() * 300))),
1260
  (21, REPEAT('l', CEIL(RAND() * 300))),
1261
  (22, REPEAT('m', CEIL(RAND() * 300))),
1262
  (23, REPEAT('n', CEIL(RAND() * 300))),
1263
  (24, REPEAT('o', CEIL(RAND() * 300))),
1264
  (25, REPEAT('p', CEIL(RAND() * 300))),
1265
  (26, REPEAT('q', CEIL(RAND() * 300))),
1266
  (27, REPEAT('r', CEIL(RAND() * 300))),
1267
  (28, REPEAT('s', CEIL(RAND() * 300))),
1268
  (29, REPEAT('t', CEIL(RAND() * 300))),
1269
  (30, REPEAT('u', CEIL(RAND() * 300))),
1270
  (31, REPEAT('v', CEIL(RAND() * 300))),
1271
  (32, REPEAT('w', CEIL(RAND() * 300))),
1272
  (33, REPEAT('x', CEIL(RAND() * 300))),
1273
  (34, REPEAT('y', CEIL(RAND() * 300))),
1274
  (35, REPEAT('z', CEIL(RAND() * 300)));
1275
INSERT INTO t1 SELECT * FROM t1;
1276
INSERT INTO t1 SELECT * FROM t1;
1277
CHECK TABLE t1;
1278
REPAIR TABLE t1;
1279
DELETE FROM t1 WHERE c1 >= 10;
1280
CHECK TABLE t1;
1281
DROP TABLE t1;
1282
1283
#
1284
# Bug#33222 - myisam-table drops rows when column is added
1285
#             and a char-field > 128 exists
1286
#
1287
# Test #1 - CHECK TABLE sees wrong record, REPAR TABLE deletes it.
1288
# Using a CHAR column that can have > 127 characters.
1289
# Using a VARCHAR to create a table with dynamic row format.
1290
CREATE TABLE t1 (
1291
  c1 CHAR(130),
1292
  c2 VARCHAR(1)
1293
) ENGINE=MyISAM;
1294
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
1295
SELECT COUNT(*) FROM t1;
1296
CHECK TABLE t1;
1297
REPAIR TABLE t1;
1298
SELECT COUNT(*) FROM t1;
1299
CHECK TABLE t1;
1300
DROP TABLE t1;
1301
#
1302
# Test #2 - same as test #1, but using EXTENDED.
1303
# Using a CHAR column that can have > 127 characters.
1304
# Using a VARCHAR to create a table with dynamic row format.
1305
CREATE TABLE t1 (
1306
  c1 CHAR(130),
1307
  c2 VARCHAR(1)
1308
) ENGINE=MyISAM;
1309
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
1310
SELECT COUNT(*) FROM t1;
1311
CHECK TABLE t1 EXTENDED;
1312
REPAIR TABLE t1 EXTENDED;
1313
SELECT COUNT(*) FROM t1;
1314
CHECK TABLE t1 EXTENDED;
1315
DROP TABLE t1;
1316
#
1317
# Test #3 - same as test #1, but using OPTIMIZE TABLE.
1318
# Using a CHAR column that can have > 127 characters.
1319
# Using a VARCHAR to create a table with dynamic row format.
1320
CREATE TABLE t1 (
1321
  c1 CHAR(130),
1322
  c2 VARCHAR(1)
1323
) ENGINE=MyISAM;
1324
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
1325
# Insert more rows and delete one in the middle to force optimize.
1326
INSERT INTO t1 VALUES('b', 'b');
1327
INSERT INTO t1 VALUES('c', 'b');
1328
DELETE FROM t1 WHERE c1='b';
1329
SELECT COUNT(*) FROM t1;
1330
OPTIMIZE TABLE t1;
1331
SELECT COUNT(*) FROM t1;
1332
DROP TABLE t1;
1333
#
1334
# Test #4 - ALTER TABLE deletes rows.
1335
# Using a CHAR column that can have > 127 characters.
1336
# Using a VARCHAR to create a table with dynamic row format.
1337
# Using an index which can be disabled during bulk insert.
1338
CREATE TABLE t1 (
1339
  c1 CHAR(130),
1340
  c2 VARCHAR(1),
1341
  KEY (c1)
1342
) ENGINE=MyISAM;
1343
#
1344
# Insert 100 rows. This turns bulk insert on during the copy phase of
1345
# ALTER TABLE. Bulk insert disables keys before the insert and re-enables
1346
# them by repair after the insert.
1347
--disable_query_log
1348
let $count= 100;
1349
--echo # Insert $count rows. Query log disabled.
1350
while ($count)
1351
{
1352
  INSERT INTO t1 VALUES ('a', 'b');
1353
  dec $count;
1354
}
1355
--enable_query_log
1356
#
1357
# Change most of the rows into long character values with > 127 characters.
1358
UPDATE t1 SET c1=REPEAT("a",128) LIMIT 90;
1359
SELECT COUNT(*) FROM t1;
1360
ALTER TABLE t1 ENGINE=MyISAM;
1361
#
1362
# With bug present, this shows that all long rows are gone.
1363
SELECT COUNT(*) FROM t1;
1364
CHECK TABLE t1;
1365
CHECK TABLE t1 EXTENDED;
1366
DROP TABLE t1;
1367
#
1368
# Test #5 - same as test #1 but UTF-8.
1369
# Using a CHAR column that can have > 127 characters.
1370
# Using a VARCHAR to create a table with dynamic row format.
1371
CREATE TABLE t1 (
1372
  c1 CHAR(50),
1373
  c2 VARCHAR(1)
1374
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1375
# Using Tamil Letter A, Unicode U+0B85
1376
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
1377
SELECT COUNT(*) FROM t1;
1378
CHECK TABLE t1;
1379
REPAIR TABLE t1;
1380
SELECT COUNT(*) FROM t1;
1381
CHECK TABLE t1;
1382
DROP TABLE t1;
1383
#
1384
# Test #6 - same as test #2, but UTF-8.
1385
# Using a CHAR column that can have > 127 characters.
1386
# Using a VARCHAR to create a table with dynamic row format.
1387
CREATE TABLE t1 (
1388
  c1 CHAR(50),
1389
  c2 VARCHAR(1)
1390
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1391
# Using Tamil Letter A, Unicode U+0B85
1392
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
1393
SELECT COUNT(*) FROM t1;
1394
CHECK TABLE t1 EXTENDED;
1395
REPAIR TABLE t1 EXTENDED;
1396
SELECT COUNT(*) FROM t1;
1397
CHECK TABLE t1 EXTENDED;
1398
DROP TABLE t1;
1399
#
1400
# Test #7 - same as test #3, but UTF-8.
1401
# Using a CHAR column that can have > 127 characters.
1402
# Using a VARCHAR to create a table with dynamic row format.
1403
CREATE TABLE t1 (
1404
  c1 CHAR(50),
1405
  c2 VARCHAR(1)
1406
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1407
# Using Tamil Letter A, Unicode U+0B85
1408
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
1409
# Insert more rows and delete one in the middle to force optimize.
1410
INSERT INTO t1 VALUES('b', 'b');
1411
INSERT INTO t1 VALUES('c', 'b');
1412
DELETE FROM t1 WHERE c1='b';
1413
SELECT COUNT(*) FROM t1;
1414
OPTIMIZE TABLE t1;
1415
SELECT COUNT(*) FROM t1;
1416
DROP TABLE t1;
1417
#
1418
# Test #8 - same as test #4, but UTF-8.
1419
# Using a CHAR column that can have > 42 UTF-8 characters.
1420
# Using a VARCHAR to create a table with dynamic row format.
1421
# Using an index which can be disabled during bulk insert.
1422
CREATE TABLE t1 (
1423
  c1 CHAR(50),
1424
  c2 VARCHAR(1),
1425
  KEY (c1)
1426
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1427
#
1428
# Insert 100 rows. This turns bulk insert on during the copy phase of
1429
# ALTER TABLE. Bulk insert disables keys before the insert and re-enables
1430
# them by repair after the insert.
1431
--disable_query_log
1432
let $count= 100;
1433
--echo # Insert $count rows. Query log disabled.
1434
while ($count)
1435
{
1436
  INSERT INTO t1 VALUES ('a', 'b');
1437
  dec $count;
1438
}
1439
--enable_query_log
1440
#
1441
# Change most of the rows into long character values with > 42 characters.
1442
# Using Tamil Letter A, Unicode U+0B85
1443
UPDATE t1 SET c1=REPEAT(_utf8 x'e0ae85',43) LIMIT 90;
1444
SELECT COUNT(*) FROM t1;
1445
ALTER TABLE t1 ENGINE=MyISAM;
1446
#
1447
# With bug present, this shows that all long rows are gone.
1448
SELECT COUNT(*) FROM t1;
1449
CHECK TABLE t1;
1450
CHECK TABLE t1 EXTENDED;
1451
DROP TABLE t1;
1452
1453
#
1454
# Bug#29182 - MyISAMCHK reports wrong character set
1455
#
1456
CREATE TABLE t1 (
1457
  c1 VARCHAR(10) NOT NULL,
1458
  c2 CHAR(10) DEFAULT NULL,
1459
  c3 VARCHAR(10) NOT NULL,
1460
  KEY (c1),
1461
  KEY (c2)
1462
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;
1463
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1464
--exec $MYISAMCHK -d $MYSQLTEST_VARDIR/master-data/test/t1
1465
DROP TABLE t1;
1466
1467
--echo End of 5.1 tests
1468