~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/myisam.test

  • Committer: Brian Aker
  • Date: 2009-03-27 22:55:28 UTC
  • mto: This revision was merged to the branch mainline in revision 968.
  • Revision ID: brian@tangent.org-20090327225528-8y76cfx8a4oemqv9
Remove ref_count

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
 
679
698
create table t1(
680
699
  cip INT NOT NULL,
681
 
  time TIME NOT NULL,
682
700
  score INT NOT NULL DEFAULT 0,
683
701
  bob TINYBLOB
684
702
);
685
703
 
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');
 
704
insert into t1 (cip) VALUES (1), (2), (3);
 
705
insert into t1 (cip, bob) VALUES (4, 'a' ), (5, 'b'), 
 
706
                                       (6, 'c');
689
707
select * from t1 where bob is null and cip=1;
690
 
create index bug on t1 (bob(22), cip, time);
 
708
create index bug on t1 (bob(22), cip);
691
709
select * from t1 where bob is null and cip=1;
692
710
drop table t1;
693
711
 
733
751
#
734
752
# Bug#8283 - OPTIMIZE TABLE causes data loss
735
753
#
736
 
SET @@myisam_repair_threads=2;
 
754
SET GLOBAL myisam_repair_threads=2;
737
755
SHOW VARIABLES LIKE 'myisam_repair%';
738
756
#
739
757
# Test OPTIMIZE. This creates a new data file.
740
758
CREATE TABLE t1 (
741
 
  `_id` int(11) NOT NULL default '0',
 
759
  `_id` int NOT NULL default '0',
742
760
  `url` text,
743
761
  `email` text,
744
762
  `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,
 
763
  `loverlap` int default NULL,
 
764
  `roverlap` int default NULL,
 
765
  `lneighbor_id` int default NULL,
 
766
  `rneighbor_id` int default NULL,
 
767
  `length_` int default NULL,
 
768
  `sequence` text,
751
769
  `name` text,
752
770
  `_obj_class` text NOT NULL,
753
771
  PRIMARY KEY  (`_id`),
754
772
  UNIQUE KEY `sequence_name_index` (`name`(50)),
755
773
  KEY (`length_`)
756
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
757
 
#
 
774
) ENGINE=MyISAM;
 
775
 
758
776
INSERT INTO t1 VALUES
759
777
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
760
778
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
780
798
#
781
799
# Test REPAIR QUICK. This retains the old data file.
782
800
CREATE TABLE t1 (
783
 
  `_id` int(11) NOT NULL default '0',
 
801
  `_id` int NOT NULL default '0',
784
802
  `url` text,
785
803
  `email` text,
786
804
  `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,
 
805
  `loverlap` int default NULL,
 
806
  `roverlap` int default NULL,
 
807
  `lneighbor_id` int default NULL,
 
808
  `rneighbor_id` int default NULL,
 
809
  `length_` int default NULL,
 
810
  `sequence` text,
793
811
  `name` text,
794
812
  `_obj_class` text NOT NULL,
795
813
  PRIMARY KEY  (`_id`),
796
814
  UNIQUE KEY `sequence_name_index` (`name`(50)),
797
815
  KEY (`length_`)
798
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
799
 
#
 
816
) ENGINE=MyISAM;
 
817
 
800
818
INSERT INTO t1 VALUES
801
819
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
802
820
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
820
838
SELECT _id FROM t1;
821
839
DROP TABLE t1;
822
840
#
823
 
SET @@myisam_repair_threads=1;
 
841
SET GLOBAL myisam_repair_threads=1;
824
842
SHOW VARIABLES LIKE 'myisam_repair%';
825
843
 
826
844
#
829
847
#
830
848
 
831
849
# A simplified test case that reflect crashed table issue.
832
 
CREATE TABLE t1(a VARCHAR(16));
 
850
CREATE TABLE t1(a VARCHAR(16)) ENGINE=MyISAM;
833
851
INSERT INTO t1 VALUES('aaaaaaaa'),(NULL);
834
852
UPDATE t1 AS ta1, t1 AS ta2 SET ta1.a='aaaaaaaaaaaaaaaa';
835
853
SELECT * FROM t1;
836
854
DROP TABLE t1;
837
855
 
838
856
# A test case that reflect wrong result set.
839
 
CREATE TABLE t1(a INT);
 
857
CREATE TABLE t1(a INT) ENGINE=MyISAM;
840
858
INSERT INTO t1 VALUES(1),(2);
841
859
UPDATE t1,t1 AS t2 SET t1.a=t1.a+2 WHERE t1.a=t2.a-1;
842
860
SELECT * FROM t1 ORDER BY a;
845
863
#
846
864
# Bug#24607 - MyISAM pointer size determined incorrectly
847
865
#
848
 
CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
 
866
CREATE TABLE t1 (c1 TEXT) ENGINE=MyISAM AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
849
867
--replace_column 5 X 6 X 7 X 9 X 10 X 11 X 12 X 13 X 14 X 16 X
850
868
SHOW TABLE STATUS LIKE 't1';
851
869
DROP TABLE t1;
1008
1026
# Some errors/warnings on create
1009
1027
#
1010
1028
 
 
1029
--error 1074
1011
1030
create table t1 (v varchar(65530), key(v));
1012
 
drop table if exists t1;
 
1031
--error 1074
1013
1032
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;
 
1033
--error 1074
 
1034
create table t1 (v varchar(65530));
1019
1035
 
1020
1036
# MyISAM specific varchar tests
1021
 
--error 1118
 
1037
--error 1074
1022
1038
create table t1 (v varchar(65535));
1023
1039
 
1024
1040
eval set storage_engine=$default;
1027
1043
# Test concurrent insert
1028
1044
# First with static record length
1029
1045
#
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;
 
1046
#@TODO The below test fails with unknown system variable
 
1047
#      concurrent_insert
 
1048
#
 
1049
#set @save_concurrent_insert=@@concurrent_insert;
 
1050
#set global concurrent_insert=1;
 
1051
#create table t1 (a int);
 
1052
#insert into t1 values (1),(2),(3),(4),(5);
 
1053
#lock table t1 read local;
 
1054
#connect (con1,localhost,root,,);
 
1055
#connection con1;
1037
1056
# 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;
 
1057
#insert into t1 values(6),(7);
 
1058
#connection default;
 
1059
#unlock tables;
 
1060
#delete from t1 where a>=3 and a<=4;
 
1061
#lock table t1 read local;
 
1062
#connection con1;
 
1063
#set global concurrent_insert=2;
1045
1064
# Insert in table with hole -> Should insert at end
1046
 
insert into t1 values (8),(9);
1047
 
connection default;
1048
 
unlock tables;
 
1065
#insert into t1 values (8),(9);
 
1066
#connection default;
 
1067
#unlock tables;
1049
1068
# 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;
 
1069
#insert into t1 values (10),(11),(12);
 
1070
#select * from t1;
 
1071
#check table t1;
 
1072
#drop table t1;
 
1073
#disconnect con1;
1055
1074
 
1056
1075
# 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;
 
1076
#create table t1 (a int, b varchar(30) default "hello");
 
1077
#insert into t1 (a) values (1),(2),(3),(4),(5);
 
1078
#lock table t1 read local;
 
1079
#connect (con1,localhost,root,,);
 
1080
#connection con1;
1062
1081
# 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;
 
1082
#insert into t1 (a) values(6),(7);
 
1083
#connection default;
 
1084
#unlock tables;
 
1085
#delete from t1 where a>=3 and a<=4;
 
1086
#lock table t1 read local;
 
1087
#connection con1;
 
1088
#set global concurrent_insert=2;
 
1089
## Insert in table with hole -> Should insert at end
 
1090
#insert into t1 (a) values (8),(9);
 
1091
#connection default;
 
1092
#unlock tables;
1074
1093
# 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;
 
1094
#insert into t1 (a) values (10),(11),(12);
 
1095
#select a from t1;
 
1096
#check table t1;
 
1097
#drop table t1;
 
1098
#disconnect con1;
 
1099
#set global concurrent_insert=@save_concurrent_insert;
1081
1100
 
1082
1101
 
1083
1102
# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
1147
1166
#--exec myisamchk -dvv var/master-data/test/t1.MYI
1148
1167
#--exec myisamchk -iev var/master-data/test/t1.MYI
1149
1168
--echo # Enable keys with parallel repair
1150
 
SET @@myisam_repair_threads=2;
 
1169
SET GLOBAL myisam_repair_threads=2;
1151
1170
ALTER TABLE t1 DISABLE KEYS;
1152
1171
ALTER TABLE t1 ENABLE KEYS;
1153
 
SET @@myisam_repair_threads=1;
 
1172
SET GLOBAL myisam_repair_threads=1;
1154
1173
CHECK TABLE t1 EXTENDED;
1155
1174
DROP TABLE t1;
1156
1175
 
1178
1197
# Test of key_block_size
1179
1198
#
1180
1199
 
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;
 
1200
create table t1 (a int not null, key `a` (a) key_block_size=1024) ENGINE=MyISAM;
 
1201
show create table t1;
 
1202
drop table t1;
 
1203
 
 
1204
create table t1 (a int not null, key `a` (a) key_block_size=2048) ENGINE=MyISAM;
 
1205
show create table t1;
 
1206
drop table t1;
 
1207
 
 
1208
create table t1 (a varchar(2048), key `a` (a)) ENGINE=MyISAM;
 
1209
show create table t1;
 
1210
drop table t1;
 
1211
 
 
1212
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024) ENGINE=MyISAM;
 
1213
show create table t1;
 
1214
drop table t1;
 
1215
 
 
1216
create table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=1024;
1198
1217
show create table t1;
1199
1218
alter table t1 key_block_size=2048;
1200
1219
show create table t1;
1205
1224
show create table t1;
1206
1225
drop table t1;
1207
1226
 
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;
 
1227
create table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=8192;
 
1228
show create table t1;
 
1229
drop table t1;
 
1230
 
 
1231
create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) ENGINE=MyISAM key_block_size=8192;
 
1232
show create table t1;
 
1233
drop table t1;
 
1234
 
 
1235
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
1236
show create table t1;
1218
1237
drop table t1;
1219
1238
 
1220
1239
 
1221
1240
# Test limits and errors of key_block_size
1222
1241
 
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));
 
1242
create table t1 (a int not null, key `a` (a) key_block_size=512) ENGINE=MyISAM;
 
1243
show create table t1;
 
1244
drop table t1;
 
1245
 
 
1246
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000) ENGINE=MyISAM;
 
1247
show create table t1;
 
1248
drop table t1;
 
1249
 
 
1250
create table t1 (a int not null, key `a` (a) key_block_size=1025) ENGINE=MyISAM;
 
1251
show create table t1;
 
1252
drop table t1;
 
1253
 
 
1254
--error 1064
 
1255
create table t1 (a int not null, key key_block_size=1024 (a)) ENGINE=MyISAM;
 
1256
--error 1064
 
1257
create table t1 (a int not null, key `a` key_block_size=1024 (a)) ENGINE=MyISAM;
1239
1258
 
1240
1259
#
1241
1260
# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk
1245
1264
  c2 VARCHAR(300),
1246
1265
  KEY (c1) KEY_BLOCK_SIZE 1024,
1247
1266
  KEY (c2) KEY_BLOCK_SIZE 8192
1248
 
  );
 
1267
  ) ENGINE=MyISAM;
1249
1268
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
1250
1269
  (11, REPEAT('b', CEIL(RAND() * 300))),
1251
1270
  (12, REPEAT('c', CEIL(RAND() * 300))),
1371
1390
CREATE TABLE t1 (
1372
1391
  c1 CHAR(50),
1373
1392
  c2 VARCHAR(1)
1374
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1393
) ENGINE=MyISAM;
1375
1394
# Using Tamil Letter A, Unicode U+0B85
1376
 
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
1395
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1377
1396
SELECT COUNT(*) FROM t1;
1378
1397
CHECK TABLE t1;
1379
1398
REPAIR TABLE t1;
1387
1406
CREATE TABLE t1 (
1388
1407
  c1 CHAR(50),
1389
1408
  c2 VARCHAR(1)
1390
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1409
) ENGINE=MyISAM;
1391
1410
# Using Tamil Letter A, Unicode U+0B85
1392
 
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
1411
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1393
1412
SELECT COUNT(*) FROM t1;
1394
1413
CHECK TABLE t1 EXTENDED;
1395
1414
REPAIR TABLE t1 EXTENDED;
1403
1422
CREATE TABLE t1 (
1404
1423
  c1 CHAR(50),
1405
1424
  c2 VARCHAR(1)
1406
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1425
) ENGINE=MyISAM;
1407
1426
# Using Tamil Letter A, Unicode U+0B85
1408
 
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
1427
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1409
1428
# Insert more rows and delete one in the middle to force optimize.
1410
1429
INSERT INTO t1 VALUES('b', 'b');
1411
1430
INSERT INTO t1 VALUES('c', 'b');
1423
1442
  c1 CHAR(50),
1424
1443
  c2 VARCHAR(1),
1425
1444
  KEY (c1)
1426
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1445
) ENGINE=MyISAM;
1427
1446
#
1428
1447
# Insert 100 rows. This turns bulk insert on during the copy phase of
1429
1448
# ALTER TABLE. Bulk insert disables keys before the insert and re-enables
1440
1459
#
1441
1460
# Change most of the rows into long character values with > 42 characters.
1442
1461
# Using Tamil Letter A, Unicode U+0B85
1443
 
UPDATE t1 SET c1=REPEAT(_utf8 x'e0ae85',43) LIMIT 90;
 
1462
UPDATE t1 SET c1=REPEAT( x'e0ae85',43) LIMIT 90;
1444
1463
SELECT COUNT(*) FROM t1;
1445
1464
ALTER TABLE t1 ENGINE=MyISAM;
1446
1465
#
1453
1472
#
1454
1473
# Bug#29182 - MyISAMCHK reports wrong character set
1455
1474
#
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
 
 
 
1475
#@TODO Disabling the below, as no myisamcheck program
 
1476
#CREATE TABLE t1 (
 
1477
#  c1 VARCHAR(10) NOT NULL,
 
1478
#  c2 CHAR(10) DEFAULT NULL,
 
1479
#  c3 VARCHAR(10) NOT NULL,
 
1480
#  KEY (c1),
 
1481
#  KEY (c2)
 
1482
#) ENGINE=MyISAM PACK_KEYS=0;
 
1483
#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
1484
#--exec $DRIZZLECHK -d $MYSQLTEST_VARDIR/master-data/test/t1
 
1485
#DROP TABLE t1;
 
1486
#
1467
1487
--echo End of 5.1 tests
1468
1488