~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/myisam.test

  • Committer: Stewart Smith
  • Date: 2009-06-17 06:44:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1094.
  • Revision ID: stewart@flamingspork.com-20090617064438-062owpgtdzgr4lvx
type_float.test for MyISAM as temp only

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
# Test problem with CHECK TABLE;
13
13
#
14
14
 
15
 
CREATE TEMPORARY TABLE t1 (
 
15
CREATE TABLE t1 (
16
16
  STRING_DATA char(255) default NULL,
17
17
  KEY string_data (STRING_DATA)
18
18
) ENGINE=MyISAM;
30
30
# Test problem with rows that are 65517-65520 bytes long
31
31
#
32
32
 
33
 
create temporary table t1 (a int not null auto_increment, b blob not null, primary key (a)) engine=myisam;
 
33
create table t1 (a int not null auto_increment, b blob not null, primary key (a));
34
34
 
35
35
let $1=100;
36
36
disable_query_log;
45
45
--enable_warnings
46
46
enable_query_log;
47
47
check table t1;
 
48
repair table t1;
48
49
 
49
50
# @TODO Because there are no notes on what the heck this
50
51
# is actually testing (which bug?), it's difficult to tell
54
55
#delete from t1 where (a & 1);
55
56
delete from t1 where (a mod 2) = 1;
56
57
check table t1;
 
58
repair table t1;
 
59
check table t1;
57
60
drop table t1;
58
61
 
59
62
#
60
63
# Test bug: Two optimize in a row reset index cardinality
61
64
#
62
65
 
63
 
create TEMPORARY table t1 (a int not null auto_increment, b int not null, primary key (a), index(b)) ENGINE=MYISAM;
 
66
create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b));
64
67
insert into t1 (b) values (1),(2),(2),(2),(2);
65
 
alter table t1 engine=MYISAM;
 
68
optimize table t1;
66
69
show index from t1;
67
 
alter table t1 engine=MyISAM;
 
70
optimize table t1;
68
71
show index from t1;
69
72
drop table t1;
70
73
 
72
75
# Test of how ORDER BY works when doing it on the whole table
73
76
#
74
77
 
75
 
create temporary table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
 
78
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
76
79
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
77
80
explain select * from t1 order by a;
78
81
explain select * from t1 order by b;
89
92
# in ha_myisam::repair, and index size is changed (decreased).
90
93
#
91
94
 
92
 
create temporary table t1 ( t1 char(255), key(t1(250))) ENGINE=MYISAM;
 
95
create table t1 ( t1 char(255), key(t1(250)));
93
96
insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169');
94
97
insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203');
95
98
insert t1 values ('213872387238723872387238723872387238723867376737673767376737673767376737673767');
119
122
insert t1 values ('70'), ('84'), ('60'), ('20'), ('76'), ('89'), ('49'), ('50'),
120
123
('88'), ('61'), ('42'), ('98'), ('39'), ('30'), ('25'), ('66'), ('61'), ('48'),
121
124
('80'), ('84'), ('98'), ('19'), ('91'), ('42'), ('47');
122
 
alter table t1 ENGINE=myisam;
 
125
optimize table t1;
123
126
check table t1;
124
127
drop table t1;
125
128
 
127
130
# test of myisam with huge number of packed fields
128
131
#
129
132
 
130
 
create temporary table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
 
133
create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
131
134
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
132
135
int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
133
136
i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
302
305
#
303
306
# Test of REPAIR that once failed
304
307
#
305
 
CREATE TEMPORARY TABLE `t1` (
 
308
CREATE TABLE `t1` (
306
309
  `post_id` int NOT NULL auto_increment,
307
310
  `topic_id` int NOT NULL default '0',
308
311
  `post_time` datetime,
322
325
 
323
326
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');
324
327
 
 
328
# @TODO The REPAIR TABLE statement crashes server.
 
329
# Bug#309802: https://bugs.launchpad.net/drizzle/+bug/309802
 
330
# Commenting it out for now to proceed in testing. - JRP
 
331
# REPAIR TABLE t1;
325
332
CHECK TABLE t1;
326
333
drop table t1;
327
334
 
329
336
# Test of creating table with too long key
330
337
#
331
338
 
332
 
--error ER_TOO_LONG_KEY
333
 
CREATE TEMPORARY TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300), KEY t1 (a, b, c, d, e)) ENGINE=MyISAM;
334
 
CREATE TEMPORARY TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300)) ENGINE=MyISAM;
335
 
--error ER_TOO_LONG_KEY
 
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)) ENGINE=MyISAM;
 
341
CREATE TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300)) ENGINE=MyISAM;
 
342
--error 1071
336
343
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
337
344
DROP TABLE t1;
338
345
 
340
347
# Test of cardinality of keys with NULL
341
348
#
342
349
 
343
 
CREATE TEMPORARY TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)) ENGINE=MyISAM;
 
350
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)) ENGINE=MyISAM;
344
351
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
345
 
create temporary table t2 (a int not null, b int, c int, key(b), key(c), key(a)) engine=myisam;
 
352
create table t2 (a int not null, b int, c int, key(b), key(c), key(a));
346
353
INSERT into t2 values (1,1,1), (2,2,2);
347
 
alter table t1 ENGINE=MYISAM;
 
354
optimize table t1;
348
355
show index from t1;
349
356
explain select * from t1,t2 where t1.a=t2.a;
350
357
explain select * from t1,t2 force index(a) where t1.a=t2.a;
361
368
# Test bug when updating a split dynamic row where keys are not changed
362
369
#
363
370
 
364
 
create temporary table t1 (a int not null auto_increment primary key, b varchar(255)) engine=myisam;
 
371
create table t1 (a int not null auto_increment primary key, b varchar(255));
365
372
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
366
373
update t1 set b=repeat(left(b,1),200) where a=1;
367
374
 
406
413
#
407
414
# two bugs in myisam-space-stripping feature
408
415
#
409
 
create temporary table t1 ( a text not null, key a (a(20))) engine=myisam;
 
416
create table t1 ( a text not null, key a (a(20)));
410
417
insert into t1 values ('aaa   '),('aaa'),('aa');
411
418
check table t1;
 
419
repair table t1;
412
420
select concat(a,'.') from t1 where a='aaa';
413
421
select concat(a,'.') from t1 where binary a='aaa';
414
422
update t1 set a='bbb' where a='aaa';
419
427
# Third bug in the same code (BUG#2295)
420
428
#
421
429
 
422
 
create temporary table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))) engine=myisam;
 
430
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10)));
423
431
insert into t1 values('807780', '477', '165');
424
432
insert into t1 values('807780', '477', '162');
425
433
insert into t1 values('807780', '472', '162');
430
438
# space-stripping in _mi_prefix_search: BUG#5284
431
439
#
432
440
DROP TABLE IF EXISTS t1;
433
 
CREATE TEMPORARY TABLE t1 (a varchar(150) NOT NULL, KEY (a)) ENGINE=MyISAM; 
 
441
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a)) ENGINE=MyISAM; 
434
442
INSERT t1 VALUES ("can \tcan"); 
435
443
INSERT t1 VALUES ("can   can"); 
436
444
INSERT t1 VALUES ("can"); 
441
449
#
442
450
# Verify blob handling
443
451
#
444
 
create temporary table t1 (a blob) engine=myisam;
 
452
create table t1 (a blob);
445
453
insert into t1 values('a '),('a');
446
454
select concat(a,'.') from t1 where a='a';
447
455
select concat(a,'.') from t1 where a='a ';
453
461
#
454
462
# Test text and unique
455
463
#
456
 
create temporary table t1 (a int not null auto_increment primary key, b text not null, unique b (b(20))) engine=myisam;
 
464
create table t1 (a int not null auto_increment primary key, b text not null, unique b (b(20)));
457
465
insert into t1 (b) values ('a'),('b'),('c');
458
466
select concat(b,'.') from t1;
459
467
update t1 set b='b ' where a=2;
469
477
#
470
478
# Test keys with 0 segments. (Bug #3203)
471
479
#
472
 
create temporary table t1 (a int not null) engine=myisam;
473
 
create temporary table t2 (a int not null, primary key (a)) engine=myisam;
 
480
create table t1 (a int not null);
 
481
create table t2 (a int not null, primary key (a));
474
482
insert into t1 values (1);
475
483
insert into t2 values (1),(2);
476
484
select sql_big_result distinct t1.a from t1,t2 order by t2.a;
483
491
#
484
492
# Bug#14616 - Freshly imported table returns error 124 when using LIMIT
485
493
#
486
 
create temporary table t1 (
 
494
create table t1 (
487
495
  c1 varchar(32),
488
496
  key (c1)
489
497
) engine=myisam;
494
502
 
495
503
# End of 4.0 tests
496
504
 
497
 
create temporary table t1 (a int, b varchar(200), c text not null) engine=myisam;
498
 
create temporary table t2 (a int, b varchar(200), c text not null) engine=myisam;
 
505
create table t1 (a int, b varchar(200), c text not null) checksum=1;
 
506
create table t2 (a int, b varchar(200), c text not null) checksum=0;
499
507
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
500
508
insert t2 select * from t1;
501
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
502
 
show table status;
 
509
checksum table t1, t2, t3 quick;
 
510
checksum table t1, t2, t3;
 
511
checksum table t1, t2, t3 extended;
 
512
#show table status;
503
513
drop table t1,t2;
504
514
 
505
515
#@TODO Figure out what the heck the below is testing.
523
533
#show keys from t1;
524
534
#alter table t1 enable keys;
525
535
#show keys from t1;
526
 
#alter table t1 engine=MEMORY;
 
536
#alter table t1 engine=heap;
527
537
#alter table t1 disable keys;
528
538
#show keys from t1;
529
539
#drop table t1,t2;
531
541
#
532
542
# index search for NULL in blob. Bug #4816
533
543
#
534
 
create temporary table t1 ( a tinytext, b char(1), index idx (a(1),b) ) engine=myisam;
 
544
create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
535
545
insert into t1 values (null,''), (null,'');
536
546
explain select count(*) from t1 where a is null;
537
547
select count(*) from t1 where a is null;
540
550
#
541
551
# bug9188 - Corruption Can't open file: 'table.MYI' (errno: 145)
542
552
#
543
 
create temporary table t1 (c1 int, c2 varchar(4) not null default '',
544
 
                 key(c2(3))) engine=myisam;
 
553
create table t1 (c1 int, c2 varchar(4) not null default '',
 
554
                 key(c2(3)));
545
555
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
546
556
update t1 set c2='A  B' where c1=2;
547
557
check table t1;
548
558
drop table t1;
549
559
 
 
560
 
 
561
#
 
562
# Bug#12296 - CHECKSUM TABLE reports 0 for the table
 
563
# This happened if the first record was marked as deleted.
 
564
#
 
565
create table t1 (c1 int);
 
566
insert into t1 values (1),(2),(3),(4);
 
567
checksum table t1;
 
568
delete from t1 where c1 = 1;
 
569
create table t2 as select * from t1;
 
570
# The following returns 0 with the bug in place.
 
571
checksum table t1;
 
572
# The above should give the same number as the following.
 
573
checksum table t2;
 
574
drop table t1, t2;
 
575
 
 
576
#
 
577
# BUG#12232: New myisam_stats_method variable.
 
578
#
 
579
# @TODO The following segfaults. Disabling for now - JRP
 
580
#
 
581
#show variables like 'myisam_stats_method';
 
582
#
 
583
#create table t1 (a int, key(a));
 
584
#insert into t1 values (0),(1),(2),(3),(4);
 
585
#insert into t1 select NULL from t1;
 
586
 
 
587
# default: NULLs considered inequal
 
588
#analyze table t1; 
 
589
#show index from t1;
 
590
#insert into t1 values (11);
 
591
#delete from t1 where a=11;
 
592
#check table t1;
 
593
#show index from t1;
 
594
 
 
595
# Set nulls to be equal:
 
596
#set myisam_stats_method=nulls_equal;
 
597
#show variables like 'myisam_stats_method';
 
598
#insert into t1 values (11);
 
599
#delete from t1 where a=11;
 
600
 
 
601
#analyze table t1; 
 
602
#show index from t1;
 
603
#
 
604
#insert into t1 values (11);
 
605
#delete from t1 where a=11;
 
606
#
 
607
#check table t1;
 
608
#show index from t1;
 
609
#
 
610
# Set nulls back to be equal 
 
611
#set myisam_stats_method=DEFAULT;
 
612
#show variables like 'myisam_stats_method';
 
613
#insert into t1 values (11);
 
614
#delete from t1 where a=11;
 
615
#
 
616
#analyze table t1; 
 
617
#show index from t1;
 
618
#
 
619
#insert into t1 values (11);
 
620
#delete from t1 where a=11;
 
621
#
 
622
#check table t1;
 
623
#show index from t1;
 
624
#
 
625
#drop table t1;
 
626
 
 
627
# WL#2609, CSC#XXXX: MyISAM 
 
628
#set myisam_stats_method=nulls_ignored;
 
629
#show variables like 'myisam_stats_method';
 
630
#
 
631
#create table t1 (
 
632
#  a char(3), b char(4), c char(5), d char(6),
 
633
#  key(a,b,c,d)
 
634
#);
 
635
#insert into t1 values ('bcd','def1', NULL, 'zz');
 
636
#insert into t1 values ('bcd','def2', NULL, 'zz');
 
637
#insert into t1 values ('bce','def1', 'yuu', NULL);
 
638
#insert into t1 values ('bce','def2', NULL, 'quux');
 
639
#analyze table t1;
 
640
#show index from t1;
 
641
#delete from t1;
 
642
#analyze table t1;
 
643
#show index from t1;
 
644
#
 
645
#set myisam_stats_method=DEFAULT;
 
646
#drop table t1;
 
647
 
550
648
# BUG#13814 - key value packed incorrectly for TINYBLOBs
551
649
 
552
 
create temporary table t1(
 
650
create table t1(
553
651
  cip INT NOT NULL,
554
652
  score INT NOT NULL DEFAULT 0,
555
653
  bob TINYBLOB
556
 
) engine=myisam;
 
654
);
557
655
 
558
656
insert into t1 (cip) VALUES (1), (2), (3);
559
657
insert into t1 (cip, bob) VALUES (4, 'a' ), (5, 'b'), 
566
664
#
567
665
# Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
568
666
#
569
 
create temporary table t1 (
 
667
create table t1 (
570
668
  id1 int not null auto_increment,
571
669
  id2 int not null default '0',
572
670
  t text not null,
585
683
# BUG##20357 - Got error 124 from storage engine using MIN and MAX functions
586
684
#              in queries
587
685
#
588
 
CREATE TEMPORARY TABLE t1(a int, KEY(a)) ENGINE=MyISAM;
 
686
CREATE TABLE t1(a int, KEY(a)) ENGINE=MyISAM;
589
687
INSERT INTO t1 VALUES(1);
590
688
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
591
689
ALTER TABLE t1 DISABLE KEYS;
594
692
DROP TABLE t1;
595
693
 
596
694
#
 
695
# BUG#18036 - update of table joined to self reports table as crashed
 
696
#
 
697
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
 
698
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
 
699
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
 
700
SELECT * FROM t1;
 
701
DROP TABLE t1;
 
702
 
 
703
#
597
704
# Bug#8283 - OPTIMIZE TABLE causes data loss
598
705
#
 
706
SET GLOBAL myisam_repair_threads=2;
 
707
SHOW VARIABLES LIKE 'myisam_repair%';
 
708
#
599
709
# Test OPTIMIZE. This creates a new data file.
600
 
CREATE TEMPORARY TABLE t1 (
601
 
  `_id` int NOT NULL default '0',
602
 
  `url` text,
603
 
  `email` text,
604
 
  `description` text,
605
 
  `loverlap` int default NULL,
606
 
  `roverlap` int default NULL,
607
 
  `lneighbor_id` int default NULL,
608
 
  `rneighbor_id` int default NULL,
609
 
  `length_` int default NULL,
610
 
  `sequence` text,
611
 
  `name` text,
612
 
  `_obj_class` text NOT NULL,
613
 
  PRIMARY KEY  (`_id`),
614
 
  UNIQUE KEY `sequence_name_index` (`name`(50)),
615
 
  KEY (`length_`)
616
 
) ENGINE=MyISAM;
617
 
 
618
 
INSERT INTO t1 VALUES
619
 
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
620
 
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
621
 
  (3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
622
 
  (4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
623
 
  (5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
624
 
  (6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
625
 
  (7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
626
 
  (8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
627
 
  (9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
628
 
#
629
 
SELECT _id FROM t1;
630
 
DELETE FROM t1 WHERE _id < 8;
631
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
632
 
show table status LIKE 't1';
633
 
CHECK TABLE t1;
634
 
ALTER TABLE t1 ENGINE=MYISAM;
635
 
CHECK TABLE t1;
636
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
637
 
show table status LIKE 't1';
638
 
SELECT _id FROM t1;
 
710
CREATE TABLE t1 (
 
711
  `_id` int NOT NULL default '0',
 
712
  `url` text,
 
713
  `email` text,
 
714
  `description` text,
 
715
  `loverlap` int default NULL,
 
716
  `roverlap` int default NULL,
 
717
  `lneighbor_id` int default NULL,
 
718
  `rneighbor_id` int default NULL,
 
719
  `length_` int default NULL,
 
720
  `sequence` text,
 
721
  `name` text,
 
722
  `_obj_class` text NOT NULL,
 
723
  PRIMARY KEY  (`_id`),
 
724
  UNIQUE KEY `sequence_name_index` (`name`(50)),
 
725
  KEY (`length_`)
 
726
) ENGINE=MyISAM;
 
727
 
 
728
INSERT INTO t1 VALUES
 
729
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
 
730
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
 
731
  (3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
 
732
  (4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
 
733
  (5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
 
734
  (6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
 
735
  (7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
 
736
  (8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
 
737
  (9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
 
738
#
 
739
SELECT _id FROM t1;
 
740
DELETE FROM t1 WHERE _id < 8;
 
741
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
 
742
SHOW TABLE STATUS LIKE 't1';
 
743
CHECK TABLE t1 EXTENDED;
 
744
OPTIMIZE TABLE t1;
 
745
CHECK TABLE t1 EXTENDED;
 
746
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
 
747
SHOW TABLE STATUS LIKE 't1';
 
748
SELECT _id FROM t1;
 
749
DROP TABLE t1;
 
750
#
 
751
# Test REPAIR QUICK. This retains the old data file.
 
752
CREATE TABLE t1 (
 
753
  `_id` int NOT NULL default '0',
 
754
  `url` text,
 
755
  `email` text,
 
756
  `description` text,
 
757
  `loverlap` int default NULL,
 
758
  `roverlap` int default NULL,
 
759
  `lneighbor_id` int default NULL,
 
760
  `rneighbor_id` int default NULL,
 
761
  `length_` int default NULL,
 
762
  `sequence` text,
 
763
  `name` text,
 
764
  `_obj_class` text NOT NULL,
 
765
  PRIMARY KEY  (`_id`),
 
766
  UNIQUE KEY `sequence_name_index` (`name`(50)),
 
767
  KEY (`length_`)
 
768
) ENGINE=MyISAM;
 
769
 
 
770
INSERT INTO t1 VALUES
 
771
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
 
772
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
 
773
  (3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
 
774
  (4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
 
775
  (5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
 
776
  (6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
 
777
  (7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
 
778
  (8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
 
779
  (9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
 
780
#
 
781
SELECT _id FROM t1;
 
782
DELETE FROM t1 WHERE _id < 8;
 
783
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
 
784
SHOW TABLE STATUS LIKE 't1';
 
785
CHECK TABLE t1 EXTENDED;
 
786
REPAIR TABLE t1 QUICK;
 
787
CHECK TABLE t1 EXTENDED;
 
788
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
 
789
SHOW TABLE STATUS LIKE 't1';
 
790
SELECT _id FROM t1;
 
791
DROP TABLE t1;
 
792
#
 
793
SET GLOBAL myisam_repair_threads=1;
 
794
SHOW VARIABLES LIKE 'myisam_repair%';
 
795
 
 
796
#
 
797
# BUG#21310 - Trees in SQL causing a "crashed" table with MyISAM storage
 
798
#             engine
 
799
#
 
800
 
 
801
# A simplified test case that reflect crashed table issue.
 
802
CREATE TABLE t1(a VARCHAR(16)) ENGINE=MyISAM;
 
803
INSERT INTO t1 VALUES('aaaaaaaa'),(NULL);
 
804
UPDATE t1 AS ta1, t1 AS ta2 SET ta1.a='aaaaaaaaaaaaaaaa';
 
805
SELECT * FROM t1;
 
806
DROP TABLE t1;
 
807
 
 
808
# A test case that reflect wrong result set.
 
809
CREATE TABLE t1(a INT) ENGINE=MyISAM;
 
810
INSERT INTO t1 VALUES(1),(2);
 
811
UPDATE t1,t1 AS t2 SET t1.a=t1.a+2 WHERE t1.a=t2.a-1;
 
812
SELECT * FROM t1 ORDER BY a;
639
813
DROP TABLE t1;
640
814
 
641
815
#
642
816
# Bug#24607 - MyISAM pointer size determined incorrectly
643
817
#
644
 
CREATE TEMPORARY TABLE t1 (c1 TEXT) ENGINE=MyISAM;
645
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
646
 
show table status like 't1';
 
818
CREATE TABLE t1 (c1 TEXT) ENGINE=MyISAM AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
 
819
--replace_column 5 X 6 X 7 X 9 X 10 X 11 X 12 X 13 X 14 X 16 X
 
820
SHOW TABLE STATUS LIKE 't1';
647
821
DROP TABLE t1;
648
822
 
649
823
#
650
824
# Bug#26231 - select count(*) on myisam table returns wrong value
651
825
#             when index is used
652
826
#
653
 
CREATE TEMPORARY TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
 
827
CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
654
828
# Fill at least two key blocks. "Tab, A" must be in both blocks. 
655
829
INSERT INTO t1 VALUES
656
830
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
798
972
 
799
973
let $default=`select @@storage_engine`;
800
974
set storage_engine=MyISAM;
801
 
let $temp= TEMPORARY;
802
975
source include/varchar.inc;
803
976
 
804
977
#
805
978
# Some errors/warnings on create
806
979
#
807
980
 
808
 
--error ER_TOO_BIG_FIELDLENGTH
809
 
create temporary table t1 (v varchar(65530), key(v));
810
 
--error ER_TOO_BIG_FIELDLENGTH
811
 
create temporary table t1 (v varchar(65536));
812
 
--error ER_TOO_BIG_FIELDLENGTH
813
 
create temporary table t1 (v varchar(65530));
 
981
--error 1074
 
982
create table t1 (v varchar(65530), key(v));
 
983
--error 1074
 
984
create table t1 (v varchar(65536));
 
985
--error 1074
 
986
create table t1 (v varchar(65530));
814
987
 
815
988
# MyISAM specific varchar tests
816
 
--error ER_TOO_BIG_FIELDLENGTH
817
 
create temporary table t1 (v varchar(65535));
 
989
--error 1074
 
990
create table t1 (v varchar(65535));
818
991
 
819
992
eval set storage_engine=$default;
820
993
 
821
994
 
822
995
# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
823
996
# different statistics on the same table with NULL values.
824
 
create temporary table t1 (a int, key(a)) engine=myisam;
 
997
create table t1 (a int, key(a));
825
998
 
826
999
insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
827
1000
analyze table t1;
835
1008
 
836
1009
 
837
1010
#
 
1011
# Bug#10056 - PACK_KEYS option take values greater than 1 while creating table
 
1012
#
 
1013
create table t1 (c1 int) engine=myisam pack_keys=0;
 
1014
create table t2 (c1 int) engine=myisam pack_keys=1;
 
1015
create table t3 (c1 int) engine=myisam pack_keys=default;
 
1016
--error 1064
 
1017
create table t4 (c1 int) engine=myisam pack_keys=2;
 
1018
drop table t1, t2, t3;
 
1019
 
 
1020
 
 
1021
#
838
1022
# Bug#28476: force index on a disabled myisam index gives error 124
839
1023
#
840
 
CREATE TEMPORARY TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
 
1024
CREATE TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
841
1025
INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
842
1026
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
843
1027
ALTER TABLE t1 DISABLE KEYS;
853
1037
#
854
1038
# Bug#4692 - DISABLE/ENABLE KEYS waste a space
855
1039
#
856
 
CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
857
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
858
 
show table status like 't1';
 
1040
CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
 
1041
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1042
SHOW TABLE STATUS LIKE 't1';
859
1043
INSERT INTO t1 VALUES (1,1);
860
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
861
 
show table status like 't1';
862
 
ALTER TABLE t1 DISABLE KEYS;
863
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
864
 
show table status like 't1';
865
 
ALTER TABLE t1 ENABLE KEYS;
866
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
867
 
show table status like 't1';
868
 
ALTER TABLE t1 DISABLE KEYS;
869
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
870
 
show table status like 't1';
871
 
ALTER TABLE t1 ENABLE KEYS;
872
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
873
 
show table status like 't1';
 
1044
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1045
SHOW TABLE STATUS LIKE 't1';
 
1046
ALTER TABLE t1 DISABLE KEYS;
 
1047
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1048
SHOW TABLE STATUS LIKE 't1';
 
1049
ALTER TABLE t1 ENABLE KEYS;
 
1050
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1051
SHOW TABLE STATUS LIKE 't1';
 
1052
ALTER TABLE t1 DISABLE KEYS;
 
1053
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1054
SHOW TABLE STATUS LIKE 't1';
 
1055
ALTER TABLE t1 ENABLE KEYS;
 
1056
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1057
SHOW TABLE STATUS LIKE 't1';
874
1058
#--exec ls -log var/master-data/test/t1.MYI
875
1059
#--exec myisamchk -dvv var/master-data/test/t1.MYI
876
1060
#--exec myisamchk -iev var/master-data/test/t1.MYI
877
1061
--echo # Enable keys with parallel repair
 
1062
SET GLOBAL myisam_repair_threads=2;
878
1063
ALTER TABLE t1 DISABLE KEYS;
879
1064
ALTER TABLE t1 ENABLE KEYS;
880
 
CHECK TABLE t1;
 
1065
SET GLOBAL myisam_repair_threads=1;
 
1066
CHECK TABLE t1 EXTENDED;
881
1067
DROP TABLE t1;
882
1068
 
883
1069
#
884
1070
# Bug#28837: MyISAM storage engine error (134) doing delete with self-join
885
1071
#
886
 
# DRIZZLE NOTE: Cannot self join on temp tables.
887
 
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id));
 
1072
 
 
1073
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
888
1074
CREATE TABLE t2 LIKE t1;
889
1075
 
890
1076
INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
892
1078
 
893
1079
SELECT * FROM t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
894
1080
SELECT * FROM t1;
 
1081
DELETE FROM a USING t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
 
1082
SELECT * FROM t1;
895
1083
 
896
1084
DROP TABLE t1, t2;
897
1085
 
899
1087
 
900
1088
 
901
1089
#
 
1090
# Test of key_block_size
 
1091
#
 
1092
 
 
1093
create table t1 (a int not null, key `a` (a) key_block_size=1024) ENGINE=MyISAM;
 
1094
show create table t1;
 
1095
drop table t1;
 
1096
 
 
1097
create table t1 (a int not null, key `a` (a) key_block_size=2048) ENGINE=MyISAM;
 
1098
show create table t1;
 
1099
drop table t1;
 
1100
 
 
1101
create table t1 (a varchar(2048), key `a` (a)) ENGINE=MyISAM;
 
1102
show create table t1;
 
1103
drop table t1;
 
1104
 
 
1105
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024) ENGINE=MyISAM;
 
1106
show create table t1;
 
1107
drop table t1;
 
1108
 
 
1109
create table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=1024;
 
1110
show create table t1;
 
1111
alter table t1 key_block_size=2048;
 
1112
show create table t1;
 
1113
alter table t1 add c int, add key (c);
 
1114
show create table t1;
 
1115
alter table t1 key_block_size=0;
 
1116
alter table t1 add d int, add key (d);
 
1117
show create table t1;
 
1118
drop table t1;
 
1119
 
 
1120
create table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=8192;
 
1121
show create table t1;
 
1122
drop table t1;
 
1123
 
 
1124
create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) ENGINE=MyISAM key_block_size=8192;
 
1125
show create table t1;
 
1126
drop table t1;
 
1127
 
 
1128
create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_block_size=8192) ENGINE=MyISAM key_block_size=16384;
 
1129
show create table t1;
 
1130
drop table t1;
 
1131
 
 
1132
 
 
1133
# Test limits and errors of key_block_size
 
1134
 
 
1135
create table t1 (a int not null, key `a` (a) key_block_size=512) ENGINE=MyISAM;
 
1136
show create table t1;
 
1137
drop table t1;
 
1138
 
 
1139
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000) ENGINE=MyISAM;
 
1140
show create table t1;
 
1141
drop table t1;
 
1142
 
 
1143
create table t1 (a int not null, key `a` (a) key_block_size=1025) ENGINE=MyISAM;
 
1144
show create table t1;
 
1145
drop table t1;
 
1146
 
 
1147
--error 1064
 
1148
create table t1 (a int not null, key key_block_size=1024 (a)) ENGINE=MyISAM;
 
1149
--error 1064
 
1150
create table t1 (a int not null, key `a` key_block_size=1024 (a)) ENGINE=MyISAM;
 
1151
 
 
1152
#
902
1153
# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk
903
1154
#
904
 
CREATE temporary TABLE t1 (
 
1155
CREATE TABLE t1 (
905
1156
  c1 INT,
906
1157
  c2 VARCHAR(300),
907
1158
  KEY (c1) KEY_BLOCK_SIZE 1024,
933
1184
  (33, REPEAT('x', CEIL(RAND() * 300))),
934
1185
  (34, REPEAT('y', CEIL(RAND() * 300))),
935
1186
  (35, REPEAT('z', CEIL(RAND() * 300)));
936
 
CREATE TEMPORARY TABLE t2 AS SELECT * FROM t1;
937
 
INSERT INTO t1 SELECT * FROM t2;
938
 
DROP TABLE t2;
939
 
CREATE TEMPORARY TABLE t2 AS SELECT * FROM t1;
940
 
INSERT INTO t1 SELECT * FROM t2;
941
 
DROP TABLE t2;
 
1187
INSERT INTO t1 SELECT * FROM t1;
 
1188
INSERT INTO t1 SELECT * FROM t1;
942
1189
CHECK TABLE t1;
 
1190
REPAIR TABLE t1;
943
1191
DELETE FROM t1 WHERE c1 >= 10;
944
1192
CHECK TABLE t1;
945
1193
DROP TABLE t1;
951
1199
# Test #1 - CHECK TABLE sees wrong record, REPAR TABLE deletes it.
952
1200
# Using a CHAR column that can have > 127 characters.
953
1201
# Using a VARCHAR to create a table with dynamic row format.
954
 
CREATE temporary TABLE t1 (
 
1202
CREATE TABLE t1 (
955
1203
  c1 CHAR(130),
956
1204
  c2 VARCHAR(1)
957
1205
) ENGINE=MyISAM;
958
1206
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
959
1207
SELECT COUNT(*) FROM t1;
960
1208
CHECK TABLE t1;
 
1209
REPAIR TABLE t1;
961
1210
SELECT COUNT(*) FROM t1;
962
1211
CHECK TABLE t1;
963
1212
DROP TABLE t1;
965
1214
# Test #2 - same as test #1, but using EXTENDED.
966
1215
# Using a CHAR column that can have > 127 characters.
967
1216
# Using a VARCHAR to create a table with dynamic row format.
968
 
CREATE temporary TABLE t1 (
 
1217
CREATE TABLE t1 (
969
1218
  c1 CHAR(130),
970
1219
  c2 VARCHAR(1)
971
1220
) ENGINE=MyISAM;
972
1221
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
973
1222
SELECT COUNT(*) FROM t1;
974
 
CHECK TABLE t1;
 
1223
CHECK TABLE t1 EXTENDED;
 
1224
REPAIR TABLE t1 EXTENDED;
975
1225
SELECT COUNT(*) FROM t1;
976
 
CHECK TABLE t1;
 
1226
CHECK TABLE t1 EXTENDED;
977
1227
DROP TABLE t1;
978
1228
#
979
1229
# Test #3 - same as test #1, but using OPTIMIZE TABLE.
980
1230
# Using a CHAR column that can have > 127 characters.
981
1231
# Using a VARCHAR to create a table with dynamic row format.
982
 
CREATE temporary TABLE t1 (
 
1232
CREATE TABLE t1 (
983
1233
  c1 CHAR(130),
984
1234
  c2 VARCHAR(1)
985
1235
) ENGINE=MyISAM;
989
1239
INSERT INTO t1 VALUES('c', 'b');
990
1240
DELETE FROM t1 WHERE c1='b';
991
1241
SELECT COUNT(*) FROM t1;
992
 
ALTER TABLE t1 ENGINE=MyISAM;
 
1242
OPTIMIZE TABLE t1;
993
1243
SELECT COUNT(*) FROM t1;
994
1244
DROP TABLE t1;
995
1245
#
997
1247
# Using a CHAR column that can have > 127 characters.
998
1248
# Using a VARCHAR to create a table with dynamic row format.
999
1249
# Using an index which can be disabled during bulk insert.
1000
 
CREATE temporary TABLE t1 (
 
1250
CREATE TABLE t1 (
1001
1251
  c1 CHAR(130),
1002
1252
  c2 VARCHAR(1),
1003
1253
  KEY (c1)
1024
1274
# With bug present, this shows that all long rows are gone.
1025
1275
SELECT COUNT(*) FROM t1;
1026
1276
CHECK TABLE t1;
1027
 
CHECK TABLE t1;
 
1277
CHECK TABLE t1 EXTENDED;
1028
1278
DROP TABLE t1;
1029
1279
#
1030
1280
# Test #5 - same as test #1 but UTF-8.
1031
1281
# Using a CHAR column that can have > 127 characters.
1032
1282
# Using a VARCHAR to create a table with dynamic row format.
1033
 
CREATE temporary TABLE t1 (
 
1283
CREATE TABLE t1 (
1034
1284
  c1 CHAR(50),
1035
1285
  c2 VARCHAR(1)
1036
1286
) ENGINE=MyISAM;
1038
1288
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1039
1289
SELECT COUNT(*) FROM t1;
1040
1290
CHECK TABLE t1;
 
1291
REPAIR TABLE t1;
1041
1292
SELECT COUNT(*) FROM t1;
1042
1293
CHECK TABLE t1;
1043
1294
DROP TABLE t1;
1045
1296
# Test #6 - same as test #2, but UTF-8.
1046
1297
# Using a CHAR column that can have > 127 characters.
1047
1298
# Using a VARCHAR to create a table with dynamic row format.
1048
 
CREATE temporary TABLE t1 (
 
1299
CREATE TABLE t1 (
1049
1300
  c1 CHAR(50),
1050
1301
  c2 VARCHAR(1)
1051
1302
) ENGINE=MyISAM;
1052
1303
# Using Tamil Letter A, Unicode U+0B85
1053
1304
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1054
1305
SELECT COUNT(*) FROM t1;
1055
 
CHECK TABLE t1;
 
1306
CHECK TABLE t1 EXTENDED;
 
1307
REPAIR TABLE t1 EXTENDED;
1056
1308
SELECT COUNT(*) FROM t1;
1057
 
CHECK TABLE t1;
 
1309
CHECK TABLE t1 EXTENDED;
1058
1310
DROP TABLE t1;
1059
1311
#
1060
1312
# Test #7 - same as test #3, but UTF-8.
1061
1313
# Using a CHAR column that can have > 127 characters.
1062
1314
# Using a VARCHAR to create a table with dynamic row format.
1063
 
CREATE temporary TABLE t1 (
 
1315
CREATE TABLE t1 (
1064
1316
  c1 CHAR(50),
1065
1317
  c2 VARCHAR(1)
1066
1318
) ENGINE=MyISAM;
1071
1323
INSERT INTO t1 VALUES('c', 'b');
1072
1324
DELETE FROM t1 WHERE c1='b';
1073
1325
SELECT COUNT(*) FROM t1;
1074
 
ALTER TABLE t1 ENGINE=MyISAM;
 
1326
OPTIMIZE TABLE t1;
1075
1327
SELECT COUNT(*) FROM t1;
1076
1328
DROP TABLE t1;
1077
1329
#
1079
1331
# Using a CHAR column that can have > 42 UTF-8 characters.
1080
1332
# Using a VARCHAR to create a table with dynamic row format.
1081
1333
# Using an index which can be disabled during bulk insert.
1082
 
CREATE temporary TABLE t1 (
 
1334
CREATE TABLE t1 (
1083
1335
  c1 CHAR(50),
1084
1336
  c2 VARCHAR(1),
1085
1337
  KEY (c1)
1107
1359
# With bug present, this shows that all long rows are gone.
1108
1360
SELECT COUNT(*) FROM t1;
1109
1361
CHECK TABLE t1;
1110
 
CHECK TABLE t1;
 
1362
CHECK TABLE t1 EXTENDED;
1111
1363
DROP TABLE t1;
 
1364
 
 
1365
#
 
1366
# Bug#29182 - MyISAMCHK reports wrong character set
 
1367
#
 
1368
#@TODO Disabling the below, as no myisamcheck program
 
1369
#CREATE TABLE t1 (
 
1370
#  c1 VARCHAR(10) NOT NULL,
 
1371
#  c2 CHAR(10) DEFAULT NULL,
 
1372
#  c3 VARCHAR(10) NOT NULL,
 
1373
#  KEY (c1),
 
1374
#  KEY (c2)
 
1375
#) ENGINE=MyISAM PACK_KEYS=0;
 
1376
#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
1377
#--exec $DRIZZLECHK -d $MYSQLTEST_VARDIR/master-data/test/t1
 
1378
#DROP TABLE t1;
 
1379
#
1112
1380
--echo End of 5.1 tests
1113
1381