⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 innodb.test

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 TEST
📖 第 1 页 / 共 5 页
字号:
--replace_column 9 #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 = innodb ;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=innodb;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 with variable length primary key#create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb;insert into t1 values("hello",1),("world",2);select * from t1 order by b desc;optimize table t1;--replace_column 7 #show keys from t1;drop table t1;## Test of create index with NULL columns#create table t1 (i int, j int ) ENGINE=innodb;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 min-max optimization#CREATE TABLE t1 (  a int3 unsigned NOT NULL,  b int1 unsigned NOT NULL,  UNIQUE (a, b)) ENGINE = innodb; INSERT INTO t1 VALUES (1, 1);SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1;drop table t1;## Test INSERT DELAYED#CREATE TABLE t1 (a int unsigned NOT NULL) engine=innodb;# Can't test this in 3.23# INSERT DELAYED INTO t1 VALUES (1);INSERT INTO t1 VALUES (1);SELECT * FROM t1;DROP TABLE t1;## Crash when using many tables (Test case by Jeremy D Zawodny)#create table t1 (a int  primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb;insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);--replace_column 9 #explain select * from t1 where a > 0 and a < 50;drop table t1;## Test lock tables#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=innodb;insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');LOCK TABLES t1 WRITE;--error 1062insert into t1 values (99,1,2,'D'),(1,1,2,'D');select id from t1;select id from t1;UNLOCK TABLES;DROP TABLE t1;create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');LOCK TABLES t1 WRITE;begin;--error 1062insert into t1 values (99,1,2,'D'),(1,1,2,'D');select id from t1;insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');commit;select id,id3 from t1;UNLOCK TABLES;DROP TABLE t1;## Test prefix key#create table t1 (a char(20), unique (a(5))) engine=innodb;drop table t1;create table t1 (a char(20), index (a(5))) engine=innodb;show create table t1;drop table t1;## Test using temporary table and auto_increment#create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb;insert into t1 values (NULL),(NULL),(NULL);delete from t1 where a=3;insert into t1 values (NULL);select * from t1;alter table t1 add b int;select * from t1;drop table t1;#Slashdot bugcreate table t1 (  id int auto_increment primary key,  name varchar(32) not null,  value text not null,  uid int not null,  unique key(name,uid) ) engine=innodb;insert into t1 values (1,'one','one value',101), (2,'two','two value',102),(3,'three','three value',103);set insert_id=5;replace into t1 (value,name,uid) values ('other value','two',102);delete from t1 where uid=102;set insert_id=5;replace into t1 (value,name,uid) values ('other value','two',102);set insert_id=6;replace into t1 (value,name,uid) values ('other value','two',102);select * from t1;drop table t1;## Test DROP DATABASE#create database mysqltest;create table mysqltest.t1 (a int not null) engine= innodb;insert into mysqltest.t1 values(1);create table mysqltest.t2 (a int not null) engine= myisam;insert into mysqltest.t2 values(1);create table mysqltest.t3 (a int not null) engine= heap;insert into mysqltest.t3 values(1);commit;drop database mysqltest;# Don't check error message--error 1049show tables from mysqltest;## Test truncate table with and without auto_commit#set autocommit=0;create table t1 (a int not null) engine= innodb;insert into t1 values(1),(2);truncate table t1;commit;truncate table t1;truncate table t1;select * from t1;insert into t1 values(1),(2);delete from t1;select * from t1;commit;drop table t1;set autocommit=1;create table t1 (a int not null) engine= innodb;insert into t1 values(1),(2);truncate table t1;insert into t1 values(1),(2);select * from t1;truncate table t1;insert into t1 values(1),(2);delete from t1;select * from t1;drop table t1;## Test of how ORDER BY works when doing it on the whole table#create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=innodb;insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);--replace_column 9 #explain select * from t1 order by a;--replace_column 9 #explain select * from t1 order by b;--replace_column 9 #explain select * from t1 order by c;--replace_column 9 #explain select a from t1 order by a;--replace_column 9 #explain select b from t1 order by b;--replace_column 9 #explain select a,b from t1 order by b;--replace_column 9 #explain select a,b from t1;--replace_column 9 #explain select a,b,c from t1;drop table t1;## Check describe#create table t1 (t int not null default 1, key (t)) engine=innodb;desc t1;drop table t1;## Test of multi-table-delete#CREATE TABLE t1 (  number bigint(20) NOT NULL default '0',  cname char(15) NOT NULL default '',  carrier_id smallint(6) NOT NULL default '0',  privacy tinyint(4) NOT NULL default '0',  last_mod_date timestamp NOT NULL,  last_mod_id smallint(6) NOT NULL default '0',  last_app_date timestamp NOT NULL,  last_app_id smallint(6) default '-1',  version smallint(6) NOT NULL default '0',  assigned_scps int(11) default '0',  status tinyint(4) default '0') ENGINE=InnoDB;INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1);INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);CREATE TABLE t2 (  number bigint(20) NOT NULL default '0',  cname char(15) NOT NULL default '',  carrier_id smallint(6) NOT NULL default '0',  privacy tinyint(4) NOT NULL default '0',  last_mod_date timestamp NOT NULL,  last_mod_id smallint(6) NOT NULL default '0',  last_app_date timestamp NOT NULL,  last_app_id smallint(6) default '-1',  version smallint(6) NOT NULL default '0',  assigned_scps int(11) default '0',  status tinyint(4) default '0') ENGINE=InnoDB;INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1);INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);select * from t1;select * from t2;delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or  (t1.carrier_id=90 and t2.number is null);select * from t1;select * from t2; select * from t2;drop table t1,t2;## A simple test with some isolation levels# TODO: Make this into a test using replication to really test how# this works.#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=innodb;BEGIN;SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;SELECT @@tx_isolation,@@global.tx_isolation;insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');select id, code, name from t1 order by id;COMMIT;BEGIN;SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');select id, code, name from t1 order by id;COMMIT;BEGIN;SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');select id, code, name from t1 order by id;COMMIT;DROP TABLE t1;## Test of multi-table-update#create table t1 (n int(10), d int(10)) engine=innodb;create table t2 (n int(10), d int(10)) engine=innodb;insert into t1 values(1,1),(1,2);insert into t2 values(1,10),(2,20);UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;select * from t1;select * from t2;drop table t1,t2;## Bug#27716  	multi-update did partially and has not binlogged#CREATE TABLE `t1` (  `a` int(11) NOT NULL auto_increment,  `b` int(11) default NULL,  PRIMARY KEY  (`a`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;CREATE TABLE `t2` (  `a` int(11) NOT NULL auto_increment,  `b` int(11) default NULL,  PRIMARY KEY  (`a`)) ENGINE=INNODB DEFAULT CHARSET=latin1 ;# A. testing multi_update::send_eof() execution branchinsert into t1 values (1,1),(2,2);insert into t2 values (1,1),(4,4);reset master;--error ER_DUP_ENTRYUPDATE t2,t1 SET t2.a=t1.a+2;# checkselect * from t2 /* must be (3,1), (4,4) */;show master status /* there must no UPDATE in binlog */;# B. testing multi_update::send_error() execution branchdelete from t1;delete from t2;insert into t1 values (1,2),(3,4),(4,4);insert into t2 values (1,2),(3,4),(4,4);reset master;--error ER_DUP_ENTRYUPDATE t2,t1  SET t2.a=t2.b where t2.a=t1.a;show master status /* there must be no UPDATE query event */;# cleanup bug#27716drop table t1, t2;## Testing of IFNULL#create table t1 (a int, b int) engine=innodb;insert into t1 values(20,null);select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 ont2.b=t3.a;select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 ont2.b=t3.a order by 1;insert into t1 values(10,null);select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 ont2.b=t3.a order by 1;drop table t1;## Test of read_through not existing const_table#create table t1 (a varchar(10) not null) engine=myisam;create table t2 (b varchar(10) not null unique) engine=innodb;select t1.a from t1,t2 where t1.a=t2.b;drop table t1,t2;create table t1 (a int not null, b int, primary key (a)) engine = innodb;create table t2 (a int not null, b int, primary key (a)) engine = innodb;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -