~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/myisam.test

  • Committer: Brian Aker
  • Date: 2009-02-12 22:45:08 UTC
  • Revision ID: brian@tangent.org-20090212224508-mrd9jwgn1zjdpqdk
Minor refactoring (we will need to disconnect the code from the include
file).

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
enable_query_log;
47
47
check table t1;
48
48
repair table t1;
49
 
delete from t1 where (a & 1);
 
49
 
 
50
# @TODO Because there are no notes on what the heck this
 
51
# is actually testing (which bug?), it's difficult to tell
 
52
# what the below DELETE statement is doing.  Since we don't
 
53
# support bitwise operators, I am replacing the delete statement
 
54
# with a version we support.
 
55
#delete from t1 where (a & 1);
 
56
delete from t1 where (a mod 2) = 1;
50
57
check table t1;
51
58
repair table t1;
52
59
check table t1;
83
90
#
84
91
# Test of OPTIMIZE of locked and modified tables
85
92
#
86
 
CREATE TABLE t1 (a INT);
 
93
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
87
94
INSERT INTO  t1 VALUES (1), (2), (3);
88
95
LOCK TABLES t1 WRITE;
89
96
INSERT INTO  t1 VALUES (1), (2), (3);
257
264
int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
258
265
int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
259
266
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;
 
267
int, i999 int, i1000 int, b blob) engine=myisam row_format=dynamic;
261
268
insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
262
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,
263
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,
309
316
# Test of REPAIR that once failed
310
317
#
311
318
CREATE TABLE `t1` (
312
 
  `post_id` mediumint(8) NOT NULL auto_increment,
313
 
  `topic_id` mediumint(8) NOT NULL default '0',
314
 
  `post_time` datetime NOT NULL default '0000-00-00 00:00:00',
 
319
  `post_id` int NOT NULL auto_increment,
 
320
  `topic_id` int NOT NULL default '0',
 
321
  `post_time` datetime,
315
322
  `post_text` text NOT NULL,
316
323
  `icon_url` varchar(10) NOT NULL default '',
317
 
  `sign` int(1) NOT NULL default '0',
 
324
  `sign` int NOT NULL default '0',
318
325
  `post_edit` varchar(150) NOT NULL default '',
319
326
  `poster_login` varchar(35) NOT NULL default '',
320
327
  `ip` varchar(15) NOT NULL default '',
322
329
  KEY `post_time` (`post_time`),
323
330
  KEY `ip` (`ip`),
324
331
  KEY `poster_login` (`poster_login`),
325
 
  KEY `topic_id` (`topic_id`),
326
 
  FULLTEXT KEY `post_text` (`post_text`)
 
332
  KEY `topic_id` (`topic_id`)
 
333
#  FULLTEXT KEY `post_text` (`post_text`)
327
334
) ENGINE=MyISAM;
328
335
 
329
336
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
337
 
331
 
REPAIR TABLE t1;
 
338
# @TODO The REPAIR TABLE statement crashes server.
 
339
# Bug#309802: https://bugs.launchpad.net/drizzle/+bug/309802
 
340
# Commenting it out for now to proceed in testing. - JRP
 
341
# REPAIR TABLE t1;
332
342
CHECK TABLE t1;
333
343
drop table t1;
334
344
 
337
347
#
338
348
 
339
349
--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));
 
350
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;
 
351
CREATE TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300)) ENGINE=MyISAM;
342
352
--error 1071
343
353
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
344
354
DROP TABLE t1;
347
357
# Test of cardinality of keys with NULL
348
358
#
349
359
 
350
 
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a));
 
360
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)) ENGINE=MyISAM;
351
361
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
352
362
create table t2 (a int not null, b int, c int, key(b), key(c), key(a));
353
363
INSERT into t2 values (1,1,1), (2,2,2);
371
381
create table t1 (a int not null auto_increment primary key, b varchar(255));
372
382
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
373
383
update t1 set b=repeat(left(b,1),200) where a=1;
374
 
delete from t1 where (a & 1)= 0;
 
384
 
 
385
# @TODO Because there are no notes on what the heck this
 
386
# is actually testing (which bug?), it's difficult to tell
 
387
# what the below DELETE statement is doing.  Since we don't
 
388
# support bitwise operators, I am replacing the delete statement
 
389
# with a version we support.
 
390
#delete from t1 where (a & 1)= 0;
 
391
delete from t1 where (a mod 2) = 0;
375
392
update t1 set b=repeat('e',200) where a=1;
376
393
flush tables;
377
394
check table t1;
384
401
let $1 = 100;
385
402
while ($1)
386
403
{
387
 
  eval insert into t1 (b) values (repeat(char(($1 & 32)+65), $1));
 
404
  eval insert into t1 (b) values (repeat(char
 
405
    (
 
406
      if($1 < 32, 0, 
 
407
        if($1 >= 64 and $1 <= 95, 0, 32)
 
408
      )
 
409
    +65), $1));
388
410
  dec $1;
389
411
}
390
412
enable_query_log;
426
448
# space-stripping in _mi_prefix_search: BUG#5284
427
449
#
428
450
DROP TABLE IF EXISTS t1;
429
 
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a)); 
 
451
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a)) ENGINE=MyISAM; 
430
452
INSERT t1 VALUES ("can \tcan"); 
431
453
INSERT t1 VALUES ("can   can"); 
432
454
INSERT t1 VALUES ("can"); 
491
513
#
492
514
# Bug #14400  Join could miss concurrently inserted row
493
515
#
 
516
# @TODO The below test hangs drizzle. Commenting out for now so I can continue with this test. - JRP
 
517
#
494
518
# 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;
 
519
#create table t1 (a int not null, primary key(a));
 
520
#create table t2 (a int not null, b int not null, primary key(a,b));
 
521
#insert into t1 values (1),(2),(3),(4),(5),(6);
 
522
#insert into t2 values (1,1),(2,1);
 
523
#lock tables t1 read local, t2 read local;
 
524
#select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
 
525
#connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
 
526
#insert into t2 values(2,0);
 
527
#disconnect root;
 
528
#connection default;
 
529
#select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
 
530
#unlock tables;
 
531
#drop table t1,t2;
508
532
#
509
533
# 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;
 
534
#CREATE TABLE t1 (c1 varchar(250) NOT NULL);
 
535
#CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
 
536
#INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
 
537
#INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
 
538
#LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
 
539
#SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
 
540
#  WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
 
541
#connect (con1,localhost,root,,);
 
542
#connection con1;
 
543
#INSERT INTO t2 VALUES ('test000001'), ('test000005');
 
544
#disconnect con1;
 
545
#connection default;
 
546
#SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
 
547
#  WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
 
548
#UNLOCK TABLES;
 
549
#DROP TABLE t1,t2;
526
550
 
527
551
# End of 4.0 tests
528
552
 
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
553
create table t1 (a int, b varchar(200), c text not null) checksum=1;
539
554
create table t2 (a int, b varchar(200), c text not null) checksum=0;
540
555
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
545
560
#show table status;
546
561
drop table t1,t2;
547
562
 
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;
 
563
#@TODO Figure out what the heck the below is testing.
 
564
#      It bombs the test with unknown system variables...
 
565
#
 
566
#create table t1 (a int, key (a));
 
567
#show keys from t1;
 
568
#alter table t1 disable keys;
 
569
#show keys from t1;
 
570
#create table t2 (a int);
 
571
#let $i=1000;
 
572
#set @@rand_seed1=31415926,@@rand_seed2=2718281828;
 
573
#--disable_query_log
 
574
#while ($i)
 
575
#{
 
576
#  dec $i;
 
577
#  insert t2 values (rand()*100000);
 
578
#}
 
579
#--enable_query_log
 
580
#insert t1 select * from t2;
 
581
#show keys from t1;
 
582
#alter table t1 enable keys;
 
583
#show keys from t1;
 
584
#alter table t1 engine=heap;
 
585
#alter table t1 disable keys;
 
586
#show keys from t1;
 
587
#drop table t1,t2;
570
588
 
571
589
#
572
590
# index search for NULL in blob. Bug #4816
581
599
# bug9188 - Corruption Can't open file: 'table.MYI' (errno: 145)
582
600
#
583
601
create table t1 (c1 int, c2 varchar(4) not null default '',
584
 
                 key(c2(3))) default charset=utf8;
 
602
                 key(c2(3)));
585
603
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
586
604
update t1 set c2='A  B' where c1=2;
587
605
check table t1;
606
624
#
607
625
# BUG#12232: New myisam_stats_method variable.
608
626
#
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;
 
627
# @TODO The following segfaults. Disabling for now - JRP
 
628
#
 
629
#show variables like 'myisam_stats_method';
 
630
#
 
631
#create table t1 (a int, key(a));
 
632
#insert into t1 values (0),(1),(2),(3),(4);
 
633
#insert into t1 select NULL from t1;
615
634
 
616
635
# 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;
 
636
#analyze table t1; 
 
637
#show index from t1;
 
638
#insert into t1 values (11);
 
639
#delete from t1 where a=11;
 
640
#check table t1;
 
641
#show index from t1;
623
642
 
624
643
# 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
 
 
 
644
#set myisam_stats_method=nulls_equal;
 
645
#show variables like 'myisam_stats_method';
 
646
#insert into t1 values (11);
 
647
#delete from t1 where a=11;
 
648
 
 
649
#analyze table t1; 
 
650
#show index from t1;
 
651
#
 
652
#insert into t1 values (11);
 
653
#delete from t1 where a=11;
 
654
#
 
655
#check table t1;
 
656
#show index from t1;
 
657
#
639
658
# 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;
 
659
#set myisam_stats_method=DEFAULT;
 
660
#show variables like 'myisam_stats_method';
 
661
#insert into t1 values (11);
 
662
#delete from t1 where a=11;
 
663
#
 
664
#analyze table t1; 
 
665
#show index from t1;
 
666
#
 
667
#insert into t1 values (11);
 
668
#delete from t1 where a=11;
 
669
#
 
670
#check table t1;
 
671
#show index from t1;
 
672
#
 
673
#drop table t1;
655
674
 
656
675
# 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
#set myisam_stats_method=nulls_ignored;
 
677
#show variables like 'myisam_stats_method';
 
678
#
 
679
#create table t1 (
 
680
#  a char(3), b char(4), c char(5), d char(6),
 
681
#  key(a,b,c,d)
 
682
#);
 
683
#insert into t1 values ('bcd','def1', NULL, 'zz');
 
684
#insert into t1 values ('bcd','def2', NULL, 'zz');
 
685
#insert into t1 values ('bce','def1', 'yuu', NULL);
 
686
#insert into t1 values ('bce','def2', NULL, 'quux');
 
687
#analyze table t1;
 
688
#show index from t1;
 
689
#delete from t1;
 
690
#analyze table t1;
 
691
#show index from t1;
 
692
#
 
693
#set myisam_stats_method=DEFAULT;
 
694
#drop table t1;
676
695
 
677
696
# BUG#13814 - key value packed incorrectly for TINYBLOBs
678
697
 
733
752
#
734
753
# Bug#8283 - OPTIMIZE TABLE causes data loss
735
754
#
736
 
SET @@myisam_repair_threads=2;
 
755
SET GLOBAL myisam_repair_threads=2;
737
756
SHOW VARIABLES LIKE 'myisam_repair%';
738
757
#
739
758
# Test OPTIMIZE. This creates a new data file.
740
759
CREATE TABLE t1 (
741
 
  `_id` int(11) NOT NULL default '0',
 
760
  `_id` int NOT NULL default '0',
742
761
  `url` text,
743
762
  `email` text,
744
763
  `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,
 
764
  `loverlap` int default NULL,
 
765
  `roverlap` int default NULL,
 
766
  `lneighbor_id` int default NULL,
 
767
  `rneighbor_id` int default NULL,
 
768
  `length_` int default NULL,
 
769
  `sequence` text,
751
770
  `name` text,
752
771
  `_obj_class` text NOT NULL,
753
772
  PRIMARY KEY  (`_id`),
754
773
  UNIQUE KEY `sequence_name_index` (`name`(50)),
755
774
  KEY (`length_`)
756
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
757
 
#
 
775
) ENGINE=MyISAM;
 
776
 
758
777
INSERT INTO t1 VALUES
759
778
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
760
779
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
780
799
#
781
800
# Test REPAIR QUICK. This retains the old data file.
782
801
CREATE TABLE t1 (
783
 
  `_id` int(11) NOT NULL default '0',
 
802
  `_id` int NOT NULL default '0',
784
803
  `url` text,
785
804
  `email` text,
786
805
  `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,
 
806
  `loverlap` int default NULL,
 
807
  `roverlap` int default NULL,
 
808
  `lneighbor_id` int default NULL,
 
809
  `rneighbor_id` int default NULL,
 
810
  `length_` int default NULL,
 
811
  `sequence` text,
793
812
  `name` text,
794
813
  `_obj_class` text NOT NULL,
795
814
  PRIMARY KEY  (`_id`),
796
815
  UNIQUE KEY `sequence_name_index` (`name`(50)),
797
816
  KEY (`length_`)
798
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
799
 
#
 
817
) ENGINE=MyISAM;
 
818
 
800
819
INSERT INTO t1 VALUES
801
820
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
802
821
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
820
839
SELECT _id FROM t1;
821
840
DROP TABLE t1;
822
841
#
823
 
SET @@myisam_repair_threads=1;
 
842
SET GLOBAL myisam_repair_threads=1;
824
843
SHOW VARIABLES LIKE 'myisam_repair%';
825
844
 
826
845
#
829
848
#
830
849
 
831
850
# A simplified test case that reflect crashed table issue.
832
 
CREATE TABLE t1(a VARCHAR(16));
 
851
CREATE TABLE t1(a VARCHAR(16)) ENGINE=MyISAM;
833
852
INSERT INTO t1 VALUES('aaaaaaaa'),(NULL);
834
853
UPDATE t1 AS ta1, t1 AS ta2 SET ta1.a='aaaaaaaaaaaaaaaa';
835
854
SELECT * FROM t1;
836
855
DROP TABLE t1;
837
856
 
838
857
# A test case that reflect wrong result set.
839
 
CREATE TABLE t1(a INT);
 
858
CREATE TABLE t1(a INT) ENGINE=MyISAM;
840
859
INSERT INTO t1 VALUES(1),(2);
841
860
UPDATE t1,t1 AS t2 SET t1.a=t1.a+2 WHERE t1.a=t2.a-1;
842
861
SELECT * FROM t1 ORDER BY a;
845
864
#
846
865
# Bug#24607 - MyISAM pointer size determined incorrectly
847
866
#
848
 
CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
 
867
CREATE TABLE t1 (c1 TEXT) ENGINE=MyISAM AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
849
868
--replace_column 5 X 6 X 7 X 9 X 10 X 11 X 12 X 13 X 14 X 16 X
850
869
SHOW TABLE STATUS LIKE 't1';
851
870
DROP TABLE t1;
1008
1027
# Some errors/warnings on create
1009
1028
#
1010
1029
 
 
1030
--error 1074
1011
1031
create table t1 (v varchar(65530), key(v));
1012
 
drop table if exists t1;
 
1032
--error 1074
1013
1033
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;
 
1034
--error 1074
 
1035
create table t1 (v varchar(65530));
1019
1036
 
1020
1037
# MyISAM specific varchar tests
1021
 
--error 1118
 
1038
--error 1074
1022
1039
create table t1 (v varchar(65535));
1023
1040
 
1024
1041
eval set storage_engine=$default;
1027
1044
# Test concurrent insert
1028
1045
# First with static record length
1029
1046
#
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;
 
1047
#@TODO The below test fails with unknown system variable
 
1048
#      concurrent_insert
 
1049
#
 
1050
#set @save_concurrent_insert=@@concurrent_insert;
 
1051
#set global concurrent_insert=1;
 
1052
#create table t1 (a int);
 
1053
#insert into t1 values (1),(2),(3),(4),(5);
 
1054
#lock table t1 read local;
 
1055
#connect (con1,localhost,root,,);
 
1056
#connection con1;
1037
1057
# 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;
 
1058
#insert into t1 values(6),(7);
 
1059
#connection default;
 
1060
#unlock tables;
 
1061
#delete from t1 where a>=3 and a<=4;
 
1062
#lock table t1 read local;
 
1063
#connection con1;
 
1064
#set global concurrent_insert=2;
1045
1065
# Insert in table with hole -> Should insert at end
1046
 
insert into t1 values (8),(9);
1047
 
connection default;
1048
 
unlock tables;
 
1066
#insert into t1 values (8),(9);
 
1067
#connection default;
 
1068
#unlock tables;
1049
1069
# 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;
 
1070
#insert into t1 values (10),(11),(12);
 
1071
#select * from t1;
 
1072
#check table t1;
 
1073
#drop table t1;
 
1074
#disconnect con1;
1055
1075
 
1056
1076
# 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;
 
1077
#create table t1 (a int, b varchar(30) default "hello");
 
1078
#insert into t1 (a) values (1),(2),(3),(4),(5);
 
1079
#lock table t1 read local;
 
1080
#connect (con1,localhost,root,,);
 
1081
#connection con1;
1062
1082
# 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;
 
1083
#insert into t1 (a) values(6),(7);
 
1084
#connection default;
 
1085
#unlock tables;
 
1086
#delete from t1 where a>=3 and a<=4;
 
1087
#lock table t1 read local;
 
1088
#connection con1;
 
1089
#set global concurrent_insert=2;
 
1090
## Insert in table with hole -> Should insert at end
 
1091
#insert into t1 (a) values (8),(9);
 
1092
#connection default;
 
1093
#unlock tables;
1074
1094
# 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;
 
1095
#insert into t1 (a) values (10),(11),(12);
 
1096
#select a from t1;
 
1097
#check table t1;
 
1098
#drop table t1;
 
1099
#disconnect con1;
 
1100
#set global concurrent_insert=@save_concurrent_insert;
1081
1101
 
1082
1102
 
1083
1103
# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
1147
1167
#--exec myisamchk -dvv var/master-data/test/t1.MYI
1148
1168
#--exec myisamchk -iev var/master-data/test/t1.MYI
1149
1169
--echo # Enable keys with parallel repair
1150
 
SET @@myisam_repair_threads=2;
 
1170
SET GLOBAL myisam_repair_threads=2;
1151
1171
ALTER TABLE t1 DISABLE KEYS;
1152
1172
ALTER TABLE t1 ENABLE KEYS;
1153
 
SET @@myisam_repair_threads=1;
 
1173
SET GLOBAL myisam_repair_threads=1;
1154
1174
CHECK TABLE t1 EXTENDED;
1155
1175
DROP TABLE t1;
1156
1176
 
1178
1198
# Test of key_block_size
1179
1199
#
1180
1200
 
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;
 
1201
create table t1 (a int not null, key `a` (a) key_block_size=1024) ENGINE=MyISAM;
 
1202
show create table t1;
 
1203
drop table t1;
 
1204
 
 
1205
create table t1 (a int not null, key `a` (a) key_block_size=2048) ENGINE=MyISAM;
 
1206
show create table t1;
 
1207
drop table t1;
 
1208
 
 
1209
create table t1 (a varchar(2048), key `a` (a)) ENGINE=MyISAM;
 
1210
show create table t1;
 
1211
drop table t1;
 
1212
 
 
1213
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024) ENGINE=MyISAM;
 
1214
show create table t1;
 
1215
drop table t1;
 
1216
 
 
1217
create table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=1024;
1198
1218
show create table t1;
1199
1219
alter table t1 key_block_size=2048;
1200
1220
show create table t1;
1205
1225
show create table t1;
1206
1226
drop table t1;
1207
1227
 
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;
 
1228
create table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=8192;
 
1229
show create table t1;
 
1230
drop table t1;
 
1231
 
 
1232
create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) ENGINE=MyISAM key_block_size=8192;
 
1233
show create table t1;
 
1234
drop table t1;
 
1235
 
 
1236
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;
1217
1237
show create table t1;
1218
1238
drop table t1;
1219
1239
 
1220
1240
 
1221
1241
# Test limits and errors of key_block_size
1222
1242
 
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));
 
1243
create table t1 (a int not null, key `a` (a) key_block_size=512) ENGINE=MyISAM;
 
1244
show create table t1;
 
1245
drop table t1;
 
1246
 
 
1247
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000) ENGINE=MyISAM;
 
1248
show create table t1;
 
1249
drop table t1;
 
1250
 
 
1251
create table t1 (a int not null, key `a` (a) key_block_size=1025) ENGINE=MyISAM;
 
1252
show create table t1;
 
1253
drop table t1;
 
1254
 
 
1255
--error 1064
 
1256
create table t1 (a int not null, key key_block_size=1024 (a)) ENGINE=MyISAM;
 
1257
--error 1064
 
1258
create table t1 (a int not null, key `a` key_block_size=1024 (a)) ENGINE=MyISAM;
1239
1259
 
1240
1260
#
1241
1261
# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk
1245
1265
  c2 VARCHAR(300),
1246
1266
  KEY (c1) KEY_BLOCK_SIZE 1024,
1247
1267
  KEY (c2) KEY_BLOCK_SIZE 8192
1248
 
  );
 
1268
  ) ENGINE=MyISAM;
1249
1269
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
1250
1270
  (11, REPEAT('b', CEIL(RAND() * 300))),
1251
1271
  (12, REPEAT('c', CEIL(RAND() * 300))),
1371
1391
CREATE TABLE t1 (
1372
1392
  c1 CHAR(50),
1373
1393
  c2 VARCHAR(1)
1374
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1394
) ENGINE=MyISAM;
1375
1395
# Using Tamil Letter A, Unicode U+0B85
1376
 
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
1396
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1377
1397
SELECT COUNT(*) FROM t1;
1378
1398
CHECK TABLE t1;
1379
1399
REPAIR TABLE t1;
1387
1407
CREATE TABLE t1 (
1388
1408
  c1 CHAR(50),
1389
1409
  c2 VARCHAR(1)
1390
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1410
) ENGINE=MyISAM;
1391
1411
# Using Tamil Letter A, Unicode U+0B85
1392
 
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
1412
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1393
1413
SELECT COUNT(*) FROM t1;
1394
1414
CHECK TABLE t1 EXTENDED;
1395
1415
REPAIR TABLE t1 EXTENDED;
1403
1423
CREATE TABLE t1 (
1404
1424
  c1 CHAR(50),
1405
1425
  c2 VARCHAR(1)
1406
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1426
) ENGINE=MyISAM;
1407
1427
# Using Tamil Letter A, Unicode U+0B85
1408
 
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
1428
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1409
1429
# Insert more rows and delete one in the middle to force optimize.
1410
1430
INSERT INTO t1 VALUES('b', 'b');
1411
1431
INSERT INTO t1 VALUES('c', 'b');
1423
1443
  c1 CHAR(50),
1424
1444
  c2 VARCHAR(1),
1425
1445
  KEY (c1)
1426
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1446
) ENGINE=MyISAM;
1427
1447
#
1428
1448
# Insert 100 rows. This turns bulk insert on during the copy phase of
1429
1449
# ALTER TABLE. Bulk insert disables keys before the insert and re-enables
1440
1460
#
1441
1461
# Change most of the rows into long character values with > 42 characters.
1442
1462
# Using Tamil Letter A, Unicode U+0B85
1443
 
UPDATE t1 SET c1=REPEAT(_utf8 x'e0ae85',43) LIMIT 90;
 
1463
UPDATE t1 SET c1=REPEAT( x'e0ae85',43) LIMIT 90;
1444
1464
SELECT COUNT(*) FROM t1;
1445
1465
ALTER TABLE t1 ENGINE=MyISAM;
1446
1466
#
1453
1473
#
1454
1474
# Bug#29182 - MyISAMCHK reports wrong character set
1455
1475
#
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
 
 
 
1476
#@TODO Disabling the below, as no myisamcheck program
 
1477
#CREATE TABLE t1 (
 
1478
#  c1 VARCHAR(10) NOT NULL,
 
1479
#  c2 CHAR(10) DEFAULT NULL,
 
1480
#  c3 VARCHAR(10) NOT NULL,
 
1481
#  KEY (c1),
 
1482
#  KEY (c2)
 
1483
#) ENGINE=MyISAM PACK_KEYS=0;
 
1484
#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
1485
#--exec $DRIZZLECHK -d $MYSQLTEST_VARDIR/master-data/test/t1
 
1486
#DROP TABLE t1;
 
1487
#
1467
1488
--echo End of 5.1 tests
1468
1489