Commit bcc3b17f authored by unknown's avatar unknown

Removed bdb test cases.


BitKeeper/deleted/.del-bdb-alter-table-1.result:
  Rename: mysql-test/r/bdb-alter-table-1.result -> BitKeeper/deleted/.del-bdb-alter-table-1.result
BitKeeper/deleted/.del-bdb-alter-table-1.test:
  Rename: mysql-test/t/bdb-alter-table-1.test -> BitKeeper/deleted/.del-bdb-alter-table-1.test
BitKeeper/deleted/.del-bdb-alter-table-2-master.opt:
  Rename: mysql-test/t/bdb-alter-table-2-master.opt -> BitKeeper/deleted/.del-bdb-alter-table-2-master.opt
BitKeeper/deleted/.del-bdb-alter-table-2.result:
  Rename: mysql-test/r/bdb-alter-table-2.result -> BitKeeper/deleted/.del-bdb-alter-table-2.result
BitKeeper/deleted/.del-bdb-alter-table-2.test:
  Rename: mysql-test/t/bdb-alter-table-2.test -> BitKeeper/deleted/.del-bdb-alter-table-2.test
BitKeeper/deleted/.del-bdb-crash.result:
  Rename: mysql-test/r/bdb-crash.result -> BitKeeper/deleted/.del-bdb-crash.result
BitKeeper/deleted/.del-bdb-crash.test:
  Rename: mysql-test/t/bdb-crash.test -> BitKeeper/deleted/.del-bdb-crash.test
BitKeeper/deleted/.del-bdb-deadlock.result:
  Rename: mysql-test/r/bdb-deadlock.result -> BitKeeper/deleted/.del-bdb-deadlock.result
BitKeeper/deleted/.del-bdb-deadlock.test:
  Rename: mysql-test/t/bdb-deadlock.test -> BitKeeper/deleted/.del-bdb-deadlock.test
BitKeeper/deleted/.del-bdb-deadlock.tminus:
  Rename: mysql-test/t/bdb-deadlock.tminus -> BitKeeper/deleted/.del-bdb-deadlock.tminus
BitKeeper/deleted/.del-bdb.result:
  Rename: mysql-test/r/bdb.result -> BitKeeper/deleted/.del-bdb.result
BitKeeper/deleted/.del-bdb.test:
  Rename: mysql-test/t/bdb.test -> BitKeeper/deleted/.del-bdb.test
BitKeeper/deleted/.del-bdb_cache-master.opt~e54093fff2e73631:
  Rename: mysql-test/t/bdb_cache-master.opt -> BitKeeper/deleted/.del-bdb_cache-master.opt~e54093fff2e73631
BitKeeper/deleted/.del-bdb_cache.result~5767ff4f4b228a66:
  Rename: mysql-test/r/bdb_cache.result -> BitKeeper/deleted/.del-bdb_cache.result~5767ff4f4b228a66
BitKeeper/deleted/.del-bdb_cache.test~818df448403a5598:
  Rename: mysql-test/t/bdb_cache.test -> BitKeeper/deleted/.del-bdb_cache.test~818df448403a5598
BitKeeper/deleted/.del-bdb_gis.result:
  Rename: mysql-test/r/bdb_gis.result -> BitKeeper/deleted/.del-bdb_gis.result
BitKeeper/deleted/.del-bdb_gis.test:
  Rename: mysql-test/t/bdb_gis.test -> BitKeeper/deleted/.del-bdb_gis.test
BitKeeper/deleted/.del-have_bdb.inc:
  Rename: mysql-test/include/have_bdb.inc -> BitKeeper/deleted/.del-have_bdb.inc
BitKeeper/deleted/.del-have_bdb.require:
  Rename: mysql-test/r/have_bdb.require -> BitKeeper/deleted/.del-have_bdb.require
BitKeeper/deleted/.del-index_merge_bdb.result:
  Rename: mysql-test/r/index_merge_bdb.result -> BitKeeper/deleted/.del-index_merge_bdb.result
BitKeeper/deleted/.del-index_merge_bdb.test:
  Rename: mysql-test/t/index_merge_bdb.test -> BitKeeper/deleted/.del-index_merge_bdb.test
BitKeeper/deleted/.del-ps_6bdb.result:
  Rename: mysql-test/r/ps_6bdb.result -> BitKeeper/deleted/.del-ps_6bdb.result
BitKeeper/deleted/.del-ps_6bdb.test:
  Rename: mysql-test/t/ps_6bdb.test -> BitKeeper/deleted/.del-ps_6bdb.test
BitKeeper/deleted/.del-rowid_order_bdb.result:
  Rename: mysql-test/r/rowid_order_bdb.result -> BitKeeper/deleted/.del-rowid_order_bdb.result
BitKeeper/deleted/.del-rowid_order_bdb.test:
  Rename: mysql-test/t/rowid_order_bdb.test -> BitKeeper/deleted/.del-rowid_order_bdb.test
BitKeeper/deleted/.del-sql_manager.h:
  Rename: sql/sql_manager.h -> BitKeeper/deleted/.del-sql_manager.h
libmysqld/Makefile.am:
  Removed bdb from the engine
mysql-test/extra/binlog_tests/binlog.test:
  Removed bdb support
mysql-test/r/binlog_stm_binlog.result:
  Updated results
mysql-test/r/ctype_utf8.result:
  Removed bdb support
mysql-test/t/ctype_utf8.test:
  Removed bdb support
sql/CMakeLists.txt:
  Removed file for Windows build
sql/Makefile.am:
  Removed unneeded include file.
sql/sql_manager.cc:
  Removed include file.
parent 189b8bc5
......@@ -45,7 +45,7 @@ noinst_HEADERS = embedded_priv.h emb_qcache.h
sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
ha_heap.cc ha_myisam.cc ha_myisammrg.cc \
ha_innodb.cc ha_berkeley.cc ha_federated.cc ha_ndbcluster.cc \
ha_innodb.cc ha_federated.cc ha_ndbcluster.cc \
ha_ndbcluster_binlog.cc ha_partition.cc \
handler.cc sql_handler.cc \
hostname.cc init.cc password.c \
......@@ -96,10 +96,6 @@ yassl_inc_libs= $(top_srcdir)/extra/yassl/src/.libs/libyassl.a \
endif
# Storage engine specific compilation options
ha_berkeley.o: ha_berkeley.cc
$(CXXCOMPILE) $(LM_CFLAGS) -c $<
ha_ndbcluster.o:ha_ndbcluster.cc
$(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<
......
......@@ -3,7 +3,6 @@
#
-- source include/not_embedded.inc
-- source include/have_bdb.inc
-- source include/have_innodb.inc
-- source include/have_debug.inc
......@@ -12,7 +11,7 @@ drop table if exists t1, t2;
--enable_warnings
reset master;
create table t1 (a int) engine=bdb;
create table t1 (a int) engine=innodb;
create table t2 (a int) engine=innodb;
begin;
insert t1 values (5);
......
-- require r/have_bdb.require
disable_query_log;
show variables like "have_bdb";
enable_query_log;
drop table if exists t1;
create table t1(objid BIGINT not null, tablename varchar(64), oid BIGINT not null, test BIGINT, PRIMARY KEY (objid), UNIQUE(tablename)) engine=BDB;
insert into t1 values(1, 't1',4,9);
insert into t1 values(2, 'metatable',1,9);
insert into t1 values(3, 'metaindex',1,9 );
select * from t1;
objid tablename oid test
1 t1 4 9
2 metatable 1 9
3 metaindex 1 9
alter table t1 drop column test;
select * from t1;
objid tablename oid
1 t1 4
2 metatable 1
3 metaindex 1
drop table t1;
drop table if exists t1;
CREATE TABLE t1 (
ChargeID int(10) unsigned NOT NULL auto_increment,
ServiceID int(10) unsigned DEFAULT '0' NOT NULL,
ChargeDate date DEFAULT '0000-00-00' NOT NULL,
ChargeAmount decimal(20,2) DEFAULT '0.00' NOT NULL,
FedTaxes decimal(20,2) DEFAULT '0.00' NOT NULL,
ProvTaxes decimal(20,2) DEFAULT '0.00' NOT NULL,
ChargeStatus enum('New','Auth','Unauth','Sale','Denied','Refund')
DEFAULT 'New' NOT NULL,
ChargeAuthorizationMessage text,
ChargeComment text,
ChargeTimeStamp varchar(20),
PRIMARY KEY (ChargeID),
KEY ServiceID (ServiceID),
KEY ChargeDate (ChargeDate)
) engine=BDB;
BEGIN;
INSERT INTO t1
VALUES(NULL,1,'2001-03-01',1,1,1,'New',NULL,NULL,'now');
COMMIT;
BEGIN;
UPDATE t1 SET ChargeAuthorizationMessage = 'blablabla' WHERE
ChargeID = 1;
COMMIT;
INSERT INTO t1
VALUES(NULL,1,'2001-03-01',1,1,1,'New',NULL,NULL,'now');
select * from t1;
ChargeID ServiceID ChargeDate ChargeAmount FedTaxes ProvTaxes ChargeStatus ChargeAuthorizationMessage ChargeComment ChargeTimeStamp
1 1 2001-03-01 1.00 1.00 1.00 New blablabla NULL now
2 1 2001-03-01 1.00 1.00 1.00 New NULL NULL now
drop table t1;
create table t1 (a int) engine=bdb;
set autocommit=0;
insert into t1 values(1);
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
drop table t1;
drop table if exists t1,t2;
create table t1 (id integer, x integer) engine=BDB;
create table t2 (id integer, x integer) engine=BDB;
insert into t1 values(0, 0);
insert into t2 values(0, 0);
set autocommit=0;
update t1 set x = 1 where id = 0;
set autocommit=0;
update t2 set x = 1 where id = 0;
select x from t1 where id = 0;
select x from t2 where id = 0;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
commit;
x
1
commit;
select * from t1;
id x
0 1
select * from t2;
id x
0 1
commit;
select * from t1;
id x
0 1
select * from t2;
id x
0 1
commit;
drop table t1,t2;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=bdb;
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
select id, code, name from t1 order by id;
id code name
1 1 Tim
2 1 Monty
3 2 David
4 2 Erik
5 3 Sasha
6 3 Jeremy
7 4 Matt
update ignore t1 set id = 8, name = 'Sinisa' where id < 3;
select id, code, name from t1 order by id;
id code name
2 1 Monty
3 2 David
4 2 Erik
5 3 Sasha
6 3 Jeremy
7 4 Matt
8 1 Sinisa
update ignore t1 set id = id + 10, name = 'Ralph' where id < 4;
select id, code, name from t1 order by id;
id code name
3 2 David
4 2 Erik
5 3 Sasha
6 3 Jeremy
7 4 Matt
8 1 Sinisa
12 1 Ralph
drop table t1;
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
parent_id int(11) DEFAULT '0' NOT NULL,
level tinyint(4) DEFAULT '0' NOT NULL,
PRIMARY KEY (id),
KEY parent_id (parent_id),
KEY level (level)
) engine=bdb;
INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
update t1 set parent_id=parent_id+100;
select * from t1 where parent_id=102;
id parent_id level
8 102 2
9 102 2
15 102 2
update t1 set id=id+1000;
update t1 set id=1024 where id=1009;
ERROR 23000: Duplicate entry '1024' for key 'PRIMARY'
select * from t1;
id parent_id level
1001 100 0
1002 101 1
1003 101 1
1004 101 1
1005 101 1
1006 101 1
1007 101 1
1008 102 2
1009 102 2
1015 102 2
1016 103 2
1017 103 2
1018 103 2
1019 103 2
1020 103 2
1021 104 2
1022 104 2
1024 104 2
1025 105 2
1026 105 2
1027 105 2
1028 105 2
1029 105 2
1030 105 2
1031 106 2
1032 106 2
1033 106 2
1034 106 2
1035 106 2
1036 107 2
1037 107 2
1038 107 2
1040 107 2
1157 100 0
1179 105 2
1183 104 2
1193 105 2
1202 107 2
1203 107 2
update ignore t1 set id=id+1;
select * from t1;
id parent_id level
1001 100 0
1002 101 1
1003 101 1
1004 101 1
1005 101 1
1006 101 1
1007 101 1
1008 102 2
1010 102 2
1015 102 2
1016 103 2
1017 103 2
1018 103 2
1019 103 2
1020 103 2
1021 104 2
1023 104 2
1024 104 2
1025 105 2
1026 105 2
1027 105 2
1028 105 2
1029 105 2
1030 105 2
1031 106 2
1032 106 2
1033 106 2
1034 106 2
1035 106 2
1036 107 2
1037 107 2
1039 107 2
1041 107 2
1158 100 0
1180 105 2
1184 104 2
1194 105 2
1202 107 2
1204 107 2
update ignore t1 set id=1023 where id=1010;
select * from t1 where parent_id=102 order by parent_id,id;
id parent_id level
1008 102 2
1010 102 2
1015 102 2
explain select level from t1 where level=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref level level 1 const X Using index
explain select level,id from t1 where level=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref level level 1 const X Using index
explain select level,id,parent_id from t1 where level=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref level level 1 const X
select level,id from t1 where level=1;
level id
1 1002
1 1003
1 1004
1 1005
1 1006
1 1007
select level,id,parent_id from t1 where level=1;
level id parent_id
1 1002 101
1 1003 101
1 1004 101
1 1005 101
1 1006 101
1 1007 101
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 id A 39 NULL NULL BTREE
t1 1 parent_id 1 parent_id A 9 NULL NULL BTREE
t1 1 level 1 level A 3 NULL NULL BTREE
drop table t1;
CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL,
benutzer_id int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (gesuchnr,benutzer_id)
) engine=BDB;
replace into t1 (gesuchnr,benutzer_id) values (2,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
select * from t1;
gesuchnr benutzer_id
1 1
2 1
drop table t1;
create table t1 (id int not null primary key, x int not null, key (x)) engine=bdb;
insert into t1 (id, x) values (1, 1);
replace into t1 (id, x) values (1, 2);
select * from t1;
id x
1 2
drop table t1;
create table t1 (a int) engine=bdb;
insert into t1 values (1), (2);
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
delete from t1 where a = 1;
select * from t1;
a
2
check table t1;
Table Op Msg_type Msg_text
test.t1 check note The storage engine for the table doesn't support check
drop table t1;
create table t1 (a int,b varchar(20)) engine=bdb;
insert into t1 values (1,""), (2,"testing");
delete from t1 where a = 1;
select * from t1;
a b
2 testing
create index skr on t1 (a);
insert into t1 values (3,""), (4,"testing");
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 skr 1 a A 3 NULL NULL YES BTREE
drop table t1;
create table t1 (a int,b varchar(20),key(a)) engine=bdb;
insert into t1 values (1,""), (2,"testing");
select * from t1 where a = 1;
a b
1
drop table t1;
create table t1 (a char(10) not null, b int not null auto_increment, primary key(a,b)) engine=BDB;
insert into t1 values ("a",1),("b",2),("a",2),("c",1);
insert into t1 values ("a",NULL),("b",NULL),("c",NULL),("e",NULL);
insert into t1 (a) values ("a"),("b"),("c"),("d");
insert into t1 (a) values ('k'),('d');
insert into t1 (a) values ("a");
insert into t1 values ("d",last_insert_id());
select * from t1;
a b
a 1
a 2
a 3
a 4
a 5
b 2
b 3
b 4
c 1
c 2
c 3
d 1
d 2
d 5
e 1
k 1
flush tables;
select count(*) from t1;
count(*)
16
drop table t1;
create table t1 (n int not null primary key) engine=bdb;
set autocommit=0;
insert into t1 values (4);
rollback;
select n, "after rollback" from t1;
n after rollback
insert into t1 values (4);
commit;
select n, "after commit" from t1;
n after commit
4 after commit
commit;
insert into t1 values (5);
insert into t1 values (4);
ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
commit;
select n, "after commit" from t1;
n after commit
4 after commit
5 after commit
set autocommit=1;
insert into t1 values (6);
insert into t1 values (4);
ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
select n from t1;
n
4
5
6
set autocommit=0;
begin;
savepoint `my_savepoint`;
insert into t1 values (7);
savepoint `savept2`;
insert into t1 values (3);
select n from t1;
n
3
4
5
6
7
savepoint savept3;
rollback to savepoint savept2;
rollback to savepoint savept3;
ERROR 42000: SAVEPOINT savept3 does not exist
rollback to savepoint savept2;
release savepoint `my_savepoint`;
select n from t1;
n
4
5
6
7
rollback to savepoint `my_savepoint`;
ERROR 42000: SAVEPOINT my_savepoint does not exist
rollback to savepoint savept2;
ERROR 42000: SAVEPOINT savept2 does not exist
insert into t1 values (8);
savepoint sv;
commit;
savepoint sv;
set autocommit=1;
rollback;
drop table t1;
create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=BDB;
begin;
insert into t1 values(1,'hamdouni');
select id as afterbegin_id,nom as afterbegin_nom from t1;
afterbegin_id afterbegin_nom
1 hamdouni
rollback;
select id as afterrollback_id,nom as afterrollback_nom from t1;
afterrollback_id afterrollback_nom
set autocommit=0;
insert into t1 values(2,'mysql');
select id as afterautocommit0_id,nom as afterautocommit0_nom from t1;
afterautocommit0_id afterautocommit0_nom
2 mysql
rollback;
select id as afterrollback_id,nom as afterrollback_nom from t1;
afterrollback_id afterrollback_nom
set autocommit=1;
drop table t1;
CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=bdb;
insert into t1 values ('pippo', 12);
insert into t1 values ('pippo', 12);
ERROR 23000: Duplicate entry 'pippo' for key 'PRIMARY'
delete from t1;
delete from t1 where id = 'pippo';
select * from t1;
id val
insert into t1 values ('pippo', 12);
set autocommit=0;
delete from t1;
rollback;
select * from t1;
id val
pippo 12
delete from t1;
commit;
select * from t1;
id val
drop table t1;
set autocommit=1;
CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=BDB;
INSERT INTO t1 VALUES (1, 'Jochen');
select * from t1;
ID NAME
1 Jochen
drop table t1;
CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=BDB;
set autocommit=0;
INSERT INTO t1 SET _userid='marc@anyware.co.uk';
COMMIT;
SELECT * FROM t1;
_userid
marc@anyware.co.uk
SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
_userid
marc@anyware.co.uk
drop table t1;
set autocommit=1;
CREATE TABLE t1 (
user_id int(10) DEFAULT '0' NOT NULL,
name varchar(100),
phone varchar(100),
ref_email varchar(100) DEFAULT '' NOT NULL,
detail varchar(200),
PRIMARY KEY (user_id,ref_email)
)engine=bdb;
INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10292,'shirish','2333604','shirish@yahoo.com','ddsds'),(10292,'sonali','323232','sonali@bolly.com','filmstar');
select * from t1 where user_id=10292;
user_id name phone ref_email detail
10292 sanjeev 29153373 sansh777@hotmail.com xxx
10292 shirish 2333604 shirish@yahoo.com ddsds
10292 sonali 323232 sonali@bolly.com filmstar
INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10293,'shirish','2333604','shirish@yahoo.com','ddsds');
select * from t1 where user_id=10292;
user_id name phone ref_email detail
10292 sanjeev 29153373 sansh777@hotmail.com xxx
10292 shirish 2333604 shirish@yahoo.com ddsds
10292 sonali 323232 sonali@bolly.com filmstar
select * from t1 where user_id>=10292;
user_id name phone ref_email detail
10292 sanjeev 29153373 sansh777@hotmail.com xxx
10292 shirish 2333604 shirish@yahoo.com ddsds
10292 sonali 323232 sonali@bolly.com filmstar
10293 shirish 2333604 shirish@yahoo.com ddsds
select * from t1 where user_id>10292;
user_id name phone ref_email detail
10293 shirish 2333604 shirish@yahoo.com ddsds
select * from t1 where user_id<10292;
user_id name phone ref_email detail
10291 sanjeev 29153373 sansh777@hotmail.com xxx
drop table t1;
CREATE TABLE t1 (a int not null, b int not null,c int not null,
key(a),primary key(a,b), unique(c),key(a),unique(b));
show index from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 a A NULL NULL NULL BTREE
t1 0 PRIMARY 2 b A 0 NULL NULL BTREE
t1 0 c 1 c A 0 NULL NULL BTREE
t1 0 b 1 b A 0 NULL NULL BTREE
t1 1 a 1 a A NULL NULL NULL BTREE
t1 1 a_2 1 a A NULL NULL NULL BTREE
drop table t1;
create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
alter table t1 engine=BDB;
insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
select * from t1;
col1 col2
1 1
2 3
3 4
4 4
5 2
update t1 set col2='7' where col1='4';
select * from t1;
col1 col2
1 1
2 3
3 4
4 7
5 2
alter table t1 add co3 int not null;
select * from t1;
col1 col2 co3
1 1 0
2 3 0
3 4 0
4 7 0
5 2 0
update t1 set col2='9' where col1='2';
select * from t1;
col1 col2 co3
1 1 0
2 9 0
3 4 0
4 7 0
5 2 0
drop table t1;
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 = myisam;
insert into t1 VALUES (1,3) , (2,3), (3,3);
select * from t1;
a b
1 3
2 3
3 3
insert into t2 select * from t1;
select * from t2;
a b
1 3
2 3
3 3
delete from t1 where b = 3;
select * from t1;
a b
insert into t1 select * from t2;
select * from t1;
a b
1 3
2 3
3 3
select * from t2;
a b
1 3
2 3
3 3
drop table t1,t2;
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
ggid varchar(32) binary DEFAULT '' NOT NULL,
email varchar(64) DEFAULT '' NOT NULL,
passwd varchar(32) binary DEFAULT '' NOT NULL,
PRIMARY KEY (id),
UNIQUE ggid (ggid)
) ENGINE=BDB;
insert into t1 (ggid,passwd) values ('test1','xxx');
insert into t1 (ggid,passwd) values ('test2','yyy');
insert into t1 (ggid,passwd) values ('test2','this will fail');
ERROR 23000: Duplicate entry 'test2' for key 'ggid'
insert into t1 (ggid,id) values ('this will fail',1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
select * from t1 where ggid='test1';
id ggid email passwd
1 test1 xxx
select * from t1 where passwd='xxx';
id ggid email passwd
1 test1 xxx
select * from t1 where id=2;
id ggid email passwd
2 test2 yyy
replace into t1 (ggid,id) values ('this will work',1);
replace into t1 (ggid,passwd) values ('test2','this will work');
update t1 set id=100,ggid='test2' where id=1;
ERROR 23000: Duplicate entry 'test2' for key 'ggid'
select * from t1;
id ggid email passwd
1 this will work
3 test2 this will work
select * from t1 where id=1;
id ggid email passwd
1 this will work
select * from t1 where id=999;
id ggid email passwd
drop table t1;
CREATE TABLE t1 (
user_name varchar(12),
password text,
subscribed char(1),
user_id int(11) DEFAULT '0' NOT NULL,
quota bigint(20),
weight double,
access_date date,
access_time time,
approved datetime,
dummy_primary_key int(11) NOT NULL auto_increment,
PRIMARY KEY (dummy_primary_key)
) ENGINE=BDB;
INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
select user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
user_name password subscribed user_id quota weight access_date access_time approved dummy_primary_key
user_0 somepassword N 0 0 0 2000-09-07 23:06:59 2000-09-07 23:06:59 1
user_1 somepassword Y 1 1 1 2000-09-07 23:06:59 2000-09-07 23:06:59 2
user_2 somepassword N 2 2 1.4142135623731 2000-09-07 23:06:59 2000-09-07 23:06:59 3
user_3 somepassword Y 3 3 1.7320508075689 2000-09-07 23:06:59 2000-09-07 23:06:59 4
user_4 somepassword N 4 4 2 2000-09-07 23:06:59 2000-09-07 23:06:59 5
drop table t1;
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
parent_id int(11) DEFAULT '0' NOT NULL,
level tinyint(4) DEFAULT '0' NOT NULL,
KEY (id),
KEY parent_id (parent_id),
KEY level (level)
) engine=bdb;
INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1);
INSERT INTO t1 values (179,5,2);
update t1 set parent_id=parent_id+100;
select * from t1 where parent_id=102;
id parent_id level
8 102 2
9 102 2
15 102 2
update t1 set id=id+1000;
update t1 set id=1024 where id=1009;
select * from t1;
id parent_id level
1001 100 0
1003 101 1
1004 101 1
1008 102 2
1024 102 2
1017 103 2
1022 104 2
1024 104 2
1028 105 2
1029 105 2
1030 105 2
1031 106 2
1032 106 2
1033 106 2
1203 107 2
1202 107 2
1020 103 2
1157 100 0
1193 105 2
1040 107 2
1002 101 1
1015 102 2
1006 101 1
1034 106 2
1035 106 2
1016 103 2
1007 101 1
1036 107 2
1018 103 2
1026 105 2
1027 105 2
1183 104 2
1038 107 2
1025 105 2
1037 107 2
1021 104 2
1019 103 2
1005 101 1
1179 105 2
update ignore t1 set id=id+1;
select * from t1;
id parent_id level
1002 100 0
1004 101 1
1005 101 1
1009 102 2
1025 102 2
1018 103 2
1023 104 2
1025 104 2
1029 105 2
1030 105 2
1031 105 2
1032 106 2
1033 106 2
1034 106 2
1204 107 2
1203 107 2
1021 103 2
1158 100 0
1194 105 2
1041 107 2
1003 101 1
1016 102 2
1007 101 1
1035 106 2
1036 106 2
1017 103 2
1008 101 1
1037 107 2
1019 103 2
1027 105 2
1028 105 2
1184 104 2
1039 107 2
1026 105 2
1038 107 2
1022 104 2
1020 103 2
1006 101 1
1180 105 2
update ignore t1 set id=1023 where id=1010;
select * from t1 where parent_id=102;
id parent_id level
1009 102 2
1025 102 2
1016 102 2
explain select level from t1 where level=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref level level 1 const X Using index
select level,id from t1 where level=1;
level id
1 1004
1 1005
1 1003
1 1007
1 1008
1 1006
select level,id,parent_id from t1 where level=1;
level id parent_id
1 1004 101
1 1005 101
1 1003 101
1 1007 101
1 1008 101
1 1006 101
select level,id from t1 where level=1 order by id;
level id
1 1003
1 1004
1 1005
1 1006
1 1007
1 1008
delete from t1 where level=1;
select * from t1;
id parent_id level
1002 100 0
1009 102 2
1025 102 2
1018 103 2
1023 104 2
1025 104 2
1029 105 2
1030 105 2
1031 105 2
1032 106 2
1033 106 2
1034 106 2
1204 107 2
1203 107 2
1021 103 2
1158 100 0
1194 105 2
1041 107 2
1016 102 2
1035 106 2
1036 106 2
1017 103 2
1037 107 2
1019 103 2
1027 105 2
1028 105 2
1184 104 2
1039 107 2
1026 105 2
1038 107 2
1022 104 2
1020 103 2
1180 105 2
drop table t1;
CREATE TABLE t1 (
sca_code char(6) NOT NULL,
cat_code char(6) NOT NULL,
sca_desc varchar(50),
lan_code char(2) NOT NULL,
sca_pic varchar(100),
sca_sdesc varchar(50),
sca_sch_desc varchar(16),
PRIMARY KEY (sca_code, cat_code, lan_code),
INDEX sca_pic (sca_pic)
) engine = bdb ;
INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
select count(*) from t1 where sca_code = 'PD';
count(*)
1
select count(*) from t1 where sca_code <= 'PD';
count(*)
1
select count(*) from t1 where sca_pic is null;
count(*)
2
alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
select count(*) from t1 where sca_code='PD' and sca_pic is null;
count(*)
1
select count(*) from t1 where cat_code='E';
count(*)
0
alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
select count(*) from t1 where sca_code='PD' and sca_pic is null;
count(*)
1
select count(*) from t1 where sca_pic >= 'n';
count(*)
1
select sca_pic from t1 where sca_pic is null;
sca_pic
NULL
NULL
update t1 set sca_pic="test" where sca_pic is null;
delete from t1 where sca_code='pd';
drop table t1;
set @a:=now();
CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=bdb;
insert into t1 (a) values(1),(2),(3);
select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
a
1
2
3
select a from t1 natural join t1 as t2 where b >= @a order by a;
a
1
2
3
update t1 set a=5 where a=1;
select a from t1;
a
2
3
5
drop table t1;
flush logs;
create table t1 (b blob, i int, key (b(100)), key (i), key (i, b(20))) engine=bdb;
insert into t1 values ('this is a blob', 1), (null, -1), (null, null),("",1),("",2),("",3);
select b from t1 where b = 'this is a blob';
b
this is a blob
select * from t1 where b like 't%';
b i
this is a blob 1
select b, i from t1 where b is not null;
b i
this is a blob 1
1
2
3
select * from t1 where b is null and i > 0;
b i
select * from t1 where i is NULL;
b i
NULL NULL
update t1 set b='updated' where i=1;
select * from t1;
b i
updated 1
NULL -1
NULL NULL
updated 1
2
3
drop table t1;
create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=bdb;
insert into t1 values("hello",1),("world",2);
select * from t1 order by b desc;
a b
world 2
hello 1
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 a A 2 NULL NULL BTREE
drop table t1;
create table t1 (i int, j int )ENGINE=BDB;
insert into t1 values (1,2);
select * from t1 where i=1 and j=2;
i j
1 2
create index ax1 on t1 (i,j);
select * from t1 where i=1 and j=2;
i j
1 2
drop table t1;
create table t1
(
branch_id int auto_increment primary key,
branch_name varchar(255) not null,
branch_active int not null default 1,
unique branch_name(branch_name),
index branch_active(branch_active)
) engine=bdb;
create table t2
(
target_id int auto_increment primary key,
target_name varchar(255) not null,
target_active int not null default 1,
unique target_name(target_name),
index target_active(target_active)
) engine=bdb;
create table t3
(
platform_id int auto_increment primary key,
platform_name varchar(255) not null,
platform_active int not null default 1,
unique platform_name(platform_name),
index platform_active(platform_active)
) engine=bdb;
create table t4
(
product_id int auto_increment primary key,
product_name varchar(255) not null,
version_file varchar(255) not null,
product_active int not null default 1,
unique product_name(product_name),
index product_active(product_active)
) engine=bdb;
create table t5
(
product_file_id int auto_increment primary key,
product_id int not null,
file_name varchar(255) not null,
/* cvs module used to find the file version */
module_name varchar(255) not null,
/* flag whether the file is still included in the product */
file_included int not null default 1,
unique product_file(product_id,file_name),
index file_included(file_included)
) engine=bdb;
create table t6
(
file_platform_id int auto_increment primary key,
product_file_id int not null,
platform_id int not null,
branch_id int not null,
/* filename in the build system */
build_filename varchar(255) not null,
/* default filename in the build archive */
archive_filename varchar(255) not null,
unique file_platform(product_file_id,platform_id,branch_id)
) engine=bdb;
create table t8
(
archive_id int auto_increment primary key,
branch_id int not null,
target_id int not null,
platform_id int not null,
product_id int not null,
status_id int not null default 1,
unique archive(branch_id,target_id,platform_id,product_id),
index status_id(status_id)
) engine=bdb;
create table t7
(
build_id int auto_increment primary key,
branch_id int not null,
target_id int not null,
build_number int not null,
build_date date not null,
/* build system tag, e.g. 'rmanight-022301-1779' */
build_tag varchar(255) not null,
/* path relative to the build archive root, e.g. 'current' */
build_path text not null,
unique build(branch_id,target_id,build_number)
) engine=bdb;
insert into t1 (branch_name)
values ('RealMedia');
insert into t1 (branch_name)
values ('RP8REV');
insert into t1 (branch_name)
values ('SERVER_8_0_GOLD');
insert into t2 (target_name)
values ('rmanight');
insert into t2 (target_name)
values ('playerall');
insert into t2 (target_name)
values ('servproxyall');
insert into t3 (platform_name)
values ('linux-2.0-libc6-i386');
insert into t3 (platform_name)
values ('win32-i386');
insert into t4 (product_name, version_file)
values ('realserver', 'servinst');
insert into t4 (product_name, version_file)
values ('realproxy', 'prxyinst');
insert into t4 (product_name, version_file)
values ('realplayer', 'playinst');
insert into t4 (product_name, version_file)
values ('plusplayer', 'plusinst');
create temporary table tmp1
select branch_id, target_id, platform_id, product_id
from t1, t2, t3, t4 ;
create temporary table tmp2
select tmp1.branch_id, tmp1.target_id, tmp1.platform_id, tmp1.product_id
from tmp1 left join t8
using (branch_id,target_id,platform_id,product_id)
where t8.archive_id is null ;
insert into t8
(branch_id, target_id, platform_id, product_id, status_id)
select branch_id, target_id, platform_id, product_id, 1
from tmp2 ;
drop table tmp1 ;
drop table tmp2 ;
insert into t5 (product_id, file_name, module_name)
values (1, 'servinst', 'server');
insert into t5 (product_id, file_name, module_name)
values (2, 'prxyinst', 'server');
insert into t5 (product_id, file_name, module_name)
values (3, 'playinst', 'rpapp');
insert into t5 (product_id, file_name, module_name)
values (4, 'plusinst', 'rpapp');
insert into t6
(product_file_id,platform_id,branch_id,build_filename,archive_filename)
values (1, 2, 3, 'servinst.exe', 'win32-servinst.exe');
insert into t6
(product_file_id,platform_id,branch_id,build_filename,archive_filename)
values (1, 1, 3, 'v80_linux-2.0-libc6-i386_servinst.bin', 'linux2-servinst.exe');
insert into t6
(product_file_id,platform_id,branch_id,build_filename,archive_filename)
values (3, 2, 2, 'playinst.exe', 'win32-playinst.exe');
insert into t6
(product_file_id,platform_id,branch_id,build_filename,archive_filename)
values (4, 2, 2, 'playinst.exe', 'win32-playinst.exe');
insert into t7
(branch_id,target_id,build_number,build_tag,build_date,build_path)
values (2, 2, 1071, 'playerall-022101-1071', '2001-02-21', 'current');
insert into t7
(branch_id,target_id,build_number,build_tag,build_date,build_path)
values (2, 2, 1072, 'playerall-022201-1072', '2001-02-22', 'current');
insert into t7
(branch_id,target_id,build_number,build_tag,build_date,build_path)
values (3, 3, 388, 'servproxyall-022201-388', '2001-02-22', 'current');
insert into t7
(branch_id,target_id,build_number,build_tag,build_date,build_path)
values (3, 3, 389, 'servproxyall-022301-389', '2001-02-23', 'current');
insert into t7
(branch_id,target_id,build_number,build_tag,build_date,build_path)
values (4, 4, 100, 'foo target-010101-100', '2001-01-01', 'current');
update t8
set status_id=2
where branch_id=2 and target_id=2 and platform_id=2 and product_id=1;
select t7.build_path
from
t1,
t7,
t2,
t3,
t4,
t5,
t6
where
t7.branch_id = t1.branch_id and
t7.target_id = t2.target_id and
t5.product_id = t4.product_id and
t6.product_file_id = t5.product_file_id and
t6.platform_id = t3.platform_id and
t6.branch_id = t6.branch_id and
t7.build_id = 1 and
t4.product_id = 3 and
t5.file_name = 'playinst' and
t3.platform_id = 2;
build_path
current
drop table t1, t2, t3, t4, t5, t6, t7, t8;
CREATE TABLE t1 (
a tinytext NOT NULL,
b tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (a(32),b)
) ENGINE=BDB;
INSERT INTO t1 VALUES ('a',1),('a',2);
SELECT * FROM t1 WHERE a='a' AND b=2;
a b
a 2
SELECT * FROM t1 WHERE a='a' AND b in (2);
a b
a 2
SELECT * FROM t1 WHERE a='a' AND b in (1,2);
a b
a 1
a 2
drop table t1;
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;
MIN(B) MAX(b)
1 1
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;
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
select id from t1;
id
0
1
2
select id from t1;
id
0
1
2
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;
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
select id from t1;
id
0
1
2
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
commit;
select id,id3 from t1;
id id3
0 0
1 1
2 2
100 2
UNLOCK TABLES;
DROP TABLE t1;
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;
KINMU_DATE
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;
KINMU_DATE
DROP TABLE t1,t2;
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;
a b
1 1
1 2
select t1.*, t2.* from t1, t1 t2 where t1.a = t2.a and t2.a = 1;
a b a b
1 1 1 1
1 1 1 2
1 2 1 1
1 2 1 2
select * from t1 where a = 1;
a b
1 1
1 2
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');
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);
id id2 id3 dummy1
SELECT t1.* FROM t2 left outer join t1 on (t1.id=t2.id);
id id2 id3 dummy1
NULL NULL NULL NULL
delete from t1 where id3 >= 0 and id3 <= 0;
drop table t1,t2;
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';
i p s
00000000-e6c4ddeaa6-003b8-83458387 programs/xxxxxxxx.wmv 00000000-e6c4ddeb32-003bc-83458387
drop table 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';
INFO_NOTE
select INFO_NOTE from t1 where STR_DATE < '20010610';
INFO_NOTE
select INFO_NOTE from t1 where STR_DATE > '20010610';
INFO_NOTE
drop table t1;
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;
a b
1 7
2 3
10 7
select * from t2;
a b
1 7
2 3
10 7
delete t1, t2 from t1, t2 where t1.a = t2.a;
select * from t1;
a b
select * from t2;
a b
select * from t2;
a b
drop table t1,t2;
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;
x
7
8
9
10
select * from t1 where x <= 10 and x >= 7 order by x;
x
7
8
9
10
select * from t1 where x <= 10 and x >= 7 order by x desc;
x
10
9
8
7
select * from t1 where x <= 8 and x >= 5 order by x desc;
x
8
7
6
5
select * from t1 where x < 8 and x > 5 order by x desc;
x
7
6
drop table t1;
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;
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
select a from t1;
a
a
A
explain select b from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 4 NULL 2 Using index
select b from t1;
b
1
2
alter table t1 modify a char(10) binary;
explain select a from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 11 NULL 2 Using index
select a from t1;
a
A
a
drop table t1;
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;
substring(pk1, 1, 4) substring(pk1, 4001) substring(pk2, 1, 4) substring(pk2, 4001) pk3 key1 key2
aaa- AAAA eee- eeee a++a 1 1
bbb- BBBB ggg- GGGG b++b 1 1
drop table t1;
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;
pk1 pk2 key1 key2
empt 2 2
a a--a 2 2
bb b--b 2 2
ccc c--c 2 2
dddd d--d 2 2
drop table t1;
set autocommit=0;
create table t1(b varchar(30)) engine=bdb;
insert into t1 values ('one');
commit;
select b FROM t1 outer_table where
exists (select 'two' from t1 where 'two' = outer_table.b);
b
drop table t1;
set autocommit=1;
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);
a
1
2
3
4
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;
a b
1 one
2 two
3 three
4 four
drop table t1, t2;
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;
a b
drop table t1;
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;
a length(a) char_length(a)
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ 510 255
drop table t1;
SET NAMES latin1;
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");
id
1
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb");
id
2
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");
id
3
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
id
4
DROP TABLE t1;
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;
count(*)
3
insert into t1 set a=(select b from t2);
ERROR 21000: Subquery returns more than 1 row
select count(*) from t1;
count(*)
3
update t1 set a = a + 1 where (a in (select b from t2));
select count(*) from t1;
count(*)
3
drop table t1, t2;
End of 4.1 tests
create temporary table t1 (a int, primary key(a)) engine=bdb;
select * from t1;
a
alter table t1 add b int;
select * from t1;
a b
drop table t1;
set storage_engine=bdb;
drop table if exists t1,t2,t3;
--- Testing varchar ---
--- Testing varchar ---
create table t1 (v varchar(10), c char(10), t text);
insert into t1 values('+ ', '+ ', '+ ');
set @a=repeat(' ',20);
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
Warnings:
Note 1265 Data truncated for column 'v' at row 1
select concat('*',v,'*',c,'*',t,'*') from t1;
concat('*',v,'*',c,'*',t,'*')
*+ *+*+ *
*+ *+*+ *
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(10) DEFAULT NULL,
`c` char(10) DEFAULT NULL,
`t` text
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
create table t2 like t1;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`v` varchar(10) DEFAULT NULL,
`c` char(10) DEFAULT NULL,
`t` text
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
create table t3 select * from t1;
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`v` varchar(10) DEFAULT NULL,
`c` char(10) DEFAULT NULL,
`t` text
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
alter table t1 modify c varchar(10);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(10) DEFAULT NULL,
`c` varchar(10) DEFAULT NULL,
`t` text
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
alter table t1 modify v char(10);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` char(10) DEFAULT NULL,
`c` varchar(10) DEFAULT NULL,
`t` text
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
alter table t1 modify t varchar(10);
Warnings:
Note 1265 Data truncated for column 't' at row 2
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` char(10) DEFAULT NULL,
`c` varchar(10) DEFAULT NULL,
`t` varchar(10) DEFAULT NULL
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
select concat('*',v,'*',c,'*',t,'*') from t1;
concat('*',v,'*',c,'*',t,'*')
*+*+*+ *
*+*+*+ *
drop table t1,t2,t3;
create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(10) DEFAULT NULL,
`c` char(10) DEFAULT NULL,
`t` text,
KEY `v` (`v`),
KEY `c` (`c`),
KEY `t` (`t`(10))
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
select count(*) from t1;
count(*)
270
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
select count(*) from t1 where v='a';
count(*)
10
select count(*) from t1 where c='a';
count(*)
10
select count(*) from t1 where t='a';
count(*)
10
select count(*) from t1 where v='a ';
count(*)
10
select count(*) from t1 where c='a ';
count(*)
10
select count(*) from t1 where t='a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
count(*)
10
select count(*) from t1 where v like 'a%';
count(*)
11
select count(*) from t1 where c like 'a%';
count(*)
11
select count(*) from t1 where t like 'a%';
count(*)
11
select count(*) from t1 where v like 'a %';
count(*)
9
explain select count(*) from t1 where v='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 13 const # Using where
explain select count(*) from t1 where c='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref c c 11 const # Using where
explain select count(*) from t1 where t='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range t t 13 NULL # Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 13 NULL # Using where
explain select count(*) from t1 where v between 'a' and 'a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 13 const # Using where
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 13 const # Using where
alter table t1 add unique(v);
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
alter table t1 add key(v);
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
qq
*a*a*a*
*a *a*a *
*a *a*a *
*a *a*a *
*a *a*a *
*a *a*a *
*a *a*a *
*a *a*a *
*a *a*a *
*a *a*a *
explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v,v_2 # 13 const # Using where
select v,count(*) from t1 group by v limit 10;
v count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select v,count(c) from t1 group by v limit 10;
v count(c)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result v,count(c) from t1 group by v limit 10;
v count(c)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select c,count(*) from t1 group by c limit 10;
c count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select c,count(t) from t1 group by c limit 10;
c count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result c,count(t) from t1 group by c limit 10;
c count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select t,count(*) from t1 group by t limit 10;
t count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select t,count(t) from t1 group by t limit 10;
t count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result t,count(t) from t1 group by t limit 10;
t count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(300) DEFAULT NULL,
`c` char(10) DEFAULT NULL,
`t` text,
KEY `c` (`c`),
KEY `t` (`t`(10)),
KEY `v` (`v`)
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
select count(*) from t1 where v='a';
count(*)
10
select count(*) from t1 where v='a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
count(*)
10
select count(*) from t1 where v like 'a%';
count(*)
11
select count(*) from t1 where v like 'a %';
count(*)
9
explain select count(*) from t1 where v='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 303 const # Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 303 NULL # Using where
explain select count(*) from t1 where v between 'a' and 'a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 303 const # Using where
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 303 const # Using where
explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 303 const # Using where
select v,count(*) from t1 group by v limit 10;
v count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
alter table t1 drop key v, add key v (v(30));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(300) DEFAULT NULL,
`c` char(10) DEFAULT NULL,
`t` text,
KEY `c` (`c`),
KEY `t` (`t`(10)),
KEY `v` (`v`(30))
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
select count(*) from t1 where v='a';
count(*)
10
select count(*) from t1 where v='a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ';
count(*)
10
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
count(*)
10
select count(*) from t1 where v like 'a%';
count(*)
11
select count(*) from t1 where v like 'a %';
count(*)
9
explain select count(*) from t1 where v='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 33 const # Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 33 NULL # Using where
explain select count(*) from t1 where v between 'a' and 'a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 33 const # Using where
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 33 const # Using where
explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 33 const # Using where
select v,count(*) from t1 group by v limit 10;
v count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
alter table t1 modify v varchar(600), drop key v, add key v (v);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(600) DEFAULT NULL,
`c` char(10) DEFAULT NULL,
`t` text,
KEY `c` (`c`),
KEY `t` (`t`(10)),
KEY `v` (`v`)
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
select v,count(*) from t1 group by v limit 10;
v count(*)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
select sql_big_result v,count(t) from t1 group by v limit 10;
v count(t)
a 1
a 10
b 10
c 10
d 10
e 10
f 10
g 10
h 10
i 10
drop table t1;
create table t1 (a char(10), unique (a));
insert into t1 values ('a ');
insert into t1 values ('a ');
ERROR 23000: Duplicate entry 'a' for key 'a'
alter table t1 modify a varchar(10);
insert into t1 values ('a '),('a '),('a '),('a ');
ERROR 23000: Duplicate entry 'a ' for key 'a'
insert into t1 values ('a ');
ERROR 23000: Duplicate entry 'a ' for key 'a'
insert into t1 values ('a ');
ERROR 23000: Duplicate entry 'a ' for key 'a'
insert into t1 values ('a ');
ERROR 23000: Duplicate entry 'a ' for key 'a'
update t1 set a='a ' where a like 'a%';
select concat(a,'.') from t1;
concat(a,'.')
a .
update t1 set a='abc ' where a like 'a ';
select concat(a,'.') from t1;
concat(a,'.')
a .
update t1 set a='a ' where a like 'a %';
select concat(a,'.') from t1;
concat(a,'.')
a .
update t1 set a='a ' where a like 'a ';
select concat(a,'.') from t1;
concat(a,'.')
a .
drop table t1;
create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5)));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(10) DEFAULT NULL,
`c` char(10) DEFAULT NULL,
`t` text,
KEY `v` (`v`(5)),
KEY `c` (`c`(5)),
KEY `t` (`t`(5))
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (v char(10) character set utf8);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` char(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (v varchar(10), c char(10)) row_format=fixed;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` varchar(10) DEFAULT NULL,
`c` char(10) DEFAULT NULL
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
insert into t1 values('a','a'),('a ','a ');
select concat('*',v,'*',c,'*') from t1;
concat('*',v,'*',c,'*')
*a*a*
*a *a*
drop table t1;
create table t1 (v varchar(65530), key(v(10)));
insert into t1 values(repeat('a',65530));
select length(v) from t1 where v=repeat('a',65530);
length(v)
65530
drop table t1;
create table t1(a int, b varchar(12), key ba(b, a));
insert into t1 values (1, 'A'), (20, NULL);
explain select * from t1 where a=20 and b is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref ba ba 20 const,const 1 Using where
select * from t1 where a=20 and b is null;
a b
20 NULL
drop table t1;
create table t1 (v varchar(65530), key(v));
Warnings:
Warning 1071 Specified key was too long; max key length is MAX_KEY_LENGTH bytes
drop table if exists t1;
create table t1 (v varchar(65536));
Warnings:
Note 1246 Converting column 'v' from VARCHAR to TEXT
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` mediumtext
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (v varchar(65530) character set utf8);
Warnings:
Note 1246 Converting column 'v' from VARCHAR to TEXT
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v` mediumtext CHARACTER SET utf8
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
drop table t1;
set storage_engine=MyISAM;
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;
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,
e varchar(255) character set utf8,
key (a,b,c,d,e)) engine=bdb;
ERROR 42000: Specified key was too long; max key length is 3072 bytes
set autocommit=0;
create table t1 (a int) engine=bdb;
commit;
alter table t1 add primary key(a);
drop table t1;
End of 5.0 tests
create table t1 (a int) engine=bdb;
set session transaction isolation level repeatable read;
set transaction isolation level serializable;
begin;
select @@tx_isolation;
@@tx_isolation
SERIALIZABLE
insert into t1 values (1);
set transaction isolation level read committed;
ERROR 25001: Transaction isolation level can't be changed while a transaction is in progress
rollback;
begin;
select @@tx_isolation;
@@tx_isolation
REPEATABLE-READ
insert into t1 values (1);
rollback;
drop table t1;
End of 5.1 tests
drop table if exists t1, t2, t3;
flush status;
set autocommit=0;
create table t1 (a int not null) engine=bdb;
insert into t1 values (1),(2),(3);
select * from t1;
a
1
2
3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
drop table t1;
set autocommit=1;
create table t1 (a int not null) engine=bdb;
begin;
insert into t1 values (1),(2),(3);
select * from t1;
a
1
2
3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
drop table t1;
create table t1 (a int not null) engine=bdb;
create table t2 (a int not null) engine=bdb;
create table t3 (a int not null) engine=bdb;
insert into t1 values (1),(2);
insert into t2 values (1),(2);
insert into t3 values (1),(2);
select * from t1;
a
1
2
select * from t2;
a
1
2
select * from t3;
a
1
2
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
begin;
select * from t1;
a
1
2
select * from t2;
a
1
2
select * from t3;
a
1
2
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
insert into t1 values (3);
insert into t2 values (3);
insert into t1 values (4);
select * from t1;
a
1
2
3
4
select * from t2;
a
1
2
3
select * from t3;
a
1
2
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
commit;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
drop table if exists t1, t2, t3;
SET storage_engine=bdb;
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT);
CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING);
CREATE TABLE gis_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON);
CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT);
CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING);
CREATE TABLE gis_multi_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON);
CREATE TABLE gis_geometrycollection (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION);
CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY);
SHOW CREATE TABLE gis_point;
Table Create Table
gis_point CREATE TABLE `gis_point` (
`fid` int(11) NOT NULL AUTO_INCREMENT,
`g` point DEFAULT NULL,
PRIMARY KEY (`fid`)
) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1
SHOW FIELDS FROM gis_point;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL auto_increment
g point YES NULL
SHOW FIELDS FROM gis_line;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL auto_increment
g linestring YES NULL
SHOW FIELDS FROM gis_polygon;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL auto_increment
g polygon YES NULL
SHOW FIELDS FROM gis_multi_point;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL auto_increment
g multipoint YES NULL
SHOW FIELDS FROM gis_multi_line;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL auto_increment
g multilinestring YES NULL
SHOW FIELDS FROM gis_multi_polygon;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL auto_increment
g multipolygon YES NULL
SHOW FIELDS FROM gis_geometrycollection;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL auto_increment
g geometrycollection YES NULL
SHOW FIELDS FROM gis_geometry;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL auto_increment
g geometry YES NULL
INSERT INTO gis_point VALUES
(101, PointFromText('POINT(10 10)')),
(102, PointFromText('POINT(20 10)')),
(103, PointFromText('POINT(20 20)')),
(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
INSERT INTO gis_line VALUES
(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))));
INSERT INTO gis_polygon VALUES
(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
INSERT INTO gis_multi_point VALUES
(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))));
INSERT INTO gis_multi_line VALUES
(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
INSERT INTO gis_multi_polygon VALUES
(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
INSERT INTO gis_geometrycollection VALUES
(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
INSERT into gis_geometry SELECT * FROM gis_point;
INSERT into gis_geometry SELECT * FROM gis_line;
INSERT into gis_geometry SELECT * FROM gis_polygon;
INSERT into gis_geometry SELECT * FROM gis_multi_point;
INSERT into gis_geometry SELECT * FROM gis_multi_line;
INSERT into gis_geometry SELECT * FROM gis_multi_polygon;
INSERT into gis_geometry SELECT * FROM gis_geometrycollection;
SELECT fid, AsText(g) FROM gis_point ORDER by fid;
fid AsText(g)
101 POINT(10 10)
102 POINT(20 10)
103 POINT(20 20)
104 POINT(10 20)
SELECT fid, AsText(g) FROM gis_line ORDER by fid;
fid AsText(g)
105 LINESTRING(0 0,0 10,10 0)
106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
107 LINESTRING(10 10,40 10)
SELECT fid, AsText(g) FROM gis_polygon ORDER by fid;
fid AsText(g)
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
110 POLYGON((0 0,30 0,30 30,0 0))
SELECT fid, AsText(g) FROM gis_multi_point ORDER by fid;
fid AsText(g)
111 MULTIPOINT(0 0,10 10,10 20,20 20)
112 MULTIPOINT(1 1,11 11,11 21,21 21)
113 MULTIPOINT(3 6,4 10)
SELECT fid, AsText(g) FROM gis_multi_line ORDER by fid;
fid AsText(g)
114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
115 MULTILINESTRING((10 48,10 21,10 0))
116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
SELECT fid, AsText(g) FROM gis_multi_polygon ORDER by fid;
fid AsText(g)
117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
SELECT fid, AsText(g) FROM gis_geometrycollection ORDER by fid;
fid AsText(g)
120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
SELECT fid, AsText(g) FROM gis_geometry ORDER by fid;
fid AsText(g)
101 POINT(10 10)
102 POINT(20 10)
103 POINT(20 20)
104 POINT(10 20)
105 LINESTRING(0 0,0 10,10 0)
106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
107 LINESTRING(10 10,40 10)
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
110 POLYGON((0 0,30 0,30 30,0 0))
111 MULTIPOINT(0 0,10 10,10 20,20 20)
112 MULTIPOINT(1 1,11 11,11 21,21 21)
113 MULTIPOINT(3 6,4 10)
114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
115 MULTILINESTRING((10 48,10 21,10 0))
116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
SELECT fid, Dimension(g) FROM gis_geometry ORDER by fid;
fid Dimension(g)
101 0
102 0
103 0
104 0
105 1
106 1
107 1
108 2
109 2
110 2
111 0
112 0
113 0
114 1
115 1
116 1
117 2
118 2
119 2
120 1
121 1
SELECT fid, GeometryType(g) FROM gis_geometry ORDER by fid;
fid GeometryType(g)
101 POINT
102 POINT
103 POINT
104 POINT
105 LINESTRING
106 LINESTRING
107 LINESTRING
108 POLYGON
109 POLYGON
110 POLYGON
111 MULTIPOINT
112 MULTIPOINT
113 MULTIPOINT
114 MULTILINESTRING
115 MULTILINESTRING
116 MULTILINESTRING
117 MULTIPOLYGON
118 MULTIPOLYGON
119 MULTIPOLYGON
120 GEOMETRYCOLLECTION
121 GEOMETRYCOLLECTION
SELECT fid, IsEmpty(g) FROM gis_geometry ORDER by fid;
fid IsEmpty(g)
101 0
102 0
103 0
104 0
105 0
106 0
107 0
108 0
109 0
110 0
111 0
112 0
113 0
114 0
115 0
116 0
117 0
118 0
119 0
120 0
121 0
SELECT fid, AsText(Envelope(g)) FROM gis_geometry ORDER by fid;
fid AsText(Envelope(g))
101 POLYGON((10 10,10 10,10 10,10 10,10 10))
102 POLYGON((20 10,20 10,20 10,20 10,20 10))
103 POLYGON((20 20,20 20,20 20,20 20,20 20))
104 POLYGON((10 20,10 20,10 20,10 20,10 20))
105 POLYGON((0 0,10 0,10 10,0 10,0 0))
106 POLYGON((10 10,20 10,20 20,10 20,10 10))
107 POLYGON((10 10,40 10,40 10,10 10,10 10))
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
109 POLYGON((0 0,50 0,50 50,0 50,0 0))
110 POLYGON((0 0,30 0,30 30,0 30,0 0))
111 POLYGON((0 0,20 0,20 20,0 20,0 0))
112 POLYGON((1 1,21 1,21 21,1 21,1 1))
113 POLYGON((3 6,4 6,4 10,3 10,3 6))
114 POLYGON((10 0,16 0,16 48,10 48,10 0))
115 POLYGON((10 0,10 0,10 48,10 48,10 0))
116 POLYGON((1 2,21 2,21 8,1 8,1 2))
117 POLYGON((28 0,84 0,84 42,28 42,28 0))
118 POLYGON((28 0,84 0,84 42,28 42,28 0))
119 POLYGON((0 0,3 0,3 3,0 3,0 0))
120 POLYGON((0 0,10 0,10 10,0 10,0 0))
121 POLYGON((3 6,44 6,44 9,3 9,3 6))
explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelope(g)) from gis_geometry;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_geometry ALL NULL NULL NULL NULL 21 100.00
Warnings:
Note 1003 select dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,astext(envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
SELECT fid, X(g) FROM gis_point ORDER by fid;
fid X(g)
101 10
102 20
103 20
104 10
SELECT fid, Y(g) FROM gis_point ORDER by fid;
fid Y(g)
101 10
102 10
103 20
104 20
explain extended select X(g),Y(g) FROM gis_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_point ALL NULL NULL NULL NULL 4 100.00
Warnings:
Note 1003 select x(`test`.`gis_point`.`g`) AS `X(g)`,y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
SELECT fid, AsText(StartPoint(g)) FROM gis_line ORDER by fid;
fid AsText(StartPoint(g))
105 POINT(0 0)
106 POINT(10 10)
107 POINT(10 10)
SELECT fid, AsText(EndPoint(g)) FROM gis_line ORDER by fid;
fid AsText(EndPoint(g))
105 POINT(10 0)
106 POINT(10 10)
107 POINT(40 10)
SELECT fid, GLength(g) FROM gis_line ORDER by fid;
fid GLength(g)
105 24.142135623731
106 40
107 30
SELECT fid, NumPoints(g) FROM gis_line ORDER by fid;
fid NumPoints(g)
105 3
106 5
107 2
SELECT fid, AsText(PointN(g, 2)) FROM gis_line ORDER by fid;
fid AsText(PointN(g, 2))
105 POINT(0 10)
106 POINT(20 10)
107 POINT(40 10)
SELECT fid, IsClosed(g) FROM gis_line ORDER by fid;
fid IsClosed(g)
105 0
106 1
107 0
explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),NumPoints(g),AsText(PointN(g, 2)),IsClosed(g) FROM gis_line;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_line ALL NULL NULL NULL NULL 3 100.00
Warnings:
Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,astext(endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,glength(`test`.`gis_line`.`g`) AS `GLength(g)`,numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,astext(pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
109 POINT(25.416666666667 25.416666666667)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
fid Area(g)
108 100
109 2400
110 450
SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon ORDER by fid;
fid AsText(ExteriorRing(g))
108 LINESTRING(10 10,20 10,20 20,10 20,10 10)
109 LINESTRING(0 0,50 0,50 50,0 50,0 0)
110 LINESTRING(0 0,30 0,30 30,0 0)
SELECT fid, NumInteriorRings(g) FROM gis_polygon ORDER by fid;
fid NumInteriorRings(g)
108 0
109 1
110 0
SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon ORDER by fid;
fid AsText(InteriorRingN(g, 1))
108 NULL
109 LINESTRING(10 10,20 10,20 20,10 20,10 10)
110 NULL
explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumInteriorRings(g),AsText(InteriorRingN(g, 1)) FROM gis_polygon;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_polygon ALL NULL NULL NULL NULL 3 100.00
Warnings:
Note 1003 select astext(centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,area(`test`.`gis_polygon`.`g`) AS `Area(g)`,astext(exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,astext(interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
SELECT fid, IsClosed(g) FROM gis_multi_line ORDER by fid;
fid IsClosed(g)
114 0
115 0
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid AsText(Centroid(g))
117 POINT(55.588527753042 17.426536064114)
118 POINT(55.588527753042 17.426536064114)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid Area(g)
117 1684.5
118 1684.5
119 4.5
SELECT fid, NumGeometries(g) from gis_multi_point ORDER by fid;
fid NumGeometries(g)
111 4
112 4
113 2
SELECT fid, NumGeometries(g) from gis_multi_line ORDER by fid;
fid NumGeometries(g)
114 2
115 1
116 2
SELECT fid, NumGeometries(g) from gis_multi_polygon ORDER by fid;
fid NumGeometries(g)
117 2
118 2
119 1
SELECT fid, NumGeometries(g) from gis_geometrycollection ORDER by fid;
fid NumGeometries(g)
120 2
121 2
explain extended SELECT fid, NumGeometries(g) from gis_multi_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00
Warnings:
Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point ORDER by fid;
fid AsText(GeometryN(g, 2))
111 POINT(10 10)
112 POINT(11 11)
113 POINT(4 10)
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line ORDER by fid;
fid AsText(GeometryN(g, 2))
114 LINESTRING(16 0,16 23,16 48)
115 NULL
116 LINESTRING(2 5,5 8,21 7)
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon ORDER by fid;
fid AsText(GeometryN(g, 2))
117 POLYGON((59 18,67 18,67 13,59 13,59 18))
118 POLYGON((59 18,67 18,67 13,59 13,59 18))
119 NULL
SELECT fid, AsText(GeometryN(g, 2)) from gis_geometrycollection ORDER by fid;
fid AsText(GeometryN(g, 2))
120 LINESTRING(0 0,10 10)
121 LINESTRING(3 6,7 9)
SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection ORDER by fid;
fid AsText(GeometryN(g, 1))
120 POINT(0 0)
121 POINT(44 6)
explain extended SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00
Warnings:
Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,astext(geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
first second w c o e d t i r
120 120 1 1 0 1 0 0 1 0
120 121 0 0 0 0 0 0 1 0
121 120 0 0 1 0 0 0 1 0
121 121 1 1 0 1 0 0 1 0
explain extended SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE g1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
1 SIMPLE g2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid`
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
CREATE TABLE t1 (
a INTEGER PRIMARY KEY AUTO_INCREMENT,
gp point,
ln linestring,
pg polygon,
mp multipoint,
mln multilinestring,
mpg multipolygon,
gc geometrycollection,
gm geometry
);
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
mp multipoint YES NULL
mln multilinestring YES NULL
mpg multipolygon YES NULL
gc geometrycollection YES NULL
gm geometry YES NULL
ALTER TABLE t1 ADD fid INT;
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
a int(11) NO PRI NULL auto_increment
gp point YES NULL
ln linestring YES NULL
pg polygon YES NULL
mp multipoint YES NULL
mln multilinestring YES NULL
mpg multipolygon YES NULL
gc geometrycollection YES NULL
gm geometry YES NULL
fid int(11) YES NULL
DROP TABLE t1;
create table t1 (pk integer primary key auto_increment, a geometry not null);
insert into t1 (a) values (GeomFromText('Point(1 2)'));
insert into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
insert IGNORE into t1 (a) values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
create table t1 (pk integer primary key auto_increment, fl geometry);
insert into t1 (fl) values (1);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
insert into t1 (fl) values (1.11);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
insert into t1 (fl) values ("qwerty");
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
insert into t1 (fl) values (pointfromtext('point(1,1)'));
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
......@@ -12,7 +12,7 @@ master-bin.000001 367 Xid 1 394 COMMIT /* XID */
drop table t1;
drop table if exists t1, t2;
reset master;
create table t1 (a int) engine=bdb;
create table t1 (a int) engine=innodb;
create table t2 (a int) engine=innodb;
begin;
insert t1 values (5);
......@@ -22,11 +22,11 @@ insert t2 values (5);
commit;
show binlog events from 102;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=bdb
master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=innodb
master-bin.000001 # Query 1 # use `test`; create table t2 (a int) engine=innodb
master-bin.000001 # Query 1 # use `test`; BEGIN
master-bin.000001 # Query 1 # use `test`; insert t1 values (5)
master-bin.000001 # Query 1 # use `test`; COMMIT
master-bin.000001 # Xid 1 # COMMIT /* xid= */
master-bin.000001 # Query 1 # use `test`; BEGIN
master-bin.000001 # Query 1 # use `test`; insert t2 values (5)
master-bin.000001 # Xid 1 # COMMIT /* xid= */
......
......@@ -479,7 +479,7 @@ drop table t1;
create table t1 (
c char(10) character set utf8,
unique key a (c(1))
) engine=bdb;
) engine=innodb;
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
insert into t1 values ('aa');
ERROR 23000: Duplicate entry 'aa' for key 'a'
......@@ -637,7 +637,7 @@ drop table t1;
create table t1 (
c char(10) character set utf8 collate utf8_bin,
unique key a (c(1))
) engine=bdb;
) engine=innodb;
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
insert into t1 values ('aa');
ERROR 23000: Duplicate entry 'aa' for key 'a'
......@@ -707,7 +707,7 @@ drop table t1;
create table t1 (
str varchar(255) character set utf8 not null,
key str (str(2))
) engine=bdb;
) engine=innodb;
INSERT INTO t1 VALUES ('str');
INSERT INTO t1 VALUES ('str2');
select * from t1 where str='str';
......@@ -796,7 +796,7 @@ insert into t1 values(1,'foo'),(2,'foobar');
select * from t1 where b like 'foob%';
a b
2 foobar
alter table t1 engine=bdb;
alter table t1 engine=innodb;
select * from t1 where b like 'foob%';
a b
2 foobar
......
Variable_name Value
have_bdb YES
drop table if exists t1;
create table t1 (
pk int primary key,
key1 int,
key2 int,
filler char(200),
filler2 char(200),
index(key1),
index(key2)
) engine=bdb;
select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 );
pk key1 key2 filler filler2
2 2 2 filler-data filler-data-2
3 3 3 filler-data filler-data-2
9 9 9 filler-data filler-data-2
10 10 10 filler-data filler-data-2
4 4 4 filler-data filler-data-2
5 5 5 filler-data filler-data-2
6 6 6 filler-data filler-data-2
7 7 7 filler-data filler-data-2
8 8 8 filler-data filler-data-2
set @maxv=1000;
select * from t1 where
(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
or key1=18 or key1=60;
pk key1 key2 filler filler2
18 18 18 filler-data filler-data-2
60 60 60 filler-data filler-data-2
1 1 1 filler-data filler-data-2
2 2 2 filler-data filler-data-2
3 3 3 filler-data filler-data-2
4 4 4 filler-data filler-data-2
11 11 11 filler-data filler-data-2
12 12 12 filler-data filler-data-2
13 13 13 filler-data filler-data-2
14 14 14 filler-data filler-data-2
50 50 50 filler-data filler-data-2
51 51 51 filler-data filler-data-2
52 52 52 filler-data filler-data-2
53 53 53 filler-data filler-data-2
54 54 54 filler-data filler-data-2
991 991 991 filler-data filler-data-2
992 992 992 filler-data filler-data-2
993 993 993 filler-data filler-data-2
994 994 994 filler-data filler-data-2
995 995 995 filler-data filler-data-2
996 996 996 filler-data filler-data-2
997 997 997 filler-data filler-data-2
998 998 998 filler-data filler-data-2
999 999 999 filler-data filler-data-2
1000 1000 1000 filler-data filler-data-2
select * from t1 where
(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
or key1 < 3 or key1 > @maxv-11;
pk key1 key2 filler filler2
990 990 990 filler-data filler-data-2
1 1 1 filler-data filler-data-2
2 2 2 filler-data filler-data-2
3 3 3 filler-data filler-data-2
4 4 4 filler-data filler-data-2
11 11 11 filler-data filler-data-2
12 12 12 filler-data filler-data-2
13 13 13 filler-data filler-data-2
14 14 14 filler-data filler-data-2
50 50 50 filler-data filler-data-2
51 51 51 filler-data filler-data-2
52 52 52 filler-data filler-data-2
53 53 53 filler-data filler-data-2
54 54 54 filler-data filler-data-2
991 991 991 filler-data filler-data-2
992 992 992 filler-data filler-data-2
993 993 993 filler-data filler-data-2
994 994 994 filler-data filler-data-2
995 995 995 filler-data filler-data-2
996 996 996 filler-data filler-data-2
997 997 997 filler-data filler-data-2
998 998 998 filler-data filler-data-2
999 999 999 filler-data filler-data-2
1000 1000 1000 filler-data filler-data-2
select * from t1 where
(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
or
(key1 < 5) or (key1 > 10 and key1 < 15) or (key1 >= 50 and key1 < 55 ) or (key1 > @maxv-10);
pk key1 key2 filler filler2
1 1 1 filler-data filler-data-2
2 2 2 filler-data filler-data-2
3 3 3 filler-data filler-data-2
4 4 4 filler-data filler-data-2
11 11 11 filler-data filler-data-2
12 12 12 filler-data filler-data-2
13 13 13 filler-data filler-data-2
14 14 14 filler-data filler-data-2
50 50 50 filler-data filler-data-2
51 51 51 filler-data filler-data-2
52 52 52 filler-data filler-data-2
53 53 53 filler-data filler-data-2
54 54 54 filler-data filler-data-2
991 991 991 filler-data filler-data-2
992 992 992 filler-data filler-data-2
993 993 993 filler-data filler-data-2
994 994 994 filler-data filler-data-2
995 995 995 filler-data filler-data-2
996 996 996 filler-data filler-data-2
997 997 997 filler-data filler-data-2
998 998 998 filler-data filler-data-2
999 999 999 filler-data filler-data-2
1000 1000 1000 filler-data filler-data-2
select * from t1 where
(pk > 10 and pk < 15) or (pk >= 50 and pk < 55 )
or
(key1 < 5) or (key1 > @maxv-10);
pk key1 key2 filler filler2
1 1 1 filler-data filler-data-2
2 2 2 filler-data filler-data-2
3 3 3 filler-data filler-data-2
4 4 4 filler-data filler-data-2
991 991 991 filler-data filler-data-2
992 992 992 filler-data filler-data-2
993 993 993 filler-data filler-data-2
994 994 994 filler-data filler-data-2
995 995 995 filler-data filler-data-2
996 996 996 filler-data filler-data-2
997 997 997 filler-data filler-data-2
998 998 998 filler-data filler-data-2
999 999 999 filler-data filler-data-2
1000 1000 1000 filler-data filler-data-2
11 11 11 filler-data filler-data-2
12 12 12 filler-data filler-data-2
13 13 13 filler-data filler-data-2
14 14 14 filler-data filler-data-2
50 50 50 filler-data filler-data-2
51 51 51 filler-data filler-data-2
52 52 52 filler-data filler-data-2
53 53 53 filler-data filler-data-2
54 54 54 filler-data filler-data-2
drop table t1;
This source diff could not be displayed because it is too large. You can view the blob instead.
drop table if exists t1, t2, t3,t4;
create table t1 (
pk1 int not NULL,
key1 int(11),
key2 int(11),
PRIMARY KEY (pk1),
KEY key1 (key1),
KEY key2 (key2)
) engine=bdb;
insert into t1 values (-5, 1, 1),
(-100, 1, 1),
(3, 1, 1),
(0, 1, 1),
(10, 1, 1);
explain select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL 5 Using sort_union(key1,key2); Using where
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
pk1 key1 key2
-100 1 1
-5 1 1
0 1 1
3 1 1
10 1 1
drop table t1;
create table t1 (
pk1 int unsigned not NULL,
key1 int(11),
key2 int(11),
PRIMARY KEY (pk1),
KEY key1 (key1),
KEY key2 (key2)
) engine=bdb;
insert into t1 values (0, 1, 1),
(0xFFFFFFFF, 1, 1),
(0xFFFFFFFE, 1, 1),
(1, 1, 1),
(2, 1, 1);
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
pk1 key1 key2
0 1 1
1 1 1
2 1 1
4294967294 1 1
4294967295 1 1
drop table t1;
create table t1 (
pk1 char(4) not NULL,
key1 int(11),
key2 int(11),
PRIMARY KEY (pk1),
KEY key1 (key1),
KEY key2 (key2)
) engine=bdb collate latin2_general_ci;
insert into t1 values ('a1', 1, 1),
('b2', 1, 1),
('A3', 1, 1),
('B4', 1, 1);
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
pk1 key1 key2
a1 1 1
A3 1 1
b2 1 1
B4 1 1
drop table t1;
create table t1 (
pk1 int not NULL,
pk2 char(4) not NULL collate latin1_german1_ci,
pk3 char(4) not NULL collate latin1_bin,
key1 int(11),
key2 int(11),
PRIMARY KEY (pk1,pk2,pk3),
KEY key1 (key1),
KEY key2 (key2)
) engine=bdb;
insert into t1 values
(1, 'u', 'u', 1, 1),
(1, 'u', char(0xEC), 1, 1),
(1, 'u', 'x', 1, 1);
insert ignore into t1 select pk1, char(0xEC), pk3, key1, key2 from t1;
insert ignore into t1 select pk1, 'x', pk3, key1, key2 from t1 where pk2='u';
insert ignore into t1 select 2, pk2, pk3, key1, key2 from t1;
select * from t1;
pk1 pk2 pk3 key1 key2
1 u 1 1
1 x 1 1
1 1 1
1 u u 1 1
1 u x 1 1
1 u 1 1
1 x u 1 1
1 x x 1 1
1 x 1 1
2 u 1 1
2 x 1 1
2 1 1
2 u u 1 1
2 u x 1 1
2 u 1 1
2 x u 1 1
2 x x 1 1
2 x 1 1
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
pk1 pk2 pk3 key1 key2
1 u 1 1
1 x 1 1
1 1 1
1 u u 1 1
1 u x 1 1
1 u 1 1
1 x u 1 1
1 x x 1 1
1 x 1 1
2 u 1 1
2 x 1 1
2 1 1
2 u u 1 1
2 u x 1 1
2 u 1 1
2 x u 1 1
2 x x 1 1
2 x 1 1
alter table t1 drop primary key;
select * from t1;
pk1 pk2 pk3 key1 key2
1 u 1 1
1 x 1 1
1 1 1
1 u u 1 1
1 u x 1 1
1 u 1 1
1 x u 1 1
1 x x 1 1
1 x 1 1
2 u 1 1
2 x 1 1
2 1 1
2 u u 1 1
2 u x 1 1
2 u 1 1
2 x u 1 1
2 x x 1 1
2 x 1 1
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
pk1 pk2 pk3 key1 key2
1 u 1 1
1 x 1 1
1 1 1
1 u u 1 1
1 u x 1 1
1 u 1 1
1 x u 1 1
1 x x 1 1
1 x 1 1
2 u 1 1
2 x 1 1
2 1 1
2 u u 1 1
2 u x 1 1
2 u 1 1
2 x u 1 1
2 x x 1 1
2 x 1 1
drop table t1;
create table t1 (
pk1 varchar(8) NOT NULL default '',
pk2 varchar(4) NOT NULL default '',
key1 int(11),
key2 int(11),
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;
pk1 pk2 key1 key2
empt 2 2
a a--a 2 2
bb b--b 2 2
ccc c--c 2 2
dddd d--d 2 2
drop table t1;
#
# Test of problem when shutting down mysqld at once after ALTER TABLE
#
-- source include/have_bdb.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(objid BIGINT not null, tablename varchar(64), oid BIGINT not null, test BIGINT, PRIMARY KEY (objid), UNIQUE(tablename)) engine=BDB;
insert into t1 values(1, 't1',4,9);
insert into t1 values(2, 'metatable',1,9);
insert into t1 values(3, 'metaindex',1,9 );
select * from t1;
alter table t1 drop column test;
# Now we do a reboot and continue with the next test
# End of 4.1 tests
#
# Note that this test uses tables from the previous test
# This is to test that the table t1 survives a reboot of MySQL
# The options in the -master.opt file are just there to force the reboot
#
-- source include/have_bdb.inc
select * from t1;
drop table t1;
# End of 4.1 tests
-- source include/have_bdb.inc
# test for bug reported by Mark Steele
--disable_warnings
drop table if exists t1;
--enable_warnings
CREATE TABLE t1 (
ChargeID int(10) unsigned NOT NULL auto_increment,
ServiceID int(10) unsigned DEFAULT '0' NOT NULL,
ChargeDate date DEFAULT '0000-00-00' NOT NULL,
ChargeAmount decimal(20,2) DEFAULT '0.00' NOT NULL,
FedTaxes decimal(20,2) DEFAULT '0.00' NOT NULL,
ProvTaxes decimal(20,2) DEFAULT '0.00' NOT NULL,
ChargeStatus enum('New','Auth','Unauth','Sale','Denied','Refund')
DEFAULT 'New' NOT NULL,
ChargeAuthorizationMessage text,
ChargeComment text,
ChargeTimeStamp varchar(20),
PRIMARY KEY (ChargeID),
KEY ServiceID (ServiceID),
KEY ChargeDate (ChargeDate)
) engine=BDB;
BEGIN;
INSERT INTO t1
VALUES(NULL,1,'2001-03-01',1,1,1,'New',NULL,NULL,'now');
COMMIT;
BEGIN;
UPDATE t1 SET ChargeAuthorizationMessage = 'blablabla' WHERE
ChargeID = 1;
COMMIT;
INSERT INTO t1
VALUES(NULL,1,'2001-03-01',1,1,1,'New',NULL,NULL,'now');
select * from t1;
drop table t1;
#
# Test for bug #2342 "Running ANALYZE TABLE on bdb table
# inside a transaction hangs server thread"
create table t1 (a int) engine=bdb;
set autocommit=0;
insert into t1 values(1);
analyze table t1;
drop table t1;
# End of 4.1 tests
# This test doesn't work with the embedded version as this code
# assumes that one query is running while we are doing queries on
# a second connection.
# This would work if mysqltest run would be threaded and handle each
# connection in a separate thread.
#
-- source include/not_embedded.inc
-- source include/have_bdb.inc
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
connection con1;
create table t1 (id integer, x integer) engine=BDB;
create table t2 (id integer, x integer) engine=BDB;
insert into t1 values(0, 0);
insert into t2 values(0, 0);
set autocommit=0;
update t1 set x = 1 where id = 0;
connection con2;
set autocommit=0;
update t2 set x = 1 where id = 0;
# The following query should hang because con1 is locking the page
--send
select x from t1 where id = 0;
connection con1;
# This should generate a deadlock as we are trying to access a locked row
--send
select x from t2 where id = 0;
connection con2;
--error 1213
reap;
commit;
connection con1;
reap;
commit;
connection con2;
select * from t1;
select * from t2;
commit;
connection con1;
select * from t1;
select * from t2;
commit;
drop table t1,t2;
# End of 4.1 tests
# This test doesn't work with the embedded version as this code
# assumes that one query is running while we are doing queries on
# a second connection.
# This would work if mysqltest run would be threaded and handle each
# connection in a separate thread.
#
#-- source include/not_embedded.inc
-- source include/have_bdb.inc
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
connection con1;
create table t1 (id integer, x integer) engine=BDB;
create table t2 (id integer, x integer) engine=BDB;
insert into t1 values(0, 0);
insert into t2 values(0, 0);
set autocommit=0;
update t1 set x = 1 where id = 0;
connection con2;
set autocommit=0;
update t2 set x = 1 where id = 0;
# The following query should hang because con1 is locking the page
--send
select x from t1 where id = 0;
connection con1;
# This should generate a deadlock as we are trying to access a locked row
--send
select x from t2 where id = 0;
connection con2;
--error 1213
reap;
commit;
connection con1;
reap;
commit;
connection con2;
select * from t1;
select * from t2;
commit;
connection con1;
select * from t1;
select * from t2;
commit;
drop table t1,t2;
# End of 4.1 tests
-- source include/have_bdb.inc
#
# Small basic test with ignore
#
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
--enable_warnings
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=bdb;
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
select id, code, name from t1 order by id;
update ignore t1 set id = 8, name = 'Sinisa' where id < 3;
select id, code, name from t1 order by id;
update ignore t1 set id = id + 10, name = 'Ralph' where id < 4;
select id, code, name from t1 order by id;
drop table t1;
#
# A bit bigger test
#
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
parent_id int(11) DEFAULT '0' NOT NULL,
level tinyint(4) DEFAULT '0' NOT NULL,
PRIMARY KEY (id),
KEY parent_id (parent_id),
KEY level (level)
) engine=bdb;
INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
update t1 set parent_id=parent_id+100;
select * from t1 where parent_id=102;
update t1 set id=id+1000;
-- error 1062
update t1 set id=1024 where id=1009;
select * from t1;
update ignore t1 set id=id+1; # This will change all rows
select * from t1;
update ignore t1 set id=1023 where id=1010;
select * from t1 where parent_id=102 order by parent_id,id;
# Here and below the differences in result are caused by difference in
# floating point calculations performed in BDB handler.
--replace_result 5 X 6 X
explain select level from t1 where level=1;
--replace_result 5 X 6 X
explain select level,id from t1 where level=1;
--replace_result 5 X 6 X
explain select level,id,parent_id from t1 where level=1;
select level,id from t1 where level=1;
select level,id,parent_id from t1 where level=1;
optimize table t1;
show keys from t1;
drop table t1;
#
# Test replace
#
CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL,
benutzer_id int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (gesuchnr,benutzer_id)
) engine=BDB;
replace into t1 (gesuchnr,benutzer_id) values (2,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
select * from t1;
drop table t1;
# test for bug in replace with secondary key
create table t1 (id int not null primary key, x int not null, key (x)) engine=bdb;
insert into t1 (id, x) values (1, 1);
replace into t1 (id, x) values (1, 2);
select * from t1;
drop table t1;
#
# test delete using hidden_primary_key
#
create table t1 (a int) engine=bdb;
insert into t1 values (1), (2);
optimize table t1;
delete from t1 where a = 1;
select * from t1;
check table t1;
drop table t1;
create table t1 (a int,b varchar(20)) engine=bdb;
insert into t1 values (1,""), (2,"testing");
delete from t1 where a = 1;
select * from t1;
create index skr on t1 (a);
insert into t1 values (3,""), (4,"testing");
analyze table t1;
show keys from t1;
drop table t1;
# Test of reading on secondary key with may be null
create table t1 (a int,b varchar(20),key(a)) engine=bdb;
insert into t1 values (1,""), (2,"testing");
select * from t1 where a = 1;
drop table t1;
#
# Test auto_increment on sub key
#
create table t1 (a char(10) not null, b int not null auto_increment, primary key(a,b)) engine=BDB;
insert into t1 values ("a",1),("b",2),("a",2),("c",1);
insert into t1 values ("a",NULL),("b",NULL),("c",NULL),("e",NULL);
insert into t1 (a) values ("a"),("b"),("c"),("d");
insert into t1 (a) values ('k'),('d');
insert into t1 (a) values ("a");
insert into t1 values ("d",last_insert_id());
select * from t1;
flush tables;
select count(*) from t1;
drop table t1;
#
# Test rollback
#
create table t1 (n int not null primary key) engine=bdb;
set autocommit=0;
insert into t1 values (4);
rollback;
select n, "after rollback" from t1;
insert into t1 values (4);
commit;
select n, "after commit" from t1;
commit;
insert into t1 values (5);
-- error 1062
insert into t1 values (4);
commit;
select n, "after commit" from t1;
set autocommit=1;
insert into t1 values (6);
-- error 1062
insert into t1 values (4);
select n from t1;
set autocommit=0;
#
# savepoints
#
begin;
savepoint `my_savepoint`;
insert into t1 values (7);
savepoint `savept2`;
insert into t1 values (3);
select n from t1;
savepoint savept3;
rollback to savepoint savept2;
--error 1305
rollback to savepoint savept3;
rollback to savepoint savept2;
release savepoint `my_savepoint`;
select n from t1;
-- error 1305
rollback to savepoint `my_savepoint`;
--error 1305
rollback to savepoint savept2;
insert into t1 values (8);
savepoint sv;
commit;
savepoint sv;
set autocommit=1;
# nop
rollback;
drop table t1;
#
# Testing transactions
#
create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=BDB;
begin;
insert into t1 values(1,'hamdouni');
select id as afterbegin_id,nom as afterbegin_nom from t1;
rollback;
select id as afterrollback_id,nom as afterrollback_nom from t1;
set autocommit=0;
insert into t1 values(2,'mysql');
select id as afterautocommit0_id,nom as afterautocommit0_nom from t1;
rollback;
select id as afterrollback_id,nom as afterrollback_nom from t1;
set autocommit=1;
drop table t1;
#
# Simple not autocommit test
#
CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=bdb;
insert into t1 values ('pippo', 12);
-- error 1062
insert into t1 values ('pippo', 12); # Gives error
delete from t1;
delete from t1 where id = 'pippo';
select * from t1;
insert into t1 values ('pippo', 12);
set autocommit=0;
delete from t1;
rollback;
select * from t1;
delete from t1;
commit;
select * from t1;
drop table t1;
set autocommit=1;
#
# The following simple tests failed at some point
#
CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=BDB;
INSERT INTO t1 VALUES (1, 'Jochen');
select * from t1;
drop table t1;
CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=BDB;
set autocommit=0;
INSERT INTO t1 SET _userid='marc@anyware.co.uk';
COMMIT;
SELECT * FROM t1;
SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
drop table t1;
set autocommit=1;
#
# Test when reading on part of unique key
#
CREATE TABLE t1 (
user_id int(10) DEFAULT '0' NOT NULL,
name varchar(100),
phone varchar(100),
ref_email varchar(100) DEFAULT '' NOT NULL,
detail varchar(200),
PRIMARY KEY (user_id,ref_email)
)engine=bdb;
INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10292,'shirish','2333604','shirish@yahoo.com','ddsds'),(10292,'sonali','323232','sonali@bolly.com','filmstar');
select * from t1 where user_id=10292;
INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10293,'shirish','2333604','shirish@yahoo.com','ddsds');
select * from t1 where user_id=10292;
select * from t1 where user_id>=10292;
select * from t1 where user_id>10292;
select * from t1 where user_id<10292;
drop table t1;
#
# Test that keys are created in right order
#
CREATE TABLE t1 (a int not null, b int not null,c int not null,
key(a),primary key(a,b), unique(c),key(a),unique(b));
show index from t1;
drop table t1;
#
# Test of ALTER TABLE and BDB tables
#
create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
alter table t1 engine=BDB;
insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
select * from t1;
update t1 set col2='7' where col1='4';
select * from t1;
alter table t1 add co3 int not null;
select * from t1;
update t1 set col2='9' where col1='2';
select * from t1;
drop table t1;
#
# INSERT INTO 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 = myisam;
insert into t1 VALUES (1,3) , (2,3), (3,3);
select * from t1;
insert into t2 select * from t1;
select * from t2;
delete from t1 where b = 3;
select * from t1;
insert into t1 select * from t2;
select * from t1;
select * from t2;
drop table t1,t2;
#
# Search on unique key
#
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
ggid varchar(32) binary DEFAULT '' NOT NULL,
email varchar(64) DEFAULT '' NOT NULL,
passwd varchar(32) binary DEFAULT '' NOT NULL,
PRIMARY KEY (id),
UNIQUE ggid (ggid)
) ENGINE=BDB;
insert into t1 (ggid,passwd) values ('test1','xxx');
insert into t1 (ggid,passwd) values ('test2','yyy');
-- error 1062
insert into t1 (ggid,passwd) values ('test2','this will fail');
-- error 1062
insert into t1 (ggid,id) values ('this will fail',1);
select * from t1 where ggid='test1';
select * from t1 where passwd='xxx';
select * from t1 where id=2;
replace into t1 (ggid,id) values ('this will work',1);
replace into t1 (ggid,passwd) values ('test2','this will work');
-- error 1062
update t1 set id=100,ggid='test2' where id=1;
select * from t1;
select * from t1 where id=1;
select * from t1 where id=999;
drop table t1;
#
# ORDER BY on not primary key
#
CREATE TABLE t1 (
user_name varchar(12),
password text,
subscribed char(1),
user_id int(11) DEFAULT '0' NOT NULL,
quota bigint(20),
weight double,
access_date date,
access_time time,
approved datetime,
dummy_primary_key int(11) NOT NULL auto_increment,
PRIMARY KEY (dummy_primary_key)
) ENGINE=BDB;
INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
select user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
drop table t1;
#
# Testing of tables without primary keys
#
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
parent_id int(11) DEFAULT '0' NOT NULL,
level tinyint(4) DEFAULT '0' NOT NULL,
KEY (id),
KEY parent_id (parent_id),
KEY level (level)
) engine=bdb;
INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1);
INSERT INTO t1 values (179,5,2);
update t1 set parent_id=parent_id+100;
select * from t1 where parent_id=102;
update t1 set id=id+1000;
update t1 set id=1024 where id=1009;
select * from t1;
update ignore t1 set id=id+1; # This will change all rows
select * from t1;
update ignore t1 set id=1023 where id=1010;
select * from t1 where parent_id=102;
--replace_result 5 X 6 X
explain select level from t1 where level=1;
select level,id from t1 where level=1;
select level,id,parent_id from t1 where level=1;
select level,id from t1 where level=1 order by id;
delete from t1 where level=1;
select * from t1;
drop table t1;
#
# Test of index only reads
#
CREATE TABLE t1 (
sca_code char(6) NOT NULL,
cat_code char(6) NOT NULL,
sca_desc varchar(50),
lan_code char(2) NOT NULL,
sca_pic varchar(100),
sca_sdesc varchar(50),
sca_sch_desc varchar(16),
PRIMARY KEY (sca_code, cat_code, lan_code),
INDEX sca_pic (sca_pic)
) engine = bdb ;
INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
select count(*) from t1 where sca_code = 'PD';
select count(*) from t1 where sca_code <= 'PD';
select count(*) from t1 where sca_pic is null;
alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
select count(*) from t1 where sca_code='PD' and sca_pic is null;
select count(*) from t1 where cat_code='E';
alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
select count(*) from t1 where sca_code='PD' and sca_pic is null;
select count(*) from t1 where sca_pic >= 'n';
select sca_pic from t1 where sca_pic is null;
update t1 set sca_pic="test" where sca_pic is null;
delete from t1 where sca_code='pd';
drop table t1;
#
# Test of opening table twice and timestamps
#
set @a:=now();
CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=bdb;
insert into t1 (a) values(1),(2),(3);
select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
select a from t1 natural join t1 as t2 where b >= @a order by a;
update t1 set a=5 where a=1;
select a from t1;
drop table t1;
#
# Test flushing of berkeley DB logs
#
flush logs;
#
# Test key on blob with null values
#
create table t1 (b blob, i int, key (b(100)), key (i), key (i, b(20))) engine=bdb;
insert into t1 values ('this is a blob', 1), (null, -1), (null, null),("",1),("",2),("",3);
select b from t1 where b = 'this is a blob';
select * from t1 where b like 't%';
select b, i from t1 where b is not null;
select * from t1 where b is null and i > 0;
select * from t1 where i is NULL;
update t1 set b='updated' where i=1;
select * from t1;
drop table t1;
#
# Test with variable length primary key
#
create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=bdb;
insert into t1 values("hello",1),("world",2);
select * from t1 order by b desc;
optimize table t1;
show keys from t1;
drop table t1;
#
# Test of bug in create index with NULL columns
#
create table t1 (i int, j int )ENGINE=BDB;
insert into t1 values (1,2);
select * from t1 where i=1 and j=2;
create index ax1 on t1 (i,j);
select * from t1 where i=1 and j=2;
drop table t1;
#
# Test of with CONST tables and TEXT columns
# This gave a wrong result because the row information was freed too early
#
create table t1
(
branch_id int auto_increment primary key,
branch_name varchar(255) not null,
branch_active int not null default 1,
unique branch_name(branch_name),
index branch_active(branch_active)
) engine=bdb;
create table t2
(
target_id int auto_increment primary key,
target_name varchar(255) not null,
target_active int not null default 1,
unique target_name(target_name),
index target_active(target_active)
) engine=bdb;
create table t3
(
platform_id int auto_increment primary key,
platform_name varchar(255) not null,
platform_active int not null default 1,
unique platform_name(platform_name),
index platform_active(platform_active)
) engine=bdb;
create table t4
(
product_id int auto_increment primary key,
product_name varchar(255) not null,
version_file varchar(255) not null,
product_active int not null default 1,
unique product_name(product_name),
index product_active(product_active)
) engine=bdb;
create table t5
(
product_file_id int auto_increment primary key,
product_id int not null,
file_name varchar(255) not null,
/* cvs module used to find the file version */
module_name varchar(255) not null,
/* flag whether the file is still included in the product */
file_included int not null default 1,
unique product_file(product_id,file_name),
index file_included(file_included)
) engine=bdb;
create table t6
(
file_platform_id int auto_increment primary key,
product_file_id int not null,
platform_id int not null,
branch_id int not null,
/* filename in the build system */
build_filename varchar(255) not null,
/* default filename in the build archive */
archive_filename varchar(255) not null,
unique file_platform(product_file_id,platform_id,branch_id)
) engine=bdb;
create table t8
(
archive_id int auto_increment primary key,
branch_id int not null,
target_id int not null,
platform_id int not null,
product_id int not null,
status_id int not null default 1,
unique archive(branch_id,target_id,platform_id,product_id),
index status_id(status_id)
) engine=bdb;
create table t7
(
build_id int auto_increment primary key,
branch_id int not null,
target_id int not null,
build_number int not null,
build_date date not null,
/* build system tag, e.g. 'rmanight-022301-1779' */
build_tag varchar(255) not null,
/* path relative to the build archive root, e.g. 'current' */
build_path text not null,
unique build(branch_id,target_id,build_number)
) engine=bdb;
insert into t1 (branch_name)
values ('RealMedia');
insert into t1 (branch_name)
values ('RP8REV');
insert into t1 (branch_name)
values ('SERVER_8_0_GOLD');
insert into t2 (target_name)
values ('rmanight');
insert into t2 (target_name)
values ('playerall');
insert into t2 (target_name)
values ('servproxyall');
insert into t3 (platform_name)
values ('linux-2.0-libc6-i386');
insert into t3 (platform_name)
values ('win32-i386');
insert into t4 (product_name, version_file)
values ('realserver', 'servinst');
insert into t4 (product_name, version_file)
values ('realproxy', 'prxyinst');
insert into t4 (product_name, version_file)
values ('realplayer', 'playinst');
insert into t4 (product_name, version_file)
values ('plusplayer', 'plusinst');
create temporary table tmp1
select branch_id, target_id, platform_id, product_id
from t1, t2, t3, t4 ;
create temporary table tmp2
select tmp1.branch_id, tmp1.target_id, tmp1.platform_id, tmp1.product_id
from tmp1 left join t8
using (branch_id,target_id,platform_id,product_id)
where t8.archive_id is null ;
insert into t8
(branch_id, target_id, platform_id, product_id, status_id)
select branch_id, target_id, platform_id, product_id, 1
from tmp2 ;
drop table tmp1 ;
drop table tmp2 ;
insert into t5 (product_id, file_name, module_name)
values (1, 'servinst', 'server');
insert into t5 (product_id, file_name, module_name)
values (2, 'prxyinst', 'server');
insert into t5 (product_id, file_name, module_name)
values (3, 'playinst', 'rpapp');
insert into t5 (product_id, file_name, module_name)
values (4, 'plusinst', 'rpapp');
insert into t6
(product_file_id,platform_id,branch_id,build_filename,archive_filename)
values (1, 2, 3, 'servinst.exe', 'win32-servinst.exe');
insert into t6
(product_file_id,platform_id,branch_id,build_filename,archive_filename)
values (1, 1, 3, 'v80_linux-2.0-libc6-i386_servinst.bin', 'linux2-servinst.exe');
insert into t6
(product_file_id,platform_id,branch_id,build_filename,archive_filename)
values (3, 2, 2, 'playinst.exe', 'win32-playinst.exe');
insert into t6
(product_file_id,platform_id,branch_id,build_filename,archive_filename)
values (4, 2, 2, 'playinst.exe', 'win32-playinst.exe');
insert into t7
(branch_id,target_id,build_number,build_tag,build_date,build_path)
values (2, 2, 1071, 'playerall-022101-1071', '2001-02-21', 'current');
insert into t7
(branch_id,target_id,build_number,build_tag,build_date,build_path)
values (2, 2, 1072, 'playerall-022201-1072', '2001-02-22', 'current');
insert into t7
(branch_id,target_id,build_number,build_tag,build_date,build_path)
values (3, 3, 388, 'servproxyall-022201-388', '2001-02-22', 'current');
insert into t7
(branch_id,target_id,build_number,build_tag,build_date,build_path)
values (3, 3, 389, 'servproxyall-022301-389', '2001-02-23', 'current');
insert into t7
(branch_id,target_id,build_number,build_tag,build_date,build_path)
values (4, 4, 100, 'foo target-010101-100', '2001-01-01', 'current');
update t8
set status_id=2
where branch_id=2 and target_id=2 and platform_id=2 and product_id=1;
select t7.build_path
from
t1,
t7,
t2,
t3,
t4,
t5,
t6
where
t7.branch_id = t1.branch_id and
t7.target_id = t2.target_id and
t5.product_id = t4.product_id and
t6.product_file_id = t5.product_file_id and
t6.platform_id = t3.platform_id and
t6.branch_id = t6.branch_id and
t7.build_id = 1 and
t4.product_id = 3 and
t5.file_name = 'playinst' and
t3.platform_id = 2;
drop table t1, t2, t3, t4, t5, t6, t7, t8;
#
# Test with blob + tinyint key
#
CREATE TABLE t1 (
a tinytext NOT NULL,
b tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (a(32),b)
) ENGINE=BDB;
INSERT INTO t1 VALUES ('a',1),('a',2);
SELECT * FROM t1 WHERE a='a' AND b=2;
SELECT * FROM t1 WHERE a='a' AND b in (2);
SELECT * FROM t1 WHERE a='a' AND b in (1,2);
drop table t1;
#
# 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 1062
insert 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 1062
insert 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 where
exists (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 1242
insert into t1 set a=(select b from t2);
select count(*) from t1;
# UPDATE also blows up
update 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_LENGTH
create 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 test
eval 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_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,
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
#
# Bug #7955: SET TRANSACTION ISIOLATION LEVEL lives longer than next
# transaciton
#
create table t1 (a int) engine=bdb;
set session transaction isolation level repeatable read;
set transaction isolation level serializable;
begin;
select @@tx_isolation;
insert into t1 values (1);
--error ER_CANT_CHANGE_TX_ISOLATION
set transaction isolation level read committed;
rollback;
begin;
select @@tx_isolation;
insert into t1 values (1);
rollback;
drop table t1;
--echo End of 5.1 tests
--set-variable=query_cache_size=1M
-- source include/have_bdb.inc
-- source include/have_query_cache.inc
#
# Without auto_commit.
#
--disable_warnings
drop table if exists t1, t2, t3;
--enable_warnings
flush status;
set autocommit=0;
create table t1 (a int not null) engine=bdb;
insert into t1 values (1),(2),(3);
select * from t1;
show status like "Qcache_queries_in_cache";
drop table t1;
set autocommit=1;
create table t1 (a int not null) engine=bdb;
begin;
insert into t1 values (1),(2),(3);
select * from t1;
show status like "Qcache_queries_in_cache";
drop table t1;
create table t1 (a int not null) engine=bdb;
create table t2 (a int not null) engine=bdb;
create table t3 (a int not null) engine=bdb;
insert into t1 values (1),(2);
insert into t2 values (1),(2);
insert into t3 values (1),(2);
select * from t1;
select * from t2;
select * from t3;
show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";
begin;
select * from t1;
select * from t2;
select * from t3;
show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";
insert into t1 values (3);
insert into t2 values (3);
insert into t1 values (4);
select * from t1;
select * from t2;
select * from t3;
show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";
commit;
show status like "Qcache_queries_in_cache";
drop table if exists t1, t2, t3;
# End of 4.1 tests
-- source include/have_bdb.inc
SET storage_engine=bdb;
--source include/gis_generic.inc
......@@ -360,7 +360,7 @@ drop table t1;
create table t1 (
c char(10) character set utf8,
unique key a (c(1))
) engine=bdb;
) engine=innodb;
--enable_warnings
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
--error 1062
......@@ -483,7 +483,7 @@ drop table t1;
create table t1 (
c char(10) character set utf8 collate utf8_bin,
unique key a (c(1))
) engine=bdb;
) engine=innodb;
--enable_warnings
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
--error 1062
......@@ -558,7 +558,7 @@ drop table t1;
create table t1 (
str varchar(255) character set utf8 not null,
key str (str(2))
) engine=bdb;
) engine=innodb;
--enable_warnings
INSERT INTO t1 VALUES ('str');
INSERT INTO t1 VALUES ('str2');
......@@ -644,7 +644,7 @@ create table t1 (
insert into t1 values(1,'foo'),(2,'foobar');
select * from t1 where b like 'foob%';
--disable_warnings
alter table t1 engine=bdb;
alter table t1 engine=innodb;
--enable_warnings
select * from t1 where b like 'foob%';
drop table t1;
......
#
# 2-sweeps read Index_merge test
#
-- source include/have_bdb.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (
pk int primary key,
key1 int,
key2 int,
filler char(200),
filler2 char(200),
index(key1),
index(key2)
) engine=bdb;
--disable_query_log
let $1=1000;
while ($1)
{
eval insert into t1 values($1, $1, $1, 'filler-data','filler-data-2');
dec $1;
}
--enable_query_log
select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 );
set @maxv=1000;
select * from t1 where
(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
or key1=18 or key1=60;
select * from t1 where
(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
or key1 < 3 or key1 > @maxv-11;
select * from t1 where
(pk < 5) or (pk > 10 and pk < 15) or (pk >= 50 and pk < 55 ) or (pk > @maxv-10)
or
(key1 < 5) or (key1 > 10 and key1 < 15) or (key1 >= 50 and key1 < 55 ) or (key1 > @maxv-10);
select * from t1 where
(pk > 10 and pk < 15) or (pk >= 50 and pk < 55 )
or
(key1 < 5) or (key1 > @maxv-10);
drop table t1;
###############################################
# #
# Prepared Statements test on BDB tables #
# #
###############################################
#
# NOTE: PLEASE SEE ps_1general.test (bottom)
# BEFORE ADDING NEW TEST CASES HERE !!!
use test;
-- source include/have_bdb.inc
let $type= 'BDB' ;
-- source include/ps_create.inc
-- source include/ps_renew.inc
-- source include/ps_query.inc
-- source include/ps_modify.inc
-- source include/ps_modify1.inc
-- source include/ps_conv.inc
drop table t1, t9;
# End of 4.1 tests
#
# Test for rowid ordering (and comparison) functions.
# do index_merge select for tables with PK of various types.
#
--disable_warnings
drop table if exists t1, t2, t3,t4;
--enable_warnings
-- source include/have_bdb.inc
# Signed number as rowid
create table t1 (
pk1 int not NULL,
key1 int(11),
key2 int(11),
PRIMARY KEY (pk1),
KEY key1 (key1),
KEY key2 (key2)
) engine=bdb;
insert into t1 values (-5, 1, 1),
(-100, 1, 1),
(3, 1, 1),
(0, 1, 1),
(10, 1, 1);
explain select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
drop table t1;
# Unsigned numbers as rowids
create table t1 (
pk1 int unsigned not NULL,
key1 int(11),
key2 int(11),
PRIMARY KEY (pk1),
KEY key1 (key1),
KEY key2 (key2)
) engine=bdb;
insert into t1 values (0, 1, 1),
(0xFFFFFFFF, 1, 1),
(0xFFFFFFFE, 1, 1),
(1, 1, 1),
(2, 1, 1);
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
drop table t1;
# Case-insensitive char(N)
create table t1 (
pk1 char(4) not NULL,
key1 int(11),
key2 int(11),
PRIMARY KEY (pk1),
KEY key1 (key1),
KEY key2 (key2)
) engine=bdb collate latin2_general_ci;
insert into t1 values ('a1', 1, 1),
('b2', 1, 1),
('A3', 1, 1),
('B4', 1, 1);
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
drop table t1;
# Multi-part PK
create table t1 (
pk1 int not NULL,
pk2 char(4) not NULL collate latin1_german1_ci,
pk3 char(4) not NULL collate latin1_bin,
key1 int(11),
key2 int(11),
PRIMARY KEY (pk1,pk2,pk3),
KEY key1 (key1),
KEY key2 (key2)
) engine=bdb;
insert into t1 values
(1, 'u', 'u', 1, 1),
(1, 'u', char(0xEC), 1, 1),
(1, 'u', 'x', 1, 1);
insert ignore into t1 select pk1, char(0xEC), pk3, key1, key2 from t1;
insert ignore into t1 select pk1, 'x', pk3, key1, key2 from t1 where pk2='u';
insert ignore into t1 select 2, pk2, pk3, key1, key2 from t1;
select * from t1;
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
# Hidden PK
alter table t1 drop primary key;
select * from t1;
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
drop table t1;
# Variable-length PK
# this is also test for Bug#2688
create table t1 (
pk1 varchar(8) NOT NULL default '',
pk2 varchar(4) NOT NULL default '',
key1 int(11),
key2 int(11),
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;
......@@ -29,7 +29,7 @@ ADD_DEFINITIONS(-DHAVE_ROW_BASED_REPLICATION -DMYSQL_SERVER
ADD_EXECUTABLE(mysqld ../sql-common/client.c derror.cc des_key_file.cc
discover.cc ../libmysql/errmsg.c field.cc field_conv.cc
filesort.cc gstream.cc ha_heap.cc ha_myisam.cc ha_myisammrg.cc
ha_innodb.cc ha_partition.cc ha_federated.cc ha_berkeley.cc
ha_innodb.cc ha_partition.cc ha_federated.cc
handler.cc hash_filo.cc hash_filo.h
hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc
item_create.cc item_func.cc item_geofunc.cc item_row.cc
......
......@@ -47,7 +47,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
item_create.h item_subselect.h item_row.h \
mysql_priv.h item_geofunc.h sql_bitmap.h \
procedure.h sql_class.h sql_lex.h sql_list.h \
sql_manager.h sql_map.h sql_string.h unireg.h \
sql_map.h sql_string.h unireg.h \
sql_error.h field.h handler.h mysqld_suffix.h \
ha_heap.h ha_myisam.h ha_myisammrg.h ha_partition.h \
ha_innodb.h ha_federated.h \
......
......@@ -23,7 +23,6 @@
*/
#include "mysql_priv.h"
#include "sql_manager.h"
ulong volatile manager_status;
bool volatile manager_thread_in_use;
......
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef WITH_BERKELEY_STORAGE_ENGINE
void berkeley_cleanup_log_files(void);
#endif /* WITH_BERKELEY_STORAGE_ENGINE */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment