📄 bdb.test
字号:
## Test min-max optimization#CREATE TABLE t1 ( a int3 unsigned NOT NULL, b int1 unsigned NOT NULL, UNIQUE (a, b)) ENGINE = BDB; INSERT INTO t1 VALUES (1, 1);SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1;drop table t1;## Test problem with BDB and lock tables with duplicate write.#create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=bdb;insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');LOCK TABLES t1 WRITE;--error 1062insert into t1 values (99,1,2,'D'),(1,1,2,'D');select id from t1;select id from t1;UNLOCK TABLES;DROP TABLE t1;create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=bdb;insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');LOCK TABLES t1 WRITE;begin;--error 1062insert into t1 values (99,1,2,'D'),(1,1,2,'D');select id from t1;insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');commit;select id,id3 from t1;UNLOCK TABLES;DROP TABLE t1;## Test with empty tables (crashed with lock error)#CREATE TABLE t1 (SYAIN_NO char(5) NOT NULL default '', KINMU_DATE char(6) NOT NULL default '', PRIMARY KEY (SYAIN_NO,KINMU_DATE)) ENGINE=BerkeleyDB;CREATE TABLE t2 ( SYAIN_NO char(5) NOT NULL default '',STR_DATE char(8) NOT NULL default '',PRIMARY KEY (SYAIN_NO,STR_DATE) ) ENGINE=BerkeleyDB;select T1.KINMU_DATE from t1 T1 ,t2 T2 where T1.SYAIN_NO = '12345' and T1.KINMU_DATE = '200106' and T2.SYAIN_NO = T1.SYAIN_NO;select T1.KINMU_DATE from t1 T1 ,t2 T2 where T1.SYAIN_NO = '12345' and T1.KINMU_DATE = '200106' and T2.SYAIN_NO = T1.SYAIN_NO;DROP TABLE t1,t2;## Test problem with joining table to itself on a multi-part unique key#create table t1 (a int(11) not null, b int(11) not null, unique (a,b)) engine=bdb;insert into t1 values (1,1), (1,2);select * from t1 where a = 1;select t1.*, t2.* from t1, t1 t2 where t1.a = t2.a and t2.a = 1;select * from t1 where a = 1;drop table t1;## This caused a deadlock in BDB internal locks#create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=bdb;insert into t1 values (0,0,0,'ABCDEFGHIJ');create table t2 (id int NOT NULL,primary key (id)) engine=bdb;LOCK TABLES t1 WRITE, t2 WRITE;insert into t2 values(1);SELECT t1.* FROM t1 WHERE id IN (1);SELECT t1.* FROM t2 left outer join t1 on (t1.id=t2.id);delete from t1 where id3 >= 0 and id3 <= 0;drop table t1,t2;## Test problems with NULL#CREATE TABLE t1 (i varchar(48) NOT NULL default '', p varchar(255) default NULL,s varchar(48) NOT NULL default '', PRIMARY KEY (i), UNIQUE(p,s)) ENGINE=BDB;INSERT INTO t1 VALUES ('00000000-e6c4ddeaa6-003b8-83458387','programs/xxxxxxxx.wmv','00000000-e6c4ddeb32-003bc-83458387');SELECT * FROM t1 WHERE p='programs/xxxxxxxx.wmv';drop table t1;## Test problem which gave error 'Can't find record in 't1''#CREATE TABLE t1 ( STR_DATE varchar(8) NOT NULL default '',INFO_NOTE varchar(200) default NULL,PRIMARY KEY (STR_DATE) ) ENGINE=BerkeleyDB;select INFO_NOTE from t1 where STR_DATE = '20010610';select INFO_NOTE from t1 where STR_DATE < '20010610';select INFO_NOTE from t1 where STR_DATE > '20010610';drop table t1;## Test problem with multi table delete which quickly shows up with bdb tables.#create table t1 (a int not null, b int, primary key (a)) engine =bdb;create table t2 (a int not null, b int, primary key (a)) engine =bdb;insert into t1 values (2, 3),(1, 7),(10, 7);insert into t2 values (2, 3),(1, 7),(10, 7);select * from t1;select * from t2;delete t1, t2 from t1, t2 where t1.a = t2.a;select * from t1;select * from t2;select * from t2;drop table t1,t2;## The bug #971#create table t1 (x int not null, index(x)) engine=bdb;insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);select * from t1 where x <= 10 and x >= 7;select * from t1 where x <= 10 and x >= 7 order by x;select * from t1 where x <= 10 and x >= 7 order by x desc;select * from t1 where x <= 8 and x >= 5 order by x desc;select * from t1 where x < 8 and x > 5 order by x desc;drop table t1;## Test of multi-table-updates (bug #1980).#create table t1 ( c char(8) not null ) engine=bdb;insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');alter table t1 add b char(8) not null;alter table t1 add a char(8) not null;alter table t1 add primary key (a,b,c);update t1 set a=c, b=c;create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=bdb;insert into t2 select * from t1;delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;drop table t1,t2;## Test index only read (Bug #2509)#create table t1 (a char(10), key(a), b int not null, key(b)) engine=bdb;insert into t1 values ('a',1),('A',2);explain select a from t1;select a from t1;explain select b from t1;select b from t1;alter table t1 modify a char(10) binary;explain select a from t1;select a from t1;drop table t1;## bug#2686 - index_merge select on BerkeleyDB table with varchar PK crashes#create table t1( pk1 text not null, pk2 text not null, pk3 char(4), key1 int, key2 int, primary key(pk1(4), pk2(4), pk3), key(key1), key(key2)) engine=bdb;insert into t1 values (concat('aaa-', repeat('A', 4000)), concat('eee-', repeat('e', 4000)), 'a++a', 1, 1);insert into t1 values (concat('bbb-', repeat('B', 4000)), concat('ggg-', repeat('G', 4000)), 'b++b', 1, 1);select substring(pk1, 1, 4), substring(pk1, 4001), substring(pk2, 1, 4), substring(pk2, 4001), pk3, key1, key2 from t1 force index(key1, key2) where key1 < 3 or key2 < 3;drop table t1;## bug#2688 - Wrong index_merge query results for BDB table with# variable length primary key#create table t1 ( pk1 varchar(8) not null default '', pk2 varchar(4) not null default '', key1 int(11) default null, key2 int(11) default null, primary key (pk1,pk2), key key1 (key1), key key2 (key2)) engine=bdb;insert into t1 values ('','empt',2,2), ('a','a--a',2,2), ('bb','b--b',2,2), ('ccc','c--c',2,2), ('dddd','d--d',2,2);select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;drop table t1;## Bug #4000: problem with active cursor.#set autocommit=0;create table t1(b varchar(30)) engine=bdb;insert into t1 values ('one');commit;select b FROM t1 outer_table whereexists (select 'two' from t1 where 'two' = outer_table.b);drop table t1;set autocommit=1;## Bug #4089: subselect and open cursor.#create table t1(a int primary key, b varchar(30)) engine=bdb;insert into t1 values (1,'one'), (2,'two'), (3,'three'), (4,'four');create table t2 like t1;insert t2 select * from t1;select a from t1 where a in (select a from t2);delete from t2;insert into t2 (a, b) select a, b from t1 where (a, b) in (select a, b from t1);select * from t2;drop table t1, t2;## Bug #4304: TRUNCATE <table of type BDB> , wrong result#create table t1 (a int, b varchar(30), primary key(a)) engine = bdb;insert into t1 values (1,'one');commit;truncate t1;select * from t1;drop table t1;## Check that BDB works fine with a string which is# longer than 255 bytes for multibyte characters.#SET NAMES utf8;create table t1 (a varchar(255) character set utf8) engine=bdb;set @a:= convert(repeat(_latin1 0xFF, 255) using utf8);insert into t1 values (@a);select a, length(a), char_length(a) from t1;drop table t1;SET NAMES latin1;## Bug #5832 SELECT doesn't return records in some cases#CREATE TABLE t1 ( id int unsigned NOT NULL auto_increment, list_id smallint unsigned NOT NULL, term TEXT NOT NULL, PRIMARY KEY(id), INDEX(list_id, term(4))) ENGINE=BDB CHARSET=utf8;INSERT INTO t1 SET list_id = 1, term = "letterc";INSERT INTO t1 SET list_id = 1, term = "letterb";INSERT INTO t1 SET list_id = 1, term = "lettera";INSERT INTO t1 SET list_id = 1, term = "letterd";SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc");SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb");SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");DROP TABLE t1;## Bug #15536: Crash when DELETE with subquery using BDB tables#create table t1 (a int, key(a)) engine=bdb;create table t2 (b int, key(b)) engine=bdb;insert into t1 values (1),(1),(2),(3),(4);insert into t2 values (1),(5),(6),(7);delete from t1 where (a in (select b from t2));select count(*) from t1;# INSERT also blows up--error 1242insert into t1 set a=(select b from t2);select count(*) from t1;# UPDATE also blows upupdate t1 set a = a + 1 where (a in (select b from t2));select count(*) from t1;drop table t1, t2;--echo End of 4.1 tests## alter temp table#create temporary table t1 (a int, primary key(a)) engine=bdb;select * from t1;alter table t1 add b int;select * from t1;drop table t1;## Test varchar#let $default=`select @@storage_engine`;set storage_engine=bdb;source include/varchar.inc;## Some errors/warnings on create#--replace_result 1024 MAX_KEY_LENGTH 3072 MAX_KEY_LENGTHcreate table t1 (v varchar(65530), key(v));drop table if exists t1;create table t1 (v varchar(65536));show create table t1;drop table t1;create table t1 (v varchar(65530) character set utf8);show create table t1;drop table t1;# End varchar testeval set storage_engine=$default;## Test that we can create a large key#create table t1 (a varchar(255) character set utf8, b varchar(255) character set utf8, c varchar(255) character set utf8, d varchar(255) character set utf8, key (a,b,c,d)) engine=bdb;drop table t1;--error ER_TOO_LONG_KEYcreate table t1 (a varchar(255) character set utf8, b varchar(255) character set utf8, c varchar(255) character set utf8, d varchar(255) character set utf8, e varchar(255) character set utf8, key (a,b,c,d,e)) engine=bdb;## Bug #14212: Server crash after COMMIT + ALTER TABLE#set autocommit=0;create table t1 (a int) engine=bdb;commit;alter table t1 add primary key(a);drop table t1;--echo End of 5.0 tests
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -