未验证 提交 3d084c74 编写于 作者: S shangyanwen 提交者: GitHub

test(mtr):add insert,create....The test script(#497) (#503)

* syw test

* syw commit mtr/create_index.test

* syw commit dropdb mtr

* add mtr create

* add mtr create_table

* commit mtr select

* Submit the modified script

* add mtr insert

* delete select_tpch.test

test

* delete select_tpch.result

* add tianmu_insert_delayed
Co-authored-by: Nmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
上级 4d47e72c
......@@ -23,6 +23,8 @@ loose-innodb_log_file_size= 5M
loose-innodb_log_files_in_group= 2
default-storage-engine=InnoDB
tianmu_insert_delayed=off
slave-net-timeout=120
log-bin=mysqld-bin
......
#
#Test creating libraries with names that are too long
#
create database aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long
drop database aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long
#
#test common library creation scenarios
#
create database test_db;
create database test_db;
ERROR HY000: Can't create database 'test_db'; database exists
create database if not exists test_db;
Warnings:
Note 1007 Can't create database 'test_db'; database exists
drop database test_db;
create database 1ea10;
drop database 1ea10;
create database e$8b;
drop database e$8b;
#
#Test the exception scenario use case for creating the library
#
create database 888;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '888' at line 1
create database "";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '""' at line 1
create database " ";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '" "' at line 1
create database "test ";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"test "' at line 1
create database "test...";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"test..."' at line 1
create database "$test$";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"$test$"' at line 1
create database "test.test";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"test.test"' at line 1
create database "'test'";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"'test'"' at line 1
create database "test/test";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"test/test"' at line 1
create table t1 (f1 binary(5)) engine=innodb;
insert into t1 values ('w'), ('w');
create unique index index_t1 on t1(f1(4));
ERROR 23000: Duplicate entry 'w' for key 'index_t1'
drop table t1;
此差异已折叠。
create database b;
use b;
create table `mysql50` (f1 int primary key) engine=tianmu;
drop database b;
此差异已折叠。
--source include/have_tianmu.inc
--echo #
--echo #Test creating libraries with names that are too long
--echo #
--error 1059
create database aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
--error 1059
drop database aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
--echo #
--echo #test common library creation scenarios
--echo #
create database test_db;
--error 1007
create database test_db;
create database if not exists test_db;
drop database test_db;
create database 1ea10;
drop database 1ea10;
create database e$8b;
drop database e$8b;
--echo #
--echo #Test the exception scenario use case for creating the library
--echo #
--error 1064
create database 888;
--error 1064
create database "";
--error 1064
create database " ";
--error 1064
create database "test ";
--error 1064
create database "test...";
--error 1064
create database "$test$";
--error 1064
create database "test.test";
--error 1064
create database "'test'";
--error 1064
create database "test/test";
--source include/have_tianmu.inc
create table t1 (f1 binary(5)) engine=innodb;
insert into t1 values ('w'), ('w');
--error ER_DUP_ENTRY
create unique index index_t1 on t1(f1(4));
drop table t1;
--source include/have_tianmu.inc
--echo #
--echo # Test table name
--echo #
drop table if exists t1,t2,t3,t4,t5;
drop database if exists mysqltest;
drop view if exists v1;
create table t1 (b char(0) not null)ENGINE=tianmu;
--error 1048
insert into t1 values (""),(null);
create table if not exists t1 (b char(0) not null)ENGINE=tianmu;
--error 1167
create table t1 (b char(0) not null, index(b))engine=tianmu;
drop table t1;
create table `a/a` (a int)engine=tianmu;
show create table `a/a`;
create table t1 like `a/a`;
drop table `a/a`,`t1`;
--echo #
--echo # Tests the long field name table
--echo #
--error 1059
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int)engine=tianmu;
--error 1059
create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int)engine=tianmu;
--error 1067
create table t1 (a int default 100 auto_increment)engine=tianmu;
--error 1067
create table t1 (a tinyint default 1000)engine=tianmu;
--error 1067
create table t1 (a varchar(5) default 'abcdef')engine=tianmu;
create table t1 (a varchar(5) default 'abcde')engine=tianmu;
insert into t1 values();
select * from t1;
--error 1067
alter table t1 alter column a set default 'abcdef';
drop table t1;
--echo #
--echo # test of dummy table names
--echo #
create table 1ea10 (1a20 int,1e int)engine=tianmu;
insert into 1ea10 values(1,1);
select 1ea10.1a20,1e+ 1e+10 from 1ea10;
drop table 1ea10;
create table t1 (t1.index int)engine=tianmu;
drop table t1;
create database mysqltest;
use mysqltest;
create table mysqltest.test2$ (a int);
drop table mysqltest.test2$;
drop database mysqltest;
--error 1103
create table `` (a int)engine=tianmu;
--error 1103
drop table if exists ``;
use test;
--error 1166
create table t1 (`` int)engine=tianmu;
--error 1280
create table t1 (i int, index `` (i))engine=tianmu;
create table t1 (i int)engine=tianmu;
drop table t1;
--echo #
--echo # Test of CREATE ... select with indexes
--echo #
create table t1 (a int auto_increment not null primary key, B CHAR(20))engine=tianmu;
insert into t1 (b) values ("hello"),("my"),("world");
explain select * from t1 where b="world";
select * from t1 where b="world";
drop table t1;
--echo #
--echo # Test of primary key with 32 index
--echo #
create table t1 (a int not null, b int, primary key(a), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b))engine=tianmu;
show create table t1;
drop table t1;
--echo #
--echo # Test default table type
--echo #
set session default_storage_engine="tianmu";
select @@default_storage_engine;
create table t1 (a int not null);
show create table t1;
drop table t1;
--error 1286
set session default_storage_engine="gemini";
set session default_storage_engine=default;
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2))engine=tianmu;
insert into t1 values ("a", 1), ("b", 2);
--error 1048
insert into t1 values ("c", NULL);
--error 1048
insert into t1 values (NULL, 3);
--error 1048
insert into t1 values (NULL, NULL);
drop table t1;
create table t1 select x'4132';
--error 1050
create table t1 select 1,2,3;
create table if not exists t1 select 1,2;
create table if not exists t1 select 1,2,3,4;
create table if not exists t1 select 1;
select * from t1;
drop table t1;
--echo #
--echo # Test create table if not exists with duplicate key error
--echo #
create table t1 (a int not null, b int, primary key (a));
insert into t1 values (1,1);
select * from t1;
show status like "Opened_tables";
select * from t1;
drop table t1;
--echo #
--echo # "Table truncated when creating another table name with Spaces"
--echo #
--error 1103
create table `t1 `(a int)engine=tianmu;
--error 1102
create database `db1 `;
--error 1166
create table t1(`a ` int)engine=tianmu;
--echo #
--echo # "Parser permits multiple commas without syntax error"
--echo #
--error 1064
create table t1 (a int,)engine=tianmu;
--error 1064
create table t1 (a int,,b int)engine=tianmu;
--error 1064
create table t1 (,b int)engine=tianmu;
--echo #
--echo # Test create with foreign keys
--echo #
create table t1 (a int, key(a))engine=tianmu;
create table t2 (b int, foreign key(b) references t1(a), key(b))engine=tianmu;
drop table if exists t1,t2;
--echo #
--echo # Test for create table .. LIKE ..
--echo #
create table t1(id int not null, name char(20))engine=tianmu;
insert into t1 values(10,'mysql'),(20,'monty- the creator');
create table t2(id int not null)engine=tianmu;
insert into t2 values(10),(20);
create table t3 like t1;
show create table t3;
select * from t3;
create table if not exists t3 like t1;
select @@warning_count;
--error 1049
create table non_existing_database.t1 like t1;
--error 1146
create table t3 like non_existing_table;
drop table t1,t3;
--echo #
--echo # Test types of data for create select with functions
--echo #
create table t1(a int,b int,c int,d date,e char,f datetime,g time,h blob)engine=tianmu;
insert into t1(a)values(1);
insert into t1(a,b,c,d,e,f,g,h)values(2,-2,2,'1825-12-14','a','2003-1-1 3:2:1','4:3:2','binary data');
select * from t1;
select a,
ifnull(b,cast(-7 as signed)) as b,
ifnull(c,cast(7 as unsigned)) as c,
ifnull(d,cast('2000-01-01' as date)) as d,
ifnull(e,cast('b' as char)) as e,
ifnull(f,cast('2000-01-01' as datetime)) as f,
ifnull(g,cast('5:4:3' as time)) as g,
ifnull(h,cast('yet another binary data' as binary)) as h,
addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd
from t1;
explain t1;
drop table t1;
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, l datetime, o char(10))engine=tianmu;
show create table t1;
drop table t1;
create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14')engine=tianmu;
insert into t1 values ('','',0,0.0);
describe t1;
drop table t1;
create table t1(name varchar(10), age smallint default -1);
describe t2;
--echo #
--echo # 'Naming a key "Primary" causes trouble'
--echo #
--error 1280
create table t1 (a int, index `primary` (a))engine=tianmu;
--error 1280
create table t1 (a int, index `PRIMARY` (a))engine=tianmu;
drop table t1;
create table t1 (`primary` int, index(`primary`))engine=tianmu;
show create table t1;
drop table t2;
create table t2 (`PRIMARY` int, index(`PRIMARY`))engine=tianmu;
show create table t2;
create table t3 (a int);
--error 1280
alter table t3 add index `primary` (a);
--error 1280
alter table t3 add index `PRIMARY` (a);
create table t4 (`primary` int)engine=tianmu;
drop table t1,t2,t3,t4;
--echo #
--echo #Can't use 'DEFAULT FALSE' for column of type bool
--echo #
create table t1 (b bool not null default false)engine=tianmu;
create table t2 (b bool not null default true)engine=tianmu;
insert into t1 values ();
insert into t2 values ();
select * from t1;
select * from t2;
drop table t1,t2;
--echo #
--echo # Invalid column name is not rejected
--echo #
create database syw_mtr;
use syw_mtr;
--error 1103
create table t1(column.name int)engine=tianmu;
--error 1102
create table t1(test.column.name int)engine=tianmu;
--error 1102
create table t1(xyz.t1.name int)engine=tianmu;
create table t1(t1.name int)engine=tianmu;
create table t2(syw_mtr.t2.name int)engine=tianmu;
drop table t1,t2;
drop database syw_mtr;
--echo #
--echo #create table like
--echo #
use test;
--error 1146
create table test.t1 like x;
drop table if exists test.t1;
--echo #
--echo #Bogus error message on attempt to create table t LIKE view
--echo #
create database mysqltest;
use mysqltest;
create view v1 as select 'foo' from dual;
--error 1347
create table t1 like v1;
drop view v1;
drop database mysqltest;
--echo #
--echo #SET value having comma not correctly handled
--echo #
use test;
--error 1367
create table t1(a set("a,b","c,d") not null);
--echo #
--echo #mysqld segfault when trying to create table with same name as existing view
--echo #
create table t1 (a int);
create table t2 (a int);
insert into t1 values (1),(2),(3);
insert into t2 values (1),(2),(3);
create view v1 as select t1.a FROM t1, t2;
--error 1050
create table v1 as select * FROM t1;
drop view v1;
drop table t1,t2;
SET sql_mode = 'NO_ZERO_DATE';
create table t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT 0);
drop table t2;
create table t2(c1 TIMESTAMP NULL);
SET sql_mode = '';
drop table t2;
--echo #
--echo #Tests the default type of year for the created table and inserts a null value
--echo #
create table t1(c1 year default 2008, c2 year default 0);
SHOW create table t1;
insert into t1 values();
select * FROM t1;
drop table t1;
--echo #
--echo # Attempt to create table with invalid default should fail in normal mode
--echo #
--error 1067
create table t1 (dt datetime default '2008-02-31 00:00:00');
set @old_mode= @@sql_mode;
set @@sql_mode='ALLOW_INVALID_DATES';
--echo # The same should be possible in relaxed mode
create table t1 (dt datetime default '2008-02-31 00:00:00');
set @@sql_mode= @old_mode;
--error 1067
create table t2 like t1;
set @@sql_mode='ALLOW_INVALID_DATES';
create table t2 like t1;
show create table t1;
show create table t2;
set @@sql_mode= @old_mode;
drop tables t1,t2;
--echo #
--echo # Creating a base table in presence of an updatable view.
--echo #
create table t2 (a int unique);
create view t1 as select a from t2;
insert into t1 (a) values (1);
--error 1050
create table t1 (a int);
create table if not exists t1 (a int);
--error 1050
create table t1 (a int) select 2 as a;
select * from t1;
create table if not exists t1 (a int) select 2 as a;
select * from t1;
select * from t2;
create temporary table if not exists t1 (a int) select 3 as a;
select * from t1;
select * from t2;
drop table t1,t2;
drop view t1;
--echo #
--echo # Repeating the test with a view select a constant number
--echo #
create view t1 as select 1 as a;
--error 1471
insert into t1 (a) values (1);
--error 1288
update t1 set a=3 where a=2;
--error 1050
create table t1 (a int);
create table if not exists t1 (a int);
--error 1050
create table t1 (a int) select 2 as a;
select * from t1;
# Note: an essential warning.
create table if not exists t1 (a int) select 2 as a;
select * from t1;
create temporary table if not exists t1 (a int) select 3 as a;
select * from t1;
# Note: an essential warning.
create temporary table if not exists t1 (a int) select 4 as a;
select * from t1;
drop temporary table t1;
drop view t1;
--echo # Test cases added for coverage.
create table t1(fld1 DATETIME NOT NULL DEFAULT '1111:11:11');
show create table t1;
drop table t1;
--echo # create table..select based on trigger fields.
create table t1 (fld1 int, fld2 DATETIME DEFAULT '1211:1:1');
show create table t1;
create database b;
use b;
create table `mysql50` (f1 int primary key) engine=tianmu;
drop database b;
--source include/have_tianmu.inc
--echo #
--echo #Insert values for different types of fields
--echo #
use test;
CREATE TABLE `column_type_test` (
`c_tinyint` tinyint(4) DEFAULT NULL COMMENT 'tinyint',
......@@ -33,3 +38,432 @@ values(104,104,104,104,104,5.2,10.88,104.083,'2016-02-25','2016-02-25 10:20:01',
select * from column_type_test;
drop table column_type_test;
--echo #
--echo # Test of refering to old values
--echo #
--disable_warnings
drop table if exists t1,t2,t3;
--enable_warnings
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
create table t1 (a int not null);
insert into t1 values (1);
insert into t1 values (a+2);
insert into t1 values (a+3),(a+4);
insert into t1 values (5),(a+6);
select * from t1;
drop table t1;
--echo #
--echo # Test of duplicate key values with packed keys
--echo #
create table t1 (id int not null auto_increment primary key, username varchar(32) not null, unique (username));
insert into t1 values (0,"mysql");
insert into t1 values (0,"mysql ab");
insert into t1 values (0,"mysql a");
insert into t1 values (0,"r1manic");
insert into t1 values (0,"r1man");
drop table t1;
--echo #
--echo # Test insert syntax
--echo #
create table t1 (a int not null auto_increment, primary key (a), t timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, c char(10) default "hello", i int)engine=tianmu;
insert into t1 values (default,default,default,default), (default,default,default,default), (4,0,"a",5),(default,default,default,default);
select a,t>0,c,i from t1;
truncate table t1;
insert into t1 set a=default,t=default,c=default;
insert into t1 set a=default,t=default,c=default,i=default;
insert into t1 set a=4,t=0,c="a",i=5;
insert into t1 set a=5,t=0,c="a",i=null;
insert into t1 set a=default,t=default,c=default,i=default;
select a,t>0,c,i from t1;
drop table t1;
--echo #
--echo # Test problem with bulk insert and auto_increment on second part keys
--echo #
create table t1 (sid char(20), id int(2) NOT NULL auto_increment, key(sid, id)) engine=myisam;
insert into t1 values ('skr',NULL),('skr',NULL),('test',NULL);
select * from t1;
insert into t1 values ('rts',NULL),('rts',NULL),('test',NULL);
select * from t1;
drop table t1;
--echo #
--echo #Test of behaviour with INSERT VALUES (NULL)
--echo #
create table t1 (id int NOT NULL DEFAULT 8);
-- error 1048
insert into t1 values(NULL);
insert into t1 values (1), (NULL), (2);
select * from t1;
drop table t1;
--echo #
--echo # Test of mysqld crash with fully qualified column names
--echo #
--disable_warnings
drop database if exists mysqltest;
--enable_warnings
create database mysqltest;
use mysqltest;
create table t1 (c int);
insert into mysqltest.t1 set mysqltest.t1.c = '1';
drop database mysqltest;
use test;
--echo #
--echo # Test of wrong values for float data
--echo #
# PS gives sligthly different numbers for max-float/max-double
--disable_ps_protocol
create table t1(number int auto_increment primary key, original_value varchar(50), f_double double, f_float float, f_double_7_2 double(7,2), f_float_4_3 float (4,3), f_double_u double, f_float_u float, f_double_15_1_u double(15,1), f_float_3_1_u float (3,1));
set @value= "aa";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--query_vertical select * from t1 where number =last_insert_id()
set @value= "1aa";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--query_vertical select * from t1 where number =last_insert_id()
set @value= "aa1";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--query_vertical select * from t1 where number =last_insert_id()
set @value= "1e+1111111111a";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--query_vertical select * from t1 where number =last_insert_id()
set @value= "-1e+1111111111a";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--query_vertical select * from t1 where number =last_insert_id()
--error 1367
set @value= 1e+1111111111;
--error 1367
set @value= -1e+1111111111;
set @value= 1e+111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--query_vertical select * from t1 where number =last_insert_id()
set @value= -1e+111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--query_vertical select * from t1 where number =last_insert_id()
set @value= 1;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--query_vertical select * from t1 where number =last_insert_id()
set @value= -1;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--query_vertical select * from t1 where number =last_insert_id()
drop table t1;
--enable_ps_protocol
--echo #
--echo # Test automatic result buffering with INSERT INTO t1 ... SELECT ... FROM t1
--echo #
create table t1(id1 int not null auto_increment primary key, t char(12));
create table t2(id2 int not null, t char(12));
create table t3(id3 int not null, t char(12), index(id3));
disable_query_log;
let $1 = 100;
while ($1)
{
let $2 = 5;
eval insert into t1(t) values ('$1');
while ($2)
{
eval insert into t2(id2,t) values ($1,'$2');
let $3 = 10;
while ($3)
{
eval insert into t3(id3,t) values ($1,'$2');
dec $3;
}
dec $2;
}
dec $1;
}
enable_query_log;
select count(*) from t2;
insert into t2 select t1.* from t1, t2 t, t3 where t1.id1 = t.id2 and t.id2 = t3.id3;
select count(*) from t2;
drop table t1,t2,t3;
--echo #
--echo # Test different cases of duplicate fields
--echo #
create table t1 (a int, b int);
insert into t1 (a,b) values (a,b);
insert into t1 SET a=1, b=a+1;
insert into t1 (a,b) select 1,2;
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
--error 1110
prepare stmt1 from ' replace into t1 (a,a) select 100, ''hundred'' ';
--error 1110
insert into t1 (a,b,b) values (1,1,1);
--error 1136
insert into t1 (a,a) values (1,1,1);
--error 1110
insert into t1 (a,a) values (1,1);
--error 1110
insert into t1 SET a=1,b=2,a=1;
--error 1110
insert into t1 (b,b) select 1,2;
--error 1110
INSERT INTO t1 (b,b) SELECT 0,0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
drop table t1;
--echo #
--echo # Test for values returned by ROW_COUNT() function
--echo # (and thus for values returned by mysql_affected_rows())
--echo # for various forms of INSERT
--echo #
create table t1 (id int primary key, data int);
insert into t1 values (1, 1), (2, 2), (3, 3);
select row_count();
insert ignore into t1 values (1, 1);
#insert ignore gives warnings which resets the row_count.
#'select row_count()' will not show the row_count from above statement.
select row_count();
# Reports that 2 rows are affected (1 deleted + 1 inserted)
replace into t1 values (1, 11);
select row_count();
replace into t1 values (4, 4);
select row_count();
# Reports that 2 rows are affected. This conforms to documentation.
# (Useful for differentiating inserts from updates).
insert into t1 values (2, 2) on duplicate key update data= data + 10;
select row_count();
insert into t1 values (5, 5) on duplicate key update data= data + 10;
select row_count();
drop table t1;
--echo #
--echo # ON DUPLICATE KEY clause allows fields not from the insert table
--echo #
create table t1 (f1 int unique, f2 int);
create table t2 (f3 int, f4 int);
create view v1 as select * from t1, t2 where f1= f3;
insert into t1 values (1,11), (2,22);
insert into t2 values (1,12), (2,24);
--error 1393
insert into v1 (f1) values (3) on duplicate key update f3= f3 + 10;
--error 1393
insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
select * from t1;
--error 1393
insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
select * from t1;
drop view v1;
drop table t1,t2;
--echo #
--echo # mysqld (debug) aborts when inserting specific numbers into char fields
--echo #
CREATE TABLE t1 (
a char(20) NOT NULL,
b char(7) DEFAULT NULL,
c char(4) DEFAULT NULL
);
INSERT INTO t1(a,b,c) VALUES (9.999999e+0, 9.999999e+0, 9.999e+0);
INSERT INTO t1(a,b) VALUES (1.225e-04, 1.225e-04);
INSERT INTO t1(a,b) VALUES (1.225e-01, 1.225e-01);
INSERT INTO t1(a,b) VALUES (1.225877e-01, 1.225877e-01);
INSERT INTO t1(a,b) VALUES (1.225e+01, 1.225e+01);
INSERT INTO t1(a,b,c) VALUES (1.225e+01, 1.225e+01, 1.225e+01);
INSERT INTO t1(a,b) VALUES (1.225e+05, 1.225e+05);
INSERT INTO t1(a,b) VALUES (1.225e+10, 1.225e+10);
INSERT INTO t1(a,b) VALUES (1.225e+15, 1.225e+15);
INSERT INTO t1(a,b) VALUES (5000000e+0, 5000000e+0);
INSERT INTO t1(a,b) VALUES (1.25e+78, 1.25e+78);
INSERT INTO t1(a,b) VALUES (1.25e-94, 1.25e-94);
INSERT INTO t1(a,b) VALUES (1.25e+203, 1.25e+203);
INSERT INTO t1(a,b) VALUES (1.25e-175, 1.25e-175);
INSERT INTO t1(a,c) VALUES (1.225e+0, 1.225e+0);
INSERT INTO t1(a,c) VALUES (1.37e+0, 1.37e+0);
INSERT INTO t1(a,c) VALUES (-1.37e+0, -1.37e+0);
INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (
a char(20) NOT NULL,
b char(7) DEFAULT NULL,
c char(5)
);
INSERT INTO t1(a,b,c) VALUES (9.999999e+0, 9.999999e+0, 9.999e+0);
INSERT INTO t1(a,b,c) VALUES (1.225e-05, 1.225e-05, 1.225e-05);
INSERT INTO t1(a,b) VALUES (1.225e-04, 1.225e-04);
INSERT INTO t1(a,b) VALUES (1.225e-01, 1.225e-01);
INSERT INTO t1(a,b) VALUES (1.225877e-01, 1.225877e-01);
INSERT INTO t1(a,b) VALUES (1.225e+01, 1.225e+01);
INSERT INTO t1(a,b,c) VALUES (1.225e+01, 1.225e+01, 1.225e+01);
INSERT INTO t1(a,b) VALUES (1.225e+05, 1.225e+05);
INSERT INTO t1(a,b) VALUES (1.225e+10, 1.225e+10);
INSERT INTO t1(a,b) VALUES (1.225e+15, 1.225e+15);
INSERT INTO t1(a,b) VALUES (5000000e+0, 5000000e+0);
INSERT INTO t1(a,b) VALUES (1.25e+78, 1.25e+78);
INSERT INTO t1(a,b) VALUES (1.25e-94, 1.25e-94);
INSERT INTO t1(a,b) VALUES (1.25e+203, 1.25e+203);
INSERT INTO t1(a,b) VALUES (1.25e-175, 1.25e-175);
INSERT INTO t1(a,c) VALUES (1.225e+0, 1.225e+0);
INSERT INTO t1(a,c) VALUES (1.37e+0, 1.37e+0);
INSERT INTO t1(a,c) VALUES (-1.37e+0, -1.37e+0);
INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
SELECT * FROM t1;
DROP TABLE t1;
SET sql_mode = default;
--echo #
--echo # assertion in Field_str::store(double)
--echo #
CREATE TABLE t (a CHAR(10),b INT);
INSERT INTO t VALUES (),(),();
INSERT INTO t(a) SELECT rand() FROM t;
DROP TABLE t;
--echo #
--echo # String not cast to int correctly
--echo #
CREATE TABLE t2 (c1 BIGINT);
INSERT INTO t2 VALUES('15449237462.0000000000');
SELECT * FROM t2;
drop table t2;
--echo #
--echo #Simple INSERT crashes the server
--echo #
CREATE TABLE t1(f1 FLOAT);
INSERT INTO t1 VALUES (1.23);
CREATE TABLE t2(f1 CHAR(1));
INSERT INTO t2 SELECT f1 FROM t1;
DROP TABLE t1, t2;
--echo #
--echo # Bug#34898 "mysql_info() reports 0 warnings while
--echo # mysql_warning_count() reports 1"
--echo # Check that the number of warnings reported by
--echo # mysql_info() is correct.
--echo #
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (data varchar(4) not null);
--echo #
--echo # Demonstrate that the number of warnings matches
--echo # the information in mysql_info().
--echo #
--enable_info
insert ignore t1 (data) values ('letter'), (1/0);
update ignore t1 set data='envelope' where 1/0 or 1;
insert ignore t1 (data) values (default), (1/0), ('dead beef');
--disable_info
drop table t1;
--echo #
--echo # Bug#54106 assert in Protocol::end_statement,
--echo # INSERT IGNORE ... SELECT ... UNION SELECT ...
--echo #
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a INT);
--error ER_FIELD_SPECIFIED_TWICE
INSERT INTO t1 (a, a) VALUES (1, 1);
# Verify that ER_FIELD_SPECIFIED_TWICE is not ignorable
--error ER_FIELD_SPECIFIED_TWICE
INSERT IGNORE t1 (a, a) VALUES (1, 1);
--error ER_FIELD_SPECIFIED_TWICE
INSERT IGNORE t1 (a, a) SELECT 1,1;
# Used to cause an assert
--error ER_FIELD_SPECIFIED_TWICE
INSERT IGNORE t1 (a, a) SELECT 1,1 UNION SELECT 2,2;
DROP TABLE t1;
--echo #
--echo # ASSERTION `TRANSL->ITEM->FIXED' FAILED IN SELECT_LEX::DELETE_UNUSED_MERGED_COLUMN
--echo #
CREATE TABLE t1 ( pk INT, PRIMARY KEY (pk))engine=tianmu;
CREATE TABLE t2 LIKE t1;
INSERT INTO t1 VALUES (2);
INSERT INTO t2 VALUES (2);
CREATE VIEW v1 AS SELECT * FROM t2 AS a
WHERE a.pk IN ( SELECT pk FROM t1 AS b WHERE b.pk = a.pk );
CREATE VIEW v2 AS SELECT * FROM t1 AS a
WHERE a.pk IN ( SELECT pk FROM v1 AS b WHERE b.pk = a.pk );
PREPARE st1 FROM 'INSERT INTO v2 (pk) VALUES ( 1 )';
EXECUTE st1;
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t1, t2;
DROP VIEW v1, v2;
--echo #
--echo # ASSERTION !(WANT_PRIVILEGE & ~(GRANT->WANT_PRIVILEGE | GRANT->PRIVILEGE))'
--echo #
CREATE TABLE t1 (pk INT, PRIMARY KEY (pk));
INSERT INTO t1 VALUES (1);
CREATE ALGORITHM = TEMPTABLE VIEW v2 AS
SELECT * FROM t1 AS a NATURAL JOIN t1 b WHERE pk BETWEEN 1 AND 2;
CREATE ALGORITHM = UNDEFINED VIEW v1 AS
SELECT * FROM t1 AS a
WHERE a.pk IN ( SELECT pk FROM v2 AS b WHERE b.pk = a.pk );
PREPARE st1 FROM "INSERT INTO v1 (pk) VALUES (2)";
EXECUTE st1;
SELECT * FROM t1;
DROP VIEW v1, v2;
DROP TABLE t1;
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册