diff options
Diffstat (limited to 'mysql-test/t')
690 files changed, 44673 insertions, 33565 deletions
diff --git a/mysql-test/t/1st.test b/mysql-test/t/1st.test new file mode 100644 index 00000000000..6b93efee944 --- /dev/null +++ b/mysql-test/t/1st.test @@ -0,0 +1,5 @@ +# +# Check that we haven't any strange new tables or databases +# +show databases; +show tables in mysql; diff --git a/mysql-test/t/almost_full.test b/mysql-test/t/almost_full.test index 5c67ab3c088..24801f9cbc3 100644 --- a/mysql-test/t/almost_full.test +++ b/mysql-test/t/almost_full.test @@ -2,6 +2,8 @@ # Some special cases with empty tables # +call mtr.add_suppression("The table 't1' is full"); + --disable_warnings drop table if exists t1; --enable_warnings diff --git a/mysql-test/t/alter_table-big.test b/mysql-test/t/alter_table-big.test index acc4f73dfff..1dcc1f1c9bd 100644 --- a/mysql-test/t/alter_table-big.test +++ b/mysql-test/t/alter_table-big.test @@ -1,9 +1,13 @@ -# In order to be more or less robust test for Bug#25044 has to take -# significant time (e.g. about 9 seconds on my (Dmitri's) computer) -# so we probably want execute it only in --big-test mode. -# Also in 5.1 this test will require statement-based binlog. +# +# Tests for various concurrency-related aspects of ALTER TABLE implemetation +# +# This test takes rather long time so let us run it only in --big-test mode --source include/big_test.inc - +# We are using some debug-only features in this test +--source include/have_debug.inc +# Also we are using SBR to check that statements are executed +# in proper order. +--source include/have_binlog_format_mixed_or_statement.inc # # Test for Bug#25044 ALTER TABLE ... ENABLE KEYS acquires global @@ -22,27 +26,20 @@ create table t1 (n1 int, n2 int, n3 int, key (n3, n1, n2)); create table t2 (i int); -# Populating 't1' table with keys disabled, so ALTER TABLE .. ENABLE KEYS -# will run for some time +# Starting from 5.1 we have runtime settable @@debug variable, +# which can be used for introducing delays at certain points of +# statement execution, so we don't need many rows in 't1' to make +# this test repeatable. alter table t1 disable keys; ---disable_query_log -insert into t1 values (RAND()*1000,RAND()*1000,RAND()*1000); -let $1=19; -while ($1) -{ - eval insert into t1 select RAND()*1000,RAND()*1000,RAND()*1000 from t1; - dec $1; -} ---enable_query_log +insert into t1 values (RAND()*1000, RAND()*1000, RAND()*1000); # Later we use binlog to check the order in which statements are # executed so let us reset it first. reset master; +set session debug="+d,sleep_alter_enable_indexes"; --send alter table t1 enable keys; connection addconroot; -let $show_type= PROCESSLIST; -let $show_pattern= '%Repair by sorting%alter table t1 enable keys%'; ---source include/wait_show_pattern.inc +--sleep 2 # This statement should not be blocked by in-flight ALTER and therefore # should be executed and written to binlog before ALTER TABLE ... ENABLE KEYS # finishes. @@ -51,9 +48,10 @@ insert into t2 values (1); insert into t1 values (1, 1, 1); connection default; --reap +set session debug="-d,sleep_alter_enable_indexes"; # Check that statements were executed/binlogged in correct order. --replace_column 2 # 5 # -show binlog events in 'master-bin.000001' from 98; +show binlog events in 'master-bin.000001' from 106; # Clean up drop tables t1, t2; @@ -61,3 +59,61 @@ disconnect addconroot; --echo End of 5.0 tests + +# +# Additional coverage for the main ALTER TABLE case +# +# We should be sure that table being altered is properly +# locked during statement execution and in particular that +# no DDL or DML statement can sneak in and get access to +# the table when real operation has already taken place +# but this fact has not been noted in binary log yet. +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings +create table t1 (i int); +# We are going to check that statements are logged in correct order +reset master; +set session debug="+d,sleep_alter_before_main_binlog"; +--send alter table t1 change i c char(10) default 'Test1'; +connect (addconroot, localhost, root,,); +connection addconroot; +--sleep 2 +insert into t1 values (); +select * from t1; +connection default; +--reap +--send alter table t1 change c vc varchar(100) default 'Test2'; +connection addconroot; +--sleep 2 +rename table t1 to t2; +connection default; +--reap +drop table t2; +# And now tests for ALTER TABLE with RENAME clause. In this +# case target table name should be properly locked as well. +create table t1 (i int); +--send alter table t1 change i c char(10) default 'Test3', rename to t2; +connection addconroot; +--sleep 2 +insert into t2 values (); +select * from t2; +connection default; +--reap +--send alter table t2 change c vc varchar(100) default 'Test2', rename to t1; +connection addconroot; +--sleep 2 +rename table t1 to t3; +connection default; +--reap +disconnect addconroot; +drop table t3; +set session debug="-d,sleep_alter_before_main_binlog"; + +# Check that all statements were logged in correct order +--replace_column 2 # 5 # +show binlog events in 'master-bin.000001' from 106; + + +--echo End of 5.1 tests + diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 18481291bba..17549745203 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -101,7 +101,7 @@ create table mysqltest.t1 (name char(15)); insert into mysqltest.t1 (name) values ("mysqltest"); select * from t1; select * from mysqltest.t1; ---error 1050 +--error ER_TABLE_EXISTS_ERROR alter table t1 rename mysqltest.t1; select * from t1; select * from mysqltest.t1; @@ -231,10 +231,10 @@ DROP TABLE t1; # BUG#4717 - check for valid table names # create table t1 (a int); ---error 1103 -alter table t1 rename to `t1\\`; ---error 1103 -rename table t1 to `t1\\`; +--error ER_WRONG_TABLE_NAME +alter table t1 rename to ``; +--error ER_WRONG_TABLE_NAME +rename table t1 to ``; drop table t1; # @@ -325,14 +325,14 @@ drop table t1; CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE); ALTER TABLE t1 DROP PRIMARY KEY; SHOW CREATE TABLE t1; ---error 1091 +--error ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE t1 DROP PRIMARY KEY; DROP TABLE t1; # BUG#3899 create table t1 (a int, b int, key(a)); insert into t1 values (1,1), (2,2); ---error 1091 +--error ER_CANT_DROP_FIELD_OR_KEY alter table t1 drop key no_such_key; alter table t1 drop key a; drop table t1; @@ -343,7 +343,7 @@ drop table t1; # Some platforms (Mac OS X, Windows) will send the error message using small letters. CREATE TABLE T12207(a int) ENGINE=MYISAM; --replace_result t12207 T12207 ---error 1031 +--error ER_ILLEGAL_HA ALTER TABLE T12207 DISCARD TABLESPACE; DROP TABLE T12207; @@ -367,7 +367,7 @@ drop table t1; # shorter than packed field length. # create table t1 ( a timestamp ); ---error 1089 +--error ER_WRONG_SUB_KEY alter table t1 add unique ( a(1) ); drop table t1; @@ -477,7 +477,7 @@ create table t1 (c1 int); # Move table to other database. alter table t1 rename mysqltest.t1; # Assure that it has moved. ---error 1051 +--error ER_BAD_TABLE_ERROR drop table t1; # Move table back. alter table mysqltest.t1 rename t1; @@ -491,7 +491,7 @@ use mysqltest; # Drop the current db. This de-selects any db. drop database mysqltest; # Now test for correct message. ---error 1046 +--error ER_NO_DB_ERROR alter table test.t1 rename t1; # Check that explicit qualifying works even with no selected db. alter table test.t1 rename test.t1; @@ -605,37 +605,6 @@ desc t1; drop table t1; # -# Bug#6073 "ALTER table minor glich": ALTER TABLE complains that an index -# without # prefix is not allowed for TEXT columns, while index -# is defined with prefix. -# -create table t1 (t varchar(255) default null, key t (t(80))) -engine=myisam default charset=latin1; -alter table t1 change t t text; -drop table t1; - -# -# Bug #26794: Adding an index with a prefix on a SPATIAL type breaks ALTER -# TABLE -# -CREATE TABLE t1 (a varchar(500)); - -ALTER TABLE t1 ADD b GEOMETRY NOT NULL, ADD SPATIAL INDEX(b); -SHOW CREATE TABLE t1; -ALTER TABLE t1 ADD KEY(b(50)); -SHOW CREATE TABLE t1; - -ALTER TABLE t1 ADD c POINT; -SHOW CREATE TABLE t1; - ---error ER_WRONG_SUB_KEY -CREATE TABLE t2 (a INT, KEY (a(20))); - -ALTER TABLE t1 ADD d INT; ---error ER_WRONG_SUB_KEY -ALTER TABLE t1 ADD KEY (d(20)); - -DROP TABLE t1; # Bug#25262 Auto Increment lost when changing Engine type # @@ -686,17 +655,102 @@ drop table t1; set sql_mode= @orig_sql_mode; # -# BUG#29957 - alter_table.test fails +# Some additional tests for new, faster alter table. Note that most of the +# whole alter table code is being tested all around the test suite already. # -create table t1 (c char(10) default "Two"); -lock table t1 write; -insert into t1 values (); -alter table t1 modify c char(10) default "Three"; -unlock tables; + +create table t1 (v varchar(32)); +insert into t1 values ('def'),('abc'),('hij'),('3r4f'); select * from t1; -check table t1; +# Fast alter, no copy performed +alter table t1 change v v2 varchar(32); +select * from t1; +# Fast alter, no copy performed +alter table t1 change v2 v varchar(64); +select * from t1; +update t1 set v = 'lmn' where v = 'hij'; +select * from t1; +# Regular alter table +alter table t1 add i int auto_increment not null primary key first; +select * from t1; +update t1 set i=5 where i=3; +select * from t1; +alter table t1 change i i bigint; +select * from t1; +alter table t1 add unique key (i, v); +select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); drop table t1; +# +# Bug#6073 "ALTER table minor glich": ALTER TABLE complains that an index +# without # prefix is not allowed for TEXT columns, while index +# is defined with prefix. +# +create table t1 (t varchar(255) default null, key t (t(80))) +engine=myisam default charset=latin1; +alter table t1 change t t text; +drop table t1; + +# +# Bug #26794: Adding an index with a prefix on a SPATIAL type breaks ALTER +# TABLE +# +CREATE TABLE t1 (a varchar(500)); + +ALTER TABLE t1 ADD b GEOMETRY NOT NULL, ADD SPATIAL INDEX(b); +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD KEY(b(50)); +SHOW CREATE TABLE t1; + +ALTER TABLE t1 ADD c POINT; +SHOW CREATE TABLE t1; + +--error ER_WRONG_SUB_KEY +CREATE TABLE t2 (a INT, KEY (a(20))); + +ALTER TABLE t1 ADD d INT; +--error ER_WRONG_SUB_KEY +ALTER TABLE t1 ADD KEY (d(20)); + +# the 5.1 part of the test +--error ER_WRONG_SUB_KEY +ALTER TABLE t1 ADD e GEOMETRY NOT NULL, ADD SPATIAL KEY (e(30)); + +DROP TABLE t1; + +# +# Bug#18038 MySQL server corrupts binary columns data +# + +CREATE TABLE t1 (s CHAR(8) BINARY); +INSERT INTO t1 VALUES ('test'); +SELECT LENGTH(s) FROM t1; +ALTER TABLE t1 MODIFY s CHAR(10) BINARY; +SELECT LENGTH(s) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (s BINARY(8)); +INSERT INTO t1 VALUES ('test'); +SELECT LENGTH(s) FROM t1; +SELECT HEX(s) FROM t1; +ALTER TABLE t1 MODIFY s BINARY(10); +SELECT HEX(s) FROM t1; +SELECT LENGTH(s) FROM t1; +DROP TABLE t1; + +# +# Bug#19386: Multiple alter causes crashed table +# The trailing column would get corrupted data, or server could not even read +# it. +# + +CREATE TABLE t1 (v VARCHAR(3), b INT); +INSERT INTO t1 VALUES ('abc', 5); +SELECT * FROM t1; +ALTER TABLE t1 MODIFY COLUMN v VARCHAR(4); +SELECT * FROM t1; +DROP TABLE t1; + # # Bug#31291 ALTER TABLE CONVERT TO CHARACTER SET does not change some data types @@ -709,3 +763,287 @@ create table t1 (a mediumtext character set latin1); alter table t1 convert to character set utf8; show create table t1; drop table t1; + +--echo End of 5.0 tests + +# +# Extended test coverage for ALTER TABLE behaviour under LOCK TABLES +# It should be consistent across all platforms and for all engines +# (Before 5.1 this was not true as behavior was different between +# Unix/Windows and transactional/non-transactional tables). +# See also innodb_mysql.test +# +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings +create table t1 (i int); +create table t3 (j int); +insert into t1 values (); +insert into t3 values (); +# Table which is altered under LOCK TABLES it should stay in list of locked +# tables and be available after alter takes place unless ALTER contains RENAME +# clause. We should see the new definition of table, of course. +lock table t1 write, t3 read; +# Example of so-called 'fast' ALTER TABLE +alter table t1 modify i int default 1; +insert into t1 values (); +select * from t1; +# And now full-blown ALTER TABLE +alter table t1 change i c char(10) default "Two"; +insert into t1 values (); +select * from t1; +# If table is renamed then it should be removed from the list +# of locked tables. 'Fast' ALTER TABLE with RENAME clause: +alter table t1 modify c char(10) default "Three", rename to t2; +--error ER_TABLE_NOT_LOCKED +select * from t1; +--error ER_TABLE_NOT_LOCKED +select * from t2; +select * from t3; +unlock tables; +insert into t2 values (); +select * from t2; +lock table t2 write, t3 read; +# Full ALTER TABLE with RENAME +alter table t2 change c vc varchar(100) default "Four", rename to t1; +--error ER_TABLE_NOT_LOCKED +select * from t1; +--error ER_TABLE_NOT_LOCKED +select * from t2; +select * from t3; +unlock tables; +insert into t1 values (); +select * from t1; +drop tables t1, t3; + + +# +# Bug#18775 - Temporary table from alter table visible to other threads +# +# Check if special characters work and duplicates are detected. +--disable_warnings +DROP TABLE IF EXISTS `t+1`, `t+2`; +--enable_warnings +CREATE TABLE `t+1` (c1 INT); +ALTER TABLE `t+1` RENAME `t+2`; +CREATE TABLE `t+1` (c1 INT); +--error ER_TABLE_EXISTS_ERROR +ALTER TABLE `t+1` RENAME `t+2`; +DROP TABLE `t+1`, `t+2`; +# +# Same for temporary tables though these names do not become file names. +CREATE TEMPORARY TABLE `tt+1` (c1 INT); +ALTER TABLE `tt+1` RENAME `tt+2`; +CREATE TEMPORARY TABLE `tt+1` (c1 INT); +--error ER_TABLE_EXISTS_ERROR +ALTER TABLE `tt+1` RENAME `tt+2`; +SHOW CREATE TABLE `tt+1`; +SHOW CREATE TABLE `tt+2`; +DROP TABLE `tt+1`, `tt+2`; +# +# Check if special characters as in tmp_file_prefix work. +CREATE TABLE `#sql1` (c1 INT); +CREATE TABLE `@0023sql2` (c1 INT); +SHOW TABLES; +RENAME TABLE `#sql1` TO `@0023sql1`; +RENAME TABLE `@0023sql2` TO `#sql2`; +SHOW TABLES; +ALTER TABLE `@0023sql1` RENAME `#sql-1`; +ALTER TABLE `#sql2` RENAME `@0023sql-2`; +SHOW TABLES; +INSERT INTO `#sql-1` VALUES (1); +INSERT INTO `@0023sql-2` VALUES (2); +DROP TABLE `#sql-1`, `@0023sql-2`; +# +# Same for temporary tables though these names do not become file names. +CREATE TEMPORARY TABLE `#sql1` (c1 INT); +CREATE TEMPORARY TABLE `@0023sql2` (c1 INT); +SHOW TABLES; +ALTER TABLE `#sql1` RENAME `@0023sql1`; +ALTER TABLE `@0023sql2` RENAME `#sql2`; +SHOW TABLES; +INSERT INTO `#sql2` VALUES (1); +INSERT INTO `@0023sql1` VALUES (2); +SHOW CREATE TABLE `#sql2`; +SHOW CREATE TABLE `@0023sql1`; +DROP TABLE `#sql2`, `@0023sql1`; + +# +# Bug #22369: Alter table rename combined with other alterations causes lost tables +# +# This problem happens if the data change is compatible. +# Changing to the same type is compatible for example. +# +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings +CREATE TABLE t1 ( + int_field INTEGER UNSIGNED NOT NULL, + char_field CHAR(10), + INDEX(`int_field`) +); + +DESCRIBE t1; + +SHOW INDEXES FROM t1; + +INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet"); +--echo "Non-copy data change - new frm, but old data and index files" +ALTER TABLE t1 + CHANGE int_field unsigned_int_field INTEGER UNSIGNED NOT NULL, + RENAME t2; + +--error ER_NO_SUCH_TABLE +SELECT * FROM t1 ORDER BY int_field; +SELECT * FROM t2 ORDER BY unsigned_int_field; +DESCRIBE t2; +DESCRIBE t2; +ALTER TABLE t2 MODIFY unsigned_int_field BIGINT UNSIGNED NOT NULL; +DESCRIBE t2; + +DROP TABLE t2; + +# +# Bug#28427: Columns were renamed instead of moving by ALTER TABLE. +# +CREATE TABLE t1 (f1 INT, f2 INT, f3 INT); +INSERT INTO t1 VALUES (1, 2, NULL); +SELECT * FROM t1; +ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f1; +SELECT * FROM t1; +ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f2; +SELECT * FROM t1; +DROP TABLE t1; + +# +# BUG#29957 - alter_table.test fails +# +create table t1 (c char(10) default "Two"); +lock table t1 write; +insert into t1 values (); +alter table t1 modify c char(10) default "Three"; +unlock tables; +select * from t1; +check table t1; +drop table t1; + +# +# Bug#33873: Fast ALTER TABLE doesn't work with multibyte character sets +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 (id int, c int) character set latin1; +INSERT INTO t1 VALUES (1,1); +--enable_info +ALTER TABLE t1 CHANGE c d int; +ALTER TABLE t1 CHANGE d c int; +ALTER TABLE t1 MODIFY c VARCHAR(10); +ALTER TABLE t1 CHANGE c d varchar(10); +ALTER TABLE t1 CHANGE d c varchar(10); +--disable_info +DROP TABLE t1; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 (id int, c int) character set utf8; +INSERT INTO t1 VALUES (1,1); +--enable_info +ALTER TABLE t1 CHANGE c d int; +ALTER TABLE t1 CHANGE d c int; +ALTER TABLE t1 MODIFY c VARCHAR(10); +ALTER TABLE t1 CHANGE c d varchar(10); +ALTER TABLE t1 CHANGE d c varchar(10); +--disable_info +DROP TABLE t1; + +# +# Bug#39372 "Smart" ALTER TABLE not so smart after all. +# +create table t1(f1 int not null, f2 int not null, key (f1), key (f2)); +let $count= 50; +--disable_query_log +while ($count) +{ + EVAL insert into t1 values (1,1),(1,1),(1,1),(1,1),(1,1); + EVAL insert into t1 values (2,2),(2,2),(2,2),(2,2),(2,2); + dec $count ; +} +--enable_query_log + +select index_length into @unpaked_keys_size from +information_schema.tables where table_name='t1'; +alter table t1 pack_keys=1; +select index_length into @paked_keys_size from +information_schema.tables where table_name='t1'; +select (@unpaked_keys_size > @paked_keys_size); + +select max_data_length into @orig_max_data_length from +information_schema.tables where table_name='t1'; +alter table t1 max_rows=100; +select max_data_length into @changed_max_data_length from +information_schema.tables where table_name='t1'; +select (@orig_max_data_length > @changed_max_data_length); + +drop table t1; + +# +# Bug #23113: Different behavior on altering ENUM fields between 5.0 and 5.1 +# +CREATE TABLE t1(a INT AUTO_INCREMENT PRIMARY KEY, + b ENUM('a', 'b', 'c') NOT NULL); +INSERT INTO t1 (b) VALUES ('a'), ('c'), ('b'), ('b'), ('a'); +ALTER TABLE t1 MODIFY b ENUM('a', 'z', 'b', 'c') NOT NULL; +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # Bug#45567: Fast ALTER TABLE broken for enum and set +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (a ENUM('a1','a2')); +INSERT INTO t1 VALUES ('a1'),('a2'); +--enable_info +--echo # No copy: No modification +ALTER TABLE t1 MODIFY COLUMN a ENUM('a1','a2'); +--echo # No copy: Add new enumeration to the end +ALTER TABLE t1 MODIFY COLUMN a ENUM('a1','a2','a3'); +--echo # Copy: Modify and add new to the end +ALTER TABLE t1 MODIFY COLUMN a ENUM('a1','a2','xx','a5'); +--echo # Copy: Remove from the end +ALTER TABLE t1 MODIFY COLUMN a ENUM('a1','a2','xx'); +--echo # Copy: Add new enumeration +ALTER TABLE t1 MODIFY COLUMN a ENUM('a1','a2','a0','xx'); +--echo # No copy: Add new enumerations to the end +ALTER TABLE t1 MODIFY COLUMN a ENUM('a1','a2','a0','xx','a5','a6'); +--disable_info +DROP TABLE t1; + +CREATE TABLE t1 (a SET('a1','a2')); +INSERT INTO t1 VALUES ('a1'),('a2'); +--enable_info +--echo # No copy: No modification +ALTER TABLE t1 MODIFY COLUMN a SET('a1','a2'); +--echo # No copy: Add new to the end +ALTER TABLE t1 MODIFY COLUMN a SET('a1','a2','a3'); +--echo # Copy: Modify and add new to the end +ALTER TABLE t1 MODIFY COLUMN a SET('a1','a2','xx','a5'); +--echo # Copy: Remove from the end +ALTER TABLE t1 MODIFY COLUMN a SET('a1','a2','xx'); +--echo # Copy: Add new member +ALTER TABLE t1 MODIFY COLUMN a SET('a1','a2','a0','xx'); +--echo # No copy: Add new to the end +ALTER TABLE t1 MODIFY COLUMN a SET('a1','a2','a0','xx','a5','a6'); +--echo # Copy: Numerical incrase (pack lenght) +ALTER TABLE t1 MODIFY COLUMN a SET('a1','a2','a0','xx','a5','a6','a7','a8','a9','a10'); +--disable_info +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 14a124a96bc..aad3d19455d 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1,13 +1,16 @@ # # Simple test for archive example -# Taken from the select test +# Taken FROM the select test # -- source include/have_archive.inc +-- source include/have_binlog_format_mixed_or_statement.inc --disable_warnings -drop table if exists t1,t2; +DROP TABLE if exists t1,t2,t3,t4,t5,t6; --enable_warnings +SET storage_engine=ARCHIVE; + CREATE TABLE t1 ( Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL @@ -15,9 +18,9 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES (9410,9412); -select period from t1; -select * from t1; -select t1.* from t1; +select period FROM t1; +select * FROM t1; +select t1.* FROM t1; # # Create test table @@ -1243,64 +1246,64 @@ INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly','' # Search with a key # -select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; -select fld3 from t2 where fld3 like "%cultivation" ; +select t2.fld3 FROM t2 where companynr = 58 and fld3 like "%imaginable%"; +select fld3 FROM t2 where fld3 like "%cultivation" ; # # Search with a key using sorting and limit the same time # -select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; -select fld3,companynr from t2 where companynr = 58 order by fld3; +select t2.fld3,companynr FROM t2 where companynr = 57+1 order by fld3; +select fld3,companynr FROM t2 where companynr = 58 order by fld3; -select fld3 from t2 order by fld3 desc limit 10; -select fld3 from t2 order by fld3 desc limit 5; -select fld3 from t2 order by fld3 desc limit 5,5; +select fld3 FROM t2 order by fld3 desc limit 10; +select fld3 FROM t2 order by fld3 desc limit 5; +select fld3 FROM t2 order by fld3 desc limit 5,5; # # Search with a key having a constant with each unique key. # The table is read directly with read-next on fld3 # -select t2.fld3 from t2 where fld3 = 'honeysuckle'; -select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; -select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; -select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; -select t2.fld3 from t2 where fld3 LIKE 'h%le'; +select t2.fld3 FROM t2 where fld3 = 'honeysuckle'; +select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckl_'; +select t2.fld3 FROM t2 where fld3 LIKE 'hon_ysuckl_'; +select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckle%'; +select t2.fld3 FROM t2 where fld3 LIKE 'h%le'; -select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; -select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckle_'; +select t2.fld3 FROM t2 where fld3 LIKE 'don_t_find_me_please%'; # # Test sorting with a used key (there is no need for sorting) # -select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; -select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +select t2.fld3 FROM t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +select fld1,fld3 FROM t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; # # Search with a key with LIKE constant # If the like starts with a certain letter key will be used. # -select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; -select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; -select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); -select fld1,fld3 from t2 where fld1 like "25050%"; -select fld1,fld3 from t2 where fld1 like "25050_"; +select fld1,fld3 FROM t2 where companynr = 37 and fld3 like 'f%'; +select fld3 FROM t2 where fld3 like "L%" and fld3 = "ok"; +select fld3 FROM t2 where (fld3 like "C%" and fld3 = "Chantilly"); +select fld1,fld3 FROM t2 where fld1 like "25050%"; +select fld1,fld3 FROM t2 where fld1 like "25050_"; # # Test rename of table # -create table t3 engine=archive select * from t2; -select * from t3 where fld3='bonfire'; -select count(*) from t3; +CREATE TABLE t3 engine=archive select * FROM t2; +select * FROM t3 where fld3='bonfire'; +select count(*) FROM t3; # Clean up path in error message --replace_result $MYSQL_TEST_DIR . /var/master-data/ / rename table t3 to t4; -select * from t4 where fld3='bonfire'; -select count(*) from t4; +select * FROM t4 where fld3='bonfire'; +select count(*) FROM t4; # End of 4.1 tests @@ -1345,6 +1348,7 @@ SELECT * FROM t2; CHECK TABLE t2; SELECT * FROM t2; + # Test INSERT DELAYED and wait until the table has one more record SELECT COUNT(auto) FROM t2; INSERT DELAYED INTO t2 VALUES (99999,011403,37,'the','delayed','insert',''); @@ -1362,16 +1366,188 @@ while (`SELECT COUNT(auto)!=1215 FROM t2`) } SELECT COUNT(auto) FROM t2; -# Adding test for alter table +# Adding test for ALTER TABLE ALTER TABLE t2 DROP COLUMN fld6; SHOW CREATE TABLE t2; -SELECT * from t2 WHERE auto != 100000; +SELECT * FROM t2 WHERE auto != 100000; + + +# Adding tests for autoincrement +# First the simple stuff + +CREATE TABLE `t5` ( +`a` int(11) NOT NULL auto_increment, +b char(12), +PRIMARY KEY (`a`) +) DEFAULT CHARSET=latin1; + +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (32, "foo"); +--error 1022 +INSERT INTO t5 VALUES (23, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +--error 1022 +INSERT INTO t5 VALUES (3, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +SELECT * FROM t5; + +SELECT * FROM t5 WHERE a=3; + +DROP TABLE t5; + +CREATE TABLE `t5` ( +`a` int(11) NOT NULL auto_increment, +b char(12), +KEY (`a`) +) DEFAULT CHARSET=latin1 AUTO_INCREMENT=5; + +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (32, "foo"); +INSERT INTO t5 VALUES (23, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (3, "foo"); +INSERT INTO t5 VALUES (NULL, "foo"); +SELECT * FROM t5; +OPTIMIZE TABLE t5; +SELECT * FROM t5; + +SELECT * FROM t5 WHERE a=32; +SELECT * FROM t5 WHERE a=3; + +DROP TABLE t5; + +CREATE TABLE `t5` ( +`a` int(11) NOT NULL auto_increment, +b blob(12), +KEY (`a`) +) DEFAULT CHARSET=latin1; + +INSERT INTO t5 VALUES (NULL, "foo"); +INSERT INTO t5 VALUES (NULL, "We the people"); +INSERT INTO t5 VALUES (NULL, "in order to form a more pefect union"); +INSERT INTO t5 VALUES (NULL, "establish justice"); +INSERT INTO t5 VALUES (NULL, "foo grok "); +INSERT INTO t5 VALUES (32, "ensure domestic tranquility"); +INSERT INTO t5 VALUES (23, "provide for the common defense"); +INSERT INTO t5 VALUES (NULL, "fo fooo"); +INSERT INTO t5 VALUES (NULL, "foo just naother bit of text"); +INSERT INTO t5 VALUES (3, "foo this is mine to think about"); +INSERT INTO t5 VALUES (NULL, "promote the general welfare"); +SELECT * FROM t5; +SELECT b FROM t5; +SELECT b FROM t5 WHERE a =3; +SELECT b FROM t5 WHERE a IN (32, 23, 5); + + +#More blob tests + +DROP TABLE t5; + +CREATE TABLE `t5` ( +`a` int(11) NOT NULL auto_increment, +b blob(12), +c blob(12), +KEY (`a`) +) DEFAULT CHARSET=latin1; + +INSERT INTO t5 VALUES (NULL, "foo", "grok this!"); +INSERT INTO t5 VALUES (NULL, "We the people", NULL); +INSERT INTO t5 VALUES (NULL, "in order to form a more peefect union", "secure the blessing of liberty"); +INSERT INTO t5 VALUES (NULL, "establish justice", "to ourselves and"); +INSERT INTO t5 VALUES (32, "ensure domestic tranquility", NULL); +INSERT INTO t5 VALUES (23, "provide for the common defense", "posterity"); +INSERT INTO t5 VALUES (NULL, "promote the general welfare", "do ordain"); +SELECT * FROM t5; +SELECT b FROM t5; +SELECT b FROM t5 WHERE a =3; +SELECT b FROM t5 WHERE a IN (32, 23, 5); +SELECT c FROM t5; +SELECT c FROM t5 WHERE a =3; +SELECT c FROM t5 WHERE a IN (32, 23, 5); + +# Adding this in case someone tries to add fast ALTER TABLE and doesn't tes +# it. +# Some additional tests for new, faster ALTER TABLE. Note that most of the +# whole ALTER TABLE code is being tested all around the test suite already. +# + +DROP TABLE t1; +CREATE TABLE t1 (v varchar(32)) ; +insert into t1 values ('def'),('abc'),('hij'),('3r4f'); +select * from t1; +# Fast alter, no copy performed +ALTER TABLE t1 change v v2 varchar(32); +select * from t1; +# Fast alter, no copy performed +ALTER TABLE t1 change v2 v varchar(64); +select * from t1; +# Regular ALTER TABLE +ALTER TABLE t1 add i int auto_increment not null primary key first; +select * from t1; + +# Testing cleared row key +DROP TABLE t5; + +CREATE TABLE `t5` ( +`a` int(11) NOT NULL auto_increment, +b varchar(250), +c varchar(800), +KEY (`a`) +) DEFAULT CHARSET=latin1; + +INSERT INTO t5 VALUES (NULL, "foo", "grok this!"); +INSERT INTO t5 VALUES (NULL, "We the people", NULL); +INSERT INTO t5 VALUES (NULL, "in order to form a more peefect union", "secure the blessing of liberty"); +INSERT INTO t5 VALUES (NULL, "establish justice", "to ourselves and"); +INSERT INTO t5 VALUES (32, "ensure domestic tranquility", NULL); +INSERT INTO t5 VALUES (23, "provide for the common defense", "posterity"); +INSERT INTO t5 VALUES (NULL, "promote the general welfare", "do ordain"); +INSERT INTO t5 VALUES (NULL, "abcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabc", "do ordain"); + +SELECT * FROM t5; + +CREATE TABLE `t6` ( +`a` int(11) NOT NULL auto_increment, +b blob(12), +c int, +KEY (`a`) +) DEFAULT CHARSET=latin1; +SELECT * FROM t6; +INSERT INTO t6 VALUES (NULL, "foo", NULL); +INSERT INTO t6 VALUES (NULL, "We the people", 5); +INSERT INTO t6 VALUES (NULL, "in order to form a more pefect union", 9); +INSERT INTO t6 VALUES (NULL, "establish justice", NULL); +INSERT INTO t6 VALUES (NULL, NULL, NULL); +INSERT INTO t6 VALUES (32, "ensure domestic tranquility", NULL); +INSERT INTO t6 VALUES (23, "provide for the common defense", 30); +INSERT INTO t6 VALUES (NULL, "fo fooo", 70); +INSERT INTO t6 VALUES (NULL, NULL, 98); +INSERT INTO t6 VALUES (NULL, "promote the general welfare", 50); +SELECT * FROM t6; +SELECT * FROM t6 ORDER BY a; +SELECT * FROM t6 ORDER BY a DESC; + +SHOW CREATE TABLE t6; + + # # Cleanup, test is over # -drop table t1, t2, t4; +--disable_warnings +DROP TABLE t1, t2, t4, t5, t6; +--enable_warnings # # BUG#26138 - REPAIR TABLE with option USE_FRM erases all records in ARCHIVE @@ -1391,3 +1567,59 @@ insert into t1 set a=''; insert into t1 set a='a'; check table t1 extended; drop table t1; + +# +# BUG#31036 - Using order by with archive table crashes server +# + +CREATE TABLE t1(a VARCHAR(510)) ENGINE = ARCHIVE; + +let $bug31036=41; +--disable_query_log +while($bug31036) +{ + INSERT INTO t1(a) VALUES (REPEAT('a', 510)); + dec $bug31036; +} +--enable_query_log +INSERT INTO t1(a) VALUES (''); + +--disable_result_log +SELECT * FROM t1 ORDER BY a; +--enable_result_log + +DROP TABLE t1; + +# +# BUG#31833 - ORDER BY leads to wrong result when ARCHIVE, BLOB and table +# cache is full +# +CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b BLOB, KEY(a)) ENGINE=archive; +INSERT INTO t1 VALUES (NULL, NULL),(NULL, NULL); +FLUSH TABLE t1; +SELECT * FROM t1 ORDER BY a; +DROP TABLE t1; + +# +# BUG#29203 - archive tables have weird values in show table status +# +CREATE TABLE t1(a INT, b BLOB) ENGINE=archive; +SELECT DATA_LENGTH, AVG_ROW_LENGTH FROM + INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test'; +INSERT INTO t1 VALUES(1, 'sampleblob1'),(2, 'sampleblob2'); +SELECT DATA_LENGTH, AVG_ROW_LENGTH FROM + INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test'; +DROP TABLE t1; + +# +# BUG#46961 - archive engine loses rows during self joining select! +# +SET @save_join_buffer_size= @@join_buffer_size; +SET @@join_buffer_size= 8228; +CREATE TABLE t1(a CHAR(255)) ENGINE=archive; +INSERT INTO t1 VALUES('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), + ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), + ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); +SELECT COUNT(t1.a) FROM t1, t1 a, t1 b, t1 c, t1 d, t1 e; +DROP TABLE t1; +SET @@join_buffer_size= @save_join_buffer_size; diff --git a/mysql-test/t/ndb_bitfield.test b/mysql-test/t/archive_bitfield.test index 59d6e56577e..2e90ce39708 100644 --- a/mysql-test/t/ndb_bitfield.test +++ b/mysql-test/t/archive_bitfield.test @@ -1,4 +1,4 @@ --- source include/have_ndb.inc +-- source include/have_archive.inc -- source include/not_embedded.inc --disable_warnings @@ -6,36 +6,34 @@ drop table if exists t1; --enable_warnings create table t1 ( - pk1 int not null primary key, + pk1 int not null auto_increment primary key, b bit(64) -) engine=ndbcluster; +) engine=archive; show create table t1; insert into t1 values -(0,b'1111111111111111111111111111111111111111111111111111111111111111'), -(1,b'1000000000000000000000000000000000000000000000000000000000000000'), -(2,b'0000000000000000000000000000000000000000000000000000000000000001'), -(3,b'1010101010101010101010101010101010101010101010101010101010101010'), -(4,b'0101010101010101010101010101010101010101010101010101010101010101'); +(NULL,b'1111111111111111111111111111111111111111111111111111111111111111'), +(NULL,b'1000000000000000000000000000000000000000000000000000000000000000'), +(NULL,b'0000000000000000000000000000000000000000000000000000000000000001'), +(NULL,b'1010101010101010101010101010101010101010101010101010101010101010'), +(NULL,b'0101010101010101010101010101010101010101010101010101010101010101'); select hex(b) from t1 order by pk1; drop table t1; create table t1 ( - pk1 int not null primary key, + pk1 int not null auto_increment primary key, b bit(9) -) engine=ndbcluster; +) engine=archive; insert into t1 values -(0,b'000000000'), -(1,b'000000001'), -(2,b'000000010'), -(3,b'000000011'), -(4,b'000000100'); -select hex(b) from t1 order by pk1; -update t1 set b = b + b'101010101'; +(NULL,b'000000000'), +(NULL,b'000000001'), +(NULL,b'000000010'), +(NULL,b'000000011'), +(NULL,b'000000100'); select hex(b) from t1 order by pk1; drop table t1; -create table t1 (a bit(7), b bit(9)) engine = ndbcluster; +create table t1 (a bit(7), b bit(9)) engine = archive; insert into t1 values (94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177), (75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380), @@ -48,7 +46,7 @@ select b+0 from t1 order by b; drop table t1; create table t1 ( - dummyKey INTEGER NOT NULL, + dummyKey INTEGER NOT NULL AUTO_INCREMENT, a001 TINYINT, a010 TINYINT, a012 TINYINT, @@ -86,37 +84,21 @@ create table t1 ( n TINYINT, o TINYINT, a034 TINYINT, -PRIMARY KEY USING HASH (dummyKey) ) engine=ndb; +PRIMARY KEY USING HASH (dummyKey) ) engine=archive; INSERT INTO `t1` VALUES -(1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000001',b'111111',b'111110',4,5,5,5,5,5,5,5,5,5,3,2,1), -(2,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000010',b'000000',b'111101',4,5,5,5,5,5,5,5,5,5,3,2,1), -(3,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000100',b'001111',b'111011',4,5,5,5,5,5,5,5,5,5,3,2,1), -(4,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'001000',b'110000',b'110111',4,5,5,5,5,5,5,5,5,5,3,2,1), -(5,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'010000',b'100001',b'101111',4,5,5,5,5,5,5,5,5,5,3,2,1), -(6,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'100000',b'010010',b'011111',4,5,5,5,5,5,5,5,5,5,3,2,1), -(7,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000000',b'001100',b'111111',4,5,5,5,5,5,5,5,5,5,3,2,1), -(8,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'000000',b'000000',4,5,5,5,5,5,5,5,5,5,3,2,1); +(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000001',b'111111',b'111110',4,5,5,5,5,5,5,5,5,5,3,2,1), +(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000010',b'000000',b'111101',4,5,5,5,5,5,5,5,5,5,3,2,1), +(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000100',b'001111',b'111011',4,5,5,5,5,5,5,5,5,5,3,2,1), +(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'001000',b'110000',b'110111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'010000',b'100001',b'101111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'100000',b'010010',b'011111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000000',b'001100',b'111111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'000000',b'000000',4,5,5,5,5,5,5,5,5,5,3,2,1); +# Determine the number of open sessions +--source include/count_sessions.inc --exec $MYSQL_DUMP --hex-blob --compact --order-by-primary --skip-extended-insert --no-create-info test t1 drop table t1; +# Wait till the number of open sessions is <= the number before the run with $MYSQL_DUMP +# = The session caused by mysqldump has finished its disconnect +--source include/wait_until_count_sessions.inc ---error 1005 -create table t1 ( - pk1 bit(9) not null primary key, - b int -) engine=ndbcluster; - ---error 1005 -create table t1 ( - pk1 int not null primary key, - b bit(9), - key(b) -) engine=ndbcluster; - -# bug#16125 -create table t1 ( - pk1 int primary key, - b bit(32) not null -) engine=ndbcluster; - -insert into t1 values (1,1); -drop table t1; diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index 00849a3b131..076e32eb22c 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -101,10 +101,10 @@ insert into t1 set i = 254; insert into t1 set i = null; select last_insert_id(); explain extended select last_insert_id(); ---error 1062 +--error ER_DUP_ENTRY insert into t1 set i = 254; select last_insert_id(); ---error 1062 +--error ER_DUP_ENTRY insert into t1 set i = null; select last_insert_id(); drop table t1; @@ -122,7 +122,7 @@ insert into t1 values (NULL, 10); select last_insert_id(); insert into t1 values (NULL, 15); select last_insert_id(); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values (NULL, 10); select last_insert_id(); @@ -277,7 +277,7 @@ create table t1 (rowid int not null auto_increment, val int not null,primary key (rowid), unique(val)); replace into t1 (val) values ('1'),('2'); replace into t1 (val) values ('1'),('2'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 (val) values ('1'),('2'); select * from t1; drop table t1; @@ -292,6 +292,39 @@ update t1 set a=2 where a=1; insert into t1 (val) values (1); select * from t1; drop table t1; + +# +# Test key duplications with auto-increment in ALTER TABLE +# bug #14573 +# +CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10)); +INSERT INTO t1 VALUES(0, 0); +INSERT INTO t1 VALUES(1, 1); +--error ER_DUP_ENTRY +ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment; +DROP TABLE t1; + +# Test of REPLACE when it does INSERT+DELETE and not UPDATE: +# see if it sets LAST_INSERT_ID() ok +create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c)); +insert into t1 values(null,1,1,now()); +insert into t1 values(null,0,0,null); +# this will delete two rows +replace into t1 values(null,1,0,null); +select last_insert_id(); +drop table t1; + +# Test of REPLACE when it does a INSERT+DELETE for all the conflicting rows +# (i.e.) when there are three rows conflicting in unique key columns with +# a row that is being inserted, all the three rows will be deleted and then +# the new rows will be inserted. +create table t1 (a int primary key auto_increment, b int, c int, e int, d timestamp default current_timestamp, unique(b),unique(c),unique(e)); +insert into t1 values(null,1,1,1,now()); +insert into t1 values(null,0,0,0,null); +replace into t1 values(null,1,0,2,null); +select last_insert_id(); +drop table t1; + --echo # --echo # Bug#46616: Assertion `!table->auto_increment_field_not_null' on view --echo # manipulations @@ -308,3 +341,4 @@ UPDATE t2 SET a = 2; SELECT a FROM t2; DROP TABLE t1, t2; + diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test index 34982b391ac..c761f48cbcb 100644 --- a/mysql-test/t/backup.test +++ b/mysql-test/t/backup.test @@ -1,6 +1,6 @@ # The server need to be started in $MYSQLTEST_VARDIR since it -# uses ../std_data_ln/ +# uses ../../std_data/ --source include/uses_vardir.inc # Save the initial number of concurrent sessions @@ -19,41 +19,41 @@ drop table if exists t1, t2, t3, t4; --enable_warnings create table t4(n int); --replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -backup table t4 to '../bogus'; -backup table t4 to '../tmp'; +backup table t4 to '../../bogus'; +backup table t4 to '../../tmp'; --replace_result ": 7" ": X" ": 17" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -backup table t4 to '../tmp'; +backup table t4 to '../../tmp'; drop table t4; -restore table t4 from '../tmp'; +restore table t4 from '../../tmp'; select count(*) from t4; create table t1(n int); insert into t1 values (23),(45),(67); -backup table t1 to '../tmp'; +backup table t1 to '../../tmp'; drop table t1; --replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -restore table t1 from '../bogus'; -restore table t1 from '../tmp'; +restore table t1 from '../../bogus'; +restore table t1 from '../../tmp'; select n from t1; create table t2(m int not null primary key); create table t3(k int not null primary key); insert into t2 values (123),(145),(167); insert into t3 values (223),(245),(267); -backup table t2,t3 to '../tmp'; +backup table t2,t3 to '../../tmp'; drop table t1,t2,t3; -restore table t1,t2,t3 from '../tmp'; +restore table t1,t2,t3 from '../../tmp'; select n from t1; select m from t2; select k from t3; drop table t1,t2,t3,t4; -restore table t1 from '../tmp'; +restore table t1 from '../../tmp'; connection con2; rename table t1 to t5; --send lock tables t5 write; connection con1; --send -backup table t5 to '../tmp'; +backup table t5 to '../../tmp'; connection con2; reap; unlock tables; @@ -76,6 +76,28 @@ remove_file $MYSQLTEST_VARDIR/tmp/t5.frm; # End of 4.1 tests +# End of 5.0 tests + +# +# Bug#18775 - Temporary table from alter table visible to other threads +# +# Backup did not encode table names. +--disable_warnings +DROP TABLE IF EXISTS `t+1`; +--enable_warnings +CREATE TABLE `t+1` (c1 INT); +INSERT INTO `t+1` VALUES (1), (2), (3); +BACKUP TABLE `t+1` TO '../../tmp'; +DROP TABLE `t+1`; +# +# Same for restore. +RESTORE TABLE `t+1` FROM '../../tmp'; +SELECT * FROM `t+1`; +DROP TABLE `t+1`; +# +remove_file $MYSQLTEST_VARDIR/tmp/t@002b1.frm; +remove_file $MYSQLTEST_VARDIR/tmp/t@002b1.MYD; + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/bdb-alter-table-1.test b/mysql-test/t/bdb-alter-table-1.test deleted file mode 100644 index 9cb469a8df6..00000000000 --- a/mysql-test/t/bdb-alter-table-1.test +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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 diff --git a/mysql-test/t/bdb-alter-table-2-master.opt b/mysql-test/t/bdb-alter-table-2-master.opt deleted file mode 100644 index c2dca33445b..00000000000 --- a/mysql-test/t/bdb-alter-table-2-master.opt +++ /dev/null @@ -1,2 +0,0 @@ ---force-restart - diff --git a/mysql-test/t/bdb-alter-table-2.test b/mysql-test/t/bdb-alter-table-2.test deleted file mode 100644 index 15b8938a11d..00000000000 --- a/mysql-test/t/bdb-alter-table-2.test +++ /dev/null @@ -1,10 +0,0 @@ -# -# 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 diff --git a/mysql-test/t/bdb-crash.test b/mysql-test/t/bdb-crash.test deleted file mode 100644 index 75f4d04d5df..00000000000 --- a/mysql-test/t/bdb-crash.test +++ /dev/null @@ -1,51 +0,0 @@ --- 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 diff --git a/mysql-test/t/bdb-deadlock.test b/mysql-test/t/bdb-deadlock.test deleted file mode 100644 index b48648e0fd0..00000000000 --- a/mysql-test/t/bdb-deadlock.test +++ /dev/null @@ -1,51 +0,0 @@ --- 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 diff --git a/mysql-test/t/bdb-deadlock.tminus b/mysql-test/t/bdb-deadlock.tminus deleted file mode 100644 index 3918a8ffe9d..00000000000 --- a/mysql-test/t/bdb-deadlock.tminus +++ /dev/null @@ -1,59 +0,0 @@ -# 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 diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test deleted file mode 100644 index d017d91bfb1..00000000000 --- a/mysql-test/t/bdb.test +++ /dev/null @@ -1,1022 +0,0 @@ --- 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; -# 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 diff --git a/mysql-test/t/bdb_cache.test b/mysql-test/t/bdb_cache.test deleted file mode 100644 index 85328920d71..00000000000 --- a/mysql-test/t/bdb_cache.test +++ /dev/null @@ -1,53 +0,0 @@ --- 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 diff --git a/mysql-test/t/bdb_gis.test b/mysql-test/t/bdb_gis.test deleted file mode 100644 index cb6d0683874..00000000000 --- a/mysql-test/t/bdb_gis.test +++ /dev/null @@ -1,4 +0,0 @@ --- source include/have_bdb.inc -SET storage_engine=bdb; ---source include/gis_generic.inc ---source include/gis_keys.inc diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test deleted file mode 100644 index 24e64ebbfb2..00000000000 --- a/mysql-test/t/bdb_notembedded.test +++ /dev/null @@ -1,38 +0,0 @@ --- source include/not_embedded.inc --- source include/have_bdb.inc - -# -# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode -# -set autocommit=1; - -let $VERSION=`select version()`; - -reset master; -create table bug16206 (a int); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -reset master; -create table bug16206 (a int) engine= bdb; -insert into bug16206 values(0); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -insert into bug16206 values(3); ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -set autocommit=0; - - ---echo End of 5.0 tests diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index f96350686af..5a589816dcd 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -319,3 +319,11 @@ select -(-(9223372036854775808)); --enable_ps_protocol select --9223372036854775808, ---9223372036854775808, ----9223372036854775808; select -(-9223372036854775808), -(-(-9223372036854775808)); + +# Bug #28005 Partitions: can't use -9223372036854775808 +create table t1 select -9223372036854775808 bi; +describe t1; +drop table t1; +create table t1 select -9223372036854775809 bi; +describe t1; +drop table t1; diff --git a/mysql-test/t/binlog-master.opt b/mysql-test/t/binlog-master.opt deleted file mode 100644 index ad2c6a647b5..00000000000 --- a/mysql-test/t/binlog-master.opt +++ /dev/null @@ -1 +0,0 @@ --O max_binlog_size=4096 diff --git a/mysql-test/t/binlog.test b/mysql-test/t/binlog.test deleted file mode 100644 index 8ceb219402a..00000000000 --- a/mysql-test/t/binlog.test +++ /dev/null @@ -1,204 +0,0 @@ -# -# misc binlogging tests that do not require a slave running -# --- source include/have_log_bin.inc --- source include/not_embedded.inc --- source include/have_innodb.inc - ---disable_warnings -drop table if exists t1, t2; ---enable_warnings -reset master; - -create table t1 (a int) engine=innodb; -create table t2 (a int) engine=innodb; -begin; -insert t1 values (5); -commit; -begin; -insert t2 values (5); -commit; -# first COMMIT must be Query_log_event, second - Xid_log_event ---replace_column 2 # 5 # ---replace_regex /\/\* xid=.* \*\//\/* XID *\// -show binlog events from 98; -drop table t1,t2; - -# -# binlog rotation after one big transaction -# -reset master; -let $1=100; - -create table t1 (n int) engine=innodb; -begin; ---disable_query_log -while ($1) -{ - eval insert into t1 values($1 + 4); - dec $1; -} ---enable_query_log -commit; -drop table t1; ---replace_column 2 # 5 # ---replace_regex /\/\* xid=.* \*\//\/* XID *\// -show binlog events in 'master-bin.000001' from 98; ---replace_column 2 # 5 # -show binlog events in 'master-bin.000002' from 98; - -# -# Bug#22540 - Incorrect value in column End_log_pos of -# SHOW BINLOG EVENTS using InnoDB -# - -# the following tests will show that certain queries now return -# absolute offsets (from binlog start, rather than relative to -# the beginning of the current transaction). under what -# conditions it should be allowed / is sensible to put the -# slider into the middle of a transaction is not our concern -# here; we just guarantee that if and when it's done, the -# user has valid offsets to use. if the setter function still -# wants to throw a "positioning into middle of transaction" -# warning, that's its prerogative and handled elsewhere. - -set @ac = @@autocommit; - -# first show this to work for SHOW BINLOG EVENTS - -set autocommit= 0; -reset master; -create table t1(n int) engine=innodb; -begin; -insert into t1 values (1); -insert into t1 values (2); -insert into t1 values (3); -commit; -drop table t1; ---replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/ -show binlog events from 0; - -# now show that nothing breaks if we need to read from the cache more -# than once, resulting in split event-headers - -set @bcs = @@binlog_cache_size; -set global binlog_cache_size=4096; -reset master; - -create table t1 (a int) engine=innodb; - -let $1=400; -disable_query_log; -begin; -while ($1) -{ - eval insert into t1 values( $1 ); - dec $1; -} -commit; -enable_query_log; - ---replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/ -show binlog events from 0; - -drop table t1; - -set global binlog_cache_size=@bcs; -set session autocommit = @ac; - -# -# Bug#33798: prepared statements improperly handle large unsigned ints -# ---disable_warnings -drop table if exists t1; ---enable_warnings -reset master; -create table t1 (a bigint unsigned, b bigint(20) unsigned); -prepare stmt from "insert into t1 values (?,?)"; -set @a= 9999999999999999; -set @b= 14632475938453979136; -execute stmt using @a, @b; -deallocate prepare stmt; -drop table t1; ---replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/ -show binlog events from 0; - - -# -# Bug #39182: Binary log producing incompatible character set query from -# stored procedure. -# -CREATE DATABASE bug39182 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; -USE bug39182; -CREATE TABLE t1 (a VARCHAR(255) COLLATE utf8_unicode_ci) - DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - -DELIMITER //; - -CREATE PROCEDURE p1() -BEGIN - DECLARE s1 VARCHAR(255); - SET s1= "test"; - CREATE TEMPORARY TABLE tmp1 - SELECT * FROM t1 WHERE a LIKE CONCAT("%", s1, "%"); - SELECT - COLLATION(NAME_CONST('s1', _utf8'test')) c1, - COLLATION(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) c2, - COLLATION(s1) c3, - COERCIBILITY(NAME_CONST('s1', _utf8'test')) d1, - COERCIBILITY(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) d2, - COERCIBILITY(s1) d3; - DROP TEMPORARY TABLE tmp1; -END// - -DELIMITER ;// - -CALL p1(); -SHOW BINLOG EVENTS FROM 1285; - -DROP PROCEDURE p1; -DROP TABLE t1; -DROP DATABASE bug39182; -USE test; - -# -# Bug#35383: binlog playback and replication breaks due to -# name_const substitution -# -DELIMITER //; -CREATE PROCEDURE p1(IN v1 INT) -BEGIN - CREATE TABLE t1 SELECT v1; - DROP TABLE t1; -END// -CREATE PROCEDURE p2() -BEGIN - DECLARE v1 INT; - CREATE TABLE t1 SELECT v1+1; - DROP TABLE t1; -END// -CREATE PROCEDURE p3(IN v1 INT) -BEGIN - CREATE TABLE t1 SELECT 1 FROM DUAL WHERE v1!=0; - DROP TABLE t1; -END// -CREATE PROCEDURE p4(IN v1 INT) -BEGIN - DECLARE v2 INT; - CREATE TABLE t1 SELECT 1, v1, v2; - DROP TABLE t1; - CREATE TABLE t1 SELECT 1, v1+1, v2; - DROP TABLE t1; -END// -DELIMITER ;// - -CALL p1(1); -CALL p2(); -CALL p3(0); -CALL p4(0); -DROP PROCEDURE p1; -DROP PROCEDURE p2; -DROP PROCEDURE p3; -DROP PROCEDURE p4; - ---echo End of 5.0 tests diff --git a/mysql-test/t/binlog_index.test b/mysql-test/t/binlog_index.test deleted file mode 100644 index 1e44a9b02e2..00000000000 --- a/mysql-test/t/binlog_index.test +++ /dev/null @@ -1,69 +0,0 @@ -# -# testing of purging of binary log files bug#18199/Bug#18453 -# -source include/have_log_bin.inc; -source include/not_embedded.inc; - -# -# testing purge binary logs TO -# - -flush logs; -flush logs; -flush logs; - -source include/show_binary_logs.inc; - -remove_file $MYSQLTEST_VARDIR/log/master-bin.000001; - -# there must be a warning with file names ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -purge binary logs TO 'master-bin.000004'; - ---echo *** must show a list starting from the 'TO' argument of PURGE *** -source include/show_binary_logs.inc; - -# -# testing purge binary logs BEFORE -# - -reset master; - -flush logs; -flush logs; -flush logs; -remove_file $MYSQLTEST_VARDIR/log/master-bin.000001; - ---echo *** must be a warning master-bin.000001 was not found *** -let $date=`select NOW() + INTERVAL 1 MINUTE`; ---disable_query_log ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval purge binary logs BEFORE '$date'; ---enable_query_log - ---echo *** must show one record, of the active binlog, left in the index file after PURGE *** -source include/show_binary_logs.inc; - -# -# testing a fatal error -# Turning a binlog file into a directory must be a portable setup -# - -reset master; - -flush logs; -flush logs; -flush logs; - -remove_file $MYSQLTEST_VARDIR/log/master-bin.000001; -mkdir $MYSQLTEST_VARDIR/log/master-bin.000001; - ---error ER_BINLOG_PURGE_FATAL_ERR -purge binary logs TO 'master-bin.000002'; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -show warnings; -rmdir $MYSQLTEST_VARDIR/log/master-bin.000001; ---disable_warnings -reset master; ---enable_warnings ---echo End of tests diff --git a/mysql-test/t/binlog_innodb.test b/mysql-test/t/binlog_innodb.test deleted file mode 100644 index 47b09719ef5..00000000000 --- a/mysql-test/t/binlog_innodb.test +++ /dev/null @@ -1,64 +0,0 @@ --- source include/have_innodb.inc --- source include/have_log_bin.inc - - -# -# Let us test binlog_cache_use and binlog_cache_disk_use status vars. -# Actually this test has nothing to do with innodb per se, it just requires -# transactional table. -# -show status like "binlog_cache_use"; -show status like "binlog_cache_disk_use"; - -create table t1 (a int) engine=innodb; - -# Now we are going to create transaction which is long enough so its -# transaction binlog will be flushed to disk... -let $1=2000; -disable_query_log; -begin; -while ($1) -{ - eval insert into t1 values( $1 ); - dec $1; -} -commit; -enable_query_log; -show status like "binlog_cache_use"; -show status like "binlog_cache_disk_use"; - -# Transaction which should not be flushed to disk and so should not -# increase binlog_cache_disk_use. -begin; -delete from t1; -commit; -show status like "binlog_cache_use"; -show status like "binlog_cache_disk_use"; -drop table t1; - - -# -# Bug #30604: different flagging of time_zone_used in normal and ps-protocol -# - -CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=MyISAM; -CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB; - -DELIMITER |; -# the function does not deal with time objects -CREATE FUNCTION bug23333() -RETURNS int(11) -DETERMINISTIC -BEGIN - INSERT INTO t1 VALUES (NULL); - SELECT COUNT(*) FROM t1 INTO @a; - RETURN @a; -END| - -DELIMITER ;| - -INSERT INTO t2 VALUES (2),(10+bug23333()); ---replace_column 1 # -SHOW MASTER STATUS; -DROP FUNCTION bug23333; -DROP TABLE t1, t2; diff --git a/mysql-test/t/binlog_killed.test b/mysql-test/t/binlog_killed.test deleted file mode 100644 index af78adf0abc..00000000000 --- a/mysql-test/t/binlog_killed.test +++ /dev/null @@ -1,216 +0,0 @@ --- source include/have_innodb.inc ---source include/not_embedded.inc ---source include/have_log_bin.inc - -### -### bug#22725 : incorrect killed error in binlogged query -### - -connect (con1, localhost, root,,); -connect (con2, localhost, root,,); - -create table t1 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; -create table t2 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=MyISAM; -create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; - -# -# effective test for bug#22725 -# - -connection con1; -select get_lock("a", 20); - -connection con2; -let $ID= `select connection_id()`; -reset master; -send insert into t2 values (null, null), (null, get_lock("a", 10)); - - -connection con1; - -disable_abort_on_error; -disable_query_log; -disable_result_log; - -eval kill query $ID; - -connection con2; ---error 0,ER_QUERY_INTERRUPTED -reap; -let $rows= `select count(*) from t2 /* must be 2 or 0 */`; - ---exec $MYSQL_BINLOG --start-position=126 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval select -(@a:=load_file("$MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) -is not null; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -let $error_code= `select @a like "%#%error_code=0%" /* must return 1 or 0*/`; -let $insert_binlogged= `select @a like "%insert into%" /* must return 1 or 0 */`; -eval set @result= $rows- $error_code - $insert_binlogged; - -enable_abort_on_error; -enable_query_log; -enable_result_log; - -select @result /* must be zero either way */; - - ---remove_file $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog -connection con1; -select RELEASE_LOCK("a"); - -# -# bug#27571 asynchronous setting mysql_`query`::error and Query_log_e::error_code -# - -# checking that killing inside of select loops is safe as before -# killing after the loop can be only simulated - another test - -delete from t1; -delete from t2; -insert into t1 values (1,1),(2,2); - -# -# simple update -# -connection con1; -begin; update t1 set b=11 where a=2; - -connection con2; -let $ID= `select connection_id()`; -begin; -send update t1 set b=b+10; - -connection con1; ---replace_result $ID ID -eval kill query $ID; -rollback; - -# Bug #32148 killi query may be ineffective -# forced to comment out the test's outcome -# and mask out ineffective ER_QUERY_INTERRUPTED -# todo1: revert back upon fixing bug#32148 -# todo2: the tests need refining in that -# killing should wait till the victim requested -# its lock (wait_condition available in 5.1 tests) - -connection con2; ---error 0,ER_QUERY_INTERRUPTED -reap; -rollback; -select * from t1 order by a /* must be the same as before (1,1),(2,2) */; - -# -# multi update -# commented out as Bug #31807 multi-update,delete killing does not report with ER_QUERY_INTERRUPTED -# in the way -# -# connection con1; -# begin; update t1 set b=b+10; - -# connection con2; -# send update t1 as t_1,t1 as t_2 set t_1.b=11 where t_2.a=2; - -# connection con1; -# --replace_result $ID ID -# eval kill query $ID; -# rollback; - -# disable_abort_on_error; - -# connection con2; -# --error HY000,ER_QUERY_INTERRUPTED -# reap; -# select * from t1 /* must be the same as before (1,1),(2,2) */; - -# enable_abort_on_error; -# -# simple delete -# -connection con1; -begin; delete from t1 where a=2; - -connection con2; -let $ID= `select connection_id()`; -begin; -send delete from t1 where a=2; - -connection con1; ---replace_result $ID ID -eval kill query $ID; -rollback; - -connection con2; ---error 0,ER_QUERY_INTERRUPTED -reap; -rollback; -# todo1,2 above -select * from t1 order by a /* must be the same as before (1,1),(2,2) */; - - -# -# multi delete -# the same as for multi-update -# -# connection con1; -# begin; delete from t1 where a=2; - -# connection con2; -# send delete t1 from t1 where t1.a=2; - -# connection con1; -# --replace_result $ID ID -# eval kill query $ID; -# rollback; - -# connection con2; -# --error 0,ER_QUERY_INTERRUPTED -# reap; -# select * from t1 /* must be the same as before (1,1),(2,2) */; -# -# insert select -# -connection con1; ---disable_warnings -drop table if exists t4; ---enable_warnings -create table t4 (a int, b int) engine=innodb; -insert into t4 values (3, 3); -begin; insert into t1 values (3, 3); - -connection con2; -let $ID= `select connection_id()`; -begin; -send insert into t1 select * from t4 for update; - -connection con1; ---replace_result $ID ID -eval kill query $ID; -rollback; - -connection con2; ---error 0,ER_QUERY_INTERRUPTED -reap; -# todo 1,2 above -rollback; -select * from t1 /* must be the same as before (1,1),(2,2) */; - -drop table t4; # cleanup for the sub-case - -### -## non-ta table case: killing must be recorded in binlog -### - -# In order to be deterministic the test needs INFORMATION_SCHEMA.PROCESSLIST -# which is not available on 5.0 at this time. -# Therefore, skip this part on 5.0. - - -# -# common cleanup -# - -drop table t1,t2,t3; - ---echo end of the tests diff --git a/mysql-test/t/binlog_killed_simulate-master.opt b/mysql-test/t/binlog_killed_simulate-master.opt deleted file mode 100644 index 90c70ecee29..00000000000 --- a/mysql-test/t/binlog_killed_simulate-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-debug=d,simulate_kill_bug27571 diff --git a/mysql-test/t/binlog_killed_simulate.test b/mysql-test/t/binlog_killed_simulate.test deleted file mode 100644 index 3f50ac350d5..00000000000 --- a/mysql-test/t/binlog_killed_simulate.test +++ /dev/null @@ -1,66 +0,0 @@ --- source include/have_debug.inc -# -# bug#27571 asynchronous setting mysql_$query()'s local error and -# Query_log_event::error_code -# - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - -# -# Checking that killing upon successful row-loop does not affect binlogging -# - -create table t1 (a int) engine=MyISAM; -insert into t1 set a=1; -reset master; - -update t1 set a=2 /* will be "killed" after work has been done */; - -# a proof the query is binlogged with no error - ---exec $MYSQL_BINLOG --start-position=98 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval select -(@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) -is not null; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -let $error_code= `select @a like "%#%error_code=0%" /* must return 1 */`; -eval select $error_code /* must return 1 as query completed before got killed*/; - -# cleanup for the sub-case -remove_file $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog; - - -# -# Checking that killing inside of row-loop for LOAD DATA into -# non-transactional table affects binlogging -# - -create table t2 (a int, b int) ENGINE=MyISAM; -reset master; ---error ER_QUERY_INTERRUPTED -load data infile '../std_data_ln/rpl_loaddata.dat' into table t2 /* will be "killed" in the middle */; - - -# a proof the query is binlogged with an error - -source include/show_binlog_events.inc; - ---exec $MYSQL_BINLOG --start-position=98 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval select -(@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) -is not null; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -let $error_code= `select @a like "%#%error_code=0%" /* must return 0*/`; -eval select $error_code /* must return 0 to mean the killed query is in */; - -# cleanup for the sub-case -remove_file $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog; - - -drop table t1,t2; - ---echo end of the tests diff --git a/mysql-test/t/binlog_start_comment.test b/mysql-test/t/binlog_start_comment.test deleted file mode 100644 index 2834c6d27e3..00000000000 --- a/mysql-test/t/binlog_start_comment.test +++ /dev/null @@ -1,24 +0,0 @@ -# Test case for bug#32205 Replaying statements from mysqlbinlog fails -# with a syntax error, replicates fine - -source include/have_log_bin.inc; -source include/have_local_infile.inc; - -reset master; ---disable_warnings -drop table if exists t1,t2; ---enable_warnings -create table t1 (word varchar(20)) -- create table t1; -create table t2 (word varchar(20)) -- create table t2; -load data infile '../std_data_ln/words.dat' into table t1 -- load data to t1; -insert into t2 values ("Ada"); -flush logs; -select * from t2; ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_start_comment.binlog ---exec $MYSQL --local-infile=1 < $MYSQLTEST_VARDIR/tmp/binlog_start_comment.binlog -flush logs; -select * from t2; - -# clean up -drop table t1,t2; -#--remove_file $MYSQLTEST_VARDIR/tmp/binlog_start_comment.binlog diff --git a/mysql-test/t/blackhole.test b/mysql-test/t/blackhole.test deleted file mode 100644 index cb8010d7967..00000000000 --- a/mysql-test/t/blackhole.test +++ /dev/null @@ -1,184 +0,0 @@ -# -# Simple test for blackhole example -# Taken from the select test -# --- source include/not_embedded.inc --- source include/have_blackhole.inc --- source include/have_log_bin.inc - -# The server need to be started in $MYSQLTEST_VARDIR since it -# uses ../std_data_ln/ --- source include/uses_vardir.inc - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - -CREATE TABLE t1 ( - Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, - Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL -) ENGINE=blackhole; - -INSERT INTO t1 VALUES (9410,9412); - -select period from t1; -select * from t1; -select t1.* from t1; - -# -# Create test table -# - -CREATE TABLE t2 ( - auto int NOT NULL auto_increment, - fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, - companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, - fld3 char(30) DEFAULT '' NOT NULL, - fld4 char(35) DEFAULT '' NOT NULL, - fld5 char(35) DEFAULT '' NOT NULL, - fld6 char(4) DEFAULT '' NOT NULL, - primary key (auto) -) ENGINE=blackhole; - -INSERT INTO t2 VALUES (1192,068305,00,'Colombo','hardware','colicky',''); -INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly',''); ---enable_query_log - -# -# Search with a key -# - -select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; -select fld3 from t2 where fld3 like "%cultivation" ; - -# -# Search with a key using sorting and limit the same time -# - -select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; -select fld3,companynr from t2 where companynr = 58 order by fld3; - -select fld3 from t2 order by fld3 desc limit 10; -select fld3 from t2 order by fld3 desc limit 5; -select fld3 from t2 order by fld3 desc limit 5,5; - -# -# Search with a key having a constant with each unique key. -# The table is read directly with read-next on fld3 -# - -select t2.fld3 from t2 where fld3 = 'honeysuckle'; -select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; -select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; -select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; -select t2.fld3 from t2 where fld3 LIKE 'h%le'; - -select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; -select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; - -# -# Test sorting with a used key (there is no need for sorting) -# - -select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; -select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; - - -# Test for fulltext -DROP TABLE t1; -CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)); -INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), - ('Full-text indexes', 'are called collections'), - ('Only MyISAM tables','support collections'), - ('Function MATCH ... AGAINST()','is used to do a search'), - ('Full-text search in MySQL', 'implements vector space model'); -SHOW INDEX FROM t1; - -# nl search - -select * from t1 where MATCH(a,b) AGAINST ("collections"); -explain extended select * from t1 where MATCH(a,b) AGAINST ("collections"); -select * from t1 where MATCH(a,b) AGAINST ("indexes"); -select * from t1 where MATCH(a,b) AGAINST ("indexes collections"); -select * from t1 where MATCH(a,b) AGAINST ("only"); - -# Test that every DML (except SELECT) and DDL gets into binlog -# so that blackhole can be used as "binlog propagator" - -reset master; -drop table t1,t2; -create table t1 (a int) engine=blackhole; -delete from t1 where a=10; -update t1 set a=11 where a=15; -insert into t1 values(1); -insert ignore into t1 values(1); -replace into t1 values(100); -create table t2 (a varchar(200)) engine=blackhole; -eval load data infile '../std_data_ln/words.dat' into table t2; -alter table t1 add b int; -alter table t1 drop b; -create table t3 like t1; -insert into t1 select * from t3; -replace into t1 select * from t3; -# Just to verify -select * from t1; -select * from t2; -select * from t3; - -let $VERSION=`select version()`; ---replace_result $VERSION VERSION ---replace_column 2 # 5 # ---replace_regex /file_id=[0-9]+/file_id=#/ -show binlog events; - -drop table t1,t2,t3; - -# -# BUG#27998 - mysqld crashed when executing INSERT DELAYED on a BLACKHOLE -# table -# -CREATE TABLE t1(a INT) ENGINE=BLACKHOLE; ---error 1031 -INSERT DELAYED INTO t1 VALUES(1); -DROP TABLE t1; - - -# -#Bug#19717: DELETE Query Error on BLACKHOLE when using WHERE on column with UNIQUE INDEX -# -CREATE TABLE t1(a INT, b INT) ENGINE=BLACKHOLE; -DELETE FROM t1 WHERE a=10; -ALTER TABLE t1 ADD INDEX(a); -DELETE FROM t1 WHERE a=10; -ALTER TABLE t1 DROP INDEX a; -ALTER TABLE t1 ADD UNIQUE INDEX(a); -DELETE FROM t1 WHERE a=10; -ALTER TABLE t1 DROP INDEX a; -ALTER TABLE t1 ADD PRIMARY KEY(a); -DELETE FROM t1 WHERE a=10; -DROP TABLE t1; - -# -# Bug#35178 INSERT_ID not written to binary log for inserts against BLACKHOLE backed tables -# -# -# the test checks that explicitly prescribed with set insert_id= value -# preceeds the following autoincrement insert in a blachhole -# - -reset master; -create table t1 (a int auto_increment, primary key (a)) engine=blackhole; - -# not insert_id prescribed insert binlogs with the default set insert_id 1 -insert into t1 values (11), (NULL), (NULL), (NULL); -set insert_id= 3; -insert into t1 values (NULL), (33), (NULL); -set insert_id= 5; -insert into t1 values (55), (NULL); -source include/show_binlog_events2.inc; - -# cleanup -drop table t1; - - -# End of tests diff --git a/mysql-test/t/bootstrap.test b/mysql-test/t/bootstrap.test index 203ba9b2914..db89269b35d 100644 --- a/mysql-test/t/bootstrap.test +++ b/mysql-test/t/bootstrap.test @@ -6,6 +6,10 @@ drop table if exists t1; --enable_warnings +# Add the datadir to the bootstrap command +let $MYSQLD_DATADIR= `select @@datadir`; +let $MYSQLD_BOOTSTRAP_CMD= $MYSQLD_BOOTSTRAP_CMD --datadir=$MYSQLD_DATADIR; + # # Check that --bootstrap reads from stdin # diff --git a/mysql-test/t/bug46080.test b/mysql-test/t/bug46080.test index 7e56e3ce421..8b4cee4d8b0 100644 --- a/mysql-test/t/bug46080.test +++ b/mysql-test/t/bug46080.test @@ -3,6 +3,9 @@ --echo # sort_buffer_size cannot allocate --echo # +call mtr.add_suppression("Out of memory at line .*, 'my_alloc.c'"); +call mtr.add_suppression("needed .* byte .*k., memory in use: .* bytes .*k"); + CREATE TABLE t1(a CHAR(255)); INSERT INTO t1 VALUES ('a'); diff --git a/mysql-test/t/bug46760-master.opt b/mysql-test/t/bug46760-master.opt new file mode 100644 index 00000000000..f830d135149 --- /dev/null +++ b/mysql-test/t/bug46760-master.opt @@ -0,0 +1,2 @@ +--innodb-lock-wait-timeout=2 +--innodb-file-per-table diff --git a/mysql-test/t/bug46760.test b/mysql-test/t/bug46760.test new file mode 100644 index 00000000000..f55edbbfa42 --- /dev/null +++ b/mysql-test/t/bug46760.test @@ -0,0 +1,38 @@ +-- source include/have_innodb.inc + +--echo # +--echo # Bug#46760: Fast ALTER TABLE no longer works for InnoDB +--echo # + +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--echo # By using --enable_info and verifying that number of affected +--echo # rows is 0 we check that this ALTER TABLE is really carried +--echo # out as "fast/online" operation, i.e. without full-blown data +--echo # copying. +--echo # +--echo # I.e. info for the below statement should normally look like: +--echo # +--echo # affected rows: 0 +--echo # info: Records: 0 Duplicates: 0 Warnings: 0 + +--enable_info +ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 10; +--disable_info +SHOW CREATE TABLE t1; + +DROP TABLE t1; + +--echo # +--echo # MySQL Bug#39200: optimize table does not recognize +--echo # ROW_FORMAT=COMPRESSED +--echo # + +CREATE TABLE t1 (a INT) ROW_FORMAT=compressed; +SHOW CREATE TABLE t1; +OPTIMIZE TABLE t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/bdb_cache-master.opt b/mysql-test/t/cache_innodb-master.opt index 5f0ebff98f6..5f0ebff98f6 100644 --- a/mysql-test/t/bdb_cache-master.opt +++ b/mysql-test/t/cache_innodb-master.opt diff --git a/mysql-test/t/cache_innodb.test b/mysql-test/t/cache_innodb.test new file mode 100644 index 00000000000..33a328d1d6c --- /dev/null +++ b/mysql-test/t/cache_innodb.test @@ -0,0 +1,16 @@ +# t/cache_innodb.test +# +# Last update: +# 2006-07-26 ML test refactored (MySQL 5.1) +# main code t/innodb_cache.test --> include/query_cache.inc +# new wrapper t/cache_innodb.test +# + +--source include/have_query_cache.inc + +--source include/have_innodb.inc +let $engine_type= InnoDB; +# InnoDB supports FOREIGN KEYs +let $test_foreign_keys= 1; + +--source include/query_cache.inc diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index b6654df4ecb..028c64d6de7 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -1,4 +1,4 @@ -# + # Testing of CASE # diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index df475b49746..8e60d548c2f 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -53,7 +53,7 @@ select cast('1a' as signed); select cast('' as signed); # -# Character set convertion +# Character set conversion # set names binary; select cast(_latin1'test' as char character set latin2); @@ -269,3 +269,18 @@ SELECT HOUR(NULL), DROP TABLE t1; --echo End of 5.0 tests + +--echo # +--echo # Bug #44766: valgrind error when using convert() in a subquery +--echo # + +CREATE TABLE t1(a tinyint); +INSERT INTO t1 VALUES (127); +SELECT 1 FROM +( + SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1 +) AS s LIMIT 1; +DROP TABLE t1; + + +--echo End of 5.1 tests diff --git a/mysql-test/t/rpl_dual_pos_advance-master.opt b/mysql-test/t/change_user-master.opt index cef79bc8585..cef79bc8585 100644 --- a/mysql-test/t/rpl_dual_pos_advance-master.opt +++ b/mysql-test/t/change_user-master.opt diff --git a/mysql-test/t/change_user.test b/mysql-test/t/change_user.test new file mode 100644 index 00000000000..89f35116a2c --- /dev/null +++ b/mysql-test/t/change_user.test @@ -0,0 +1,76 @@ +# +# Bug#20023 mysql_change_user() resets the value of SQL_BIG_SELECTS +# + +--echo Bug#20023 +SELECT @@session.sql_big_selects; +# The exact value depends on the server build flags +--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR +SELECT @@global.max_join_size; +--echo change_user +--change_user +SELECT @@session.sql_big_selects; +# The exact value depends on the server build flags +--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR +SELECT @@global.max_join_size; +SET @@global.max_join_size = 10000; +SET @@session.max_join_size = default; +--echo change_user +--change_user +SELECT @@session.sql_big_selects; +# On some machines the following will result into a warning +--disable_warnings +SET @@global.max_join_size = -1; +--enable_warnings +SET @@session.max_join_size = default; +--echo change_user +--change_user +SELECT @@session.sql_big_selects; + +# +# Bug#31418 User locks misfunctioning after mysql_change_user() +# + +--echo Bug#31418 +SELECT IS_FREE_LOCK('bug31418'); +SELECT IS_USED_LOCK('bug31418'); +SELECT GET_LOCK('bug31418', 1); +SELECT IS_USED_LOCK('bug31418') = CONNECTION_ID(); +--echo change_user +--change_user +SELECT IS_FREE_LOCK('bug31418'); +SELECT IS_USED_LOCK('bug31418'); + +# +# Bug#31222: com_% global status counters behave randomly with +# mysql_change_user. +# + +FLUSH STATUS; + +--disable_result_log +--disable_query_log + +let $i = 100; + +while ($i) +{ + dec $i; + + SELECT 1; +} + +--enable_query_log +--enable_result_log + +let $before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_select',Value,1); + +--change_user + +let $after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_select',Value,1); + +if (`select $after != $before`){ + SHOW GLOBAL STATUS LIKE 'com_select'; + die The value of com_select changed during change_user; +} +echo Value of com_select did not change; diff --git a/mysql-test/t/client_xml.test b/mysql-test/t/client_xml.test index 81cd5a079ad..0847e2b366b 100644 --- a/mysql-test/t/client_xml.test +++ b/mysql-test/t/client_xml.test @@ -1,6 +1,11 @@ # Can't run with embedded server -- source include/not_embedded.inc +# Disable concurrent inserts to avoid test failures when reading +# data from concurrent connections (insert might return before +# the data is actually in the table). +set @old_concurrent_insert= @@global.concurrent_insert; +set @@global.concurrent_insert= 0; --disable_warnings drop table if exists t1; --enable_warnings @@ -13,6 +18,10 @@ create table t1 ( `a>b` text ); insert into t1 values (1, 2, 'a&b a<b a>b'); + +# Determine the number of open sessions +--source include/count_sessions.inc + --exec $MYSQL --xml test -e "select * from t1" --exec $MYSQL_DUMP --xml --skip-create test @@ -25,3 +34,11 @@ insert into t1 values (1, 2, 'a&b a<b a>b'); --exec $MYSQL --xml test -vv -e "select 1 limit 0" drop table t1; + +# Restore global concurrent_insert value +set @@global.concurrent_insert= @old_concurrent_insert; + +# Wait till the number of open sessions is <= the number before the runs with +# $MYSQL and $MYSQL_DUMP +# = The session caused by mysql and mysqldump have finished their disconnect +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/comments.test b/mysql-test/t/comments.test index 0c6853cf298..3a18a8bd483 100644 --- a/mysql-test/t/comments.test +++ b/mysql-test/t/comments.test @@ -20,6 +20,19 @@ select 1 # The rest of the row will be ignored # End of 4.1 tests +# +# Bug#25411 (trigger code truncated) +# + +--error ER_PARSE_ERROR +select 1/*!2*/; + +--error ER_PARSE_ERROR +select 1/*!000002*/; + +select 1/*!999992*/; + +select 1 + /*!00000 2 */ + 3 /*!99999 noise*/ + 4; # # Bug#28779 (mysql_query() allows execution of statements with unbalanced diff --git a/mysql-test/t/commit_1innodb.test b/mysql-test/t/commit_1innodb.test new file mode 100644 index 00000000000..c4a29acdddd --- /dev/null +++ b/mysql-test/t/commit_1innodb.test @@ -0,0 +1,6 @@ +-- source include/have_log_bin.inc +-- source include/have_innodb.inc + +let $engine_type = InnoDB; + +-- source include/commit.inc diff --git a/mysql-test/t/compress.test b/mysql-test/t/compress.test index 8e12ab46f06..0a20daef8de 100644 --- a/mysql-test/t/compress.test +++ b/mysql-test/t/compress.test @@ -14,6 +14,7 @@ connect (comp_con,localhost,root,,,,,COMPRESS); # Check compression turned on SHOW STATUS LIKE 'Compression'; +select * from information_schema.session_status where variable_name= 'COMPRESSION'; # Source select test case -- source include/common-tests.inc diff --git a/mysql-test/t/concurrent_innodb_safelog-master.opt b/mysql-test/t/concurrent_innodb_safelog-master.opt new file mode 100644 index 00000000000..462f8fbe828 --- /dev/null +++ b/mysql-test/t/concurrent_innodb_safelog-master.opt @@ -0,0 +1 @@ +--innodb_lock_wait_timeout=1 diff --git a/mysql-test/t/concurrent_innodb_safelog.test b/mysql-test/t/concurrent_innodb_safelog.test new file mode 100644 index 00000000000..828df9ef717 --- /dev/null +++ b/mysql-test/t/concurrent_innodb_safelog.test @@ -0,0 +1,23 @@ +# t/concurrent_innodb_safelog.test +# +# Concurrent InnoDB tests +# +# Last update: +# 2006-07-26 ML test refactored (MySQL 5.1) +# main code t/innodb_concurrent.test -> include/concurrent.inc +# new wrapper t/concurrent_innodb.test +# 2008-06-03 KP test refactored; removed name locks, added comments. +# renamed wrapper t/concurrent_innodb.test -> +# t/concurrent_innodb_unsafelog.test +# new wrapper t/concurrent_innodb_safelog.test +# + +--source include/have_innodb.inc + +let $engine_type= InnoDB; + +SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; +# innodb_locks_unsafe_for_binlog not set for this test + +--source include/concurrent.inc + diff --git a/mysql-test/t/concurrent_innodb_unsafelog-master.opt b/mysql-test/t/concurrent_innodb_unsafelog-master.opt new file mode 100644 index 00000000000..210212a40bc --- /dev/null +++ b/mysql-test/t/concurrent_innodb_unsafelog-master.opt @@ -0,0 +1,2 @@ +--innodb_locks_unsafe_for_binlog +--innodb_lock_wait_timeout=1 diff --git a/mysql-test/t/concurrent_innodb_unsafelog.test b/mysql-test/t/concurrent_innodb_unsafelog.test new file mode 100644 index 00000000000..e2c03655e43 --- /dev/null +++ b/mysql-test/t/concurrent_innodb_unsafelog.test @@ -0,0 +1,23 @@ +# t/concurrent_innodb_unsafelog.test +# +# Concurrent InnoDB tests +# +# Last update: +# 2006-07-26 ML test refactored (MySQL 5.1) +# main code t/innodb_concurrent.test -> include/concurrent.inc +# new wrapper t/concurrent_innodb.test +# 2008-06-03 KP test refactored; removed name locks, added comments. +# renamed wrapper t/concurrent_innodb.test -> +# t/concurrent_innodb_unsafelog.test +# new wrapper t/concurrent_innodb_safelog.test +# + +--source include/have_innodb.inc + +let $engine_type= InnoDB; + +SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ; +# innodb_locks_unsafe_for_binlog is set fro this test. + +--source include/concurrent.inc + diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index c3a14964bb7..9a29e4ff861 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -5,11 +5,18 @@ # This test makes no sense with the embedded server --source include/not_embedded.inc +# check that CSV engine was compiled in, as the test relies on the presence +# of the log tables (which are CSV-based). By connect mysql; show tables; +--source include/have_csv.inc + +# Save the initial number of concurrent sessions +--source include/count_sessions.inc + + --disable_warnings drop table if exists t1,t2; --enable_warnings - #connect (con1,localhost,root,,""); #show tables; connect (con1,localhost,root,,mysql); @@ -48,7 +55,8 @@ disconnect con4; connect (fail_con,localhost,test,,test2); --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR -connect (fail_con,localhost,test,,""); +# Need to protect "" within '' so it's interpreted literally +connect (fail_con,localhost,test,,'""'); --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect (fail_con,localhost,test,zorro,test2); @@ -96,18 +104,199 @@ delete from mysql.user where user=_binary"test"; flush privileges; # -# Bug#12517: Clear user variables and replication events before -# closing temp tables in thread cleanup. +# Bug#12517 Clear user variables and replication events before +# closing temp tables in thread cleanup. connect (con7,localhost,root,,test); connection con7; +let $connection_id= `select connection_id()`; create table t1 (id integer not null auto_increment primary key); create temporary table t2(id integer not null auto_increment primary key); set @id := 1; delete from t1 where id like @id; -disconnect con7; ---sleep 5 connection default; +disconnect con7; +# Wait till the session con7 is disconnected +let $wait_condition = + SELECT COUNT(*) = 0 + FROM information_schema.processlist + WHERE id = '$connection_id'; +--source include/wait_condition.inc drop table t1; +--echo # ------------------------------------------------------------------ +--echo # -- End of 4.1 tests +--echo # ------------------------------------------------------------------ + +########################################################################### + +--echo +--echo # -- Bug#33507: Event scheduler creates more threads than max_connections +--echo # -- which results in user lockout. + +--echo +GRANT USAGE ON *.* TO mysqltest_u1@localhost; + +# NOTE: if the test case fails sporadically due to spurious connections, +# consider disabling all users. + +--echo +let $saved_max_connections = `SELECT @@global.max_connections`; +SET GLOBAL max_connections = 3; +SET GLOBAL event_scheduler = ON; + +--echo +--echo # -- Waiting for Event Scheduler to start... +let $wait_condition = + SELECT COUNT(*) = 1 + FROM information_schema.processlist + WHERE user = 'event_scheduler'; +--source include/wait_condition.inc + +--echo +--echo # -- Disconnecting default connection... +--disconnect default + +--echo +--echo # -- Check that we allow exactly three user connections, no matter how +--echo # -- many threads are running. + +--echo +--echo # -- Connecting (1)... +let $con_name = con_1; +let $con_user_name = mysqltest_u1; +--source include/connect2.inc + +--echo +--echo # -- Connecting (2)... +let $con_name = con_2; +let $con_user_name = mysqltest_u1; +--source include/connect2.inc + +--echo +--echo # -- Connecting (3)... +let $con_name = con_3; +let $con_user_name = mysqltest_u1; +--source include/connect2.inc + +--echo +--echo # -- Connecting (4) [should fail]... +let $con_name = con_4; +let $con_user_name = mysqltest_u1; +let $wait_timeout = 5; +--source include/connect2.inc + +--echo +--echo # -- Check that we allow one extra SUPER-user connection. + +--echo +--echo # -- Connecting super (1)... +let $con_name = con_super_1; +let $con_user_name = root; +--source include/connect2.inc + +--echo +--echo # -- Connecting super (2) [should fail]... +let $con_name = con_super_2; +let $con_user_name = root; +let $wait_timeout = 5; +--source include/connect2.inc + +--echo +--echo # -- Ensure that we have Event Scheduler thread, 3 ordinary user +--echo # -- connections and one extra super-user connection. +SELECT user FROM information_schema.processlist ORDER BY id; + +--echo +--echo # -- Resetting variables... +--eval SET GLOBAL max_connections = $saved_max_connections + +--echo +--echo # -- Stopping Event Scheduler... +SET GLOBAL event_scheduler = OFF; + +--echo +--echo # -- Waiting for Event Scheduler to stop... +let $wait_condition = + SELECT COUNT(*) = 0 + FROM information_schema.processlist + WHERE user = 'event_scheduler'; +--source include/wait_condition.inc + +--echo +--echo # -- That's it. Closing connections... +--disconnect con_1 +--disconnect con_2 +--disconnect con_3 +--disconnect con_super_1 + +--echo +--echo # -- Restoring default connection... +--connect (default,localhost,root,,test) + +--echo +--echo # -- Waiting for connections to close... +let $wait_condition = + SELECT COUNT(*) = 1 + FROM information_schema.processlist + WHERE db = 'test'; +--source include/wait_condition.inc + +--echo +DROP USER mysqltest_u1@localhost; + +--echo +--echo # -- End of Bug#33507. +--echo + +########################################################################### + +--echo # -- Bug#35074: max_used_connections is not correct. +--echo + +FLUSH STATUS; + +--echo +SHOW STATUS LIKE 'max_used_connections'; + +--echo +--echo # -- Starting Event Scheduler... +SET GLOBAL event_scheduler = ON; + +--echo # -- Waiting for Event Scheduler to start... +--source include/running_event_scheduler.inc + +# NOTE: We should use a new connection here instead of reconnect in order to +# avoid races (we can not for sure when the connection being disconnected is +# actually disconnected on the server). + +--echo +--echo # -- Opening a new connection to check max_used_connections... +--connect (con_1,localhost,root) + +--echo +--echo # -- Check that max_used_connections hasn't changed. +SHOW STATUS LIKE 'max_used_connections'; + +--echo +--echo # -- Closing new connection... +--disconnect con_1 +--connection default + +--echo +--echo # -- Stopping Event Scheduler... +SET GLOBAL event_scheduler = OFF; + +--echo # -- Waiting for Event Scheduler to stop... +--source include/no_running_events.inc + +--echo +--echo # -- End of Bug#35074. +--echo + +--echo # ------------------------------------------------------------------ +--echo # -- End of 5.1 tests +--echo # ------------------------------------------------------------------ + +# Wait till all disconnects are completed +--source include/wait_until_count_sessions.inc -# End of 4.1 tests diff --git a/mysql-test/t/consistent_snapshot.test b/mysql-test/t/consistent_snapshot.test index 82edf2e22b2..fb1f3bc007c 100644 --- a/mysql-test/t/consistent_snapshot.test +++ b/mysql-test/t/consistent_snapshot.test @@ -12,9 +12,9 @@ connect (con1,localhost,root,,); --echo # Establish connection con2 (user=root) connect (con2,localhost,root,,); -### Test 1: -### - While a consistent snapshot transaction is executed, -### no external inserts should be visible to the transaction. +--echo ### Test 1: +--echo ### - While a consistent snapshot transaction is executed, +--echo ### no external inserts should be visible to the transaction. --echo # Switch to connection con1 connection con1; @@ -31,9 +31,9 @@ SELECT * FROM t1; # if consistent snapshot was set as expected, we # should see nothing. COMMIT; -### Test 2: -### - For any non-consistent snapshot transaction, external -### committed inserts should be visible to the transaction. +--echo ### Test 2: +--echo ### - For any non-consistent snapshot transaction, external +--echo ### committed inserts should be visible to the transaction. DELETE FROM t1; START TRANSACTION; # Now we omit WITH CONSISTENT SNAPSHOT @@ -48,6 +48,24 @@ SELECT * FROM t1; # if consistent snapshot was not set, as expected, we # should see 1. COMMIT; +--echo ### Test 3: +--echo ### - Bug#44664: valgrind warning for COMMIT_AND_CHAIN and ROLLBACK_AND_CHAIN +--echo ### Chaining a transaction does not retain consistency level. + +START TRANSACTION WITH CONSISTENT SNAPSHOT; +DELETE FROM t1; +COMMIT WORK AND CHAIN; + +--echo # Switch to connection con2 +connection con2; +INSERT INTO t1 VALUES(1); + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; # if consistent snapshot was not set, as expected, we +# should see 1. +COMMIT; + --echo # Switch to connection default + close connections con1 and con2 connection default; disconnect con1; diff --git a/mysql-test/t/contributors.test b/mysql-test/t/contributors.test new file mode 100644 index 00000000000..e463c4a888b --- /dev/null +++ b/mysql-test/t/contributors.test @@ -0,0 +1 @@ +SHOW CONTRIBUTORS; diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test index 2f7cf7e5260..ad2bbee95a3 100644 --- a/mysql-test/t/count_distinct3.test +++ b/mysql-test/t/count_distinct3.test @@ -3,6 +3,8 @@ # mysql-4.1 # +--source include/big_test.inc + --disable_warnings DROP TABLE IF EXISTS t1, t2; --enable_warnings diff --git a/mysql-test/t/crash_commit_before-master.opt b/mysql-test/t/crash_commit_before-master.opt new file mode 100644 index 00000000000..a745693594e --- /dev/null +++ b/mysql-test/t/crash_commit_before-master.opt @@ -0,0 +1,2 @@ +--skip-stack-trace --skip-core-file + diff --git a/mysql-test/t/crash_commit_before.test b/mysql-test/t/crash_commit_before.test new file mode 100644 index 00000000000..e3dba58d4df --- /dev/null +++ b/mysql-test/t/crash_commit_before.test @@ -0,0 +1,35 @@ +-- source include/not_embedded.inc +# Don't test this under valgrind, memory leaks will occur +--source include/not_valgrind.inc + +# Binary must be compiled with debug for crash to occur +--source include/have_debug.inc + +--source include/have_innodb.inc + +CREATE TABLE t1(a int) engine=innodb; +START TRANSACTION; +insert into t1 values(9); + +# Setup the mysqld to crash at certain point +SET SESSION debug="d,crash_commit_before"; + +# Write file to make mysql-test-run.pl expect crash and restart +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +# Run the crashing query +--error 2013 +COMMIT; + +# Turn on reconnect +--enable_reconnect + +# Call script that will poll the server waiting for it to be back online again +--source include/wait_until_connected_again.inc + +SHOW CREATE TABLE t1; + +SELECT * FROM t1; + + +DROP TABLE t1; diff --git a/mysql-test/t/create-big.test b/mysql-test/t/create-big.test new file mode 100644 index 00000000000..6cd6326cdb8 --- /dev/null +++ b/mysql-test/t/create-big.test @@ -0,0 +1,392 @@ +# Tests for various concurrency-related aspects of CREATE TABLE ... SELECT +# and CREATE TABLE like implementation. +# +# Note that we don't test general CREATE TABLE ... SELECT/LIKE functionality +# here as it is already covered by create.test. We are more interested in +# extreme cases. +# +# This test takes rather long time so let us run it only in --big-test mode +--source include/big_test.inc +# We are using some debug-only features in this test +--source include/have_debug.inc +# Some of tests below also use binlog to check that statements are +# executed and logged in correct order +--source include/have_binlog_format_mixed_or_statement.inc + +# Create auxilliary connections +connect (addconroot1, localhost, root,,); +connect (addconroot2, localhost, root,,); +connect (addconroot3, localhost, root,,); +connection default; + +--disable_warnings +drop table if exists t1,t2,t3,t4,t5; +--enable_warnings + + +# +# Tests for concurrency problems in CREATE TABLE ... SELECT +# +# We introduce delays between various stages of table creation +# and check that other statements dealing with this table cannot +# interfere during those delays. +# +# What happens in situation when other statement messes with +# table to be created before it is created ? +# Concurrent CREATE TABLE +set session debug="+d,sleep_create_select_before_create"; +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +--error ER_TABLE_EXISTS_ERROR +create table t1 (j char(5)); +connection default; +--reap +show create table t1; +drop table t1; +# Concurrent CREATE TABLE ... SELECT +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +--error ER_TABLE_EXISTS_ERROR +create table t1 select "Test" as j; +connection default; +--reap +show create table t1; +drop table t1; +# Concurrent CREATE TABLE LIKE +create table t3 (j char(5)); +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +--error ER_TABLE_EXISTS_ERROR +create table t1 like t3; +connection default; +--reap +show create table t1; +drop table t1; +# Concurrent RENAME TABLE +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +--error ER_TABLE_EXISTS_ERROR +rename table t3 to t1; +connection default; +--reap +show create table t1; +drop table t1; +# Concurrent ALTER TABLE RENAME +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +--error ER_TABLE_EXISTS_ERROR +alter table t3 rename to t1; +connection default; +--reap +show create table t1; +drop table t1; +# Concurrent ALTER TABLE RENAME which also adds column +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +--error ER_TABLE_EXISTS_ERROR +alter table t3 rename to t1, add k int; +connection default; +--reap +show create table t1; +drop table t1, t3; +# What happens if other statement sneaks in after the table +# creation but before its opening ? +set session debug="-d,sleep_create_select_before_create:+d,sleep_create_select_before_open"; +# Concurrent DROP TABLE +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +drop table t1; +connection default; +--reap +# Concurrent RENAME TABLE +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +rename table t1 to t2; +connection default; +--reap +drop table t2; +# Concurrent SELECT +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +select * from t1; +connection default; +--reap +drop table t1; +# Concurrent INSERT +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +insert into t1 values (2); +connection default; +--reap +select * from t1; +drop table t1; +# Concurrent CREATE TRIGGER +set @a:=0; +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +create trigger t1_bi before insert on t1 for each row set @a:=1; +connection default; +--reap +select @a; +drop table t1; +# Okay, now the same tests for the potential gap between open and lock +set session debug="-d,sleep_create_select_before_open:+d,sleep_create_select_before_lock"; +# Concurrent DROP TABLE +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +drop table t1; +connection default; +--reap +# Concurrent RENAME TABLE +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +rename table t1 to t2; +connection default; +--reap +drop table t2; +# Concurrent SELECT +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +select * from t1; +connection default; +--reap +drop table t1; +# Concurrent INSERT +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +insert into t1 values (2); +connection default; +--reap +select * from t1; +drop table t1; +# Concurrent CREATE TRIGGER +set @a:=0; +--send create table t1 select 1 as i; +connection addconroot1; +--sleep 2 +create trigger t1_bi before insert on t1 for each row set @a:=1; +connection default; +--reap +select @a; +drop table t1; +# Some tests for case with existing table +set session debug="-d,sleep_create_select_before_lock:+d,sleep_create_select_before_check_if_exists"; +create table t1 (i int); +# Concurrent DROP TABLE +--send create table if not exists t1 select 1 as i; +connection addconroot1; +--sleep 2 +drop table t1; +connection default; +--reap +# Concurrent CREATE TRIGGER +create table t1 (i int); +set @a:=0; +--send create table if not exists t1 select 1 as i; +connection addconroot1; +--sleep 2 +create trigger t1_bi before insert on t1 for each row set @a:=1; +connection default; +--reap +select @a; +select * from t1; +drop table t1; +set session debug="-d,sleep_create_select_before_check_if_exists"; + + +# Test for some details of CREATE TABLE ... SELECT implementation. +# +# We check that create placeholder is handled properly if we have +# to reopen tables in open_tables(). +# This test heavily relies on current implementation of name-locking/ +# table cache so it may stop working if it changes. OTOH it such problem +# will serve as warning that such changes should not be done lightly. +create table t2 (a int); +create table t4 (b int); +connection addconroot2; +lock table t4 write; +select 1; +connection addconroot1; +# Create placeholder/name-lock for t3 +--send create table t3 as select * from t4; +--sleep 2 +connection default; +# This statement creates placeholder for t1, then opens t2, +# then meets name-lock for t3 and then reopens all tables +--send create table t1 select * from t2, t3; +--sleep 2 +connection addconroot2; +unlock tables; +connection addconroot1; +--reap +connection default; +--reap +select * from t1; +show create table t1; +drop table t1, t3; +# Now similar test which proves that we really temporarily +# remove placeholder when we reopen tables. +connection addconroot2; +lock table t4 read; +select 1; +connection addconroot1; +# Create name-lock for t3 +--send rename table t4 to t3; +--sleep 2 +connection default; +# This statement creates placeholder for t1, then opens t2, +# then meets name-lock for t3 and then reopens all tables +--send create table if not exists t1 select 1 as i from t2, t3; +--sleep 2 +connection addconroot3; +# We should be able to take name-lock on table t1 as we should not have +# open placeholder for it at this point (otherwise it is possible to +# come-up with situation which will lead to deadlock, e.g. think of +# concurrent CREATE TABLE t1 SELECT * FROM t2 and RENAME TABLE t2 TO t1) +create table t5 (j int); +# This statement takes name-lock on t1 and therefore proves +# that there is no active open placeholder for it. +rename table t5 to t1; +connection addconroot2; +unlock tables; +connection addconroot1; +--reap +connection default; +--reap +select * from t1; +show create table t1; +drop table t1, t2, t3; + + +# Tests for possible concurrency issues with CREATE TABLE ... LIKE +# +# Bug #18950 "create table like does not obtain LOCK_open" +# Bug #23667 "CREATE TABLE LIKE is not isolated from alteration by other +# connections" +# +# Again the idea of this test is that we introduce artificial delays on +# various stages of table creation and check that concurrent statements +# for tables from CREATE TABLE ... LIKE are not interfering. + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +# What happens if some statements sneak in right after we have +# opened source table ? +create table t1 (i int); +set session debug="+d,sleep_create_like_before_check_if_exists"; +# Reset binlog to have clear start +reset master; +--send create table t2 like t1; +connection addconroot1; +--sleep 2 +# DML on source table should be allowed to run concurrently +insert into t1 values (1); +# And DDL should wait +drop table t1; +connection default; +--reap +show create table t2; +drop table t2; +# Let us check that statements were executed/binlogged in correct order +--replace_column 2 # 5 # +show binlog events in 'master-bin.000001' from 106; + +# Now let us check the gap between check for target table +# existance and copying of .frm file. +create table t1 (i int); +set session debug="-d,sleep_create_like_before_check_if_exists:+d,sleep_create_like_before_copy"; +# It should be impossible to create target table concurrently +--send create table t2 like t1; +connection addconroot1; +--sleep 2 +create table if not exists t2 (j int); +connection default; +--reap +show create table t2; +drop table t2; +# And concurrent DDL on the source table should be still disallowed +reset master; +--send create table t2 like t1; +connection addconroot1; +--sleep 2 +drop table t1; +connection default; +--reap +drop table t2; +--replace_column 2 # 5 # +show binlog events in 'master-bin.000001' from 106; + +# And now he gap between copying of .frm file and ha_create_table() call. +create table t1 (i int); +set session debug="-d,sleep_create_like_before_copy:+d,sleep_create_like_before_ha_create"; +# Both DML and DDL on target table should wait till operation completes +reset master; +--send create table t2 like t1; +connection addconroot1; +--sleep 2 +insert into t2 values (1); +connection default; +--reap +drop table t2; +--send create table t2 like t1; +connection addconroot1; +--sleep 2 +drop table t2; +connection default; +--reap +# Concurrent DDL on the source table still waits +--send create table t2 like t1; +connection addconroot1; +--sleep 2 +drop table t1; +connection default; +--reap +drop table t2; +--replace_column 2 # 5 # +show binlog events in 'master-bin.000001' from 106; + +# Finally we check the gap between ha_create_table() and binlogging +create table t1 (i int); +set session debug="-d,sleep_create_like_before_ha_create:+d,sleep_create_like_before_binlogging"; +reset master; +--send create table t2 like t1; +connection addconroot1; +--sleep 2 +insert into t2 values (1); +connection default; +--reap +drop table t2; +--send create table t2 like t1; +connection addconroot1; +--sleep 2 +drop table t2; +connection default; +--reap +--send create table t2 like t1; +connection addconroot1; +--sleep 2 +drop table t1; +connection default; +--reap +drop table t2; +--replace_column 2 # 5 # +show binlog events in 'master-bin.000001' from 106; + +set session debug="-d,sleep_create_like_before_binlogging"; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 2ec416cfc87..5ffa1b93929 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -41,8 +41,11 @@ create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null -- error 1049 create table not_existing_database.test (a int); ---error 1103 create table `a/a` (a int); +show create table `a/a`; +create table t1 like `a/a`; +drop table `a/a`; +drop table `t1`; --error 1103 create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int); --error 1059 @@ -150,7 +153,7 @@ drop table if exists t1,t2; CREATE TABLE t1 (a int not null); INSERT INTO t1 values (1),(2),(1); ---error 1062 +--error ER_DUP_ENTRY CREATE TABLE t2 (primary key(a)) SELECT * FROM t1; --error 1146 SELECT * from t2; @@ -223,13 +226,16 @@ drop table t1; # Test create table if not exists with duplicate key error # +flush status; create table t1 (a int not null, b int, primary key (a)); insert into t1 values (1,1); create table if not exists t1 select 2; select * from t1; create table if not exists t1 select 3 as 'a',4 as 'b'; ---error 1062 +--error ER_DUP_ENTRY create table if not exists t1 select 3 as 'a',3 as 'b'; +show warnings; +show status like "Opened_tables"; select * from t1; drop table t1; @@ -300,12 +306,10 @@ create table t3 like t1; create table t3 like mysqltest.t3; --error 1049 create table non_existing_database.t1 like t1; ---error 1051 +--error ER_NO_SUCH_TABLE create table t3 like non_existing_table; --error 1050 create temporary table t3 like t1; ---error 1103 -create table t3 like `a/a`; drop table t1, t2, t3; drop table t3; drop database mysqltest; @@ -479,7 +483,7 @@ drop table t1,t2; create table t1 (a int); --error 1093 create table t1 select * from t1; ---error 1093 +--error ER_WRONG_OBJECT create table t2 union = (t1) select * from t1; flush tables with read lock; unlock tables; @@ -1213,3 +1217,368 @@ DROP VIEW v1; DROP TABLE t1,t2; --echo End of 5.0 tests + +# +# Test of behaviour with CREATE ... SELECT +# + +CREATE TABLE t1 (a int, b int); +insert into t1 values (1,1),(1,2); +--error ER_DUP_ENTRY +CREATE TABLE t2 (primary key (a)) select * from t1; +# This should give warning +drop table if exists t2; +--error ER_DUP_ENTRY +CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1; +# This should give warning +drop table if exists t2; +CREATE TABLE t2 (a int, b int, primary key (a)); +--error ER_DUP_ENTRY +CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; +SELECT * from t2; +TRUNCATE table t2; +--error ER_DUP_ENTRY +INSERT INTO t2 select * from t1; +SELECT * from t2; +drop table t2; + +CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)); +--error ER_DUP_ENTRY +CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1; +SELECT * from t2; +TRUNCATE table t2; +--error ER_DUP_ENTRY +INSERT INTO t2 select * from t1; +SELECT * from t2; +drop table t1,t2; + + +# +# Test incorrect database names +# + +--error 1102 +CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +--error 1102 +DROP DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; + +# TODO: enable these tests when RENAME DATABASE is implemented. +# --error 1049 +# RENAME DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa TO a; +# --error 1102 +# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +# create database mysqltest; +# --error 1102 +# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +# drop database mysqltest; + +--error 1102 +USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +--error 1102 +SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; + +# +# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte +# +set names utf8; + +create database имя_базы_в_кодировке_утф8_длиной_больше_чем_45; +use имя_базы_в_кодировке_утф8_длиной_больше_чем_45; +select database(); +use test; + +select SCHEMA_NAME from information_schema.schemata +where schema_name='имя_базы_в_кодировке_утф8_длиной_больше_чем_45'; + +drop database имя_базы_в_кодировке_утф8_длиной_больше_чем_45; +create table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 +( + имя_поля_в_кодировке_утф8_длиной_больше_чем_45 int, + index имя_индекса_в_кодировке_утф8_длиной_больше_чем_48 (имя_поля_в_кодировке_утф8_длиной_больше_чем_45) +); + +create view имя_вью_кодировке_утф8_длиной_больше_чем_42 as +select имя_поля_в_кодировке_утф8_длиной_больше_чем_45 +from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48; + +# database, table, field, key, view +select * from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48; + +select TABLE_NAME from information_schema.tables where +table_schema='test'; + +select COLUMN_NAME from information_schema.columns where +table_schema='test'; + +select INDEX_NAME from information_schema.statistics where +table_schema='test'; + +select TABLE_NAME from information_schema.views where +table_schema='test'; + +show create table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48; +show create view имя_вью_кодировке_утф8_длиной_больше_чем_42; + +create trigger имя_триггера_в_кодировке_утф8_длиной_больше_чем_49 +before insert on имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 for each row set @a:=1; +select TRIGGER_NAME from information_schema.triggers where +trigger_schema='test'; +drop trigger имя_триггера_в_кодировке_утф8_длиной_больше_чем_49; +--error 1059 +create trigger +очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66 +before insert on имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 for each row set @a:=1; +--error 1059 +drop trigger очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66; + +create procedure имя_процедуры_в_кодировке_утф8_длиной_больше_чем_50() +begin +end; +select ROUTINE_NAME from information_schema.routines where +routine_schema='test'; +drop procedure имя_процедуры_в_кодировке_утф8_длиной_больше_чем_50; +--error 1059 +create procedure очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66() +begin +end; + +create function имя_функции_в_кодировке_утф8_длиной_больше_чем_49() + returns int +return 0; +select ROUTINE_NAME from information_schema.routines where +routine_schema='test'; +drop function имя_функции_в_кодировке_утф8_длиной_больше_чем_49; +--error 1059 +create function очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66() + returns int +return 0; + +drop view имя_вью_кодировке_утф8_длиной_больше_чем_42; +drop table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48; +set names default; + +# +# Bug#21136 CREATE TABLE SELECT within CREATE TABLE SELECT causes server crash +# + +--disable_warnings +drop table if exists t1,t2,t3; +drop function if exists f1; +--enable_warnings + +--delimiter | +create function f1() returns int +begin + declare res int; + create temporary table t3 select 1 i; + set res:= (select count(*) from t1); + drop temporary table t3; + return res; +end| +--delimiter ; +create table t1 as select 1; +create table t2 as select f1() from t1; +drop table t1,t2; +drop function f1; + +# +# Bug#25629 CREATE TABLE LIKE does not work with INFORMATION_SCHEMA +# +create table t1 like information_schema.processlist; +show create table t1; +drop table t1; +create temporary table t1 like information_schema.processlist; +show create table t1; +drop table t1; +create table t1 like information_schema.character_sets; +show create table t1; +drop table t1; + +########################################################################### + +--echo +--echo # -- +--echo # -- Bug#21380: DEFAULT definition not always transfered by CREATE +--echo # -- TABLE/SELECT to the new table. +--echo # -- +--echo + + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings + +--echo + +CREATE TABLE t1( + c1 INT DEFAULT 12 COMMENT 'column1', + c2 INT NULL COMMENT 'column2', + c3 INT NOT NULL COMMENT 'column3', + c4 VARCHAR(255) CHARACTER SET utf8 NOT NULL DEFAULT 'a', + c5 VARCHAR(255) COLLATE utf8_unicode_ci NULL DEFAULT 'b', + c6 VARCHAR(255)) + COLLATE latin1_bin; + +--echo + +SHOW CREATE TABLE t1; + +--echo + +CREATE TABLE t2 AS SELECT * FROM t1; + +--echo + +SHOW CREATE TABLE t2; + +--echo + +DROP TABLE t2; +DROP TABLE t1; + +--echo +--echo # -- End of test case for Bug#21380. + +########################################################################### + +--echo +--echo # -- +--echo # -- Bug#18834: ALTER TABLE ADD INDEX on table with two timestamp fields +--echo # -- +--echo + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +--enable_warnings + +--echo + +CREATE TABLE t1(c1 TIMESTAMP, c2 TIMESTAMP); + +--echo + +SET sql_mode = NO_ZERO_DATE; + +--echo +--error ER_INVALID_DEFAULT +CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT 0); + +--echo +--error ER_INVALID_DEFAULT +CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP); + +--echo +--echo # -- Check that NULL column still can be created. +CREATE TABLE t2(c1 TIMESTAMP NULL); + +--echo +--echo # -- Check ALTER TABLE. +--error ER_INVALID_DEFAULT +ALTER TABLE t1 ADD INDEX(c1); + +--echo +--echo # -- Check DATETIME. +SET sql_mode = ''; + +--echo + +CREATE TABLE t3(c1 DATETIME NOT NULL); +INSERT INTO t3 VALUES (0); + +--echo +SET sql_mode = TRADITIONAL; + +--echo +--error ER_TRUNCATED_WRONG_VALUE +ALTER TABLE t3 ADD INDEX(c1); + +--echo +--echo # -- Cleanup. + +SET sql_mode = ''; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; + +--echo +--echo # -- End of Bug#18834. + +########################################################################### + +--echo +--echo # -- +--echo # -- Bug#34274: Invalid handling of 'DEFAULT 0' for YEAR data type. +--echo # -- +--echo + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo +CREATE TABLE t1(c1 YEAR DEFAULT 2008, c2 YEAR DEFAULT 0); + +--echo +SHOW CREATE TABLE t1; + +--echo +INSERT INTO t1 VALUES(); + +--echo +SELECT * FROM t1; + +--echo +ALTER TABLE t1 MODIFY c1 YEAR DEFAULT 0; + +--echo +SHOW CREATE TABLE t1; + +--echo +INSERT INTO t1 VALUES(); + +--echo +SELECT * FROM t1; + +--echo +DROP TABLE t1; + +--echo +--echo # -- End of Bug#34274 + +########################################################################### + +# +# Bug#40104 regression with table names? +# +create table `me:i`(id int); +drop table `me:i`; + +########################################################################### + +# +# Bug#45829 CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing +# + +--echo +--echo # -- +--echo # -- Bug#45829: CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing +--echo # -- +--echo + +--disable_warnings +drop table if exists t1,t2,t3; +--enable_warnings +--error ER_PARSE_ERROR +create table t1 (a int) transactional=0; +--error ER_PARSE_ERROR +create table t2 (a int) page_checksum=1; +--error ER_PARSE_ERROR +create table t3 (a int) row_format=page; +--echo +--echo # -- End of Bug#45829 + +--echo +--echo End of 5.1 tests diff --git a/mysql-test/t/create_not_windows.test b/mysql-test/t/create_not_windows.test index 7e51ff51024..b612e31e3aa 100644 --- a/mysql-test/t/create_not_windows.test +++ b/mysql-test/t/create_not_windows.test @@ -19,3 +19,25 @@ drop table `about:text`; # End of 5.0 tests + +# +# Bug#16532:mysql server assert in debug if table det is removed +# +use test; +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1(a int) engine=myisam; +insert into t1 values(1); +let $MYSQLD_DATADIR= `select @@datadir`; +remove_file $MYSQLD_DATADIR/test/t1.frm; +--echo "We get an error because the table is in the definition cache" +--error ER_TABLE_EXISTS_ERROR +create table t1(a int, b int); +--echo "Flush the cache and recreate the table anew to be able to drop it" +flush tables; +show open tables like "t%"; +create table t1(a int, b int, c int); +--echo "Try to select from the table. This should not crash the server" +select count(a) from t1; +drop table t1; diff --git a/mysql-test/t/create_select_tmp.test b/mysql-test/t/create_select_tmp.test index c527548e282..a61f9f2466c 100644 --- a/mysql-test/t/create_select_tmp.test +++ b/mysql-test/t/create_select_tmp.test @@ -5,25 +5,28 @@ # binlog if it was a transactional table, it resulted in an # inconsistency between binlog and the internal list of temp tables. +# This does not work for RBR yet. +--source include/have_binlog_format_mixed_or_statement.inc + -- source include/have_innodb.inc --disable_warnings drop table if exists t1, t2; --enable_warnings CREATE TABLE t1 ( a int ); INSERT INTO t1 VALUES (1),(2),(1); ---error 1062 +--error ER_DUP_ENTRY CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; --error 1146 select * from t2; ---error 1062 +--error ER_DUP_ENTRY CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; --error 1146 select * from t2; ---error 1062 +--error ER_DUP_ENTRY CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; --error 1146 select * from t2; ---error 1062 +--error ER_DUP_ENTRY CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; --error 1146 select * from t2; diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 72d61fc7781..cdf274190dd 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -2,7 +2,7 @@ # Test for the CSV engine # --- source include/have_csv.inc +--source include/have_csv.inc # # Simple select test @@ -1322,7 +1322,7 @@ drop table if exists t1,t2,t3,t4; DROP TABLE IF EXISTS bug13894; --enable_warnings -CREATE TABLE bug13894 ( val integer ) ENGINE = CSV; +CREATE TABLE bug13894 ( val integer not null ) ENGINE = CSV; INSERT INTO bug13894 VALUES (5); INSERT INTO bug13894 VALUES (10); INSERT INTO bug13894 VALUES (11); @@ -1340,7 +1340,7 @@ DROP TABLE bug13894; DROP TABLE IF EXISTS bug14672; --enable_warnings -CREATE TABLE bug14672 (c1 integer) engine = CSV; +CREATE TABLE bug14672 (c1 integer not null) engine = CSV; INSERT INTO bug14672 VALUES (1), (2), (3); SELECT * FROM bug14672; DELETE FROM bug14672 WHERE c1 = 2; @@ -1354,10 +1354,174 @@ DROP TABLE bug14672; # End of 4.1 tests # +# Test CONCURRENT INSERT (5.1) +# + +CREATE TABLE test_concurrent_insert ( val integer not null ) ENGINE = CSV; + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); + +connection con1; +# obtain TL_READ lock on the table +LOCK TABLES test_concurrent_insert READ LOCAL; + +connection con2; +# should pass despite of the lock +INSERT INTO test_concurrent_insert VALUES (1); +SELECT * FROM test_concurrent_insert; + +connection con1; +# first connection should not notice the changes +SELECT * FROM test_concurrent_insert; + +UNLOCK TABLES; + +# Now check that we see our own changes + +LOCK TABLES test_concurrent_insert WRITE; +INSERT INTO test_concurrent_insert VALUES (2); +SELECT * FROM test_concurrent_insert; +UNLOCK TABLES; + +# cleanup +DROP TABLE test_concurrent_insert; +connection default; +--disconnect con1 +--disconnect con2 + +# +# Test REPAIR/CHECK TABLE (5.1) +# + +# Check that repair on the newly created table works fine + +CREATE TABLE test_repair_table ( val integer not null ) ENGINE = CSV; + +CHECK TABLE test_repair_table; +REPAIR TABLE test_repair_table; + +DROP TABLE test_repair_table; + +# +# Check autorepair. Here we also check that we can work w/o metafile +# restore the meta-file +# + +CREATE TABLE test_repair_table2 ( val integer not null ) ENGINE = CSV; +let $MYSQLD_DATADIR= `select @@datadir`; +--remove_file $MYSQLD_DATADIR/test/test_repair_table2.CSM + +# Should give a warning and perform autorepair. We also disable ps-protocol +# here, as mysql-test eats up warnings in ps-protocol mode + +--disable_ps_protocol +SELECT * from test_repair_table2; +--enable_ps_protocol +# this should work ok, as the table is already repaired +SELECT * from test_repair_table2; +# check that the metafile appeared again. +--file_exists $MYSQLD_DATADIR/test/test_repair_table2.CSM +CHECK TABLE test_repair_table2; +DROP TABLE test_repair_table2; + + +# Corrupt csv file and see if we can repair it +CREATE TABLE test_repair_table3 ( val integer not null ) ENGINE = CSV; +--remove_file $MYSQLD_DATADIR/test/test_repair_table3.CSV +--write_file $MYSQLD_DATADIR/test/test_repair_table3.CSV +"1" +"4" +"3 +EOF +CHECK TABLE test_repair_table3; +REPAIR TABLE test_repair_table3; +SELECT * FROM test_repair_table3; +DROP TABLE test_repair_table3; + +# Test with more sophisticated table + +CREATE TABLE test_repair_table4 ( + num int not null, + magic_no int(4) unsigned zerofill DEFAULT '0000' NOT NULL, + company_name char(30) DEFAULT '' NOT NULL, + founded char(4) DEFAULT '' NOT NULL +) ENGINE = CSV; + +--remove_file $MYSQLD_DATADIR/test/test_repair_table4.CSM +--disable_ps_protocol +SELECT * FROM test_repair_table4; +--enable_ps_protocol +SELECT * FROM test_repair_table4; +CHECK TABLE test_repair_table4; + +INSERT INTO test_repair_table4 VALUES (2,101,'SAP','1972'); +INSERT INTO test_repair_table4 VALUES (1,101,'Microsoft','1978'); +INSERT INTO test_repair_table4 VALUES (2,101,'MySQL','1995'); + +# list table content +SELECT * FROM test_repair_table4; +CHECK TABLE test_repair_table4; +REPAIR TABLE test_repair_table4; +# check that nothing changed +SELECT * FROM test_repair_table4; +# verify that check/repair did non corrupt the table itself +CHECK TABLE test_repair_table4; +REPAIR TABLE test_repair_table4; +SELECT * FROM test_repair_table4; +DROP TABLE test_repair_table4; + +# Run CHECK/REPAIR on the CSV file with a single row, which misses a column. + +CREATE TABLE test_repair_table5 ( + num int not null, + magic_no int(4) unsigned zerofill DEFAULT '0000' NOT NULL, + company_name char(30) DEFAULT '' NOT NULL, + founded char(4) DEFAULT '' NOT NULL +) ENGINE = CSV; + +# Corrupt a table -- put a file with wrong # of columns +--remove_file $MYSQLD_DATADIR/test/test_repair_table5.CSV +--write_file $MYSQLD_DATADIR/test/test_repair_table5.CSV +"1","101","IBM" +EOF + +CHECK TABLE test_repair_table5; +REPAIR TABLE test_repair_table5; +SELECT * FROM test_repair_table5; +INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT", 1876); +SELECT * FROM test_repair_table5; + +# Corrupt a table -- put a row with wrong # of columns at end of file +--append_file $MYSQLD_DATADIR/test/test_repair_table5.CSV +"1","101","IBM" +EOF + +FLUSH TABLES; +CHECK TABLE test_repair_table5; +REPAIR TABLE test_repair_table5; +# The correct record inserted should still be in the file +SELECT * FROM test_repair_table5; +INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT2", 1876); +SELECT * FROM test_repair_table5; + +# Corrupt table again -- put a row with wrong # of columns at end of file +--append_file $MYSQLD_DATADIR/test/test_repair_table5.CSV +"1","101","IBM" +EOF + +FLUSH TABLES; +CHECK TABLE test_repair_table5; +REPAIR TABLE test_repair_table5; +# The two correct records inserted should still be in the file +SELECT * FROM test_repair_table5; +DROP TABLE test_repair_table5; + +# # BUG#13406 - incorrect amount of "records deleted" # -create table t1 (a int) engine=csv; +create table t1 (a int not null) engine=csv; insert t1 values (1); --enable_info delete from t1; # delete_row @@ -1385,6 +1549,33 @@ truncate table t1; # truncate drop table t1; # +# Some additional tests for new, faster alter table. Note that most of the +# whole alter table code is being tested all around the test suite already. +# + +create table t1 (v varchar(32) not null); +insert into t1 values ('def'),('abc'),('hij'),('3r4f'); +select * from t1; +# Fast alter, no copy performed +alter table t1 change v v2 varchar(32); +select * from t1; +# Fast alter, no copy performed +alter table t1 change v2 v varchar(64); +select * from t1; +update t1 set v = 'lmn' where v = 'hij'; +select * from t1; +# Regular alter table +alter table t1 add i int auto_increment not null primary key first; +select * from t1; +update t1 set i=5 where i=3; +select * from t1; +alter table t1 change i i bigint; +select * from t1; +alter table t1 add unique key (i, v); +select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); +drop table t1; + +# # Bug #15205 Select from CSV table without the datafile causes crash # # NOTE: the bug is not deterministic @@ -1396,27 +1587,29 @@ drop table t1; # resulted in scanning through deleted memory and we were geting a crash. # that's why we need two tables in the bugtest -create table bug15205 (val int(11) default null) engine=csv; -create table bug15205_2 (val int(11) default null) engine=csv; ---remove_file $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV +create table bug15205 (val int(11) not null) engine=csv; +create table bug15205_2 (val int(11) not null) engine=csv; +--remove_file $MYSQLD_DATADIR/test/bug15205.CSV # system error (can't open the datafile) ---error ER_GET_ERRNO +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' +--error 13 select * from bug15205; select * from bug15205_2; # Create empty file ---write_file $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV +--write_file $MYSQLD_DATADIR/test/bug15205.CSV EOF select * from bug15205; drop table bug15205; drop table bug15205_2; + # # Bug#28862 "Extended Latin1 characters get lost in CVS engine" # set names latin1; create table t1 ( - c varchar(1), - name varchar(64) + c varchar(1) not null, + name varchar(64) not null ) character set latin1 engine=csv; insert into t1 values (0xC0,'LATIN CAPITAL LETTER A WITH GRAVE'); insert into t1 values (0xE0,'LATIN SMALL LETTER A WITH GRAVE'); @@ -1427,80 +1620,203 @@ insert into t1 values (0xFF,'LATIN SMALL LETTER Y WITH DIAERESIS'); select hex(c), c, name from t1 order by 1; drop table t1; +--echo End of 5.0 tests + + +# +# Bug#22080 "CHECK fails to identify some corruption" +# + +create table bug22080_1 (id int not null,string varchar(64) not null) Engine=CSV; +create table bug22080_2 (id int not null,string varchar(64) not null) Engine=CSV; +create table bug22080_3 (id int not null,string varchar(64) not null) Engine=CSV; +insert into bug22080_1 values(1,'string'); +insert into bug22080_1 values(2,'string'); +insert into bug22080_1 values(3,'string'); + +# Create first corrupt file as described in bug report +--remove_file $MYSQLD_DATADIR/test/bug22080_2.CSV +--write_file $MYSQLD_DATADIR/test/bug22080_2.CSV +1,"string" +2","string" +3,"string" +EOF + +# Create second corrupt file as described in bug report +--remove_file $MYSQLD_DATADIR/test/bug22080_3.CSV +--write_file $MYSQLD_DATADIR/test/bug22080_3.CSV +1,"string" +"2",string" +3,"string" +EOF + +check table bug22080_2; + +check table bug22080_3; + +drop tables bug22080_1,bug22080_2,bug22080_3; + +# +# Testing float type +# +create table float_test (id float not null,string varchar(64) not null) Engine=CSV; +insert into float_test values(1.0,'string'); +insert into float_test values(2.23,'serg.g'); +insert into float_test values(0.03,'string'); +insert into float_test values(0.19,'string'); +insert into float_test values(.67,'string'); +insert into float_test values(9.67,'string'); +select * from float_test; + +drop table float_test; +# +# Bug #21328 mysqld issues warnings on ALTER CSV table to MyISAM +# + +CREATE TABLE `bug21328` ( + `col1` int(11) NOT NULL, + `col2` int(11) NOT NULL, + `col3` int(11) NOT NULL +) ENGINE=CSV; + +insert into bug21328 values (1,0,0); +alter table bug21328 engine=myisam; +drop table bug21328; + +# +# BUG#28971 - ALTER TABLE followed by UPDATE for a CSV table make server +# crash +# +create table t1(a blob not null, b int not null) engine=csv; +insert into t1 values('a', 1); +flush tables; +update t1 set b=2; +select * from t1; +drop table t1; + +# +# Bug #29353: negative values +# +create table t1(a int not null) engine=csv; +insert into t1 values(-1), (-123.34), (2), (-23); +select * from t1; +check table t1; +drop table t1; + +create table t1(a int not null, b int not null) engine=csv; +--remove_file $MYSQLD_DATADIR/test/t1.CSV +--write_file $MYSQLD_DATADIR/test/t1.CSV +1, 1E-2 +-2E2, .9 +-10E-1, -.9 +-1, -100.1 +1a, -2b +EOF +repair table t1; +check table t1; +select * from t1; +check table t1; +drop table t1; + +# +# Bug #29411: deleting from a csv table leads to the table corruption +# +create table t1(a int not null) engine=csv; +insert into t1 values (0), (1), (2); +delete from t1 limit 2; +check table t1; +select * from t1; +delete from t1; +check table t1; +select * from t1; +drop table t1; + # # Bug #31473: does not work with NULL value in datetime field -# This bug is a 5.1 but is here to prevent 5.0 regression. # -create table t1(a datetime) engine=csv; +create table t1(a datetime not null) engine=csv; insert into t1 values(); select * from t1; drop table t1; -create table t1(a set('foo','bar')) engine=csv; +create table t1(a set('foo','bar') not null) engine=csv; insert into t1 values(); select * from t1; drop table t1; -create table t1(a varchar(32)) engine=csv; +create table t1(a varchar(32) not null) engine=csv; insert into t1 values(); select * from t1; drop table t1; -create table t1(a int) engine=csv; +create table t1(a int not null) engine=csv; insert into t1 values(); select * from t1; drop table t1; -create table t1(a blob) engine=csv; +create table t1(a blob not null) engine=csv; insert into t1 values(); select * from t1; drop table t1; -create table t1(a bit(1)) engine=csv; +create table t1(a bit(1) not null) engine=csv; insert into t1 values(); select BIN(a) from t1; drop table t1; +# We prevent creation of table with nullable ENUM +--error ER_CHECK_NOT_IMPLEMENTED +create table t1(a enum('foo','bar') default null) engine=csv; +--error ER_CHECK_NOT_IMPLEMENTED create table t1(a enum('foo','bar') default 'foo') engine=csv; +# Enum columns must be specified as NOT NULL +create table t1(a enum('foo','bar') default 'foo' not null) engine=csv; insert into t1 values(); select * from t1; drop table t1; # -# Bug #39616 Missing quotes from .CSV crashes server -# -# Editing the .CSV file and leaving out quotes from around an integer field -# crashes the server. +# BUG#32817 - though CSV is marked as supported create table is rejected +# with error 1005. # +--error ER_CHECK_NOT_IMPLEMENTED +CREATE TABLE t1(a INT) ENGINE=CSV; +SHOW WARNINGS; # -# Test for the integers and strings enclosed in quotes, not enclosed in quotes, -# \X characters. +# BUG#33067 - . # -create table bug39616_1(id int NOT NULL, d varchar(50) NOT NULL) ENGINE=csv; - ---remove_file $MYSQLTEST_VARDIR/master-data/test/bug39616_1.CSV ---write_file $MYSQLTEST_VARDIR/master-data/test/bug39616_1.CSV -1,"integer sans quotes" -1,string sans quotes -1,string end quotes" -1,quotes"in between" strings -"1",Integer with quote and string with no quote -1,"escape sequence \n \" \\ \r \a within quotes" -EOF - -select * from bug39616_1; - -drop table bug39616_1; +create table t1 (c1 tinyblob not null) engine=csv; +insert into t1 values("This"); +--enable_info +update t1 set c1="That" where c1="This"; +--disable_info +select * from t1; +drop table t1; # -# Test for he case when a field begins with a quote, but does not end in a -# quote. -# Note: This results in an empty set. +# Bug#36638 mysqld crashes when open file limit is passed and general query log enabled # -create table bug39616_1(id int NOT NULL, d varchar(50) NOT NULL) ENGINE=csv; - ---remove_file $MYSQLTEST_VARDIR/master-data/test/bug39616_1.CSV ---write_file $MYSQLTEST_VARDIR/master-data/test/bug39616_1.CSV -1,"string only at the beginning quotes -EOF +create table t1 (a int not null) engine=csv; +lock tables t1 read; +connect (con1,localhost,root,,); +--connection con1 +--remove_file $MYSQLD_DATADIR/test/t1.CSV +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR/ ./ MYSQLD_DATADIR/ 13 2 +# EE_FILENOTFOUND 29 +--error 29 +select * from t1; +--disconnect con1 +--source include/wait_until_disconnected.inc +connection default; +unlock tables; +drop table t1; -select * from bug39616_1; +# +# Bug#41441 repair csv table crashes debug server +# +# Note: The test should be removed after Bug#33717 is fixed -drop table bug39616_1; +create table t1(a enum ('a') not null) engine=csv; +insert into t1 values (2); +--error ER_CRASHED_ON_USAGE +select * from t1 limit 1; +repair table t1; +select * from t1 limit 1; +drop table t1; ---echo End of 5.0 tests +--echo End of 5.1 tests diff --git a/mysql-test/t/csv_alter_table.test b/mysql-test/t/csv_alter_table.test new file mode 100644 index 00000000000..0093a1d10a7 --- /dev/null +++ b/mysql-test/t/csv_alter_table.test @@ -0,0 +1,56 @@ +#----------------------------------------------------------------------------- +# csv_alter_table.test - .test file for MySQL regression suite +# Purpose: To test the behavior of the CSV engine +# Bug#31473 resulted in strict enforcement of non-nullable +# columns in CSV engine. +# Tests code for Bug#33696 - CSV engine allows NULLable +# Columns via ALTER TABLE statements +# +# Author pcrews +# Last modified: 2008-01-06 +#----------------------------------------------------------------------------- + +--source include/have_csv.inc + +############################################################################# +# Testcase csv_alter_table.1: Positive test for ALTER table +# +############################################################################# +-- echo # ===== csv_alter_table.1 ===== +-- disable_warnings +DROP TABLE IF EXISTS t1; +-- enable_warnings + +CREATE TABLE t1 (a int NOT NULL) ENGINE = CSV; +ALTER TABLE t1 ADD COLUMN b CHAR(5) NOT NULL; +DESC t1; +ALTER TABLE t1 DROP COLUMN b; +DESC t1; +ALTER TABLE t1 MODIFY a BIGINT NOT NULL; +DESC t1; +ALTER TABLE t1 CHANGE a a INT NOT NULL; +DESC t1; + +DROP TABLE t1; + +############################################################################# +# Testcase csv_alter_table.2: Negative test for ALTER table +# These queries should not succeed / should throw errors +############################################################################# +-- echo # ===== csv_alter_table.2 ===== +-- disable_warnings +DROP TABLE IF EXISTS t1; +-- enable_warnings + +CREATE TABLE t1 (a int NOT NULL) ENGINE = CSV; +--error ER_CHECK_NOT_IMPLEMENTED +ALTER TABLE t1 ADD COLUMN b CHAR(5); +DESC t1; +--error ER_CHECK_NOT_IMPLEMENTED +ALTER TABLE t1 MODIFY a BIGINT; +DESC t1; +--error ER_CHECK_NOT_IMPLEMENTED +ALTER TABLE t1 CHANGE a a INT; +DESC t1; + +DROP TABLE t1; diff --git a/mysql-test/t/csv_not_null.test b/mysql-test/t/csv_not_null.test new file mode 100644 index 00000000000..03ed566fb22 --- /dev/null +++ b/mysql-test/t/csv_not_null.test @@ -0,0 +1,99 @@ +#----------------------------------------------------------------------------- +# csv_not_null.test - .test file for MySQL regression suite +# Purpose: To test the behavior of the CSV engine +# Bug#31473 resulted in strict enforcement of non-nullable +# columns in CSV engine. +# NOTE: Main functionality tested - NOT NULL restrictions on CSV tables +# CREATE, INSERT, and UPDATE statements +# ALTER statements in separate file due to BUG#33696 +# Author pcrews +# Last modified: 2008-01-04 +#----------------------------------------------------------------------------- + +--source include/have_csv.inc + +############################################################################# +# Testcase csv_not_null.1: CREATE TABLE for CSV Engine requires explicit +# NOT NULL for each column +############################################################################# +-- echo # ===== csv_not_null.1 ===== +-- disable_warnings +DROP TABLE IF EXISTS t1, t2; +-- enable_warnings + + +--echo # === Will fail -- no NOT NULL === +--error ER_CHECK_NOT_IMPLEMENTED +CREATE TABLE t1 (a int) ENGINE = CSV; + +--echo # === Good CREATE === +CREATE TABLE t1 (a int NOT NULL) ENGINE = CSV; + +--echo # === Will fail -- ALL columns need NOT NULL == +--error ER_CHECK_NOT_IMPLEMENTED +CREATE TABLE t2 (a int NOT NULL, b char(20)) ENGINE = CSV; + + +DROP TABLE t1; +############################################################################## +# Testcase csv_not_null.2: INSERT tests -- validating behavior of INSERT +# statements for CSV +############################################################################## +-- echo # ===== csv_not_null.2 ===== +-- disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + + +CREATE TABLE t1 (a int NOT NULL, b blob NOT NULL, c CHAR(20) NOT NULL, +d VARCHAR(20) NOT NULL, e enum('foo','bar') NOT NULL,f DATE NOT NULL) +ENGINE = CSV; +-- echo # === should result in default for each datatype === +-- disable_warnings +INSERT INTO t1 VALUES(); +-- enable_warnings +SELECT * FROM t1; + +-- disable_warnings +# NOTE - Test disabled due to enum crash for this INSERT +# See Bug#33717 - INSERT...(default) fails for enum. +# Crashes CSV tables, loads spaces for MyISAM +#INSERT INTO t1 VALUES(default,default,default,default,default,default); +-- enable_warnings + +SELECT * FROM t1; +INSERT INTO t1 VALUES(0,'abc','def','ghi','bar','1999-12-31'); +SELECT * FROM t1; +-- echo # === insert failures === +--error ER_BAD_NULL_ERROR +INSERT INTO t1 VALUES(NULL,'ab','a','b','foo','2007-01-01'); +--error ER_NO_DEFAULT_FOR_FIELD +INSERT INTO t1 VALUES(default(a),default(b), default(c), default(d), + default(e), default(f)); + + +DROP TABLE t1; + +############################################################################## +# Testcase csv_not_null.3: UPDATE tests -- examining behavior of UPDATE +# statements for CSV +############################################################################## +-- echo # ===== csv_not_null.3 ===== +-- disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + + +CREATE TABLE t1 (a int NOT NULL, b char(10) NOT NULL) ENGINE = CSV; +--disable_warnings +INSERT INTO t1 VALUES(); +--enable_warnings +SELECT * FROM t1; +--disable_warnings +UPDATE t1 set b = 'new_value' where a = 0; +--enable_warnings +SELECT * FROM t1; +UPDATE t1 set b = NULL where b = 'new_value'; +SELECT * FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/t/ctype_big5.test b/mysql-test/t/ctype_big5.test index 5a8a13f2bad..a75fd917052 100644 --- a/mysql-test/t/ctype_big5.test +++ b/mysql-test/t/ctype_big5.test @@ -75,12 +75,12 @@ create table t1 (a blob); insert into t1 values (0xEE00); select * into outfile 'test/t1.txt' from t1; delete from t1; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---eval select hex(load_file('$MYSQLTEST_VARDIR/master-data/test/t1.txt')); +let $MYSQLD_DATADIR= `select @@datadir`; +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--eval select hex(load_file('$MYSQLD_DATADIR/test/t1.txt')); load data infile 't1.txt' into table t1; select hex(a) from t1; ---remove_file $MYSQLTEST_VARDIR/master-data/test/t1.txt - +--remove_file $MYSQLD_DATADIR/test/t1.txt drop table t1; --echo End of 5.0 tests diff --git a/mysql-test/t/ctype_cp1250_ch.test b/mysql-test/t/ctype_cp1250_ch.test index b3daa8a02a2..1fb656f2a01 100644 --- a/mysql-test/t/ctype_cp1250_ch.test +++ b/mysql-test/t/ctype_cp1250_ch.test @@ -1,4 +1,7 @@ -- source include/have_cp1250_ch.inc +--disable_warnings +drop table if exists t1; +--enable_warnings --disable_warnings DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test deleted file mode 100644 index 4042a973576..00000000000 --- a/mysql-test/t/ctype_cp932.test +++ /dev/null @@ -1,468 +0,0 @@ --- source include/have_cp932.inc - ---character_set cp932 ---disable_warnings -drop table if exists t1; -drop table if exists t2; -drop table if exists t3; -drop table if exists t4; ---enable_warnings - -SET @test_character_set= 'cp932'; -SET @test_collation= 'cp932_japanese_ci'; --- source include/ctype_common.inc - -set names cp932; -set character_set_database = cp932; - -CREATE TABLE t1(c1 CHAR(1)) DEFAULT CHARACTER SET = cp932; - -#Characters which are converted to Unicode ambiguously -INSERT INTO t1 VALUES -(0x05),(0x7E),(0x815C),(0x815F),(0x8160),(0x8161),(0x817C),(0x8191),(0x8192),(0x81CA); - -#NEC ROW 13 characters (0x8740 - 0x879C) -INSERT INTO t1 VALUES -(0x8740),(0x8741),(0x8742),(0x8743),(0x8744),(0x8745),(0x8746),(0x8747), -(0x8748),(0x8749),(0x874A),(0x874B),(0x874C),(0x874D),(0x874E),(0x874F), -(0x8750),(0x8751),(0x8752),(0x8753),(0x8754),(0x8755),(0x8756),(0x8757), -(0x8758),(0x8759),(0x875A),(0x875B),(0x875C),(0x875D),(0x875F), -(0x8760),(0x8761),(0x8762),(0x8763),(0x8764),(0x8765),(0x8766),(0x8767), -(0x8768),(0x8769),(0x876A),(0x876B),(0x876C),(0x876D),(0x876E),(0x876F), -(0x8770),(0x8771),(0x8772),(0x8773),(0x8774),(0x8775),(0x877E), -(0x8780),(0x8781),(0x8782),(0x8783),(0x8784),(0x8785),(0x8786),(0x8787), -(0x8788),(0x8789),(0x878A),(0x878B),(0x878C),(0x878D),(0x878E),(0x878F), -(0x8790),(0x8791),(0x8792),(0x8793),(0x8794),(0x8795),(0x8796),(0x8797), -(0x8798),(0x8799),(0x879A),(0x879B),(0x879C); - -#IBM selected characters kanji & non-kanji, NEC implementation (0xED40 - 0xEEFC) -INSERT INTO t1 VALUES -(0xED40),(0xED41),(0xED42),(0xED43),(0xED44),(0xED45),(0xED46),(0xED47), -(0xED48),(0xED49),(0xED4A),(0xED4B),(0xED4C),(0xED4D),(0xED4E),(0xED4F), -(0xED50),(0xED51),(0xED52),(0xED53),(0xED54),(0xED55),(0xED56),(0xED57), -(0xED58),(0xED59),(0xED5A),(0xED5B),(0xED5C),(0xED5D),(0xED5E),(0xED5F), -(0xED60),(0xED61),(0xED62),(0xED63),(0xED64),(0xED65),(0xED66),(0xED67), -(0xED68),(0xED69),(0xED6A),(0xED6B),(0xED6C),(0xED6D),(0xED6E),(0xED6F), -(0xED70),(0xED71),(0xED72),(0xED73),(0xED74),(0xED75),(0xED76),(0xED77), -(0xED78),(0xED79),(0xED7A),(0xED7B),(0xED7C),(0xED7D),(0xED7E), -(0xED80),(0xED81),(0xED82),(0xED83),(0xED84),(0xED85),(0xED86),(0xED87), -(0xED88),(0xED89),(0xED8A),(0xED8B),(0xED8C),(0xED8D),(0xED8E),(0xED8F), -(0xED90),(0xED91),(0xED92),(0xED93),(0xED94),(0xED95),(0xED96),(0xED97), -(0xED98),(0xED99),(0xED9A),(0xED9B),(0xED9C),(0xED9D),(0xED9E),(0xED9F), -(0xEDA0),(0xEDA1),(0xEDA2),(0xEDA3),(0xEDA4),(0xEDA5),(0xEDA6),(0xEDA7), -(0xEDA8),(0xEDA9),(0xEDAA),(0xEDAB),(0xEDAC),(0xEDAD),(0xEDAE),(0xEDAF), -(0xEDB0),(0xEDB1),(0xEDB2),(0xEDB3),(0xEDB4),(0xEDB5),(0xEDB6),(0xEDB7), -(0xEDB8),(0xEDB9),(0xEDBA),(0xEDBB),(0xEDBC),(0xEDBD),(0xEDBE),(0xEDBF), -(0xEDC0),(0xEDC1),(0xEDC2),(0xEDC3),(0xEDC4),(0xEDC5),(0xEDC6),(0xEDC7), -(0xEDC8),(0xEDC9),(0xEDCA),(0xEDCB),(0xEDCC),(0xEDCD),(0xEDCE),(0xEDCF), -(0xEDD0),(0xEDD1),(0xEDD2),(0xEDD3),(0xEDD4),(0xEDD5),(0xEDD6),(0xEDD7), -(0xEDD8),(0xEDD9),(0xEDDA),(0xEDDB),(0xEDDC),(0xEDDD),(0xEDDE),(0xEDDF), -(0xEDE0),(0xEDE1),(0xEDE2),(0xEDE3),(0xEDE4),(0xEDE5),(0xEDE6),(0xEDE7), -(0xEDE8),(0xEDE9),(0xEDEA),(0xEDEB),(0xEDEC),(0xEDED),(0xEDEE),(0xEDEF), -(0xEDF0),(0xEDF1),(0xEDF2),(0xEDF3),(0xEDF4),(0xEDF5),(0xEDF6),(0xEDF7), -(0xEDF8),(0xEDF9),(0xEDFA),(0xEDFB),(0xEDFC), -(0xEE40),(0xEE41),(0xEE42),(0xEE43),(0xEE44),(0xEE45),(0xEE46),(0xEE47), -(0xEE48),(0xEE49),(0xEE4A),(0xEE4B),(0xEE4C),(0xEE4D),(0xEE4E),(0xEE4F), -(0xEE50),(0xEE51),(0xEE52),(0xEE53),(0xEE54),(0xEE55),(0xEE56),(0xEE57), -(0xEE58),(0xEE59),(0xEE5A),(0xEE5B),(0xEE5C),(0xEE5D),(0xEE5E),(0xEE5F), -(0xEE60),(0xEE61),(0xEE62),(0xEE63),(0xEE64),(0xEE65),(0xEE66),(0xEE67), -(0xEE68),(0xEE69),(0xEE6A),(0xEE6B),(0xEE6C),(0xEE6D),(0xEE6E),(0xEE6F), -(0xEE70),(0xEE71),(0xEE72),(0xEE73),(0xEE74),(0xEE75),(0xEE76),(0xEE77), -(0xEE78),(0xEE79),(0xEE7A),(0xEE7B),(0xEE7C),(0xEE7D),(0xEE7E), -(0xEE80),(0xEE81),(0xEE82),(0xEE83),(0xEE84),(0xEE85),(0xEE86),(0xEE87), -(0xEE88),(0xEE89),(0xEE8A),(0xEE8B),(0xEE8C),(0xEE8D),(0xEE8E),(0xEE8F), -(0xEE90),(0xEE91),(0xEE92),(0xEE93),(0xEE94),(0xEE95),(0xEE96),(0xEE97), -(0xEE98),(0xEE99),(0xEE9A),(0xEE9B),(0xEE9C),(0xEE9D),(0xEE9E),(0xEE9F), -(0xEEA0),(0xEEA1),(0xEEA2),(0xEEA3),(0xEEA4),(0xEEA5),(0xEEA6),(0xEEA7), -(0xEEA8),(0xEEA9),(0xEEAA),(0xEEAB),(0xEEAC),(0xEEAD),(0xEEAE),(0xEEAF), -(0xEEB0),(0xEEB1),(0xEEB2),(0xEEB3),(0xEEB4),(0xEEB5),(0xEEB6),(0xEEB7), -(0xEEB8),(0xEEB9),(0xEEBA),(0xEEBB),(0xEEBC),(0xEEBD),(0xEEBE),(0xEEBF), -(0xEEC0),(0xEEC1),(0xEEC2),(0xEEC3),(0xEEC4),(0xEEC5),(0xEEC6),(0xEEC7), -(0xEEC8),(0xEEC9),(0xEECA),(0xEECB),(0xEECC),(0xEECD),(0xEECE),(0xEECF), -(0xEED0),(0xEED1),(0xEED2),(0xEED3),(0xEED4),(0xEED5),(0xEED6),(0xEED7), -(0xEED8),(0xEED9),(0xEEDA),(0xEEDB),(0xEEDC),(0xEEDD),(0xEEDE),(0xEEDF), -(0xEEE0),(0xEEE1),(0xEEE2),(0xEEE3),(0xEEE4),(0xEEE5),(0xEEE6),(0xEEE7), -(0xEEE8),(0xEEE9),(0xEEEA),(0xEEEB),(0xEEEC),(0xEEEF), -(0xEEF0),(0xEEF1),(0xEEF2),(0xEEF3),(0xEEF4),(0xEEF5),(0xEEF6),(0xEEF7), -(0xEEF8),(0xEEF9),(0xEEFA),(0xEEFB),(0xEEFC); - -#IBM selected kanji & non-kanji (0xFA40 - 0xFC4B) -INSERT INTO t1 VALUES -(0xFA40),(0xFA41),(0xFA42),(0xFA43),(0xFA44),(0xFA45),(0xFA46),(0xFA47), -(0xFA48),(0xFA49),(0xFA4A),(0xFA4B),(0xFA4C),(0xFA4D),(0xFA4E),(0xFA4F), -(0xFA50),(0xFA51),(0xFA52),(0xFA53),(0xFA54),(0xFA55),(0xFA56),(0xFA57), -(0xFA58),(0xFA59),(0xFA5A),(0xFA5B),(0xFA5C),(0xFA5D),(0xFA5E),(0xFA5F), -(0xFA60),(0xFA61),(0xFA62),(0xFA63),(0xFA64),(0xFA65),(0xFA66),(0xFA67), -(0xFA68),(0xFA69),(0xFA6A),(0xFA6B),(0xFA6C),(0xFA6D),(0xFA6E),(0xFA6F), -(0xFA70),(0xFA71),(0xFA72),(0xFA73),(0xFA74),(0xFA75),(0xFA76),(0xFA77), -(0xFA78),(0xFA79),(0xFA7A),(0xFA7B),(0xFA7C),(0xFA7D),(0xFA7E), -(0xFA80),(0xFA81),(0xFA82),(0xFA83),(0xFA84),(0xFA85),(0xFA86),(0xFA87), -(0xFA88),(0xFA89),(0xFA8A),(0xFA8B),(0xFA8C),(0xFA8D),(0xFA8E),(0xFA8F), -(0xFA90),(0xFA91),(0xFA92),(0xFA93),(0xFA94),(0xFA95),(0xFA96),(0xFA97), -(0xFA98),(0xFA99),(0xFA9A),(0xFA9B),(0xFA9C),(0xFA9D),(0xFA9E),(0xFA9F), -(0xFAA0),(0xFAA1),(0xFAA2),(0xFAA3),(0xFAA4),(0xFAA5),(0xFAA6),(0xFAA7), -(0xFAA8),(0xFAA9),(0xFAAA),(0xFAAB),(0xFAAC),(0xFAAD),(0xFAAE),(0xFAAF), -(0xFAB0),(0xFAB1),(0xFAB2),(0xFAB3),(0xFAB4),(0xFAB5),(0xFAB6),(0xFAB7), -(0xFAB8),(0xFAB9),(0xFABA),(0xFABB),(0xFABC),(0xFABD),(0xFABE),(0xFABF), -(0xFAC0),(0xFAC1),(0xFAC2),(0xFAC3),(0xFAC4),(0xFAC5),(0xFAC6),(0xFAC7), -(0xFAC8),(0xFAC9),(0xFACA),(0xFACB),(0xFACC),(0xFACD),(0xFACE),(0xFACF), -(0xFAD0),(0xFAD1),(0xFAD2),(0xFAD3),(0xFAD4),(0xFAD5),(0xFAD6),(0xFAD7), -(0xFAD8),(0xFAD9),(0xFADA),(0xFADB),(0xFADC),(0xFADD),(0xFADE),(0xFADF), -(0xFAE0),(0xFAE1),(0xFAE2),(0xFAE3),(0xFAE4),(0xFAE5),(0xFAE6),(0xFAE7), -(0xFAE8),(0xFAE9),(0xFAEA),(0xFAEB),(0xFAEC),(0xFAED),(0xFAEE),(0xFAEF), -(0xFAF0),(0xFAF1),(0xFAF2),(0xFAF3),(0xFAF4),(0xFAF5),(0xFAF6),(0xFAF7), -(0xFAF8),(0xFAF9),(0xFAFA),(0xFAFB),(0xFAFC), -(0xFB40),(0xFB41),(0xFB42),(0xFB43),(0xFB44),(0xFB45),(0xFB46),(0xFB47), -(0xFB48),(0xFB49),(0xFB4A),(0xFB4B),(0xFB4C),(0xFB4D),(0xFB4E),(0xFB4F), -(0xFB50),(0xFB51),(0xFB52),(0xFB53),(0xFB54),(0xFB55),(0xFB56),(0xFB57), -(0xFB58),(0xFB59),(0xFB5A),(0xFB5B),(0xFB5C),(0xFB5D),(0xFB5E),(0xFB5F), -(0xFB60),(0xFB61),(0xFB62),(0xFB63),(0xFB64),(0xFB65),(0xFB66),(0xFB67), -(0xFB68),(0xFB69),(0xFB6A),(0xFB6B),(0xFB6C),(0xFB6D),(0xFB6E),(0xFB6F), -(0xFB70),(0xFB71),(0xFB72),(0xFB73),(0xFB74),(0xFB75),(0xFB76),(0xFB77), -(0xFB78),(0xFB79),(0xFB7A),(0xFB7B),(0xFB7C),(0xFB7D),(0xFB7E), -(0xFB80),(0xFB81),(0xFB82),(0xFB83),(0xFB84),(0xFB85),(0xFB86),(0xFB87), -(0xFB88),(0xFB89),(0xFB8A),(0xFB8B),(0xFB8C),(0xFB8D),(0xFB8E),(0xFB8F), -(0xFB90),(0xFB91),(0xFB92),(0xFB93),(0xFB94),(0xFB95),(0xFB96),(0xFB97), -(0xFB98),(0xFB99),(0xFB9A),(0xFB9B),(0xFB9C),(0xFB9D),(0xFB9E),(0xFB9F), -(0xFBA0),(0xFBA1),(0xFBA2),(0xFBA3),(0xFBA4),(0xFBA5),(0xFBA6),(0xFBA7), -(0xFBA8),(0xFBA9),(0xFBAA),(0xFBAB),(0xFBAC),(0xFBAD),(0xFBAE),(0xFBAF), -(0xFBB0),(0xFBB1),(0xFBB2),(0xFBB3),(0xFBB4),(0xFBB5),(0xFBB6),(0xFBB7), -(0xFBB8),(0xFBB9),(0xFBBA),(0xFBBB),(0xFBBC),(0xFBBD),(0xFBBE),(0xFBBF), -(0xFBC0),(0xFBC1),(0xFBC2),(0xFBC3),(0xFBC4),(0xFBC5),(0xFBC6),(0xFBC7), -(0xFBC8),(0xFBC9),(0xFBCA),(0xFBCB),(0xFBCC),(0xFBCD),(0xFBCE),(0xFBCF), -(0xFBD0),(0xFBD1),(0xFBD2),(0xFBD3),(0xFBD4),(0xFBD5),(0xFBD6),(0xFBD7), -(0xFBD8),(0xFBD9),(0xFBDA),(0xFBDB),(0xFBDC),(0xFBDD),(0xFBDE),(0xFBDF), -(0xFBE0),(0xFBE1),(0xFBE2),(0xFBE3),(0xFBE4),(0xFBE5),(0xFBE6),(0xFBE7), -(0xFBE8),(0xFBE9),(0xFBEA),(0xFBEB),(0xFBEC),(0xFBED),(0xFBEE),(0xFBEF), -(0xFBF0),(0xFBF1),(0xFBF2),(0xFBF3),(0xFBF4),(0xFBF5),(0xFBF6),(0xFBF7), -(0xFBF8),(0xFBF9),(0xFBFA),(0xFBFB),(0xFBFC), -(0xFC40),(0xFC41),(0xFC42),(0xFC43),(0xFC44),(0xFC45),(0xFC46),(0xFC47), -(0xFC48),(0xFC49),(0xFC4A),(0xFC4B); - -#User defined characters (0xF040-0xF9FC) -INSERT INTO t1 VALUES -(0xF040),(0xF041),(0xF042),(0xF043),(0xF044),(0xF045),(0xF046),(0xF047), -(0xF048),(0xF049),(0xF04A),(0xF04B),(0xF04C),(0xF04D),(0xF04E),(0xF04F), -(0xF050),(0xF051),(0xF052),(0xF053),(0xF054),(0xF055),(0xF056),(0xF057), -(0xF058),(0xF059),(0xF05A),(0xF05B),(0xF05C),(0xF05D),(0xF05E),(0xF05F), -(0xF060),(0xF061),(0xF062),(0xF063),(0xF064),(0xF065),(0xF066),(0xF067), -(0xF068),(0xF069),(0xF06A),(0xF06B),(0xF06C),(0xF06D),(0xF06E),(0xF06F), -(0xF070),(0xF071),(0xF072),(0xF073),(0xF074),(0xF075),(0xF076),(0xF077), -(0xF078),(0xF079),(0xF07A),(0xF07B),(0xF07C),(0xF07D),(0xF07E), -(0xF080),(0xF081),(0xF082),(0xF083),(0xF084),(0xF085),(0xF086),(0xF087), -(0xF088),(0xF089),(0xF08A),(0xF08B),(0xF08C),(0xF08D),(0xF08E),(0xF08F), -(0xF090),(0xF091),(0xF092),(0xF093),(0xF094),(0xF095),(0xF096),(0xF097), -(0xF098),(0xF099),(0xF09A),(0xF09B),(0xF09C),(0xF09D),(0xF09E),(0xF09F), -(0xF0A0),(0xF0A1),(0xF0A2),(0xF0A3),(0xF0A4),(0xF0A5),(0xF0A6),(0xF0A7), -(0xF0A8),(0xF0A9),(0xF0AA),(0xF0AB),(0xF0AC),(0xF0AD),(0xF0AE),(0xF0AF), -(0xF0B0),(0xF0B1),(0xF0B2),(0xF0B3),(0xF0B4),(0xF0B5),(0xF0B6),(0xF0B7), -(0xF0B8),(0xF0B9),(0xF0BA),(0xF0BB),(0xF0BC),(0xF0BD),(0xF0BE),(0xF0BF), -(0xF0C0),(0xF0C1),(0xF0C2),(0xF0C3),(0xF0C4),(0xF0C5),(0xF0C6),(0xF0C7), -(0xF0C8),(0xF0C9),(0xF0CA),(0xF0CB),(0xF0CC),(0xF0CD),(0xF0CE),(0xF0CF), -(0xF0D0),(0xF0D1),(0xF0D2),(0xF0D3),(0xF0D4),(0xF0D5),(0xF0D6),(0xF0D7), -(0xF0D8),(0xF0D9),(0xF0DA),(0xF0DB),(0xF0DC),(0xF0DD),(0xF0DE),(0xF0DF), -(0xF0E0),(0xF0E1),(0xF0E2),(0xF0E3),(0xF0E4),(0xF0E5),(0xF0E6),(0xF0E7), -(0xF0E8),(0xF0E9),(0xF0EA),(0xF0EB),(0xF0EC),(0xF0ED),(0xF0EE),(0xF0EF), -(0xF0F0),(0xF0F1),(0xF0F2),(0xF0F3),(0xF0F4),(0xF0F5),(0xF0F6),(0xF0F7), -(0xF0F8),(0xF0F9),(0xF0FA),(0xF0FB),(0xF0FC), -(0xF140),(0xF141),(0xF142),(0xF143),(0xF144),(0xF145),(0xF146),(0xF147), -(0xF148),(0xF149),(0xF14A),(0xF14B),(0xF14C),(0xF14D),(0xF14E),(0xF14F), -(0xF150),(0xF151),(0xF152),(0xF153),(0xF154),(0xF155),(0xF156),(0xF157), -(0xF158),(0xF159),(0xF15A),(0xF15B),(0xF15C),(0xF15D),(0xF15E),(0xF15F), -(0xF160),(0xF161),(0xF162),(0xF163),(0xF164),(0xF165),(0xF166),(0xF167), -(0xF168),(0xF169),(0xF16A),(0xF16B),(0xF16C),(0xF16D),(0xF16E),(0xF16F), -(0xF170),(0xF171),(0xF172),(0xF173),(0xF174),(0xF175),(0xF176),(0xF177), -(0xF178),(0xF179),(0xF17A),(0xF17B),(0xF17C),(0xF17D),(0xF17E), -(0xF180),(0xF181),(0xF182),(0xF183),(0xF184),(0xF185),(0xF186),(0xF187), -(0xF188),(0xF189),(0xF18A),(0xF18B),(0xF18C),(0xF18D),(0xF18E),(0xF18F), -(0xF190),(0xF191),(0xF192),(0xF193),(0xF194),(0xF195),(0xF196),(0xF197), -(0xF198),(0xF199),(0xF19A),(0xF19B),(0xF19C),(0xF19D),(0xF19E),(0xF19F), -(0xF1A0),(0xF1A1),(0xF1A2),(0xF1A3),(0xF1A4),(0xF1A5),(0xF1A6),(0xF1A7), -(0xF1A8),(0xF1A9),(0xF1AA),(0xF1AB),(0xF1AC),(0xF1AD),(0xF1AE),(0xF1AF), -(0xF1B0),(0xF1B1),(0xF1B2),(0xF1B3),(0xF1B4),(0xF1B5),(0xF1B6),(0xF1B7), -(0xF1B8),(0xF1B9),(0xF1BA),(0xF1BB),(0xF1BC),(0xF1BD),(0xF1BE),(0xF1BF), -(0xF1C0),(0xF1C1),(0xF1C2),(0xF1C3),(0xF1C4),(0xF1C5),(0xF1C6),(0xF1C7), -(0xF1C8),(0xF1C9),(0xF1CA),(0xF1CB),(0xF1CC),(0xF1CD),(0xF1CE),(0xF1CF), -(0xF1D0),(0xF1D1),(0xF1D2),(0xF1D3),(0xF1D4),(0xF1D5),(0xF1D6),(0xF1D7), -(0xF1D8),(0xF1D9),(0xF1DA),(0xF1DB),(0xF1DC),(0xF1DD),(0xF1DE),(0xF1DF), -(0xF1E0),(0xF1E1),(0xF1E2),(0xF1E3),(0xF1E4),(0xF1E5),(0xF1E6),(0xF1E7), -(0xF1E8),(0xF1E9),(0xF1EA),(0xF1EB),(0xF1EC),(0xF1ED),(0xF1EE),(0xF1EF), -(0xF1F0),(0xF1F1),(0xF1F2),(0xF1F3),(0xF1F4),(0xF1F5),(0xF1F6),(0xF1F7), -(0xF1F8),(0xF1F9),(0xF1FA),(0xF1FB),(0xF1FC), -(0xF240),(0xF241),(0xF242),(0xF243),(0xF244),(0xF245),(0xF246),(0xF247), -(0xF248),(0xF249),(0xF24A),(0xF24B),(0xF24C),(0xF24D),(0xF24E),(0xF24F), -(0xF250),(0xF251),(0xF252),(0xF253),(0xF254),(0xF255),(0xF256),(0xF257), -(0xF258),(0xF259),(0xF25A),(0xF25B),(0xF25C),(0xF25D),(0xF25E),(0xF25F), -(0xF260),(0xF261),(0xF262),(0xF263),(0xF264),(0xF265),(0xF266),(0xF267), -(0xF268),(0xF269),(0xF26A),(0xF26B),(0xF26C),(0xF26D),(0xF26E),(0xF26F), -(0xF270),(0xF271),(0xF272),(0xF273),(0xF274),(0xF275),(0xF276),(0xF277), -(0xF278),(0xF279),(0xF27A),(0xF27B),(0xF27C),(0xF27D),(0xF27E), -(0xF280),(0xF281),(0xF282),(0xF283),(0xF284),(0xF285),(0xF286),(0xF287), -(0xF288),(0xF289),(0xF28A),(0xF28B),(0xF28C),(0xF28D),(0xF28E),(0xF28F), -(0xF290),(0xF291),(0xF292),(0xF293),(0xF294),(0xF295),(0xF296),(0xF297), -(0xF298),(0xF299),(0xF29A),(0xF29B),(0xF29C),(0xF29D),(0xF29E),(0xF29F), -(0xF2A0),(0xF2A1),(0xF2A2),(0xF2A3),(0xF2A4),(0xF2A5),(0xF2A6),(0xF2A7), -(0xF2A8),(0xF2A9),(0xF2AA),(0xF2AB),(0xF2AC),(0xF2AD),(0xF2AE),(0xF2AF), -(0xF2B0),(0xF2B1),(0xF2B2),(0xF2B3),(0xF2B4),(0xF2B5),(0xF2B6),(0xF2B7), -(0xF2B8),(0xF2B9),(0xF2BA),(0xF2BB),(0xF2BC),(0xF2BD),(0xF2BE),(0xF2BF), -(0xF2C0),(0xF2C1),(0xF2C2),(0xF2C3),(0xF2C4),(0xF2C5),(0xF2C6),(0xF2C7), -(0xF2C8),(0xF2C9),(0xF2CA),(0xF2CB),(0xF2CC),(0xF2CD),(0xF2CE),(0xF2CF), -(0xF2D0),(0xF2D1),(0xF2D2),(0xF2D3),(0xF2D4),(0xF2D5),(0xF2D6),(0xF2D7), -(0xF2D8),(0xF2D9),(0xF2DA),(0xF2DB),(0xF2DC),(0xF2DD),(0xF2DE),(0xF2DF), -(0xF2E0),(0xF2E1),(0xF2E2),(0xF2E3),(0xF2E4),(0xF2E5),(0xF2E6),(0xF2E7), -(0xF2E8),(0xF2E9),(0xF2EA),(0xF2EB),(0xF2EC),(0xF2ED),(0xF2EE),(0xF2EF), -(0xF2F0),(0xF2F1),(0xF2F2),(0xF2F3),(0xF2F4),(0xF2F5),(0xF2F6),(0xF2F7), -(0xF2F8),(0xF2F9),(0xF2FA),(0xF2FB),(0xF2FC), -(0xF340),(0xF341),(0xF342),(0xF343),(0xF344),(0xF345),(0xF346),(0xF347), -(0xF348),(0xF349),(0xF34A),(0xF34B),(0xF34C),(0xF34D),(0xF34E),(0xF34F), -(0xF350),(0xF351),(0xF352),(0xF353),(0xF354),(0xF355),(0xF356),(0xF357), -(0xF358),(0xF359),(0xF35A),(0xF35B),(0xF35C),(0xF35D),(0xF35E),(0xF35F), -(0xF360),(0xF361),(0xF362),(0xF363),(0xF364),(0xF365),(0xF366),(0xF367), -(0xF368),(0xF369),(0xF36A),(0xF36B),(0xF36C),(0xF36D),(0xF36E),(0xF36F), -(0xF370),(0xF371),(0xF372),(0xF373),(0xF374),(0xF375),(0xF376),(0xF377), -(0xF378),(0xF379),(0xF37A),(0xF37B),(0xF37C),(0xF37D),(0xF37E), -(0xF380),(0xF381),(0xF382),(0xF383),(0xF384),(0xF385),(0xF386),(0xF387), -(0xF388),(0xF389),(0xF38A),(0xF38B),(0xF38C),(0xF38D),(0xF38E),(0xF38F), -(0xF390),(0xF391),(0xF392),(0xF393),(0xF394),(0xF395),(0xF396),(0xF397), -(0xF398),(0xF399),(0xF39A),(0xF39B),(0xF39C),(0xF39D),(0xF39E),(0xF39F), -(0xF3A0),(0xF3A1),(0xF3A2),(0xF3A3),(0xF3A4),(0xF3A5),(0xF3A6),(0xF3A7), -(0xF3A8),(0xF3A9),(0xF3AA),(0xF3AB),(0xF3AC),(0xF3AD),(0xF3AE),(0xF3AF), -(0xF3B0),(0xF3B1),(0xF3B2),(0xF3B3),(0xF3B4),(0xF3B5),(0xF3B6),(0xF3B7), -(0xF3B8),(0xF3B9),(0xF3BA),(0xF3BB),(0xF3BC),(0xF3BD),(0xF3BE),(0xF3BF), -(0xF3C0),(0xF3C1),(0xF3C2),(0xF3C3),(0xF3C4),(0xF3C5),(0xF3C6),(0xF3C7), -(0xF3C8),(0xF3C9),(0xF3CA),(0xF3CB),(0xF3CC),(0xF3CD),(0xF3CE),(0xF3CF), -(0xF3D0),(0xF3D1),(0xF3D2),(0xF3D3),(0xF3D4),(0xF3D5),(0xF3D6),(0xF3D7), -(0xF3D8),(0xF3D9),(0xF3DA),(0xF3DB),(0xF3DC),(0xF3DD),(0xF3DE),(0xF3DF), -(0xF3E0),(0xF3E1),(0xF3E2),(0xF3E3),(0xF3E4),(0xF3E5),(0xF3E6),(0xF3E7), -(0xF3E8),(0xF3E9),(0xF3EA),(0xF3EB),(0xF3EC),(0xF3ED),(0xF3EE),(0xF3EF), -(0xF3F0),(0xF3F1),(0xF3F2),(0xF3F3),(0xF3F4),(0xF3F5),(0xF3F6),(0xF3F7), -(0xF3F8),(0xF3F9),(0xF3FA),(0xF3FB),(0xF3FC), -(0xF440),(0xF441),(0xF442),(0xF443),(0xF444),(0xF445),(0xF446),(0xF447), -(0xF448),(0xF449),(0xF44A),(0xF44B),(0xF44C),(0xF44D),(0xF44E),(0xF44F), -(0xF450),(0xF451),(0xF452),(0xF453),(0xF454),(0xF455),(0xF456),(0xF457), -(0xF458),(0xF459),(0xF45A),(0xF45B),(0xF45C),(0xF45D),(0xF45E),(0xF45F), -(0xF460),(0xF461),(0xF462),(0xF463),(0xF464),(0xF465),(0xF466),(0xF467), -(0xF468),(0xF469),(0xF46A),(0xF46B),(0xF46C),(0xF46D),(0xF46E),(0xF46F), -(0xF470),(0xF471),(0xF472),(0xF473),(0xF474),(0xF475),(0xF476),(0xF477), -(0xF478),(0xF479),(0xF47A),(0xF47B),(0xF47C),(0xF47D),(0xF47E), -(0xF480),(0xF481),(0xF482),(0xF483),(0xF484),(0xF485),(0xF486),(0xF487), -(0xF488),(0xF489),(0xF48A),(0xF48B),(0xF48C),(0xF48D),(0xF48E),(0xF48F), -(0xF490),(0xF491),(0xF492),(0xF493),(0xF494),(0xF495),(0xF496),(0xF497), -(0xF498),(0xF499),(0xF49A),(0xF49B),(0xF49C),(0xF49D),(0xF49E),(0xF49F), -(0xF4A0),(0xF4A1),(0xF4A2),(0xF4A3),(0xF4A4),(0xF4A5),(0xF4A6),(0xF4A7), -(0xF4A8),(0xF4A9),(0xF4AA),(0xF4AB),(0xF4AC),(0xF4AD),(0xF4AE),(0xF4AF), -(0xF4B0),(0xF4B1),(0xF4B2),(0xF4B3),(0xF4B4),(0xF4B5),(0xF4B6),(0xF4B7), -(0xF4B8),(0xF4B9),(0xF4BA),(0xF4BB),(0xF4BC),(0xF4BD),(0xF4BE),(0xF4BF), -(0xF4C0),(0xF4C1),(0xF4C2),(0xF4C3),(0xF4C4),(0xF4C5),(0xF4C6),(0xF4C7), -(0xF4C8),(0xF4C9),(0xF4CA),(0xF4CB),(0xF4CC),(0xF4CD),(0xF4CE),(0xF4CF), -(0xF4D0),(0xF4D1),(0xF4D2),(0xF4D3),(0xF4D4),(0xF4D5),(0xF4D6),(0xF4D7), -(0xF4D8),(0xF4D9),(0xF4DA),(0xF4DB),(0xF4DC),(0xF4DD),(0xF4DE),(0xF4DF), -(0xF4E0),(0xF4E1),(0xF4E2),(0xF4E3),(0xF4E4),(0xF4E5),(0xF4E6),(0xF4E7), -(0xF4E8),(0xF4E9),(0xF4EA),(0xF4EB),(0xF4EC),(0xF4ED),(0xF4EE),(0xF4EF), -(0xF4F0),(0xF4F1),(0xF4F2),(0xF4F3),(0xF4F4),(0xF4F5),(0xF4F6),(0xF4F7), -(0xF4F8),(0xF4F9),(0xF4FA),(0xF4FB),(0xF4FC), -(0xF540),(0xF541),(0xF542),(0xF543),(0xF544),(0xF545),(0xF546),(0xF547), -(0xF548),(0xF549),(0xF54A),(0xF54B),(0xF54C),(0xF54D),(0xF54E),(0xF54F), -(0xF550),(0xF551),(0xF552),(0xF553),(0xF554),(0xF555),(0xF556),(0xF557), -(0xF558),(0xF559),(0xF55A),(0xF55B),(0xF55C),(0xF55D),(0xF55E),(0xF55F), -(0xF560),(0xF561),(0xF562),(0xF563),(0xF564),(0xF565),(0xF566),(0xF567), -(0xF568),(0xF569),(0xF56A),(0xF56B),(0xF56C),(0xF56D),(0xF56E),(0xF56F), -(0xF570),(0xF571),(0xF572),(0xF573),(0xF574),(0xF575),(0xF576),(0xF577), -(0xF578),(0xF579),(0xF57A),(0xF57B),(0xF57C),(0xF57D),(0xF57E), -(0xF580),(0xF581),(0xF582),(0xF583),(0xF584),(0xF585),(0xF586),(0xF587), -(0xF588),(0xF589),(0xF58A),(0xF58B),(0xF58C),(0xF58D),(0xF58E),(0xF58F), -(0xF590),(0xF591),(0xF592),(0xF593),(0xF594),(0xF595),(0xF596),(0xF597), -(0xF598),(0xF599),(0xF59A),(0xF59B),(0xF59C),(0xF59D),(0xF59E),(0xF59F), -(0xF5A0),(0xF5A1),(0xF5A2),(0xF5A3),(0xF5A4),(0xF5A5),(0xF5A6),(0xF5A7), -(0xF5A8),(0xF5A9),(0xF5AA),(0xF5AB),(0xF5AC),(0xF5AD),(0xF5AE),(0xF5AF), -(0xF5B0),(0xF5B1),(0xF5B2),(0xF5B3),(0xF5B4),(0xF5B5),(0xF5B6),(0xF5B7), -(0xF5B8),(0xF5B9),(0xF5BA),(0xF5BB),(0xF5BC),(0xF5BD),(0xF5BE),(0xF5BF), -(0xF5C0),(0xF5C1),(0xF5C2),(0xF5C3),(0xF5C4),(0xF5C5),(0xF5C6),(0xF5C7), -(0xF5C8),(0xF5C9),(0xF5CA),(0xF5CB),(0xF5CC),(0xF5CD),(0xF5CE),(0xF5CF), -(0xF5D0),(0xF5D1),(0xF5D2),(0xF5D3),(0xF5D4),(0xF5D5),(0xF5D6),(0xF5D7), -(0xF5D8),(0xF5D9),(0xF5DA),(0xF5DB),(0xF5DC),(0xF5DD),(0xF5DE),(0xF5DF), -(0xF5E0),(0xF5E1),(0xF5E2),(0xF5E3),(0xF5E4),(0xF5E5),(0xF5E6),(0xF5E7), -(0xF5E8),(0xF5E9),(0xF5EA),(0xF5EB),(0xF5EC),(0xF5ED),(0xF5EE),(0xF5EF), -(0xF5F0),(0xF5F1),(0xF5F2),(0xF5F3),(0xF5F4),(0xF5F5),(0xF5F6),(0xF5F7), -(0xF5F8),(0xF5F9),(0xF5FA),(0xF5FB),(0xF5FC), -(0xF640),(0xF641),(0xF642),(0xF643),(0xF644),(0xF645),(0xF646),(0xF647), -(0xF648),(0xF649),(0xF64A),(0xF64B),(0xF64C),(0xF64D),(0xF64E),(0xF64F), -(0xF650),(0xF651),(0xF652),(0xF653),(0xF654),(0xF655),(0xF656),(0xF657), -(0xF658),(0xF659),(0xF65A),(0xF65B),(0xF65C),(0xF65D),(0xF65E),(0xF65F), -(0xF660),(0xF661),(0xF662),(0xF663),(0xF664),(0xF665),(0xF666),(0xF667), -(0xF668),(0xF669),(0xF66A),(0xF66B),(0xF66C),(0xF66D),(0xF66E),(0xF66F), -(0xF670),(0xF671),(0xF672),(0xF673),(0xF674),(0xF675),(0xF676),(0xF677), -(0xF678),(0xF679),(0xF67A),(0xF67B),(0xF67C),(0xF67D),(0xF67E), -(0xF680),(0xF681),(0xF682),(0xF683),(0xF684),(0xF685),(0xF686),(0xF687), -(0xF688),(0xF689),(0xF68A),(0xF68B),(0xF68C),(0xF68D),(0xF68E),(0xF68F), -(0xF690),(0xF691),(0xF692),(0xF693),(0xF694),(0xF695),(0xF696),(0xF697), -(0xF698),(0xF699),(0xF69A),(0xF69B),(0xF69C),(0xF69D),(0xF69E),(0xF69F), -(0xF6A0),(0xF6A1),(0xF6A2),(0xF6A3),(0xF6A4),(0xF6A5),(0xF6A6),(0xF6A7), -(0xF6A8),(0xF6A9),(0xF6AA),(0xF6AB),(0xF6AC),(0xF6AD),(0xF6AE),(0xF6AF), -(0xF6B0),(0xF6B1),(0xF6B2),(0xF6B3),(0xF6B4),(0xF6B5),(0xF6B6),(0xF6B7), -(0xF6B8),(0xF6B9),(0xF6BA),(0xF6BB),(0xF6BC),(0xF6BD),(0xF6BE),(0xF6BF), -(0xF6C0),(0xF6C1),(0xF6C2),(0xF6C3),(0xF6C4),(0xF6C5),(0xF6C6),(0xF6C7), -(0xF6C8),(0xF6C9),(0xF6CA),(0xF6CB),(0xF6CC),(0xF6CD),(0xF6CE),(0xF6CF), -(0xF6D0),(0xF6D1),(0xF6D2),(0xF6D3),(0xF6D4),(0xF6D5),(0xF6D6),(0xF6D7), -(0xF6D8),(0xF6D9),(0xF6DA),(0xF6DB),(0xF6DC),(0xF6DD),(0xF6DE),(0xF6DF), -(0xF6E0),(0xF6E1),(0xF6E2),(0xF6E3),(0xF6E4),(0xF6E5),(0xF6E6),(0xF6E7), -(0xF6E8),(0xF6E9),(0xF6EA),(0xF6EB),(0xF6EC),(0xF6ED),(0xF6EE),(0xF6EF), -(0xF6F0),(0xF6F1),(0xF6F2),(0xF6F3),(0xF6F4),(0xF6F5),(0xF6F6),(0xF6F7), -(0xF6F8),(0xF6F9),(0xF6FA),(0xF6FB),(0xF6FC), -(0xF740),(0xF741),(0xF742),(0xF743),(0xF744),(0xF745),(0xF746),(0xF747), -(0xF748),(0xF749),(0xF74A),(0xF74B),(0xF74C),(0xF74D),(0xF74E),(0xF74F), -(0xF750),(0xF751),(0xF752),(0xF753),(0xF754),(0xF755),(0xF756),(0xF757), -(0xF758),(0xF759),(0xF75A),(0xF75B),(0xF75C),(0xF75D),(0xF75E),(0xF75F), -(0xF760),(0xF761),(0xF762),(0xF763),(0xF764),(0xF765),(0xF766),(0xF767), -(0xF768),(0xF769),(0xF76A),(0xF76B),(0xF76C),(0xF76D),(0xF76E),(0xF76F), -(0xF770),(0xF771),(0xF772),(0xF773),(0xF774),(0xF775),(0xF776),(0xF777), -(0xF778),(0xF779),(0xF77A),(0xF77B),(0xF77C),(0xF77D),(0xF77E), -(0xF780),(0xF781),(0xF782),(0xF783),(0xF784),(0xF785),(0xF786),(0xF787), -(0xF788),(0xF789),(0xF78A),(0xF78B),(0xF78C),(0xF78D),(0xF78E),(0xF78F), -(0xF790),(0xF791),(0xF792),(0xF793),(0xF794),(0xF795),(0xF796),(0xF797), -(0xF798),(0xF799),(0xF79A),(0xF79B),(0xF79C),(0xF79D),(0xF79E),(0xF79F), -(0xF7A0),(0xF7A1),(0xF7A2),(0xF7A3),(0xF7A4),(0xF7A5),(0xF7A6),(0xF7A7), -(0xF7A8),(0xF7A9),(0xF7AA),(0xF7AB),(0xF7AC),(0xF7AD),(0xF7AE),(0xF7AF), -(0xF7B0),(0xF7B1),(0xF7B2),(0xF7B3),(0xF7B4),(0xF7B5),(0xF7B6),(0xF7B7), -(0xF7B8),(0xF7B9),(0xF7BA),(0xF7BB),(0xF7BC),(0xF7BD),(0xF7BE),(0xF7BF), -(0xF7C0),(0xF7C1),(0xF7C2),(0xF7C3),(0xF7C4),(0xF7C5),(0xF7C6),(0xF7C7), -(0xF7C8),(0xF7C9),(0xF7CA),(0xF7CB),(0xF7CC),(0xF7CD),(0xF7CE),(0xF7CF), -(0xF7D0),(0xF7D1),(0xF7D2),(0xF7D3),(0xF7D4),(0xF7D5),(0xF7D6),(0xF7D7), -(0xF7D8),(0xF7D9),(0xF7DA),(0xF7DB),(0xF7DC),(0xF7DD),(0xF7DE),(0xF7DF), -(0xF7E0),(0xF7E1),(0xF7E2),(0xF7E3),(0xF7E4),(0xF7E5),(0xF7E6),(0xF7E7), -(0xF7E8),(0xF7E9),(0xF7EA),(0xF7EB),(0xF7EC),(0xF7ED),(0xF7EE),(0xF7EF), -(0xF7F0),(0xF7F1),(0xF7F2),(0xF7F3),(0xF7F4),(0xF7F5),(0xF7F6),(0xF7F7), -(0xF7F8),(0xF7F9),(0xF7FA),(0xF7FB),(0xF7FC), -(0xF840),(0xF841),(0xF842),(0xF843),(0xF844),(0xF845),(0xF846),(0xF847), -(0xF848),(0xF849),(0xF84A),(0xF84B),(0xF84C),(0xF84D),(0xF84E),(0xF84F), -(0xF850),(0xF851),(0xF852),(0xF853),(0xF854),(0xF855),(0xF856),(0xF857), -(0xF858),(0xF859),(0xF85A),(0xF85B),(0xF85C),(0xF85D),(0xF85E),(0xF85F), -(0xF860),(0xF861),(0xF862),(0xF863),(0xF864),(0xF865),(0xF866),(0xF867), -(0xF868),(0xF869),(0xF86A),(0xF86B),(0xF86C),(0xF86D),(0xF86E),(0xF86F), -(0xF870),(0xF871),(0xF872),(0xF873),(0xF874),(0xF875),(0xF876),(0xF877), -(0xF878),(0xF879),(0xF87A),(0xF87B),(0xF87C),(0xF87D),(0xF87E), -(0xF880),(0xF881),(0xF882),(0xF883),(0xF884),(0xF885),(0xF886),(0xF887), -(0xF888),(0xF889),(0xF88A),(0xF88B),(0xF88C),(0xF88D),(0xF88E),(0xF88F), -(0xF890),(0xF891),(0xF892),(0xF893),(0xF894),(0xF895),(0xF896),(0xF897), -(0xF898),(0xF899),(0xF89A),(0xF89B),(0xF89C),(0xF89D),(0xF89E),(0xF89F), -(0xF8A0),(0xF8A1),(0xF8A2),(0xF8A3),(0xF8A4),(0xF8A5),(0xF8A6),(0xF8A7), -(0xF8A8),(0xF8A9),(0xF8AA),(0xF8AB),(0xF8AC),(0xF8AD),(0xF8AE),(0xF8AF), -(0xF8B0),(0xF8B1),(0xF8B2),(0xF8B3),(0xF8B4),(0xF8B5),(0xF8B6),(0xF8B7), -(0xF8B8),(0xF8B9),(0xF8BA),(0xF8BB),(0xF8BC),(0xF8BD),(0xF8BE),(0xF8BF), -(0xF8C0),(0xF8C1),(0xF8C2),(0xF8C3),(0xF8C4),(0xF8C5),(0xF8C6),(0xF8C7), -(0xF8C8),(0xF8C9),(0xF8CA),(0xF8CB),(0xF8CC),(0xF8CD),(0xF8CE),(0xF8CF), -(0xF8D0),(0xF8D1),(0xF8D2),(0xF8D3),(0xF8D4),(0xF8D5),(0xF8D6),(0xF8D7), -(0xF8D8),(0xF8D9),(0xF8DA),(0xF8DB),(0xF8DC),(0xF8DD),(0xF8DE),(0xF8DF), -(0xF8E0),(0xF8E1),(0xF8E2),(0xF8E3),(0xF8E4),(0xF8E5),(0xF8E6),(0xF8E7), -(0xF8E8),(0xF8E9),(0xF8EA),(0xF8EB),(0xF8EC),(0xF8ED),(0xF8EE),(0xF8EF), -(0xF8F0),(0xF8F1),(0xF8F2),(0xF8F3),(0xF8F4),(0xF8F5),(0xF8F6),(0xF8F7), -(0xF8F8),(0xF8F9),(0xF8FA),(0xF8FB),(0xF8FC), -(0xF940),(0xF941),(0xF942),(0xF943),(0xF944),(0xF945),(0xF946),(0xF947), -(0xF948),(0xF949),(0xF94A),(0xF94B),(0xF94C),(0xF94D),(0xF94E),(0xF94F), -(0xF950),(0xF951),(0xF952),(0xF953),(0xF954),(0xF955),(0xF956),(0xF957), -(0xF958),(0xF959),(0xF95A),(0xF95B),(0xF95C),(0xF95D),(0xF95E),(0xF95F), -(0xF960),(0xF961),(0xF962),(0xF963),(0xF964),(0xF965),(0xF966),(0xF967), -(0xF968),(0xF969),(0xF96A),(0xF96B),(0xF96C),(0xF96D),(0xF96E),(0xF96F), -(0xF970),(0xF971),(0xF972),(0xF973),(0xF974),(0xF975),(0xF976),(0xF977), -(0xF978),(0xF979),(0xF97A),(0xF97B),(0xF97C),(0xF97D),(0xF97E), -(0xF980),(0xF981),(0xF982),(0xF983),(0xF984),(0xF985),(0xF986),(0xF987), -(0xF988),(0xF989),(0xF98A),(0xF98B),(0xF98C),(0xF98D),(0xF98E),(0xF98F), -(0xF990),(0xF991),(0xF992),(0xF993),(0xF994),(0xF995),(0xF996),(0xF997), -(0xF998),(0xF999),(0xF99A),(0xF99B),(0xF99C),(0xF99D),(0xF99E),(0xF99F), -(0xF9A0),(0xF9A1),(0xF9A2),(0xF9A3),(0xF9A4),(0xF9A5),(0xF9A6),(0xF9A7), -(0xF9A8),(0xF9A9),(0xF9AA),(0xF9AB),(0xF9AC),(0xF9AD),(0xF9AE),(0xF9AF), -(0xF9B0),(0xF9B1),(0xF9B2),(0xF9B3),(0xF9B4),(0xF9B5),(0xF9B6),(0xF9B7), -(0xF9B8),(0xF9B9),(0xF9BA),(0xF9BB),(0xF9BC),(0xF9BD),(0xF9BE),(0xF9BF), -(0xF9C0),(0xF9C1),(0xF9C2),(0xF9C3),(0xF9C4),(0xF9C5),(0xF9C6),(0xF9C7), -(0xF9C8),(0xF9C9),(0xF9CA),(0xF9CB),(0xF9CC),(0xF9CD),(0xF9CE),(0xF9CF), -(0xF9D0),(0xF9D1),(0xF9D2),(0xF9D3),(0xF9D4),(0xF9D5),(0xF9D6),(0xF9D7), -(0xF9D8),(0xF9D9),(0xF9DA),(0xF9DB),(0xF9DC),(0xF9DD),(0xF9DE),(0xF9DF), -(0xF9E0),(0xF9E1),(0xF9E2),(0xF9E3),(0xF9E4),(0xF9E5),(0xF9E6),(0xF9E7), -(0xF9E8),(0xF9E9),(0xF9EA),(0xF9EB),(0xF9EC),(0xF9ED),(0xF9EE),(0xF9EF), -(0xF9F0),(0xF9F1),(0xF9F2),(0xF9F3),(0xF9F4),(0xF9F5),(0xF9F6),(0xF9F7), -(0xF9F8),(0xF9F9),(0xF9FA),(0xF9FB),(0xF9FC); - -#Test that all the characters are stored correctly -SELECT HEX(c1) FROM t1; - -#Test conversion to ucs2 -CREATE TABLE t2 SELECT CONVERT(c1 USING ucs2) AS c1 FROM t1; -SELECT HEX(c1) FROM t2; - -#Test round trip conversion -CREATE TABLE t3 SELECT CONVERT(c1 USING cp932) AS c1 FROM t2; -SELECT HEX(c1) FROM t3; - -#Test conversion to eucjpms -CREATE TABLE t4 SELECT CONVERT(c1 USING eucjpms) AS c1 FROM t1; -SELECT HEX(c1) FROM t4; - -DROP TABLE t1; -DROP TABLE t2; -DROP TABLE t3; -DROP TABLE t4; - -SET collation_connection='cp932_japanese_ci'; --- source include/ctype_filesort.inc --- source include/ctype_like_range_f1f2.inc -SET collation_connection='cp932_bin'; --- source include/ctype_filesort.inc --- source include/ctype_like_range_f1f2.inc - -# -# Bug#29333 myisam corruption with -# character set cp932 collate cp932_japanese_ci -# -create table t2 (a char(1)); -insert into t2 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'); -insert into t2 values ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F'); -create table t1 ( - a varchar(2) character set cp932 -) engine=myisam; ---disable_warnings -insert into t1 -select unhex(concat(t24.a, t23.a, t22.a, t21.a)) -from t2 t21, t2 t22, t2 t23, t2 t24; ---enable_warnings -delete from t1 where a=''; -alter table t1 add key(a); -check table t1; -drop table t1; -drop table t2; - - -# -# Bug#12547: Inserting long string into varchar causes table crash in cp932 -# -create table t1 (col1 varchar(1)) character set cp932; -insert into t1 values ('a'); -insert into t1 values ('ab'); -select * from t1; -insert into t1 values ('abc'); -select * from t1; -drop table t1; - -# -# BUG#16217 - MySQL client misinterpretes multi-byte char as escape `\' -# - -# new command \C or charset ---exec $MYSQL --default-character-set=utf8 test -e "\C cp932 \g" ---exec $MYSQL --default-character-set=cp932 test -e "charset utf8;" - -# its usage to switch internally in mysql to requested charset ---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select '\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('\'); select * from t1; drop table t1;" ---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select '\'" ---exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select '\'" ---exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select '\'" - -# -# Bug#25815 Data truncated for column TEXT -# -set names utf8; -create table t1 (a text) default character set cp932; -insert into t1 values (_utf8 0xE38182); -show warnings; -select * from t1; -select hex(a) from t1; -drop table t1; diff --git a/mysql-test/t/ctype_cp932_binlog.test b/mysql-test/t/ctype_cp932_binlog.test deleted file mode 100644 index 7db8f311800..00000000000 --- a/mysql-test/t/ctype_cp932_binlog.test +++ /dev/null @@ -1,58 +0,0 @@ --- source include/not_embedded.inc --- source include/have_cp932.inc --- source include/have_log_bin.inc - ---character_set cp932 ---disable_warnings -drop table if exists t1; ---enable_warnings - -set names cp932; -set character_set_database = cp932; - -# Test prepared statement with 0x8300 sequence in parameter while -# running with cp932 client character set. -RESET MASTER; -CREATE TABLE t1(f1 blob); -PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)'; -SET @var1= x'8300'; -# TODO: Note that this doesn't actually test the code which was added for -# bug#11338 because this syntax for prepared statements causes the PS to -# be replicated differently than if we executed the PS from C or Java. -# Using this syntax, variable names are inserted into the binlog instead -# of values. The real goal of this test is to check the code that was -# added to Item_param::query_val_str() in order to do hex encoding of -# PS parameters when the client character set is cp932; -# Bug#11338 has an example java program which can be used to verify this -# code (and I have used it to test the fix) until there is some way to -# exercise this code from mysql-test-run. -EXECUTE stmt1 USING @var1; -SHOW BINLOG EVENTS FROM 98; -SELECT HEX(f1) FROM t1; -DROP table t1; -# end test for bug#11338 - -# End of 4.1 tests - -# -# Bug#18293: Values in stored procedure written to binlog unescaped -# - -delimiter |; -CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, - s2 CHAR(50) CHARACTER SET cp932, - d DECIMAL(10,2))| -CREATE PROCEDURE bug18293 (IN ins1 CHAR(50), - IN ins2 CHAR(50) CHARACTER SET cp932, - IN ind DECIMAL(10,2)) - BEGIN - INSERT INTO t4 VALUES (ins1, ins2, ind); - END| -CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)| -SELECT HEX(s1),HEX(s2),d FROM t4| -DROP PROCEDURE bug18293| -DROP TABLE t4| -SHOW BINLOG EVENTS FROM 362| -delimiter ;| - -# End of 5.0 tests diff --git a/mysql-test/t/ctype_cp932_binlog_row.test b/mysql-test/t/ctype_cp932_binlog_row.test new file mode 100644 index 00000000000..38614ea45c0 --- /dev/null +++ b/mysql-test/t/ctype_cp932_binlog_row.test @@ -0,0 +1,5 @@ +# This is a wrapper for binlog.test so that the same test case can be used +# For both statement and row based bin logs 11/07/2005 [jbm] + +-- source include/have_binlog_format_row.inc +-- source extra/binlog_tests/ctype_cp932_binlog.test diff --git a/mysql-test/t/ctype_cp932_binlog_stm.test b/mysql-test/t/ctype_cp932_binlog_stm.test new file mode 100644 index 00000000000..89df33a6df5 --- /dev/null +++ b/mysql-test/t/ctype_cp932_binlog_stm.test @@ -0,0 +1,44 @@ +# This is a wrapper for binlog.test so that the same test case can be used +# For both statement and row based bin logs 11/07/2005 [jbm] + +-- source include/have_binlog_format_mixed_or_statement.inc +-- source extra/binlog_tests/ctype_cp932_binlog.test + +# +# Bug#18293: Values in stored procedure written to binlog unescaped +# + +delimiter |; +CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, + s2 CHAR(50) CHARACTER SET cp932, + d DECIMAL(10,2))| +CREATE PROCEDURE bug18293 (IN ins1 CHAR(50), + IN ins2 CHAR(50) CHARACTER SET cp932, + IN ind DECIMAL(10,2)) + BEGIN + INSERT INTO t4 VALUES (ins1, ins2, ind); + END| +CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)| +SELECT HEX(s1),HEX(s2),d FROM t4| +DROP PROCEDURE bug18293| +DROP TABLE t4| +SHOW BINLOG EVENTS FROM 370| +delimiter ;| + +--echo End of 5.0 tests + +# +# #28436: Incorrect position in SHOW BINLOG EVENTS causes server coredump +# Note: 364 is a magic position (found experimentally, depends on +# the log's contents) that caused the server crash. + +--error 1220 +SHOW BINLOG EVENTS FROM 365; + +--echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment. +CREATE TABLE t1 (a varchar(16)) character set cp932; +INSERT INTO t1 VALUES (0x8372835E),(0x8352835E); +SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a); +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/ctype_create.test b/mysql-test/t/ctype_create.test index e88004bbb8c..060c09a0459 100644 --- a/mysql-test/t/ctype_create.test +++ b/mysql-test/t/ctype_create.test @@ -100,3 +100,8 @@ drop database mysqltest2; ALTER DATABASE DEFAULT CHARACTER SET latin2; # End of 4.1 tests + +--error 1102 +ALTER DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa DEFAULT CHARACTER SET latin2; +--error 1102 +ALTER DATABASE `` DEFAULT CHARACTER SET latin2; diff --git a/mysql-test/t/ctype_euckr.test b/mysql-test/t/ctype_euckr.test index 0aba830e725..fcb94e7b6d1 100644 --- a/mysql-test/t/ctype_euckr.test +++ b/mysql-test/t/ctype_euckr.test @@ -56,3 +56,54 @@ select hex(s1), hex(convert(s1 using utf8)) from t1 order by binary s1; drop table t1; --echo End of 5.0 tests + + +--echo Start of 5.4 tests + +--echo # +--echo # WL#3997 New euckr characters +--echo # +SET NAMES utf8; +CREATE TABLE t1 (a varchar(10) character set euckr); +INSERT INTO t1 VALUES (0xA2E6), (0xA2E7); +SELECT hex(a), hex(@utf8:=convert(a using utf8)), hex(convert(@utf8 using euckr)) FROM t1; +DROP TABLE t1; + +--echo # +--echo # WL#3332 Korean Enhancements +--echo # euckr valid codes are now [81..FE][41..5A,61..7A,81..FE] +--echo # + +CREATE TABLE t1 (a binary(1), key(a)); +--disable_query_log +let $1=255; +while($1) +{ + eval INSERT INTO t1 VALUES (unhex(hex($1))); + dec $1; +} +--enable_query_log + +CREATE TABLE t2 (s VARCHAR(4), a VARCHAR(1) CHARACTER SET euckr); +--disable_warnings +INSERT INTO t2 +SELECT hex(concat(t11.a, t12.a)), concat(t11.a, t12.a) +FROM t1 t11, t1 t12 +WHERE t11.a >= 0x81 AND t11.a <= 0xFE +AND t12.a >= 0x41 AND t12.a <= 0xFE +ORDER BY t11.a, t12.a; +--enable_warnings +SELECT s as bad_code FROM t2 WHERE a='' ORDER BY s; +DELETE FROM t2 WHERE a=''; +ALTER TABLE t2 ADD u VARCHAR(1) CHARACTER SET utf8, ADD a2 VARCHAR(1) CHARACTER SET euckr; +--disable_warnings +UPDATE t2 SET u=a, a2=u; +--enable_warnings +SELECT s as unassigned_code FROM t2 WHERE u='?'; +DELETE FROM t2 WHERE u='?'; +# Make sure there are no euckr->utf8->euckr roundtrip problems +SELECT count(*) as roundtrip_problem_chars FROM t2 WHERE hex(a) <> hex(a2); +SELECT s, hex(a), hex(u), hex(a2) FROM t2 ORDER BY s; +DROP TABLE t1, t2; + +--echo End of 5.4 tests diff --git a/mysql-test/t/ctype_filename.test b/mysql-test/t/ctype_filename.test new file mode 100644 index 00000000000..436ccfc4f2e --- /dev/null +++ b/mysql-test/t/ctype_filename.test @@ -0,0 +1,21 @@ +--disable_warnings +drop table if exists con, aux, nul, lpt1, com1, `clock$`; +--enable_warnings + +create table con (a int); +drop table con; + +create table aux (a int); +drop table aux; + +create table nul (a int); +drop table nul; + +create table lpt1 (a int); +drop table lpt1; + +create table com1 (a int); +drop table com1; + +create table `clock$` (a int); +drop table `clock$`; diff --git a/mysql-test/t/ctype_gbk_binlog.test b/mysql-test/t/ctype_gbk_binlog.test new file mode 100644 index 00000000000..e4c1bee19af --- /dev/null +++ b/mysql-test/t/ctype_gbk_binlog.test @@ -0,0 +1,37 @@ +-- source include/have_binlog_format_mixed_or_statement.inc +-- source include/have_gbk.inc + +RESET MASTER; +SET NAMES gbk; +--character_set gbk + +CREATE TABLE t1 ( + f1 BLOB +) ENGINE=MyISAM DEFAULT CHARSET=gbk; + +delimiter |; +CREATE PROCEDURE p1(IN val BLOB) +BEGIN + SET @tval = val; + SET @sql_cmd = CONCAT_WS(' ', 'insert into t1(f1) values(?)'); + PREPARE stmt FROM @sql_cmd; + EXECUTE stmt USING @tval; + DEALLOCATE PREPARE stmt; +END| +delimiter ;| + +SET @`tcontent`:=_binary 0x50434B000900000000000000E9000000 COLLATE `binary`/*!*/; +CALL p1(@`tcontent`); + +FLUSH LOGS; +DROP PROCEDURE p1; +RENAME TABLE t1 to t2; + +let $MYSQLD_DATADIR= `select @@datadir`; +--exec $MYSQL_BINLOG --force-if-open --short-form $MYSQLD_DATADIR/master-bin.000001 | $MYSQL +SELECT hex(f1) FROM t2; +SELECT hex(f1) FROM t1; + +DROP PROCEDURE p1; +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test index 5727603f1d3..b12436f77ba 100644 --- a/mysql-test/t/ctype_latin1.test +++ b/mysql-test/t/ctype_latin1.test @@ -111,6 +111,16 @@ SELECT convert(@str collate latin1_swedish_ci using utf8); # End of 4.1 tests +SET NAMES latin1; +--disable_warnings +DROP TABLE IF EXISTS `abcdef`; +--enable_warnings +CREATE TABLE `abcdef` (i int); +INSERT INTO `abcdef` VALUES (1); +INSERT INTO abcdef VALUES (2); +SELECT * FROM `abcdef`; +SELECT * FROM abcdef; +DROP TABLE `abcdef`; # # Bug#29499 Converting 'del' from ascii to Unicode results in 'question mark' # diff --git a/mysql-test/t/ctype_latin1_de.test b/mysql-test/t/ctype_latin1_de.test index d6a11a22857..1efbfa4a3ae 100644 --- a/mysql-test/t/ctype_latin1_de.test +++ b/mysql-test/t/ctype_latin1_de.test @@ -116,6 +116,7 @@ SELECT FIELD('ue',s1), FIELD('',s1), s1='ue', s1='' FROM t1; DROP TABLE t1; -- source include/ctype_filesort.inc +-- source include/ctype_german.inc # # Bug#7878 with utf8_general_ci, equals (=) has problem with diff --git a/mysql-test/t/ctype_ldml.test b/mysql-test/t/ctype_ldml.test index fc6ed0f2579..0395de273de 100644 --- a/mysql-test/t/ctype_ldml.test +++ b/mysql-test/t/ctype_ldml.test @@ -21,6 +21,39 @@ insert into t1 values ('a'); select * from t1 where c1='b'; drop table t1; + +# +# Bug#41084 full-text index added to custom UCA collation not working +# +CREATE TABLE t1 ( + col1 varchar(100) character set utf8 collate utf8_test_ci +); +INSERT INTO t1 (col1) VALUES ('abcd'),('efgh'),('ijkl'); +ALTER TABLE t1 ADD FULLTEXT INDEX (col1); +SELECT * FROM t1 where match (col1) against ('abcd'); +SELECT * FROM t1 where match (col1) against ('abcd' IN BOOLEAN MODE); +ALTER TABLE t1 ADD (col2 varchar(100) character set latin1); +UPDATE t1 SET col2=col1; +SELECT * FROM t1 WHERE col1=col2 ORDER BY col1; +DROP TABLE t1; + +--echo # +--echo # Bug#45645 Mysql server close all connection and restart using lower function +--echo # +CREATE TABLE t1 (a VARCHAR(10)) CHARACTER SET utf8 COLLATE utf8_test_ci; +INSERT INTO t1 (a) VALUES ('hello!'); +SELECT * FROM t1 WHERE LOWER(a)=LOWER('N'); +DROP TABLE t1; + +--echo # +--echo # Bug#43827 Server closes connections and restarts +--echo # +# Crash happened with a user-defined utf8 collation, +# on attempt to insert a string longer than the column can store. +CREATE TABLE t1 (c1 VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_test_ci); +INSERT INTO t1 SELECT REPEAT('a',11); +DROP TABLE t1; + # # Vietnamese experimental collation # @@ -61,3 +94,8 @@ select hex(c1) as h, c1 from t1 order by c1, h; select group_concat(hex(c1) order by hex(c1)) from t1 group by c1; select group_concat(c1 order by hex(c1) SEPARATOR '') from t1 group by c1; drop table t1; + +--echo Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20 +set names latin1; +show collation like 'latin1_test'; +select "foo" = "foo " collate latin1_test; diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test index 27cbdff451b..7de94e34dea 100644 --- a/mysql-test/t/ctype_sjis.test +++ b/mysql-test/t/ctype_sjis.test @@ -83,3 +83,13 @@ SET NAMES sjis; SELECT HEX('@\') FROM DUAL; # End of 4.1 tests + +--echo # Start of 5.1 tests + +--echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment. +CREATE TABLE t1 (a varchar(16)) character set sjis; +INSERT INTO t1 VALUES (0x8372835E),(0x8352835E); +SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a); +DROP TABLE t1; + +--echo # End of 5.1 tests diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index 27f833c0695..11a489ba24d 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -458,6 +458,7 @@ drop table t1; SET collation_connection='utf8_unicode_ci'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc +-- source include/ctype_german.inc # End of 4.1 tests diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 715b74dd2a8..e247110658b 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -377,6 +377,7 @@ drop table t1; SET collation_connection='ucs2_general_ci'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc +-- source include/ctype_german.inc -- source include/ctype_like_range_f1f2.inc SET NAMES latin1; SET collation_connection='ucs2_bin'; @@ -677,6 +678,17 @@ select * from t1 where a=if(b<10,_ucs2 0x00C0,_ucs2 0x0062); select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0); drop table t1; +# +# Bug#35720 ucs2 + pad_char_to_full_length = failure +# +CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET UCS2); +INSERT INTO t1 VALUES ('a'); +SET @@sql_mode=pad_char_to_full_length; +SELECT HEX(s1) FROM t1; +SET @@sql_mode=default; +SELECT HEX(s1) FROM t1; +DROP TABLE t1; + set collation_connection=ucs2_general_ci; --source include/ctype_regex.inc set names latin1; diff --git a/mysql-test/t/ctype_ucs_binlog.test b/mysql-test/t/ctype_ucs_binlog.test deleted file mode 100644 index 92d4458a9c2..00000000000 --- a/mysql-test/t/ctype_ucs_binlog.test +++ /dev/null @@ -1,21 +0,0 @@ ---source include/not_embedded.inc ---source include/have_ucs2.inc ---source include/have_log_bin.inc - -# -# Check correct binlogging of UCS2 user variables (BUG#3875) -# -SET TIMESTAMP=10000; -create table t2 (c char(30)) charset=ucs2; -set @v=convert('abc' using ucs2); -reset master; -insert into t2 values (@v); -show binlog events from 98; -# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we -# absolutely need variables names to be quoted and strings to be -# escaped). ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 -drop table t2; - -# End of 4.1 tests diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test index 7d191931934..400f1301dd3 100644 --- a/mysql-test/t/ctype_ujis.test +++ b/mysql-test/t/ctype_ujis.test @@ -94,7 +94,7 @@ CREATE TABLE t1 b VARCHAR(50) NOT NULL DEFAULT '', PRIMARY KEY (a), KEY b (b(10)) -) TYPE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; +) ENGINE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; --enable_warnings INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd'); INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh'); @@ -110,7 +110,7 @@ CREATE TABLE t1 b VARCHAR(50) NOT NULL DEFAULT '', PRIMARY KEY (a), KEY b (b(10)) -) TYPE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; +) ENGINE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; --enable_warnings INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd'); INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh'); diff --git a/mysql-test/t/ctype_ujis_ucs2.test b/mysql-test/t/ctype_ujis_ucs2.test new file mode 100644 index 00000000000..1a8702b2aa9 --- /dev/null +++ b/mysql-test/t/ctype_ujis_ucs2.test @@ -0,0 +1,1306 @@ +-- source include/have_ujis.inc +-- source include/have_ucs2.inc + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +# +# Tests for UJIS-to-Unicode and Unicode-to-UJIS mapping +# +# MySQL's "ujis" is x-eucjp-unicode-0.9. +# + +# +# A helper table, with codes 0xA1..0xFE +# +create table t2 (code binary(1)); +insert into t2 values (0xA1),(0xA2),(0xA3),(0xA4),(0xA5),(0xA6),(0xA7); +insert into t2 values (0xA8),(0xA9),(0xAA),(0xAB),(0xAC),(0xAD),(0xAE),(0xAF); +insert into t2 values (0xB0),(0xB1),(0xB2),(0xB3),(0xB4),(0xB5),(0xB6),(0xB7); +insert into t2 values (0xB8),(0xB9),(0xBA),(0xBB),(0xBC),(0xBD),(0xBE),(0xBF); +insert into t2 values (0xC0),(0xC1),(0xC2),(0xC3),(0xC4),(0xC5),(0xC6),(0xC7); +insert into t2 values (0xC8),(0xC9),(0xCA),(0xCB),(0xCC),(0xCD),(0xCE),(0xCF); +insert into t2 values (0xD0),(0xD1),(0xD2),(0xD3),(0xD4),(0xD5),(0xD6),(0xD7); +insert into t2 values (0xD8),(0xD9),(0xDA),(0xDB),(0xDC),(0xDD),(0xDE),(0xDF); +insert into t2 values (0xE0),(0xE1),(0xE2),(0xE3),(0xE4),(0xE5),(0xE6),(0xE7); +insert into t2 values (0xE8),(0xE9),(0xEA),(0xEB),(0xEC),(0xED),(0xEE),(0xEF); +insert into t2 values (0xF0),(0xF1),(0xF2),(0xF3),(0xF4),(0xF5),(0xF6),(0xF7); +insert into t2 values (0xF8),(0xF9),(0xFA),(0xFB),(0xFC),(0xFD),(0xFE); + +create table t1 +( + ujis varchar(1) character set ujis collate ujis_bin primary key, + ucs2 varchar(1) character set ucs2 not null default '', + ujis2 varchar(1) character set ujis not null default '', + name varchar(64) character set ujis not null default '' +); + +# +# A character from the ASCII (code set 0) +# is represented by one byte, in the range 0x00 - 0x7E. +# + +insert into t1 set ujis=0x00, name='U+0000 NULL'; +insert into t1 set ujis=0x01, name='U+0001 START OF HEADING'; +insert into t1 set ujis=0x02, name='U+0002 START OF TEXT'; +insert into t1 set ujis=0x03, name='U+0003 END OF TEXT'; +insert into t1 set ujis=0x04, name='U+0004 END OF TRANSMISSION'; +insert into t1 set ujis=0x05, name='U+0005 ENQUIRY'; +insert into t1 set ujis=0x06, name='U+0006 ACKNOWLEDGE'; +insert into t1 set ujis=0x07, name='U+0007 BELL'; +insert into t1 set ujis=0x08, name='U+0008 BACKSPACE'; +insert into t1 set ujis=0x09, name='U+0009 HORIZONTAL TABULATION'; +insert into t1 set ujis=0x0A, name='U+000A LINE FEED'; +insert into t1 set ujis=0x0B, name='U+000B VERTICAL TABULATION'; +insert into t1 set ujis=0x0C, name='U+000C FORM FEED'; +insert into t1 set ujis=0x0D, name='U+000D CARRIAGE RETURN'; +insert into t1 set ujis=0x0E, name='U+000E SHIFT OUT'; +insert into t1 set ujis=0x0F, name='U+000F SHIFT IN'; +insert into t1 set ujis=0x10, name='U+0010 DATA LINK ESCAPE'; +insert into t1 set ujis=0x11, name='U+0011 DEVICE CONTROL ONE'; +insert into t1 set ujis=0x12, name='U+0012 DEVICE CONTROL TWO'; +insert into t1 set ujis=0x13, name='U+0013 DEVICE CONTROL THREE'; +insert into t1 set ujis=0x14, name='U+0014 DEVICE CONTROL FOUR'; +insert into t1 set ujis=0x15, name='U+0015 NEGATIVE ACKNOWLEDGE'; +insert into t1 set ujis=0x16, name='U+0016 SYNCHRONOUS IDLE'; +insert into t1 set ujis=0x17, name='U+0017 END OF TRANSMISSION BLOCK'; +insert into t1 set ujis=0x18, name='U+0018 CANCEL'; +insert into t1 set ujis=0x19, name='U+0019 END OF MEDIUM'; +insert into t1 set ujis=0x1A, name='U+001A SUBSTITUTE'; +insert into t1 set ujis=0x1B, name='U+001B ESCAPE'; +insert into t1 set ujis=0x1C, name='U+001C FILE SEPARATOR'; +insert into t1 set ujis=0x1D, name='U+001D GROUP SEPARATOR'; +insert into t1 set ujis=0x1E, name='U+001E RECORD SEPARATOR'; +insert into t1 set ujis=0x1F, name='U+001F UNIT SEPARATOR'; +insert into t1 set ujis=0x20, name='U+0020 SPACE'; +insert into t1 set ujis=0x21, name='U+0021 EXCLAMATION MARK'; +insert into t1 set ujis=0x22, name='U+0022 QUOTATION MARK'; +insert into t1 set ujis=0x23, name='U+0023 NUMBER SIGN'; +insert into t1 set ujis=0x24, name='U+0024 DOLLAR SIGN'; +insert into t1 set ujis=0x25, name='U+0025 PERCENT SIGN'; +insert into t1 set ujis=0x26, name='U+0026 AMPERSAND'; +insert into t1 set ujis=0x27, name='U+0027 APOSTROPHE'; +insert into t1 set ujis=0x28, name='U+0028 LEFT PARENTHESIS'; +insert into t1 set ujis=0x29, name='U+0029 RIGHT PARENTHESIS'; +insert into t1 set ujis=0x2A, name='U+002A ASTERISK'; +insert into t1 set ujis=0x2B, name='U+002B PLUS SIGN'; +insert into t1 set ujis=0x2C, name='U+002C COMMA'; +insert into t1 set ujis=0x2D, name='U+002D HYPHEN-MINUS'; +insert into t1 set ujis=0x2E, name='U+002E FULL STOP'; +insert into t1 set ujis=0x2F, name='U+002F SOLIDUS'; +insert into t1 set ujis=0x30, name='U+0030 DIGIT ZERO'; +insert into t1 set ujis=0x31, name='U+0031 DIGIT ONE'; +insert into t1 set ujis=0x32, name='U+0032 DIGIT TWO'; +insert into t1 set ujis=0x33, name='U+0033 DIGIT THREE'; +insert into t1 set ujis=0x34, name='U+0034 DIGIT FOUR'; +insert into t1 set ujis=0x35, name='U+0035 DIGIT FIVE'; +insert into t1 set ujis=0x36, name='U+0036 DIGIT SIX'; +insert into t1 set ujis=0x37, name='U+0037 DIGIT SEVEN'; +insert into t1 set ujis=0x38, name='U+0038 DIGIT EIGHT'; +insert into t1 set ujis=0x39, name='U+0039 DIGIT NINE'; +insert into t1 set ujis=0x3A, name='U+003A COLON'; +insert into t1 set ujis=0x3B, name='U+003B SEMICOLON'; +insert into t1 set ujis=0x3C, name='U+003C LESS-THAN SIGN'; +insert into t1 set ujis=0x3D, name='U+003D EQUALS SIGN'; +insert into t1 set ujis=0x3E, name='U+003E GREATER-THAN SIGN'; +insert into t1 set ujis=0x3F, name='U+003F QUESTION MARK'; +insert into t1 set ujis=0x40, name='U+0040 COMMERCIAL AT'; +insert into t1 set ujis=0x41, name='U+0041 LATIN CAPITAL LETTER A'; +insert into t1 set ujis=0x42, name='U+0042 LATIN CAPITAL LETTER B'; +insert into t1 set ujis=0x43, name='U+0043 LATIN CAPITAL LETTER C'; +insert into t1 set ujis=0x44, name='U+0044 LATIN CAPITAL LETTER D'; +insert into t1 set ujis=0x45, name='U+0045 LATIN CAPITAL LETTER E'; +insert into t1 set ujis=0x46, name='U+0046 LATIN CAPITAL LETTER F'; +insert into t1 set ujis=0x47, name='U+0047 LATIN CAPITAL LETTER G'; +insert into t1 set ujis=0x48, name='U+0048 LATIN CAPITAL LETTER H'; +insert into t1 set ujis=0x49, name='U+0049 LATIN CAPITAL LETTER I'; +insert into t1 set ujis=0x4A, name='U+004A LATIN CAPITAL LETTER J'; +insert into t1 set ujis=0x4B, name='U+004B LATIN CAPITAL LETTER K'; +insert into t1 set ujis=0x4C, name='U+004C LATIN CAPITAL LETTER L'; +insert into t1 set ujis=0x4D, name='U+004D LATIN CAPITAL LETTER M'; +insert into t1 set ujis=0x4E, name='U+004E LATIN CAPITAL LETTER N'; +insert into t1 set ujis=0x4F, name='U+004F LATIN CAPITAL LETTER O'; +insert into t1 set ujis=0x50, name='U+0050 LATIN CAPITAL LETTER P'; +insert into t1 set ujis=0x51, name='U+0051 LATIN CAPITAL LETTER Q'; +insert into t1 set ujis=0x52, name='U+0052 LATIN CAPITAL LETTER R'; +insert into t1 set ujis=0x53, name='U+0053 LATIN CAPITAL LETTER S'; +insert into t1 set ujis=0x54, name='U+0054 LATIN CAPITAL LETTER T'; +insert into t1 set ujis=0x55, name='U+0055 LATIN CAPITAL LETTER U'; +insert into t1 set ujis=0x56, name='U+0056 LATIN CAPITAL LETTER V'; +insert into t1 set ujis=0x57, name='U+0057 LATIN CAPITAL LETTER W'; +insert into t1 set ujis=0x58, name='U+0058 LATIN CAPITAL LETTER X'; +insert into t1 set ujis=0x59, name='U+0059 LATIN CAPITAL LETTER Y'; +insert into t1 set ujis=0x5A, name='U+005A LATIN CAPITAL LETTER Z'; +insert into t1 set ujis=0x5B, name='U+005B LEFT SQUARE BRACKET'; +insert into t1 set ujis=0x5C, name='U+005C REVERSE SOLIDUS'; +insert into t1 set ujis=0x5D, name='U+005D RIGHT SQUARE BRACKET'; +insert into t1 set ujis=0x5E, name='U+005E CIRCUMFLEX ACCENT'; +insert into t1 set ujis=0x5F, name='U+005F LOW LINE'; +insert into t1 set ujis=0x60, name='U+0060 GRAVE ACCENT'; +insert into t1 set ujis=0x61, name='U+0061 LATIN SMALL LETTER A'; +insert into t1 set ujis=0x62, name='U+0062 LATIN SMALL LETTER B'; +insert into t1 set ujis=0x63, name='U+0063 LATIN SMALL LETTER C'; +insert into t1 set ujis=0x64, name='U+0064 LATIN SMALL LETTER D'; +insert into t1 set ujis=0x65, name='U+0065 LATIN SMALL LETTER E'; +insert into t1 set ujis=0x66, name='U+0066 LATIN SMALL LETTER F'; +insert into t1 set ujis=0x67, name='U+0067 LATIN SMALL LETTER G'; +insert into t1 set ujis=0x68, name='U+0068 LATIN SMALL LETTER H'; +insert into t1 set ujis=0x69, name='U+0069 LATIN SMALL LETTER I'; +insert into t1 set ujis=0x6A, name='U+006A LATIN SMALL LETTER J'; +insert into t1 set ujis=0x6B, name='U+006B LATIN SMALL LETTER K'; +insert into t1 set ujis=0x6C, name='U+006C LATIN SMALL LETTER L'; +insert into t1 set ujis=0x6D, name='U+006D LATIN SMALL LETTER M'; +insert into t1 set ujis=0x6E, name='U+006E LATIN SMALL LETTER N'; +insert into t1 set ujis=0x6F, name='U+006F LATIN SMALL LETTER O'; +insert into t1 set ujis=0x70, name='U+0070 LATIN SMALL LETTER P'; +insert into t1 set ujis=0x71, name='U+0071 LATIN SMALL LETTER Q'; +insert into t1 set ujis=0x72, name='U+0072 LATIN SMALL LETTER R'; +insert into t1 set ujis=0x73, name='U+0073 LATIN SMALL LETTER S'; +insert into t1 set ujis=0x74, name='U+0074 LATIN SMALL LETTER T'; +insert into t1 set ujis=0x75, name='U+0075 LATIN SMALL LETTER U'; +insert into t1 set ujis=0x76, name='U+0076 LATIN SMALL LETTER V'; +insert into t1 set ujis=0x77, name='U+0077 LATIN SMALL LETTER W'; +insert into t1 set ujis=0x78, name='U+0078 LATIN SMALL LETTER X'; +insert into t1 set ujis=0x79, name='U+0079 LATIN SMALL LETTER Y'; +insert into t1 set ujis=0x7A, name='U+007A LATIN SMALL LETTER Z'; +insert into t1 set ujis=0x7B, name='U+007B LEFT CURLY BRACKET'; +insert into t1 set ujis=0x7C, name='U+007C VERTICAL LINE'; +insert into t1 set ujis=0x7D, name='U+007D RIGHT CURLY BRACKET'; +insert into t1 set ujis=0x7E, name='U+007E TILDE'; +insert into t1 set ujis=0x7F, name='U+007F DELETE'; + + +# +# A character from JIS-X-0208 (code set 1) +# is represented by two bytes, +# both in the range 0xA1 - 0xFE. +# Codes according to: +# ftp://ftp.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0208.TXT +# +# Fill table t1 with codes "[A1..FE][A1..FE]" using helper table t2. +# 8836 codes total: +# +insert into t1 (ujis) select concat(t21.code,t22.code) from t2 t21, t2 t22 order by 1; + +update t1 set name='U+3000 IDEOGRAPHIC SPACE' where ujis=0xA1A1; +update t1 set name='U+3001 IDEOGRAPHIC COMMA' where ujis=0xA1A2; +update t1 set name='U+3002 IDEOGRAPHIC FULL STOP' where ujis=0xA1A3; +update t1 set name='U+FF0C FULLWIDTH COMMA' where ujis=0xA1A4; +update t1 set name='U+FF0E FULLWIDTH FULL STOP' where ujis=0xA1A5; +update t1 set name='U+30FB KATAKANA MIDDLE DOT' where ujis=0xA1A6; +update t1 set name='U+FF1A FULLWIDTH COLON' where ujis=0xA1A7; +update t1 set name='U+FF1B FULLWIDTH SEMICOLON' where ujis=0xA1A8; +update t1 set name='U+FF1F FULLWIDTH QUESTION MARK' where ujis=0xA1A9; +update t1 set name='U+FF01 FULLWIDTH EXCLAMATION MARK' where ujis=0xA1AA; +update t1 set name='U+309B KATAKANA-HIRAGANA VOICED SOUND MARK' where ujis=0xA1AB; +update t1 set name='U+309C KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK' where ujis=0xA1AC; +update t1 set name='U+00B4 ACUTE ACCENT' where ujis=0xA1AD; +update t1 set name='U+FF40 FULLWIDTH GRAVE ACCENT' where ujis=0xA1AE; +update t1 set name='U+00A8 DIAERESIS' where ujis=0xA1AF; +update t1 set name='U+FF3E FULLWIDTH CIRCUMFLEX ACCENT' where ujis=0xA1B0; +update t1 set name='U+FFE3 FULLWIDTH MACRON' where ujis=0xA1B1; +update t1 set name='U+FF3F FULLWIDTH LOW LINE' where ujis=0xA1B2; +update t1 set name='U+30FD KATAKANA ITERATION MARK' where ujis=0xA1B3; +update t1 set name='U+30FE KATAKANA VOICED ITERATION MARK' where ujis=0xA1B4; +update t1 set name='U+309D HIRAGANA ITERATION MARK' where ujis=0xA1B5; +update t1 set name='U+309E HIRAGANA VOICED ITERATION MARK' where ujis=0xA1B6; +update t1 set name='U+3003 DITTO MARK' where ujis=0xA1B7; +update t1 set name='U+4EDD <CJK>' where ujis=0xA1B8; +update t1 set name='U+3005 IDEOGRAPHIC ITERATION MARK' where ujis=0xA1B9; +update t1 set name='U+3006 IDEOGRAPHIC CLOSING MARK' where ujis=0xA1BA; +update t1 set name='U+3007 IDEOGRAPHIC NUMBER ZERO' where ujis=0xA1BB; +update t1 set name='U+30FC KATAKANA-HIRAGANA PROLONGED SOUND MARK' where ujis=0xA1BC; +update t1 set name='U+2015 HORIZONTAL BAR' where ujis=0xA1BD; +update t1 set name='U+2010 HYPHEN' where ujis=0xA1BE; +update t1 set name='U+FF0F FULLWIDTH SOLIDUS' where ujis=0xA1BF; +update t1 set name='U+005C REVERSE SOLIDUS' where ujis=0xA1C0; +update t1 set name='U+301C WAVE DASH' where ujis=0xA1C1; +update t1 set name='U+2016 DOUBLE VERTICAL LINE' where ujis=0xA1C2; +update t1 set name='U+FF5C FULLWIDTH VERTICAL LINE' where ujis=0xA1C3; +update t1 set name='U+2026 HORIZONTAL ELLIPSIS' where ujis=0xA1C4; +update t1 set name='U+2025 TWO DOT LEADER' where ujis=0xA1C5; +update t1 set name='U+2018 LEFT SINGLE QUOTATION MARK' where ujis=0xA1C6; +update t1 set name='U+2019 RIGHT SINGLE QUOTATION MARK' where ujis=0xA1C7; +update t1 set name='U+201C LEFT DOUBLE QUOTATION MARK' where ujis=0xA1C8; +update t1 set name='U+201D RIGHT DOUBLE QUOTATION MARK' where ujis=0xA1C9; +update t1 set name='U+FF08 FULLWIDTH LEFT PARENTHESIS' where ujis=0xA1CA; +update t1 set name='U+FF09 FULLWIDTH RIGHT PARENTHESIS' where ujis=0xA1CB; +update t1 set name='U+3014 LEFT TORTOISE SHELL BRACKET' where ujis=0xA1CC; +update t1 set name='U+3015 RIGHT TORTOISE SHELL BRACKET' where ujis=0xA1CD; +update t1 set name='U+FF3B FULLWIDTH LEFT SQUARE BRACKET' where ujis=0xA1CE; +update t1 set name='U+FF3D FULLWIDTH RIGHT SQUARE BRACKET' where ujis=0xA1CF; +update t1 set name='U+FF5B FULLWIDTH LEFT CURLY BRACKET' where ujis=0xA1D0; +update t1 set name='U+FF5D FULLWIDTH RIGHT CURLY BRACKET' where ujis=0xA1D1; +update t1 set name='U+3008 LEFT ANGLE BRACKET' where ujis=0xA1D2; +update t1 set name='U+3009 RIGHT ANGLE BRACKET' where ujis=0xA1D3; +update t1 set name='U+300A LEFT DOUBLE ANGLE BRACKET' where ujis=0xA1D4; +update t1 set name='U+300B RIGHT DOUBLE ANGLE BRACKET' where ujis=0xA1D5; +update t1 set name='U+300C LEFT CORNER BRACKET' where ujis=0xA1D6; +update t1 set name='U+300D RIGHT CORNER BRACKET' where ujis=0xA1D7; +update t1 set name='U+300E LEFT WHITE CORNER BRACKET' where ujis=0xA1D8; +update t1 set name='U+300F RIGHT WHITE CORNER BRACKET' where ujis=0xA1D9; +update t1 set name='U+3010 LEFT BLACK LENTICULAR BRACKET' where ujis=0xA1DA; +update t1 set name='U+3011 RIGHT BLACK LENTICULAR BRACKET' where ujis=0xA1DB; +update t1 set name='U+FF0B FULLWIDTH PLUS SIGN' where ujis=0xA1DC; +update t1 set name='U+2212 MINUS SIGN' where ujis=0xA1DD; +update t1 set name='U+00B1 PLUS-MINUS SIGN' where ujis=0xA1DE; +update t1 set name='U+00D7 MULTIPLICATION SIGN' where ujis=0xA1DF; +update t1 set name='U+00F7 DIVISION SIGN' where ujis=0xA1E0; +update t1 set name='U+FF1D FULLWIDTH EQUALS SIGN' where ujis=0xA1E1; +update t1 set name='U+2260 NOT EQUAL TO' where ujis=0xA1E2; +update t1 set name='U+FF1C FULLWIDTH LESS-THAN SIGN' where ujis=0xA1E3; +update t1 set name='U+FF1E FULLWIDTH GREATER-THAN SIGN' where ujis=0xA1E4; +update t1 set name='U+2266 LESS-THAN OVER EQUAL TO' where ujis=0xA1E5; +update t1 set name='U+2267 GREATER-THAN OVER EQUAL TO' where ujis=0xA1E6; +update t1 set name='U+221E INFINITY' where ujis=0xA1E7; +update t1 set name='U+2234 THEREFORE' where ujis=0xA1E8; +update t1 set name='U+2642 MALE SIGN' where ujis=0xA1E9; +update t1 set name='U+2640 FEMALE SIGN' where ujis=0xA1EA; +update t1 set name='U+00B0 DEGREE SIGN' where ujis=0xA1EB; +update t1 set name='U+2032 PRIME' where ujis=0xA1EC; +update t1 set name='U+2033 DOUBLE PRIME' where ujis=0xA1ED; +update t1 set name='U+2103 DEGREE CELSIUS' where ujis=0xA1EE; +update t1 set name='U+FFE5 FULLWIDTH YEN SIGN' where ujis=0xA1EF; +update t1 set name='U+FF04 FULLWIDTH DOLLAR SIGN' where ujis=0xA1F0; +update t1 set name='U+00A2 CENT SIGN' where ujis=0xA1F1; +update t1 set name='U+00A3 POUND SIGN' where ujis=0xA1F2; +update t1 set name='U+FF05 FULLWIDTH PERCENT SIGN' where ujis=0xA1F3; +update t1 set name='U+FF03 FULLWIDTH NUMBER SIGN' where ujis=0xA1F4; +update t1 set name='U+FF06 FULLWIDTH AMPERSAND' where ujis=0xA1F5; +update t1 set name='U+FF0A FULLWIDTH ASTERISK' where ujis=0xA1F6; +update t1 set name='U+FF20 FULLWIDTH COMMERCIAL AT' where ujis=0xA1F7; +update t1 set name='U+00A7 SECTION SIGN' where ujis=0xA1F8; +update t1 set name='U+2606 WHITE STAR' where ujis=0xA1F9; +update t1 set name='U+2605 BLACK STAR' where ujis=0xA1FA; +update t1 set name='U+25CB WHITE CIRCLE' where ujis=0xA1FB; +update t1 set name='U+25CF BLACK CIRCLE' where ujis=0xA1FC; +update t1 set name='U+25CE BULLSEYE' where ujis=0xA1FD; +update t1 set name='U+25C7 WHITE DIAMOND' where ujis=0xA1FE; +update t1 set name='U+25C6 BLACK DIAMOND' where ujis=0xA2A1; +update t1 set name='U+25A1 WHITE SQUARE' where ujis=0xA2A2; +update t1 set name='U+25A0 BLACK SQUARE' where ujis=0xA2A3; +update t1 set name='U+25B3 WHITE UP-POINTING TRIANGLE' where ujis=0xA2A4; +update t1 set name='U+25B2 BLACK UP-POINTING TRIANGLE' where ujis=0xA2A5; +update t1 set name='U+25BD WHITE DOWN-POINTING TRIANGLE' where ujis=0xA2A6; +update t1 set name='U+25BC BLACK DOWN-POINTING TRIANGLE' where ujis=0xA2A7; +update t1 set name='U+203B REFERENCE MARK' where ujis=0xA2A8; +update t1 set name='U+3012 POSTAL MARK' where ujis=0xA2A9; +update t1 set name='U+2192 RIGHTWARDS ARROW' where ujis=0xA2AA; +update t1 set name='U+2190 LEFTWARDS ARROW' where ujis=0xA2AB; +update t1 set name='U+2191 UPWARDS ARROW' where ujis=0xA2AC; +update t1 set name='U+2193 DOWNWARDS ARROW' where ujis=0xA2AD; +update t1 set name='U+3013 GETA MARK' where ujis=0xA2AE; +update t1 set name='U+2208 ELEMENT OF' where ujis=0xA2BA; +update t1 set name='U+220B CONTAINS AS MEMBER' where ujis=0xA2BB; +update t1 set name='U+2286 SUBset OF OR EQUAL TO' where ujis=0xA2BC; +update t1 set name='U+2287 SUPERset OF OR EQUAL TO' where ujis=0xA2BD; +update t1 set name='U+2282 SUBset OF' where ujis=0xA2BE; +update t1 set name='U+2283 SUPERset OF' where ujis=0xA2BF; +update t1 set name='U+222A UNION' where ujis=0xA2C0; +update t1 set name='U+2229 INTERSECTION' where ujis=0xA2C1; +update t1 set name='U+2227 LOGICAL AND' where ujis=0xA2CA; +update t1 set name='U+2228 LOGICAL OR' where ujis=0xA2CB; +update t1 set name='U+00AC NOT SIGN' where ujis=0xA2CC; +update t1 set name='U+21D2 RIGHTWARDS DOUBLE ARROW' where ujis=0xA2CD; +update t1 set name='U+21D4 LEFT RIGHT DOUBLE ARROW' where ujis=0xA2CE; +update t1 set name='U+2200 FOR ALL' where ujis=0xA2CF; +update t1 set name='U+2203 THERE EXISTS' where ujis=0xA2D0; +update t1 set name='U+2220 ANGLE' where ujis=0xA2DC; +update t1 set name='U+22A5 UP TACK' where ujis=0xA2DD; +update t1 set name='U+2312 ARC' where ujis=0xA2DE; +update t1 set name='U+2202 PARTIAL DIFFERENTIAL' where ujis=0xA2DF; +update t1 set name='U+2207 NABLA' where ujis=0xA2E0; +update t1 set name='U+2261 IDENTICAL TO' where ujis=0xA2E1; +update t1 set name='U+2252 APPROXIMATELY EQUAL TO OR THE IMAGE OF' where ujis=0xA2E2; +update t1 set name='U+226A MUCH LESS-THAN' where ujis=0xA2E3; +update t1 set name='U+226B MUCH GREATER-THAN' where ujis=0xA2E4; +update t1 set name='U+221A SQUARE ROOT' where ujis=0xA2E5; +update t1 set name='U+223D REVERSED TILDE' where ujis=0xA2E6; +update t1 set name='U+221D PROPORTIONAL TO' where ujis=0xA2E7; +update t1 set name='U+2235 BECAUSE' where ujis=0xA2E8; +update t1 set name='U+222B INTEGRAL' where ujis=0xA2E9; +update t1 set name='U+222C DOUBLE INTEGRAL' where ujis=0xA2EA; +update t1 set name='U+212B ANGSTROM SIGN' where ujis=0xA2F2; +update t1 set name='U+2030 PER MILLE SIGN' where ujis=0xA2F3; +update t1 set name='U+266F MUSIC SHARP SIGN' where ujis=0xA2F4; +update t1 set name='U+266D MUSIC FLAT SIGN' where ujis=0xA2F5; +update t1 set name='U+266A EIGHTH NOTE' where ujis=0xA2F6; +update t1 set name='U+2020 DAGGER' where ujis=0xA2F7; +update t1 set name='U+2021 DOUBLE DAGGER' where ujis=0xA2F8; +update t1 set name='U+00B6 PILCROW SIGN' where ujis=0xA2F9; +update t1 set name='U+25EF LARGE CIRCLE' where ujis=0xA2FE; +update t1 set name='U+FF10 FULLWIDTH DIGIT ZERO' where ujis=0xA3B0; +update t1 set name='U+FF11 FULLWIDTH DIGIT ONE' where ujis=0xA3B1; +update t1 set name='U+FF12 FULLWIDTH DIGIT TWO' where ujis=0xA3B2; +update t1 set name='U+FF13 FULLWIDTH DIGIT THREE' where ujis=0xA3B3; +update t1 set name='U+FF14 FULLWIDTH DIGIT FOUR' where ujis=0xA3B4; +update t1 set name='U+FF15 FULLWIDTH DIGIT FIVE' where ujis=0xA3B5; +update t1 set name='U+FF16 FULLWIDTH DIGIT SIX' where ujis=0xA3B6; +update t1 set name='U+FF17 FULLWIDTH DIGIT SEVEN' where ujis=0xA3B7; +update t1 set name='U+FF18 FULLWIDTH DIGIT EIGHT' where ujis=0xA3B8; +update t1 set name='U+FF19 FULLWIDTH DIGIT NINE' where ujis=0xA3B9; +update t1 set name='U+FF21 FULLWIDTH LATIN CAPITAL LETTER A' where ujis=0xA3C1; +update t1 set name='U+FF22 FULLWIDTH LATIN CAPITAL LETTER B' where ujis=0xA3C2; +update t1 set name='U+FF23 FULLWIDTH LATIN CAPITAL LETTER C' where ujis=0xA3C3; +update t1 set name='U+FF24 FULLWIDTH LATIN CAPITAL LETTER D' where ujis=0xA3C4; +update t1 set name='U+FF25 FULLWIDTH LATIN CAPITAL LETTER E' where ujis=0xA3C5; +update t1 set name='U+FF26 FULLWIDTH LATIN CAPITAL LETTER F' where ujis=0xA3C6; +update t1 set name='U+FF27 FULLWIDTH LATIN CAPITAL LETTER G' where ujis=0xA3C7; +update t1 set name='U+FF28 FULLWIDTH LATIN CAPITAL LETTER H' where ujis=0xA3C8; +update t1 set name='U+FF29 FULLWIDTH LATIN CAPITAL LETTER I' where ujis=0xA3C9; +update t1 set name='U+FF2A FULLWIDTH LATIN CAPITAL LETTER J' where ujis=0xA3CA; +update t1 set name='U+FF2B FULLWIDTH LATIN CAPITAL LETTER K' where ujis=0xA3CB; +update t1 set name='U+FF2C FULLWIDTH LATIN CAPITAL LETTER L' where ujis=0xA3CC; +update t1 set name='U+FF2D FULLWIDTH LATIN CAPITAL LETTER M' where ujis=0xA3CD; +update t1 set name='U+FF2E FULLWIDTH LATIN CAPITAL LETTER N' where ujis=0xA3CE; +update t1 set name='U+FF2F FULLWIDTH LATIN CAPITAL LETTER O' where ujis=0xA3CF; +update t1 set name='U+FF30 FULLWIDTH LATIN CAPITAL LETTER P' where ujis=0xA3D0; +update t1 set name='U+FF31 FULLWIDTH LATIN CAPITAL LETTER Q' where ujis=0xA3D1; +update t1 set name='U+FF32 FULLWIDTH LATIN CAPITAL LETTER R' where ujis=0xA3D2; +update t1 set name='U+FF33 FULLWIDTH LATIN CAPITAL LETTER S' where ujis=0xA3D3; +update t1 set name='U+FF34 FULLWIDTH LATIN CAPITAL LETTER T' where ujis=0xA3D4; +update t1 set name='U+FF35 FULLWIDTH LATIN CAPITAL LETTER U' where ujis=0xA3D5; +update t1 set name='U+FF36 FULLWIDTH LATIN CAPITAL LETTER V' where ujis=0xA3D6; +update t1 set name='U+FF37 FULLWIDTH LATIN CAPITAL LETTER W' where ujis=0xA3D7; +update t1 set name='U+FF38 FULLWIDTH LATIN CAPITAL LETTER X' where ujis=0xA3D8; +update t1 set name='U+FF39 FULLWIDTH LATIN CAPITAL LETTER Y' where ujis=0xA3D9; +update t1 set name='U+FF3A FULLWIDTH LATIN CAPITAL LETTER Z' where ujis=0xA3DA; +update t1 set name='U+FF41 FULLWIDTH LATIN SMALL LETTER A' where ujis=0xA3E1; +update t1 set name='U+FF42 FULLWIDTH LATIN SMALL LETTER B' where ujis=0xA3E2; +update t1 set name='U+FF43 FULLWIDTH LATIN SMALL LETTER C' where ujis=0xA3E3; +update t1 set name='U+FF44 FULLWIDTH LATIN SMALL LETTER D' where ujis=0xA3E4; +update t1 set name='U+FF45 FULLWIDTH LATIN SMALL LETTER E' where ujis=0xA3E5; +update t1 set name='U+FF46 FULLWIDTH LATIN SMALL LETTER F' where ujis=0xA3E6; +update t1 set name='U+FF47 FULLWIDTH LATIN SMALL LETTER G' where ujis=0xA3E7; +update t1 set name='U+FF48 FULLWIDTH LATIN SMALL LETTER H' where ujis=0xA3E8; +update t1 set name='U+FF49 FULLWIDTH LATIN SMALL LETTER I' where ujis=0xA3E9; +update t1 set name='U+FF4A FULLWIDTH LATIN SMALL LETTER J' where ujis=0xA3EA; +update t1 set name='U+FF4B FULLWIDTH LATIN SMALL LETTER K' where ujis=0xA3EB; +update t1 set name='U+FF4C FULLWIDTH LATIN SMALL LETTER L' where ujis=0xA3EC; +update t1 set name='U+FF4D FULLWIDTH LATIN SMALL LETTER M' where ujis=0xA3ED; +update t1 set name='U+FF4E FULLWIDTH LATIN SMALL LETTER N' where ujis=0xA3EE; +update t1 set name='U+FF4F FULLWIDTH LATIN SMALL LETTER O' where ujis=0xA3EF; +update t1 set name='U+FF50 FULLWIDTH LATIN SMALL LETTER P' where ujis=0xA3F0; +update t1 set name='U+FF51 FULLWIDTH LATIN SMALL LETTER Q' where ujis=0xA3F1; +update t1 set name='U+FF52 FULLWIDTH LATIN SMALL LETTER R' where ujis=0xA3F2; +update t1 set name='U+FF53 FULLWIDTH LATIN SMALL LETTER S' where ujis=0xA3F3; +update t1 set name='U+FF54 FULLWIDTH LATIN SMALL LETTER T' where ujis=0xA3F4; +update t1 set name='U+FF55 FULLWIDTH LATIN SMALL LETTER U' where ujis=0xA3F5; +update t1 set name='U+FF56 FULLWIDTH LATIN SMALL LETTER V' where ujis=0xA3F6; +update t1 set name='U+FF57 FULLWIDTH LATIN SMALL LETTER W' where ujis=0xA3F7; +update t1 set name='U+FF58 FULLWIDTH LATIN SMALL LETTER X' where ujis=0xA3F8; +update t1 set name='U+FF59 FULLWIDTH LATIN SMALL LETTER Y' where ujis=0xA3F9; +update t1 set name='U+FF5A FULLWIDTH LATIN SMALL LETTER Z' where ujis=0xA3FA; +update t1 set name='U+3041 HIRAGANA LETTER SMALL A' where ujis=0xA4A1; +update t1 set name='U+3042 HIRAGANA LETTER A' where ujis=0xA4A2; +update t1 set name='U+3043 HIRAGANA LETTER SMALL I' where ujis=0xA4A3; +update t1 set name='U+3044 HIRAGANA LETTER I' where ujis=0xA4A4; +update t1 set name='U+3045 HIRAGANA LETTER SMALL U' where ujis=0xA4A5; +update t1 set name='U+3046 HIRAGANA LETTER U' where ujis=0xA4A6; +update t1 set name='U+3047 HIRAGANA LETTER SMALL E' where ujis=0xA4A7; +update t1 set name='U+3048 HIRAGANA LETTER E' where ujis=0xA4A8; +update t1 set name='U+3049 HIRAGANA LETTER SMALL O' where ujis=0xA4A9; +update t1 set name='U+304A HIRAGANA LETTER O' where ujis=0xA4AA; +update t1 set name='U+304B HIRAGANA LETTER KA' where ujis=0xA4AB; +update t1 set name='U+304C HIRAGANA LETTER GA' where ujis=0xA4AC; +update t1 set name='U+304D HIRAGANA LETTER KI' where ujis=0xA4AD; +update t1 set name='U+304E HIRAGANA LETTER GI' where ujis=0xA4AE; +update t1 set name='U+304F HIRAGANA LETTER KU' where ujis=0xA4AF; +update t1 set name='U+3050 HIRAGANA LETTER GU' where ujis=0xA4B0; +update t1 set name='U+3051 HIRAGANA LETTER KE' where ujis=0xA4B1; +update t1 set name='U+3052 HIRAGANA LETTER GE' where ujis=0xA4B2; +update t1 set name='U+3053 HIRAGANA LETTER KO' where ujis=0xA4B3; +update t1 set name='U+3054 HIRAGANA LETTER GO' where ujis=0xA4B4; +update t1 set name='U+3055 HIRAGANA LETTER SA' where ujis=0xA4B5; +update t1 set name='U+3056 HIRAGANA LETTER ZA' where ujis=0xA4B6; +update t1 set name='U+3057 HIRAGANA LETTER SI' where ujis=0xA4B7; +update t1 set name='U+3058 HIRAGANA LETTER ZI' where ujis=0xA4B8; +update t1 set name='U+3059 HIRAGANA LETTER SU' where ujis=0xA4B9; +update t1 set name='U+305A HIRAGANA LETTER ZU' where ujis=0xA4BA; +update t1 set name='U+305B HIRAGANA LETTER SE' where ujis=0xA4BB; +update t1 set name='U+305C HIRAGANA LETTER ZE' where ujis=0xA4BC; +update t1 set name='U+305D HIRAGANA LETTER SO' where ujis=0xA4BD; +update t1 set name='U+305E HIRAGANA LETTER ZO' where ujis=0xA4BE; +update t1 set name='U+305F HIRAGANA LETTER TA' where ujis=0xA4BF; +update t1 set name='U+3060 HIRAGANA LETTER DA' where ujis=0xA4C0; +update t1 set name='U+3061 HIRAGANA LETTER TI' where ujis=0xA4C1; +update t1 set name='U+3062 HIRAGANA LETTER DI' where ujis=0xA4C2; +update t1 set name='U+3063 HIRAGANA LETTER SMALL TU' where ujis=0xA4C3; +update t1 set name='U+3064 HIRAGANA LETTER TU' where ujis=0xA4C4; +update t1 set name='U+3065 HIRAGANA LETTER DU' where ujis=0xA4C5; +update t1 set name='U+3066 HIRAGANA LETTER TE' where ujis=0xA4C6; +update t1 set name='U+3067 HIRAGANA LETTER DE' where ujis=0xA4C7; +update t1 set name='U+3068 HIRAGANA LETTER TO' where ujis=0xA4C8; +update t1 set name='U+3069 HIRAGANA LETTER DO' where ujis=0xA4C9; +update t1 set name='U+306A HIRAGANA LETTER NA' where ujis=0xA4CA; +update t1 set name='U+306B HIRAGANA LETTER NI' where ujis=0xA4CB; +update t1 set name='U+306C HIRAGANA LETTER NU' where ujis=0xA4CC; +update t1 set name='U+306D HIRAGANA LETTER NE' where ujis=0xA4CD; +update t1 set name='U+306E HIRAGANA LETTER NO' where ujis=0xA4CE; +update t1 set name='U+306F HIRAGANA LETTER HA' where ujis=0xA4CF; +update t1 set name='U+3070 HIRAGANA LETTER BA' where ujis=0xA4D0; +update t1 set name='U+3071 HIRAGANA LETTER PA' where ujis=0xA4D1; +update t1 set name='U+3072 HIRAGANA LETTER HI' where ujis=0xA4D2; +update t1 set name='U+3073 HIRAGANA LETTER BI' where ujis=0xA4D3; +update t1 set name='U+3074 HIRAGANA LETTER PI' where ujis=0xA4D4; +update t1 set name='U+3075 HIRAGANA LETTER HU' where ujis=0xA4D5; +update t1 set name='U+3076 HIRAGANA LETTER BU' where ujis=0xA4D6; +update t1 set name='U+3077 HIRAGANA LETTER PU' where ujis=0xA4D7; +update t1 set name='U+3078 HIRAGANA LETTER HE' where ujis=0xA4D8; +update t1 set name='U+3079 HIRAGANA LETTER BE' where ujis=0xA4D9; +update t1 set name='U+307A HIRAGANA LETTER PE' where ujis=0xA4DA; +update t1 set name='U+307B HIRAGANA LETTER HO' where ujis=0xA4DB; +update t1 set name='U+307C HIRAGANA LETTER BO' where ujis=0xA4DC; +update t1 set name='U+307D HIRAGANA LETTER PO' where ujis=0xA4DD; +update t1 set name='U+307E HIRAGANA LETTER MA' where ujis=0xA4DE; +update t1 set name='U+307F HIRAGANA LETTER MI' where ujis=0xA4DF; +update t1 set name='U+3080 HIRAGANA LETTER MU' where ujis=0xA4E0; +update t1 set name='U+3081 HIRAGANA LETTER ME' where ujis=0xA4E1; +update t1 set name='U+3082 HIRAGANA LETTER MO' where ujis=0xA4E2; +update t1 set name='U+3083 HIRAGANA LETTER SMALL YA' where ujis=0xA4E3; +update t1 set name='U+3084 HIRAGANA LETTER YA' where ujis=0xA4E4; +update t1 set name='U+3085 HIRAGANA LETTER SMALL YU' where ujis=0xA4E5; +update t1 set name='U+3086 HIRAGANA LETTER YU' where ujis=0xA4E6; +update t1 set name='U+3087 HIRAGANA LETTER SMALL YO' where ujis=0xA4E7; +update t1 set name='U+3088 HIRAGANA LETTER YO' where ujis=0xA4E8; +update t1 set name='U+3089 HIRAGANA LETTER RA' where ujis=0xA4E9; +update t1 set name='U+308A HIRAGANA LETTER RI' where ujis=0xA4EA; +update t1 set name='U+308B HIRAGANA LETTER RU' where ujis=0xA4EB; +update t1 set name='U+308C HIRAGANA LETTER RE' where ujis=0xA4EC; +update t1 set name='U+308D HIRAGANA LETTER RO' where ujis=0xA4ED; +update t1 set name='U+308E HIRAGANA LETTER SMALL WA' where ujis=0xA4EE; +update t1 set name='U+308F HIRAGANA LETTER WA' where ujis=0xA4EF; +update t1 set name='U+3090 HIRAGANA LETTER WI' where ujis=0xA4F0; +update t1 set name='U+3091 HIRAGANA LETTER WE' where ujis=0xA4F1; +update t1 set name='U+3092 HIRAGANA LETTER WO' where ujis=0xA4F2; +update t1 set name='U+3093 HIRAGANA LETTER N' where ujis=0xA4F3; +update t1 set name='U+30A1 KATAKANA LETTER SMALL A' where ujis=0xA5A1; +update t1 set name='U+30A2 KATAKANA LETTER A' where ujis=0xA5A2; +update t1 set name='U+30A3 KATAKANA LETTER SMALL I' where ujis=0xA5A3; +update t1 set name='U+30A4 KATAKANA LETTER I' where ujis=0xA5A4; +update t1 set name='U+30A5 KATAKANA LETTER SMALL U' where ujis=0xA5A5; +update t1 set name='U+30A6 KATAKANA LETTER U' where ujis=0xA5A6; +update t1 set name='U+30A7 KATAKANA LETTER SMALL E' where ujis=0xA5A7; +update t1 set name='U+30A8 KATAKANA LETTER E' where ujis=0xA5A8; +update t1 set name='U+30A9 KATAKANA LETTER SMALL O' where ujis=0xA5A9; +update t1 set name='U+30AA KATAKANA LETTER O' where ujis=0xA5AA; +update t1 set name='U+30AB KATAKANA LETTER KA' where ujis=0xA5AB; +update t1 set name='U+30AC KATAKANA LETTER GA' where ujis=0xA5AC; +update t1 set name='U+30AD KATAKANA LETTER KI' where ujis=0xA5AD; +update t1 set name='U+30AE KATAKANA LETTER GI' where ujis=0xA5AE; +update t1 set name='U+30AF KATAKANA LETTER KU' where ujis=0xA5AF; +update t1 set name='U+30B0 KATAKANA LETTER GU' where ujis=0xA5B0; +update t1 set name='U+30B1 KATAKANA LETTER KE' where ujis=0xA5B1; +update t1 set name='U+30B2 KATAKANA LETTER GE' where ujis=0xA5B2; +update t1 set name='U+30B3 KATAKANA LETTER KO' where ujis=0xA5B3; +update t1 set name='U+30B4 KATAKANA LETTER GO' where ujis=0xA5B4; +update t1 set name='U+30B5 KATAKANA LETTER SA' where ujis=0xA5B5; +update t1 set name='U+30B6 KATAKANA LETTER ZA' where ujis=0xA5B6; +update t1 set name='U+30B7 KATAKANA LETTER SI' where ujis=0xA5B7; +update t1 set name='U+30B8 KATAKANA LETTER ZI' where ujis=0xA5B8; +update t1 set name='U+30B9 KATAKANA LETTER SU' where ujis=0xA5B9; +update t1 set name='U+30BA KATAKANA LETTER ZU' where ujis=0xA5BA; +update t1 set name='U+30BB KATAKANA LETTER SE' where ujis=0xA5BB; +update t1 set name='U+30BC KATAKANA LETTER ZE' where ujis=0xA5BC; +update t1 set name='U+30BD KATAKANA LETTER SO' where ujis=0xA5BD; +update t1 set name='U+30BE KATAKANA LETTER ZO' where ujis=0xA5BE; +update t1 set name='U+30BF KATAKANA LETTER TA' where ujis=0xA5BF; +update t1 set name='U+30C0 KATAKANA LETTER DA' where ujis=0xA5C0; +update t1 set name='U+30C1 KATAKANA LETTER TI' where ujis=0xA5C1; +update t1 set name='U+30C2 KATAKANA LETTER DI' where ujis=0xA5C2; +update t1 set name='U+30C3 KATAKANA LETTER SMALL TU' where ujis=0xA5C3; +update t1 set name='U+30C4 KATAKANA LETTER TU' where ujis=0xA5C4; +update t1 set name='U+30C5 KATAKANA LETTER DU' where ujis=0xA5C5; +update t1 set name='U+30C6 KATAKANA LETTER TE' where ujis=0xA5C6; +update t1 set name='U+30C7 KATAKANA LETTER DE' where ujis=0xA5C7; +update t1 set name='U+30C8 KATAKANA LETTER TO' where ujis=0xA5C8; +update t1 set name='U+30C9 KATAKANA LETTER DO' where ujis=0xA5C9; +update t1 set name='U+30CA KATAKANA LETTER NA' where ujis=0xA5CA; +update t1 set name='U+30CB KATAKANA LETTER NI' where ujis=0xA5CB; +update t1 set name='U+30CC KATAKANA LETTER NU' where ujis=0xA5CC; +update t1 set name='U+30CD KATAKANA LETTER NE' where ujis=0xA5CD; +update t1 set name='U+30CE KATAKANA LETTER NO' where ujis=0xA5CE; +update t1 set name='U+30CF KATAKANA LETTER HA' where ujis=0xA5CF; +update t1 set name='U+30D0 KATAKANA LETTER BA' where ujis=0xA5D0; +update t1 set name='U+30D1 KATAKANA LETTER PA' where ujis=0xA5D1; +update t1 set name='U+30D2 KATAKANA LETTER HI' where ujis=0xA5D2; +update t1 set name='U+30D3 KATAKANA LETTER BI' where ujis=0xA5D3; +update t1 set name='U+30D4 KATAKANA LETTER PI' where ujis=0xA5D4; +update t1 set name='U+30D5 KATAKANA LETTER HU' where ujis=0xA5D5; +update t1 set name='U+30D6 KATAKANA LETTER BU' where ujis=0xA5D6; +update t1 set name='U+30D7 KATAKANA LETTER PU' where ujis=0xA5D7; +update t1 set name='U+30D8 KATAKANA LETTER HE' where ujis=0xA5D8; +update t1 set name='U+30D9 KATAKANA LETTER BE' where ujis=0xA5D9; +update t1 set name='U+30DA KATAKANA LETTER PE' where ujis=0xA5DA; +update t1 set name='U+30DB KATAKANA LETTER HO' where ujis=0xA5DB; +update t1 set name='U+30DC KATAKANA LETTER BO' where ujis=0xA5DC; +update t1 set name='U+30DD KATAKANA LETTER PO' where ujis=0xA5DD; +update t1 set name='U+30DE KATAKANA LETTER MA' where ujis=0xA5DE; +update t1 set name='U+30DF KATAKANA LETTER MI' where ujis=0xA5DF; +update t1 set name='U+30E0 KATAKANA LETTER MU' where ujis=0xA5E0; +update t1 set name='U+30E1 KATAKANA LETTER ME' where ujis=0xA5E1; +update t1 set name='U+30E2 KATAKANA LETTER MO' where ujis=0xA5E2; +update t1 set name='U+30E3 KATAKANA LETTER SMALL YA' where ujis=0xA5E3; +update t1 set name='U+30E4 KATAKANA LETTER YA' where ujis=0xA5E4; +update t1 set name='U+30E5 KATAKANA LETTER SMALL YU' where ujis=0xA5E5; +update t1 set name='U+30E6 KATAKANA LETTER YU' where ujis=0xA5E6; +update t1 set name='U+30E7 KATAKANA LETTER SMALL YO' where ujis=0xA5E7; +update t1 set name='U+30E8 KATAKANA LETTER YO' where ujis=0xA5E8; +update t1 set name='U+30E9 KATAKANA LETTER RA' where ujis=0xA5E9; +update t1 set name='U+30EA KATAKANA LETTER RI' where ujis=0xA5EA; +update t1 set name='U+30EB KATAKANA LETTER RU' where ujis=0xA5EB; +update t1 set name='U+30EC KATAKANA LETTER RE' where ujis=0xA5EC; +update t1 set name='U+30ED KATAKANA LETTER RO' where ujis=0xA5ED; +update t1 set name='U+30EE KATAKANA LETTER SMALL WA' where ujis=0xA5EE; +update t1 set name='U+30EF KATAKANA LETTER WA' where ujis=0xA5EF; +update t1 set name='U+30F0 KATAKANA LETTER WI' where ujis=0xA5F0; +update t1 set name='U+30F1 KATAKANA LETTER WE' where ujis=0xA5F1; +update t1 set name='U+30F2 KATAKANA LETTER WO' where ujis=0xA5F2; +update t1 set name='U+30F3 KATAKANA LETTER N' where ujis=0xA5F3; +update t1 set name='U+30F4 KATAKANA LETTER VU' where ujis=0xA5F4; +update t1 set name='U+30F5 KATAKANA LETTER SMALL KA' where ujis=0xA5F5; +update t1 set name='U+30F6 KATAKANA LETTER SMALL KE' where ujis=0xA5F6; +update t1 set name='U+0391 GREEK CAPITAL LETTER ALPHA' where ujis=0xA6A1; +update t1 set name='U+0392 GREEK CAPITAL LETTER BETA' where ujis=0xA6A2; +update t1 set name='U+0393 GREEK CAPITAL LETTER GAMMA' where ujis=0xA6A3; +update t1 set name='U+0394 GREEK CAPITAL LETTER DELTA' where ujis=0xA6A4; +update t1 set name='U+0395 GREEK CAPITAL LETTER EPSILON' where ujis=0xA6A5; +update t1 set name='U+0396 GREEK CAPITAL LETTER ZETA' where ujis=0xA6A6; +update t1 set name='U+0397 GREEK CAPITAL LETTER ETA' where ujis=0xA6A7; +update t1 set name='U+0398 GREEK CAPITAL LETTER THETA' where ujis=0xA6A8; +update t1 set name='U+0399 GREEK CAPITAL LETTER IOTA' where ujis=0xA6A9; +update t1 set name='U+039A GREEK CAPITAL LETTER KAPPA' where ujis=0xA6AA; +update t1 set name='U+039B GREEK CAPITAL LETTER LAMDA' where ujis=0xA6AB; +update t1 set name='U+039C GREEK CAPITAL LETTER MU' where ujis=0xA6AC; +update t1 set name='U+039D GREEK CAPITAL LETTER NU' where ujis=0xA6AD; +update t1 set name='U+039E GREEK CAPITAL LETTER XI' where ujis=0xA6AE; +update t1 set name='U+039F GREEK CAPITAL LETTER OMICRON' where ujis=0xA6AF; +update t1 set name='U+03A0 GREEK CAPITAL LETTER PI' where ujis=0xA6B0; +update t1 set name='U+03A1 GREEK CAPITAL LETTER RHO' where ujis=0xA6B1; +update t1 set name='U+03A3 GREEK CAPITAL LETTER SIGMA' where ujis=0xA6B2; +update t1 set name='U+03A4 GREEK CAPITAL LETTER TAU' where ujis=0xA6B3; +update t1 set name='U+03A5 GREEK CAPITAL LETTER UPSILON' where ujis=0xA6B4; +update t1 set name='U+03A6 GREEK CAPITAL LETTER PHI' where ujis=0xA6B5; +update t1 set name='U+03A7 GREEK CAPITAL LETTER CHI' where ujis=0xA6B6; +update t1 set name='U+03A8 GREEK CAPITAL LETTER PSI' where ujis=0xA6B7; +update t1 set name='U+03A9 GREEK CAPITAL LETTER OMEGA' where ujis=0xA6B8; +update t1 set name='U+03B1 GREEK SMALL LETTER ALPHA' where ujis=0xA6C1; +update t1 set name='U+03B2 GREEK SMALL LETTER BETA' where ujis=0xA6C2; +update t1 set name='U+03B3 GREEK SMALL LETTER GAMMA' where ujis=0xA6C3; +update t1 set name='U+03B4 GREEK SMALL LETTER DELTA' where ujis=0xA6C4; +update t1 set name='U+03B5 GREEK SMALL LETTER EPSILON' where ujis=0xA6C5; +update t1 set name='U+03B6 GREEK SMALL LETTER ZETA' where ujis=0xA6C6; +update t1 set name='U+03B7 GREEK SMALL LETTER ETA' where ujis=0xA6C7; +update t1 set name='U+03B8 GREEK SMALL LETTER THETA' where ujis=0xA6C8; +update t1 set name='U+03B9 GREEK SMALL LETTER IOTA' where ujis=0xA6C9; +update t1 set name='U+03BA GREEK SMALL LETTER KAPPA' where ujis=0xA6CA; +update t1 set name='U+03BB GREEK SMALL LETTER LAMDA' where ujis=0xA6CB; +update t1 set name='U+03BC GREEK SMALL LETTER MU' where ujis=0xA6CC; +update t1 set name='U+03BD GREEK SMALL LETTER NU' where ujis=0xA6CD; +update t1 set name='U+03BE GREEK SMALL LETTER XI' where ujis=0xA6CE; +update t1 set name='U+03BF GREEK SMALL LETTER OMICRON' where ujis=0xA6CF; +update t1 set name='U+03C0 GREEK SMALL LETTER PI' where ujis=0xA6D0; +update t1 set name='U+03C1 GREEK SMALL LETTER RHO' where ujis=0xA6D1; +update t1 set name='U+03C3 GREEK SMALL LETTER SIGMA' where ujis=0xA6D2; +update t1 set name='U+03C4 GREEK SMALL LETTER TAU' where ujis=0xA6D3; +update t1 set name='U+03C5 GREEK SMALL LETTER UPSILON' where ujis=0xA6D4; +update t1 set name='U+03C6 GREEK SMALL LETTER PHI' where ujis=0xA6D5; +update t1 set name='U+03C7 GREEK SMALL LETTER CHI' where ujis=0xA6D6; +update t1 set name='U+03C8 GREEK SMALL LETTER PSI' where ujis=0xA6D7; +update t1 set name='U+03C9 GREEK SMALL LETTER OMEGA' where ujis=0xA6D8; +update t1 set name='U+0410 CYRILLIC CAPITAL LETTER A' where ujis=0xA7A1; +update t1 set name='U+0411 CYRILLIC CAPITAL LETTER BE' where ujis=0xA7A2; +update t1 set name='U+0412 CYRILLIC CAPITAL LETTER VE' where ujis=0xA7A3; +update t1 set name='U+0413 CYRILLIC CAPITAL LETTER GHE' where ujis=0xA7A4; +update t1 set name='U+0414 CYRILLIC CAPITAL LETTER DE' where ujis=0xA7A5; +update t1 set name='U+0415 CYRILLIC CAPITAL LETTER IE' where ujis=0xA7A6; +update t1 set name='U+0401 CYRILLIC CAPITAL LETTER IO' where ujis=0xA7A7; +update t1 set name='U+0416 CYRILLIC CAPITAL LETTER ZHE' where ujis=0xA7A8; +update t1 set name='U+0417 CYRILLIC CAPITAL LETTER ZE' where ujis=0xA7A9; +update t1 set name='U+0418 CYRILLIC CAPITAL LETTER I' where ujis=0xA7AA; +update t1 set name='U+0419 CYRILLIC CAPITAL LETTER SHORT I' where ujis=0xA7AB; +update t1 set name='U+041A CYRILLIC CAPITAL LETTER KA' where ujis=0xA7AC; +update t1 set name='U+041B CYRILLIC CAPITAL LETTER EL' where ujis=0xA7AD; +update t1 set name='U+041C CYRILLIC CAPITAL LETTER EM' where ujis=0xA7AE; +update t1 set name='U+041D CYRILLIC CAPITAL LETTER EN' where ujis=0xA7AF; +update t1 set name='U+041E CYRILLIC CAPITAL LETTER O' where ujis=0xA7B0; +update t1 set name='U+041F CYRILLIC CAPITAL LETTER PE' where ujis=0xA7B1; +update t1 set name='U+0420 CYRILLIC CAPITAL LETTER ER' where ujis=0xA7B2; +update t1 set name='U+0421 CYRILLIC CAPITAL LETTER ES' where ujis=0xA7B3; +update t1 set name='U+0422 CYRILLIC CAPITAL LETTER TE' where ujis=0xA7B4; +update t1 set name='U+0423 CYRILLIC CAPITAL LETTER U' where ujis=0xA7B5; +update t1 set name='U+0424 CYRILLIC CAPITAL LETTER EF' where ujis=0xA7B6; +update t1 set name='U+0425 CYRILLIC CAPITAL LETTER HA' where ujis=0xA7B7; +update t1 set name='U+0426 CYRILLIC CAPITAL LETTER TSE' where ujis=0xA7B8; +update t1 set name='U+0427 CYRILLIC CAPITAL LETTER CHE' where ujis=0xA7B9; +update t1 set name='U+0428 CYRILLIC CAPITAL LETTER SHA' where ujis=0xA7BA; +update t1 set name='U+0429 CYRILLIC CAPITAL LETTER SHCHA' where ujis=0xA7BB; +update t1 set name='U+042A CYRILLIC CAPITAL LETTER HARD SIGN' where ujis=0xA7BC; +update t1 set name='U+042B CYRILLIC CAPITAL LETTER YERU' where ujis=0xA7BD; +update t1 set name='U+042C CYRILLIC CAPITAL LETTER SOFT SIGN' where ujis=0xA7BE; +update t1 set name='U+042D CYRILLIC CAPITAL LETTER E' where ujis=0xA7BF; +update t1 set name='U+042E CYRILLIC CAPITAL LETTER YU' where ujis=0xA7C0; +update t1 set name='U+042F CYRILLIC CAPITAL LETTER YA' where ujis=0xA7C1; +update t1 set name='U+0430 CYRILLIC SMALL LETTER A' where ujis=0xA7D1; +update t1 set name='U+0431 CYRILLIC SMALL LETTER BE' where ujis=0xA7D2; +update t1 set name='U+0432 CYRILLIC SMALL LETTER VE' where ujis=0xA7D3; +update t1 set name='U+0433 CYRILLIC SMALL LETTER GHE' where ujis=0xA7D4; +update t1 set name='U+0434 CYRILLIC SMALL LETTER DE' where ujis=0xA7D5; +update t1 set name='U+0435 CYRILLIC SMALL LETTER IE' where ujis=0xA7D6; +update t1 set name='U+0451 CYRILLIC SMALL LETTER IO' where ujis=0xA7D7; +update t1 set name='U+0436 CYRILLIC SMALL LETTER ZHE' where ujis=0xA7D8; +update t1 set name='U+0437 CYRILLIC SMALL LETTER ZE' where ujis=0xA7D9; +update t1 set name='U+0438 CYRILLIC SMALL LETTER I' where ujis=0xA7DA; +update t1 set name='U+0439 CYRILLIC SMALL LETTER SHORT I' where ujis=0xA7DB; +update t1 set name='U+043A CYRILLIC SMALL LETTER KA' where ujis=0xA7DC; +update t1 set name='U+043B CYRILLIC SMALL LETTER EL' where ujis=0xA7DD; +update t1 set name='U+043C CYRILLIC SMALL LETTER EM' where ujis=0xA7DE; +update t1 set name='U+043D CYRILLIC SMALL LETTER EN' where ujis=0xA7DF; +update t1 set name='U+043E CYRILLIC SMALL LETTER O' where ujis=0xA7E0; +update t1 set name='U+043F CYRILLIC SMALL LETTER PE' where ujis=0xA7E1; +update t1 set name='U+0440 CYRILLIC SMALL LETTER ER' where ujis=0xA7E2; +update t1 set name='U+0441 CYRILLIC SMALL LETTER ES' where ujis=0xA7E3; +update t1 set name='U+0442 CYRILLIC SMALL LETTER TE' where ujis=0xA7E4; +update t1 set name='U+0443 CYRILLIC SMALL LETTER U' where ujis=0xA7E5; +update t1 set name='U+0444 CYRILLIC SMALL LETTER EF' where ujis=0xA7E6; +update t1 set name='U+0445 CYRILLIC SMALL LETTER HA' where ujis=0xA7E7; +update t1 set name='U+0446 CYRILLIC SMALL LETTER TSE' where ujis=0xA7E8; +update t1 set name='U+0447 CYRILLIC SMALL LETTER CHE' where ujis=0xA7E9; +update t1 set name='U+0448 CYRILLIC SMALL LETTER SHA' where ujis=0xA7EA; +update t1 set name='U+0449 CYRILLIC SMALL LETTER SHCHA' where ujis=0xA7EB; +update t1 set name='U+044A CYRILLIC SMALL LETTER HARD SIGN' where ujis=0xA7EC; +update t1 set name='U+044B CYRILLIC SMALL LETTER YERU' where ujis=0xA7ED; +update t1 set name='U+044C CYRILLIC SMALL LETTER SOFT SIGN' where ujis=0xA7EE; +update t1 set name='U+044D CYRILLIC SMALL LETTER E' where ujis=0xA7EF; +update t1 set name='U+044E CYRILLIC SMALL LETTER YU' where ujis=0xA7F0; +update t1 set name='U+044F CYRILLIC SMALL LETTER YA' where ujis=0xA7F1; +update t1 set name='U+2500 BOX DRAWINGS LIGHT HORIZONTAL' where ujis=0xA8A1; +update t1 set name='U+2502 BOX DRAWINGS LIGHT VERTICAL' where ujis=0xA8A2; +update t1 set name='U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT' where ujis=0xA8A3; +update t1 set name='U+2510 BOX DRAWINGS LIGHT DOWN AND LEFT' where ujis=0xA8A4; +update t1 set name='U+2518 BOX DRAWINGS LIGHT UP AND LEFT' where ujis=0xA8A5; +update t1 set name='U+2514 BOX DRAWINGS LIGHT UP AND RIGHT' where ujis=0xA8A6; +update t1 set name='U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT' where ujis=0xA8A7; +update t1 set name='U+252C BOX DRAWINGS LIGHT DOWN AND HORIZONTAL' where ujis=0xA8A8; +update t1 set name='U+2524 BOX DRAWINGS LIGHT VERTICAL AND LEFT' where ujis=0xA8A9; +update t1 set name='U+2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL' where ujis=0xA8AA; +update t1 set name='U+253C BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL' where ujis=0xA8AB; +update t1 set name='U+2501 BOX DRAWINGS HEAVY HORIZONTAL' where ujis=0xA8AC; +update t1 set name='U+2503 BOX DRAWINGS HEAVY VERTICAL' where ujis=0xA8AD; +update t1 set name='U+250F BOX DRAWINGS HEAVY DOWN AND RIGHT' where ujis=0xA8AE; +update t1 set name='U+2513 BOX DRAWINGS HEAVY DOWN AND LEFT' where ujis=0xA8AF; +update t1 set name='U+251B BOX DRAWINGS HEAVY UP AND LEFT' where ujis=0xA8B0; +update t1 set name='U+2517 BOX DRAWINGS HEAVY UP AND RIGHT' where ujis=0xA8B1; +update t1 set name='U+2523 BOX DRAWINGS HEAVY VERTICAL AND RIGHT' where ujis=0xA8B2; +update t1 set name='U+2533 BOX DRAWINGS HEAVY DOWN AND HORIZONTAL' where ujis=0xA8B3; +update t1 set name='U+252B BOX DRAWINGS HEAVY VERTICAL AND LEFT' where ujis=0xA8B4; +update t1 set name='U+253B BOX DRAWINGS HEAVY UP AND HORIZONTAL' where ujis=0xA8B5; +update t1 set name='U+254B BOX DRAWINGS HEAVY VERTICAL AND HORIZONTAL' where ujis=0xA8B6; +update t1 set name='U+2520 BOX DRAWINGS VERTICAL HEAVY AND RIGHT LIGHT' where ujis=0xA8B7; +update t1 set name='U+252F BOX DRAWINGS DOWN LIGHT AND HORIZONTAL HEAVY' where ujis=0xA8B8; +update t1 set name='U+2528 BOX DRAWINGS VERTICAL HEAVY AND LEFT LIGHT' where ujis=0xA8B9; +update t1 set name='U+2537 BOX DRAWINGS UP LIGHT AND HORIZONTAL HEAVY' where ujis=0xA8BA; +update t1 set name='U+253F BOX DRAWINGS VERTICAL LIGHT AND HORIZONTAL HEAVY' where ujis=0xA8BB; +update t1 set name='U+251D BOX DRAWINGS VERTICAL LIGHT AND RIGHT HEAVY' where ujis=0xA8BC; +update t1 set name='U+2530 BOX DRAWINGS DOWN HEAVY AND HORIZONTAL LIGHT' where ujis=0xA8BD; +update t1 set name='U+2525 BOX DRAWINGS VERTICAL LIGHT AND LEFT HEAVY' where ujis=0xA8BE; +update t1 set name='U+2538 BOX DRAWINGS UP HEAVY AND HORIZONTAL LIGHT' where ujis=0xA8BF; +update t1 set name='U+2542 BOX DRAWINGS VERTICAL HEAVY AND HORIZONTAL LIGHT' where ujis=0xA8C0; + +# +# [B0..BF][A1..FE] - 16*94=1504 codes assigned +# +update t1 set name='<CJK>' where ujis >= 0xB0A1 AND ujis <= 0xBFFE; + +# +# [C0..CE][A1..FE] = 15*94=1410 codes assigned +# +update t1 set name='<CJK>' where ujis >= 0xC0A1 AND ujis <= 0xCEFE; + +# +# 0xCFxx - 51 codes assigned +# +update t1 set name='U+84EE <CJK>' where ujis=0xCFA1; +update t1 set name='U+9023 <CJK>' where ujis=0xCFA2; +update t1 set name='U+932C <CJK>' where ujis=0xCFA3; +update t1 set name='U+5442 <CJK>' where ujis=0xCFA4; +update t1 set name='U+9B6F <CJK>' where ujis=0xCFA5; +update t1 set name='U+6AD3 <CJK>' where ujis=0xCFA6; +update t1 set name='U+7089 <CJK>' where ujis=0xCFA7; +update t1 set name='U+8CC2 <CJK>' where ujis=0xCFA8; +update t1 set name='U+8DEF <CJK>' where ujis=0xCFA9; +update t1 set name='U+9732 <CJK>' where ujis=0xCFAA; +update t1 set name='U+52B4 <CJK>' where ujis=0xCFAB; +update t1 set name='U+5A41 <CJK>' where ujis=0xCFAC; +update t1 set name='U+5ECA <CJK>' where ujis=0xCFAD; +update t1 set name='U+5F04 <CJK>' where ujis=0xCFAE; +update t1 set name='U+6717 <CJK>' where ujis=0xCFAF; +update t1 set name='U+697C <CJK>' where ujis=0xCFB0; +update t1 set name='U+6994 <CJK>' where ujis=0xCFB1; +update t1 set name='U+6D6A <CJK>' where ujis=0xCFB2; +update t1 set name='U+6F0F <CJK>' where ujis=0xCFB3; +update t1 set name='U+7262 <CJK>' where ujis=0xCFB4; +update t1 set name='U+72FC <CJK>' where ujis=0xCFB5; +update t1 set name='U+7BED <CJK>' where ujis=0xCFB6; +update t1 set name='U+8001 <CJK>' where ujis=0xCFB7; +update t1 set name='U+807E <CJK>' where ujis=0xCFB8; +update t1 set name='U+874B <CJK>' where ujis=0xCFB9; +update t1 set name='U+90CE <CJK>' where ujis=0xCFBA; +update t1 set name='U+516D <CJK>' where ujis=0xCFBB; +update t1 set name='U+9E93 <CJK>' where ujis=0xCFBC; +update t1 set name='U+7984 <CJK>' where ujis=0xCFBD; +update t1 set name='U+808B <CJK>' where ujis=0xCFBE; +update t1 set name='U+9332 <CJK>' where ujis=0xCFBF; +update t1 set name='U+8AD6 <CJK>' where ujis=0xCFC0; +update t1 set name='U+502D <CJK>' where ujis=0xCFC1; +update t1 set name='U+548C <CJK>' where ujis=0xCFC2; +update t1 set name='U+8A71 <CJK>' where ujis=0xCFC3; +update t1 set name='U+6B6A <CJK>' where ujis=0xCFC4; +update t1 set name='U+8CC4 <CJK>' where ujis=0xCFC5; +update t1 set name='U+8107 <CJK>' where ujis=0xCFC6; +update t1 set name='U+60D1 <CJK>' where ujis=0xCFC7; +update t1 set name='U+67A0 <CJK>' where ujis=0xCFC8; +update t1 set name='U+9DF2 <CJK>' where ujis=0xCFC9; +update t1 set name='U+4E99 <CJK>' where ujis=0xCFCA; +update t1 set name='U+4E98 <CJK>' where ujis=0xCFCB; +update t1 set name='U+9C10 <CJK>' where ujis=0xCFCC; +update t1 set name='U+8A6B <CJK>' where ujis=0xCFCD; +update t1 set name='U+85C1 <CJK>' where ujis=0xCFCE; +update t1 set name='U+8568 <CJK>' where ujis=0xCFCF; +update t1 set name='U+6900 <CJK>' where ujis=0xCFD0; +update t1 set name='U+6E7E <CJK>' where ujis=0xCFD1; +update t1 set name='U+7897 <CJK>' where ujis=0xCFD2; +update t1 set name='U+8155 <CJK>' where ujis=0xCFD3; + +# +# [D0..DF][A1..FE] - all 16*94=1504 codes assigned +# +update t1 set name='<CJK>' where ujis >= 0xD0A1 AND ujis <= 0xDFFE; + +# +# [E0..EF][A1..FE] - all codes assigned, 16*94=1504 total +# +update t1 set name='<CJK>' where ujis >= 0xE0A1 AND ujis <= 0xEFFE; + +# +# [F0..F3][A1..FE] - all codes assigned, 4*94=376 total +# +update t1 set name='<CJK>' where ujis >= 0xF0A1 AND ujis <= 0xF3FE; + +# 0xF4xx - six codes assigned +update t1 set name='U+582F <CJK>' where ujis=0xF4A1; +update t1 set name='U+69C7 <CJK>' where ujis=0xF4A2; +update t1 set name='U+9059 <CJK>' where ujis=0xF4A3; +update t1 set name='U+7464 <CJK>' where ujis=0xF4A4; +update t1 set name='U+51DC <CJK>' where ujis=0xF4A5; +update t1 set name='U+7199 <CJK>' where ujis=0xF4A6; + +# [F5..FE][A1..FE] - User defined range +update t1 set name='User defined range #1' where ujis >= 0xF5A1 AND ujis <= 0xFEFE; + + +# A character from the upper half of JIS-X-0201 +# (half-width kana, code set 2) +# is represented by two bytes: +# the first being 0x8E, +# the second in the range 0xA1 - 0xDF. +# Codes according to: +# ftp://ftp.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0201.TXT + +insert into t1 (ujis,name) values (0x8EA1,'U+FF61 HALFWIDTH IDEOGRAPHIC FULL STOP'); +insert into t1 (ujis,name) values (0x8EA2,'U+FF62 HALFWIDTH LEFT CORNER BRACKET'); +insert into t1 (ujis,name) values (0x8EA3,'U+FF63 HALFWIDTH RIGHT CORNER BRACKET'); +insert into t1 (ujis,name) values (0x8EA4,'U+FF64 HALFWIDTH IDEOGRAPHIC COMMA'); +insert into t1 (ujis,name) values (0x8EA5,'U+FF65 HALFWIDTH KATAKANA MIDDLE DOT'); +insert into t1 (ujis,name) values (0x8EA6,'U+FF66 HALFWIDTH KATAKANA LETTER WO'); +insert into t1 (ujis,name) values (0x8EA7,'U+FF67 HALFWIDTH KATAKANA LETTER SMALL A'); +insert into t1 (ujis,name) values (0x8EA8,'U+FF68 HALFWIDTH KATAKANA LETTER SMALL I'); +insert into t1 (ujis,name) values (0x8EA9,'U+FF69 HALFWIDTH KATAKANA LETTER SMALL U'); +insert into t1 (ujis,name) values (0x8EAA,'U+FF6A HALFWIDTH KATAKANA LETTER SMALL E'); +insert into t1 (ujis,name) values (0x8EAB,'U+FF6B HALFWIDTH KATAKANA LETTER SMALL O'); +insert into t1 (ujis,name) values (0x8EAC,'U+FF6C HALFWIDTH KATAKANA LETTER SMALL YA'); +insert into t1 (ujis,name) values (0x8EAD,'U+FF6D HALFWIDTH KATAKANA LETTER SMALL YU'); +insert into t1 (ujis,name) values (0x8EAE,'U+FF6E HALFWIDTH KATAKANA LETTER SMALL YO'); +insert into t1 (ujis,name) values (0x8EAF,'U+FF6F HALFWIDTH KATAKANA LETTER SMALL TU'); +insert into t1 (ujis,name) values (0x8EB0,'U+FF70 HALFWIDTH KATAKANA-HIRAGANA PROLONGED SOUND MARK'); +insert into t1 (ujis,name) values (0x8EB1,'U+FF71 HALFWIDTH KATAKANA LETTER A'); +insert into t1 (ujis,name) values (0x8EB2,'U+FF72 HALFWIDTH KATAKANA LETTER I'); +insert into t1 (ujis,name) values (0x8EB3,'U+FF73 HALFWIDTH KATAKANA LETTER U'); +insert into t1 (ujis,name) values (0x8EB4,'U+FF74 HALFWIDTH KATAKANA LETTER E'); +insert into t1 (ujis,name) values (0x8EB5,'U+FF75 HALFWIDTH KATAKANA LETTER O'); +insert into t1 (ujis,name) values (0x8EB6,'U+FF76 HALFWIDTH KATAKANA LETTER KA'); +insert into t1 (ujis,name) values (0x8EB7,'U+FF77 HALFWIDTH KATAKANA LETTER KI'); +insert into t1 (ujis,name) values (0x8EB8,'U+FF78 HALFWIDTH KATAKANA LETTER KU'); +insert into t1 (ujis,name) values (0x8EB9,'U+FF79 HALFWIDTH KATAKANA LETTER KE'); +insert into t1 (ujis,name) values (0x8EBA,'U+FF7A HALFWIDTH KATAKANA LETTER KO'); +insert into t1 (ujis,name) values (0x8EBB,'U+FF7B HALFWIDTH KATAKANA LETTER SA'); +insert into t1 (ujis,name) values (0x8EBC,'U+FF7C HALFWIDTH KATAKANA LETTER SI'); +insert into t1 (ujis,name) values (0x8EBD,'U+FF7D HALFWIDTH KATAKANA LETTER SU'); +insert into t1 (ujis,name) values (0x8EBE,'U+FF7E HALFWIDTH KATAKANA LETTER SE'); +insert into t1 (ujis,name) values (0x8EBF,'U+FF7F HALFWIDTH KATAKANA LETTER SO'); +insert into t1 (ujis,name) values (0x8EC0,'U+FF80 HALFWIDTH KATAKANA LETTER TA'); +insert into t1 (ujis,name) values (0x8EC1,'U+FF81 HALFWIDTH KATAKANA LETTER TI'); +insert into t1 (ujis,name) values (0x8EC2,'U+FF82 HALFWIDTH KATAKANA LETTER TU'); +insert into t1 (ujis,name) values (0x8EC3,'U+FF83 HALFWIDTH KATAKANA LETTER TE'); +insert into t1 (ujis,name) values (0x8EC4,'U+FF84 HALFWIDTH KATAKANA LETTER TO'); +insert into t1 (ujis,name) values (0x8EC5,'U+FF85 HALFWIDTH KATAKANA LETTER NA'); +insert into t1 (ujis,name) values (0x8EC6,'U+FF86 HALFWIDTH KATAKANA LETTER NI'); +insert into t1 (ujis,name) values (0x8EC7,'U+FF87 HALFWIDTH KATAKANA LETTER NU'); +insert into t1 (ujis,name) values (0x8EC8,'U+FF88 HALFWIDTH KATAKANA LETTER NE'); +insert into t1 (ujis,name) values (0x8EC9,'U+FF89 HALFWIDTH KATAKANA LETTER NO'); +insert into t1 (ujis,name) values (0x8ECA,'U+FF8A HALFWIDTH KATAKANA LETTER HA'); +insert into t1 (ujis,name) values (0x8ECB,'U+FF8B HALFWIDTH KATAKANA LETTER HI'); +insert into t1 (ujis,name) values (0x8ECC,'U+FF8C HALFWIDTH KATAKANA LETTER HU'); +insert into t1 (ujis,name) values (0x8ECD,'U+FF8D HALFWIDTH KATAKANA LETTER HE'); +insert into t1 (ujis,name) values (0x8ECE,'U+FF8E HALFWIDTH KATAKANA LETTER HO'); +insert into t1 (ujis,name) values (0x8ECF,'U+FF8F HALFWIDTH KATAKANA LETTER MA'); +insert into t1 (ujis,name) values (0x8ED0,'U+FF90 HALFWIDTH KATAKANA LETTER MI'); +insert into t1 (ujis,name) values (0x8ED1,'U+FF91 HALFWIDTH KATAKANA LETTER MU'); +insert into t1 (ujis,name) values (0x8ED2,'U+FF92 HALFWIDTH KATAKANA LETTER ME'); +insert into t1 (ujis,name) values (0x8ED3,'U+FF93 HALFWIDTH KATAKANA LETTER MO'); +insert into t1 (ujis,name) values (0x8ED4,'U+FF94 HALFWIDTH KATAKANA LETTER YA'); +insert into t1 (ujis,name) values (0x8ED5,'U+FF95 HALFWIDTH KATAKANA LETTER YU'); +insert into t1 (ujis,name) values (0x8ED6,'U+FF96 HALFWIDTH KATAKANA LETTER YO'); +insert into t1 (ujis,name) values (0x8ED7,'U+FF97 HALFWIDTH KATAKANA LETTER RA'); +insert into t1 (ujis,name) values (0x8ED8,'U+FF98 HALFWIDTH KATAKANA LETTER RI'); +insert into t1 (ujis,name) values (0x8ED9,'U+FF99 HALFWIDTH KATAKANA LETTER RU'); +insert into t1 (ujis,name) values (0x8EDA,'U+FF9A HALFWIDTH KATAKANA LETTER RE'); +insert into t1 (ujis,name) values (0x8EDB,'U+FF9B HALFWIDTH KATAKANA LETTER RO'); +insert into t1 (ujis,name) values (0x8EDC,'U+FF9C HALFWIDTH KATAKANA LETTER WA'); +insert into t1 (ujis,name) values (0x8EDD,'U+FF9D HALFWIDTH KATAKANA LETTER N'); +insert into t1 (ujis,name) values (0x8EDE,'U+FF9E HALFWIDTH KATAKANA VOICED SOUND MARK'); +insert into t1 (ujis,name) values (0x8EDF,'U+FF9F HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK'); + + +# +# A character from JIS-X-0212 (code set 3) +# is represented by three bytes, +# the first being 0x8F, +# the following two in the range 0xA1 - 0xFE. +# ftp://ftp.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0212.TXT +# +# Fill table t1 with codes [8F][A1..FE][A1..FE] using helper table t2, +# 8836 codes total +# +insert into t1 (ujis) select concat(0x8F,t21.code,t22.code) from t2 t21, t2 t22 order by 1; + +update t1 set name='U+02D8 BREVE' where ujis=0x8FA2AF; +update t1 set name='U+02C7 CARON (Mandarin Chinese third tone)' where ujis=0x8FA2B0; +update t1 set name='U+00B8 CEDILLA' where ujis=0x8FA2B1; +update t1 set name='U+02D9 DOT ABOVE (Mandarin Chinese light tone)' where ujis=0x8FA2B2; +update t1 set name='U+02DD DOUBLE ACUTE ACCENT' where ujis=0x8FA2B3; +update t1 set name='U+00AF MACRON' where ujis=0x8FA2B4; +update t1 set name='U+02DB OGONEK' where ujis=0x8FA2B5; +update t1 set name='U+02DA RING ABOVE' where ujis=0x8FA2B6; +update t1 set name='U+007E TILDE' where ujis=0x8FA2B7; +update t1 set name='U+0384 GREEK TONOS' where ujis=0x8FA2B8; +update t1 set name='U+0385 GREEK DIALYTIKA TONOS' where ujis=0x8FA2B9; +update t1 set name='U+00A1 INVERTED EXCLAMATION MARK' where ujis=0x8FA2C2; +update t1 set name='U+00A6 BROKEN BAR' where ujis=0x8FA2C3; +update t1 set name='U+00BF INVERTED QUESTION MARK' where ujis=0x8FA2C4; +update t1 set name='U+00BA MASCULINE ORDINAL INDICATOR' where ujis=0x8FA2EB; +update t1 set name='U+00AA FEMININE ORDINAL INDICATOR' where ujis=0x8FA2EC; +update t1 set name='U+00A9 COPYRIGHT SIGN' where ujis=0x8FA2ED; +update t1 set name='U+00AE REGISTERED SIGN' where ujis=0x8FA2EE; +update t1 set name='U+2122 TRADE MARK SIGN' where ujis=0x8FA2EF; +update t1 set name='U+00A4 CURRENCY SIGN' where ujis=0x8FA2F0; +update t1 set name='U+2116 NUMERO SIGN' where ujis=0x8FA2F1; +update t1 set name='U+0386 GREEK CAPITAL LETTER ALPHA WITH TONOS' where ujis=0x8FA6E1; +update t1 set name='U+0388 GREEK CAPITAL LETTER EPSILON WITH TONOS' where ujis=0x8FA6E2; +update t1 set name='U+0389 GREEK CAPITAL LETTER ETA WITH TONOS' where ujis=0x8FA6E3; +update t1 set name='U+038A GREEK CAPITAL LETTER IOTA WITH TONOS' where ujis=0x8FA6E4; +update t1 set name='U+03AA GREEK CAPITAL LETTER IOTA WITH DIALYTIKA' where ujis=0x8FA6E5; +update t1 set name='U+038C GREEK CAPITAL LETTER OMICRON WITH TONOS' where ujis=0x8FA6E7; +update t1 set name='U+038E GREEK CAPITAL LETTER UPSILON WITH TONOS' where ujis=0x8FA6E9; +update t1 set name='U+03AB GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA' where ujis=0x8FA6EA; +update t1 set name='U+038F GREEK CAPITAL LETTER OMEGA WITH TONOS' where ujis=0x8FA6EC; +update t1 set name='U+03AC GREEK SMALL LETTER ALPHA WITH TONOS' where ujis=0x8FA6F1; +update t1 set name='U+03AD GREEK SMALL LETTER EPSILON WITH TONOS' where ujis=0x8FA6F2; +update t1 set name='U+03AE GREEK SMALL LETTER ETA WITH TONOS' where ujis=0x8FA6F3; +update t1 set name='U+03AF GREEK SMALL LETTER IOTA WITH TONOS' where ujis=0x8FA6F4; +update t1 set name='U+03CA GREEK SMALL LETTER IOTA WITH DIALYTIKA' where ujis=0x8FA6F5; +update t1 set name='U+0390 GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS' where ujis=0x8FA6F6; +update t1 set name='U+03CC GREEK SMALL LETTER OMICRON WITH TONOS' where ujis=0x8FA6F7; +update t1 set name='U+03C2 GREEK SMALL LETTER FINAL SIGMA' where ujis=0x8FA6F8; +update t1 set name='U+03CD GREEK SMALL LETTER UPSILON WITH TONOS' where ujis=0x8FA6F9; +update t1 set name='U+03CB GREEK SMALL LETTER UPSILON WITH DIALYTIKA' where ujis=0x8FA6FA; +update t1 set name='U+03B0 GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS' where ujis=0x8FA6FB; +update t1 set name='U+03CE GREEK SMALL LETTER OMEGA WITH TONOS' where ujis=0x8FA6FC; +update t1 set name='U+0402 CYRILLIC CAPITAL LETTER DJE' where ujis=0x8FA7C2; +update t1 set name='U+0403 CYRILLIC CAPITAL LETTER GJE' where ujis=0x8FA7C3; +update t1 set name='U+0404 CYRILLIC CAPITAL LETTER UKRAINIAN IE' where ujis=0x8FA7C4; +update t1 set name='U+0405 CYRILLIC CAPITAL LETTER DZE' where ujis=0x8FA7C5; +update t1 set name='U+0406 CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I' where ujis=0x8FA7C6; +update t1 set name='U+0407 CYRILLIC CAPITAL LETTER YI' where ujis=0x8FA7C7; +update t1 set name='U+0408 CYRILLIC CAPITAL LETTER JE' where ujis=0x8FA7C8; +update t1 set name='U+0409 CYRILLIC CAPITAL LETTER LJE' where ujis=0x8FA7C9; +update t1 set name='U+040A CYRILLIC CAPITAL LETTER NJE' where ujis=0x8FA7CA; +update t1 set name='U+040B CYRILLIC CAPITAL LETTER TSHE' where ujis=0x8FA7CB; +update t1 set name='U+040C CYRILLIC CAPITAL LETTER KJE' where ujis=0x8FA7CC; +update t1 set name='U+040E CYRILLIC CAPITAL LETTER SHORT U' where ujis=0x8FA7CD; +update t1 set name='U+040F CYRILLIC CAPITAL LETTER DZHE' where ujis=0x8FA7CE; +update t1 set name='U+0452 CYRILLIC SMALL LETTER DJE' where ujis=0x8FA7F2; +update t1 set name='U+0453 CYRILLIC SMALL LETTER GJE' where ujis=0x8FA7F3; +update t1 set name='U+0454 CYRILLIC SMALL LETTER UKRAINIAN IE' where ujis=0x8FA7F4; +update t1 set name='U+0455 CYRILLIC SMALL LETTER DZE' where ujis=0x8FA7F5; +update t1 set name='U+0456 CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I' where ujis=0x8FA7F6; +update t1 set name='U+0457 CYRILLIC SMALL LETTER YI' where ujis=0x8FA7F7; +update t1 set name='U+0458 CYRILLIC SMALL LETTER JE' where ujis=0x8FA7F8; +update t1 set name='U+0459 CYRILLIC SMALL LETTER LJE' where ujis=0x8FA7F9; +update t1 set name='U+045A CYRILLIC SMALL LETTER NJE' where ujis=0x8FA7FA; +update t1 set name='U+045B CYRILLIC SMALL LETTER TSHE' where ujis=0x8FA7FB; +update t1 set name='U+045C CYRILLIC SMALL LETTER KJE' where ujis=0x8FA7FC; +update t1 set name='U+045E CYRILLIC SMALL LETTER SHORT U' where ujis=0x8FA7FD; +update t1 set name='U+045F CYRILLIC SMALL LETTER DZHE' where ujis=0x8FA7FE; +update t1 set name='U+00C6 LATIN CAPITAL LIGATURE AE' where ujis=0x8FA9A1; +update t1 set name='U+0110 LATIN CAPITAL LETTER D WITH STROKE' where ujis=0x8FA9A2; +update t1 set name='U+0126 LATIN CAPITAL LETTER H WITH STROKE' where ujis=0x8FA9A4; +update t1 set name='U+0132 LATIN CAPITAL LIGATURE IJ' where ujis=0x8FA9A6; +update t1 set name='U+0141 LATIN CAPITAL LETTER L WITH STROKE' where ujis=0x8FA9A8; +update t1 set name='U+013F LATIN CAPITAL LETTER L WITH MIDDLE DOT' where ujis=0x8FA9A9; +update t1 set name='U+014A LATIN CAPITAL LETTER ENG' where ujis=0x8FA9AB; +update t1 set name='U+00D8 LATIN CAPITAL LETTER O WITH STROKE' where ujis=0x8FA9AC; +update t1 set name='U+0152 LATIN CAPITAL LIGATURE OE' where ujis=0x8FA9AD; +update t1 set name='U+0166 LATIN CAPITAL LETTER T WITH STROKE' where ujis=0x8FA9AF; +update t1 set name='U+00DE LATIN CAPITAL LETTER THORN' where ujis=0x8FA9B0; +update t1 set name='U+00E6 LATIN SMALL LIGATURE AE' where ujis=0x8FA9C1; +update t1 set name='U+0111 LATIN SMALL LETTER D WITH STROKE' where ujis=0x8FA9C2; +update t1 set name='U+00F0 LATIN SMALL LETTER ETH' where ujis=0x8FA9C3; +update t1 set name='U+0127 LATIN SMALL LETTER H WITH STROKE' where ujis=0x8FA9C4; +update t1 set name='U+0131 LATIN SMALL LETTER DOTLESS I' where ujis=0x8FA9C5; +update t1 set name='U+0133 LATIN SMALL LIGATURE IJ' where ujis=0x8FA9C6; +update t1 set name='U+0138 LATIN SMALL LETTER KRA' where ujis=0x8FA9C7; +update t1 set name='U+0142 LATIN SMALL LETTER L WITH STROKE' where ujis=0x8FA9C8; +update t1 set name='U+0140 LATIN SMALL LETTER L WITH MIDDLE DOT' where ujis=0x8FA9C9; +update t1 set name='U+0149 LATIN SMALL LETTER N PRECEDED BY APOSTROPHE' where ujis=0x8FA9CA; +update t1 set name='U+014B LATIN SMALL LETTER ENG' where ujis=0x8FA9CB; +update t1 set name='U+00F8 LATIN SMALL LETTER O WITH STROKE' where ujis=0x8FA9CC; +update t1 set name='U+0153 LATIN SMALL LIGATURE OE' where ujis=0x8FA9CD; +update t1 set name='U+00DF LATIN SMALL LETTER SHARP S' where ujis=0x8FA9CE; +update t1 set name='U+0167 LATIN SMALL LETTER T WITH STROKE' where ujis=0x8FA9CF; +update t1 set name='U+00FE LATIN SMALL LETTER THORN' where ujis=0x8FA9D0; +update t1 set name='U+00C1 LATIN CAPITAL LETTER A WITH ACUTE' where ujis=0x8FAAA1; +update t1 set name='U+00C0 LATIN CAPITAL LETTER A WITH GRAVE' where ujis=0x8FAAA2; +update t1 set name='U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS' where ujis=0x8FAAA3; +update t1 set name='U+00C2 LATIN CAPITAL LETTER A WITH CIRCUMFLEX' where ujis=0x8FAAA4; +update t1 set name='U+0102 LATIN CAPITAL LETTER A WITH BREVE' where ujis=0x8FAAA5; +update t1 set name='U+01CD LATIN CAPITAL LETTER A WITH CARON' where ujis=0x8FAAA6; +update t1 set name='U+0100 LATIN CAPITAL LETTER A WITH MACRON' where ujis=0x8FAAA7; +update t1 set name='U+0104 LATIN CAPITAL LETTER A WITH OGONEK' where ujis=0x8FAAA8; +update t1 set name='U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE' where ujis=0x8FAAA9; +update t1 set name='U+00C3 LATIN CAPITAL LETTER A WITH TILDE' where ujis=0x8FAAAA; +update t1 set name='U+0106 LATIN CAPITAL LETTER C WITH ACUTE' where ujis=0x8FAAAB; +update t1 set name='U+0108 LATIN CAPITAL LETTER C WITH CIRCUMFLEX' where ujis=0x8FAAAC; +update t1 set name='U+010C LATIN CAPITAL LETTER C WITH CARON' where ujis=0x8FAAAD; +update t1 set name='U+00C7 LATIN CAPITAL LETTER C WITH CEDILLA' where ujis=0x8FAAAE; +update t1 set name='U+010A LATIN CAPITAL LETTER C WITH DOT ABOVE' where ujis=0x8FAAAF; +update t1 set name='U+010E LATIN CAPITAL LETTER D WITH CARON' where ujis=0x8FAAB0; +update t1 set name='U+00C9 LATIN CAPITAL LETTER E WITH ACUTE' where ujis=0x8FAAB1; +update t1 set name='U+00C8 LATIN CAPITAL LETTER E WITH GRAVE' where ujis=0x8FAAB2; +update t1 set name='U+00CB LATIN CAPITAL LETTER E WITH DIAERESIS' where ujis=0x8FAAB3; +update t1 set name='U+00CA LATIN CAPITAL LETTER E WITH CIRCUMFLEX' where ujis=0x8FAAB4; +update t1 set name='U+011A LATIN CAPITAL LETTER E WITH CARON' where ujis=0x8FAAB5; +update t1 set name='U+0116 LATIN CAPITAL LETTER E WITH DOT ABOVE' where ujis=0x8FAAB6; +update t1 set name='U+0112 LATIN CAPITAL LETTER E WITH MACRON' where ujis=0x8FAAB7; +update t1 set name='U+0118 LATIN CAPITAL LETTER E WITH OGONEK' where ujis=0x8FAAB8; +update t1 set name='U+011C LATIN CAPITAL LETTER G WITH CIRCUMFLEX' where ujis=0x8FAABA; +update t1 set name='U+011E LATIN CAPITAL LETTER G WITH BREVE' where ujis=0x8FAABB; +update t1 set name='U+0122 LATIN CAPITAL LETTER G WITH CEDILLA' where ujis=0x8FAABC; +update t1 set name='U+0120 LATIN CAPITAL LETTER G WITH DOT ABOVE' where ujis=0x8FAABD; +update t1 set name='U+0124 LATIN CAPITAL LETTER H WITH CIRCUMFLEX' where ujis=0x8FAABE; +update t1 set name='U+00CD LATIN CAPITAL LETTER I WITH ACUTE' where ujis=0x8FAABF; +update t1 set name='U+00CC LATIN CAPITAL LETTER I WITH GRAVE' where ujis=0x8FAAC0; +update t1 set name='U+00CF LATIN CAPITAL LETTER I WITH DIAERESIS' where ujis=0x8FAAC1; +update t1 set name='U+00CE LATIN CAPITAL LETTER I WITH CIRCUMFLEX' where ujis=0x8FAAC2; +update t1 set name='U+01CF LATIN CAPITAL LETTER I WITH CARON' where ujis=0x8FAAC3; +update t1 set name='U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE' where ujis=0x8FAAC4; +update t1 set name='U+012A LATIN CAPITAL LETTER I WITH MACRON' where ujis=0x8FAAC5; +update t1 set name='U+012E LATIN CAPITAL LETTER I WITH OGONEK' where ujis=0x8FAAC6; +update t1 set name='U+0128 LATIN CAPITAL LETTER I WITH TILDE' where ujis=0x8FAAC7; +update t1 set name='U+0134 LATIN CAPITAL LETTER J WITH CIRCUMFLEX' where ujis=0x8FAAC8; +update t1 set name='U+0136 LATIN CAPITAL LETTER K WITH CEDILLA' where ujis=0x8FAAC9; +update t1 set name='U+0139 LATIN CAPITAL LETTER L WITH ACUTE' where ujis=0x8FAACA; +update t1 set name='U+013D LATIN CAPITAL LETTER L WITH CARON' where ujis=0x8FAACB; +update t1 set name='U+013B LATIN CAPITAL LETTER L WITH CEDILLA' where ujis=0x8FAACC; +update t1 set name='U+0143 LATIN CAPITAL LETTER N WITH ACUTE' where ujis=0x8FAACD; +update t1 set name='U+0147 LATIN CAPITAL LETTER N WITH CARON' where ujis=0x8FAACE; +update t1 set name='U+0145 LATIN CAPITAL LETTER N WITH CEDILLA' where ujis=0x8FAACF; +update t1 set name='U+00D1 LATIN CAPITAL LETTER N WITH TILDE' where ujis=0x8FAAD0; +update t1 set name='U+00D3 LATIN CAPITAL LETTER O WITH ACUTE' where ujis=0x8FAAD1; +update t1 set name='U+00D2 LATIN CAPITAL LETTER O WITH GRAVE' where ujis=0x8FAAD2; +update t1 set name='U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS' where ujis=0x8FAAD3; +update t1 set name='U+00D4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX' where ujis=0x8FAAD4; +update t1 set name='U+01D1 LATIN CAPITAL LETTER O WITH CARON' where ujis=0x8FAAD5; +update t1 set name='U+0150 LATIN CAPITAL LETTER O WITH DOUBLE ACUTE' where ujis=0x8FAAD6; +update t1 set name='U+014C LATIN CAPITAL LETTER O WITH MACRON' where ujis=0x8FAAD7; +update t1 set name='U+00D5 LATIN CAPITAL LETTER O WITH TILDE' where ujis=0x8FAAD8; +update t1 set name='U+0154 LATIN CAPITAL LETTER R WITH ACUTE' where ujis=0x8FAAD9; +update t1 set name='U+0158 LATIN CAPITAL LETTER R WITH CARON' where ujis=0x8FAADA; +update t1 set name='U+0156 LATIN CAPITAL LETTER R WITH CEDILLA' where ujis=0x8FAADB; +update t1 set name='U+015A LATIN CAPITAL LETTER S WITH ACUTE' where ujis=0x8FAADC; +update t1 set name='U+015C LATIN CAPITAL LETTER S WITH CIRCUMFLEX' where ujis=0x8FAADD; +update t1 set name='U+0160 LATIN CAPITAL LETTER S WITH CARON' where ujis=0x8FAADE; +update t1 set name='U+015E LATIN CAPITAL LETTER S WITH CEDILLA' where ujis=0x8FAADF; +update t1 set name='U+0164 LATIN CAPITAL LETTER T WITH CARON' where ujis=0x8FAAE0; +update t1 set name='U+0162 LATIN CAPITAL LETTER T WITH CEDILLA' where ujis=0x8FAAE1; +update t1 set name='U+00DA LATIN CAPITAL LETTER U WITH ACUTE' where ujis=0x8FAAE2; +update t1 set name='U+00D9 LATIN CAPITAL LETTER U WITH GRAVE' where ujis=0x8FAAE3; +update t1 set name='U+00DC LATIN CAPITAL LETTER U WITH DIAERESIS' where ujis=0x8FAAE4; +update t1 set name='U+00DB LATIN CAPITAL LETTER U WITH CIRCUMFLEX' where ujis=0x8FAAE5; +update t1 set name='U+016C LATIN CAPITAL LETTER U WITH BREVE' where ujis=0x8FAAE6; +update t1 set name='U+01D3 LATIN CAPITAL LETTER U WITH CARON' where ujis=0x8FAAE7; +update t1 set name='U+0170 LATIN CAPITAL LETTER U WITH DOUBLE ACUTE' where ujis=0x8FAAE8; +update t1 set name='U+016A LATIN CAPITAL LETTER U WITH MACRON' where ujis=0x8FAAE9; +update t1 set name='U+0172 LATIN CAPITAL LETTER U WITH OGONEK' where ujis=0x8FAAEA; +update t1 set name='U+016E LATIN CAPITAL LETTER U WITH RING ABOVE' where ujis=0x8FAAEB; +update t1 set name='U+0168 LATIN CAPITAL LETTER U WITH TILDE' where ujis=0x8FAAEC; +update t1 set name='U+01D7 LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE' where ujis=0x8FAAED; +update t1 set name='U+01DB LATIN CAPITAL LETTER U WITH DIAERESIS AND GRAVE' where ujis=0x8FAAEE; +update t1 set name='U+01D9 LATIN CAPITAL LETTER U WITH DIAERESIS AND CARON' where ujis=0x8FAAEF; +update t1 set name='U+01D5 LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON' where ujis=0x8FAAF0; +update t1 set name='U+0174 LATIN CAPITAL LETTER W WITH CIRCUMFLEX' where ujis=0x8FAAF1; +update t1 set name='U+00DD LATIN CAPITAL LETTER Y WITH ACUTE' where ujis=0x8FAAF2; +update t1 set name='U+0178 LATIN CAPITAL LETTER Y WITH DIAERESIS' where ujis=0x8FAAF3; +update t1 set name='U+0176 LATIN CAPITAL LETTER Y WITH CIRCUMFLEX' where ujis=0x8FAAF4; +update t1 set name='U+0179 LATIN CAPITAL LETTER Z WITH ACUTE' where ujis=0x8FAAF5; +update t1 set name='U+017D LATIN CAPITAL LETTER Z WITH CARON' where ujis=0x8FAAF6; +update t1 set name='U+017B LATIN CAPITAL LETTER Z WITH DOT ABOVE' where ujis=0x8FAAF7; +update t1 set name='U+00E1 LATIN SMALL LETTER A WITH ACUTE' where ujis=0x8FABA1; +update t1 set name='U+00E0 LATIN SMALL LETTER A WITH GRAVE' where ujis=0x8FABA2; +update t1 set name='U+00E4 LATIN SMALL LETTER A WITH DIAERESIS' where ujis=0x8FABA3; +update t1 set name='U+00E2 LATIN SMALL LETTER A WITH CIRCUMFLEX' where ujis=0x8FABA4; +update t1 set name='U+0103 LATIN SMALL LETTER A WITH BREVE' where ujis=0x8FABA5; +update t1 set name='U+01CE LATIN SMALL LETTER A WITH CARON' where ujis=0x8FABA6; +update t1 set name='U+0101 LATIN SMALL LETTER A WITH MACRON' where ujis=0x8FABA7; +update t1 set name='U+0105 LATIN SMALL LETTER A WITH OGONEK' where ujis=0x8FABA8; +update t1 set name='U+00E5 LATIN SMALL LETTER A WITH RING ABOVE' where ujis=0x8FABA9; +update t1 set name='U+00E3 LATIN SMALL LETTER A WITH TILDE' where ujis=0x8FABAA; +update t1 set name='U+0107 LATIN SMALL LETTER C WITH ACUTE' where ujis=0x8FABAB; +update t1 set name='U+0109 LATIN SMALL LETTER C WITH CIRCUMFLEX' where ujis=0x8FABAC; +update t1 set name='U+010D LATIN SMALL LETTER C WITH CARON' where ujis=0x8FABAD; +update t1 set name='U+00E7 LATIN SMALL LETTER C WITH CEDILLA' where ujis=0x8FABAE; +update t1 set name='U+010B LATIN SMALL LETTER C WITH DOT ABOVE' where ujis=0x8FABAF; +update t1 set name='U+010F LATIN SMALL LETTER D WITH CARON' where ujis=0x8FABB0; +update t1 set name='U+00E9 LATIN SMALL LETTER E WITH ACUTE' where ujis=0x8FABB1; +update t1 set name='U+00E8 LATIN SMALL LETTER E WITH GRAVE' where ujis=0x8FABB2; +update t1 set name='U+00EB LATIN SMALL LETTER E WITH DIAERESIS' where ujis=0x8FABB3; +update t1 set name='U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX' where ujis=0x8FABB4; +update t1 set name='U+011B LATIN SMALL LETTER E WITH CARON' where ujis=0x8FABB5; +update t1 set name='U+0117 LATIN SMALL LETTER E WITH DOT ABOVE' where ujis=0x8FABB6; +update t1 set name='U+0113 LATIN SMALL LETTER E WITH MACRON' where ujis=0x8FABB7; +update t1 set name='U+0119 LATIN SMALL LETTER E WITH OGONEK' where ujis=0x8FABB8; +update t1 set name='U+01F5 LATIN SMALL LETTER G WITH ACUTE' where ujis=0x8FABB9; +update t1 set name='U+011D LATIN SMALL LETTER G WITH CIRCUMFLEX' where ujis=0x8FABBA; +update t1 set name='U+011F LATIN SMALL LETTER G WITH BREVE' where ujis=0x8FABBB; +update t1 set name='U+0121 LATIN SMALL LETTER G WITH DOT ABOVE' where ujis=0x8FABBD; +update t1 set name='U+0125 LATIN SMALL LETTER H WITH CIRCUMFLEX' where ujis=0x8FABBE; +update t1 set name='U+00ED LATIN SMALL LETTER I WITH ACUTE' where ujis=0x8FABBF; +update t1 set name='U+00EC LATIN SMALL LETTER I WITH GRAVE' where ujis=0x8FABC0; +update t1 set name='U+00EF LATIN SMALL LETTER I WITH DIAERESIS' where ujis=0x8FABC1; +update t1 set name='U+00EE LATIN SMALL LETTER I WITH CIRCUMFLEX' where ujis=0x8FABC2; +update t1 set name='U+01D0 LATIN SMALL LETTER I WITH CARON' where ujis=0x8FABC3; +update t1 set name='U+012B LATIN SMALL LETTER I WITH MACRON' where ujis=0x8FABC5; +update t1 set name='U+012F LATIN SMALL LETTER I WITH OGONEK' where ujis=0x8FABC6; +update t1 set name='U+0129 LATIN SMALL LETTER I WITH TILDE' where ujis=0x8FABC7; +update t1 set name='U+0135 LATIN SMALL LETTER J WITH CIRCUMFLEX' where ujis=0x8FABC8; +update t1 set name='U+0137 LATIN SMALL LETTER K WITH CEDILLA' where ujis=0x8FABC9; +update t1 set name='U+013A LATIN SMALL LETTER L WITH ACUTE' where ujis=0x8FABCA; +update t1 set name='U+013E LATIN SMALL LETTER L WITH CARON' where ujis=0x8FABCB; +update t1 set name='U+013C LATIN SMALL LETTER L WITH CEDILLA' where ujis=0x8FABCC; +update t1 set name='U+0144 LATIN SMALL LETTER N WITH ACUTE' where ujis=0x8FABCD; +update t1 set name='U+0148 LATIN SMALL LETTER N WITH CARON' where ujis=0x8FABCE; +update t1 set name='U+0146 LATIN SMALL LETTER N WITH CEDILLA' where ujis=0x8FABCF; +update t1 set name='U+00F1 LATIN SMALL LETTER N WITH TILDE' where ujis=0x8FABD0; +update t1 set name='U+00F3 LATIN SMALL LETTER O WITH ACUTE' where ujis=0x8FABD1; +update t1 set name='U+00F2 LATIN SMALL LETTER O WITH GRAVE' where ujis=0x8FABD2; +update t1 set name='U+00F6 LATIN SMALL LETTER O WITH DIAERESIS' where ujis=0x8FABD3; +update t1 set name='U+00F4 LATIN SMALL LETTER O WITH CIRCUMFLEX' where ujis=0x8FABD4; +update t1 set name='U+01D2 LATIN SMALL LETTER O WITH CARON' where ujis=0x8FABD5; +update t1 set name='U+0151 LATIN SMALL LETTER O WITH DOUBLE ACUTE' where ujis=0x8FABD6; +update t1 set name='U+014D LATIN SMALL LETTER O WITH MACRON' where ujis=0x8FABD7; +update t1 set name='U+00F5 LATIN SMALL LETTER O WITH TILDE' where ujis=0x8FABD8; +update t1 set name='U+0155 LATIN SMALL LETTER R WITH ACUTE' where ujis=0x8FABD9; +update t1 set name='U+0159 LATIN SMALL LETTER R WITH CARON' where ujis=0x8FABDA; +update t1 set name='U+0157 LATIN SMALL LETTER R WITH CEDILLA' where ujis=0x8FABDB; +update t1 set name='U+015B LATIN SMALL LETTER S WITH ACUTE' where ujis=0x8FABDC; +update t1 set name='U+015D LATIN SMALL LETTER S WITH CIRCUMFLEX' where ujis=0x8FABDD; +update t1 set name='U+0161 LATIN SMALL LETTER S WITH CARON' where ujis=0x8FABDE; +update t1 set name='U+015F LATIN SMALL LETTER S WITH CEDILLA' where ujis=0x8FABDF; +update t1 set name='U+0165 LATIN SMALL LETTER T WITH CARON' where ujis=0x8FABE0; +update t1 set name='U+0163 LATIN SMALL LETTER T WITH CEDILLA' where ujis=0x8FABE1; +update t1 set name='U+00FA LATIN SMALL LETTER U WITH ACUTE' where ujis=0x8FABE2; +update t1 set name='U+00F9 LATIN SMALL LETTER U WITH GRAVE' where ujis=0x8FABE3; +update t1 set name='U+00FC LATIN SMALL LETTER U WITH DIAERESIS' where ujis=0x8FABE4; +update t1 set name='U+00FB LATIN SMALL LETTER U WITH CIRCUMFLEX' where ujis=0x8FABE5; +update t1 set name='U+016D LATIN SMALL LETTER U WITH BREVE' where ujis=0x8FABE6; +update t1 set name='U+01D4 LATIN SMALL LETTER U WITH CARON' where ujis=0x8FABE7; +update t1 set name='U+0171 LATIN SMALL LETTER U WITH DOUBLE ACUTE' where ujis=0x8FABE8; +update t1 set name='U+016B LATIN SMALL LETTER U WITH MACRON' where ujis=0x8FABE9; +update t1 set name='U+0173 LATIN SMALL LETTER U WITH OGONEK' where ujis=0x8FABEA; +update t1 set name='U+016F LATIN SMALL LETTER U WITH RING ABOVE' where ujis=0x8FABEB; +update t1 set name='U+0169 LATIN SMALL LETTER U WITH TILDE' where ujis=0x8FABEC; +update t1 set name='U+01D8 LATIN SMALL LETTER U WITH DIAERESIS AND ACUTE' where ujis=0x8FABED; +update t1 set name='U+01DC LATIN SMALL LETTER U WITH DIAERESIS AND GRAVE' where ujis=0x8FABEE; +update t1 set name='U+01DA LATIN SMALL LETTER U WITH DIAERESIS AND CARON' where ujis=0x8FABEF; +update t1 set name='U+01D6 LATIN SMALL LETTER U WITH DIAERESIS AND MACRON' where ujis=0x8FABF0; +update t1 set name='U+0175 LATIN SMALL LETTER W WITH CIRCUMFLEX' where ujis=0x8FABF1; +update t1 set name='U+00FD LATIN SMALL LETTER Y WITH ACUTE' where ujis=0x8FABF2; +update t1 set name='U+00FF LATIN SMALL LETTER Y WITH DIAERESIS' where ujis=0x8FABF3; +update t1 set name='U+0177 LATIN SMALL LETTER Y WITH CIRCUMFLEX' where ujis=0x8FABF4; +update t1 set name='U+017A LATIN SMALL LETTER Z WITH ACUTE' where ujis=0x8FABF5; +update t1 set name='U+017E LATIN SMALL LETTER Z WITH CARON' where ujis=0x8FABF6; +update t1 set name='U+017C LATIN SMALL LETTER Z WITH DOT ABOVE' where ujis=0x8FABF7; + +# [8F][B0..BF][A1..FE] - all 16*94=1504 codes assigned +update t1 set name='<CJK>' where ujis >= 0x8FB0A1 AND ujis <= 0x8FBFFE; + +# [8F][C0..CF][A1..FE] - all 16*94=1504 codes assigned +update t1 set name='<CJK>' where ujis >= 0x8FC0A1 AND ujis <= 0x8FCFFE; + +# [8F][D0..DF][A1..FE] - all 16*94=1504 codes assigned +update t1 set name='<CJK>' where ujis >= 0x8FD0A1 AND ujis <= 0x8FDFFE; + +# [8F][E0..EC][A1..FE] - all 13*94=1222 codes assigned +update t1 set name='<CJK>' where ujis >= 0x8FE0A1 AND ujis <= 0x8FECFE; + +# +update t1 set name='U+9EF8 <CJK>' where ujis=0x8FEDA1; +update t1 set name='U+9EFF <CJK>' where ujis=0x8FEDA2; +update t1 set name='U+9F02 <CJK>' where ujis=0x8FEDA3; +update t1 set name='U+9F03 <CJK>' where ujis=0x8FEDA4; +update t1 set name='U+9F09 <CJK>' where ujis=0x8FEDA5; +update t1 set name='U+9F0F <CJK>' where ujis=0x8FEDA6; +update t1 set name='U+9F10 <CJK>' where ujis=0x8FEDA7; +update t1 set name='U+9F11 <CJK>' where ujis=0x8FEDA8; +update t1 set name='U+9F12 <CJK>' where ujis=0x8FEDA9; +update t1 set name='U+9F14 <CJK>' where ujis=0x8FEDAA; +update t1 set name='U+9F16 <CJK>' where ujis=0x8FEDAB; +update t1 set name='U+9F17 <CJK>' where ujis=0x8FEDAC; +update t1 set name='U+9F19 <CJK>' where ujis=0x8FEDAD; +update t1 set name='U+9F1A <CJK>' where ujis=0x8FEDAE; +update t1 set name='U+9F1B <CJK>' where ujis=0x8FEDAF; + +update t1 set name='U+9F1F <CJK>' where ujis=0x8FEDB0; +update t1 set name='U+9F22 <CJK>' where ujis=0x8FEDB1; +update t1 set name='U+9F26 <CJK>' where ujis=0x8FEDB2; +update t1 set name='U+9F2A <CJK>' where ujis=0x8FEDB3; +update t1 set name='U+9F2B <CJK>' where ujis=0x8FEDB4; +update t1 set name='U+9F2F <CJK>' where ujis=0x8FEDB5; +update t1 set name='U+9F31 <CJK>' where ujis=0x8FEDB6; +update t1 set name='U+9F32 <CJK>' where ujis=0x8FEDB7; +update t1 set name='U+9F34 <CJK>' where ujis=0x8FEDB8; +update t1 set name='U+9F37 <CJK>' where ujis=0x8FEDB9; +update t1 set name='U+9F39 <CJK>' where ujis=0x8FEDBA; +update t1 set name='U+9F3A <CJK>' where ujis=0x8FEDBB; +update t1 set name='U+9F3C <CJK>' where ujis=0x8FEDBC; +update t1 set name='U+9F3D <CJK>' where ujis=0x8FEDBD; +update t1 set name='U+9F3F <CJK>' where ujis=0x8FEDBE; +update t1 set name='U+9F41 <CJK>' where ujis=0x8FEDBF; + +update t1 set name='U+9F43 <CJK>' where ujis=0x8FEDC0; +update t1 set name='U+9F44 <CJK>' where ujis=0x8FEDC1; +update t1 set name='U+9F45 <CJK>' where ujis=0x8FEDC2; +update t1 set name='U+9F46 <CJK>' where ujis=0x8FEDC3; +update t1 set name='U+9F47 <CJK>' where ujis=0x8FEDC4; +update t1 set name='U+9F53 <CJK>' where ujis=0x8FEDC5; +update t1 set name='U+9F55 <CJK>' where ujis=0x8FEDC6; +update t1 set name='U+9F56 <CJK>' where ujis=0x8FEDC7; +update t1 set name='U+9F57 <CJK>' where ujis=0x8FEDC8; +update t1 set name='U+9F58 <CJK>' where ujis=0x8FEDC9; +update t1 set name='U+9F5A <CJK>' where ujis=0x8FEDCA; +update t1 set name='U+9F5D <CJK>' where ujis=0x8FEDCB; +update t1 set name='U+9F5E <CJK>' where ujis=0x8FEDCC; +update t1 set name='U+9F68 <CJK>' where ujis=0x8FEDCD; +update t1 set name='U+9F69 <CJK>' where ujis=0x8FEDCE; +update t1 set name='U+9F6D <CJK>' where ujis=0x8FEDCF; + +update t1 set name='U+9F6E <CJK>' where ujis=0x8FEDD0; +update t1 set name='U+9F6F <CJK>' where ujis=0x8FEDD1; +update t1 set name='U+9F70 <CJK>' where ujis=0x8FEDD2; +update t1 set name='U+9F71 <CJK>' where ujis=0x8FEDD3; +update t1 set name='U+9F73 <CJK>' where ujis=0x8FEDD4; +update t1 set name='U+9F75 <CJK>' where ujis=0x8FEDD5; +update t1 set name='U+9F7A <CJK>' where ujis=0x8FEDD6; +update t1 set name='U+9F7D <CJK>' where ujis=0x8FEDD7; +update t1 set name='U+9F8F <CJK>' where ujis=0x8FEDD8; +update t1 set name='U+9F90 <CJK>' where ujis=0x8FEDD9; +update t1 set name='U+9F91 <CJK>' where ujis=0x8FEDDA; +update t1 set name='U+9F92 <CJK>' where ujis=0x8FEDDB; +update t1 set name='U+9F94 <CJK>' where ujis=0x8FEDDC; +update t1 set name='U+9F96 <CJK>' where ujis=0x8FEDDD; +update t1 set name='U+9F97 <CJK>' where ujis=0x8FEDDE; +update t1 set name='U+9F9E <CJK>' where ujis=0x8FEDDF; + +update t1 set name='U+9FA1 <CJK>' where ujis=0x8FEDE0; +update t1 set name='U+9FA2 <CJK>' where ujis=0x8FEDE1; +update t1 set name='U+9FA3 <CJK>' where ujis=0x8FEDE2; +update t1 set name='U+9FA5 <CJK>' where ujis=0x8FEDE3; + +# [8F][F5..FE][A1..FE] - User defined range +update t1 set name='User defined range #2' where ujis >= 0x8FF5A1 and ujis <= 0x8FFEFE; + +# Other characters are not assigned +update t1 set name='UNASSIGNED' where name=''; + +update t1 set ucs2=ujis, ujis2=ucs2; +--echo Characters with safe Unicode round trip +select hex(ujis), hex(ucs2), hex(ujis2), name from t1 where ujis=ujis2 order by ujis; +--echo Characters with unsafe Unicode round trip +select hex(ujis), hex(ucs2), hex(ujis2), name from t1 where ujis<>ujis2 order by ujis; +drop table t1; + +drop table t2; + +# +# Tricky characters, which have different mapping +# in various euc-jp versions. See WL#1820 for details. +# +create table t1 ( + ujis varchar(1) character set ujis, + name varchar(64), + ucs2 varchar(1) character set ucs2, + ujis2 varchar(1) character set ujis +); +insert into t1 (ujis,name) values (0x5C, 'U+005C REVERSE SOLIDUS'); +insert into t1 (ujis,name) values (0x7E, 'U+007E TILDE'); +insert into t1 (ujis,name) values (0xA1B1, 'U+FFE3 FULLWIDTH MACRON'); +insert into t1 (ujis,name) values (0xA1BD, 'U+2015 HORIZONTAL BAR'); +insert into t1 (ujis,name) values (0xA1C0, 'U+005C REVERSE SOLIDUS'); +insert into t1 (ujis,name) values (0xA1C1, 'U+301C WAVE DASH'); +insert into t1 (ujis,name) values (0xA1C2, 'U+2016 DOUBLE VERTICAL LINE'); +insert into t1 (ujis,name) values (0xA1DD, 'U+2212 MINUS SIGN'); +insert into t1 (ujis,name) values (0xA1F1, 'U+00A2 CENT SIGN'); +insert into t1 (ujis,name) values (0xA1F2, 'U+00A3 POUND SIGN'); +insert into t1 (ujis,name) values (0xA1EF, 'U+FFE5 FULLWIDTH YEN SIGN'); +insert into t1 (ujis,name) values (0xA2CC, 'U+00AC NOT SIGN'); +insert into t1 (ujis,name) values (0x8FA2B7, 'U+007E TILDE'); +insert into t1 (ujis,name) values (0x8FA2C3, 'U+00A6 BROKEN BAR'); +update t1 set ucs2=ujis, ujis2=ucs2; +select hex(ujis), hex(ucs2), hex(ujis2), name from t1; +drop table t1; + +# +# Unicode characters which are not in x-eucjp-unicode-0.9 +# +create table t1 ( + ujis char(1) character set ujis, + ucs2 char(1) character set ucs2, + name char(64) +); +insert into t1 (ucs2,name) values (0x00A5,'U+00A5 YEN SIGN'); +insert into t1 (ucs2,name) values (0x2014,'U+2014 EM DASH'); +insert into t1 (ucs2,name) values (0x203E,'U+203E OVERLINE'); +insert into t1 (ucs2,name) values (0x2225,'U+2225 PARALLEL TO'); +insert into t1 (ucs2,name) values (0xFF0D,'U+FF0D FULLWIDTH HYPHEN-MINUS'); +insert into t1 (ucs2,name) values (0xFF3C,'U+FF3C FULLWIDTH REVERSE SOLIDUS'); +insert into t1 (ucs2,name) values (0xFF5E,'U+FF5E FULLWIDTH TILDE'); +insert into t1 (ucs2,name) values (0xFFE0,'U+FFE0 FULLWIDTH CENT SIGN'); +insert into t1 (ucs2,name) values (0xFFE1,'U+FFE1 FULLWIDTH POUND SIGN'); +insert into t1 (ucs2,name) values (0xFFE2,'U+FFE2 FULLWIDTH NOT SIGN'); +insert into t1 (ucs2,name) values (0xFFE4,'U+FFE4 FULLWIDTH BROKEN BAR'); +update t1 set ujis=ucs2; +select hex(ucs2),hex(ujis),name from t1 order by name; +drop table t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 5111660bcbe..f0c769251cf 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -237,9 +237,9 @@ drop table t2; create table t1 (c varchar(30) character set utf8, unique(c(10))); insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); insert into t1 values ('aaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaaaaaaaaaaa'); insert into t1 values (repeat('b',20)); select c c1 from t1 where c='1'; @@ -261,9 +261,9 @@ create table t1 (c varchar(30) character set utf8, unique(c(10))) engine=innodb; --enable_warnings insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); insert into t1 values ('aaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaaaaaaaaaaa'); insert into t1 values (repeat('b',20)); select c c1 from t1 where c='1'; @@ -283,23 +283,23 @@ create table t1 (c char(3) character set utf8, unique (c(2))); insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); insert into t1 values ('a'); insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaa'); insert into t1 values ('b'); insert into t1 values ('bb'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('bbb'); insert into t1 values ('а'); insert into t1 values ('аа'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ааа'); insert into t1 values ('б'); insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ббб'); insert into t1 values ('ꪪ'); insert into t1 values ('ꪪꪪ'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ꪪꪪꪪ'); drop table t1; # @@ -312,23 +312,23 @@ create table t1 (c char(3) character set utf8, unique (c(2))) engine=innodb; insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); insert into t1 values ('a'); insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaa'); insert into t1 values ('b'); insert into t1 values ('bb'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('bbb'); insert into t1 values ('а'); insert into t1 values ('аа'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ааа'); insert into t1 values ('б'); insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ббб'); insert into t1 values ('ꪪ'); insert into t1 values ('ꪪꪪ'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ꪪꪪꪪ'); drop table t1; # @@ -341,14 +341,14 @@ unique key a using hash (c(1)) ) engine=heap; show create table t1; insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; @@ -365,14 +365,14 @@ unique key a using btree (c(1)) ) engine=heap; show create table t1; insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; @@ -387,17 +387,17 @@ 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 +--error ER_DUP_ENTRY insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; @@ -411,9 +411,9 @@ drop table t1; create table t1 (c varchar(30) character set utf8 collate utf8_bin, unique(c(10))); insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); insert into t1 values ('aaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaaaaaaaaaa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaaaaaaaaaaa'); insert into t1 values (repeat('b',20)); select c c1 from t1 where c='1'; @@ -434,23 +434,23 @@ create table t1 (c char(3) character set utf8 collate utf8_bin, unique (c(2))); insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); insert into t1 values ('a'); insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaa'); insert into t1 values ('b'); insert into t1 values ('bb'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('bbb'); insert into t1 values ('а'); insert into t1 values ('аа'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ааа'); insert into t1 values ('б'); insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ббб'); insert into t1 values ('ꪪ'); insert into t1 values ('ꪪꪪ'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ꪪꪪꪪ'); drop table t1; @@ -464,14 +464,14 @@ unique key a using hash (c(1)) ) engine=heap; show create table t1; insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; @@ -488,14 +488,14 @@ unique key a using btree (c(1)) ) engine=heap; show create table t1; insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; @@ -510,17 +510,17 @@ 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 +--error ER_DUP_ENTRY insert into t1 values ('aa'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('aaa'); insert into t1 values ('б'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('бб'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('ббб'); select c as c_all from t1 order by c; select c as c_a from t1 where c='a'; @@ -585,7 +585,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'); @@ -671,7 +671,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; @@ -721,6 +721,7 @@ select hex(soundex(_utf8 0xD091D092D093)); SET collation_connection='utf8_general_ci'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc +-- source include/ctype_german.inc SET collation_connection='utf8_bin'; -- source include/ctype_filesort.inc -- source include/ctype_like_escape.inc @@ -1184,6 +1185,7 @@ explain select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1; select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1; drop table t1; + # End of 4.1 tests # diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 0c02398acc1..e5dc7ffa53e 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -6,8 +6,15 @@ drop table if exists t1; --enable_warnings -SHOW GLOBAL VARIABLES LIKE "%_format%"; -SHOW SESSION VARIABLES LIKE "%_format%"; +SELECT variable_name, variable_value +FROM information_schema.global_variables +WHERE variable_name IN ('date_format', 'datetime_format', 'time_format') +ORDER BY variable_name; + +SELECT variable_name, variable_value +FROM information_schema.session_variables +WHERE variable_name IN ('date_format', 'datetime_format', 'time_format') +ORDER BY variable_name; # # Test setting a lot of different formats to see which formats are accepted and @@ -34,7 +41,10 @@ set datetime_format= '%H:%i:%s.%f %m-%d-%Y'; set datetime_format= '%h:%i:%s %p %Y-%m-%d'; set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d'; -SHOW SESSION VARIABLES LIKE "%format"; +SELECT variable_name, variable_value +FROM information_schema.session_variables +WHERE variable_name IN ('date_format', 'datetime_format', 'time_format') +ORDER BY variable_name; --error 1231 SET time_format='%h:%i:%s'; @@ -118,7 +128,7 @@ SET datetime_format=default; # Test of str_to_date # -# PS doesn't support fraction of a seconds +# PS doesn't support fractions of a second --disable_ps_protocol select str_to_date(concat('15-01-2001',' 2:59:58.999'), concat('%d-%m-%Y',' ','%H:%i:%s.%f')); diff --git a/mysql-test/t/ddl_i18n_koi8r.test b/mysql-test/t/ddl_i18n_koi8r.test new file mode 100644 index 00000000000..fecef2f95d5 --- /dev/null +++ b/mysql-test/t/ddl_i18n_koi8r.test @@ -0,0 +1,1149 @@ +# Objects to test: +# - stored procedures/functions; +# - triggers; +# - events; +# - views; +# +# For stored routines: +# - create a database with collation utf8_unicode_ci; +# - create an object, which +# - contains SP-var with explicit CHARSET-clause; +# - contains SP-var without CHARSET-clause; +# - contains text constant; +# - has localized routine/parameter names; +# - check: +# - execute; +# - SHOW CREATE output; +# - SHOW output; +# - SELECT FROM INFORMATION_SCHEMA output; +# - alter database character set; +# - change connection collation; +# - check again; +# - dump definition using mysqldump; +# - drop object; +# - restore object; +# + +########################################################################### +# +# NOTE: this file contains text in UTF8 and KOI8-R encodings. +# +########################################################################### + +# Test requires server to accept client connections (for mysqldump portions) +--source include/not_embedded.inc +--source include/have_utf8.inc +--source include/have_cp866.inc +--source include/have_cp1251.inc +--source include/have_koi8r.inc + +########################################################################### + +set names koi8r; +delimiter |; + +########################################################################### +# +# * Views. +# +########################################################################### + +--echo +--echo ------------------------------------------------------------------- +--echo Views +--echo ------------------------------------------------------------------- +--echo + +# +# Preparation: +# + +# - Create database with fixed, pre-defined character set. + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1| +--enable_warnings + +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| + +use mysqltest1| + +CREATE TABLE t1( INT)| +INSERT INTO t1 VALUES(1)| + +# - Create views; + +--echo + +CREATE VIEW v1 AS + SELECT '' AS c1, AS c2 + FROM t1| + +--echo + +CREATE VIEW v2 AS SELECT _utf8'тест' as c1| + +--echo + +CREATE VIEW v3 AS SELECT _utf8'тест'| + +--echo + +# +# First-round checks. +# + +--source include/ddl_i18n.check_views.inc + +# +# Change running environment (alter database character set, change session +# variables). +# + +--echo +--echo + +ALTER DATABASE mysqltest1 COLLATE cp866_general_ci| + +# +# Second-round checks: +# + +# - Change connection to flush cache; + +--connect (con2,localhost,root,,) +--echo +--echo ---> connection: con2 + +# - Switch environment variables and trigger loading views; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +--disable_result_log +SELECT * FROM mysqltest1.v1| +SELECT * FROM mysqltest1.v2| +SELECT * FROM mysqltest1.v3| +--enable_result_log + +use mysqltest1| + +# - Restore environment; + +set names koi8r| + +# - Check! + +--source include/ddl_i18n.check_views.inc + +# +# Check mysqldump. +# + +# - Dump mysqltest1; + +--let $views_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.views.mysqltest1.sql + +--echo +--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.views.mysqltest1.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $views_dump1 + +# - Clean mysqltest1; + +--echo +--echo + +DROP DATABASE mysqltest1| + +# - Restore mysqltest1; + +--echo +--echo + +--echo ---> Restoring mysqltest1... +--exec $MYSQL test < $views_dump1 + +--remove_file $views_dump1 + +# +# Third-round checks. +# + +# - Change connection to flush cache; + +--connect (con3,localhost,root,,) +--echo +--echo ---> connection: con3 + +# - Switch environment variables and trigger loading views; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +--disable_result_log +SELECT * FROM mysqltest1.v1| +SELECT * FROM mysqltest1.v2| +SELECT * FROM mysqltest1.v3| +--enable_result_log + +use mysqltest1| + +# - Restore environment; + +set names koi8r| + +# - Check! + +--source include/ddl_i18n.check_views.inc + +# +# Cleanup. +# + +--connection default +--echo +--echo ---> connection: default + +--disconnect con2 +--disconnect con3 + +use test| + +DROP DATABASE mysqltest1| + +########################################################################### +# +# * Stored procedures/functions. +# +########################################################################### + +--echo +--echo ------------------------------------------------------------------- +--echo Stored procedures/functions +--echo ------------------------------------------------------------------- +--echo + +# +# Preparation: +# + +# - Create database with fixed, pre-defined character set. + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +--enable_warnings + +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| +CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| + +use mysqltest1| + +# - Create two stored routines -- with and without explicit +# CHARSET-clause for SP-variable; +# + +--echo + +# - Procedure p1 + +CREATE PROCEDURE p1( + INOUT 1 CHAR(10), + OUT 2 CHAR(10)) +BEGIN + DECLARE 1 CHAR(10); + + SELECT + COLLATION(1) AS c1, + COLLATION(1) AS c2, + COLLATION(2) AS c3; + + SELECT + COLLATION('') AS c4, + COLLATION(_koi8r '') AS c5, + COLLATION(_utf8 'текст') AS c6, + @@collation_connection AS c7, + @@character_set_client AS c8; + + SET 1 = 'a'; + SET 2 = 'b'; +END| + +--echo + +# - Procedure p2 + +CREATE PROCEDURE p2( + INOUT 1 CHAR(10) CHARACTER SET utf8, + OUT 2 CHAR(10) CHARACTER SET utf8) +BEGIN + DECLARE 1 CHAR(10) CHARACTER SET utf8; + + SELECT + COLLATION(1) AS c1, + COLLATION(1) AS c2, + COLLATION(2) AS c3; + + SELECT + COLLATION('') AS c4, + COLLATION(_koi8r '') AS c5, + COLLATION(_utf8 'текст') AS c6, + @@collation_connection AS c7, + @@character_set_client AS c8; + + SET 1 = 'a'; + SET 2 = 'b'; +END| + +--echo + +# - Procedure p3 + +CREATE PROCEDURE mysqltest2.p3( + INOUT 1 CHAR(10), + OUT 2 CHAR(10)) +BEGIN + DECLARE 1 CHAR(10); + + SELECT + COLLATION(1) AS c1, + COLLATION(1) AS c2, + COLLATION(2) AS c3; + + SELECT + COLLATION('') AS c4, + COLLATION(_koi8r '') AS c5, + COLLATION(_utf8 'текст') AS c6, + @@collation_connection AS c7, + @@character_set_client AS c8; + + SET 1 = 'a'; + SET 2 = 'b'; +END| + +--echo + +# - Procedure p4 + +CREATE PROCEDURE mysqltest2.p4( + INOUT 1 CHAR(10) CHARACTER SET utf8, + OUT 2 CHAR(10) CHARACTER SET utf8) +BEGIN + DECLARE 1 CHAR(10) CHARACTER SET utf8; + + SELECT + COLLATION(1) AS c1, + COLLATION(1) AS c2, + COLLATION(2) AS c3; + + SELECT + COLLATION('') AS c4, + COLLATION(_koi8r '') AS c5, + COLLATION(_utf8 'текст') AS c6, + @@collation_connection AS c7, + @@character_set_client AS c8; + + SET 1 = 'a'; + SET 2 = 'b'; +END| + +# +# First-round checks. +# + +--source include/ddl_i18n.check_sp.inc + +# +# Change running environment (alter database character set, change session +# variables). +# + +--echo +--echo + +ALTER DATABASE mysqltest1 COLLATE cp866_general_ci| +ALTER DATABASE mysqltest2 COLLATE cp866_general_ci| + +# +# Second-round checks: +# + +# - Change connection to flush SP-cache; + +--connect (con2,localhost,root,,mysqltest1) +--echo +--echo ---> connection: con2 + +# - Switch environment variables and trigger loading stored procedures; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +CALL p1(@a, @b)| +CALL p2(@a, @b)| +CALL mysqltest2.p3(@a, @b)| +CALL mysqltest2.p4(@a, @b)| + +# - Restore environment; + +set names koi8r| + +# - Check! + +--source include/ddl_i18n.check_sp.inc + +# +# Check mysqldump. +# + +# - Dump mysqltest1, mysqltest2; + +--let $sp_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest1.sql +--let $sp_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest2.sql + +--echo +--echo ---> Dump of mysqltest1 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 + +--echo +--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.sp.mysqltest1.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $sp_dump1 + +--echo +--echo ---> Dump of mysqltest2 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 + +--echo +--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.sp.mysqltest2.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $sp_dump2 + +# - Clean mysqltest1, mysqltest2; + +--echo +--echo + +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| + +# - Restore mysqltest1; + +--echo +--echo + +--echo ---> Restoring mysqltest1... +--exec $MYSQL test < $sp_dump1 + +--echo ---> Restoring mysqltest2... +--exec $MYSQL test < $sp_dump2 + +--remove_file $sp_dump1 +--remove_file $sp_dump2 + +# +# Third-round checks. +# + +# - Change connection to flush SP-cache; + +--connect (con3,localhost,root,,mysqltest1) +--echo +--echo ---> connection: con3 + +# - Switch environment variables and trigger loading stored procedures; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +CALL p1(@a, @b)| +CALL p2(@a, @b)| +CALL mysqltest2.p3(@a, @b)| +CALL mysqltest2.p4(@a, @b)| + +# - Restore environment; + +set names koi8r| + +# - Check! + +--source include/ddl_i18n.check_sp.inc + +# +# Cleanup. +# + +--connection default +--echo +--echo ---> connection: default + +--disconnect con2 +--disconnect con3 + +use test| + +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| + +########################################################################### +# +# * Triggers. +# +########################################################################### + +--echo +--echo ------------------------------------------------------------------- +--echo Triggers +--echo ------------------------------------------------------------------- +--echo + +# +# Preparation: +# + +# - Create database with fixed, pre-defined character set; + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +--enable_warnings + +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| +CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| + +use mysqltest1| + +# - Create tables for triggers; + +CREATE TABLE t1(c INT)| +CREATE TABLE mysqltest2.t1(c INT)| + +# - Create log tables; + +CREATE TABLE log(msg VARCHAR(255))| +CREATE TABLE mysqltest2.log(msg VARCHAR(255))| + + +# - Create triggers -- with and without explicit CHARSET-clause for +# SP-variable; +# + +--echo + +# - Trigger trg1 + +CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW +BEGIN + DECLARE 1 CHAR(10); + + INSERT INTO log VALUES(COLLATION(1)); + INSERT INTO log VALUES(COLLATION('')); + INSERT INTO log VALUES(COLLATION(_koi8r '')); + INSERT INTO log VALUES(COLLATION(_utf8 'текст')); + INSERT INTO log VALUES(@@collation_connection); + INSERT INTO log VALUES(@@character_set_client); + + SET @a1 = ''; + SET @a1 = _koi8r ''; + SET @a2 = _utf8 'текст'; +END| + +--echo + +# - Trigger trg2 + +CREATE TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW +BEGIN + DECLARE 1 CHAR(10) CHARACTER SET utf8; + + INSERT INTO log VALUES(COLLATION(1)); + INSERT INTO log VALUES(COLLATION('')); + INSERT INTO log VALUES(COLLATION(_koi8r '')); + INSERT INTO log VALUES(COLLATION(_utf8 'текст')); + INSERT INTO log VALUES(@@collation_connection); + INSERT INTO log VALUES(@@character_set_client); + + SET @b1 = ''; + SET @b1 = _koi8r ''; + SET @b2 = _utf8 'текст'; +END| + +--echo + +# - Trigger trg3 + +CREATE TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW +BEGIN + DECLARE 1 CHAR(10); + + INSERT INTO log VALUES(COLLATION(1)); + INSERT INTO log VALUES(COLLATION('')); + INSERT INTO log VALUES(COLLATION(_koi8r '')); + INSERT INTO log VALUES(COLLATION(_utf8 'текст')); + INSERT INTO log VALUES(@@collation_connection); + INSERT INTO log VALUES(@@character_set_client); + + SET @a1 = ''; + SET @a1 = _koi8r ''; + SET @a2 = _utf8 'текст'; +END| + +--echo + +# - Trigger trg4 + +CREATE TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW +BEGIN + DECLARE 1 CHAR(10) CHARACTER SET utf8; + + INSERT INTO log VALUES(COLLATION(1)); + INSERT INTO log VALUES(COLLATION('')); + INSERT INTO log VALUES(COLLATION(_koi8r '')); + INSERT INTO log VALUES(COLLATION(_utf8 'текст')); + INSERT INTO log VALUES(@@collation_connection); + INSERT INTO log VALUES(@@character_set_client); + + SET @b1 = ''; + SET @b1 = _koi8r ''; + SET @b2 = _utf8 'текст'; +END| + +--echo + +# +# First-round checks. +# + +--source include/ddl_i18n.check_triggers.inc + +# +# Change running environment (alter database character set, change session +# variables). +# + +--echo +--echo + +ALTER DATABASE mysqltest1 COLLATE cp866_general_ci| +ALTER DATABASE mysqltest2 COLLATE cp866_general_ci| + +# +# Second-round checks: +# + +# - Flush table cache; + +ALTER TABLE t1 ADD COLUMN fake INT| +ALTER TABLE t1 DROP COLUMN fake| + +ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT| +ALTER TABLE mysqltest2.t1 DROP COLUMN fake| + +# - Switch environment variables and initiate loading of triggers +# (connect using NULL database); + +--connect (con2,localhost,root,,) +--echo +--echo ---> connection: con2 + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +INSERT INTO mysqltest1.t1 VALUES(0)| +INSERT INTO mysqltest2.t1 VALUES(0)| + +DELETE FROM mysqltest1.log| +DELETE FROM mysqltest2.log| + +# - Restore environment; + +set names koi8r| + +use mysqltest1| + +# - Check! + +--source include/ddl_i18n.check_triggers.inc + +# +# Check mysqldump. +# + +# - Dump mysqltest1, mysqltest2; + +--let $triggers_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest1.sql +--let $triggers_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest2.sql + +--echo +--echo ---> Dump of mysqltest1 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 + +--echo +--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.triggers.mysqltest1.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $triggers_dump1 + +--echo +--echo ---> Dump of mysqltest2 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 + +--echo +--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.triggers.mysqltest2.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $triggers_dump2 + +# - Clean mysqltest1, mysqltest2; + +--echo +--echo + +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| + +# - Restore mysqltest1; + +--echo +--echo + +--echo ---> Restoring mysqltest1... +--exec $MYSQL test < $triggers_dump1 + +--echo ---> Restoring mysqltest2... +--exec $MYSQL test < $triggers_dump2 + +--remove_file $triggers_dump1 +--remove_file $triggers_dump2 + +# +# Third-round checks. +# + +# - Flush table cache; + +ALTER TABLE mysqltest1.t1 ADD COLUMN fake INT| +ALTER TABLE mysqltest1.t1 DROP COLUMN fake| + +ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT| +ALTER TABLE mysqltest2.t1 DROP COLUMN fake| + +# - Switch environment variables and initiate loading of triggers +# (connect using NULL database); + +--connect (con3,localhost,root,,) +--echo +--echo ---> connection: con3 + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +INSERT INTO mysqltest1.t1 VALUES(0)| +INSERT INTO mysqltest2.t1 VALUES(0)| + +DELETE FROM mysqltest1.log| +DELETE FROM mysqltest2.log| + +# - Restore environment; + +set names koi8r| + +use mysqltest1| + +# - Check! + +--source include/ddl_i18n.check_triggers.inc + +# +# Cleanup. +# + +--connection default +--echo +--echo ---> connection: default + +--disconnect con2 +--disconnect con3 + +use test| + +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| + +########################################################################### +# +# * Events +# +# We don't have EXECUTE EVENT so far, so this test is limited. It checks that +# event with non-latin1 symbols can be created, dumped, restored and SHOW +# statements work properly. +# +########################################################################### + +--echo +--echo ------------------------------------------------------------------- +--echo Events +--echo ------------------------------------------------------------------- +--echo + +# +# Preparation: +# + +# - Create database with fixed, pre-defined character set. + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +--enable_warnings + +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| +CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| + +use mysqltest1| + +# - Create two stored routines -- with and without explicit +# CHARSET-clause for SP-variable; +# + +--echo + +# - Event ev1 + +CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO +BEGIN + DECLARE 1 CHAR(10); + + SELECT + COLLATION(1) AS c1, + COLLATION('') AS c2, + COLLATION(_koi8r '') AS c3, + COLLATION(_utf8 'текст') AS c4, + @@collation_connection AS c5, + @@character_set_client AS c6; +END| + +--echo + +# - Event ev2 + +CREATE EVENT ev2 ON SCHEDULE AT '2030-01-01 00:00:00' DO +BEGIN + DECLARE 1 CHAR(10) CHARACTER SET utf8; + + SELECT + COLLATION(1) AS c1, + COLLATION('') AS c2, + COLLATION(_koi8r '') AS c3, + COLLATION(_utf8 'текст') AS c4, + @@collation_connection AS c5, + @@character_set_client AS c6; +END| + +--echo + +# - Event ev3 + +CREATE EVENT mysqltest2.ev3 ON SCHEDULE AT '2030-01-01 00:00:00' DO +BEGIN + DECLARE 1 CHAR(10) CHARACTER SET utf8; + + SELECT + COLLATION(1) AS c1, + COLLATION('') AS c2, + COLLATION(_koi8r '') AS c3, + COLLATION(_utf8 'текст') AS c4, + @@collation_connection AS c5, + @@character_set_client AS c6; +END| + +--echo + +# - Event ev4 + +CREATE EVENT mysqltest2.ev4 ON SCHEDULE AT '2030-01-01 00:00:00' DO +BEGIN + DECLARE 1 CHAR(10) CHARACTER SET utf8; + + SELECT + COLLATION(1) AS c1, + COLLATION('') AS c2, + COLLATION(_koi8r '') AS c3, + COLLATION(_utf8 'текст') AS c4, + @@collation_connection AS c5, + @@character_set_client AS c6; +END| + +--echo + + +# +# First-round checks. +# + +--source include/ddl_i18n.check_events.inc + +# +# Change running environment (alter database character set, change session +# variables). +# + +--echo +--echo + +ALTER DATABASE mysqltest1 COLLATE cp866_general_ci| +ALTER DATABASE mysqltest2 COLLATE cp866_general_ci| + +# +# Second-round checks: +# + +# - Change connection to flush cache; + +--connect (con2,localhost,root,,mysqltest1) +--echo +--echo ---> connection: con2 + +# - Switch environment variables and trigger loading stored procedures; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +--disable_result_log +SHOW CREATE EVENT ev1| +SHOW CREATE EVENT ev2| +SHOW CREATE EVENT mysqltest2.ev3| +SHOW CREATE EVENT mysqltest2.ev4| +--enable_result_log + +# - Restore environment; + +set names koi8r| + +# - Check! + +--source include/ddl_i18n.check_events.inc + +# +# Check mysqldump. +# + +# - Dump mysqltest1, mysqltest2; + +--let $events_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest1.sql +--let $events_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest2.sql + +--echo +--echo ---> Dump of mysqltest1 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 + +--echo +--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.events.mysqltest1.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $events_dump1 + +--echo +--echo ---> Dump of mysqltest2 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 + +--echo +--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.events.mysqltest2.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $events_dump2 + +# - Clean mysqltest1, mysqltest2; + +--echo +--echo + +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| + +# - Restore mysqltest1; + +--echo +--echo + +--echo ---> Restoring mysqltest1... +--exec $MYSQL test < $events_dump1 + +--echo ---> Restoring mysqltest2... +--exec $MYSQL test < $events_dump2 + +--remove_file $events_dump1 +--remove_file $events_dump2 + +# +# Third-round checks. +# + +# - Change connection to flush cache; + +--connect (con3,localhost,root,,mysqltest1) +--echo +--echo ---> connection: con3 + +# - Switch environment variables and trigger loading stored procedures; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +--disable_result_log +SHOW CREATE EVENT ev1| +SHOW CREATE EVENT ev2| +SHOW CREATE EVENT mysqltest2.ev3| +SHOW CREATE EVENT mysqltest2.ev4| +--enable_result_log + +# - Restore environment; + +set names koi8r| + +# - Check! + +--source include/ddl_i18n.check_events.inc + +########################################################################### +# +# * DDL statements inside stored routine. +# +# Here we check that DDL statements use actual database collation even if they +# are called from stored routine. +# +########################################################################### + +--echo +--echo ------------------------------------------------------------------- +--echo DDL statements within stored routine. +--echo ------------------------------------------------------------------- +--echo + +# +# Preparation: +# + +# - Create database with fixed, pre-defined character set. + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +--enable_warnings + +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| +CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| + +use mysqltest1| + +# - Create procedures; + +--echo + +CREATE PROCEDURE p1() +BEGIN + CREATE TABLE t1(col1 VARCHAR(10)); + SHOW CREATE TABLE t1; +END| + +--echo + +CREATE PROCEDURE mysqltest2.p2() +BEGIN + CREATE TABLE t2(col1 VARCHAR(10)); + SHOW CREATE TABLE t2; +END| + +--echo + +# +# First-round checks. +# + +CALL p1()| + +--echo + +SHOW CREATE TABLE t1| + +--echo +--echo + +CALL mysqltest2.p2()| + +--echo + +SHOW CREATE TABLE mysqltest2.t2| + +# +# Alter database. +# + +--echo + +ALTER DATABASE mysqltest1 COLLATE cp1251_general_cs| +ALTER DATABASE mysqltest2 COLLATE cp1251_general_cs| + +DROP TABLE t1| +DROP TABLE mysqltest2.t2| + +--echo + +# +# Second-round checks. +# + +CALL p1()| + +--echo + +SHOW CREATE TABLE t1| + +--echo +--echo + +CALL mysqltest2.p2()| + +--echo + +SHOW CREATE TABLE mysqltest2.t2| + +########################################################################### +# +# That's it. +# +########################################################################### + +# +# Cleanup. +# +delimiter ;| + +--connection con2 +--echo +--echo ---> connection: con2 +--disconnect con2 +--source include/wait_until_disconnected.inc +--connection con3 +--echo +--echo ---> connection: con3 +--disconnect con3 +--source include/wait_until_disconnected.inc +--connection default +--echo +--echo ---> connection: default +USE test; +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; + diff --git a/mysql-test/t/ddl_i18n_utf8.test b/mysql-test/t/ddl_i18n_utf8.test new file mode 100644 index 00000000000..8788d0604f2 --- /dev/null +++ b/mysql-test/t/ddl_i18n_utf8.test @@ -0,0 +1,1149 @@ +# Objects to test: +# - stored procedures/functions; +# - triggers; +# - events; +# - views; +# +# For stored routines: +# - create a database with collation utf8_unicode_ci; +# - create an object, which +# - contains SP-var with explicit CHARSET-clause; +# - contains SP-var without CHARSET-clause; +# - contains text constant; +# - has localized routine/parameter names; +# - check: +# - execute; +# - SHOW CREATE output; +# - SHOW output; +# - SELECT FROM INFORMATION_SCHEMA output; +# - alter database character set; +# - change connection collation; +# - check again; +# - dump definition using mysqldump; +# - drop object; +# - restore object; +# + +########################################################################### +# +# NOTE: this file contains text in UTF8 and KOI8-R encodings. +# +########################################################################### + +# Test requires server to accept client connections (for mysqldump portions) +--source include/not_embedded.inc +--source include/have_utf8.inc +--source include/have_cp866.inc +--source include/have_cp1251.inc +--source include/have_koi8r.inc + +########################################################################### + +set names utf8; +delimiter |; + +########################################################################### +# +# * Views. +# +########################################################################### + +--echo +--echo ------------------------------------------------------------------- +--echo Views +--echo ------------------------------------------------------------------- +--echo + +# +# Preparation: +# + +# - Create database with fixed, pre-defined character set. + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1| +--enable_warnings + +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| + +use mysqltest1| + +CREATE TABLE t1(кол INT)| +INSERT INTO t1 VALUES(1)| + +# - Create views; + +--echo + +CREATE VIEW v1 AS + SELECT 'тест' AS c1, кол AS c2 + FROM t1| + +--echo + +CREATE VIEW v2 AS SELECT _koi8r'' as c1| + +--echo + +CREATE VIEW v3 AS SELECT _koi8r''| + +--echo + +# +# First-round checks. +# + +--source include/ddl_i18n.check_views.inc + +# +# Change running environment (alter database character set, change session +# variables). +# + +--echo +--echo + +ALTER DATABASE mysqltest1 COLLATE cp866_general_ci| + +# +# Second-round checks: +# + +# - Change connection to flush cache; + +--connect (con2,localhost,root,,) +--echo +--echo ---> connection: con2 + +# - Switch environment variables and trigger loading views; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +--disable_result_log +SELECT * FROM mysqltest1.v1| +SELECT * FROM mysqltest1.v2| +SELECT * FROM mysqltest1.v3| +--enable_result_log + +use mysqltest1| + +# - Restore environment; + +set names utf8| + +# - Check! + +--source include/ddl_i18n.check_views.inc + +# +# Check mysqldump. +# + +# - Dump mysqltest1; + +--let $views_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8views.mysqltest1.sql + +--echo +--echo ---> Dumping mysqltest1 to ddl_i18n_utf8views.mysqltest1.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $views_dump1 + +# - Clean mysqltest1; + +--echo +--echo + +DROP DATABASE mysqltest1| + +# - Restore mysqltest1; + +--echo +--echo + +--echo ---> Restoring mysqltest1... +--exec $MYSQL test < $views_dump1 + +--remove_file $views_dump1 + +# +# Third-round checks. +# + +# - Change connection to flush cache; + +--connect (con3,localhost,root,,) +--echo +--echo ---> connection: con3 + +# - Switch environment variables and trigger loading views; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +--disable_result_log +SELECT * FROM mysqltest1.v1| +SELECT * FROM mysqltest1.v2| +SELECT * FROM mysqltest1.v3| +--enable_result_log + +use mysqltest1| + +# - Restore environment; + +set names utf8| + +# - Check! + +--source include/ddl_i18n.check_views.inc + +# +# Cleanup. +# + +--connection default +--echo +--echo ---> connection: default + +--disconnect con2 +--disconnect con3 + +use test| + +DROP DATABASE mysqltest1| + +########################################################################### +# +# * Stored procedures/functions. +# +########################################################################### + +--echo +--echo ------------------------------------------------------------------- +--echo Stored procedures/functions +--echo ------------------------------------------------------------------- +--echo + +# +# Preparation: +# + +# - Create database with fixed, pre-defined character set. + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +--enable_warnings + +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| +CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| + +use mysqltest1| + +# - Create two stored routines -- with and without explicit +# CHARSET-clause for SP-variable; +# + +--echo + +# - Procedure p1 + +CREATE PROCEDURE p1( + INOUT парам1 CHAR(10), + OUT парам2 CHAR(10)) +BEGIN + DECLARE перем1 CHAR(10); + + SELECT + COLLATION(перем1) AS c1, + COLLATION(парам1) AS c2, + COLLATION(парам2) AS c3; + + SELECT + COLLATION('текст') AS c4, + COLLATION(_utf8 'текст') AS c5, + COLLATION(_koi8r '') AS c6, + @@collation_connection AS c7, + @@character_set_client AS c8; + + SET парам1 = 'a'; + SET парам2 = 'b'; +END| + +--echo + +# - Procedure p2 + +CREATE PROCEDURE p2( + INOUT парам1 CHAR(10) CHARACTER SET utf8, + OUT парам2 CHAR(10) CHARACTER SET utf8) +BEGIN + DECLARE перем1 CHAR(10) CHARACTER SET utf8; + + SELECT + COLLATION(перем1) AS c1, + COLLATION(парам1) AS c2, + COLLATION(парам2) AS c3; + + SELECT + COLLATION('текст') AS c4, + COLLATION(_utf8 'текст') AS c5, + COLLATION(_koi8r '') AS c6, + @@collation_connection AS c7, + @@character_set_client AS c8; + + SET парам1 = 'a'; + SET парам2 = 'b'; +END| + +--echo + +# - Procedure p3 + +CREATE PROCEDURE mysqltest2.p3( + INOUT парам1 CHAR(10), + OUT парам2 CHAR(10)) +BEGIN + DECLARE перем1 CHAR(10); + + SELECT + COLLATION(перем1) AS c1, + COLLATION(парам1) AS c2, + COLLATION(парам2) AS c3; + + SELECT + COLLATION('текст') AS c4, + COLLATION(_utf8 'текст') AS c5, + COLLATION(_koi8r '') AS c6, + @@collation_connection AS c7, + @@character_set_client AS c8; + + SET парам1 = 'a'; + SET парам2 = 'b'; +END| + +--echo + +# - Procedure p4 + +CREATE PROCEDURE mysqltest2.p4( + INOUT парам1 CHAR(10) CHARACTER SET utf8, + OUT парам2 CHAR(10) CHARACTER SET utf8) +BEGIN + DECLARE перем1 CHAR(10) CHARACTER SET utf8; + + SELECT + COLLATION(перем1) AS c1, + COLLATION(парам1) AS c2, + COLLATION(парам2) AS c3; + + SELECT + COLLATION('текст') AS c4, + COLLATION(_utf8 'текст') AS c5, + COLLATION(_koi8r '') AS c6, + @@collation_connection AS c7, + @@character_set_client AS c8; + + SET парам1 = 'a'; + SET парам2 = 'b'; +END| + +# +# First-round checks. +# + +--source include/ddl_i18n.check_sp.inc + +# +# Change running environment (alter database character set, change session +# variables). +# + +--echo +--echo + +ALTER DATABASE mysqltest1 COLLATE cp866_general_ci| +ALTER DATABASE mysqltest2 COLLATE cp866_general_ci| + +# +# Second-round checks: +# + +# - Change connection to flush SP-cache; + +--connect (con2,localhost,root,,mysqltest1) +--echo +--echo ---> connection: con2 + +# - Switch environment variables and trigger loading stored procedures; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +CALL p1(@a, @b)| +CALL p2(@a, @b)| +CALL mysqltest2.p3(@a, @b)| +CALL mysqltest2.p4(@a, @b)| + +# - Restore environment; + +set names utf8| + +# - Check! + +--source include/ddl_i18n.check_sp.inc + +# +# Check mysqldump. +# + +# - Dump mysqltest1, mysqltest2; + +--let $sp_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest1.sql +--let $sp_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest2.sql + +--echo +--echo ---> Dump of mysqltest1 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 + +--echo +--echo ---> Dumping mysqltest1 to ddl_i18n_utf8sp.mysqltest1.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $sp_dump1 + +--echo +--echo ---> Dump of mysqltest2 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 + +--echo +--echo ---> Dumping mysqltest2 to ddl_i18n_utf8sp.mysqltest2.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $sp_dump2 + +# - Clean mysqltest1, mysqltest2; + +--echo +--echo + +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| + +# - Restore mysqltest1; + +--echo +--echo + +--echo ---> Restoring mysqltest1... +--exec $MYSQL test < $sp_dump1 + +--echo ---> Restoring mysqltest2... +--exec $MYSQL test < $sp_dump2 + +--remove_file $sp_dump1 +--remove_file $sp_dump2 + +# +# Third-round checks. +# + +# - Change connection to flush SP-cache; + +--connect (con3,localhost,root,,mysqltest1) +--echo +--echo ---> connection: con3 + +# - Switch environment variables and trigger loading stored procedures; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +CALL p1(@a, @b)| +CALL p2(@a, @b)| +CALL mysqltest2.p3(@a, @b)| +CALL mysqltest2.p4(@a, @b)| + +# - Restore environment; + +set names utf8| + +# - Check! + +--source include/ddl_i18n.check_sp.inc + +# +# Cleanup. +# + +--connection default +--echo +--echo ---> connection: default + +--disconnect con2 +--disconnect con3 + +use test| + +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| + +########################################################################### +# +# * Triggers. +# +########################################################################### + +--echo +--echo ------------------------------------------------------------------- +--echo Triggers +--echo ------------------------------------------------------------------- +--echo + +# +# Preparation: +# + +# - Create database with fixed, pre-defined character set; + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +--enable_warnings + +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| +CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| + +use mysqltest1| + +# - Create tables for triggers; + +CREATE TABLE t1(c INT)| +CREATE TABLE mysqltest2.t1(c INT)| + +# - Create log tables; + +CREATE TABLE log(msg VARCHAR(255))| +CREATE TABLE mysqltest2.log(msg VARCHAR(255))| + + +# - Create triggers -- with and without explicit CHARSET-clause for +# SP-variable; +# + +--echo + +# - Trigger trg1 + +CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW +BEGIN + DECLARE перем1 CHAR(10); + + INSERT INTO log VALUES(COLLATION(перем1)); + INSERT INTO log VALUES(COLLATION('текст')); + INSERT INTO log VALUES(COLLATION(_utf8 'текст')); + INSERT INTO log VALUES(COLLATION(_koi8r '')); + INSERT INTO log VALUES(@@collation_connection); + INSERT INTO log VALUES(@@character_set_client); + + SET @a1 = 'текст'; + SET @a2 = _utf8 'текст'; + SET @a3 = _koi8r ''; +END| + +--echo + +# - Trigger trg2 + +CREATE TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW +BEGIN + DECLARE перем1 CHAR(10) CHARACTER SET utf8; + + INSERT INTO log VALUES(COLLATION(перем1)); + INSERT INTO log VALUES(COLLATION('текст')); + INSERT INTO log VALUES(COLLATION(_utf8 'текст')); + INSERT INTO log VALUES(COLLATION(_koi8r '')); + INSERT INTO log VALUES(@@collation_connection); + INSERT INTO log VALUES(@@character_set_client); + + SET @b1 = 'текст'; + SET @b2 = _utf8 'текст'; + SET @b3 = _koi8r ''; +END| + +--echo + +# - Trigger trg3 + +CREATE TRIGGER mysqltest2.trg3 BEFORE INSERT ON mysqltest2.t1 FOR EACH ROW +BEGIN + DECLARE перем1 CHAR(10); + + INSERT INTO log VALUES(COLLATION(перем1)); + INSERT INTO log VALUES(COLLATION('текст')); + INSERT INTO log VALUES(COLLATION(_utf8 'текст')); + INSERT INTO log VALUES(COLLATION(_koi8r '')); + INSERT INTO log VALUES(@@collation_connection); + INSERT INTO log VALUES(@@character_set_client); + + SET @a1 = 'текст'; + SET @a2 = _utf8 'текст'; + SET @a3 = _koi8r ''; +END| + +--echo + +# - Trigger trg4 + +CREATE TRIGGER mysqltest2.trg4 AFTER INSERT ON mysqltest2.t1 FOR EACH ROW +BEGIN + DECLARE перем1 CHAR(10) CHARACTER SET utf8; + + INSERT INTO log VALUES(COLLATION(перем1)); + INSERT INTO log VALUES(COLLATION('текст')); + INSERT INTO log VALUES(COLLATION(_utf8 'текст')); + INSERT INTO log VALUES(COLLATION(_koi8r '')); + INSERT INTO log VALUES(@@collation_connection); + INSERT INTO log VALUES(@@character_set_client); + + SET @b1 = 'текст'; + SET @b2 = _utf8 'текст'; + SET @b3 = _koi8r ''; +END| + +--echo + +# +# First-round checks. +# + +--source include/ddl_i18n.check_triggers.inc + +# +# Change running environment (alter database character set, change session +# variables). +# + +--echo +--echo + +ALTER DATABASE mysqltest1 COLLATE cp866_general_ci| +ALTER DATABASE mysqltest2 COLLATE cp866_general_ci| + +# +# Second-round checks: +# + +# - Flush table cache; + +ALTER TABLE t1 ADD COLUMN fake INT| +ALTER TABLE t1 DROP COLUMN fake| + +ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT| +ALTER TABLE mysqltest2.t1 DROP COLUMN fake| + +# - Switch environment variables and initiate loading of triggers +# (connect using NULL database); + +--connect (con2,localhost,root,,) +--echo +--echo ---> connection: con2 + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +INSERT INTO mysqltest1.t1 VALUES(0)| +INSERT INTO mysqltest2.t1 VALUES(0)| + +DELETE FROM mysqltest1.log| +DELETE FROM mysqltest2.log| + +# - Restore environment; + +set names utf8| + +use mysqltest1| + +# - Check! + +--source include/ddl_i18n.check_triggers.inc + +# +# Check mysqldump. +# + +# - Dump mysqltest1, mysqltest2; + +--let $triggers_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest1.sql +--let $triggers_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest2.sql + +--echo +--echo ---> Dump of mysqltest1 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 + +--echo +--echo ---> Dumping mysqltest1 to ddl_i18n_utf8triggers.mysqltest1.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $triggers_dump1 + +--echo +--echo ---> Dump of mysqltest2 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 + +--echo +--echo ---> Dumping mysqltest2 to ddl_i18n_utf8triggers.mysqltest2.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $triggers_dump2 + +# - Clean mysqltest1, mysqltest2; + +--echo +--echo + +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| + +# - Restore mysqltest1; + +--echo +--echo + +--echo ---> Restoring mysqltest1... +--exec $MYSQL test < $triggers_dump1 + +--echo ---> Restoring mysqltest2... +--exec $MYSQL test < $triggers_dump2 + +--remove_file $triggers_dump1 +--remove_file $triggers_dump2 + +# +# Third-round checks. +# + +# - Flush table cache; + +ALTER TABLE mysqltest1.t1 ADD COLUMN fake INT| +ALTER TABLE mysqltest1.t1 DROP COLUMN fake| + +ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT| +ALTER TABLE mysqltest2.t1 DROP COLUMN fake| + +# - Switch environment variables and initiate loading of triggers +# (connect using NULL database); + +--connect (con3,localhost,root,,) +--echo +--echo ---> connection: con3 + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +INSERT INTO mysqltest1.t1 VALUES(0)| +INSERT INTO mysqltest2.t1 VALUES(0)| + +DELETE FROM mysqltest1.log| +DELETE FROM mysqltest2.log| + +# - Restore environment; + +set names utf8| + +use mysqltest1| + +# - Check! + +--source include/ddl_i18n.check_triggers.inc + +# +# Cleanup. +# + +--connection default +--echo +--echo ---> connection: default + +--disconnect con2 +--disconnect con3 + +use test| + +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| + +########################################################################### +# +# * Events +# +# We don't have EXECUTE EVENT so far, so this test is limited. It checks that +# event with non-latin1 symbols can be created, dumped, restored and SHOW +# statements work properly. +# +########################################################################### + +--echo +--echo ------------------------------------------------------------------- +--echo Events +--echo ------------------------------------------------------------------- +--echo + +# +# Preparation: +# + +# - Create database with fixed, pre-defined character set. + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +--enable_warnings + +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| +CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| + +use mysqltest1| + +# - Create two stored routines -- with and without explicit +# CHARSET-clause for SP-variable; +# + +--echo + +# - Event ev1 + +CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO +BEGIN + DECLARE перем1 CHAR(10); + + SELECT + COLLATION(перем1) AS c1, + COLLATION('текст') AS c2, + COLLATION(_utf8 'текст') AS c3, + COLLATION(_koi8r '') AS c4, + @@collation_connection AS c5, + @@character_set_client AS c6; +END| + +--echo + +# - Event ev2 + +CREATE EVENT ev2 ON SCHEDULE AT '2030-01-01 00:00:00' DO +BEGIN + DECLARE перем1 CHAR(10) CHARACTER SET utf8; + + SELECT + COLLATION(перем1) AS c1, + COLLATION('текст') AS c2, + COLLATION(_utf8 'текст') AS c3, + COLLATION(_koi8r '') AS c4, + @@collation_connection AS c5, + @@character_set_client AS c6; +END| + +--echo + +# - Event ev3 + +CREATE EVENT mysqltest2.ev3 ON SCHEDULE AT '2030-01-01 00:00:00' DO +BEGIN + DECLARE перем1 CHAR(10) CHARACTER SET utf8; + + SELECT + COLLATION(перем1) AS c1, + COLLATION('текст') AS c2, + COLLATION(_utf8 'текст') AS c3, + COLLATION(_koi8r '') AS c4, + @@collation_connection AS c5, + @@character_set_client AS c6; +END| + +--echo + +# - Event ev4 + +CREATE EVENT mysqltest2.ev4 ON SCHEDULE AT '2030-01-01 00:00:00' DO +BEGIN + DECLARE перем1 CHAR(10) CHARACTER SET utf8; + + SELECT + COLLATION(перем1) AS c1, + COLLATION('текст') AS c2, + COLLATION(_utf8 'текст') AS c3, + COLLATION(_koi8r '') AS c4, + @@collation_connection AS c5, + @@character_set_client AS c6; +END| + +--echo + + +# +# First-round checks. +# + +--source include/ddl_i18n.check_events.inc + +# +# Change running environment (alter database character set, change session +# variables). +# + +--echo +--echo + +ALTER DATABASE mysqltest1 COLLATE cp866_general_ci| +ALTER DATABASE mysqltest2 COLLATE cp866_general_ci| + +# +# Second-round checks: +# + +# - Change connection to flush cache; + +--connect (con2,localhost,root,,mysqltest1) +--echo +--echo ---> connection: con2 + +# - Switch environment variables and trigger loading stored procedures; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +--disable_result_log +SHOW CREATE EVENT ev1| +SHOW CREATE EVENT ev2| +SHOW CREATE EVENT mysqltest2.ev3| +SHOW CREATE EVENT mysqltest2.ev4| +--enable_result_log + +# - Restore environment; + +set names utf8| + +# - Check! + +--source include/ddl_i18n.check_events.inc + +# +# Check mysqldump. +# + +# - Dump mysqltest1, mysqltest2; + +--let $events_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest1.sql +--let $events_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest2.sql + +--echo +--echo ---> Dump of mysqltest1 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 + +--echo +--echo ---> Dumping mysqltest1 to ddl_i18n_utf8events.mysqltest1.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $events_dump1 + +--echo +--echo ---> Dump of mysqltest2 + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 + +--echo +--echo ---> Dumping mysqltest2 to ddl_i18n_utf8events.mysqltest2.sql + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $events_dump2 + +# - Clean mysqltest1, mysqltest2; + +--echo +--echo + +DROP DATABASE mysqltest1| +DROP DATABASE mysqltest2| + +# - Restore mysqltest1; + +--echo +--echo + +--echo ---> Restoring mysqltest1... +--exec $MYSQL test < $events_dump1 + +--echo ---> Restoring mysqltest2... +--exec $MYSQL test < $events_dump2 + +--remove_file $events_dump1 +--remove_file $events_dump2 + +# +# Third-round checks. +# + +# - Change connection to flush cache; + +--connect (con3,localhost,root,,mysqltest1) +--echo +--echo ---> connection: con3 + +# - Switch environment variables and trigger loading stored procedures; + +SET @@character_set_client= cp1251| +SET @@character_set_results= cp1251| +SET @@collation_connection= cp1251_general_ci| + +--disable_result_log +SHOW CREATE EVENT ev1| +SHOW CREATE EVENT ev2| +SHOW CREATE EVENT mysqltest2.ev3| +SHOW CREATE EVENT mysqltest2.ev4| +--enable_result_log + +# - Restore environment; + +set names utf8| + +# - Check! + +--source include/ddl_i18n.check_events.inc + +########################################################################### +# +# * DDL statements inside stored routine. +# +# Here we check that DDL statements use actual database collation even if they +# are called from stored routine. +# +########################################################################### + +--echo +--echo ------------------------------------------------------------------- +--echo DDL statements within stored routine. +--echo ------------------------------------------------------------------- +--echo + +# +# Preparation: +# + +# - Create database with fixed, pre-defined character set. + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1| +DROP DATABASE IF EXISTS mysqltest2| +--enable_warnings + +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| +CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci| + +use mysqltest1| + +# - Create procedures; + +--echo + +CREATE PROCEDURE p1() +BEGIN + CREATE TABLE t1(col1 VARCHAR(10)); + SHOW CREATE TABLE t1; +END| + +--echo + +CREATE PROCEDURE mysqltest2.p2() +BEGIN + CREATE TABLE t2(col1 VARCHAR(10)); + SHOW CREATE TABLE t2; +END| + +--echo + +# +# First-round checks. +# + +CALL p1()| + +--echo + +SHOW CREATE TABLE t1| + +--echo +--echo + +CALL mysqltest2.p2()| + +--echo + +SHOW CREATE TABLE mysqltest2.t2| + +# +# Alter database. +# + +--echo + +ALTER DATABASE mysqltest1 COLLATE cp1251_general_cs| +ALTER DATABASE mysqltest2 COLLATE cp1251_general_cs| + +DROP TABLE t1| +DROP TABLE mysqltest2.t2| + +--echo + +# +# Second-round checks. +# + +CALL p1()| + +--echo + +SHOW CREATE TABLE t1| + +--echo +--echo + +CALL mysqltest2.p2()| + +--echo + +SHOW CREATE TABLE mysqltest2.t2| + +########################################################################### +# +# That's it. +# +########################################################################### + +# +# Cleanup. +# +delimiter ;| + +--connection con2 +--echo +--echo ---> connection: con2 +--disconnect con2 +--source include/wait_until_disconnected.inc +--connection con3 +--echo +--echo ---> connection: con3 +--disconnect con3 +--source include/wait_until_disconnected.inc +--connection default +--echo +--echo ---> connection: default +USE test; +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; + diff --git a/mysql-test/t/deadlock_innodb.test b/mysql-test/t/deadlock_innodb.test new file mode 100644 index 00000000000..08e3e256790 --- /dev/null +++ b/mysql-test/t/deadlock_innodb.test @@ -0,0 +1,16 @@ +# t/deadlock_innodb.test +# +# +# Last update: +# 2006-07-26 ML test refactored (MySQL 5.1) +# main code --> include/deadlock.inc +# new wrapper t/deadlock_innodb.test +# + +# Can't test this with embedded server +-- source include/not_embedded.inc + +--source include/have_innodb.inc +let $engine_type= InnoDB; + +--source include/deadlock.inc diff --git a/mysql-test/t/debug_sync.test b/mysql-test/t/debug_sync.test new file mode 100644 index 00000000000..514e471b603 --- /dev/null +++ b/mysql-test/t/debug_sync.test @@ -0,0 +1,420 @@ +###################### t/debug_sync.test ############################### +# # +# Testing of the Debug Sync Facility. # +# # +# There is important documentation within sql/debug_sync.cc # +# # +# Used objects in this test case: # +# p0 - synchronization point 0. Non-existent dummy sync point. # +# s1 - signal 1. # +# s2 - signal 2. # +# # +# Creation: # +# 2008-02-18 istruewing # +# # +######################################################################## + +# +# We need the Debug Sync Facility. +# +--source include/have_debug_sync.inc + +# +# We are checking privileges, which the embedded server cannot do. +# +--source include/not_embedded.inc + +# +# Preparative cleanup. +# +--disable_warnings +SET DEBUG_SYNC= 'RESET'; +DROP TABLE IF EXISTS t1; +--enable_warnings + +# +# Show the special system variable. +# It shows ON or OFF depending on the command line option --debug-sync. +# The test case assumes it is ON (command line option present). +# +SHOW VARIABLES LIKE 'DEBUG_SYNC'; + +# +# Syntax. Valid forms. +# +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3'; +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2'; +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 HIT_LIMIT 3'; +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6'; +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 EXECUTE 2 HIT_LIMIT 3'; +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 EXECUTE 2'; +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 HIT_LIMIT 3'; +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2'; +SET DEBUG_SYNC='p0 SIGNAL s1 EXECUTE 2 HIT_LIMIT 3'; +SET DEBUG_SYNC='p0 SIGNAL s1 EXECUTE 2'; +SET DEBUG_SYNC='p0 SIGNAL s1 HIT_LIMIT 3'; +SET DEBUG_SYNC='p0 SIGNAL s1'; +SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3'; +SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2'; +SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 HIT_LIMIT 3'; +SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6'; +SET DEBUG_SYNC='p0 WAIT_FOR s2 EXECUTE 2 HIT_LIMIT 3'; +SET DEBUG_SYNC='p0 WAIT_FOR s2 EXECUTE 2'; +SET DEBUG_SYNC='p0 WAIT_FOR s2 HIT_LIMIT 3'; +SET DEBUG_SYNC='p0 WAIT_FOR s2'; +SET DEBUG_SYNC='p0 HIT_LIMIT 3'; +SET DEBUG_SYNC='p0 CLEAR'; +SET DEBUG_SYNC='p0 TEST'; +SET DEBUG_SYNC='RESET'; + +# +# Syntax. Valid forms. Lower case. +# +set debug_sync='p0 signal s1 wait_for s2 timeout 6 execute 2 hit_limit 3'; +set debug_sync='p0 signal s1 wait_for s2 timeout 6 execute 2'; +set debug_sync='p0 signal s1 wait_for s2 timeout 6 hit_limit 3'; +set debug_sync='p0 signal s1 wait_for s2 timeout 6'; +set debug_sync='p0 signal s1 wait_for s2 execute 2 hit_limit 3'; +set debug_sync='p0 signal s1 wait_for s2 execute 2'; +set debug_sync='p0 signal s1 wait_for s2 hit_limit 3'; +set debug_sync='p0 signal s1 wait_for s2'; +set debug_sync='p0 signal s1 execute 2 hit_limit 3'; +set debug_sync='p0 signal s1 execute 2'; +set debug_sync='p0 signal s1 hit_limit 3'; +set debug_sync='p0 signal s1'; +set debug_sync='p0 wait_for s2 timeout 6 execute 2 hit_limit 3'; +set debug_sync='p0 wait_for s2 timeout 6 execute 2'; +set debug_sync='p0 wait_for s2 timeout 6 hit_limit 3'; +set debug_sync='p0 wait_for s2 timeout 6'; +set debug_sync='p0 wait_for s2 execute 2 hit_limit 3'; +set debug_sync='p0 wait_for s2 execute 2'; +set debug_sync='p0 wait_for s2 hit_limit 3'; +set debug_sync='p0 wait_for s2'; +set debug_sync='p0 hit_limit 3'; +set debug_sync='p0 clear'; +set debug_sync='p0 test'; +set debug_sync='reset'; + +# +# Syntax. Valid forms. Line wrap, leading, mid, trailing space. +# +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 + EXECUTE 2 HIT_LIMIT 3'; +SET DEBUG_SYNC=' p0 SIGNAL s1 WAIT_FOR s2'; +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2'; +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 '; +SET DEBUG_SYNC=' p0 SIGNAL s1 WAIT_FOR s2 '; +SET DEBUG_SYNC=' p0 SIGNAL s1 WAIT_FOR s2 '; + +# +# Syntax. Invalid forms. +# +--error ER_PARSE_ERROR +SET DEBUG_SYNC=''; +--error ER_PARSE_ERROR +SET DEBUG_SYNC=' '; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 EXECUTE 2'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 TIMEOUT 6 EXECUTE 2'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 TIMEOUT 6'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1 EXECUTE 2'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1 TIMEOUT 6 EXECUTE 2'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1 TIMEOUT 6'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 SIGNAL s1 EXECUTE 2'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 SIGNAL s1'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 TIMEOUT 6 WAIT_FOR s2 EXECUTE 2'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 TIMEOUT 6 WAIT_FOR s2'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 SIGNAL s1 TIMEOUT 6 EXECUTE 2'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 SIGNAL s1 TIMEOUT 6'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 EXECUTE 2 SIGNAL s1 TIMEOUT 6'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 TIMEOUT 6 SIGNAL s1'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 EXECUTE 2 TIMEOUT 6 SIGNAL s1'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 CLEAR HIT_LIMIT 3'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='CLEAR'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 CLEAR p0'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='TEST'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 TEST p0'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 RESET'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='RESET p0'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 RESET p0'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 SIGNAL '; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 WAIT_FOR '; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 SIGNAL s1 EXECUTE '; + +# +# Syntax. Invalid keywords used. +# +--error ER_UNKNOWN_SYSTEM_VARIABLE +SET DEBUG_SYNCx='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 SIGNAx s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOx s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUx 0 EXECUTE 2 HIT_LIMIT 3'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTx 2 HIT_LIMIT 3'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIx 3'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 CLEARx'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 TESTx'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='RESETx'; + +# +# Syntax. Invalid numbers. Decimal only. +# +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 0x6 EXECUTE 2 HIT_LIMIT 3'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 EXECUTE 0x2 HIT_LIMIT 3'; +--error ER_PARSE_ERROR +SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 7 EXECUTE 2 HIT_LIMIT 0x3'; + +# +# Syntax. Invalid value type. +# +--error ER_WRONG_TYPE_FOR_VAR +SET DEBUG_SYNC= 7; + +# +# Syntax. DEBUG_SYNC is a SESSION-only variable. +# +--error ER_LOCAL_VARIABLE +SET GLOBAL DEBUG_SYNC= 'p0 CLEAR'; + +# +# Syntax. The variable value does not need to be a string literal. +# +SET @myvar= 'now SIGNAL from_myvar'; +SET DEBUG_SYNC= @myvar; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +# +SET DEBUG_SYNC= LEFT('now SIGNAL from_function_cut_here', 24); +SHOW VARIABLES LIKE 'DEBUG_SYNC'; + +# +# Functional tests. +# +# NOTE: There is the special synchronization point 'now'. It is placed +# immediately after setting of the DEBUG_SYNC variable. +# So it is executed before the SET statement ends. +# +# NOTE: There is only one global signal (say "signal post" or "flag mast"). +# A SIGNAL action writes its signal into it ("sets a flag"). +# The signal persists until explicitly overwritten. +# To avoid confusion for later tests, it is recommended to clear +# the signal by signalling "empty" ("setting the 'empty' flag"): +# SET DEBUG_SYNC= 'now SIGNAL empty'; +# Preferably you can reset the whole facility with: +# SET DEBUG_SYNC= 'RESET'; +# The signal is then '' (really empty) which connot be done otherwise. +# + +# +# Time out immediately. This gives just a warning. +# +SET DEBUG_SYNC= 'now SIGNAL something'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +# Suppress warning number +--replace_column 2 #### +SET DEBUG_SYNC= 'now WAIT_FOR nothing TIMEOUT 0'; +# +# If signal is present already, TIMEOUT 0 does not give a warning. +# +SET DEBUG_SYNC= 'now SIGNAL nothing'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'now WAIT_FOR nothing TIMEOUT 0'; + +# +# EXECUTE 0 is effectively a no-op. +# +SET DEBUG_SYNC= 'now SIGNAL something EXECUTE 0'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'now WAIT_FOR anotherthing TIMEOUT 0 EXECUTE 0'; + +# +# Run into HIT_LIMIT. This gives an error. +# +--error ER_DEBUG_SYNC_HIT_LIMIT +SET DEBUG_SYNC= 'now HIT_LIMIT 1'; + +# +# Many actions. Watch the array growing and shrinking in the debug trace: +# egrep 'query:|debug_sync_action:' mysql-test/var/log/master.trace +# +SET DEBUG_SYNC= 'RESET'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'p1abcd SIGNAL s1 EXECUTE 2'; +SET DEBUG_SYNC= 'p2abc SIGNAL s2 EXECUTE 2'; +SET DEBUG_SYNC= 'p9abcdef SIGNAL s9 EXECUTE 2'; +SET DEBUG_SYNC= 'p4a SIGNAL s4 EXECUTE 2'; +SET DEBUG_SYNC= 'p5abcde SIGNAL s5 EXECUTE 2'; +SET DEBUG_SYNC= 'p6ab SIGNAL s6 EXECUTE 2'; +SET DEBUG_SYNC= 'p7 SIGNAL s7 EXECUTE 2'; +SET DEBUG_SYNC= 'p8abcdef SIGNAL s8 EXECUTE 2'; +SET DEBUG_SYNC= 'p3abcdef SIGNAL s3 EXECUTE 2'; +# +# Execute some actions to show they exist. Each sets a distinct signal. +# +SET DEBUG_SYNC= 'p4a TEST'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'p1abcd TEST'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'p7 TEST'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'p9abcdef TEST'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'p3abcdef TEST'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +# +# Clear the actions. +# +SET DEBUG_SYNC= 'p1abcd CLEAR'; +SET DEBUG_SYNC= 'p2abc CLEAR'; +SET DEBUG_SYNC= 'p5abcde CLEAR'; +SET DEBUG_SYNC= 'p6ab CLEAR'; +SET DEBUG_SYNC= 'p8abcdef CLEAR'; +SET DEBUG_SYNC= 'p9abcdef CLEAR'; +SET DEBUG_SYNC= 'p3abcdef CLEAR'; +SET DEBUG_SYNC= 'p4a CLEAR'; +SET DEBUG_SYNC= 'p7 CLEAR'; +# +# Execute some actions to show they have gone. +# +SET DEBUG_SYNC= 'p1abcd TEST'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'p7 TEST'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'p9abcdef TEST'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +# +# Now cleanup. Actions are clear already, but signal needs to be cleared. +# +SET DEBUG_SYNC= 'RESET'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; + +# +# Facility requires SUPER privilege. +# +CREATE USER mysqltest_1@localhost; +GRANT SUPER ON *.* TO mysqltest_1@localhost; +--echo connection con1, mysqltest_1 +connect (con1,localhost,mysqltest_1,,); +SET DEBUG_SYNC= 'RESET'; +disconnect con1; +--echo connection default +connection default; +DROP USER mysqltest_1@localhost; +# +CREATE USER mysqltest_2@localhost; +GRANT ALL ON *.* TO mysqltest_2@localhost; +REVOKE SUPER ON *.* FROM mysqltest_2@localhost; +--echo connection con1, mysqltest_2 +connect (con1,localhost,mysqltest_2,,); +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +SET DEBUG_SYNC= 'RESET'; +disconnect con1; +--echo connection default +connection default; +DROP USER mysqltest_2@localhost; + +# +# Example 1. +# +# Preparative cleanup. +--disable_warnings +SET DEBUG_SYNC= 'RESET'; +DROP TABLE IF EXISTS t1; +--enable_warnings +# +# Test. +CREATE TABLE t1 (c1 INT); + --echo connection con1 + connect (con1,localhost,root,,); + SET DEBUG_SYNC= 'before_lock_tables_takes_lock + SIGNAL opened WAIT_FOR flushed'; + send INSERT INTO t1 VALUES(1); +--echo connection default +connection default; +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +SET DEBUG_SYNC= 'after_flush_unlock SIGNAL flushed'; +FLUSH TABLE t1; + --echo connection con1 + connection con1; + reap; + disconnect con1; +--echo connection default +connection default; +DROP TABLE t1; + +# +# Example 2. +# +# Preparative cleanup. +--disable_warnings +SET DEBUG_SYNC= 'RESET'; +DROP TABLE IF EXISTS t1; +--enable_warnings +# +# Test. +CREATE TABLE t1 (c1 INT); +LOCK TABLE t1 WRITE; + --echo connection con1 + connect (con1,localhost,root,,); + # Retain action after use. First used by general_log. + SET DEBUG_SYNC= 'wait_for_lock SIGNAL locked EXECUTE 2'; + send INSERT INTO t1 VALUES (1); +--echo connection default +connection default; +# Wait until INSERT waits for lock. +SET DEBUG_SYNC= 'now WAIT_FOR locked'; +# let INSERT continue. +UNLOCK TABLES; + --echo connection con1 + connection con1; + --echo retrieve INSERT result. + reap; + disconnect con1; +--echo connection default +connection default; +DROP TABLE t1; + +# +# Cleanup after test case. +# Otherwise signal would contain 'flushed' here, +# which could confuse the next test. +# +SET DEBUG_SYNC= 'RESET'; + diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index db01aade3ca..94ad22b80d0 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -184,7 +184,7 @@ INSERT INTO t1 VALUES( 49, 71), (NULL, 72), (NULL, 73); INSERT INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83); # Create a duplicate value. SET insert_id= 114; ---error 1062 +--error ER_DUP_ENTRY INSERT INTO t1 VALUES(NULL, 91); INSERT INTO t1 VALUES (NULL, 92), (NULL, 93); # Check what we have now @@ -244,15 +244,6 @@ SELECT HEX(a) FROM t1; DROP TABLE t1; # -# Bug#26464 - insert delayed + update + merge = corruption -# -CREATE TABLE t1(c1 INT) ENGINE=MyISAM; -CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1); ---error 1031 -INSERT DELAYED INTO t2 VALUES(1); -DROP TABLE t1, t2; - -# # Bug #32676: insert delayed crash with wrong column and function specified # CREATE TABLE t1 (a INT); @@ -261,3 +252,80 @@ INSERT DELAYED INTO t1 SET b= b(); DROP TABLE t1; --echo End of 5.0 tests + +# +# Bug#27358 INSERT DELAYED does not honour SQL_MODE of the client +# +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings +SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; +CREATE TABLE `t1` ( + `id` int(11) PRIMARY KEY auto_increment, + `f1` varchar(10) NOT NULL UNIQUE +); +INSERT DELAYED INTO t1 VALUES(0,"test1"); +sleep 1; +SELECT * FROM t1; +SET SQL_MODE='PIPES_AS_CONCAT'; +INSERT DELAYED INTO t1 VALUES(0,'a' || 'b'); +sleep 1; +SELECT * FROM t1; +SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,STRICT_ALL_TABLES'; +--error 1365 +INSERT DELAYED INTO t1 VALUES(mod(1,0),"test3"); +CREATE TABLE t2 ( + `id` int(11) PRIMARY KEY auto_increment, + `f1` date +); +SET SQL_MODE='NO_ZERO_DATE,STRICT_ALL_TABLES,NO_ZERO_IN_DATE'; +--error ER_TRUNCATED_WRONG_VALUE +INSERT DELAYED INTO t2 VALUES (0,'0000-00-00'); +--error ER_TRUNCATED_WRONG_VALUE +INSERT DELAYED INTO t2 VALUES (0,'2007-00-00'); +DROP TABLE t1,t2; + +# +# Bug#40536: SELECT is blocked by INSERT DELAYED waiting on upgrading lock, +# even with low_priority_updates +# + +set @old_delayed_updates = @@global.low_priority_updates; +set global low_priority_updates = 1; +select @@global.low_priority_updates; + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int, b int); +insert into t1 values (1,1); +lock table t1 read; +connect (update,localhost,root,,); +connection update; +--echo connection: update +--send insert delayed into t1 values (2,2); +connection default; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where command = "Delayed insert" and state = "upgrading lock"; +--source include/wait_condition.inc +connect (select,localhost,root,,); +--echo connection: select +select * from t1; +connection default; +--echo connection: default +select * from t1; +connection default; +disconnect update; +disconnect select; +unlock tables; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where command = "Delayed insert" and state = "Waiting for INSERT"; +--source include/wait_condition.inc +select * from t1; +drop table t1; + +set global low_priority_updates = @old_delayed_updates; + +--echo End of 5.1 tests diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index ec70587c9d1..d77f5eb128b 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -235,6 +235,50 @@ DELETE FROM t1 ORDER BY (SELECT x); DROP TABLE t1; # +# Bug #30234: Unexpected behavior using DELETE with AS and USING +# ' +CREATE TABLE t1 ( + a INT +); + +CREATE TABLE t2 ( + a INT +); + +CREATE DATABASE db1; +CREATE TABLE db1.t1 ( + a INT +); +INSERT INTO db1.t1 (a) SELECT * FROM t1; + +CREATE DATABASE db2; +CREATE TABLE db2.t1 ( + a INT +); +INSERT INTO db2.t1 (a) SELECT * FROM t2; + +--error ER_PARSE_ERROR +DELETE FROM t1 alias USING t1, t2 alias WHERE t1.a = alias.a; +DELETE FROM alias USING t1, t2 alias WHERE t1.a = alias.a; +DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a; +--error ER_UNKNOWN_TABLE +DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a; +--error ER_PARSE_ERROR +DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a; +--error ER_UNKNOWN_TABLE +DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a; +DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a; +DELETE FROM t1 USING t1 WHERE a = 1; +SELECT * FROM t1; +--error ER_PARSE_ERROR +DELETE FROM t1 alias USING t1 alias WHERE a = 2; +SELECT * FROM t1; + +DROP TABLE t1, t2; +DROP DATABASE db1; +DROP DATABASE db2; + +# # Bug 31742: delete from ... order by function call that causes an error, # asserts server # @@ -248,3 +292,47 @@ DROP TABLE t1; DROP FUNCTION f1; --echo End of 5.0 tests + +--echo # +--echo # Bug#46958: Assertion in Diagnostics_area::set_ok_status, trigger, +--echo # merge table +--echo # +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( a INT ); +CREATE TABLE t3 ( a INT ); + +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); + +CREATE TRIGGER tr1 BEFORE DELETE ON t2 +FOR EACH ROW INSERT INTO no_such_table VALUES (1); + +--error ER_NO_SUCH_TABLE +DELETE t1, t2, t3 FROM t1, t2, t3; + +SELECT * FROM t1; +SELECT * FROM t2; +SELECT * FROM t3; + +DROP TABLE t1, t2, t3; + +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( a INT ); +CREATE TABLE t3 ( a INT ); + +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); +INSERT INTO t3 VALUES (1), (2); + +CREATE TRIGGER tr1 AFTER DELETE ON t2 +FOR EACH ROW INSERT INTO no_such_table VALUES (1); + +--error ER_NO_SUCH_TABLE +DELETE t1, t2, t3 FROM t1, t2, t3; + +SELECT * FROM t1; +SELECT * FROM t2; +SELECT * FROM t3; + +DROP TABLE t1, t2, t3; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 4e79fac584f..d28c19bbd18 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -273,8 +273,32 @@ select t2.* from ((select * from t1) as A inner join t2 on A.ID = t2.FID); select t2.* from (select * from t1) as A inner join t2 on A.ID = t2.FID; drop table t1, t2; +connection con1; disconnect con1; +--source include/wait_until_disconnected.inc connection default; drop user mysqltest_1; -# End of 4.1 tests +--echo # End of 4.1 tests + +# +# Bug #41156: List of derived tables acts like a chain of +# mutually-nested subqueries +# + +SELECT 0 FROM +(SELECT 0) t01, (SELECT 0) t02, (SELECT 0) t03, (SELECT 0) t04, (SELECT 0) t05, +(SELECT 0) t06, (SELECT 0) t07, (SELECT 0) t08, (SELECT 0) t09, (SELECT 0) t10, +(SELECT 0) t11, (SELECT 0) t12, (SELECT 0) t13, (SELECT 0) t14, (SELECT 0) t15, +(SELECT 0) t16, (SELECT 0) t17, (SELECT 0) t18, (SELECT 0) t19, (SELECT 0) t20, +(SELECT 0) t21, (SELECT 0) t22, (SELECT 0) t23, (SELECT 0) t24, (SELECT 0) t25, +(SELECT 0) t26, (SELECT 0) t27, (SELECT 0) t28, (SELECT 0) t29, (SELECT 0) t30, +(SELECT 0) t31, (SELECT 0) t32, (SELECT 0) t33, (SELECT 0) t34, (SELECT 0) t35, +(SELECT 0) t36, (SELECT 0) t37, (SELECT 0) t38, (SELECT 0) t39, (SELECT 0) t40, +(SELECT 0) t41, (SELECT 0) t42, (SELECT 0) t43, (SELECT 0) t44, (SELECT 0) t45, +(SELECT 0) t46, (SELECT 0) t47, (SELECT 0) t48, (SELECT 0) t49, (SELECT 0) t50, +(SELECT 0) t51, (SELECT 0) t52, (SELECT 0) t53, (SELECT 0) t54, (SELECT 0) t55, +(SELECT 0) t56, (SELECT 0) t57, (SELECT 0) t58, (SELECT 0) t59, (SELECT 0) t60, +(SELECT 0) t61; # 61 == MAX_TABLES + +--echo # End of 5.0 tests diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 062667c249e..6f0b1716d38 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -1,27 +1,16 @@ ############################################################################## # -# List the test cases that are to be disabled temporarely. +# List the test cases that are to be disabled temporarily. # # Separate the test case name and the comment with ':'. # -# <testcasename> : Comment test +# <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment> # -# Don't use any TAB characters for whitespace. +# Do not use any TAB characters for whitespace. # ############################################################################## - -user_limits : Bug#23921 random failure of user_limits.test -im_life_cycle : Bug#27851: Instance manager test im_life_cycle fails randomly -im_daemon_life_cycle : Bug#20294: Instance manager tests fail randomly -im_options_set : Bug#20294: Instance manager tests fail randomly -im_options_unset : Bug#20294: Instance manager tests fail randomly -im_utils : Bug#20294: Instance manager tests fail randomly -rpl_log_pos : Bug#8693 Test 'rpl_log_pos' fails sometimes -kill : Bug#29149 Test "kill" fails on Windows -ps_7ndb : Bug#38315 "Cluster Failure" in ps_7ndb -strict_autoinc_5ndb : Bug#35148 "Error '4009 Cluster Failure' in various tests on various platforms" -rpl_slave_skip : Bug#45521: rpl_slave_skip fails in pb2 -loaddata_autocom_ndb : Bug#35148: Error '4009 Cluster Failure' in various tests on various platforms -ndb_autodiscover3 : Bug#35148: Error '4009 Cluster Failure' in various tests on various platforms -ndb_autodiscover : Bug#45972: ndb.ndb_autodiscover fails occasionally with pb2 -ndb_autodiscover2 : Bug#45972: ndb.ndb_autodiscover fails occasionally with pb2 +kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild. +innodb_bug39438 : Bug#42383 2009-01-28 lsoares "This fails in embedded and on windows. Note that this test is not run on windows and on embedded in PB for main trees currently" +query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically +partition_innodb_builtin : Bug#32430 2009-09-25 mattiasj Waiting for push of Innodb changes +partition_innodb_plugin : Bug#32430 2009-09-25 mattiasj Waiting for push of Innodb changes diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index 2cbd34c0d2c..bf4c23562cf 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -97,7 +97,7 @@ explain SELECT t1.a from t1 group by a order by a desc; explain SELECT distinct t1.a from t1 order by a desc limit 1; explain SELECT distinct a from t3 order by a desc limit 2; explain SELECT distinct a,b from t3 order by a+1; -explain SELECT distinct a,b from t3 order by a limit 10; +explain SELECT distinct a,b from t3 order by a limit 2; explain SELECT a,b from t3 group by a,b order by a+1; drop table t1,t2,t3,t4; @@ -440,7 +440,6 @@ SELECT DISTINCT a,a FROM t1 WHERE b < 12 ORDER BY a; DROP TABLE t1; #Bug #20836: Selecting into variables results in wrong results being returned - --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings @@ -488,14 +487,14 @@ CREATE TABLE t2 (fruit_id INT NOT NULL, fruit_name varchar(20) default NULL); SELECT DISTINCT fruit_id, fruit_name INTO OUTFILE -'../tmp/data1.tmp' FROM t1 WHERE fruit_name = 'APPLE'; -LOAD DATA INFILE '../tmp/data1.tmp' INTO TABLE t2; +'../../tmp/data1.tmp' FROM t1 WHERE fruit_name = 'APPLE'; +LOAD DATA INFILE '../../tmp/data1.tmp' INTO TABLE t2; --error 0,1 --remove_file $MYSQLTEST_VARDIR/tmp/data1.tmp SELECT DISTINCT @v19:= fruit_id, @v20:= fruit_name INTO OUTFILE -'../tmp/data2.tmp' FROM t1 WHERE fruit_name = 'APPLE'; -LOAD DATA INFILE '../tmp/data2.tmp' INTO TABLE t2; +'../../tmp/data2.tmp' FROM t1 WHERE fruit_name = 'APPLE'; +LOAD DATA INFILE '../../tmp/data2.tmp' INTO TABLE t2; --remove_file $MYSQLTEST_VARDIR/tmp/data2.tmp SELECT @v19, @v20; @@ -552,3 +551,66 @@ SELECT DISTINCT a, a, b FROM t1; DROP TABLE t1; --echo End of 5.0 tests + +# +# Bug #34928: Confusion by having Primary Key and Index +# +CREATE TABLE t1(a INT, b INT, c INT, d INT, e INT, + PRIMARY KEY(a,b,c,d,e), + KEY(a,b,d,c) +); + +INSERT INTO t1(a, b, c) VALUES (1, 1, 1), + (1, 1, 2), + (1, 1, 3), + (1, 2, 1), + (1, 2, 2), + (1, 2, 3); + +EXPLAIN SELECT DISTINCT a, b, d, c FROM t1; + +SELECT DISTINCT a, b, d, c FROM t1; + +DROP TABLE t1; + +--echo # +--echo # Bug #46159: simple query that never returns +--echo # + +# Set max_heap_table_size to the minimum value so that GROUP BY table in the +# SELECT query below gets converted to MyISAM +SET @old_max_heap_table_size = @@max_heap_table_size; +SET @@max_heap_table_size = 16384; + +# Set sort_buffer_size to the mininum value so that remove_duplicates() calls +# remove_dup_with_compare() +SET @old_sort_buffer_size = @@sort_buffer_size; +SET @@sort_buffer_size = 32804; + +CREATE TABLE t1(c1 int, c2 VARCHAR(20)); +INSERT INTO t1 VALUES (1, '1'), (1, '1'), (2, '2'), (3, '1'), (3, '1'), (4, '4'); +# Now we just need to pad the table with random data so we have enough unique +# values to force conversion of the GROUP BY table to MyISAM +INSERT INTO t1 SELECT 5 + 10000 * RAND(), '5' FROM t1; +INSERT INTO t1 SELECT 5 + 10000 * RAND(), '5' FROM t1; +INSERT INTO t1 SELECT 5 + 10000 * RAND(), '5' FROM t1; +INSERT INTO t1 SELECT 5 + 10000 * RAND(), '5' FROM t1; +INSERT INTO t1 SELECT 5 + 10000 * RAND(), '5' FROM t1; +INSERT INTO t1 SELECT 5 + 10000 * RAND(), '5' FROM t1; +INSERT INTO t1 SELECT 5 + 10000 * RAND(), '5' FROM t1; +INSERT INTO t1 SELECT 5 + 10000 * RAND(), '5' FROM t1; + +# First rows of the GROUP BY table that will be processed by +# remove_dup_with_compare() +SELECT c1, c2, COUNT(*) FROM t1 GROUP BY c1 LIMIT 4; + +# The actual test case +SELECT DISTINCT c2 FROM t1 GROUP BY c1 HAVING COUNT(*) > 1; + +# Cleanup + +DROP TABLE t1; +SET @@sort_buffer_size = @old_sort_buffer_size; +SET @@max_heap_table_size = @old_max_heap_table_size; + +--echo End of 5.1 tests diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index a1451773e90..bb4dd3e11f9 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -117,8 +117,88 @@ connection addconroot1; --reap connection addconroot2; --reap -disconnect addconroot1; disconnect addconroot2; +--source include/wait_until_disconnected.inc +connection addconroot1; +disconnect addconroot1; +--source include/wait_until_disconnected.inc connection default; --echo End of 5.0 tests + +# +# Bug#30152 MySQLD crash duing alter table causes DROP DATABASE to FAIL due to temp file +# +create database mysql_test; +create table mysql_test.t1(f1 int); +create table mysql_test.`#sql-347f_7` (f1 int); +create table mysql_test.`#sql-347f_8` (f1 int); +drop table mysql_test.`#sql-347f_8`; +let $MYSQLD_DATADIR= `select @@datadir`; +copy_file $MYSQLD_DATADIR/mysql_test/t1.frm $MYSQLD_DATADIR/mysql_test/#sql-347f_6.frm; +drop database mysql_test; + +########################################################################### + +--echo +--echo # -- +--echo # -- Bug#29958: Weird message on DROP DATABASE if mysql.proc does not +--echo # -- exist. +--echo # -- + +--disable_warnings +DROP DATABASE IF EXISTS mysql_test; +--enable_warnings + +CREATE DATABASE mysql_test; + +let $MYSQLD_DATADIR= `select @@datadir`; + +--let $proc_frm = $MYSQLD_DATADIR/mysql/proc.frm +--let $proc_MYD = $MYSQLD_DATADIR/mysql/proc.MYD +--let $proc_MYI = $MYSQLD_DATADIR/mysql/proc.MYI + +--let $copy_of_proc_frm = $MYSQLTEST_VARDIR/tmp/bug29958.copy.frm +--let $copy_of_proc_MYD = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MYD +--let $copy_of_proc_MYI = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MYI + +--copy_file $proc_frm $copy_of_proc_frm +--copy_file $proc_MYD $copy_of_proc_MYD +--copy_file $proc_MYI $copy_of_proc_MYI + +DROP TABLE mysql.proc; + +DROP DATABASE mysql_test; + +--copy_file $copy_of_proc_frm $proc_frm +--copy_file $copy_of_proc_MYD $proc_MYD +--copy_file $copy_of_proc_MYI $proc_MYI + +--remove_file $copy_of_proc_frm +--remove_file $copy_of_proc_MYD +--remove_file $copy_of_proc_MYI + +--echo +--echo # -- +--echo # -- End of Bug#29958. +--echo # -- + +########################################################################### + +--echo +# +# Bug#26703: DROP DATABASE fails if database contains a #mysql50# table with backticks +# +create database mysqltestbug26703; +use mysqltestbug26703; +create table `#mysql50#abc``def` ( id int ); +--error ER_WRONG_TABLE_NAME +create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); +create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); +--error ER_WRONG_TABLE_NAME +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); +use test; +drop database mysqltestbug26703; + +--echo End of 5.1 tests diff --git a/mysql-test/t/drop_temp_table.test b/mysql-test/t/drop_temp_table.test deleted file mode 100644 index b456e75576b..00000000000 --- a/mysql-test/t/drop_temp_table.test +++ /dev/null @@ -1,30 +0,0 @@ --- source include/have_log_bin.inc - ---disable_warnings -drop database if exists `drop-temp+table-test`; ---enable_warnings - -connect (con1,localhost,root,,); -connect (con2,localhost,root,,); -connection con1; -reset master; -create database `drop-temp+table-test`; -use `drop-temp+table-test`; -create temporary table shortn1 (a int); -create temporary table `table:name` (a int); -create temporary table shortn2 (a int); -select get_lock("a",10); -disconnect con1; - -connection con2; -# We want to SHOW BINLOG EVENTS, to know what was logged. But there is no -# guarantee that logging of the terminated con1 has been done yet. -# To be sure that logging has been done, we use a user lock. -select get_lock("a",10); -let $VERSION=`select version()`; ---replace_result $VERSION VERSION ---replace_column 2 # 5 # -show binlog events; -drop database `drop-temp+table-test`; - -# End of 4.1 tests diff --git a/mysql-test/t/endspace.test b/mysql-test/t/endspace.test index c4d53450910..b223c683cde 100644 --- a/mysql-test/t/endspace.test +++ b/mysql-test/t/endspace.test @@ -16,7 +16,8 @@ drop table if exists t1; create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)); insert into t1 values ('teststring'), ('nothing'), ('teststring\t'); check table t1; -select * from t1 ignore key (key1) where text1='teststring' or text1 like 'teststring_%'; +select * from t1 ignore key (key1) where text1='teststring' or + text1 like 'teststring_%' ORDER BY text1; select * from t1 where text1='teststring' or text1 like 'teststring_%'; select * from t1 where text1='teststring' or text1 > 'teststring\t'; select * from t1 order by text1; @@ -24,7 +25,8 @@ explain select * from t1 order by text1; alter table t1 modify text1 char(32) binary not null; check table t1; -select * from t1 ignore key (key1) where text1='teststring' or text1 like 'teststring_%'; +select * from t1 ignore key (key1) where text1='teststring' or + text1 like 'teststring_%' ORDER BY text1; select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%'; select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t'; select text1, length(text1) from t1 order by text1; @@ -57,7 +59,8 @@ drop table t1; create table t1 (text1 varchar(32) not NULL, KEY key1 using BTREE (text1)) engine=heap; insert into t1 values ('teststring'), ('nothing'), ('teststring\t'); -select * from t1 ignore key (key1) where text1='teststring' or text1 like 'teststring_%'; +select * from t1 ignore key (key1) where text1='teststring' or + text1 like 'teststring_%' ORDER BY text1; select * from t1 where text1='teststring' or text1 like 'teststring_%'; select * from t1 where text1='teststring' or text1 >= 'teststring\t'; select * from t1 order by text1; diff --git a/mysql-test/t/error_simulation-master.opt b/mysql-test/t/error_simulation-master.opt deleted file mode 100644 index edb77cfa85e..00000000000 --- a/mysql-test/t/error_simulation-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-debug=d,raise_error diff --git a/mysql-test/t/error_simulation.test b/mysql-test/t/error_simulation.test index 8c044224b8a..f730c95208e 100644 --- a/mysql-test/t/error_simulation.test +++ b/mysql-test/t/error_simulation.test @@ -21,9 +21,15 @@ INSERT INTO t1 VALUES set tmp_table_size=1024; +# Set debug flag so an error is returned when +# tmp table in query is converted from heap to myisam +set session debug="d,raise_error"; + +--replace_regex /in table '[^']+'/in table 'tmp_table'/ --error ER_DUP_KEY SELECT MAX(a) FROM t1 GROUP BY a,b; set tmp_table_size=default; - DROP TABLE t1; + + diff --git a/mysql-test/t/events_1.test b/mysql-test/t/events_1.test new file mode 100644 index 00000000000..ccdeb70d291 --- /dev/null +++ b/mysql-test/t/events_1.test @@ -0,0 +1,419 @@ +# changes 2008-02-20 hhunger splitted events.test into events_1 and events_2 +# changes 2008-02-22 hhunger replaced all sleep by wait_condition +# +# Can't test with embedded server that doesn't support grants +-- source include/not_embedded.inc + +--disable_warnings +drop database if exists events_test; +drop database if exists db_x; +drop database if exists mysqltest_db2; +drop database if exists mysqltest_no_such_database; +--enable_warnings +create database events_test; +use events_test; + +# +# START: BUG #17289 Events: missing privilege check for drop database +# +CREATE USER pauline@localhost; +CREATE DATABASE db_x; +GRANT EVENT ON db_x.* TO pauline@localhost; +USE db_x; +CREATE TABLE x_table(a int); +connect (priv_conn,localhost,pauline,,db_x); +CREATE EVENT e_x1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE db_x; +CREATE EVENT e_x2 ON SCHEDULE EVERY 1 SECOND DO DROP TABLE x_table; +connection default; +SHOW DATABASES LIKE 'db_x'; +SET GLOBAL event_scheduler=1; +let $wait_condition= SELECT count(*)= 1 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME LIKE 'db_x'; +--source include/wait_condition.inc +SHOW DATABASES LIKE 'db_x'; +SHOW TABLES FROM db_x; +SET GLOBAL event_scheduler=off; +connection priv_conn; +DROP EVENT e_x1; +DROP EVENT e_x2; +disconnect priv_conn; +connection default; +DROP DATABASE db_x; +DROP USER pauline@localhost; +USE events_test; +# +# END: BUG #17289 Events: missing privilege check for drop database +# +SET GLOBAL event_scheduler=off; +drop event if exists event1; +create event event1 on schedule every 15 minute starts now() ends date_add(now(), interval 5 hour) DO begin end; +alter event event1 rename to event2 enable; +alter event event2 disable; +alter event event2 enable; +alter event event2 on completion not preserve; +delimiter __; +alter event event2 on schedule every 1 year on completion preserve rename to event3 comment "new comment" do begin select 1; end__ +delimiter ;__ +alter event event3 rename to event2; + +drop event event2; +create event event2 on schedule every 2 second starts now() ends date_add(now(), interval 5 hour) comment "some" DO begin end; +drop event event2; + +# +# BUG #16537 (Events: mysql.event.starts is null) +# +CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1; +SELECT interval_field, interval_value, body FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; +SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; +ALTER EVENT event_starts_test ON SCHEDULE AT '2020-02-02 20:00:02'; +SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; +ALTER EVENT event_starts_test COMMENT "non-empty comment"; +SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; +ALTER EVENT event_starts_test COMMENT ""; +SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; +DROP EVENT event_starts_test; + +CREATE EVENT event_starts_test ON SCHEDULE EVERY 20 SECOND STARTS '2020-02-02 20:00:02' ENDS '2022-02-02 20:00:02' DO SELECT 2; +SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; +ALTER EVENT event_starts_test COMMENT "non-empty comment"; +SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; +ALTER EVENT event_starts_test COMMENT ""; +SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; +DROP EVENT event_starts_test; +# +# +create table test_nested(a int); +create event e_43 on schedule every 1 second do set @a = 5; +--error ER_EVENT_RECURSION_FORBIDDEN +alter event e_43 do alter event e_43 do set @a = 4; +delimiter |; +alter event e_43 do +begin + alter event e_43 on schedule every 5 minute; + insert into test_nested values(1); +end| +delimiter ;| +set global event_scheduler = on; +let $wait_condition= SELECT count(*)>0 from mysql.event where name='e_43' and interval_value= 5; +--source include/wait_condition.inc +select db, name, body, status, interval_field, interval_value from mysql.event; +drop event e_43; +drop table test_nested; + +--echo "Let's check whether we can use non-qualified names" +create table non_qualif(a int); +create event non_qualif_ev on schedule every 10 minute do insert into non_qualif values (800219); +let $wait_condition=SELECT count(*)= 1 from non_qualif where a=800219; +--source include/wait_condition.inc +select * from non_qualif; +drop event non_qualif_ev; +drop table non_qualif; + +--error ER_EVENT_DOES_NOT_EXIST +alter event non_existant rename to non_existant_too; + +set global event_scheduler = off; +create event existant on schedule at now() + interval 1 year do select 12; +--error ER_EVENT_ALREADY_EXISTS +alter event non_existant rename to existant; +--error ER_EVENT_SAME_NAME +alter event existant rename to events_test.existant; +drop event existant; + + +create table t_event3 (a int, b float); +drop event if exists event3; +create event event3 on schedule every 50 + 10 minute starts date_add("20100101", interval 5 minute) ends date_add("20151010", interval 5 day) comment "portokala_comment" DO insert into t_event3 values (unix_timestamp(), rand()); +let $wait_condition=SELECT count(*)=0 from t_event3; +--source include/wait_condition.inc +select count(*) from t_event3; +drop event event3; +drop table t_event3; + + +set names utf8; +# +# SHOW CREATE EVENT test begin +# +CREATE EVENT root6 ON SCHEDULE EVERY '10:20' MINUTE_SECOND ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root6; +create event root7 on schedule every 2 year do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root7; +create event root8 on schedule every '2:5' year_month do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root8; +create event root8_1 on schedule every '2:15' year_month do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root8_1; +create event root9 on schedule every 2 week ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root9; +create event root10 on schedule every '20:5' day_hour do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root10; +create event root11 on schedule every '20:25' day_hour do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root11; +create event root12 on schedule every '20:25' hour_minute do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root12; +create event root13 on schedule every '25:25' hour_minute do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root13; +create event root13_1 on schedule every '11:65' hour_minute do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root13_1; +create event root14 on schedule every '35:35' minute_second do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root14; +create event root15 on schedule every '35:66' minute_second do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root15; +create event root16 on schedule every '35:56' day_minute do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root16; +create event root17 on schedule every '35:12:45' day_minute do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root17; +create event root17_1 on schedule every '35:25:65' day_minute do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root17_1; +create event root18 on schedule every '35:12:45' hour_second do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root18; +create event root19 on schedule every '15:59:85' hour_second do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root19; +create event root20 on schedule every '50:20:12:45' day_second do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT root20; +set names cp1251; +create event 21 on schedule every '50:23:59:95' day_second COMMENT ' 1251 ' do select 1; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT 21; +insert into mysql.event ( + db, + name, + body, + definer, + interval_value, + interval_field, + originator, + character_set_client, + collation_connection, + db_collation, + body_utf8) +values ( + database(), + "root22", + "select 1", + user(), + 100, + "SECOND_MICROSECOND", + 1, + 'utf8', + 'utf8_general_ci', + 'utf8_general_ci', + 'select 1'); +--error ER_NOT_SUPPORTED_YET +show create event root22; +--error ER_NOT_SUPPORTED_YET +SHOW EVENTS; +drop event root22; +--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG +create event root23 on schedule every -100 year do select 1; +--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG +create event root23 on schedule every 222222222222222222222 year do select 1; +drop event root6; +drop event root7; +drop event root8; +drop event root8_1; +drop event root9; +drop event root10; +drop event root11; +drop event root12; +drop event root13; +drop event root13_1; +drop event root14; +drop event root15; +drop event root16; +drop event root17; +drop event root17_1; +drop event root18; +drop event root19; +drop event root20; +drop event 21; + +set names latin1; +# +# SHOW CREATE EVENT test end +# + +# +# mysql.event intact checking +# Check that the server does not crash if +# one has destroyed or tampered with the event table. +# Please see see for events_restart_phase* tests to +# see the server behavior at start up with bad mysql.event +# table. +# +# +--echo Create a test event. Only event metadata is relevant, +--echo the actual schedule and body are not. +# +CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; +--replace_column 8 # 9 # +SHOW EVENTS; +# +--echo Try to alter mysql.event: the server should fail to load +--echo event information after mysql.event was tampered with. +--echo +--echo First, let's add a column to the end and make sure everything +--echo works as before +--echo +ALTER TABLE mysql.event ADD dummy INT; +--replace_column 8 # 9 # +SHOW EVENTS; +SELECT event_name FROM INFORMATION_SCHEMA.events; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +SHOW CREATE EVENT intact_check; +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT no_such_event; +CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; +ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; +ALTER EVENT intact_check_1 RENAME TO intact_check_2; +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT intact_check_1; +DROP EVENT intact_check_2; +DROP EVENT intact_check; +DROP DATABASE IF EXISTS mysqltest_no_such_database; +CREATE DATABASE mysqltest_db2; +DROP DATABASE mysqltest_db2; +SELECT @@event_scheduler; +SHOW VARIABLES LIKE 'event_scheduler'; +SET GLOBAL event_scheduler=OFF; +# Clean up +ALTER TABLE mysql.event DROP dummy; +CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; +--echo +--echo Now let's add a column to the first position: the server +--echo expects to see event schema name there +--echo +ALTER TABLE mysql.event ADD dummy INT FIRST; +--error ER_CANNOT_LOAD_FROM_TABLE +SHOW EVENTS; +--error ER_CANNOT_LOAD_FROM_TABLE +SELECT event_name FROM INFORMATION_SCHEMA.events; +--error ER_EVENT_DOES_NOT_EXIST +SHOW CREATE EVENT intact_check; +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT no_such_event; +--error ER_EVENT_STORE_FAILED +CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; +--error ER_EVENT_DOES_NOT_EXIST +ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; +--error ER_EVENT_DOES_NOT_EXIST +ALTER EVENT intact_check_1 RENAME TO intact_check_2; +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT intact_check_1; +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT intact_check_2; +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT intact_check; +# Should work OK +DROP DATABASE IF EXISTS mysqltest_no_such_database; +CREATE DATABASE mysqltest_db2; +DROP DATABASE mysqltest_db2; +SELECT @@event_scheduler; +SHOW VARIABLES LIKE 'event_scheduler'; +SET GLOBAL event_scheduler=OFF; +--echo Clean up +ALTER TABLE mysql.event DROP dummy; +DELETE FROM mysql.event; +CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; +--echo Back up the table, further changes are not reversible +CREATE TABLE event_like LIKE mysql.event; +INSERT INTO event_like SELECT * FROM mysql.event; +--echo +--echo Drop some columns and try more checks. +--echo +--echo +ALTER TABLE mysql.event DROP comment, DROP starts; +--error ER_CANNOT_LOAD_FROM_TABLE +SHOW EVENTS; +--error ER_CANNOT_LOAD_FROM_TABLE +SELECT event_name FROM INFORMATION_SCHEMA.EVENTS; +--error ER_CANNOT_LOAD_FROM_TABLE +SHOW CREATE EVENT intact_check; +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT no_such_event; +--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED +CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; +--error ER_EVENT_DOES_NOT_EXIST +ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; +--error ER_EVENT_DOES_NOT_EXIST +ALTER EVENT intact_check_1 RENAME TO intact_check_2; +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT intact_check_1; +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT intact_check_2; +# Should succeed +DROP EVENT intact_check; +DROP DATABASE IF EXISTS mysqltest_no_such_database; +CREATE DATABASE mysqltest_db2; +DROP DATABASE mysqltest_db2; +SELECT @@event_scheduler; +SHOW VARIABLES LIKE 'event_scheduler'; +SET GLOBAL event_scheduler=OFF; +--echo +--echo Now drop the table, and test again +--echo +--echo +DROP TABLE mysql.event; +--error ER_NO_SUCH_TABLE +SHOW EVENTS; +--error ER_NO_SUCH_TABLE +SELECT event_name FROM INFORMATION_SCHEMA.events; +--error ER_NO_SUCH_TABLE +SHOW CREATE EVENT intact_check; +--error ER_NO_SUCH_TABLE +DROP EVENT no_such_event; +--error ER_NO_SUCH_TABLE +CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; +--error ER_NO_SUCH_TABLE +ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; +--error ER_NO_SUCH_TABLE +ALTER EVENT intact_check_1 RENAME TO intact_check_2; +--error ER_NO_SUCH_TABLE +DROP EVENT intact_check_1; +--error ER_NO_SUCH_TABLE +DROP EVENT intact_check_2; +--error ER_NO_SUCH_TABLE +DROP EVENT intact_check; +DROP DATABASE IF EXISTS mysqltest_no_such_database; +CREATE DATABASE mysqltest_db2; +DROP DATABASE mysqltest_db2; +--echo OK, there is an unnecessary warning about the non-existent table +--echo but it's not easy to fix and no one complained about it. +--echo A similar warning is printed if mysql.proc is missing. +SHOW WARNINGS; +SELECT @@event_scheduler; +SHOW VARIABLES LIKE 'event_scheduler'; +SET GLOBAL event_scheduler=OFF; +--echo Restore the original table. +CREATE TABLE mysql.event like event_like; +DROP TABLE event_like; +--replace_column 8 # 9 # +SHOW EVENTS; +# +# End of tests +# + +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where db='events_test' and command = 'Connect' and user=current_user(); +--source include/wait_condition.inc + +drop database events_test; diff --git a/mysql-test/t/events_2.test b/mysql-test/t/events_2.test new file mode 100644 index 00000000000..a50255e9f8b --- /dev/null +++ b/mysql-test/t/events_2.test @@ -0,0 +1,525 @@ +# changes 2008-02-20 hhunger splitted events.test into events_1 and events_2 +# +# Can't test with embedded server that doesn't support grants +-- source include/not_embedded.inc + +--disable_warnings +drop database if exists events_test; +--enable_warnings +create database events_test; +use events_test; + +# +# mysql.event intact checking end +# + +create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5; +select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event; +drop event e_26; +--error ER_WRONG_VALUE +create event e_26 on schedule at NULL disable do set @a = 5; +--error ER_WRONG_VALUE +create event e_26 on schedule at 'definitely not a datetime' disable do set @a = 5; + +set names utf8; +create event задачка on schedule every 123 minute starts now() ends now() + interval 1 month do select 1; +drop event задачка; + +# event_scheduler is a global var +--error ER_GLOBAL_VARIABLE +set event_scheduler=off; +# event_scheduler could be only either 1 or 2 +--error ER_WRONG_VALUE_FOR_VAR +set global event_scheduler=3; +--error ER_WRONG_VALUE_FOR_VAR +set global event_scheduler=disabled; + +--echo "DISABLE the scheduler. Testing that it does not work when the variable is 0" +set global event_scheduler=off; +select definer, name, db from mysql.event; +select get_lock("test_lock1", 20); +create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20); +--echo "Should return 1 row" +select definer, name, db from mysql.event; + +--echo "Should be only 0 process" +select /*1*/ user, host, db, command, state, info + from information_schema.processlist + where (user='event_scheduler') + order by info; +select release_lock("test_lock1"); +drop event закачка; +--echo "Should have 0 events" +select count(*) from mysql.event; + +# +# +# +--echo "ENABLE the scheduler and get a lock" +set global event_scheduler=on; +select get_lock("test_lock2", 20); +--echo "Create an event which tries to acquire a mutex. The event locks on the mutex" +create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20); + +--echo "Should have only 2 processes: the scheduler and the locked event" +let $wait_condition= select count(*) = 2 from information_schema.processlist + where ( (state like 'User lock%' AND info like 'select get_lock%') + OR (command='Daemon' AND user='event_scheduler' AND + state = 'Waiting for next activation')); +--source include/wait_condition.inc + +select /*2*/ user, host, db, command, state, info + from information_schema.processlist + where (info like "select get_lock%" OR user='event_scheduler') + order by info; +--echo "Release the mutex, the event worker should finish." +select release_lock("test_lock2"); +drop event закачка; + +# Wait for release_lock("test_lock2") to complete, +# to avoid polluting the next test information_schema.processlist +let $wait_condition= select count(*) = 0 from information_schema.processlist + where (state like 'User lock%' AND info like 'select get_lock%'); +--source include/wait_condition.inc + + +## +## 1. get a lock +## 2. create an event +## 3. sleep so it has time to start +## 4. should appear in processlist +## 5. kill the scheduler, it will wait for the child to stop +## 6. both processes should be there on show processlist +## 7. release the lock and sleep, both scheduler and child should end +set global event_scheduler=1; +select get_lock("test_lock2_1", 20); +create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20); + +--echo "Should have only 2 processes: the scheduler and the locked event" +let $wait_condition= select count(*) = 2 from information_schema.processlist + where ( (state like 'User lock%' AND info like 'select get_lock%') + OR (command='Daemon' AND user='event_scheduler' AND + state = 'Waiting for next activation')); +--source include/wait_condition.inc + +select /*3*/ user, host, db, command, state, info + from information_schema.processlist + where (info like "select get_lock%" OR user='event_scheduler') + order by info; + +set global event_scheduler=off; + +let $wait_condition= select count(*) =1 from information_schema.processlist + where (info like "select get_lock%" OR user='event_scheduler'); +--source include/wait_condition.inc + +--echo "Should have only our process now:" +select /*4*/ user, host, db, command, state, info + from information_schema.processlist + where (info like "select get_lock%" OR user='event_scheduler') + order by info; +select release_lock("test_lock2_1"); +drop event закачка21; +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where db='events_test' and command = 'Connect' and user=current_user(); +--source include/wait_condition.inc + +#### +# Bug #16410 Events: CREATE EVENT is legal in a CREATE TRIGGER statement +# +create table t_16 (s1 int); +--error ER_EVENT_RECURSION_FORBIDDEN +create trigger t_16_bi before insert on t_16 for each row create event e_16 on schedule every 1 second do set @a=5; +drop table t_16; +# +# end of test case +#### + +# +# START: BUG #17453: Creating Event crash the server +# +create event white_space +on schedule every 10 hour +disable +do +select 1; +select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space'; +drop event white_space; +create event white_space on schedule every 10 hour disable do + +select 2; +select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space'; +drop event white_space; +create event white_space on schedule every 10 hour disable do select 3; +select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space'; +drop event white_space; +# +# END: BUG #17453: Creating Event crash the server +# + +# +# Bug#17403 "Events: packets out of order with show create event" +# +create event e1 on schedule every 1 year do set @a = 5; +create table t1 (s1 int); +--error ER_SP_NO_RETSET +create trigger t1_ai after insert on t1 for each row show create event e1; +drop table t1; +drop event e1; + +##set global event_scheduler=1; +##select get_lock("test_lock3", 20); +##create event закачка on schedule every 10 hour do select get_lock("test_lock3", 20); +##select sleep(2); +##select /*5*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info; +##drop event закачка; +##select release_lock("test_lock3"); + +# +# test with very often occuring event +# (disabled for now, locks) +##select get_lock("test_lock4", 20); +##create event закачка4 on schedule every 1 second do select get_lock("test_lock4", 20); +##select sleep(3); +##select /*6*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info; +##drop event закачка4; +##select release_lock("test_lock4"); + +##set global event_scheduler=off; +##select sleep(2); +##--replace_column 1 # 6 # +##show processlist; +##select count(*) from mysql.event; + +# +# Test wrong syntax +# + +--error ER_WRONG_DB_NAME +SHOW EVENTS FROM aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +--error ER_WRONG_DB_NAME +SHOW EVENTS FROM ``; + +SHOW EVENTS FROM `events\\test`; +# +# A check for events SQL under LOCK TABLES and in pre-locked mode. +# +--echo +--echo LOCK TABLES mode. +--echo +# +# SHOW CREATE EVENT and INFORMATION_SCHEMA.events are available and +# cause an implicit lock/unlock of mysql.event table, regardless of the +# currently locked tables. +# +create table t1 (a int); +create event e1 on schedule every 10 hour do select 1; +# +lock table t1 read; +# +--replace_regex /STARTS '[^']+'/STARTS '#'/ +show create event e1; +select event_name from information_schema.events; +--error ER_TABLE_NOT_LOCKED +create event e2 on schedule every 10 hour do select 1; +--error ER_TABLE_NOT_LOCKED +alter event e2 disable; +--error ER_TABLE_NOT_LOCKED +alter event e2 rename to e3; +--error ER_TABLE_NOT_LOCKED +drop event e2; +--error ER_TABLE_NOT_LOCKED +drop event e1; +unlock tables; +# +lock table t1 write; +# +--replace_regex /STARTS '[^']+'/STARTS '#'/ +show create event e1; +select event_name from information_schema.events; +--error ER_TABLE_NOT_LOCKED +create event e2 on schedule every 10 hour do select 1; +--error ER_TABLE_NOT_LOCKED +alter event e2 disable; +--error ER_TABLE_NOT_LOCKED +alter event e2 rename to e3; +--error ER_TABLE_NOT_LOCKED +drop event e2; +--error ER_TABLE_NOT_LOCKED +drop event e1; +unlock tables; +# +lock table t1 read, mysql.event read; +# +--replace_regex /STARTS '[^']+'/STARTS '#'/ +show create event e1; +select event_name from information_schema.events; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +create event e2 on schedule every 10 hour do select 1; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +alter event e2 disable; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +alter event e2 rename to e3; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +drop event e2; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +drop event e1; +unlock tables; +# +lock table t1 write, mysql.event read; +# +--replace_regex /STARTS '[^']+'/STARTS '#'/ +show create event e1; +select event_name from information_schema.events; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +create event e2 on schedule every 10 hour do select 1; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +alter event e2 disable; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +alter event e2 rename to e3; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +drop event e2; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +drop event e1; +unlock tables; +# +--error ER_WRONG_LOCK_OF_SYSTEM_TABLE +lock table t1 read, mysql.event write; +# +--error ER_WRONG_LOCK_OF_SYSTEM_TABLE +lock table t1 write, mysql.event write; +# +lock table mysql.event write; +--replace_regex /STARTS '[^']+'/STARTS '#'/ +show create event e1; +select event_name from information_schema.events; +create event e2 on schedule every 10 hour do select 1; +alter event e2 disable; +alter event e2 rename to e3; +drop event e3; +drop event e1; +unlock tables; +--echo Make sure we have left no events +select event_name from information_schema.events; +--echo +--echo Events in sub-statements, events and prelocking +--echo +--echo +create event e1 on schedule every 10 hour do select 1; +delimiter |; +--error ER_SP_NO_RETSET +create function f1() returns int +begin + show create event e1; + return 1; +end| +--error ER_SP_NO_RETSET +create trigger trg before insert on t1 for each row +begin + show create event e1; +end| +--error ER_SP_NO_RETSET +create function f1() returns int +begin + select event_name from information_schema.events; + return 1; +end| +--error ER_SP_NO_RETSET +create trigger trg before insert on t1 for each row +begin + select event_name from information_schema.events; +end| +--error ER_EVENT_RECURSION_FORBIDDEN +create function f1() returns int +begin + create event e2 on schedule every 10 hour do select 1; + return 1; +end| +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function f1() returns int +begin + alter event e1 rename to e2; + return 1; +end| +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function f1() returns int +begin + drop event e2; + return 1; +end| +--echo ---------------------------------------------------------------------- +create trigger trg before insert on t1 for each row +begin + set new.a= f1(); +end| +create function f1() returns int +begin + call p1(); + return 0; +end| +create procedure p1() +begin + select event_name from information_schema.events; +end| +--error ER_SP_NO_RETSET +insert into t1 (a) values (1)| +drop procedure p1| +create procedure p1() +begin + show create event e1; +end| +--error ER_SP_NO_RETSET +insert into t1 (a) values (1)| +drop procedure p1| +create procedure p1() +begin + create temporary table tmp select event_name from information_schema.events; +end| +--echo expected to work, since we redirect the output into a tmp table +insert into t1 (a) values (1)| +select * from tmp| +drop temporary table tmp| +drop procedure p1| +create procedure p1() +begin + alter event e1 rename to e2; +end| +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +insert into t1 (a) values (1)| +drop procedure p1| +create procedure p1() +begin + drop event e1; +end| +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +insert into t1 (a) values (1)| +drop table t1| +drop event e1| +delimiter ;| + +# +# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte +# +set names utf8; +create event имя_события_в_кодировке_утф8_длиной_больше_чем_48 on schedule every 2 year do select 1; +select EVENT_NAME from information_schema.events +where event_schema='test'; +drop event имя_события_в_кодировке_утф8_длиной_больше_чем_48; +--error 1059 +create event +очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66 +on schedule every 2 year do select 1; + +# +# Bug#35981: ALTER EVENT causes the server to change the PRESERVE option. +# + +create event event_35981 on schedule every 6 month on completion preserve +disable +do + select 1; + +echo The following SELECTs should all give 1; + +# show current ON_COMPLETION +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'PRESERVE'; + +# show ON_COMPLETION remains "PRESERVE" when not given in ALTER EVENT +alter event event_35981 enable; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'PRESERVE'; + +# show we can change ON_COMPLETION +alter event event_35981 on completion not preserve; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'NOT PRESERVE'; + +# show ON_COMPLETION remains "NOT PRESERVE" when not given in ALTER EVENT +alter event event_35981 disable; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'NOT PRESERVE'; + +# show we can change ON_COMPLETION +alter event event_35981 on completion preserve; +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'PRESERVE'; + + +drop event event_35981; + +create event event_35981 on schedule every 6 month disable +do + select 1; + +# show that the defaults for CREATE EVENT are still correct (NOT PRESERVE) +select count(*) from information_schema.events +where event_schema = database() and event_name = 'event_35981' and + on_completion = 'NOT PRESERVE'; + +drop event event_35981; + + +# show that backdating doesn't break + +create event event_35981 on schedule every 1 hour starts current_timestamp + on completion not preserve +do + select 1; + +# should fail thanks to above's NOT PRESERVE +--error ER_EVENT_CANNOT_ALTER_IN_THE_PAST +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00'; + +drop event event_35981; + +create event event_35981 on schedule every 1 hour starts current_timestamp + on completion not preserve +do + select 1; + +# succeed with warning +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00' on completion preserve; + +drop event event_35981; + + + +create event event_35981 on schedule every 1 hour starts current_timestamp + on completion preserve +do + select 1; + +# this should succeed thanks to above PRESERVE! give a warning though. +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00'; + +# this should fail, as the event would have passed already +--error ER_EVENT_CANNOT_ALTER_IN_THE_PAST +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00' on completion not preserve; + +# should succeed giving a warning +alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' + ends '1999-01-02 00:00:00' on completion preserve; + +drop event event_35981; + +# +# End of tests +# + +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where db='events_test' and command = 'Connect' and user=current_user(); +--source include/wait_condition.inc + +drop database events_test; diff --git a/mysql-test/t/events_bugs-master.opt b/mysql-test/t/events_bugs-master.opt new file mode 100644 index 00000000000..f93413a61e5 --- /dev/null +++ b/mysql-test/t/events_bugs-master.opt @@ -0,0 +1 @@ +--event-scheduler diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test new file mode 100644 index 00000000000..81397b333f9 --- /dev/null +++ b/mysql-test/t/events_bugs.test @@ -0,0 +1,1243 @@ +#### t/events_bugs.test +# +# Last change: +# 2009-01-08 mleich +# - Fix for +# Bug#41111 events_bugs fails sporadically on pushbuild +# - Avoid effects of +# Bug#41925 Warning 1366 Incorrect string value: ... for column processlist.info +# +# Please set $ +let $fixed_bug41925= 0; +# +# Dear maintainer of this test. Please do NOT remove the next big comment. +# The tests for events were quite unstable over a significant time because the +# effects of events in general and their representation within the processlist +# were partially not known. Therefore I had to make excessive experiments. +# The comment with the outcome of these experiments will be moved into a README +# file as soon as the tests for events get their own testsuite. +# +# Outcome of some experiments (mleich, mysql-5.1 2008-12): +# -------------------------------------------------------- +# 0. Most time used setup: +# High parallel I/O load +# set global event_scheduler= off; +# sleep 3; +# use events_test; +# create event e_16407 on schedule every 2 second do +# begin +# select 'FIRST COMMAND', sleep(0.5); +# select 'SECOND COMMAND'; +# end| +# set global event_scheduler= on; +# Start observation of the processlist +# +# +# 1. SET GLOBAL event_scheduler = 'ON' and immediate observation of the processlist. +# 1.1 Effects around event scheduler: +# 1.1.1 First phase (very short) +# No user 'event_scheduler' within information_schema.processlist. +# 1.1.2 Second phase observed (independend of probably existing events and very short) was +# USER HOST DB COMMAND TIME STATE INFO +# event_scheduler localhost NULL Daemon 0 Initialized NULL +# 1.1.3 Third phase observed: +# 1.1.3.1 Case we do not have existing events (rather long) +# USER HOST DB COMMAND TIME STATE INFO +# event_scheduler localhost NULL Daemon 0 Waiting on empty queue NULL +# 1.1.3.2 Case there exists already an event +# 1.1.3.2.1 Event executor is not visible in processlist but comes up soon +# USER HOST DB COMMAND TIME STATE INFO +# event_scheduler localhost NULL Daemon 0 NULL +# or +# event_scheduler localhost NULL Daemon 0 NULL NULL +# 1.1.3.2.2 A bit later, at least one event executor is or was visible in processlist +# The states mentioned in 3.2.1 or a bit later +# USER HOST DB COMMAND TIME STATE INFO +# event_scheduler localhost NULL Daemon 0 Waiting for next activation NULL +# 1.2 Effects around event executor: +# Typical processlist content: +# USER evtest1 -- Definer of event +# DB events_test -- DB during time of event creation (use DB is not allowed in events) +# COMMAND Connect +# STATE NULL +# INFO SET @evname = 'ev_sched_1823' -- Part of the event code +# +# State before "User sleep select 'FIRST COMMAND', sleep(0.5);" +# ID USER HOST DB COMMAND TIME STATE INFO +# 7 event_scheduler localhost NULL Connect 0 NULL NULL +# !! The user is not the event creator and the DB is different. !! +# !! This means that we must get later a change of the identity. !! +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 checking permissions +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 checking permissions CREATE PROCEDURE .... +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 NULL select 'FIRST COMMAND', sleep(0.5) +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 checking permissions select 'FIRST COMMAND'... +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 Opening table select 'FIRST COMMAND', sleep(0.5) +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 Locked select 'FIRST COMMAND', sleep(0.5) +# or +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 executing select 'FIRST COMMAND', sleep(0.5) +# +# State "User sleep select 'FIRST COMMAND', sleep(0.5);" reached +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 User sleep select 'FIRST COMMAND', sleep(0.5) +# +# State at end (! It looks like a slow CREATE PROC !) of event code execution was sometimes +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 logging slow query CREATE PROCEDURE `e_16407`... +# +# State after running some event code was sometimes +# USER HOST DB COMMAND TIME STATE INFO +# root localhost events_test Connect 0 logging slow query select 'SECOND COMMAND' +# +# State somewhere (I guess just before the event executor disappears) +# USER HOST DB COMMAND TIME STATE INFO +# Event thread fin <empty> events_test Connect 0 Clearing NULL +# +# +# 2. SET GLOBAL event_scheduler = 'OFF'; +# Immediate observation of the processlist. +# Effects: +# 1. I never found the user 'event_scheduler' within the processlist. +# 2. Events just during execution could be found within the processlist +# = It does not look like "SET GLOBAL event_scheduler = 'OFF'" stops them. +# ==> Everything mentioned in 1.2 above could be observed. +# +# Several subtests were weak because they showed random result set differences after issuing +# "SET GLOBAL EVENT_SCHEDULER= off;". +# 1. Reason one: There were already event executors +# Fix: Wait till there is no event executor active ==> no session WHERE +# - command IN ('Connect') +# There must be no parallel session being just in "Connect" phase! +# or +# - user = <who created the maybe current running events> +# There must be no parallel session of this person. +# or user = 'event_scheduler' with command = 'Connect' +# The session which will soon change its identity to event creator. +# +# 2. Reason two: If an event modifies a MyISAM table than a delayed visibilty of changes +# might occur (concurrent_inserts=on or delayed inserts ...). +# + +# Can't test with embedded server that doesn't support grants +-- source include/not_embedded.inc + +--disable_warnings +drop database if exists events_test; +drop database if exists mysqltest_db1; +drop database if exists mysqltest_db2; +--enable_warnings +create database events_test; +use events_test; +# We use MyISAM tables and must avoid effects (visibility of changes might be +# delayed) caused by concurrent_insert on (default). +set @concurrent_insert= @@global.concurrent_insert; +set @@global.concurrent_insert = 0; + +# +# START: Bug #31332 --event-scheduler option misbehaving +# + +# NOTE!! this test must come first! It's testing that the --event-scheduler +# option with no argument in events_bugs-master.opt turns the scheduler on. + +select * from information_schema.global_variables where variable_name like 'event_scheduler'; +# Check that the event_scheduler is really running +--source include/running_event_scheduler.inc + +SET GLOBAL event_scheduler = 'OFF'; +--source include/check_events_off.inc + +# +# END: Bug #31332 +# + +# +# START - 16415: Events: event names are case sensitive +# +CREATE EVENT lower_case ON SCHEDULE EVERY 1 MINUTE DO SELECT 1; +--error ER_EVENT_ALREADY_EXISTS +CREATE EVENT Lower_case ON SCHEDULE EVERY 2 MINUTE DO SELECT 2; +DROP EVENT Lower_case; +SET NAMES cp1251; +CREATE EVENT __1251 ON SCHEDULE EVERY 1 YEAR DO SELECT 100; +--error ER_EVENT_ALREADY_EXISTS +CREATE EVENT __1251 ON SCHEDULE EVERY 2 YEAR DO SELECT 200; +DROP EVENT __1251; +SET NAMES utf8; +CREATE EVENT долен_регистър_утф8 ON SCHEDULE EVERY 3 YEAR DO SELECT 300; +--error ER_EVENT_ALREADY_EXISTS +CREATE EVENT ДОЛЕН_регистър_утф8 ON SCHEDULE EVERY 4 YEAR DO SELECT 400; +DROP EVENT ДОЛЕН_регистър_утф8; +SET NAMES latin1; +# +# END - 16415: Events: event names are case sensitive +# + +# +# START - BUG#16408: Events: crash for an event in a procedure +# +set @a=3; +--error ER_EVENT_RECURSION_FORBIDDEN +CREATE PROCEDURE p_16 () CREATE EVENT e_16 ON SCHEDULE EVERY @a SECOND DO SET @a=5; +# +# END - BUG#16408: Events: crash for an event in a procedure +# + +# +# Start - 16396: Events: Distant-future dates become past dates +# +--error ER_WRONG_VALUE +create event e_55 on schedule at 99990101000000 do drop table t; +--error ER_WRONG_VALUE +create event e_55 on schedule every 10 hour starts 99990101000000 do drop table t; +--error ER_EVENT_ENDS_BEFORE_STARTS +create event e_55 on schedule every 10 minute ends 99990101000000 do drop table t; +--error ER_WRONG_VALUE +create event e_55 on schedule at 10000101000000 do drop table t; + +# For the purpose of backup we allow times in the past. Here, no +# error will be given, but the event won't be created. One may think +# of that as if the event was created, then it turned out it's in the +# past, so it was dropped because of implicit ON COMPLETION NOT +# PRESERVE. +create event e_55 on schedule at 20000101000000 do drop table t; +show events; + +--error ER_PARSE_ERROR +create event e_55 on schedule at 20200101000000 starts 10000101000000 do drop table t; +--error ER_PARSE_ERROR +create event e_55 on schedule at 20200101000000 ends 10000101000000 do drop table t; +--error ER_PARSE_ERROR +create event e_55 on schedule at 20200101000000 starts 10000101000000 ends 10000101000000 do drop table t; +--error ER_WRONG_VALUE +create event e_55 on schedule every 10 hour starts 10000101000000 do drop table t; + +# +# End - 16396: Events: Distant-future dates become past dates +# + +# +# Start - 16407: Events: Changes in sql_mode won't be taken into account +# +set global event_scheduler=off; +--source include/check_events_off.inc +delete from mysql.event; +set global event_scheduler= on; +--source include/running_event_scheduler.inc +set @old_sql_mode:=@@sql_mode; +set sql_mode=ansi; +select get_lock('test_bug16407', 60); +delimiter |; +create event e_16407 on schedule every 60 second do +begin + select get_lock('test_bug16407', 60); +end| +delimiter ;| + +# The default session has the user lock. +# We wait till one event runs and hangs when trying to get the user lock. +let $wait_condition= + select count(*) > 0 from information_schema.processlist + where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)'; +--source include/wait_condition.inc + +--echo "Now if everything is fine the event has compiled and is locked" +# Expect to see one session in events_test waiting for the user lock. +select /*1*/ user, host, db, info from information_schema.processlist +where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)'; +select release_lock('test_bug16407'); +# Try to avoid +# Bug#39863 events_bugs fails sporadically on pushbuild (extra processes in I_S.PROCESSLIST) +# which is most probably caused by +# Bug#32782 User lock hash fails to find lock +# "various issues related to missing or incorrect return results +# from release_lock()." +# Therefore we check here if the event executor is no more locked or +# we waited >= 5 seconds for this to happen. +let $wait_timeout= 5; +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)'; +--source include/wait_condition.inc +if (!`$wait_condition`) +{ + --echo ERROR: There must be no session with + --echo state = 'User lock' and info = 'select get_lock('test_bug16407', 60) + --echo within the processlist. + --echo We probably hit Bug#32782 User lock hash fails to find lock + SELECT * FROM information_schema.processlist; + --echo Abort + exit; +} + +set global event_scheduler= off; +# Wait till the event scheduler and all event executors have finished their work. +--source include/check_events_off.inc + +select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; +--echo "Let's check whether we change the sql_mode on ALTER EVENT" +set sql_mode='traditional'; +alter event e_16407 do select 1; +select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; +drop event e_16407; + +set sql_mode="ansi"; +select get_lock('ee_16407_2', 60); + +set global event_scheduler= 1; +--source include/running_event_scheduler.inc +--echo "Another sql_mode test" +set sql_mode="traditional"; +create table events_smode_test(ev_name char(10), a date); +--echo "This should never insert something" +delimiter |; +create event ee_16407_2 on schedule every 60 second do +begin + select get_lock('ee_16407_2', 60) /*ee_16407_2*/; + select release_lock('ee_16407_2'); + insert into events_test.events_smode_test values('ee_16407_2','1980-19-02'); +end| +--error ER_TRUNCATED_WRONG_VALUE +insert into events_test.events_smode_test values ('test','1980-19-02')| +--echo "This is ok" +create event ee_16407_3 on schedule every 60 second do +begin + select get_lock('ee_16407_2', 60) /*ee_16407_3*/; + select release_lock('ee_16407_2'); + insert into events_test.events_smode_test values ('ee_16407_3','1980-02-19'); + insert into events_test.events_smode_test values ('ee_16407_3','1980-02-29'); +end| +set sql_mode=""| +--echo "This will insert rows but they will be truncated" +create event ee_16407_4 on schedule every 60 second do +begin + select get_lock('ee_16407_2', 60) /*ee_16407_4*/; + select release_lock('ee_16407_2'); + insert into events_test.events_smode_test values ('ee_16407_4','10-11-1956'); +end| +delimiter ;| +select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; + +# We wait till we have three event executors waiting for the removal of the lock. +let $wait_condition= + select count(*) = 3 from information_schema.processlist + where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; +--source include/wait_condition.inc + +# There is an extreme low risk that an additional event execution is just coming +# up because +# - the events have to be started every 60 seconds. +# - we are just after event creation + waiting for seeing 3 locked +# We expect to see three event executors in state 'User lock'. +select /*2*/ user, host, db, info from information_schema.processlist +where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; + +select release_lock('ee_16407_2'); + +# Try to avoid +# Bug#39863 events_bugs fails sporadically on pushbuild (extra processes in I_S.PROCESSLIST) +# which is most probably caused by +# Bug#32782 User lock hash fails to find lock +# "various issues related to missing or incorrect return results +# from release_lock()." +# Therefore we check here if the event executing sessions disappeared or +# we waited >= 5 seconds for this to happen. +let $wait_timeout= 5; +let $wait_condition= + select count(*) = 0 + from information_schema.processlist + where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; +--source include/wait_condition.inc +if (!`$wait_condition`) +{ + --echo ERROR: There must be no session with + --echo state = 'User lock' and info = 'select get_lock('test_bug16407_2', 60) + --echo within the processlist. + --echo We probably hit Bug#32782 User lock hash fails to find lock + SELECT * FROM information_schema.processlist; + --echo Abort + exit; +} + +# We expect to see no event executors in state 'User lock'. +if(!$fixed_bug41925) +{ + --disable_warnings +} +select /*3*/ user, host, db, info from information_schema.processlist +where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; +if(!$fixed_bug41925) +{ + --enable_warnings +} + +set global event_scheduler= off; +# Wait till the event scheduler and all event executors have finished their work. +# Without this the next queries will give unstable results. +--source include/check_events_off.inc + +select * from events_test.events_smode_test order by ev_name, a; +--echo "OK, last check before we drop them" +select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; +drop event ee_16407_2; +drop event ee_16407_3; +drop event ee_16407_4; + + +--echo "And now one last test regarding sql_mode and call of SP from an event" +delete from events_test.events_smode_test; +set sql_mode='ansi'; +select get_lock('ee_16407_5', 60); + +set global event_scheduler= on; +--source include/running_event_scheduler.inc + +set sql_mode='traditional'; +delimiter |; +# ee_16407_5_pendant() should not insert anything because of invalid date. +create procedure ee_16407_5_pendant() begin insert into events_test.events_smode_test values('ee_16407_5','2001-02-29'); end| +create procedure ee_16407_6_pendant() begin insert into events_test.events_smode_test values('ee_16407_6','2004-02-29'); end| +create event ee_16407_5 on schedule every 60 second do +begin + select get_lock('ee_16407_5', 60) /*ee_16407_5*/; + select release_lock('ee_16407_5'); + call events_test.ee_16407_5_pendant(); +end| +create event ee_16407_6 on schedule every 60 second do +begin + select get_lock('ee_16407_5', 60) /*ee_16407_6*/; + select release_lock('ee_16407_5'); + call events_test.ee_16407_6_pendant(); +end| +delimiter ;| + +let $wait_condition= + select count(*) = 2 from information_schema.processlist + where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; +--source include/wait_condition.inc + +--echo "Should have 2 locked processes" +select /*4*/ user, host, db, info from information_schema.processlist +where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; + +select release_lock('ee_16407_5'); + +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; +--source include/wait_condition.inc + +--echo "Should have 0 processes locked" +if(!$fixed_bug41925) +{ + --disable_warnings +} +select /*5*/ user, host, db, info from information_schema.processlist +where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; +if(!$fixed_bug41925) +{ + --enable_warnings +} + +# Wait till all event executors have finished their work, so that we can be sure +# that their changes to events_smode_test are done. +--source include/no_running_events.inc + +select * from events_test.events_smode_test order by ev_name, a; +--echo "And here we check one more time before we drop the events" +select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; + +drop event ee_16407_5; +drop event ee_16407_6; +drop procedure ee_16407_5_pendant; +drop procedure ee_16407_6_pendant; +set global event_scheduler= off; +--source include/check_events_off.inc +drop table events_smode_test; +set sql_mode=@old_sql_mode; +# +# End - 16407: Events: Changes in sql_mode won't be taken into account +# + +# +# START - 18897: Events: unauthorized action possible with alter event rename +# +set global event_scheduler=off; +--source include/check_events_off.inc +--disable_warnings +delete from mysql.user where User like 'mysqltest_%'; +delete from mysql.db where User like 'mysqltest_%'; +flush privileges; +drop database if exists mysqltest_db1; +--enable_warnings +create user mysqltest_user1@localhost; +create database mysqltest_db1; +grant event on events_test.* to mysqltest_user1@localhost; +connect (conn2,localhost,mysqltest_user1,,events_test); +create event mysqltest_user1 on schedule every 10 second do select 42; +--error ER_DBACCESS_DENIED_ERROR +alter event mysqltest_user1 rename to mysqltest_db1.mysqltest_user1; +--echo "Let's test now rename when there is no select DB" +disconnect conn2; +connect (conn2,localhost,mysqltest_user1,,*NO-ONE*); +select database(); +--error ER_NO_DB_ERROR +alter event events_test.mysqltest_user1 rename to mysqltest_user1; +select event_schema, event_name, definer, event_type, status from information_schema.events; +drop event events_test.mysqltest_user1; +disconnect conn2; +connection default; +drop user mysqltest_user1@localhost; +drop database mysqltest_db1; +# +# END - 18897: Events: unauthorized action possible with alter event rename +# + +# +# START - BUG#16394: Events: Crash if schedule contains SELECT +# +--error ER_NOT_SUPPORTED_YET +create event e_53 on schedule at (select s1 from ttx) do drop table t; +--error ER_NOT_SUPPORTED_YET +create event e_53 on schedule every (select s1 from ttx) second do drop table t; +--error ER_NOT_SUPPORTED_YET +create event e_53 on schedule every 5 second starts (select s1 from ttx) do drop table t; +--error ER_NOT_SUPPORTED_YET +create event e_53 on schedule every 5 second ends (select s1 from ttx) do drop table t; +# +# END - BUG#16394: Events: Crash if schedule contains SELECT +# + +# +# START - BUG#22397: Events: crash with procedure which alters events +# +--disable_warnings +drop event if exists e_16; +drop procedure if exists p_16; +--enable_warnings +create event e_16 on schedule every 1 second do set @a=5; +create procedure p_16 () alter event e_16 on schedule every @a second; +set @a = null; +--error ER_WRONG_VALUE +call p_16(); +--error ER_WRONG_VALUE +call p_16(); +set @a= 6; +call p_16(); + +drop procedure p_16; +drop event e_16; + +# +# START - BUG#22830 Events: crash with procedure which alters events with function +# +--disable_warnings +drop function if exists f22830; +drop event if exists e22830; +drop event if exists e22830_1; +drop event if exists e22830_2; +drop event if exists e22830_3; +drop event if exists e22830_4; +drop table if exists t1; +drop table if exists t2; +--enable_warnings +create table t1 (a int); +insert into t1 values (2); +create table t2 (a char(20)); +insert into t2 values ("e22830_1"); +create function f22830 () returns int return 5; + +select get_lock('ee_22830', 60); +set global event_scheduler=on; +--source include/running_event_scheduler.inc + +delimiter |; +create procedure p22830_wait() +begin + select get_lock('ee_22830', 60); + select release_lock('ee_22830'); +end| + +--error ER_NOT_SUPPORTED_YET +create event e22830 on schedule every f22830() second do +begin + call p22830_wait(); + select 123; +end| +create event e22830_1 on schedule every 1 hour do +begin + call p22830_wait(); + alter event e22830_1 on schedule every (select 8 from dual) hour; +end| +create event e22830_2 on schedule every 1 hour do +begin + call p22830_wait(); + alter event e22830_2 on schedule every (select 8 from t1) hour; +end| +create event e22830_3 on schedule every 1 hour do +begin + call p22830_wait(); + alter event e22830_3 on schedule every f22830() hour; +end| +create event e22830_4 on schedule every 1 hour do +begin + call p22830_wait(); + alter event e22830_4 on schedule every (select f22830() from dual) hour; +end| +delimiter ;| + +--echo "All events should be blocked in get_lock()" +select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name; + +select release_lock('ee_22830'); + +let $wait_condition= + select group_concat(interval_value order by interval_value) = '1,1,1,8' + from information_schema.events; +--source include/wait_condition.inc + +set global event_scheduler=off; +--source include/check_events_off.inc +select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name; +drop procedure p22830_wait; +drop function f22830; +--error ER_PARSE_ERROR +drop event (select a from t2); +drop event e22830_1; +drop event e22830_2; +drop event e22830_3; +drop event e22830_4; +drop table t1; +drop table t2; + + +# +# BUG#16425: Events: no DEFINER clause +# +--error 0,ER_CANNOT_USER +DROP USER mysqltest_u1@localhost; + +CREATE USER mysqltest_u1@localhost; +GRANT EVENT ON events_test.* TO mysqltest_u1@localhost; + +CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; +DROP EVENT e1; + +CREATE DEFINER=CURRENT_USER EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; +ALTER DEFINER=mysqltest_u1@localhost EVENT e1 ON SCHEDULE EVERY 1 HOUR; +SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; +DROP EVENT e1; + +CREATE DEFINER=CURRENT_USER() EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; +DROP EVENT e1; + +CREATE DEFINER=mysqltest_u1@localhost EVENT e1 ON SCHEDULE EVERY 1 DAY DO + SELECT 1; +SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; +DROP EVENT e1; + +connect (conn1, localhost, mysqltest_u1, , events_test); + +CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; +DROP EVENT e1; + +CREATE DEFINER=CURRENT_USER EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +ALTER DEFINER=root@localhost EVENT e1 ON SCHEDULE EVERY 1 HOUR; +SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; +DROP EVENT e1; + +CREATE DEFINER=CURRENT_USER() EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; +DROP EVENT e1; + +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +CREATE DEFINER=root@localhost EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT e1; + +disconnect conn1; +connection default; + +DROP USER mysqltest_u1@localhost; + + +# +# BUG#16420: Events: timestamps become UTC +# BUG#26429: SHOW CREATE EVENT is incorrect for an event that +# STARTS NOW() +# BUG#26431: Impossible to re-create an event from backup if its +# STARTS clause is in the past +# WL#3698: Events: execution in local time zone +# +# Here we only check non-concurrent aspects of the patch. +# For the actual tests of time zones please see events_time_zone.test +# +SET GLOBAL EVENT_SCHEDULER= OFF; +--source include/check_events_off.inc +SET @save_time_zone= @@TIME_ZONE; + +#---------------------------------------------------------------------- + +# We will use a separate connection because SET TIMESTAMP will stop +# the clock in that connection. + +SET TIME_ZONE= '+00:00'; +SET TIMESTAMP= UNIX_TIMESTAMP('2005-12-31 23:58:59'); + + +# Test when event time zone is updated on ALTER EVENT. +# + +CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +SHOW EVENTS; + +# Test storing and updating of the event time zone. +# +SET TIME_ZONE= '-01:00'; +ALTER EVENT e1 ON SCHEDULE EVERY 1 DAY STARTS '2000-01-01 00:00:00'; +SHOW EVENTS; + +# This will update event time zone. +SET TIME_ZONE= '+02:00'; +ALTER EVENT e1 ON SCHEDULE AT '2000-01-02 00:00:00' + ON COMPLETION PRESERVE DISABLE; +SHOW EVENTS; + +# This will update event time zone. +SET TIME_ZONE= '-03:00'; +ALTER EVENT e1 ON SCHEDULE EVERY 1 DAY ENDS '2030-01-03 00:00:00' + ON COMPLETION PRESERVE DISABLE; +SHOW EVENTS; + +# This will not update event time zone, as no time is being adjusted. +SET TIME_ZONE= '+04:00'; +ALTER EVENT e1 DO SELECT 2; +SHOW EVENTS; + +DROP EVENT e1; + +#---------------------------------------------------------------------- + +# Create some events. +SET TIME_ZONE='+05:00'; +CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO + SELECT 1; + +SET TIMESTAMP= @@TIMESTAMP + 1; + +SET TIME_ZONE='-05:00'; +CREATE EVENT e2 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO + SELECT 1; + +SET TIMESTAMP= @@TIMESTAMP + 1; + +SET TIME_ZONE='+00:00'; +CREATE EVENT e3 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO + SELECT 1; + + +# Test INFORMATION_SCHEMA.EVENTS. +# + +SELECT * FROM INFORMATION_SCHEMA.EVENTS ORDER BY event_name; + + +# Test SHOW EVENTS. +# + +SHOW EVENTS; + + +# Test SHOW CREATE EVENT. +# + +SHOW CREATE EVENT e1; +SHOW CREATE EVENT e2; +SHOW CREATE EVENT e3; + +#---------------------------------------------------------------------- + +# Test times in the past. +# + +--echo The following should fail, and nothing should be altered. + +--error ER_EVENT_CANNOT_ALTER_IN_THE_PAST +ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' + ENDS '1999-01-02 00:00:00'; + +--error ER_EVENT_CANNOT_ALTER_IN_THE_PAST +ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' + ENDS '1999-01-02 00:00:00' DISABLE; + +--echo The following should give warnings, and nothing should be created. + +CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' + ENDS '1999-01-02 00:00:00' +DO + SELECT 1; + +CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' + ENDS '1999-01-02 00:00:00' DISABLE +DO + SELECT 1; + +CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DO + SELECT 1; + +CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DISABLE +DO + SELECT 1; + +SHOW EVENTS; + +--echo The following should succeed giving a warning. + +ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' + ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE; + +CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' + ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE +DO + SELECT 1; + +CREATE EVENT e5 ON SCHEDULE AT '1999-01-01 00:00:00' + ON COMPLETION PRESERVE +DO + SELECT 1; + +--echo The following should succeed without warnings. + +ALTER EVENT e2 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'; + +ALTER EVENT e3 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' + ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE DISABLE; + +CREATE EVENT e6 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' DO + SELECT 1; + +CREATE EVENT e7 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' + ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE DISABLE +DO + SELECT 1; + +CREATE EVENT e8 ON SCHEDULE AT '1999-01-01 00:00:00' + ON COMPLETION PRESERVE DISABLE +DO + SELECT 1; + +SHOW EVENTS; + + +DROP EVENT e8; +DROP EVENT e7; +DROP EVENT e6; +DROP EVENT e5; +DROP EVENT e4; +DROP EVENT e3; +DROP EVENT e2; +DROP EVENT e1; + +SET TIME_ZONE=@save_time_zone; + +# +# START - BUG#28666 CREATE EVENT ... EVERY 0 SECOND let server crash +# +--disable_warnings +drop event if exists new_event; +--enable_warnings +--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG +CREATE EVENT new_event ON SCHEDULE EVERY 0 SECOND DO SELECT 1; +--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG +CREATE EVENT new_event ON SCHEDULE EVERY (SELECT 0) SECOND DO SELECT 1; +--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG +CREATE EVENT new_event ON SCHEDULE EVERY "abcdef" SECOND DO SELECT 1; +--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG +CREATE EVENT new_event ON SCHEDULE EVERY "0abcdef" SECOND DO SELECT 1; +--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG +CREATE EVENT new_event ON SCHEDULE EVERY "a1bcdef" SECOND DO SELECT 1; + +--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG +CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "abcdef" UNION SELECT "abcdef") SECOND DO SELECT 1; +--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG +CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "0abcdef") SECOND DO SELECT 1; +--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG +CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "a1bcdef") SECOND DO SELECT 1; + +--error ER_WRONG_VALUE +CREATE EVENT new_event ON SCHEDULE AT "every day" DO SELECT 1; +--error ER_WRONG_VALUE +CREATE EVENT new_event ON SCHEDULE AT "0every day" DO SELECT 1; +--error ER_WRONG_VALUE +CREATE EVENT new_event ON SCHEDULE AT (SELECT "every day") DO SELECT 1; + +--error ER_PARSE_ERROR +CREATE EVENT new_event ON SCHEDULE AT NOW() STARTS NOW() DO SELECT 1; +--error ER_PARSE_ERROR +CREATE EVENT new_event ON SCHEDULE AT NOW() ENDS NOW() DO SELECT 1; +--error ER_PARSE_ERROR +CREATE EVENT new_event ON SCHEDULE AT NOW() STARTS NOW() ENDS NOW() DO SELECT 1; + +# +# START - BUG#28924 If I drop the user who is the definer of an active event +# then server cores +# +let $engine=MyISAM; +USE test; +SHOW GRANTS FOR CURRENT_USER; +SET GLOBAL event_scheduler = ON; +--source include/running_event_scheduler.inc +eval +CREATE TABLE events_test.event_log +(id int KEY AUTO_INCREMENT, ev_nm char(40), ev_cnt int, ev_tm timestamp) +ENGINE=$engine; +SET autocommit=0; +CREATE USER evtest1@localhost; +SET PASSWORD FOR evtest1@localhost = password('ev1'); +REVOKE ALL PRIVILEGES, GRANT OPTION FROM evtest1@localhost; +GRANT create, insert, select, event ON events_test.* TO evtest1@localhost; +GRANT select,insert ON test.* TO evtest1@localhost; +SHOW GRANTS FOR evtest1@localhost; + +--echo connection e1; +--replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK +connect (e1,localhost,evtest1,ev1,events_test,$MASTER_MYPORT,$MASTER_MYSOCK); +DELIMITER |; +CREATE EVENT ev_sched_1823 ON SCHEDULE EVERY 2 SECOND +DO BEGIN + SET AUTOCOMMIT = 0; + SET @evname = 'ev_sched_1823'; + SET @cnt = 0; + SELECT COUNT(*) INTO @cnt FROM events_test.event_log WHERE ev_nm = @evname; + IF @cnt < 6 THEN + INSERT INTO events_test.event_log VALUES (NULL,@evname,@cnt+1,current_timestamp()); + COMMIT; + END IF; + SELECT COUNT(*) INTO @cnt FROM events_test.event_log WHERE ev_nm = @evname; + IF @cnt < 6 THEN + INSERT INTO events_test.event_log VALUES (NULL,@evname,@cnt+1,current_timestamp()); + ROLLBACK; + END IF; +END;| +DELIMITER ;| +# 1. Show that the new created event is runnable and gets executed within a +# reasonable time like 4 seconds. Till ~ 2 seconds could pass on a heavy +# loaded testing box before something gets executed). +# Detection of execution is via the records inserted by the event. +--echo Sleep till the first INSERT into events_test.event_log occured +let $wait_timeout= 4; +let $wait_condition= +SELECT COUNT(*) > 0 FROM events_test.event_log; +--source include/wait_condition.inc +SELECT COUNT(*) > 0 AS "Expect 1" FROM events_test.event_log; +# +--echo connection default; +connection default; +DROP USER evtest1@localhost; +# 2. If we meet BUG#28924 again than a server crash happens within the next +# few seconds +# 3. Check that the event is never executed again +# It could be that an event execution was running before the DROP USER +# and all implicite actions belonging to this are completed. +# Lets assume that ~ 4 seconds waiting are enough for the event +# scheduler to detect that +--echo Sleep 4 seconds +sleep 4; +SELECT COUNT(*) INTO @row_cnt FROM events_test.event_log; +# Give the event mechanism ~ 4 seconds to do something wrong +# (execute the event of the dropped user -> inser rows). +--echo Sleep 4 seconds +sleep 4; +SELECT COUNT(*) > @row_cnt AS "Expect 0" FROM events_test.event_log; +# +# Cleanup +disconnect e1; +DROP EVENT events_test.ev_sched_1823; +DROP TABLE events_test.event_log; +SET GLOBAL event_scheduler = OFF; +--source include/check_events_off.inc + + +# +# Bug#28641 CREATE EVENT with '2038.01.18 03:00:00' let server crash. +# +SET GLOBAL event_scheduler= ON; +--source include/running_event_scheduler.inc +DELIMITER |; +CREATE EVENT bug28641 ON SCHEDULE AT '2038.01.18 03:00:00' +DO BEGIN + SELECT 1; +END;| + +DELIMITER ;| +SET GLOBAL event_scheduler= OFF; +--source include/check_events_off.inc +DROP EVENT bug28641; + +########################################################################### + +--echo +--echo ##################################################################### +--echo # +--echo # BUG#31111: --read-only crashes MySQL (events fail to load). +--echo # +--echo ##################################################################### +--echo + +--error 0,ER_CANNOT_USER +DROP USER mysqltest_u1@localhost; + +--disable_warnings +DROP EVENT IF EXISTS e1; +DROP EVENT IF EXISTS e2; +--enable_warnings + +--echo + +# Check that an ordinary user can not create/update/drop events in the +# read-only mode. + +GRANT EVENT ON *.* TO mysqltest_u1@localhost; + +--echo + +SET GLOBAL READ_ONLY = 1; + +--echo + +--echo # +--echo # Connection: u1_con (mysqltest_u1@localhost/events_test). +--echo # + +--connect(u1_con,localhost,mysqltest_u1,,events_test) + +--echo + +--error ER_OPTION_PREVENTS_STATEMENT +CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1; + +--echo + +--error ER_OPTION_PREVENTS_STATEMENT +ALTER EVENT e1 COMMENT 'comment'; + +--echo + +--error ER_OPTION_PREVENTS_STATEMENT +DROP EVENT e1; + +--echo + +# Check that the super user still can create/update/drop events. + +--echo # +--echo # Connection: root_con (root@localhost/events_test). +--echo # + +--connect(root_con,localhost,root,,events_test) + +--echo + +CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1; + +--echo + +ALTER EVENT e1 COMMENT 'comment'; + +--echo + +DROP EVENT e1; + +--echo + +# +# Switch to read-write mode; create test events under the user mysqltest_u1; +# switch back to read-only mode. +# + +SET GLOBAL READ_ONLY = 0; + +--echo + +--echo # +--echo # Connection: u1_con (mysqltest_u1@localhost/test). +--echo # + +--connection u1_con + +--echo + +CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND DO SET @a = 1; +CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO SET @a = 1; + +--echo + +SELECT + event_name, + last_executed IS NULL, + definer +FROM INFORMATION_SCHEMA.EVENTS +WHERE event_schema = 'events_test'; + +--echo + +--echo # +--echo # Connection: root_con (root@localhost/events_test). +--echo # + +--connection root_con + +--echo + +SET GLOBAL READ_ONLY = 1; + +# Check that the event scheduler is able to update event. + +--echo + +SET GLOBAL EVENT_SCHEDULER = ON; +--source include/running_event_scheduler.inc + +--echo + +--echo # Waiting for the event scheduler to execute and drop event e1... + +let $wait_timeout = 4; +let $wait_condition = + SELECT COUNT(*) = 0 + FROM INFORMATION_SCHEMA.EVENTS + WHERE event_schema = 'events_test' AND event_name = 'e1'; +--source include/wait_condition.inc + +--echo + +--echo # Waiting for the event scheduler to execute and update event e2... + +let $wait_condition = + SELECT last_executed IS NOT NULL + FROM INFORMATION_SCHEMA.EVENTS + WHERE event_schema = 'events_test' AND event_name = 'e2'; +--source include/wait_condition.inc + +--echo + +SET GLOBAL EVENT_SCHEDULER = OFF; +--source include/check_events_off.inc + +--echo + +SELECT + event_name, + last_executed IS NULL, + definer +FROM INFORMATION_SCHEMA.EVENTS +WHERE event_schema = 'events_test'; + +--echo + +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT e1; + +--echo +--echo # Cleanup. +--echo + +DROP EVENT e2; + +--echo + +SET GLOBAL READ_ONLY = 0; + +--echo + +--echo # +--echo # Connection: default +--echo # + +--disconnect u1_con +--disconnect root_con +--connection default + +--echo + +DROP USER mysqltest_u1@localhost; + +--echo +--echo ##################################################################### +--echo # +--echo # End of BUG#31111. +--echo # +--echo ##################################################################### +--echo + +# +# Bug#32633 Can not create any routine if SQL_MODE=no_engine_substitution +# +# Ensure that when new SQL modes are introduced, they are also added to +# the mysql.event table. +# + +--disable_warnings +drop procedure if exists p; +--enable_warnings +set @old_mode= @@sql_mode; +set @@sql_mode= pow(2,32)-1; +create event e1 on schedule every 1 day do select 1; +select @@sql_mode; +set @@sql_mode= @old_mode; +# Rename SQL modes that differ in name between the server and the table definition. +select replace(@full_mode, '?', 'NOT_USED') into @full_mode; +select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode; +select name from mysql.event where name = 'p' and sql_mode = @full_mode; +drop event e1; + +# +# Bug#36540: CREATE EVENT and ALTER EVENT statements fail with large server_id +# + +SET @old_server_id = @@GLOBAL.server_id; +SET GLOBAL server_id = (1 << 32) - 1; +SELECT @@GLOBAL.server_id; +CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS; +DROP EVENT ev1; +SET GLOBAL server_id = @old_server_id; + +########################################################################### +# +# End of tests +# +# !!! KEEP this section AT THE END of this file !!! +# +########################################################################### + +# Ensure that all event executors have finished their work and cannot harm +# the next test. +--source include/no_running_events.inc + +DROP DATABASE events_test; +# Restore the original state i.e to how it was when test started +# (option with no argument in events_bugs-master.opt turns the scheduler on). +SET GLOBAL event_scheduler= 'ON'; +--source include/running_event_scheduler.inc +SET @@global.concurrent_insert= @concurrent_insert; + +# THIS MUST BE THE LAST LINE in this file. diff --git a/mysql-test/t/events_embedded.test b/mysql-test/t/events_embedded.test new file mode 100644 index 00000000000..9922ea6dfee --- /dev/null +++ b/mysql-test/t/events_embedded.test @@ -0,0 +1,5 @@ +--source include/is_embedded.inc + +--error 1193 +set global event_scheduler=ON; + diff --git a/mysql-test/t/events_grant.test b/mysql-test/t/events_grant.test new file mode 100644 index 00000000000..8db4333cc03 --- /dev/null +++ b/mysql-test/t/events_grant.test @@ -0,0 +1,113 @@ +# Can't test with embedded server that doesn't support grants +-- source include/not_embedded.inc + +CREATE DATABASE IF NOT EXISTS events_test; +use events_test; +# +# Events grants test begin +# +CREATE EVENT one_event ON SCHEDULE EVERY 10 SECOND DO SELECT 123; +--replace_column 8 # 9 # +SHOW EVENTS; +SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; +CREATE DATABASE events_test2; +CREATE USER ev_test@localhost; +GRANT ALL ON events_test.* to ev_test@localhost; +GRANT ALL ON events_test2.* to ev_test@localhost; +REVOKE EVENT ON events_test2.* FROM ev_test@localhost; +#now we are on con1 +connect (ev_con1,localhost,ev_test,,events_test2); +select "NEW CONNECTION"; +SELECT USER(), DATABASE(); +SHOW GRANTS; +--echo "Here comes an error:"; +#NO EVENT_ACL on events_test2 +--error 1044 +SHOW EVENTS; +USE events_test; +--echo "We should see one event"; +--replace_column 8 # 9 # +SHOW EVENTS; +#now create an event with the same name but we are different user +SELECT CONCAT("Let's create some new events from the name of ", USER()); +--error ER_EVENT_ALREADY_EXISTS +CREATE EVENT one_event ON SCHEDULE EVERY 20 SECOND DO SELECT 123; +CREATE EVENT two_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION NOT PRESERVE COMMENT "two event" DO SELECT 123; +CREATE EVENT three_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION PRESERVE COMMENT "three event" DO SELECT 123; + +--echo "Now we should see 3 events:"; +--replace_column 8 # 9 # +SHOW EVENTS; + +--echo "This should show us only 2 events:"; +--replace_column 8 # 9 # +SHOW EVENTS LIKE 't%event'; + +--echo "This should show us no events:"; +--replace_column 8 # 9 # +SHOW EVENTS FROM test LIKE '%'; +#ok, we are back +connection default; +GRANT EVENT ON events_test2.* TO ev_test@localhost; +connection ev_con1; +USE events_test2; +CREATE EVENT four_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42; +connection default; +USE events_test; +--echo "We should see 4 events : one_event, two_event, three_event & four_event" +SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; +DROP DATABASE events_test2; +--echo "We should see 3 events : one_event, two_event, three_event" +SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; + +connection default; +CREATE DATABASE events_test2; +USE events_test2; +CREATE EVENT five_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42; + +connection ev_con1; +--echo "Should see 4 events - one, two, three & five" +SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; +connection default; +REVOKE EVENT ON events_test2.* FROM ev_test@localhost; +connection ev_con1; +USE test; +--echo "Should see 3 events - one, two & three" +SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; +--echo "Let's test ALTER EVENT which changes the definer" +USE events_test; +ALTER EVENT one_event ON SCHEDULE EVERY 10 SECOND; +--echo "The definer should be ev_test@localhost" +SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event'; +connection default; +USE events_test; +ALTER EVENT one_event COMMENT "comment"; +connection ev_con1; +--echo "The definer should be root@localhost" +SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event'; +ALTER EVENT one_event DO SELECT 12; +--echo "The definer should be ev_test@localhost" +SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event'; +connection default; +--echo "make the definer again root@localhost" +ALTER EVENT one_event COMMENT "new comment"; +connection ev_con1; +--echo "test DROP by another user" +DROP EVENT one_event; +connection default; +--echo "One event should not be there" +SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; +connection ev_con1; +disconnect ev_con1; +--source include/wait_until_disconnected.inc +connection default; +DROP USER ev_test@localhost; +DROP DATABASE events_test2; + +# +# End of tests +# + +--source include/check_events_off.inc + +DROP DATABASE events_test; diff --git a/mysql-test/t/events_logs_tests-master.opt b/mysql-test/t/events_logs_tests-master.opt new file mode 100644 index 00000000000..3ece9710a45 --- /dev/null +++ b/mysql-test/t/events_logs_tests-master.opt @@ -0,0 +1 @@ +--log-output=table,file --log-slow-queries diff --git a/mysql-test/t/events_logs_tests.test b/mysql-test/t/events_logs_tests.test new file mode 100644 index 00000000000..3240dccbc76 --- /dev/null +++ b/mysql-test/t/events_logs_tests.test @@ -0,0 +1,90 @@ +# Can't test with embedded server that doesn't support grants +-- source include/not_embedded.inc + +--disable_warnings +drop database if exists events_test; +--enable_warnings +create database if not exists events_test; +use events_test; +--echo +--echo We use procedure here because its statements won't be +--echo logged into the general log. If we had used normal select +--echo that are logged in different ways depending on whether the +--echo test suite is run in normal mode or with --ps-protocol +--echo +delimiter |; +create procedure select_general_log() +begin + select user_host, argument from mysql.general_log + where argument like '%events_logs_test%'; +end| +delimiter ;| +--echo +--echo Check that general query log works, but sub-statements +--echo of the stored procedure do not leave traces in it. +--echo +truncate mysql.general_log; +# Logging format in ps protocol is slightly different +--disable_ps_protocol +select 'events_logs_tests' as outside_event; +--enable_ps_protocol +--replace_column 1 USER_HOST +call select_general_log(); +--echo +--echo Check that unlike sub-statements of stored procedures, +--echo sub-statements of events are present in the general log. +--echo +set global event_scheduler=on; +truncate mysql.general_log; +create event ev_log_general on schedule at now() on completion not preserve do select 'events_logs_test' as inside_event; +--let $wait_condition=select count(*)=0 from information_schema.events where event_name='ev_log_general' +--source include/wait_condition.inc +--replace_column 1 USER_HOST +call select_general_log(); + +--echo +--echo Check slow query log +--echo +--echo Ensure that slow logging is on +show variables like 'log_slow_queries'; +--echo +--echo Demonstrate that session value has no effect +--echo +set @@session.long_query_time=1; +set @@global.long_query_time=300; +truncate mysql.slow_log; +create event ev_log_general on schedule at now() on completion not preserve + do select 'events_logs_test' as inside_event, sleep(1.5); +--let $wait_condition=select count(*)=0 from information_schema.events where event_name='ev_log_general' +--source include/wait_condition.inc +--echo +--echo Nothing should be logged +--echo +--replace_column 1 USER_HOST +select user_host, db, sql_text from mysql.slow_log + where sql_text like 'select \'events_logs_test\'%'; +set @@global.long_query_time=1; +truncate mysql.slow_log; +create event ev_log_general on schedule at now() on completion not preserve + do select 'events_logs_test' as inside_event, sleep(1.5); +--let $wait_condition=select count(*)=0 from information_schema.events where event_name='ev_log_general' +--source include/wait_condition.inc +--echo +--echo Event sub-statement should be logged. +--echo +--replace_column 1 USER_HOST +select user_host, db, sql_text from mysql.slow_log + where sql_text like 'select \'events_logs_test\'%'; + +drop database events_test; +set global event_scheduler=off; +set @@global.long_query_time=default; +set @@session.long_query_time=default; + +# +# Safety +# +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where db='events_test' and command = 'Connect' and user=current_user(); +--source include/wait_condition.inc diff --git a/mysql-test/t/events_microsec.test b/mysql-test/t/events_microsec.test new file mode 100644 index 00000000000..3e9abf6ec56 --- /dev/null +++ b/mysql-test/t/events_microsec.test @@ -0,0 +1,21 @@ +# Can't test with embedded server that doesn't support grants +-- source include/not_embedded.inc + +--disable_warnings +create database if not exists events_test; +--enable_warnings + +use events_test; + +--error ER_NOT_SUPPORTED_YET +CREATE EVENT micro_test ON SCHEDULE EVERY 100 MICROSECOND DO SELECT 1; +--error ER_NOT_SUPPORTED_YET +CREATE EVENT micro_test ON SCHEDULE EVERY 100 DAY_MICROSECOND DO SELECT 1; +--error ER_NOT_SUPPORTED_YET +CREATE EVENT micro_test ON SCHEDULE EVERY 100 HOUR_MICROSECOND DO SELECT 1; +--error ER_NOT_SUPPORTED_YET +CREATE EVENT micro_test ON SCHEDULE EVERY 100 MINUTE_MICROSECOND DO SELECT 1; +--error ER_NOT_SUPPORTED_YET +CREATE EVENT micro_test ON SCHEDULE EVERY 100 SECOND_MICROSECOND DO SELECT 1; + +drop database events_test; diff --git a/mysql-test/t/events_restart-master.opt b/mysql-test/t/events_restart-master.opt new file mode 100644 index 00000000000..f93413a61e5 --- /dev/null +++ b/mysql-test/t/events_restart-master.opt @@ -0,0 +1 @@ +--event-scheduler diff --git a/mysql-test/t/events_restart.test b/mysql-test/t/events_restart.test new file mode 100644 index 00000000000..e155fe2ea16 --- /dev/null +++ b/mysql-test/t/events_restart.test @@ -0,0 +1,106 @@ +# Can't test with embedded server that doesn't support grants +-- source include/not_embedded.inc + +# +# Test that when the server is restarted, it checks mysql.event table, +# and disables the scheduler if it's not up to date. +# + +# Switch off the scheduler for now. +set global event_scheduler=off; + +--disable_warnings +drop database if exists events_test; +--enable_warnings +create database events_test; +use events_test; +create table execution_log(name char(10)); + +create event abc1 on schedule every 1 second do + insert into execution_log value('abc1'); +create event abc2 on schedule every 1 second do + insert into execution_log value('abc2'); +create event abc3 on schedule every 1 second do + insert into execution_log value('abc3'); +# +# There are various conditions when a server would regard mysql.event +# table as damaged: +# - the table has more column than specified in the compiled in value, but +# the version of the server which created the table is the same +# - the column count in the table is less than the compiled in value +# - some column has an incompatible type specification (for what is an +# incompatible type specification please refer to the comments in the source +# +# Unfortunately, in order to test a condition, we need to restart the +# server. Therefore, here we test only one simple case: changing the data +# type of the 'body' field to blob. +# +# First, let's do a backup to not depend on actual definition of mysql.event +create table event_like like mysql.event; +insert into event_like select * from mysql.event; +# Now let's alter the table and restart the server +alter table mysql.event + change column body body longtext character set utf8 collate utf8_bin; +--echo "Now we restart the server" + +--source include/restart_mysqld.inc + +use events_test; +# Event scheduler should be disabled: the system tables are damaged +select @@event_scheduler; +# Try various Event Scheduler operation and check the output. +--error ER_EVENTS_DB_ERROR +show events; +--error ER_EVENTS_DB_ERROR +select event_name from information_schema.events; +--error ER_EVENTS_DB_ERROR +show create event intact_check; +--error ER_EVENTS_DB_ERROR +drop event no_such_event; +--error ER_EVENTS_DB_ERROR +create event intact_check_1 on schedule every 5 hour do select 5; +--error ER_EVENTS_DB_ERROR +alter event intact_check_1 on schedule every 8 hour do select 8; +--error ER_EVENTS_DB_ERROR +alter event intact_check_1 rename to intact_check_2; +--error ER_EVENTS_DB_ERROR +drop event intact_check_1; +--error ER_EVENTS_DB_ERROR +drop event intact_check_2; +--error ER_EVENTS_DB_ERROR +drop event intact_check; +--error ER_EVENTS_DB_ERROR +set global event_scheduler=on; +--error ER_EVENTS_DB_ERROR +set global event_scheduler=off; +show variables like 'event_scheduler'; +--echo Make sure that we still can create and drop databases, +--echo and no warnings are produced. +drop database if exists mysqltest_database_not_exists; +create database mysqltest_db1; +drop database mysqltest_db1; +--echo Restore the original mysql.event table +drop table mysql.event; +rename table event_like to mysql.event; +--echo Now let's restart the server again + +--source include/restart_mysqld.inc + +# We need this file primarily to make sure that the scheduler is restarted +# and enabled after we have restored mysql.event table. +# This is the final step of the "cleanup". +# +# Make sure also that events are executed OK after restart, just in case. +use events_test; +# Make sure the scheduler was started successfully +select @@event_scheduler; +let $wait_condition=select count(distinct name)=3 from execution_log; +--source include/wait_condition.inc +drop table execution_log; +# Will drop all events +drop database events_test; + +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where db='events_test' and command = 'Connect' and user=current_user(); +--source include/wait_condition.inc diff --git a/mysql-test/t/events_scheduling.test b/mysql-test/t/events_scheduling.test new file mode 100644 index 00000000000..041a2def490 --- /dev/null +++ b/mysql-test/t/events_scheduling.test @@ -0,0 +1,122 @@ +# Can't test with embedded server that doesn't support events +-- source include/not_embedded.inc + +CREATE DATABASE IF NOT EXISTS events_test; +USE events_test; + +SET @event_scheduler=@@global.event_scheduler; +SET GLOBAL event_scheduler=OFF; +--echo Try again to make sure it's allowed +SET GLOBAL event_scheduler=OFF; +SHOW VARIABLES LIKE 'event_scheduler'; +SET GLOBAL event_scheduler=1; +SHOW VARIABLES LIKE 'event_scheduler'; +SET GLOBAL event_scheduler=0; +SHOW VARIABLES LIKE 'event_scheduler'; +SET GLOBAL event_scheduler=ON; +--echo Try again to make sure it's allowed +SET GLOBAL event_scheduler=ON; +SHOW VARIABLES LIKE 'event_scheduler'; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL event_scheduler=DISABLED; +SHOW VARIABLES LIKE 'event_scheduler'; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL event_scheduler=-1; +SHOW VARIABLES LIKE 'event_scheduler'; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL event_scheduler=2; +SHOW VARIABLES LIKE 'event_scheduler'; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL event_scheduler=5; +SHOW VARIABLES LIKE 'event_scheduler'; + +CREATE TABLE table_1(a int); +CREATE TABLE table_2(a int); +CREATE TABLE table_3(a int); +CREATE TABLE table_4(a int); + +SET GLOBAL event_scheduler=ON; +# We need to have 2 to make it safe with valgrind. This is probably because +# of when we calculate the timestamp value +CREATE EVENT event_1 ON SCHEDULE EVERY 2 SECOND +DO + INSERT INTO table_1 VALUES (1); + +CREATE EVENT event_2 ON SCHEDULE EVERY 1 SECOND +ENDS NOW() + INTERVAL 6 SECOND +ON COMPLETION PRESERVE +DO + INSERT INTO table_2 VALUES (1); + +CREATE EVENT event_3 ON SCHEDULE EVERY 2 SECOND ENDS NOW() + INTERVAL 1 SECOND +ON COMPLETION NOT PRESERVE +DO + INSERT INTO table_3 VALUES (1); + +CREATE EVENT event_4 ON SCHEDULE EVERY 1 SECOND ENDS NOW() + INTERVAL 1 SECOND +ON COMPLETION PRESERVE +DO + INSERT INTO table_4 VALUES (1); + +# Let event_1 insert at least 4 records into the table +let $wait_condition=select count(*) >= 4 from table_1; +--source include/wait_condition.inc +# Minimum of passed time is 6 seconds assuming +# - event executions starts immediate after creation +# - 4 times event_1 means an insert at ect, ect+2, ect+4, ect+6 +# ect = event creation time + +# Let event_2 reach the end of its execution interval +let $wait_condition=select count(*) = 0 from information_schema.events +where event_name='event_2' and status='enabled'; +--source include/wait_condition.inc +# Minimum of passed time is 6 seconds. +# See wait_condition for event_1 above and ENDS condition for event_2. + +# Let event_3, which is ON COMPLETION NOT PRESERVE execute and drop itself +let $wait_condition=select count(*) = 0 from information_schema.events +where event_name='event_3'; +--source include/wait_condition.inc + +# Let event_4 reach the end of its execution interval +let $wait_condition=select count(*) = 0 from information_schema.events +where event_name='event_4' and status='enabled'; +--source include/wait_condition.inc + +# +# On a busy system the scheduler may skip execution of events, +# we can't reliably expect that the data in a table to be modified +# by an event will be exact. Thus we do not SELECT from the tables +# in this test. See also +# Bug#39854 events_scheduling fails sporadically on pushbuild +# + +SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') +FROM INFORMATION_SCHEMA.EVENTS +WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='event_2'; + +--echo "Already dropped because ended. Therefore an error." +--error ER_EVENT_DOES_NOT_EXIST +DROP EVENT event_3; + +DROP EVENT event_1; +--echo "Should be preserved" +SELECT EVENT_NAME, STATUS FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_NAME; +DROP EVENT event_2; +DROP EVENT event_4; +DROP TABLE table_1; +DROP TABLE table_2; +DROP TABLE table_3; +DROP TABLE table_4; +DROP DATABASE events_test; +SET GLOBAL event_scheduler=@event_scheduler; + +# +# End of tests +# + +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where db='events_test' and command = 'Connect' and user=current_user(); +--source include/wait_condition.inc + diff --git a/mysql-test/t/events_stress.test b/mysql-test/t/events_stress.test new file mode 100644 index 00000000000..e51fa734256 --- /dev/null +++ b/mysql-test/t/events_stress.test @@ -0,0 +1,141 @@ +# Can't test with embedded server that doesn't support grants +--source include/not_embedded.inc +--source include/big_test.inc + +CREATE DATABASE IF NOT EXISTS events_test; +# +# DROP DATABASE test start (bug #16406) +# +CREATE DATABASE events_conn1_test2; +# BUG#20676: MySQL in debug mode has a limit of 100 waiters +# (in mysys/thr_lock.c), so use three different tables to insert into. +CREATE TABLE events_test.fill_it1(test_name varchar(20), occur datetime); +CREATE TABLE events_test.fill_it2(test_name varchar(20), occur datetime); +CREATE TABLE events_test.fill_it3(test_name varchar(20), occur datetime); +CREATE USER event_user2@localhost; +CREATE DATABASE events_conn2_db; +GRANT ALL ON *.* TO event_user2@localhost; +CREATE USER event_user3@localhost; +CREATE DATABASE events_conn3_db; +GRANT ALL ON *.* TO event_user3@localhost; +connect (conn2,localhost,event_user2,,events_conn2_db); +--echo "In the second connection we create some events which won't be dropped till the end" +--disable_query_log +let $1= 50; +while ($1) +{ + eval CREATE EVENT conn2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it1 VALUES("conn2_ev$1", NOW()); + dec $1; +} +--enable_query_log +connect (conn3,localhost,event_user3,,events_conn3_db); +--echo "In the second connection we create some events which won't be dropped till the end" +--disable_query_log +let $1= 50; +while ($1) +{ + eval CREATE EVENT conn3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it1 VALUES("conn3_ev$1", NOW()); + dec $1; +} +--enable_query_log +connection default; +USE events_conn1_test2; +CREATE EVENT ev_drop1 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1; +CREATE EVENT ev_drop2 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1; +CREATE EVENT ev_drop3 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1; +USE events_test; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; +DROP DATABASE events_conn1_test2; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; + +--echo "Now testing stability - dropping db -> events while they are running" +CREATE DATABASE events_conn1_test2; +USE events_conn1_test2; +--disable_query_log +let $1= 50; +while ($1) +{ + eval CREATE EVENT conn1_round1_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it2 VALUES("conn1_round1_ev$1", NOW()); + dec $1; +} +--enable_query_log +SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; +SET GLOBAL event_scheduler=on; +--sleep 2.5 +DROP DATABASE events_conn1_test2; + +SET GLOBAL event_scheduler=off; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; +CREATE DATABASE events_conn1_test3; +USE events_conn1_test3; +--disable_query_log +let $1= 50; +while ($1) +{ + eval CREATE EVENT conn1_round2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it2 VALUES("conn1_round2_ev$1", NOW()); + dec $1; +} +--enable_query_log +SET GLOBAL event_scheduler=on; +SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test3'; +CREATE DATABASE events_conn1_test4; +USE events_conn1_test4; +--disable_query_log +let $1= 50; +while ($1) +{ + eval CREATE EVENT conn1_round3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it3 VALUES("conn1_round3_ev$1", NOW()); + dec $1; +} +--enable_query_log + +CREATE DATABASE events_conn1_test2; +USE events_conn1_test2; +--disable_query_log +let $1= 50; +while ($1) +{ + eval CREATE EVENT ev_round4_drop$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it3 VALUES("conn1_round4_ev$1", NOW()); + dec $1; +} +--enable_query_log +SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; +--sleep 2.5 +connection conn2; +--send +DROP DATABASE events_conn2_db; +connection conn3; +--send +DROP DATABASE events_conn3_db; +connection default; +# --send +DROP DATABASE events_conn1_test2; +DROP DATABASE events_conn1_test3; +SET GLOBAL event_scheduler=off; +DROP DATABASE events_conn1_test4; +SET GLOBAL event_scheduler=on; +connection conn2; +reap; +disconnect conn2; +connection conn3; +reap; +disconnect conn3; +connection default; +USE events_test; +DROP TABLE fill_it1; +DROP TABLE fill_it2; +DROP TABLE fill_it3; +--disable_query_log +DROP USER event_user2@localhost; +DROP USER event_user3@localhost; +--enable_query_log +# +# DROP DATABASE test end (bug #16406) +# + +DROP DATABASE events_test; + +# Cleanup +SET GLOBAL event_scheduler=off; +--source include/check_events_off.inc diff --git a/mysql-test/t/events_time_zone.test b/mysql-test/t/events_time_zone.test new file mode 100644 index 00000000000..ccae7847618 --- /dev/null +++ b/mysql-test/t/events_time_zone.test @@ -0,0 +1,331 @@ +# 1. This test case is sensitive to execution timing. You may control +# this sensitivity by the parameter below. Small values will result +# in fast but more unstable execution, large values will improve +# stability at the cost of speed. Basically, N is a number of seconds +# to wait for operation to complete. Should be positive. Test runs +# about 25*N seconds (it sleeps most of the time, so CPU speed is not +# relevant). +let $N = 5; +# +# 2. Some subtests +# - create a new time zone +# - run some statements +# - delete the new time zone. +# But the time zone name used gets somewhere cached and it cannot be +# "reused" later in the same or another session for a new time zone. +# Experiments (2008-11 MySQL 5.1) showed that none of the available +# RESET/FLUSH commands removes these entries. +# 2008-11 MySQL 5.1 Bug#39979 main.events_time_zone does not clean up +# second bad effect +# Therefore we compute unique and unusual timezone names to minimize +# the likelihood that a later test uses the same name. +# +# 3. The subtests mentioned in 2. cause that the AUTO_INCREMENT value +# within "SHOW CREATE TABLE mysql.timezone" differ from the initial one. +# (Bug#39979 main.events_time_zone does not clean up) +# Therefore we reset this value after each of these subtests. +# +# Note(mleich): +# There is a significant likelihood that future improvements of the server +# cause that the solutions for the issues mentioned in 2. and 3. will no +# more work. +# A mysql-test-run.pl feature which allows to enforce +# 1. Server shutdown (-> Problem mentioned in 2. disappears) +# 2. Reset all data to initial state (-> Problem mentioned in 3. disappears) +# 3. Server start +# after a tests would be a perfect replacement. +# + +--source include/big_test.inc + + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest_db1; +--enable_warnings + +CREATE DATABASE mysqltest_db1; + +let $old_db= `SELECT DATABASE()`; +USE mysqltest_db1; + +SET GLOBAL EVENT_SCHEDULER= OFF; +SET @save_time_zone= @@TIME_ZONE; + + +# +# BUG#16420: Events: timestamps become UTC +# BUG#26429: SHOW CREATE EVENT is incorrect for an event that +# STARTS NOW() +# BUG#26431: Impossible to re-create an event from backup if its +# STARTS clause is in the past +# WL#3698: Events: execution in local time zone +# + +#---------------------------------------------------------------------- + +# Create rounding function. + +# Disable query log to hide actual value of $N. +--disable_query_log +eval SET @step= $N; +--enable_query_log + +# Since we are working in a separate database, we may use any names we +# like. +CREATE TABLE t_step (step INT); +INSERT INTO t_step VALUES (@step); + +# We can't use @variables in function, because it will be called from +# the event thread, and 'eval' doesn't work for multi-statements, so +# we can't interpolate $variables either, hence we fetch the step +# value from the table. +delimiter //; +CREATE FUNCTION round_to_step(i INT, n INT) RETURNS INT +BEGIN + DECLARE step INT; + + SELECT * INTO step FROM t_step; + + # We add 0.1 as a protection from inexact division. + RETURN FLOOR((i % (step * n) + 0.1) / step); +END// +delimiter ;// + + +# Test time computations wrt Daylight Saving Time shifts. We also +# test here that the event operates in its time zone (see what NOW() +# returns). +# + +# Create a fake time zone with time transitions every 3*$N second. + +SET @step3= @step * 3; +SET @step6= @step * 6; + +SET @unix_time= UNIX_TIMESTAMP() - 1; +SET @unix_time= @unix_time - @unix_time % @step6; + +INSERT INTO mysql.time_zone VALUES (NULL, 'N'); +SET @tzid= LAST_INSERT_ID(); +INSERT INTO mysql.time_zone_transition_type + VALUES (@tzid, 0, 0, 0, 'b16420_0'); +INSERT INTO mysql.time_zone_transition_type + VALUES (@tzid, 1, @step3 - @step, 1, 'b16420_1'); + +let $transition_unix_time= `SELECT @unix_time`; +let $count= 30; +--disable_query_log +while ($count) +{ + eval INSERT INTO mysql.time_zone_transition + VALUES (@tzid, $transition_unix_time, + $transition_unix_time % @step6 = 0); + let $transition_unix_time= `SELECT $transition_unix_time + @step3`; + dec $count; +} +--enable_query_log +let $tz_name = `SELECT CONCAT('b16420_a',UNIX_TIMESTAMP())`; +--replace_result $tz_name <TZ_NAME_1> +eval INSERT INTO mysql.time_zone_name VALUES ('$tz_name', @tzid); + +CREATE TABLE t1 (count INT, unix_time INT, local_time INT, comment CHAR(80)); +CREATE TABLE t2 (count INT); +INSERT INTO t2 VALUES (1); + +delimiter //; +CREATE FUNCTION f1(comment CHAR(80)) RETURNS INT +BEGIN + DECLARE orig_tz CHAR(64); + DECLARE unix_time INT; + DECLARE local_now DATETIME; + DECLARE utc_now DATETIME; + DECLARE local_time INT; + + SET unix_time= UNIX_TIMESTAMP(); + SET local_now= FROM_UNIXTIME(unix_time); + SET orig_tz= @@TIME_ZONE; + SET TIME_ZONE = '+00:00'; + SET utc_now= FROM_UNIXTIME(unix_time); + SET TIME_ZONE= orig_tz; + SET local_time = unix_time + TIMESTAMPDIFF(SECOND, utc_now, local_now); + + SET unix_time= round_to_step(unix_time, 6); + SET local_time= round_to_step(local_time, 6); + + INSERT INTO t1 VALUES ((SELECT count FROM t2), + unix_time, local_time, comment); + RETURN 0; +END// +delimiter ;// + +SET TIME_ZONE= '+00:00'; +CREATE EVENT e1 ON SCHEDULE EVERY @step SECOND + STARTS FROM_UNIXTIME(@unix_time) DO SELECT f1("<e1>"); + +--replace_result $tz_name <TZ_NAME_1> +eval SET TIME_ZONE= '$tz_name'; +CREATE EVENT e2 ON SCHEDULE EVERY @step SECOND + STARTS FROM_UNIXTIME(@unix_time) DO SELECT f1("<e2>"); + +# We want to start at the beginning of the DST cycle, so we wait +# untill current time divides by @step6. +let $wait_timeout= `SELECT @step6 + 1`; +let $wait_condition= SELECT UNIX_TIMESTAMP() % @step6 = @step6 - 1; +--source include/wait_condition.inc +# The second wait is needed because after the first wait we may end up +# on the ending edge of a second. Second wait will bring us to the +# beginning edge. +let $wait_timeout= `SELECT @step + 1`; +let $wait_condition= SELECT UNIX_TIMESTAMP() % @step6 = 0; +--source include/wait_condition.inc + +# Note that after the scheduler is enabled, the event will be +# scheduled only for the next second. +SET GLOBAL EVENT_SCHEDULER= ON; + +# We want to run after the events are executed. +SELECT SLEEP(@step / 2); + +let $count= 7; +--disable_query_log +--disable_result_log +while ($count) +{ + SELECT SLEEP(@step); + + eval SELECT CASE $count + WHEN 5 THEN f1(CONCAT("Second pass after backward -2 step shift,", + " e2 should not be executed")) + WHEN 4 THEN f1(CONCAT("Second pass after backward -2 step shift,", + " e2 should not be executed")) + WHEN 2 THEN f1(CONCAT("Forward +2 step shift, local 0, 1 are skipped,", + " e2 should be executed")) + ELSE f1("e2 should be executed") + END; + UPDATE t2 SET count= count + 1; + + dec $count; +} +--enable_result_log +--enable_query_log + +SET GLOBAL EVENT_SCHEDULER= OFF; + +SELECT * FROM t1 ORDER BY count, comment; + +SET TIME_ZONE= @save_time_zone; + +DROP EVENT e2; +DROP EVENT e1; +DROP FUNCTION f1; +DROP TABLE t1, t2; + +DELETE FROM mysql.time_zone_name WHERE time_zone_id = @tzid; +DELETE FROM mysql.time_zone_transition_type WHERE time_zone_id = @tzid; +DELETE FROM mysql.time_zone_transition WHERE time_zone_id = @tzid; +DELETE FROM mysql.time_zone WHERE time_zone_id = @tzid; +let $time_zone_auto_inc = `SELECT MAX(Time_zone_id) + 1 FROM mysql.time_zone`; +eval ALTER TABLE mysql.time_zone AUTO_INCREMENT = $time_zone_auto_inc; + +#---------------------------------------------------------------------- + +# Test MONTH interval. +# + +SET TIME_ZONE= '+00:00'; + +CREATE TABLE t1 (event CHAR(2), dt DATE, offset INT); + +INSERT INTO mysql.time_zone VALUES (NULL, 'N'); +SET @tzid= LAST_INSERT_ID(); + +SET @now= UNIX_TIMESTAMP(); +SET @offset_month_01= UNIX_TIMESTAMP('2030-01-31 12:00:00') - @now; +SET @offset_month_02= UNIX_TIMESTAMP('2030-02-28 12:00:00') - @now - 5*@step; +SET @offset_month_03= UNIX_TIMESTAMP('2030-03-31 12:00:00') - @now - 5*@step; +SET @offset_month_04= UNIX_TIMESTAMP('2030-04-30 12:00:00') - @now - 13*@step; + +INSERT INTO mysql.time_zone_transition_type + VALUES (@tzid, 0, @offset_month_01, 0, 'b16420_0'); +INSERT INTO mysql.time_zone_transition_type + VALUES (@tzid, 1, @offset_month_02, 1, 'b16420_1'); +INSERT INTO mysql.time_zone_transition_type + VALUES (@tzid, 2, @offset_month_03, 1, 'b16420_2'); +INSERT INTO mysql.time_zone_transition_type + VALUES (@tzid, 3, @offset_month_04, 1, 'b16420_3'); +INSERT INTO mysql.time_zone_transition + VALUES (@tzid, @now, 0); +INSERT INTO mysql.time_zone_transition + VALUES (@tzid, @now + 3 * @step, 1); +INSERT INTO mysql.time_zone_transition + VALUES (@tzid, @now + 7 * @step, 2); +INSERT INTO mysql.time_zone_transition + VALUES (@tzid, @now + 12 * @step, 3); +let $tz_name = `SELECT CONCAT('b16420_b',UNIX_TIMESTAMP())`; +--replace_result $tz_name <TZ_NAME_2> +eval INSERT INTO mysql.time_zone_name VALUES ('$tz_name', @tzid); + +--replace_result $tz_name <TZ_NAME_2> +eval SET TIME_ZONE= '$tz_name'; + +SET GLOBAL EVENT_SCHEDULER= ON; + +let $now= `SELECT @now`; +--disable_query_log +eval CREATE EVENT e1 ON SCHEDULE EVERY 1 MONTH + STARTS FROM_UNIXTIME($now - @step) DO + INSERT INTO t1 VALUES + ("e1", NOW(), round_to_step(UNIX_TIMESTAMP() - $now, 4) - 1); +eval CREATE EVENT e2 ON SCHEDULE EVERY 1 MONTH + STARTS FROM_UNIXTIME($now + @step) DO + INSERT INTO t1 VALUES + ("e2", NOW(), round_to_step(UNIX_TIMESTAMP() - $now, 4) - 1); +--enable_query_log + +let $wait_timeout= `SELECT 16 * @step`; +let $wait_condition= SELECT COUNT(*) = 7 FROM t1; +--source include/wait_condition.inc + +SET GLOBAL EVENT_SCHEDULER= OFF; + +--echo Below we should see the following: +--echo - On Jan 31 only e2 is executed, because we started later than +--echo e1 should have been executed. Offset of e2 is 0 because of +--echo the late start, not 1. +--echo - The next execution is on Feb 28 (last day of Feb). Both events +--echo are executed in their times, offsets are -1 and 1. +--echo - The next time is Mar 31. Because the time of event +--echo execution was skipped over, events are executed right away, +--echo offsets are 2 and 2. +--echo - The next time is Apr 30. Events are again executed in their +--echo appointed times, offsets are -1 and 1. +SELECT * FROM t1 ORDER BY dt, event; + +DROP EVENT e2; +DROP EVENT e1; +DROP TABLE t1; + +SET TIME_ZONE= @save_time_zone; + +DELETE FROM mysql.time_zone_name WHERE time_zone_id = @tzid; +DELETE FROM mysql.time_zone_transition_type WHERE time_zone_id = @tzid; +DELETE FROM mysql.time_zone_transition WHERE time_zone_id = @tzid; +DELETE FROM mysql.time_zone WHERE time_zone_id = @tzid; +let $time_zone_auto_inc = `SELECT MAX(Time_zone_id) + 1 FROM mysql.time_zone`; +eval ALTER TABLE mysql.time_zone AUTO_INCREMENT = $time_zone_auto_inc; + +DROP FUNCTION round_to_step; +DROP TABLE t_step; + + +DROP DATABASE mysqltest_db1; +--disable_query_log +eval USE $old_db; + +--enable_query_log +let $wait_condition= + SELECT COUNT(*) = 0 FROM information_schema.processlist + WHERE db='mysqltest_db1' AND command = 'Connect' AND user=current_user(); +--source include/wait_condition.inc + +--echo End of 5.1 tests. diff --git a/mysql-test/t/events_trans.test b/mysql-test/t/events_trans.test new file mode 100644 index 00000000000..a94b75bb812 --- /dev/null +++ b/mysql-test/t/events_trans.test @@ -0,0 +1,123 @@ +# +# Tests that require transactions +# +-- source include/have_innodb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop database if exists events_test; +drop database if exists mysqltest_no_such_database; +--enable_warnings +create database events_test; +use events_test; + +--echo +--echo Test that Events DDL issue an implicit COMMIT +--echo +--echo +set autocommit=off; +# Sanity check +select @@autocommit; +create table t1 (a varchar(255)) engine=innodb; +# Basic: check that successful Events DDL commits pending transaction +begin work; +insert into t1 (a) values ("OK: create event"); +create event e1 on schedule every 1 day do select 1; +rollback work; +select * from t1; +delete from t1; +commit work; +# +begin work; +insert into t1 (a) values ("OK: alter event"); +alter event e1 on schedule every 2 day do select 2; +rollback work; +select * from t1; +delete from t1; +commit work; +# +begin work; +insert into t1 (a) values ("OK: alter event rename"); +alter event e1 rename to e2; +rollback work; +select * from t1; +delete from t1; +commit work; +# +begin work; +insert into t1 (a) values ("OK: drop event"); +drop event e2; +rollback work; +select * from t1; +delete from t1; +commit work; +# +begin work; +insert into t1 (a) values ("OK: drop event if exists"); +drop event if exists e2; +rollback work; +select * from t1; +delete from t1; +commit work; +# +create event e1 on schedule every 1 day do select 1; +begin work; +insert into t1 (a) values ("OK: create event if not exists"); +create event if not exists e1 on schedule every 2 day do select 2; +rollback work; +select * from t1; +delete from t1; +commit work; +--echo +--echo Now check various error conditions: make sure we issue an +--echo implicit commit anyway +--echo +# +begin work; +insert into t1 (a) values ("OK: create event: event already exists"); +--error ER_EVENT_ALREADY_EXISTS +create event e1 on schedule every 2 day do select 2; +rollback work; +select * from t1; +delete from t1; +commit work; +# +begin work; +insert into t1 (a) values ("OK: alter event rename: rename to same name"); +--error ER_EVENT_SAME_NAME +alter event e1 rename to e1; +rollback work; +select * from t1; +delete from t1; +commit work; +# +create event e2 on schedule every 3 day do select 3; +begin work; +insert into t1 (a) values ("OK: alter event rename: destination exists"); +--error ER_EVENT_ALREADY_EXISTS +alter event e2 rename to e1; +rollback work; +select * from t1; +delete from t1; +commit work; +# +begin work; +insert into t1 (a) values ("OK: create event: database does not exist"); +--error ER_BAD_DB_ERROR +create event mysqltest_no_such_database.e1 on schedule every 1 day do select 1; +rollback work; +select * from t1; +delete from t1; +commit work; + +# +# Cleanup +# + +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where db='events_test' and command = 'Connect' and user=current_user(); +--source include/wait_condition.inc + +drop database events_test; + diff --git a/mysql-test/t/events_trans_notembedded.test b/mysql-test/t/events_trans_notembedded.test new file mode 100644 index 00000000000..0353d183386 --- /dev/null +++ b/mysql-test/t/events_trans_notembedded.test @@ -0,0 +1,67 @@ +# +# Tests that require transactions +# +-- source include/not_embedded.inc +-- source include/have_innodb.inc +--disable_warnings +drop database if exists events_test; +drop database if exists mysqltest_db2; +--enable_warnings +create database events_test; +use events_test; + +# +# Privilege checks +# +grant create, insert, select, delete on mysqltest_db2.* + to mysqltest_user1@localhost; +create database mysqltest_db2; +connect (conn1,localhost,mysqltest_user1,,mysqltest_db2); +set autocommit=off; +# Sanity check +select @@autocommit; +create table t1 (a varchar(255)) engine=innodb; +# Not enough privileges to CREATE EVENT +begin work; +insert into t1 (a) values ("OK: create event: insufficient privileges"); +--error ER_DBACCESS_DENIED_ERROR +create event e1 on schedule every 1 day do select 1; +rollback work; +select * from t1; +delete from t1; +commit work; +# Not enough privileges to ALTER EVENT +begin work; +insert into t1 (a) values ("OK: alter event: insufficient privileges"); +--error ER_DBACCESS_DENIED_ERROR +alter event e1 on schedule every 1 day do select 1; +rollback work; +select * from t1; +delete from t1; +commit work; +# Not enough privileges to DROP EVENT +begin work; +insert into t1 (a) values ("OK: drop event: insufficient privileges"); +--error ER_DBACCESS_DENIED_ERROR +drop event e1; +rollback work; +select * from t1; +delete from t1; +commit work; +# Cleanup +disconnect conn1; +--source include/wait_until_disconnected.inc +connection default; +drop user mysqltest_user1@localhost; +drop database mysqltest_db2; + +# +# Cleanup +# +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where db='events_test' and command = 'Connect' and user=current_user(); +--source include/wait_condition.inc + +drop database events_test; + diff --git a/mysql-test/t/exampledb.test b/mysql-test/t/exampledb.test index 946d25325dc..fbb2a18f344 100644 --- a/mysql-test/t/exampledb.test +++ b/mysql-test/t/exampledb.test @@ -5,6 +5,10 @@ -- source include/have_exampledb.inc --disable_warnings +# Clean up if event's test fails +drop database if exists events_test; +drop database if exists events_test2; + drop table if exists t1; --enable_warnings diff --git a/mysql-test/t/execution_constants.test b/mysql-test/t/execution_constants.test index 4930164d3fa..e61d79f5249 100644 --- a/mysql-test/t/execution_constants.test +++ b/mysql-test/t/execution_constants.test @@ -41,12 +41,19 @@ while ($i) error 0,1436 // eval $query_head 0 $query_tail// - if ($mysql_errno != 1436) + if ($mysql_errno) { # We reached the place where we reported an error about the stack limit, # and we successfully returned the error. That means that at the stack # limit, we still have enough space reserved to report an error. let $i = 1// + + # Check that mysql_errno is 1436 + if (`select $mysql_errno != 1436`) + { + die Wrong error triggered, expected 1436 but got $mysql_errno// + } + } # Multiplying by three stack frames should be fine enough resolution. diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index 7b7bdd3563c..18f1145a25d 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -148,3 +148,23 @@ EXPLAIN SELECT DISTINCT 1 FROM t1, DROP TABLE t1; # End of 5.0 tests. + +--echo # +--echo # Bug#37870: Usage of uninitialized value caused failed assertion. +--echo # +create table t1 (dt datetime not null, t time not null); +create table t2 (dt datetime not null); +insert into t1 values ('2001-01-01 1:1:1', '1:1:1'), +('2001-01-01 1:1:1', '1:1:1'); +insert into t2 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1'); +flush tables; +EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); +flush tables; +SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); +flush tables; +EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' ); +flush tables; +SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' ); +drop tables t1, t2; + +--echo End of 5.1 tests. diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test deleted file mode 100644 index ee9d1981558..00000000000 --- a/mysql-test/t/federated.test +++ /dev/null @@ -1,1877 +0,0 @@ -# Note: This test is tricky. It reuses the prerequisites generated for -# replication tests (master+slave server and connections) for its -# own purposes. But the replication feature itself is stopped. -# - - ---source include/federated.inc - -connection default; - -# Disable concurrent inserts to avoid test failures when reading -# data from concurrent connections (insert might return before -# the data is actually in the table). -SET @OLD_MASTER_CONCURRENT_INSERT= @@GLOBAL.CONCURRENT_INSERT; -SET @@GLOBAL.CONCURRENT_INSERT= 0; - -connection slave; -SET @OLD_SLAVE_CONCURRENT_INSERT= @@GLOBAL.CONCURRENT_INSERT; -SET @@GLOBAL.CONCURRENT_INSERT= 0; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL, - `name` varchar(32) NOT NULL default '' - ) - DEFAULT CHARSET=latin1; - -connection master; -DROP TABLE IF EXISTS federated.t1; -# test too many items (malformed) in the comment string url ---error ER_FOREIGN_DATA_STRING_INVALID_CANT_CREATE -CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL, - `name` varchar(32) NOT NULL default '' - ) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:@/too/many/items/federated/t1'; - -# test not enough items (malformed) in the comment string url ---error ER_FOREIGN_DATA_STRING_INVALID_CANT_CREATE -CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL, - `name` varchar(32) NOT NULL default '' - ) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1'; - -# test non-existant table ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL, - `name` varchar(32) NOT NULL default '' - ) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t3'; ---error ER_FOREIGN_DATA_SOURCE_DOESNT_EXIST -SELECT * FROM federated.t1; -DROP TABLE federated.t1; - -# test bad user/password ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL, - `name` varchar(32) NOT NULL default '' - ) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://user:pass@127.0.0.1:$SLAVE_MYPORT/federated/t1'; ---error ER_CONNECT_TO_FOREIGN_DATA_SOURCE -SELECT * FROM federated.t1; -DROP TABLE federated.t1; - -# # correct connection, same named tables ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL, - `name` varchar(32) NOT NULL default '' - ) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 (id, name) VALUES (1, 'foo'); -INSERT INTO federated.t1 (id, name) VALUES (2, 'fee'); - ---sorted_result -SELECT * FROM federated.t1; -DELETE FROM federated.t1; -DROP TABLE federated.t1; - -# correct connection, differently named tables -DROP TABLE IF EXISTS federated.t2; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t2 ( - `id` int(20) NOT NULL, - `name` varchar(32) NOT NULL default '' - ) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval SHOW CREATE TABLE federated.t2; - -INSERT INTO federated.t2 (id, name) VALUES (1, 'foo'); -INSERT INTO federated.t2 (id, name) VALUES (2, 'fee'); - -SELECT * FROM federated.t2 ORDER BY id, name; -DROP TABLE federated.t2; - -connection slave; -DROP TABLE IF EXISTS federated.t1; - -DROP TABLE IF EXISTS federated.`t1%`; -CREATE TABLE federated.`t1%` ( - `id` int(20) NOT NULL, - `name` varchar(32) NOT NULL default '' - ) - DEFAULT CHARSET=latin1; - -connection master; -DROP TABLE IF EXISTS federated.t1; - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL, - `name` varchar(32) NOT NULL default '' - ) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1%'; - -INSERT INTO federated.t1 (id, name) VALUES (1, 'foo'); -INSERT INTO federated.t1 (id, name) VALUES (2, 'fee'); - -SELECT * FROM federated.t1 ORDER BY id,name; -DELETE FROM federated.t1; -DROP TABLE IF EXISTS federated.t1; - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.`t1%` ( - `id` int(20) NOT NULL, - `name` varchar(32) NOT NULL default '' - ) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1%'; - -INSERT INTO federated.`t1%` (id, name) VALUES (1, 'foo'); -INSERT INTO federated.`t1%` (id, name) VALUES (2, 'fee'); - -SELECT * FROM federated.`t1%` ORDER BY id, name; -DELETE FROM federated.`t1%`; -DROP TABLE IF EXISTS federated.`t1%`; - -connection slave; -DROP TABLE IF EXISTS federated.`t1%`; - -# I wanted to use timestamp, but results will fail if so!!! -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - `name` varchar(32) NOT NULL default '', - `other` int(20) NOT NULL default '0', - `created` datetime default '2004-04-04 04:04:04', - PRIMARY KEY (`id`)) - DEFAULT CHARSET=latin1; - -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - `name` varchar(32) NOT NULL default '', - `other` int(20) NOT NULL default '0', - `created` datetime default '2004-04-04 04:04:04', - PRIMARY KEY (`id`)) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 (name, other) VALUES ('First Name', 11111); -INSERT INTO federated.t1 (name, other) VALUES ('Second Name', 22222); -INSERT INTO federated.t1 (name, other) VALUES ('Third Name', 33333); -INSERT INTO federated.t1 (name, other) VALUES ('Fourth Name', 44444); -INSERT INTO federated.t1 (name, other) VALUES ('Fifth Name', 55555); -INSERT INTO federated.t1 (name, other) VALUES ('Sixth Name', 66666); -INSERT INTO federated.t1 (name, other) VALUES ('Seventh Name', 77777); -INSERT INTO federated.t1 (name, other) VALUES ('Eigth Name', 88888); -INSERT INTO federated.t1 (name, other) VALUES ('Ninth Name', 99999); -INSERT INTO federated.t1 (name, other) VALUES ('Tenth Name', 101010); - -# basic select ---sorted_result -SELECT * FROM federated.t1; -# with PRIMARY KEY index_read_idx -SELECT * FROM federated.t1 WHERE id = 5; -SELECT * FROM federated.t1 WHERE name = 'Sixth Name'; -SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; -SELECT * FROM federated.t1 WHERE name = 'Sixth Name' AND other = 44444; ---sorted_result -SELECT * FROM federated.t1 WHERE name like '%th%'; -UPDATE federated.t1 SET name = '3rd name' WHERE id = 3; -SELECT * FROM federated.t1 WHERE name = '3rd name'; -UPDATE federated.t1 SET name = 'Third name' WHERE name = '3rd name'; -SELECT * FROM federated.t1 WHERE name = 'Third name'; -# rnd_post, ::position -SELECT * FROM federated.t1 ORDER BY id DESC; -SELECT * FROM federated.t1 ORDER BY name; -SELECT * FROM federated.t1 ORDER BY name DESC; -SELECT * FROM federated.t1 ORDER BY name ASC; -SELECT * FROM federated.t1 GROUP BY other; - -# ::delete_row -DELETE FROM federated.t1 WHERE id = 5; -SELECT * FROM federated.t1 WHERE id = 5; - -# ::delete_all_rows -DELETE FROM federated.t1; -SELECT * FROM federated.t1 WHERE id = 5; - -# previous test, but this time with indexes -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - `name` varchar(32) NOT NULL default '', - `other` int(20) NOT NULL default '0', - `created` datetime NOT NULL, - PRIMARY KEY (`id`), - key name(`name`), - key other(`other`), - key created(`created`)) - DEFAULT CHARSET=latin1; - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - `name` varchar(32) NOT NULL default '', - `other` int(20) NOT NULL default '0', - `created` datetime NOT NULL, - PRIMARY KEY (`id`), - key name(`name`), - key other(`other`), - key created(`created`)) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 (name, other, created) - VALUES ('First Name', 11111, '2004-01-01 01:01:01'); -INSERT INTO federated.t1 (name, other, created) - VALUES ('Second Name', 22222, '2004-01-23 02:43:00'); -INSERT INTO federated.t1 (name, other, created) - VALUES ('Third Name', 33333, '2004-02-14 02:14:00'); -INSERT INTO federated.t1 (name, other, created) - VALUES ('Fourth Name', 44444, '2003-04-05 00:00:00'); -INSERT INTO federated.t1 (name, other, created) - VALUES ('Fifth Name', 55555, '2001-02-02 02:02:02'); -INSERT INTO federated.t1 (name, other, created) - VALUES ('Sixth Name', 66666, '2005-06-06 15:30:00'); -INSERT INTO federated.t1 (name, other, created) - VALUES ('Seventh Name', 77777, '2003-12-12 18:32:00'); -INSERT INTO federated.t1 (name, other, created) - VALUES ('Eigth Name', 88888, '2005-03-12 11:00:00'); -INSERT INTO federated.t1 (name, other, created) - VALUES ('Ninth Name', 99999, '2005-03-12 11:00:01'); -INSERT INTO federated.t1 (name, other, created) - VALUES ('Tenth Name', 101010, '2005-03-12 12:00:01'); - -# basic select ---sorted_result -SELECT * FROM federated.t1; -# with PRIMARY KEY index_read_idx -SELECT * FROM federated.t1 WHERE id = 5; -# with regular key index_read -> index_read_idx -# regular and PRIMARY KEY index_read_idx -SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; -# with regular key index_read -> index_read_idx -SELECT * FROM federated.t1 WHERE other = 44444; ---sorted_result -SELECT * FROM federated.t1 WHERE name like '%th%'; -# update - update_row, index_read_idx -UPDATE federated.t1 SET name = '3rd name' WHERE id = 3; -SELECT * FROM federated.t1 WHERE name = '3rd name'; -# update - update_row, index_read -> index_read_idx -UPDATE federated.t1 SET name = 'Third name' WHERE name = '3rd name'; -SELECT * FROM federated.t1 WHERE name = 'Third name'; -# rnd_post, ::position -SELECT * FROM federated.t1 ORDER BY id DESC; -SELECT * FROM federated.t1 ORDER BY name; -SELECT * FROM federated.t1 ORDER BY name DESC; -SELECT * FROM federated.t1 ORDER BY name ASC; -SELECT * FROM federated.t1 GROUP BY other; - -# ::delete_row -DELETE FROM federated.t1 WHERE id = 5; -SELECT * FROM federated.t1 WHERE id = 5; - -# ::delete_all_rows -DELETE FROM federated.t1; -SELECT * FROM federated.t1 WHERE id = 5; -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - `name` varchar(32), - `other` varchar(20), - PRIMARY KEY (`id`) ); - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - `name` varchar(32), - `other` varchar(20), - PRIMARY KEY (`id`) ) - ENGINE="FEDERATED" - DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 (name, other) VALUES ('First Name', 11111); -INSERT INTO federated.t1 (name, other) VALUES ('Second Name', NULL); -INSERT INTO federated.t1 (name, other) VALUES ('Third Name', 33333); -INSERT INTO federated.t1 (name, other) VALUES (NULL, NULL); -INSERT INTO federated.t1 (name, other) VALUES ('Fifth Name', 55555); -INSERT INTO federated.t1 (name, other) VALUES ('Sixth Name', 66666); -INSERT INTO federated.t1 (name) VALUES ('Seventh Name'); -INSERT INTO federated.t1 (name, other) VALUES ('Eigth Name', 88888); -INSERT INTO federated.t1 (name, other) VALUES ('Ninth Name', 99999); -INSERT INTO federated.t1 (other) VALUES ('fee fie foe fum'); - ---sorted_result -SELECT * FROM federated.t1 WHERE other IS NULL; ---sorted_result -SELECT * FROM federated.t1 WHERE name IS NULL; -SELECT * FROM federated.t1 WHERE name IS NULL and other IS NULL; ---sorted_result -SELECT * FROM federated.t1 WHERE name IS NULL or other IS NULL; - -UPDATE federated.t1 -SET name = 'Fourth Name', other = 'four four four' -WHERE name IS NULL AND other IS NULL; - -UPDATE federated.t1 SET other = 'two two two two' WHERE name = 'Second Name'; -UPDATE federated.t1 SET other = 'seven seven' WHERE name like 'Sev%'; -UPDATE federated.t1 SET name = 'Tenth Name' WHERE other like 'fee fie%'; -SELECT * FROM federated.t1 WHERE name IS NULL OR other IS NULL ; ---sorted_result -SELECT * FROM federated.t1; - -# test multi-keys -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - `name` varchar(32) NOT NULL DEFAULT '', - `other` varchar(20) NOT NULL DEFAULT '', - PRIMARY KEY (`id`), - KEY nameoth (name, other) ); - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - `name` varchar(32) NOT NULL DEFAULT '', - `other` varchar(20) NOT NULL DEFAULT '', - PRIMARY KEY (`id`), - KEY nameoth (name, other)) - ENGINE="FEDERATED" DEFAULT - CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 (name, other) VALUES ('First Name', '1111'); -INSERT INTO federated.t1 (name, other) VALUES ('Second Name', '2222'); -INSERT INTO federated.t1 (name, other) VALUES ('Third Name', '3333'); -SELECT * FROM federated.t1 WHERE name = 'Second Name'; -SELECT * FROM federated.t1 WHERE other = '2222'; -SELECT * FROM federated.t1 WHERE name = 'Third Name'; -SELECT * FROM federated.t1 WHERE name = 'Third Name' AND other = '3333'; - -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `id` int NOT NULL auto_increment, - `name` char(32) NOT NULL DEFAULT '', - `bincol` binary(1) NOT NULL, - `floatval` decimal(5,2) NOT NULL DEFAULT 0.0, - `other` int NOT NULL DEFAULT 0, - PRIMARY KEY (id), - KEY nameoth(name, other), - KEY bincol(bincol), - KEY floatval(floatval)); - -# test other types of indexes -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int NOT NULL auto_increment, - `name` char(32) NOT NULL DEFAULT '', - `bincol` binary(1) NOT NULL, - `floatval` decimal(5,2) NOT NULL DEFAULT 0.0, - `other` int NOT NULL DEFAULT 0, - PRIMARY KEY (id), - KEY nameoth(name,other), - KEY bincol(bincol), - KEY floatval(floatval)) - ENGINE="FEDERATED" - DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 (name, bincol, floatval, other) - VALUES ('first', 0x65, 11.11, 1111); -INSERT INTO federated.t1 (name, bincol, floatval, other) - VALUES ('second', 0x66, 22.22, 2222); -INSERT INTO federated.t1 (name, bincol, floatval, other) - VALUES ('third', 'g', 22.22, 2222); ---sorted_result -SELECT * FROM federated.t1; -SELECT * FROM federated.t1 WHERE name = 'second'; -SELECT * FROM federated.t1 WHERE bincol= 'f'; -SELECT * FROM federated.t1 WHERE bincol= 0x66; -SELECT * FROM federated.t1 WHERE bincol= 0x67; -SELECT * FROM federated.t1 WHERE bincol= 'g'; -SELECT * FROM federated.t1 WHERE floatval=11.11; -SELECT * FROM federated.t1 WHERE name='third'; ---sorted_result -SELECT * FROM federated.t1 WHERE other=2222; -SELECT * FROM federated.t1 WHERE name='third' and other=2222; - -# more multi-column indexes, in the primary key -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `id` int NOT NULL auto_increment, - `col1` int(10) NOT NULL DEFAULT 0, - `col2` varchar(64) NOT NULL DEFAULT '', - `col3` int(20) NOT NULL, - `col4` int(40) NOT NULL, - primary key (`id`, `col1`, `col2`, `col3`, `col4`), - key col1(col1), - key col2(col2), - key col3(col3), - key col4(col4)); - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int NOT NULL auto_increment, - `col1` int(10) NOT NULL DEFAULT 0, - `col2` varchar(64) NOT NULL DEFAULT '', - `col3` int(20) NOT NULL, - `col4` int(40) NOT NULL, - primary key (`id`, `col1`, `col2`, `col3`, `col4`), - key col1(col1), - key col2(col2), - key col3(col3), - key col4(col4)) - ENGINE="FEDERATED" - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES (1, 'one One', 11, 1111); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES (2, 'Two two', 22, 2222); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES (3, 'three Three', 33, 33333); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES (4, 'fourfourfour', 444, 4444444); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES (5, 'five 5 five five 5', 5, 55555); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES (6, 'six six Sixsix', 6666, 6); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES (7, 'seven Sevenseven', 77777, 7777); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES (8, 'eight eight eight', 88888, 88); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES (9, 'nine Nine', 999999, 999999); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES (10, 'Tenth ten TEN', 1010101, 1010); - -SELECT * FROM federated.t1 WHERE col2 = 'two two'; -SELECT * FROM federated.t1 WHERE col2 = 'two Two'; -SELECT * FROM federated.t1 WHERE id = 3; -SELECT * FROM federated.t1 WHERE id = 3 AND col1 = 3; -SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'Two two'; -SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'fourfourfour'; -SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' - AND col3 = 5; -SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' - AND col3 = 5 - AND col4 = 55555; -SELECT * FROM federated.t1 WHERE id = 5 - AND col2 = 'Two two' AND col3 = 22 - AND col4 = 33; -SELECT * FROM federated.t1 WHERE id = 5 - AND col2 = 'five 5 five five 5' AND col3 = 5 - AND col4 = 55555; ---sorted_result -SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'five 5 five five 5') - OR (col2 = 'three Three' AND col3 = 33); -SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'Two two') - OR (col2 = 444 AND col3 = 4444444); ---sorted_result -SELECT * FROM federated.t1 WHERE id = 1 - OR col1 = 10 - OR col2 = 'Two two' - OR col3 = 33 - OR col4 = 4444444; ---sorted_result -SELECT * FROM federated.t1 WHERE id > 5; ---sorted_result -SELECT * FROM federated.t1 WHERE id >= 5; ---sorted_result -SELECT * FROM federated.t1 WHERE id < 5; ---sorted_result -SELECT * FROM federated.t1 WHERE id <= 5; ---sorted_result -SELECT * FROM federated.t1 WHERE id != 5; ---sorted_result -SELECT * FROM federated.t1 WHERE id > 3 AND id < 7; ---sorted_result -SELECT * FROM federated.t1 WHERE id > 3 AND id <= 7; ---sorted_result -SELECT * FROM federated.t1 WHERE id >= 3 AND id <= 7; -SELECT * FROM federated.t1 WHERE id < 3 AND id <= 7; -SELECT * FROM federated.t1 WHERE id < 3 AND id > 7; ---sorted_result -SELECT * FROM federated.t1 WHERE id < 3 OR id > 7; -SELECT * FROM federated.t1 WHERE col2 = 'three Three'; ---sorted_result -SELECT * FROM federated.t1 WHERE col2 > 'one'; ---sorted_result -SELECT * FROM federated.t1 WHERE col2 LIKE 's%'; -SELECT * FROM federated.t1 WHERE col2 LIKE 'si%'; -SELECT * FROM federated.t1 WHERE col2 LIKE 'se%'; ---sorted_result -SELECT * FROM federated.t1 WHERE col2 NOT LIKE 'e%'; ---sorted_result -SELECT * FROM federated.t1 WHERE col2 <> 'one One'; - -# more multi-column indexes, in the primary key -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `col1` varchar(8) NOT NULL DEFAULT '', - `col2` varchar(128) NOT NULL DEFAULT '', - `col3` varchar(20) NOT NULL DEFAULT '', - `col4` varchar(40) NOT NULL DEFAULT '', - primary key (`col1`, `col2`, `col3`, `col4`), - key 3key(`col2`,`col3`,`col4`), - key 2key (`col3`,`col4`), - key col4(col4)); - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `col1` varchar(8) NOT NULL DEFAULT '', - `col2` varchar(128) NOT NULL DEFAULT '', - `col3` varchar(20) NOT NULL DEFAULT '', - `col4` varchar(40) NOT NULL DEFAULT '', - primary key (`col1`, `col2`, `col3`, `col4`), - key 3key(`col2`,`col3`,`col4`), - key 2key (`col3`,`col4`), - key col4(col4)) - ENGINE="FEDERATED" - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES ('aaaa', 'aaaaaaaaaaaaaaaaaaa', 'ababababab', 'acacacacacacacac'); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES ('bbbb', 'bbbbbbbbbbbbbbbbbbb', 'bababababa', 'bcbcbcbcbcbcbcbc'); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES ('cccc', 'ccccccccccccccccccc', 'cacacacaca', 'cbcbcbcbcbcbcbcb'); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES ('dddd', 'ddddddddddddddddddd', 'dadadadada', 'dcdcdcdcdcdcdcdc'); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES ('eeee', 'eeeeeeeeeeeeeeeeeee', 'eaeaeaeaea', 'ecececececececec'); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES ('ffff', 'fffffffffffffffffff', 'fafafafafa', 'fcfcfcfcfcfcfcfc'); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES ('gggg', 'ggggggggggggggggggg', 'gagagagaga', 'gcgcgcgcgcgcgcgc'); -INSERT INTO federated.t1 (col1, col2, col3, col4) - VALUES ('hhhh', 'hhhhhhhhhhhhhhhhhhh', 'hahahahaha', 'hchchchchchchchc'); - -SELECT * FROM federated.t1 WHERE col1 = 'cccc'; -SELECT * FROM federated.t1 WHERE col2 = 'eeeeeeeeeeeeeeeeeee'; -SELECT * FROM federated.t1 WHERE col3 = 'bababababa'; -SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col2 = 'ggggggggggggggggggg'; -SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col3 = 'gagagagaga'; -SELECT * FROM federated.t1 WHERE col1 = 'ffff' AND col4 = 'fcfcfcfcfcfcfcfc'; ---sorted_result -SELECT * FROM federated.t1 WHERE col1 > 'bbbb'; ---sorted_result -SELECT * FROM federated.t1 WHERE col1 >= 'bbbb'; -SELECT * FROM federated.t1 WHERE col1 < 'bbbb'; ---sorted_result -SELECT * FROM federated.t1 WHERE col1 <= 'bbbb'; ---sorted_result -SELECT * FROM federated.t1 WHERE col1 <> 'bbbb'; -SELECT * FROM federated.t1 WHERE col1 LIKE 'b%'; ---sorted_result -SELECT * FROM federated.t1 WHERE col4 LIKE '%b%'; ---sorted_result -SELECT * FROM federated.t1 WHERE col1 NOT LIKE 'c%'; -SELECT * FROM federated.t1 WHERE col4 NOT LIKE '%c%'; -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `col1` varchar(8) NOT NULL DEFAULT '', - `col2` int(8) NOT NULL DEFAULT 0, - `col3` varchar(8) NOT NULL DEFAULT '', - primary key (`col1`, `col2`, `col3`)); - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `col1` varchar(8) NOT NULL DEFAULT '', - `col2` varchar(8) NOT NULL DEFAULT '', - `col3` varchar(8) NOT NULL DEFAULT '', - primary key (`col1`, `col2`, `col3`)) - ENGINE="FEDERATED" - DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 VALUES ('a00', '110', 'cc0'); -INSERT INTO federated.t1 VALUES ('aaa', '111', 'ccc'); -INSERT INTO federated.t1 VALUES ('bbb', '222', 'yyy'); -INSERT INTO federated.t1 VALUES ('ccc', '111', 'zzz'); -INSERT INTO federated.t1 VALUES ('ccd', '112', 'zzzz'); - -# let's see what the foreign database says -connection slave; ---sorted_result -SELECT col3 FROM federated.t1 WHERE ( -(col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND -(col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); - -connection master; ---sorted_result -SELECT col3 FROM federated.t1 WHERE ( -(col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND -(col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); - -# test NULLs -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `id` int, - `name` varchar(32), - `floatval` float, - `other` int) -DEFAULT CHARSET=latin1; - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int, - `name` varchar(32), - `floatval` float, - `other` int) -ENGINE="FEDERATED" -DEFAULT CHARSET=latin1 -CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -# these both should be the same -INSERT INTO federated.t1 values (NULL, NULL, NULL, NULL); -INSERT INTO federated.t1 values (); -INSERT INTO federated.t1 (id) VALUES (1); -INSERT INTO federated.t1 (name, floatval, other) - VALUES ('foo', 33.33333332, NULL); -INSERT INTO federated.t1 (name, floatval, other) - VALUES (0, 00.3333, NULL); ---sorted_result -SELECT * FROM federated.t1; -SELECT count(*) FROM federated.t1 -WHERE id IS NULL -AND name IS NULL -AND floatval IS NULL -AND other IS NULL; - -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `blurb_id` int NOT NULL DEFAULT 0, - `blurb` text default '', - PRIMARY KEY (blurb_id)) - DEFAULT CHARSET=latin1; - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `blurb_id` int NOT NULL DEFAULT 0, - `blurb` text default '', - PRIMARY KEY (blurb_id)) - ENGINE="FEDERATED" - DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 VALUES (1, " MySQL supports a number of column types in several categories: numeric types, date and time types, and string (character) types. This chapter first gives an overview of these column types, and then provides a more detailed description of the properties of the types in each category, and a summary of the column type storage requirements. The overview is intentionally brief. The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values."); -INSERT INTO federated.t1 VALUES (2, "All arithmetic is done using signed BIGINT or DOUBLE values, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting a BIGINT value to a DOUBLE."); -INSERT INTO federated.t1 VALUES (3, " A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display size and number of decimals are undefined. "); -INSERT INTO federated.t1 VALUES(4, "Die Übersetzung einer so umfangreichen technischen Dokumentation wie des MySQL-Referenzhandbuchs ist schon eine besondere Herausforderung. Zumindest für jemanden, der seine Zielsprache ernst nimmt:"); ---sorted_result -SELECT * FROM federated.t1; - -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `a` int NOT NULL, - `b` int NOT NULL, - `c` int NOT NULL, - PRIMARY KEY (a),key(b)); - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `a` int NOT NULL, - `b` int NOT NULL, - `c` int NOT NULL, - PRIMARY KEY (a), - KEY (b)) - ENGINE="FEDERATED" - DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 VALUES (3,3,3),(1,1,1),(2,2,2),(4,4,4); - -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8 -int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17 -int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int, -i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34 -int, i35 int, i36 int, i37 int, i38 int, i39 int, i40 int, i41 int, i42 int, -i43 int, i44 int, i45 int, i46 int, i47 int, i48 int, i49 int, i50 int, i51 -int, i52 int, i53 int, i54 int, i55 int, i56 int, i57 int, i58 int, i59 int, -i60 int, i61 int, i62 int, i63 int, i64 int, i65 int, i66 int, i67 int, i68 -int, i69 int, i70 int, i71 int, i72 int, i73 int, i74 int, i75 int, i76 int, -i77 int, i78 int, i79 int, i80 int, i81 int, i82 int, i83 int, i84 int, i85 -int, i86 int, i87 int, i88 int, i89 int, i90 int, i91 int, i92 int, i93 int, -i94 int, i95 int, i96 int, i97 int, i98 int, i99 int, i100 int, i101 int, i102 -int, i103 int, i104 int, i105 int, i106 int, i107 int, i108 int, i109 int, i110 -int, i111 int, i112 int, i113 int, i114 int, i115 int, i116 int, i117 int, i118 -int, i119 int, i120 int, i121 int, i122 int, i123 int, i124 int, i125 int, i126 -int, i127 int, i128 int, i129 int, i130 int, i131 int, i132 int, i133 int, i134 -int, i135 int, i136 int, i137 int, i138 int, i139 int, i140 int, i141 int, i142 -int, i143 int, i144 int, i145 int, i146 int, i147 int, i148 int, i149 int, i150 -int, i151 int, i152 int, i153 int, i154 int, i155 int, i156 int, i157 int, i158 -int, i159 int, i160 int, i161 int, i162 int, i163 int, i164 int, i165 int, i166 -int, i167 int, i168 int, i169 int, i170 int, i171 int, i172 int, i173 int, i174 -int, i175 int, i176 int, i177 int, i178 int, i179 int, i180 int, i181 int, i182 -int, i183 int, i184 int, i185 int, i186 int, i187 int, i188 int, i189 int, i190 -int, i191 int, i192 int, i193 int, i194 int, i195 int, i196 int, i197 int, i198 -int, i199 int, i200 int, i201 int, i202 int, i203 int, i204 int, i205 int, i206 -int, i207 int, i208 int, i209 int, i210 int, i211 int, i212 int, i213 int, i214 -int, i215 int, i216 int, i217 int, i218 int, i219 int, i220 int, i221 int, i222 -int, i223 int, i224 int, i225 int, i226 int, i227 int, i228 int, i229 int, i230 -int, i231 int, i232 int, i233 int, i234 int, i235 int, i236 int, i237 int, i238 -int, i239 int, i240 int, i241 int, i242 int, i243 int, i244 int, i245 int, i246 -int, i247 int, i248 int, i249 int, i250 int, i251 int, i252 int, i253 int, i254 -int, i255 int, i256 int, i257 int, i258 int, i259 int, i260 int, i261 int, i262 -int, i263 int, i264 int, i265 int, i266 int, i267 int, i268 int, i269 int, i270 -int, i271 int, i272 int, i273 int, i274 int, i275 int, i276 int, i277 int, i278 -int, i279 int, i280 int, i281 int, i282 int, i283 int, i284 int, i285 int, i286 -int, i287 int, i288 int, i289 int, i290 int, i291 int, i292 int, i293 int, i294 -int, i295 int, i296 int, i297 int, i298 int, i299 int, i300 int, i301 int, i302 -int, i303 int, i304 int, i305 int, i306 int, i307 int, i308 int, i309 int, i310 -int, i311 int, i312 int, i313 int, i314 int, i315 int, i316 int, i317 int, i318 -int, i319 int, i320 int, i321 int, i322 int, i323 int, i324 int, i325 int, i326 -int, i327 int, i328 int, i329 int, i330 int, i331 int, i332 int, i333 int, i334 -int, i335 int, i336 int, i337 int, i338 int, i339 int, i340 int, i341 int, i342 -int, i343 int, i344 int, i345 int, i346 int, i347 int, i348 int, i349 int, i350 -int, i351 int, i352 int, i353 int, i354 int, i355 int, i356 int, i357 int, i358 -int, i359 int, i360 int, i361 int, i362 int, i363 int, i364 int, i365 int, i366 -int, i367 int, i368 int, i369 int, i370 int, i371 int, i372 int, i373 int, i374 -int, i375 int, i376 int, i377 int, i378 int, i379 int, i380 int, i381 int, i382 -int, i383 int, i384 int, i385 int, i386 int, i387 int, i388 int, i389 int, i390 -int, i391 int, i392 int, i393 int, i394 int, i395 int, i396 int, i397 int, i398 -int, i399 int, i400 int, i401 int, i402 int, i403 int, i404 int, i405 int, i406 -int, i407 int, i408 int, i409 int, i410 int, i411 int, i412 int, i413 int, i414 -int, i415 int, i416 int, i417 int, i418 int, i419 int, i420 int, i421 int, i422 -int, i423 int, i424 int, i425 int, i426 int, i427 int, i428 int, i429 int, i430 -int, i431 int, i432 int, i433 int, i434 int, i435 int, i436 int, i437 int, i438 -int, i439 int, i440 int, i441 int, i442 int, i443 int, i444 int, i445 int, i446 -int, i447 int, i448 int, i449 int, i450 int, i451 int, i452 int, i453 int, i454 -int, i455 int, i456 int, i457 int, i458 int, i459 int, i460 int, i461 int, i462 -int, i463 int, i464 int, i465 int, i466 int, i467 int, i468 int, i469 int, i470 -int, i471 int, i472 int, i473 int, i474 int, i475 int, i476 int, i477 int, i478 -int, i479 int, i480 int, i481 int, i482 int, i483 int, i484 int, i485 int, i486 -int, i487 int, i488 int, i489 int, i490 int, i491 int, i492 int, i493 int, i494 -int, i495 int, i496 int, i497 int, i498 int, i499 int, i500 int, i501 int, i502 -int, i503 int, i504 int, i505 int, i506 int, i507 int, i508 int, i509 int, i510 -int, i511 int, i512 int, i513 int, i514 int, i515 int, i516 int, i517 int, i518 -int, i519 int, i520 int, i521 int, i522 int, i523 int, i524 int, i525 int, i526 -int, i527 int, i528 int, i529 int, i530 int, i531 int, i532 int, i533 int, i534 -int, i535 int, i536 int, i537 int, i538 int, i539 int, i540 int, i541 int, i542 -int, i543 int, i544 int, i545 int, i546 int, i547 int, i548 int, i549 int, i550 -int, i551 int, i552 int, i553 int, i554 int, i555 int, i556 int, i557 int, i558 -int, i559 int, i560 int, i561 int, i562 int, i563 int, i564 int, i565 int, i566 -int, i567 int, i568 int, i569 int, i570 int, i571 int, i572 int, i573 int, i574 -int, i575 int, i576 int, i577 int, i578 int, i579 int, i580 int, i581 int, i582 -int, i583 int, i584 int, i585 int, i586 int, i587 int, i588 int, i589 int, i590 -int, i591 int, i592 int, i593 int, i594 int, i595 int, i596 int, i597 int, i598 -int, i599 int, i600 int, i601 int, i602 int, i603 int, i604 int, i605 int, i606 -int, i607 int, i608 int, i609 int, i610 int, i611 int, i612 int, i613 int, i614 -int, i615 int, i616 int, i617 int, i618 int, i619 int, i620 int, i621 int, i622 -int, i623 int, i624 int, i625 int, i626 int, i627 int, i628 int, i629 int, i630 -int, i631 int, i632 int, i633 int, i634 int, i635 int, i636 int, i637 int, i638 -int, i639 int, i640 int, i641 int, i642 int, i643 int, i644 int, i645 int, i646 -int, i647 int, i648 int, i649 int, i650 int, i651 int, i652 int, i653 int, i654 -int, i655 int, i656 int, i657 int, i658 int, i659 int, i660 int, i661 int, i662 -int, i663 int, i664 int, i665 int, i666 int, i667 int, i668 int, i669 int, i670 -int, i671 int, i672 int, i673 int, i674 int, i675 int, i676 int, i677 int, i678 -int, i679 int, i680 int, i681 int, i682 int, i683 int, i684 int, i685 int, i686 -int, i687 int, i688 int, i689 int, i690 int, i691 int, i692 int, i693 int, i694 -int, i695 int, i696 int, i697 int, i698 int, i699 int, i700 int, i701 int, i702 -int, i703 int, i704 int, i705 int, i706 int, i707 int, i708 int, i709 int, i710 -int, i711 int, i712 int, i713 int, i714 int, i715 int, i716 int, i717 int, i718 -int, i719 int, i720 int, i721 int, i722 int, i723 int, i724 int, i725 int, i726 -int, i727 int, i728 int, i729 int, i730 int, i731 int, i732 int, i733 int, i734 -int, i735 int, i736 int, i737 int, i738 int, i739 int, i740 int, i741 int, i742 -int, i743 int, i744 int, i745 int, i746 int, i747 int, i748 int, i749 int, i750 -int, i751 int, i752 int, i753 int, i754 int, i755 int, i756 int, i757 int, i758 -int, i759 int, i760 int, i761 int, i762 int, i763 int, i764 int, i765 int, i766 -int, i767 int, i768 int, i769 int, i770 int, i771 int, i772 int, i773 int, i774 -int, i775 int, i776 int, i777 int, i778 int, i779 int, i780 int, i781 int, i782 -int, i783 int, i784 int, i785 int, i786 int, i787 int, i788 int, i789 int, i790 -int, i791 int, i792 int, i793 int, i794 int, i795 int, i796 int, i797 int, i798 -int, i799 int, i800 int, i801 int, i802 int, i803 int, i804 int, i805 int, i806 -int, i807 int, i808 int, i809 int, i810 int, i811 int, i812 int, i813 int, i814 -int, i815 int, i816 int, i817 int, i818 int, i819 int, i820 int, i821 int, i822 -int, i823 int, i824 int, i825 int, i826 int, i827 int, i828 int, i829 int, i830 -int, i831 int, i832 int, i833 int, i834 int, i835 int, i836 int, i837 int, i838 -int, i839 int, i840 int, i841 int, i842 int, i843 int, i844 int, i845 int, i846 -int, i847 int, i848 int, i849 int, i850 int, i851 int, i852 int, i853 int, i854 -int, i855 int, i856 int, i857 int, i858 int, i859 int, i860 int, i861 int, i862 -int, i863 int, i864 int, i865 int, i866 int, i867 int, i868 int, i869 int, i870 -int, i871 int, i872 int, i873 int, i874 int, i875 int, i876 int, i877 int, i878 -int, i879 int, i880 int, i881 int, i882 int, i883 int, i884 int, i885 int, i886 -int, i887 int, i888 int, i889 int, i890 int, i891 int, i892 int, i893 int, i894 -int, i895 int, i896 int, i897 int, i898 int, i899 int, i900 int, i901 int, i902 -int, i903 int, i904 int, i905 int, i906 int, i907 int, i908 int, i909 int, i910 -int, i911 int, i912 int, i913 int, i914 int, i915 int, i916 int, i917 int, i918 -int, i919 int, i920 int, i921 int, i922 int, i923 int, i924 int, i925 int, i926 -int, i927 int, i928 int, i929 int, i930 int, i931 int, i932 int, i933 int, i934 -int, i935 int, i936 int, i937 int, i938 int, i939 int, i940 int, i941 int, i942 -int, i943 int, i944 int, i945 int, i946 int, i947 int, i948 int, i949 int, i950 -int, i951 int, i952 int, i953 int, i954 int, i955 int, i956 int, i957 int, i958 -int, i959 int, i960 int, i961 int, i962 int, i963 int, i964 int, i965 int, i966 -int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974 -int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982 -int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990 -int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998 -int, i999 int, i1000 int, b varchar(256)) row_format=dynamic; - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 -(i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8 -int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, -i17 int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int, -i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34 -int, i35 int, i36 int, i37 int, i38 int, i39 int, i40 int, i41 int, i42 int, -i43 int, i44 int, i45 int, i46 int, i47 int, i48 int, i49 int, i50 int, i51 -int, i52 int, i53 int, i54 int, i55 int, i56 int, i57 int, i58 int, i59 int, -i60 int, i61 int, i62 int, i63 int, i64 int, i65 int, i66 int, i67 int, i68 -int, i69 int, i70 int, i71 int, i72 int, i73 int, i74 int, i75 int, i76 int, -i77 int, i78 int, i79 int, i80 int, i81 int, i82 int, i83 int, i84 int, i85 -int, i86 int, i87 int, i88 int, i89 int, i90 int, i91 int, i92 int, i93 int, -i94 int, i95 int, i96 int, i97 int, i98 int, i99 int, i100 int, i101 int, i102 -int, i103 int, i104 int, i105 int, i106 int, i107 int, i108 int, i109 int, i110 -int, i111 int, i112 int, i113 int, i114 int, i115 int, i116 int, i117 int, i118 -int, i119 int, i120 int, i121 int, i122 int, i123 int, i124 int, i125 int, i126 -int, i127 int, i128 int, i129 int, i130 int, i131 int, i132 int, i133 int, i134 -int, i135 int, i136 int, i137 int, i138 int, i139 int, i140 int, i141 int, i142 -int, i143 int, i144 int, i145 int, i146 int, i147 int, i148 int, i149 int, i150 -int, i151 int, i152 int, i153 int, i154 int, i155 int, i156 int, i157 int, i158 -int, i159 int, i160 int, i161 int, i162 int, i163 int, i164 int, i165 int, i166 -int, i167 int, i168 int, i169 int, i170 int, i171 int, i172 int, i173 int, i174 -int, i175 int, i176 int, i177 int, i178 int, i179 int, i180 int, i181 int, i182 -int, i183 int, i184 int, i185 int, i186 int, i187 int, i188 int, i189 int, i190 -int, i191 int, i192 int, i193 int, i194 int, i195 int, i196 int, i197 int, i198 -int, i199 int, i200 int, i201 int, i202 int, i203 int, i204 int, i205 int, i206 -int, i207 int, i208 int, i209 int, i210 int, i211 int, i212 int, i213 int, i214 -int, i215 int, i216 int, i217 int, i218 int, i219 int, i220 int, i221 int, i222 -int, i223 int, i224 int, i225 int, i226 int, i227 int, i228 int, i229 int, i230 -int, i231 int, i232 int, i233 int, i234 int, i235 int, i236 int, i237 int, i238 -int, i239 int, i240 int, i241 int, i242 int, i243 int, i244 int, i245 int, i246 -int, i247 int, i248 int, i249 int, i250 int, i251 int, i252 int, i253 int, i254 -int, i255 int, i256 int, i257 int, i258 int, i259 int, i260 int, i261 int, i262 -int, i263 int, i264 int, i265 int, i266 int, i267 int, i268 int, i269 int, i270 -int, i271 int, i272 int, i273 int, i274 int, i275 int, i276 int, i277 int, i278 -int, i279 int, i280 int, i281 int, i282 int, i283 int, i284 int, i285 int, i286 -int, i287 int, i288 int, i289 int, i290 int, i291 int, i292 int, i293 int, i294 -int, i295 int, i296 int, i297 int, i298 int, i299 int, i300 int, i301 int, i302 -int, i303 int, i304 int, i305 int, i306 int, i307 int, i308 int, i309 int, i310 -int, i311 int, i312 int, i313 int, i314 int, i315 int, i316 int, i317 int, i318 -int, i319 int, i320 int, i321 int, i322 int, i323 int, i324 int, i325 int, i326 -int, i327 int, i328 int, i329 int, i330 int, i331 int, i332 int, i333 int, i334 -int, i335 int, i336 int, i337 int, i338 int, i339 int, i340 int, i341 int, i342 -int, i343 int, i344 int, i345 int, i346 int, i347 int, i348 int, i349 int, i350 -int, i351 int, i352 int, i353 int, i354 int, i355 int, i356 int, i357 int, i358 -int, i359 int, i360 int, i361 int, i362 int, i363 int, i364 int, i365 int, i366 -int, i367 int, i368 int, i369 int, i370 int, i371 int, i372 int, i373 int, i374 -int, i375 int, i376 int, i377 int, i378 int, i379 int, i380 int, i381 int, i382 -int, i383 int, i384 int, i385 int, i386 int, i387 int, i388 int, i389 int, i390 -int, i391 int, i392 int, i393 int, i394 int, i395 int, i396 int, i397 int, i398 -int, i399 int, i400 int, i401 int, i402 int, i403 int, i404 int, i405 int, i406 -int, i407 int, i408 int, i409 int, i410 int, i411 int, i412 int, i413 int, i414 -int, i415 int, i416 int, i417 int, i418 int, i419 int, i420 int, i421 int, i422 -int, i423 int, i424 int, i425 int, i426 int, i427 int, i428 int, i429 int, i430 -int, i431 int, i432 int, i433 int, i434 int, i435 int, i436 int, i437 int, i438 -int, i439 int, i440 int, i441 int, i442 int, i443 int, i444 int, i445 int, i446 -int, i447 int, i448 int, i449 int, i450 int, i451 int, i452 int, i453 int, i454 -int, i455 int, i456 int, i457 int, i458 int, i459 int, i460 int, i461 int, i462 -int, i463 int, i464 int, i465 int, i466 int, i467 int, i468 int, i469 int, i470 -int, i471 int, i472 int, i473 int, i474 int, i475 int, i476 int, i477 int, i478 -int, i479 int, i480 int, i481 int, i482 int, i483 int, i484 int, i485 int, i486 -int, i487 int, i488 int, i489 int, i490 int, i491 int, i492 int, i493 int, i494 -int, i495 int, i496 int, i497 int, i498 int, i499 int, i500 int, i501 int, i502 -int, i503 int, i504 int, i505 int, i506 int, i507 int, i508 int, i509 int, i510 -int, i511 int, i512 int, i513 int, i514 int, i515 int, i516 int, i517 int, i518 -int, i519 int, i520 int, i521 int, i522 int, i523 int, i524 int, i525 int, i526 -int, i527 int, i528 int, i529 int, i530 int, i531 int, i532 int, i533 int, i534 -int, i535 int, i536 int, i537 int, i538 int, i539 int, i540 int, i541 int, i542 -int, i543 int, i544 int, i545 int, i546 int, i547 int, i548 int, i549 int, i550 -int, i551 int, i552 int, i553 int, i554 int, i555 int, i556 int, i557 int, i558 -int, i559 int, i560 int, i561 int, i562 int, i563 int, i564 int, i565 int, i566 -int, i567 int, i568 int, i569 int, i570 int, i571 int, i572 int, i573 int, i574 -int, i575 int, i576 int, i577 int, i578 int, i579 int, i580 int, i581 int, i582 -int, i583 int, i584 int, i585 int, i586 int, i587 int, i588 int, i589 int, i590 -int, i591 int, i592 int, i593 int, i594 int, i595 int, i596 int, i597 int, i598 -int, i599 int, i600 int, i601 int, i602 int, i603 int, i604 int, i605 int, i606 -int, i607 int, i608 int, i609 int, i610 int, i611 int, i612 int, i613 int, i614 -int, i615 int, i616 int, i617 int, i618 int, i619 int, i620 int, i621 int, i622 -int, i623 int, i624 int, i625 int, i626 int, i627 int, i628 int, i629 int, i630 -int, i631 int, i632 int, i633 int, i634 int, i635 int, i636 int, i637 int, i638 -int, i639 int, i640 int, i641 int, i642 int, i643 int, i644 int, i645 int, i646 -int, i647 int, i648 int, i649 int, i650 int, i651 int, i652 int, i653 int, i654 -int, i655 int, i656 int, i657 int, i658 int, i659 int, i660 int, i661 int, i662 -int, i663 int, i664 int, i665 int, i666 int, i667 int, i668 int, i669 int, i670 -int, i671 int, i672 int, i673 int, i674 int, i675 int, i676 int, i677 int, i678 -int, i679 int, i680 int, i681 int, i682 int, i683 int, i684 int, i685 int, i686 -int, i687 int, i688 int, i689 int, i690 int, i691 int, i692 int, i693 int, i694 -int, i695 int, i696 int, i697 int, i698 int, i699 int, i700 int, i701 int, i702 -int, i703 int, i704 int, i705 int, i706 int, i707 int, i708 int, i709 int, i710 -int, i711 int, i712 int, i713 int, i714 int, i715 int, i716 int, i717 int, i718 -int, i719 int, i720 int, i721 int, i722 int, i723 int, i724 int, i725 int, i726 -int, i727 int, i728 int, i729 int, i730 int, i731 int, i732 int, i733 int, i734 -int, i735 int, i736 int, i737 int, i738 int, i739 int, i740 int, i741 int, i742 -int, i743 int, i744 int, i745 int, i746 int, i747 int, i748 int, i749 int, i750 -int, i751 int, i752 int, i753 int, i754 int, i755 int, i756 int, i757 int, i758 -int, i759 int, i760 int, i761 int, i762 int, i763 int, i764 int, i765 int, i766 -int, i767 int, i768 int, i769 int, i770 int, i771 int, i772 int, i773 int, i774 -int, i775 int, i776 int, i777 int, i778 int, i779 int, i780 int, i781 int, i782 -int, i783 int, i784 int, i785 int, i786 int, i787 int, i788 int, i789 int, i790 -int, i791 int, i792 int, i793 int, i794 int, i795 int, i796 int, i797 int, i798 -int, i799 int, i800 int, i801 int, i802 int, i803 int, i804 int, i805 int, i806 -int, i807 int, i808 int, i809 int, i810 int, i811 int, i812 int, i813 int, i814 -int, i815 int, i816 int, i817 int, i818 int, i819 int, i820 int, i821 int, i822 -int, i823 int, i824 int, i825 int, i826 int, i827 int, i828 int, i829 int, i830 -int, i831 int, i832 int, i833 int, i834 int, i835 int, i836 int, i837 int, i838 -int, i839 int, i840 int, i841 int, i842 int, i843 int, i844 int, i845 int, i846 -int, i847 int, i848 int, i849 int, i850 int, i851 int, i852 int, i853 int, i854 -int, i855 int, i856 int, i857 int, i858 int, i859 int, i860 int, i861 int, i862 -int, i863 int, i864 int, i865 int, i866 int, i867 int, i868 int, i869 int, i870 -int, i871 int, i872 int, i873 int, i874 int, i875 int, i876 int, i877 int, i878 -int, i879 int, i880 int, i881 int, i882 int, i883 int, i884 int, i885 int, i886 -int, i887 int, i888 int, i889 int, i890 int, i891 int, i892 int, i893 int, i894 -int, i895 int, i896 int, i897 int, i898 int, i899 int, i900 int, i901 int, i902 -int, i903 int, i904 int, i905 int, i906 int, i907 int, i908 int, i909 int, i910 -int, i911 int, i912 int, i913 int, i914 int, i915 int, i916 int, i917 int, i918 -int, i919 int, i920 int, i921 int, i922 int, i923 int, i924 int, i925 int, i926 -int, i927 int, i928 int, i929 int, i930 int, i931 int, i932 int, i933 int, i934 -int, i935 int, i936 int, i937 int, i938 int, i939 int, i940 int, i941 int, i942 -int, i943 int, i944 int, i945 int, i946 int, i947 int, i948 int, i949 int, i950 -int, i951 int, i952 int, i953 int, i954 int, i955 int, i956 int, i957 int, i958 -int, i959 int, i960 int, i961 int, i962 int, i963 int, i964 int, i965 int, i966 -int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974 -int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982 -int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990 -int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998 -int, i999 int, i1000 int, b varchar(256)) -row_format=dynamic -ENGINE="FEDERATED" -DEFAULT CHARSET=latin1 -CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.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, 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, 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, -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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "PatrickG"); -UPDATE federated.t1 SET b=repeat('a',256); -UPDATE federated.t1 SET i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0, i9=0, i10=0; -SELECT * FROM federated.t1 WHERE i9=0 and i10=0; -UPDATE federated.t1 SET i50=20; -SELECT * FROM federated.t1; -DELETE FROM federated.t1 WHERE i51=20; -SELECT * FROM federated.t1; -DELETE FROM federated.t1 WHERE i50=20; -SELECT * FROM federated.t1; - -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', PRIMARY KEY(id), index(code), index(fileguts(10))) DEFAULT CHARSET=latin1; - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - id int NOT NULL auto_increment, - code char(20) NOT NULL, - fileguts blob NOT NULL, - creation_date datetime, - entered_time datetime default '2004-04-04 04:04:04', - PRIMARY KEY(id), - index(code), - index(fileguts(10))) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; -INSERT INTO federated.t1 (code, fileguts, creation_date) VALUES ('ASDFWERQWETWETAWETA', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2003-03-03 03:03:03'); -INSERT INTO federated.t1 (code, fileguts, creation_date) VALUES ('DEUEUEUEUEUEUEUEUEU', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2004-04-04 04:04:04'); -INSERT INTO federated.t1 (code, fileguts, creation_date) VALUES ('DEUEUEUEUEUEUEUEUEU', 'jimbob', '2004-04-04 04:04:04'); ---sorted_result -SELECT * FROM federated.t1; -# test blob indexes -SELECT * FROM federated.t1 WHERE fileguts = 'jimbob'; - -# test blob with binary -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 (`a` BLOB); - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `a` BLOB) -ENGINE="FEDERATED" -CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 VALUES (0x00); -INSERT INTO federated.t1 VALUES (0x0001); -INSERT INTO federated.t1 VALUES (0x0100); ---sorted_result -SELECT HEX(a) FROM federated.t1; - -# # simple tests for cyrillic, given to me by -# DROP TABLE IF EXISTS federated.t1; -# --replace_result $SLAVE_MYPORT SLAVE_PORT -# eval CREATE TABLE federated.t1 -# (a char(20)) charset=cp1251 -# ENGINE="FEDERATED" CONNECTION="mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1"; -# # -# connection slave; -# DROP TABLE IF EXISTS federated.t1; -# CREATE TABLE federated.t1 (a char(20)) charset=cp1251; -# # -# connection master; -# INSERT INTO federated.t1 values (_cp1251'À-ÁÂÃ-1'); -# INSERT INTO federated.t1 values (_cp1251'Á-ÂÃÄ-2'); -# SELECT * FROM federated.t1; -# SET names cp1251; -# INSERT INTO federated.t1 values ('Â-ÃÄÅ-3'); -# INSERT INTO federated.t1 values ('Ã-ŨÆ-4'); -# SELECT * FROM federated.t1; -# SELECT hex(a) from federated.t1; -# SELECT hex(a) from federated.t1 ORDER BY a desc; -# UPDATE federated.t1 SET a='À-ÁÂÃ-1íîâûé' WHERE a='À-ÁÂÃ-1'; -# SELECT * FROM federated.t1; -# DELETE FROM federated.t1 WHERE a='Ã-ŨÆ-4'; -# SELECT * FROM federated.t1; -# DELETE FROM federated.t1 WHERE a>'Â-'; -# SELECT * FROM federated.t1; -# SET names default; -# DROP TABLE IF EXISTS federated.t1; - -# -# DROP TABLE IF EXISTS federated.t1; -# - -# test joins with non-federated table -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - `country_id` int(20) NOT NULL DEFAULT 0, - `name` varchar(32), - `other` varchar(20), - PRIMARY KEY (`id`), - key (country_id)); - -connection master; -DROP TABLE IF EXISTS federated.countries; -CREATE TABLE federated.countries ( - `id` int(20) NOT NULL auto_increment, - `country` varchar(32), - PRIMARY KEY (id)); -INSERT INTO federated.countries (country) VALUES ('India'); -INSERT INTO federated.countries (country) VALUES ('Germany'); -INSERT INTO federated.countries (country) VALUES ('Italy'); -INSERT INTO federated.countries (country) VALUES ('Finland'); -INSERT INTO federated.countries (country) VALUES ('Ukraine'); - -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - `country_id` int(20) NOT NULL DEFAULT 0, - `name` varchar(32), - `other` varchar(20), - PRIMARY KEY (`id`), - KEY (country_id) ) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 (name, country_id, other) VALUES ('Kumar', 1, 11111); -INSERT INTO federated.t1 (name, country_id, other) VALUES ('Lenz', 2, 22222); -INSERT INTO federated.t1 (name, country_id, other) VALUES ('Marizio', 3, 33333); -INSERT INTO federated.t1 (name, country_id, other) VALUES ('Monty', 4, 33333); -INSERT INTO federated.t1 (name, country_id, other) VALUES ('Sanja', 5, 33333); - -#inner join ---sorted_result -SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1, federated.countries WHERE -federated.t1.country_id = federated.countries.id; - -SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1 INNER JOIN federated.countries ON -federated.t1.country_id = federated.countries.id; - -SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1 INNER JOIN federated.countries ON -federated.t1.country_id = federated.countries.id -WHERE federated.t1.name = 'Monty'; - -#left join -SELECT federated.t1.*, federated.countries.country -FROM federated.t1 LEFT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.countries.id; - -SELECT federated.t1.*, federated.countries.country -FROM federated.t1 LEFT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.countries.country; - -#right join -SELECT federated.t1.*, federated.countries.country -FROM federated.t1 RIGHT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.t1.country_id; - -DROP TABLE federated.countries; - -#BEGIN optimize and repair tests -OPTIMIZE TABLE federated.t1; -REPAIR TABLE federated.t1; -REPAIR TABLE federated.t1 QUICK; -REPAIR TABLE federated.t1 EXTENDED; -REPAIR TABLE federated.t1 USE_FRM; -#END optimize and repair tests - - -# BEGIN ALTER TEST -connection slave; ---disable_warnings -DROP TABLE IF EXISTS federated.normal_table; ---enable_warnings - -CREATE TABLE federated.normal_table ( - `id` int(4) NOT NULL, - `name` varchar(10) default NULL - ) DEFAULT CHARSET=latin1; - -connection master; ---disable_warnings -DROP TABLE IF EXISTS federated.alter_me; ---enable_warnings - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.alter_me ( - `id` int(4) NOT NULL, - `name` varchar(10) default NULL, - PRIMARY KEY (`id`) - ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/normal_table'; - -INSERT INTO federated.alter_me (id, name) VALUES (1, 'Monty'); -INSERT INTO federated.alter_me (id, name) VALUES (2, 'David'); - -SELECT * FROM federated.alter_me; - ---error ER_ILLEGAL_HA -ALTER TABLE federated.alter_me MODIFY COLUMN id int(16) NOT NULL; - -SELECT * FROM federated.alter_me; - -DROP TABLE federated.alter_me; -connection slave; -DROP TABLE federated.normal_table; -# END ALTER TEST - -# -# Test BUG #14532 - bit columns broken in federated -# storage engine -# ---disable_warnings -DROP TABLE IF EXISTS federated.t1; ---enable_warnings -CREATE TABLE federated.t1 ( - `bitty` bit(3) -) DEFAULT CHARSET=latin1; - -connection master; - ---disable_warnings -DROP TABLE IF EXISTS federated.t1; ---enable_warnings - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `bitty` bit(3) -) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 VALUES (b'001'); -INSERT INTO federated.t1 VALUES (b'010'); -INSERT INTO federated.t1 VALUES (b'011'); -INSERT INTO federated.t1 VALUES (b'100'); -INSERT INTO federated.t1 VALUES (b'101'); -INSERT INTO federated.t1 VALUES (b'110'); -INSERT INTO federated.t1 VALUES (b'111'); -select * FROM federated.t1; -drop table federated.t1; - -connection slave; -drop table federated.t1; - -# -# BUG# 14768 test auto_increment last_insert_id() -# -connection slave; -DROP TABLE IF EXISTS federated.t1; -CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - PRIMARY KEY (`id`)); - -connection master; -DROP TABLE IF EXISTS federated.t1; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int(20) NOT NULL auto_increment, - PRIMARY KEY (`id`) - ) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -INSERT INTO federated.t1 VALUES (); -SELECT LAST_INSERT_ID(); -INSERT INTO federated.t1 VALUES (); -SELECT LAST_INSERT_ID(); -INSERT INTO federated.t1 VALUES (); -SELECT LAST_INSERT_ID(); -INSERT INTO federated.t1 VALUES (); -SELECT LAST_INSERT_ID(); -INSERT INTO federated.t1 VALUES (); -SELECT LAST_INSERT_ID(); -SELECT * FROM federated.t1; -DROP TABLE federated.t1; - -connection slave; -DROP TABLE federated.t1; - -# -# Bug#17377 Federated Engine returns wrong Data, always the rows -# with the highest ID -# - -connection slave; - ---disable_warnings -DROP TABLE IF EXISTS federated.bug_17377_table; ---enable_warnings - -CREATE TABLE federated.bug_17377_table ( -`fld_cid` bigint(20) NOT NULL auto_increment, -`fld_name` varchar(255) NOT NULL default '', -`fld_parentid` bigint(20) NOT NULL default '0', -`fld_delt` int(1) NOT NULL default '0', -PRIMARY KEY (`fld_cid`), -KEY `fld_parentid` (`fld_parentid`), -KEY `fld_delt` (`fld_delt`), -KEY `fld_cid` (`fld_cid`) -) ENGINE=MyISAM; - -# Insert some test-data -insert into federated.bug_17377_table( fld_name ) -values -("Mats"), ("Sivert"), ("Sigvard"), ("Torgny"), ("Torkel"); - -connection master; ---disable_warnings -DROP TABLE IF EXISTS federated.t1; ---enable_warnings - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( -`fld_cid` bigint(20) NOT NULL auto_increment, -`fld_name` varchar(255) NOT NULL default '', -`fld_parentid` bigint(20) NOT NULL default '0', -`fld_delt` int(1) NOT NULL default '0', -PRIMARY KEY (`fld_cid`), -KEY `fld_parentid` (`fld_parentid`), -KEY `fld_delt` (`fld_delt`), -KEY `fld_cid` (`fld_cid`) -) ENGINE=FEDERATED -CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/bug_17377_table'; - -select * from federated.t1 where fld_parentid=0 and fld_delt=0 -order by fld_name; - -select * from federated.t1 where fld_parentid=0 and fld_delt=0; - -DROP TABLE federated.t1; -connection slave; -DROP TABLE federated.bug_17377_table; - -# -# BUG 19773 Crash when using multi-table updates, deletes -# with federated tables -# -connection slave; -create table federated.t1 (i1 int, i2 int, i3 int); -create table federated.t2 (id int, c1 varchar(20), c2 varchar(20)); - -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.t1 (i1 int, i2 int, i3 int) ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.t2 (id int, c1 varchar(20), c2 varchar(20)) ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t2'; -insert into federated.t1 values (1,5,10),(3,7,12),(4,5,2),(9,10,15),(2,2,2); -insert into federated.t2 values (9,"abc","def"),(5,"opq","lmn"),(2,"test t","t test"); -select * from federated.t1 order by i1; -select * from federated.t2; -update federated.t1,federated.t2 set t1.i2=15, t2.c2="ppc" where t1.i1=t2.id; -select * from federated.t1 order by i1; -select * from federated.t2 order by id; -delete federated.t1.*,federated.t2.* from federated.t1,federated.t2 where t1.i2=t2.id; -select * from federated.t1 order by i1; -select * from federated.t2 order by id; -drop table federated.t1, federated.t2; -connection slave; -drop table federated.t1, federated.t2; - -# Test multi updates and deletes with keys -connection slave; -create table federated.t1 (i1 int, i2 int, i3 int, primary key (i1)); -create table federated.t2 (id int, c1 varchar(20), c2 varchar(20), primary key (id)); - -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.t1 (i1 int auto_increment not null, i2 int, i3 int, primary key (i1)) ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.t2 (id int auto_increment not null, c1 varchar(20), c2 varchar(20), primary key(id)) ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t2'; -insert into federated.t1 values (1,5,10),(3,7,12),(4,5,2),(9,10,15),(2,2,2); -insert into federated.t2 values (9,"abc","def"),(5,"opq","lmn"),(2,"test t","t test"); -select * from federated.t1 order by i1; -select * from federated.t2 order by id; -update federated.t1,federated.t2 set t1.i2=15, t2.c2="ppc" where t1.i1=t2.id; -select * from federated.t1 order by i1; -select * from federated.t2 order by id; -delete federated.t1.*,federated.t2.* from federated.t1,federated.t2 where t1.i2=t2.id; -select * from federated.t1 order by i1; -select * from federated.t2 order by id; -drop table federated.t1, federated.t2; - -connection slave; -drop table federated.t1, federated.t2; - -# -# BUG #18764: Delete conditions causing inconsistencies in Federated tables -# -connection slave; ---disable_warnings -DROP TABLE IF EXISTS federated.test; ---enable_warnings -CREATE TABLE federated.test ( - `id` int(11) NOT NULL, - `val1` varchar(255) NOT NULL, - `val2` varchar(255) NOT NULL, - PRIMARY KEY (`id`) - ) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -connection master; ---disable_warnings -DROP TABLE IF EXISTS federated.test_local; -DROP TABLE IF EXISTS federated.test_remote; ---enable_warnings -CREATE TABLE federated.test_local ( - `id` int(11) NOT NULL, - `val1` varchar(255) NOT NULL, - `val2` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -INSERT INTO federated.test_local VALUES (1, 'foo', 'bar'), -(2, 'bar', 'foo'); - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.test_remote ( - `id` int(11) NOT NULL, - `val1` varchar(255) NOT NULL, - `val2` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=FEDERATED DEFAULT CHARSET=latin1 -CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/test'; - -insert into federated.test_remote select * from federated.test_local; - -select * from federated.test_remote; - -delete from federated.test_remote where id in (1,2); - -insert into federated.test_remote select * from federated.test_local; - -select * from federated.test_remote; ---disable_warnings -DROP TABLE federated.test_local; -DROP TABLE federated.test_remote; ---enable_warnings -connection slave; ---disable_warnings -DROP TABLE federated.test; ---enable_warnings - -# -# Additional test for bug#18437 "Wrong values inserted with a before -# update trigger on NDB table". SQL-layer didn't properly inform -# handler about fields which were read and set in triggers. In some -# cases this resulted in incorrect (garbage) values of OLD variables -# and lost changes to NEW variables. -# Since for federated engine only operation which is affected by wrong -# fields mark-up is handler::write_row() this file constains coverage -# for ON INSERT triggers only. Tests for other types of triggers reside -# in ndb_trigger.test. -# ---disable_warnings -drop table if exists federated.t1; ---enable_warnings -create table federated.t1 (a int, b int, c int); -connection master; ---disable_warnings -drop table if exists federated.t1; -drop table if exists federated.t2; ---enable_warnings ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.t1 (a int, b int, c int) engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; -create trigger federated.t1_bi before insert on federated.t1 for each row set new.c= new.a * new.b; -create table federated.t2 (a int, b int); -insert into federated.t2 values (13, 17), (19, 23); -# Each of three statements should correctly set values for all three fields -# insert -insert into federated.t1 (a, b) values (1, 2), (3, 5), (7, 11); -select * from federated.t1 order by a; -delete from federated.t1; -# insert ... select -insert into federated.t1 (a, b) select * from federated.t2; -select * from federated.t1 order by a; -delete from federated.t1; -# load -load data infile '../std_data_ln/loaddata5.dat' into table federated.t1 fields terminated by '' enclosed by '' ignore 1 lines (a, b); -select * from federated.t1 order by a; -drop tables federated.t1, federated.t2; - -connection slave; -drop table federated.t1; -# -# Bug #16494: Updates that set a column to NULL fail sometimes -# -connection slave; -create table t1 (id int not null auto_increment primary key, val int); -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table t1 - (id int not null auto_increment primary key, val int) engine=federated - connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; -insert into t1 values (1,0),(2,0); -update t1 set val = NULL where id = 1; -select * from t1; -connection slave; -select * from t1; -drop table t1; -connection master; -drop table t1; - -# -# Bug #17608: String literals lost during INSERT query on FEDERATED table -# -connection slave; -create table t1 (a longblob not null); -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table t1 - (a longblob not null) engine=federated - connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; -insert into t1 values (repeat('a',5000)); -select length(a) from t1; -connection slave; -select length(a) from t1; -drop table t1; -connection master; -drop table t1; - -# -# BUG #15133: unique index with nullable value not accepted in federated table -# - -connection slave; ---disable_warnings -DROP TABLE IF EXISTS federated.test; -CREATE TABLE federated.test ( - `i` int(11) NOT NULL, - `j` int(11) NOT NULL, - `c` varchar(30) default NULL, - PRIMARY KEY (`i`,`j`), - UNIQUE KEY `i` (`i`,`c`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; ---enable_warnings - -connection master; ---disable_warnings -DROP TABLE IF EXISTS federated.test1; -DROP TABLE IF EXISTS federated.test2; ---enable_warnings - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.test1 ( - i int not null, - j int not null, - c varchar(30), - primary key (i,j), - unique key (i, c)) -engine = federated -connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/test'; - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.test2 ( - i int default null, - j int not null, - c varchar(30), - key (i)) -engine = federated -connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/test'; -drop table federated.test1, federated.test2; - -connection slave; -drop table federated.test; - -# -# BUG# 17044 Federated Storage Engine not UTF8 clean -# -connection slave; -set names utf8; -create table federated.t1 (a varchar(64)) DEFAULT CHARSET=utf8; - -insert into federated.t1 values (0x6DC3A56E6164); -select hex(a) from federated.t1; - -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.t1 (a varchar(64)) -ENGINE=FEDERATED -connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1' -DEFAULT CHARSET=utf8; -set names utf8; -select hex(a) from federated.t1; -insert into federated.t1 values (0xC3A4C3B6C3BCC39F); -insert into federated.t1 values (0xD18DD184D184D0B5D0BAD182D0B8D0B2D0BDD183D18E); -select hex(a) from federated.t1; - -connection slave; -select hex(a) from federated.t1; - -connection master; -drop table federated.t1; - -connection slave; -drop table federated.t1; - -# -# Bug#26909: Specified key was too long; max key length is 255 bytes -# when creating a table -# -connection slave; -CREATE TABLE federated.t1 ( - categoryId int(11) NOT NULL AUTO_INCREMENT, - domainId varchar(745) NOT NULL DEFAULT '', - categoryName varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (categoryId), - UNIQUE KEY idx_unique_category_categoryName (domainId, categoryName), - KEY idx_category_domainId (domainId) - ) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - categoryId int(11) NOT NULL AUTO_INCREMENT, - domainId varchar(745) NOT NULL DEFAULT '', - categoryName varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (categoryId), - UNIQUE KEY idx_unique_category_categoryName (domainId, categoryName), - KEY idx_category_domainId (domainId) - ) ENGINE=FEDERATED DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - - -insert into federated.t1 (domainId, categoryName) values ( '1231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231 300', '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 250'); -insert into federated.t1 (domainId, categoryName) values ( '12312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312 301', '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 250'); -insert into federated.t1 (domainId, categoryName) values ('a', 'b'); - -select categoryId from federated.t1 order by domainId, categoryName; -select categoryId from federated.t1 where domainId='a' and categoryName='b' order by categoryId; -select categoryId from federated.t1 where domainId='a' and categoryName='b' order by categoryId; -select categoryId from federated.t1 where domainId<>'a' and categoryName<>'b' order by categoryId; - -drop table federated.t1; - -connection slave; -drop table federated.t1; - -# -# BUG#21019 Federated Engine does not support REPLACE/INSERT IGNORE/UPDATE IGNORE -# -connection slave; -create table federated.t1 (a int primary key, b varchar(64)) - DEFAULT CHARSET=utf8; -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.t1 (a int primary key, b varchar(64)) - ENGINE=FEDERATED - connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1' - DEFAULT CHARSET=utf8; - -insert ignore into federated.t1 values (1,"Larry"), (2,"Curly"), (1,"Moe"); -select * from federated.t1; - -truncate federated.t1; -replace into federated.t1 values (1,"Larry"), (2,"Curly"), (1,"Moe"); -select * from federated.t1; - -update ignore federated.t1 set a=a+1; -select * from federated.t1; - -drop table federated.t1; -connection slave; -drop table federated.t1; - -# -# BUG#25511 Federated Insert failures. -# -# When the user performs a INSERT...ON DUPLICATE KEY UPDATE, we want -# it to fail if a duplicate key exists instead of ignoring it. -# -connection slave; -create table federated.t1 (a int primary key, b varchar(64)) - DEFAULT CHARSET=utf8; -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.t1 (a int primary key, b varchar(64)) - ENGINE=FEDERATED - connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1' - DEFAULT CHARSET=utf8; - ---error ER_DUP_KEY -insert into federated.t1 values (1,"Larry"), (2,"Curly"), (1,"Moe") -on duplicate key update a=a+100; -select * from federated.t1; - -drop table federated.t1; -connection slave; -drop table federated.t1; - ---echo ---echo Bug#18287 create federated table always times out, error 1159 ' ' ---echo ---echo Test that self-references work ---echo -connection slave; -create table federated.t1 (a int primary key); ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.t2 (a int primary key) - ENGINE=FEDERATED - connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; -insert into federated.t1 (a) values (1); -select * from federated.t2; -drop table federated.t1, federated.t2; - -# -# Bug #32374 crash with filesort when selecting from federated table and view -# -connection slave; -create table t1 (a varchar(256)); ---disable_warnings -drop view if exists v1; ---enable_warnings -create view v1 as select a from t1; ---disable_query_log -let $n= 100; -while ($n) -{ - insert into t1 values (repeat('a',200)); - dec $n; -} ---enable_query_log - -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table t1 - (a varchar(256)) engine=federated - connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/v1'; - -select 1 from t1 order by a; -drop table t1; -connection slave; -drop table t1; -drop view v1; - -# -# BUG#33946 - Join on Federated tables with Unique index gives error 1430 -# from storage engine -# -connection slave; -CREATE TABLE t1 (a INT, b INT, KEY(a,b)); -INSERT INTO t1 VALUES(NULL,1),(1,NULL),(NULL,NULL),(1,1),(2,2); - -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE t1 (a INT, b INT, KEY(a,b)) ENGINE=federated -CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; -SELECT * FROM t1 WHERE a IS NULL; -SELECT * FROM t1 WHERE a IS NOT NULL; -SELECT * FROM t1 WHERE a=1 AND b=1; -SELECT * FROM t1 WHERE a IS NULL AND b=1; -SELECT * FROM t1 WHERE a IS NOT NULL AND b=1; -DROP TABLE t1; - -connection slave; -DROP TABLE t1; - -# -# BUG#34788 - malformed federated connection url is not handled correctly - -# crashes server ! -# -# also tests -# -# BUG#35509 - Federated leaks memory when connecting to localhost/default -# port -# -CREATE TABLE t1 (a INT) ENGINE=federated CONNECTION='mysql://@:://'; -DROP TABLE t1; - - -# -# Bug #34779: crash in checksum table on federated tables with blobs -# containing nulls -# -connection slave; -CREATE TABLE t1 (a LONGBLOB, b LONGBLOB); -INSERT INTO t1 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaa', NULL); -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE t1 - (a LONGBLOB, b LONGBLOB) ENGINE=FEDERATED - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; -CHECKSUM TABLE t1; -connection slave; -DROP TABLE t1; -connection master; -DROP TABLE t1; - - -# -# Bug #34774 key prefix on text field in federated tables can cause -# server to crash! -# -connection slave; -CREATE TABLE t1 (a TEXT, b TEXT, KEY(b(1))); -INSERT INTO t1 VALUES (NULL, NULL), (NULL, NULL), (NULL, NULL), (NULL, NULL); -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE t1 - (a TEXT, b TEXT, KEY(b(1))) ENGINE=FEDERATED - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; -SELECT t1.a FROM t1, t1 as t2 WHERE t2.b NOT LIKE t1.b; -connection slave; -DROP TABLE t1; -connection master; -DROP TABLE t1; - ---echo # ---echo # BUG#21360 - mysqldump error on federated tables ---echo # -connection slave; ---echo #Switch to Connection Slave -CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id)); -INSERT INTO t1 VALUES ('text1'),('text2'),('text3'),('text4'); - -connection master; ---echo #Switch to Connection Master ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id)) ENGINE=FEDERATED - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; ---echo # Dump table t1 using mysqldump tool ---replace_result $SLAVE_MYPORT SLAVE_PORT ---exec $MYSQL_DUMP --compact test t1 -DROP TABLE t1; - -connection slave; ---echo #Switch to Connection Slave -DROP TABLE t1; - -connection default; - ---echo End of 5.0 tests - -SET @@GLOBAL.CONCURRENT_INSERT= @OLD_MASTER_CONCURRENT_INSERT; -connection slave; -SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT; - -connection default; -source include/federated_cleanup.inc; diff --git a/mysql-test/t/federated_archive.test b/mysql-test/t/federated_archive.test deleted file mode 100644 index 6d80664fef7..00000000000 --- a/mysql-test/t/federated_archive.test +++ /dev/null @@ -1,58 +0,0 @@ -source include/have_archive.inc; -source include/federated.inc; - - -connection slave; ---disable_warnings -DROP TABLE IF EXISTS federated.archive_table; ---enable_warnings - -CREATE TABLE federated.archive_table ( - `id` int(4) NOT NULL, - `name` varchar(54) default NULL - ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1; - - -connection master; ---disable_warnings -DROP TABLE IF EXISTS federated.t1; ---enable_warnings - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int(4) NOT NULL, - `name` varchar(54) default NULL, - PRIMARY KEY (`id`) - ) - ENGINE="FEDERATED" DEFAULT CHARSET=latin1 - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/archive_table'; - -INSERT INTO federated.t1 (id, name) VALUES (1, 'foo'); -INSERT INTO federated.t1 (id, name) VALUES (2, 'bar'); - -SELECT * FROM federated.t1; - ---error 1296 -DELETE FROM federated.t1 WHERE id = 1; - -SELECT * FROM federated.t1; - - ---error 1296 -UPDATE federated.t1 SET name='baz' WHERE id = 1; - -SELECT * FROM federated.t1; - - -# --error 1296 -# TRUNCATE federated.t1; -# -# SELECT * from federated.t1; - -DROP TABLE federated.t1; -connection slave; -DROP TABLE federated.archive_table; - - -source include/federated_cleanup.inc; - diff --git a/mysql-test/t/federated_bug_13118.test b/mysql-test/t/federated_bug_13118.test deleted file mode 100644 index deec79becd2..00000000000 --- a/mysql-test/t/federated_bug_13118.test +++ /dev/null @@ -1,42 +0,0 @@ -source include/federated.inc; - - -connection slave; ---disable_warnings -DROP TABLE IF EXISTS federated.bug_13118_table; ---enable_warnings - -CREATE TABLE federated.bug_13118_table ( - `foo` integer, - `bar` integer - ); - - -connection master; ---disable_warnings -DROP TABLE IF EXISTS federated.t1; ---enable_warnings - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `foo` integer, - `bar` integer - ) ENGINE="FEDERATED" - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/bug_13118_table'; - -SELECT * from federated.t1; - -INSERT INTO federated.t1 VALUES (1,1); -SELECT * FROM federated.t1; - -INSERT INTO federated.t1 VALUES (1,1); -SELECT * FROM federated.t1; - - -DROP TABLE federated.t1; -connection slave; -DROP TABLE federated.bug_13118_table; - - -source include/federated_cleanup.inc; - diff --git a/mysql-test/t/federated_bug_25714.test b/mysql-test/t/federated_bug_25714.test deleted file mode 100644 index 6d112cae5b8..00000000000 --- a/mysql-test/t/federated_bug_25714.test +++ /dev/null @@ -1,58 +0,0 @@ ---source include/have_bug25714.inc -source include/federated.inc; - -connection master; -# Disable concurrent inserts to avoid test failures when reading -# data from concurrent connections (insert might return before -# the data is actually in the table). -SET @OLD_MASTER_CONCURRENT_INSERT= @@GLOBAL.CONCURRENT_INSERT; -SET @@GLOBAL.CONCURRENT_INSERT= 0; - -connection slave; -SET @OLD_SLAVE_CONCURRENT_INSERT= @@GLOBAL.CONCURRENT_INSERT; -SET @@GLOBAL.CONCURRENT_INSERT= 0; ---disable_warnings -DROP TABLE IF EXISTS federated.bug_13118_table; ---enable_warnings - -CREATE TABLE federated.t1 ( - `id` int auto_increment primary key, - `value` int - ) ENGINE=MyISAM; -INSERT INTO federated.t1 SET value=1; -INSERT INTO federated.t1 SET value=2; -INSERT INTO federated.t1 SET value=2; - -connection master; ---disable_warnings -DROP TABLE IF EXISTS federated.t1; ---enable_warnings - ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE federated.t1 ( - `id` int auto_increment primary key, - `value` int - ) ENGINE=FEDERATED - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - -SELECT * from federated.t1; - -INSERT INTO federated.t1 SET value=4; - -SELECT LAST_INSERT_ID(); - ---exec $MYSQL_BUG25714 $SLAVE_MYPORT ---exec $MYSQL_BUG25714 $MASTER_MYPORT - -SELECT * from federated.t1; - -DROP TABLE federated.t1; -SET @@GLOBAL.CONCURRENT_INSERT= @OLD_MASTER_CONCURRENT_INSERT; -connection slave; -DROP TABLE federated.t1; -SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT; - - -source include/federated_cleanup.inc; - - diff --git a/mysql-test/t/federated_debug-master.opt b/mysql-test/t/federated_debug-master.opt deleted file mode 100644 index ad9ba4795af..00000000000 --- a/mysql-test/t/federated_debug-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-debug=d,simulate_detached_thread_refresh diff --git a/mysql-test/t/federated_debug.test b/mysql-test/t/federated_debug.test deleted file mode 100644 index 9de440f4d79..00000000000 --- a/mysql-test/t/federated_debug.test +++ /dev/null @@ -1,39 +0,0 @@ ---source include/have_debug.inc ---source include/federated.inc - ---echo # ---echo # Bug#47525: MySQL crashed (Federated) ---echo # - -connection slave; ---echo # Switch to slave -CREATE TABLE t1(a INT); -INSERT INTO t1 VALUES (1); - -connection master; ---echo # Switch to master ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval CREATE TABLE t1(a INT) ENGINE=FEDERATED - CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; - -SELECT * FROM t1; - ---echo # Start a asynchronous reload ---exec $MYSQLADMIN --no-defaults -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= refresh 2>&1 - ---echo # Wait for tables to be closed -let $show_statement= SHOW STATUS LIKE 'Open_tables'; -let $field= Value; -let $condition= = '0'; ---source include/wait_show_condition.inc - ---echo # Ensure that the server didn't crash -SELECT * FROM t1; ---echo # Drop tables on master and slave -DROP TABLE t1; -connection slave; -DROP TABLE t1; - -connection default; ---echo # Federated cleanup -source include/federated_cleanup.inc; diff --git a/mysql-test/t/federated_disabled-master.opt b/mysql-test/t/federated_disabled-master.opt deleted file mode 100644 index 4f2df1dd301..00000000000 --- a/mysql-test/t/federated_disabled-master.opt +++ /dev/null @@ -1 +0,0 @@ ---skip-federated diff --git a/mysql-test/t/federated_disabled.test b/mysql-test/t/federated_disabled.test deleted file mode 100644 index 99fcad76828..00000000000 --- a/mysql-test/t/federated_disabled.test +++ /dev/null @@ -1,3 +0,0 @@ -source include/federated.inc; - -SHOW VARIABLES LIKE 'have_federated_engine'; diff --git a/mysql-test/t/federated_innodb-slave.opt b/mysql-test/t/federated_innodb-slave.opt deleted file mode 100644 index 627becdbfb5..00000000000 --- a/mysql-test/t/federated_innodb-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb diff --git a/mysql-test/t/federated_innodb.test b/mysql-test/t/federated_innodb.test deleted file mode 100644 index 0617cb15d97..00000000000 --- a/mysql-test/t/federated_innodb.test +++ /dev/null @@ -1,39 +0,0 @@ -# NOTE: Keep any include/ files that will kill / skip a test BEFORE any others -# having federated.inc before have_innodb.inc allows for an orphaned database -# that can cause other tests to fail. -# See Bug #40645 Test main.federated_innodb does not always clean up after itself - -source include/have_innodb.inc; -source include/federated.inc; - -# -# Bug#25513 Federated transaction failures -# -connection slave; -create table federated.t1 (a int primary key, b varchar(64)) - engine=myisam; -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval create table federated.t1 (a int primary key, b varchar(64)) - engine=federated - connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; - ---error ER_DUP_KEY -insert into federated.t1 values (1,"Larry"), (2,"Curly"), (1,"Moe"); -select * from federated.t1; - -connection slave; -truncate federated.t1; -alter table federated.t1 engine=innodb; -connection master; - ---error ER_DUP_KEY -insert into federated.t1 values (1,"Larry"), (2,"Curly"), (1,"Moe"); -select * from federated.t1; - -drop table federated.t1; -connection slave; -drop table federated.t1; - - -source include/federated_cleanup.inc; diff --git a/mysql-test/t/fix_priv_tables.test b/mysql-test/t/fix_priv_tables.test index 3051fd88076..eeda9bc8d15 100644 --- a/mysql-test/t/fix_priv_tables.test +++ b/mysql-test/t/fix_priv_tables.test @@ -51,7 +51,13 @@ echo; -- disable_query_log # Run the mysql_fix_privilege_tables.sql using "mysql --force" ---exec $MYSQL --force mysql < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/log/fix_priv_tables.log 2>&1 +# Determine the number of open sessions +--source include/count_sessions.inc +--exec $MYSQL --force mysql < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/tmp/fix_priv_tables.log 2>&1 +--remove_file $MYSQLTEST_VARDIR/tmp/fix_priv_tables.log +# Wait till the number of open sessions is <= the number before the run with $MYSQL +# = The session caused by mysql has finished its disconnect +--source include/wait_until_count_sessions.inc -- enable_query_log -- enable_result_log diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index 4c6d4265600..f27d4cf2fad 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -171,6 +171,31 @@ set session low_priority_updates=default; connect (con1,localhost,root,,); send select benchmark(200, (select sin(1))) > 1000; disconnect con1; +--source include/wait_until_disconnected.inc connection default; -# End of 5.0 tests +--echo End of 5.0 tests + +# +# Bug #26380: LOCK TABLES + FLUSH LOGS causes deadlock +# +set @old_general_log= @@general_log; +set @old_read_only= @@read_only; +set global general_log= on; + +flush tables with read lock; +flush logs; +unlock tables; + +set global read_only=1; +flush logs; +unlock tables; + +flush tables with read lock; +flush logs; +unlock tables; + +set global general_log= @old_general_log; +set global read_only= @old_read_only; + +--echo End of 5.1 tests diff --git a/mysql-test/t/flush_read_lock_kill-master.opt b/mysql-test/t/flush_read_lock_kill-master.opt index 2b2b5eb5ebf..61e2b242351 100644 --- a/mysql-test/t/flush_read_lock_kill-master.opt +++ b/mysql-test/t/flush_read_lock_kill-master.opt @@ -1 +1 @@ ---loose-debug=d,make_global_read_lock_block_commit_loop +--loose-debug=+d,make_global_read_lock_block_commit_loop diff --git a/mysql-test/t/flush_read_lock_kill.test b/mysql-test/t/flush_read_lock_kill.test index 6c842f8aff3..2d359383949 100644 --- a/mysql-test/t/flush_read_lock_kill.test +++ b/mysql-test/t/flush_read_lock_kill.test @@ -42,7 +42,14 @@ send FLUSH TABLES WITH READ LOCK; connection con2; SELECT ((@id := kill_id) - kill_id) FROM t1; ---sleep 2 # leave time for FLUSH to block +# Wait for the debug sync point, test won't run on non-debug +# builds anyway. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for all running commits to finish" + and info = "flush tables with read lock"; +--source include/wait_condition.inc + KILL CONNECTION @id; connection con1; @@ -55,6 +62,7 @@ reap; connection con2; DROP TABLE t1; + connection default; disconnect con2; diff --git a/mysql-test/t/flush_table.test b/mysql-test/t/flush_table.test index e46b67ad3d0..50e7e91419a 100644 --- a/mysql-test/t/flush_table.test +++ b/mysql-test/t/flush_table.test @@ -4,15 +4,70 @@ # Test of flush table # +# Should work in embedded server after mysqltest is fixed +-- source include/not_embedded.inc --disable_warnings drop table if exists t1,t2; --enable_warnings create table t1 (a int not null auto_increment primary key); insert into t1 values(0); + +# Test for with read lock + flush + lock table t1 read; flush table t1; check table t1; +unlock tables; + +# Test for with 2 read lock in different thread + flush + +lock table t1 read; +connect (locker,localhost,root,,test); +connection locker; +lock table t1 read; +connection default; +send flush table t1; +connection locker; +--sleep 2 +select * from t1; +unlock tables; +connection default; +reap; +select * from t1; +unlock tables; + +# Test for with a write lock and a waiting read lock + flush + +lock table t1 write; +connection locker; +send lock table t1 read; +connection default; +sleep 2; +flush table t1; +select * from t1; +unlock tables; +connection locker; +reap; +unlock tables; +connection default; + +# Test for with a read lock and a waiting write lock + flush + +lock table t1 read; +connection locker; +send lock table t1 write; +connection default; +sleep 2; +flush table t1; +select * from t1; +unlock tables; +connection locker; +reap; +unlock tables; +select * from t1; +connection default; drop table t1; +disconnect locker; # # In the following test FLUSH TABLES produces a deadlock diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 9551c98f143..80c8658d35c 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -28,6 +28,12 @@ select * from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION); select * from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION); select * from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION); +# IN NATURAL LANGUAGE MODE +select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE); +select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION); +--error 1064 +select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION); + # add_ft_keys() tests explain select * from t1 where MATCH(a,b) AGAINST ("collections"); @@ -355,6 +361,12 @@ SET myisam_repair_threads=@@global.myisam_repair_threads; INSERT INTO t1 VALUES('testword\'\''); SELECT a FROM t1 WHERE MATCH a AGAINST('testword' IN BOOLEAN MODE); SELECT a FROM t1 WHERE MATCH a AGAINST('testword\'\'' IN BOOLEAN MODE); + +# +# BUG#14194: Problem with fulltext boolean search and apostrophe +# +INSERT INTO t1 VALUES('test\'s'); +SELECT a FROM t1 WHERE MATCH a AGAINST('test' IN BOOLEAN MODE); DROP TABLE t1; # @@ -395,6 +407,16 @@ INSERT INTO t1 VALUES(' aaaaa aaaa'); SELECT * FROM t1 WHERE MATCH(a) AGAINST ('"aaaa"' IN BOOLEAN MODE); DROP TABLE t1; +# +# BUG#29445 - match ... against () never returns +# +CREATE TABLE t1(a VARCHAR(20), FULLTEXT(a)); +INSERT INTO t1 VALUES('Offside'),('City Of God'); +SELECT a FROM t1 WHERE MATCH a AGAINST ('+city of*' IN BOOLEAN MODE); +SELECT a FROM t1 WHERE MATCH a AGAINST ('+city (of*)' IN BOOLEAN MODE); +SELECT a FROM t1 WHERE MATCH a AGAINST ('+city* of*' IN BOOLEAN MODE); +DROP TABLE t1; + # End of 4.1 tests # @@ -442,9 +464,17 @@ SELECT GROUP_CONCAT(a) AS st FROM t1 HAVING MATCH(st) AGAINST('test' IN BOOLEAN DROP TABLE t1; # -# BUG#37740 Server crashes on execute statement with full text search and match against +# BUG#42907 - Multi-term boolean fulltext query containing a single +# quote fails in 5.1.x # +CREATE TABLE t1(a VARCHAR(64), FULLTEXT(a)); +INSERT INTO t1 VALUES('awrd bwrd cwrd'),('awrd bwrd cwrd'),('awrd bwrd cwrd'); +SELECT * FROM t1 WHERE MATCH(a) AGAINST('+awrd bwrd* +cwrd*' IN BOOLEAN MODE); +DROP TABLE t1; +# +# BUG#37740 Server crashes on execute statement with full text search and match against +# CREATE TABLE t1 (col text, FULLTEXT KEY full_text (col)); PREPARE s FROM @@ -454,4 +484,3 @@ PREPARE s FROM EXECUTE s; DEALLOCATE PREPARE s; DROP TABLE t1; - diff --git a/mysql-test/t/fulltext2.test b/mysql-test/t/fulltext2.test index fd97f795534..88967a5dd04 100644 --- a/mysql-test/t/fulltext2.test +++ b/mysql-test/t/fulltext2.test @@ -221,3 +221,13 @@ drop table t1; set names latin1; # End of 4.1 tests + +# +# BUG#19580 - FULLTEXT search produces wrong results on UTF-8 columns +# +SET NAMES utf8; +CREATE TABLE t1(a VARCHAR(255), FULLTEXT(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8; +INSERT INTO t1 VALUES('„MySQL“'); +SELECT a FROM t1 WHERE MATCH a AGAINST('“MySQL„' IN BOOLEAN MODE); +DROP TABLE t1; +SET NAMES latin1; diff --git a/mysql-test/t/fulltext3.test b/mysql-test/t/fulltext3.test index a57fd48daaa..1b6a07c540f 100644 --- a/mysql-test/t/fulltext3.test +++ b/mysql-test/t/fulltext3.test @@ -22,3 +22,13 @@ DROP TABLE t1; # End of 5.0 tests +# +# BUG#29464 - load data infile into table with big5 chinese fulltext index +# hangs 100% cpu +# +CREATE TABLE t1(a VARCHAR(2) CHARACTER SET big5 COLLATE big5_chinese_ci, +FULLTEXT(a)); +INSERT INTO t1 VALUES(0xA3C2); +DROP TABLE t1; + +# End of 5.1 tests diff --git a/mysql-test/t/fulltext_plugin-master.opt b/mysql-test/t/fulltext_plugin-master.opt new file mode 100644 index 00000000000..a2554caa20b --- /dev/null +++ b/mysql-test/t/fulltext_plugin-master.opt @@ -0,0 +1 @@ +$SIMPLE_PARSER_OPT diff --git a/mysql-test/t/fulltext_plugin.test b/mysql-test/t/fulltext_plugin.test new file mode 100644 index 00000000000..31978dadc51 --- /dev/null +++ b/mysql-test/t/fulltext_plugin.test @@ -0,0 +1,10 @@ +--source include/have_simple_parser.inc + +# +# BUG#39746 - Debug flag breaks struct definition (server crash) +# +INSTALL PLUGIN simple_parser SONAME 'mypluglib.so'; +CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a) WITH PARSER simple_parser); +ALTER TABLE t1 ADD FULLTEXT(b) WITH PARSER simple_parser; +DROP TABLE t1; +UNINSTALL PLUGIN simple_parser; diff --git a/mysql-test/t/func_compress.test b/mysql-test/t/func_compress.test index 2ee222c6a10..d63130f190d 100644 --- a/mysql-test/t/func_compress.test +++ b/mysql-test/t/func_compress.test @@ -45,9 +45,14 @@ drop table t1; set @@global.max_allowed_packet=1048576*100; --replace_result "''" XXX "'1'" XXX + # reconnect to make the new max packet size take effect --connect (newconn, localhost, root,,) eval select compress(repeat('aaaaaaaaaa', IF('$LOW_MEMORY', 10, 10000000))) is null; +disconnect newconn; +--source include/wait_until_disconnected.inc +connection default; +set @@global.max_allowed_packet=default; # # Bug #18643: problem with null values diff --git a/mysql-test/t/func_concat.test b/mysql-test/t/func_concat.test index f2aa0d004e5..1c7e5823fb2 100644 --- a/mysql-test/t/func_concat.test +++ b/mysql-test/t/func_concat.test @@ -78,3 +78,37 @@ SELECT * FROM t1 WHERE CONCAT(c1,' ',c2) REGEXP 'First.*'; DROP TABLE t1; --echo # End of 5.0 tests + + +--echo # +--echo # Bug #44743: Join in combination with concat does not always work +--echo # +CREATE TABLE t1 ( + a VARCHAR(100) NOT NULL DEFAULT '0', + b VARCHAR(2) NOT NULL DEFAULT '', + c VARCHAR(2) NOT NULL DEFAULT '', + d TEXT NOT NULL, + PRIMARY KEY (a, b, c), + KEY (a) +) DEFAULT CHARSET=utf8; + +INSERT INTO t1 VALUES ('gui_A', 'a', 'b', 'str1'), + ('gui_AB', 'a', 'b', 'str2'), ('gui_ABC', 'a', 'b', 'str3'); + +CREATE TABLE t2 ( + a VARCHAR(100) NOT NULL DEFAULT '', + PRIMARY KEY (a) +) DEFAULT CHARSET=latin1; + +INSERT INTO t2 VALUES ('A'), ('AB'), ('ABC'); + +SELECT CONCAT('gui_', t2.a), t1.d FROM t2 + LEFT JOIN t1 ON t1.a = CONCAT('gui_', t2.a) AND t1.b = 'a' AND t1.c = 'b'; + +EXPLAIN SELECT CONCAT('gui_', t2.a), t1.d FROM t2 + LEFT JOIN t1 ON t1.a = CONCAT('gui_', t2.a) AND t1.b = 'a' AND t1.c = 'b'; + +DROP TABLE t1, t2; + + +--echo # End of 5.1 tests diff --git a/mysql-test/t/func_encrypt.test b/mysql-test/t/func_encrypt.test index bcf1e5a77f4..879732fc81f 100644 --- a/mysql-test/t/func_encrypt.test +++ b/mysql-test/t/func_encrypt.test @@ -88,3 +88,18 @@ select hex(des_decrypt(des_encrypt("hello","hidden"))); explain extended select des_decrypt(des_encrypt("hello",4),'password2'), des_decrypt(des_encrypt("hello","hidden")); # End of 4.1 tests + +# +# Bug#44365 valgrind warnings with encrypt() function +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (f1 smallint(6) default null, f2 mediumtext character set utf8) +engine=myisam default charset=latin1; +insert into t1 values (null,'contraction\'s'); +insert into t1 values (-15818,'requirement\'s'); +--disable_result_log +select encrypt(f1,f2) as a from t1,(select encrypt(f1,f2) as b from t1) a; +--enable_result_log +drop table t1; diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 816ac9c2959..e92f3e96303 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -177,8 +177,8 @@ select t1.a, group_concat(c order by (select mid(group_concat(c order by a),1,5) select t1.a, group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a) desc) as grp from t1 group by 1; # The following returns random results as we are sorting on blob addresses -# select group_concat(c order by (select group_concat(c order by a) from t2 where t2.a=t1.a)) as grp from t1; -# select group_concat(c order by (select group_concat(c) from t2 where a=t1.a)) as grp from t1; +select group_concat(c order by (select concat(5-t1.c,group_concat(c order by a)) from t2 where t2.a=t1.a)) as grp from t1; +select group_concat(c order by (select concat(t1.c,group_concat(c)) from t2 where a=t1.a)) as grp from t1; select a,c,(select group_concat(c order by a) from t2 where a=t1.a) as grp from t1 order by grp; drop table t1,t2; diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index cfa2e038fa2..6e39795a5d6 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -18,6 +18,8 @@ insert into t1 values (3,5,"C"); insert into t1 values (3,6,"D"); # Test of MySQL field extension with and without matching records. +#### Note: The two following statements may fail if the execution plan +#### or optimizer is changed. The result for column c is undefined. select a,c,sum(a) from t1 group by a; select a,c,sum(a) from t1 where a > 10 group by a; select sum(a) from t1 where a > 10; @@ -380,13 +382,15 @@ explain select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME'; drop table t1, t2; ---disable_warnings -create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB; ---enable_warnings -insert into t1 values (1, 3); -select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ; -select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ; -drop table t1; +# Moved to func_group_innodb +#--disable_warnings +#create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB; +#--enable_warnings +#insert into t1 values (1, 3); +#select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ; +#select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ; +#drop table t1; + create table t1 (a char(10)); insert into t1 values ('a'),('b'),('c'); @@ -541,6 +545,11 @@ INSERT INTO t1 VALUES SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6; DROP TABLE t1; + +# +# Bug #12882 min/max inconsistent on empty table +# +# Test case moved to func_group_innodb # # Bug #18206: min/max optimization cannot be applied to partial index # @@ -927,35 +936,6 @@ SELECT AVG(a), CAST(AVG(a) AS DECIMAL) FROM t1; DROP TABLE t1; # -# Bug #39656: Behaviour different for agg functions with & without where - -# ONLY_FULL_GROUP_BY -# - -CREATE TABLE t1 (a INT, b INT); -INSERT INTO t1 VALUES (1,1), (1,2), (1,3); - -SET SQL_MODE='ONLY_FULL_GROUP_BY'; - -SELECT COUNT(*) FROM t1; -SELECT COUNT(*) FROM t1 where a=1; - ---error ER_MIX_OF_GROUP_FUNC_AND_FIELDS -SELECT COUNT(*),a FROM t1; - -SELECT COUNT(*) FROM t1 a JOIN t1 b ON a.a= b.a; - ---error ER_MIX_OF_GROUP_FUNC_AND_FIELDS -SELECT COUNT(*), (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a) - FROM t1 outr; - -SELECT COUNT(*) FROM t1 a JOIN t1 outr - ON a.a= (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a); - -SET SQL_MODE=default; -DROP TABLE t1; - - -# # Bug #37348: Crash in or immediately after JOIN::make_sum_func_list # @@ -995,5 +975,82 @@ GROUP BY int_nokey LIMIT 1; DROP TABLE derived1; DROP TABLE D; +# +# Bug #39656: Behaviour different for agg functions with & without where - +# ONLY_FULL_GROUP_BY +# + +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1), (1,2), (1,3); + +SET SQL_MODE='ONLY_FULL_GROUP_BY'; + +SELECT COUNT(*) FROM t1; +SELECT COUNT(*) FROM t1 where a=1; + +--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS +SELECT COUNT(*),a FROM t1; + +SELECT COUNT(*) FROM t1 a JOIN t1 b ON a.a= b.a; + +--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS +SELECT COUNT(*), (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a) + FROM t1 outr; + +SELECT COUNT(*) FROM t1 a JOIN t1 outr + ON a.a= (SELECT count(*) FROM t1 inr WHERE inr.a = outr.a); + +SET SQL_MODE=default; +DROP TABLE t1; + + ### --echo End of 5.0 tests + +--echo # +--echo # BUG#47280 - strange results from count(*) with order by multiple +--echo # columns without where/group +--echo # + +--echo # +--echo # Initialize test +--echo # + +CREATE TABLE t1 ( + pk INT NOT NULL, + i INT, + PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,11),(2,12),(3,13); + +--echo # +--echo # Start test +--echo # All the following queries shall return 1 record +--echo # + +--echo +--echo # Masking all correct values {11...13} for column i in this result. +--replace_column 2 # +SELECT MAX(pk) as max, i +FROM t1 +ORDER BY max; + +--echo +EXPLAIN +SELECT MAX(pk) as max, i +FROM t1 +ORDER BY max; + +--echo +--echo # Only 11 is correct for collumn i in this result +SELECT MAX(pk) as max, i +FROM t1 +WHERE pk<2 +ORDER BY max; + +--echo # +--echo # Cleanup +--echo # +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/func_group_innodb.test b/mysql-test/t/func_group_innodb.test new file mode 100644 index 00000000000..1bdfd8f54bb --- /dev/null +++ b/mysql-test/t/func_group_innodb.test @@ -0,0 +1,85 @@ +# +# Test of group functions that depend on innodb +# + +--source include/have_innodb.inc + +--disable_warnings +create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) engine=InnoDB; +--enable_warnings +insert into t1 values (1, 3); +select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ; +select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ; +drop table t1; + + +# +# Bug #12882 min/max inconsistent on empty table +# + +--disable_warnings +create table t1m (a int) engine=myisam; +create table t1i (a int) engine=innodb; +create table t2m (a int) engine=myisam; +create table t2i (a int) engine=innodb; +--enable_warnings +insert into t2m values (5); +insert into t2i values (5); + +# test with MyISAM +select min(a) from t1m; +select min(7) from t1m; +select min(7) from DUAL; +explain select min(7) from t2m join t1m; +select min(7) from t2m join t1m; + +select max(a) from t1m; +select max(7) from t1m; +select max(7) from DUAL; +explain select max(7) from t2m join t1m; +select max(7) from t2m join t1m; + +select 1, min(a) from t1m where a=99; +select 1, min(a) from t1m where 1=99; +select 1, min(1) from t1m where a=99; +select 1, min(1) from t1m where 1=99; + +select 1, max(a) from t1m where a=99; +select 1, max(a) from t1m where 1=99; +select 1, max(1) from t1m where a=99; +select 1, max(1) from t1m where 1=99; + +# test with InnoDB +select min(a) from t1i; +select min(7) from t1i; +select min(7) from DUAL; +explain select min(7) from t2i join t1i; +select min(7) from t2i join t1i; + +select max(a) from t1i; +select max(7) from t1i; +select max(7) from DUAL; +explain select max(7) from t2i join t1i; +select max(7) from t2i join t1i; + +select 1, min(a) from t1i where a=99; +select 1, min(a) from t1i where 1=99; +select 1, min(1) from t1i where a=99; +select 1, min(1) from t1i where 1=99; + +select 1, max(a) from t1i where a=99; +select 1, max(a) from t1i where 1=99; +select 1, max(1) from t1i where a=99; +select 1, max(1) from t1i where 1=99; + +# mixed MyISAM/InnoDB test +explain select count(*), min(7), max(7) from t1m, t1i; +select count(*), min(7), max(7) from t1m, t1i; + +explain select count(*), min(7), max(7) from t1m, t2i; +select count(*), min(7), max(7) from t1m, t2i; + +explain select count(*), min(7), max(7) from t2m, t1i; +select count(*), min(7), max(7) from t2m, t1i; + +drop table t1m, t1i, t2m, t2i; diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index a84ffada1ee..61ae812d874 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -268,13 +268,14 @@ CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); -INSERT INTO t2 VALUES (3,2),(4,2); +INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); CREATE TABLE t3 (a int PRIMARY KEY); INSERT INTO t3 VALUES (1),(2),(3),(4); -CREATE TABLE t4 (a int PRIMARY KEY); -INSERT INTO t4 VALUES (1),(2); +CREATE TABLE t4 (a int PRIMARY KEY,b int); +INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002), + (1003,1003),(1004,1004); EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 JOIN t1 ON t3.a=t1.a @@ -381,3 +382,163 @@ SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) ); DROP TABLE t1; --echo End of 5.0 tests + + +# +# Bug#18360: Type aggregation for IN and CASE may lead to a wrong result +# +create table t1(f1 char(1)); +insert into t1 values ('a'),('b'),('1'); +select f1 from t1 where f1 in ('a',1); +select f1, case f1 when 'a' then '+' when 1 then '-' end from t1; +create index t1f1_idx on t1(f1); +select f1 from t1 where f1 in ('a',1); +explain select f1 from t1 where f1 in ('a',1); +select f1 from t1 where f1 in ('a','b'); +explain select f1 from t1 where f1 in ('a','b'); +select f1 from t1 where f1 in (2,1); +explain select f1 from t1 where f1 in (2,1); +create table t2(f2 int, index t2f2(f2)); +insert into t2 values(0),(1),(2); +select f2 from t2 where f2 in ('a',2); +explain select f2 from t2 where f2 in ('a',2); +select f2 from t2 where f2 in ('a','b'); +explain select f2 from t2 where f2 in ('a','b'); +select f2 from t2 where f2 in (1,'b'); +explain select f2 from t2 where f2 in (1,'b'); +drop table t1, t2; + +# +# Bug #31075: crash in get_func_mm_tree +# + +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +drop table t1; + +# +# Bug #37761: IN handles NULL differently for table-subquery and value-list +# + +create table t1 (id int); +select * from t1 where NOT id in (select null union all select 1); +select * from t1 where NOT id in (null, 1); +drop table t1; + +# +# Bug #41363: crash of mysqld on windows with aggregate in case +# + +CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER); +INSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1); + +SELECT CASE AVG (c0) WHEN c1 * c2 THEN 1 END FROM t1; +SELECT CASE c1 * c2 WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1; +SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; + +DROP TABLE t1; + +# +# Bug #44399: crash with statement using TEXT columns, aggregates, GROUP BY, +# and HAVING +# + +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN + ((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +DROP TABLE t1; + +--echo # +--echo # Bug #44139: Table scan when NULL appears in IN clause +--echo # + +--disable_warnings + +CREATE TABLE t1 ( + c_int INT NOT NULL, + c_decimal DECIMAL(5,2) NOT NULL, + c_float FLOAT(5, 2) NOT NULL, + c_bit BIT(10) NOT NULL, + c_date DATE NOT NULL, + c_datetime DATETIME NOT NULL, + c_timestamp TIMESTAMP NOT NULL, + c_time TIME NOT NULL, + c_year YEAR NOT NULL, + c_char CHAR(10) NOT NULL, + INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date), + INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year), + INDEX(c_char)); + +INSERT INTO t1 (c_int) VALUES (1), (2), (3), (4), (5); +INSERT INTO t1 (c_int) SELECT 0 FROM t1; +INSERT INTO t1 (c_int) SELECT 0 FROM t1; + +--enable_warnings + +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3); + +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3); +EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL); +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL); +EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL); + +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3); +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3); +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL); +EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL); + +EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3); +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3); +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL); +EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL); + +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3); +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3); +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL); +EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL); + +EXPLAIN SELECT * FROM t1 WHERE c_date + IN ('2009-09-01', '2009-09-02', '2009-09-03'); +EXPLAIN SELECT * FROM t1 WHERE c_date + IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03'); +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL); +EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL); + +EXPLAIN SELECT * FROM t1 WHERE c_datetime + IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +EXPLAIN SELECT * FROM t1 WHERE c_datetime + IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01'); +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL); +EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL); + +EXPLAIN SELECT * FROM t1 WHERE c_timestamp + IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +EXPLAIN SELECT * FROM t1 WHERE c_timestamp + IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); +EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL); + +EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3); +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3); +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL); +EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL); + +EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3'); +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3'); +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL); +EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL); + +DROP TABLE t1; + +--echo # + +--echo End of 5.1 tests diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test index 4e1183afeff..741ea5533da 100644 --- a/mysql-test/t/func_like.test +++ b/mysql-test/t/func_like.test @@ -8,8 +8,8 @@ drop table if exists t1; create table t1 (a varchar(10), key(a)); insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); -explain select * from t1 where a like 'abc%'; -explain select * from t1 where a like concat('abc','%'); +explain extended select * from t1 where a like 'abc%'; +explain extended select * from t1 where a like concat('abc','%'); select * from t1 where a like "abc%"; select * from t1 where a like concat("abc","%"); select * from t1 where a like "ABC%"; diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 2c1094213e4..91fdce8addb 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -34,6 +34,11 @@ select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6) explain extended select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6); select degrees(pi()),radians(360); +select format(atan(-2, 2), 6); +select format(atan(pi(), 0), 6); +select format(atan2(-2, 2), 6); +select format(atan2(pi(), 0), 6); + # # Bug #2338 Trignometric arithmatic problems # @@ -105,11 +110,25 @@ select abs(-2) * -2; # # Bug #6172 RAND(a) should only accept constant values as arguments # -create table t1 (i int); -insert into t1 values (1); ---error 1210 -select rand(i) from t1; -drop table t1; +CREATE TABLE t1 (a INT); + +INSERT INTO t1 VALUES (1),(1),(1),(2); +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) + FROM t1; +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) + FROM t1 WHERE a = 1; +INSERT INTO t1 VALUES (3); +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) + FROM t1; +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) + FROM t1 WHERE a = 1; +PREPARE stmt FROM + "SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(?) * 1000 AS UNSIGNED) + FROM t1 WHERE a = 1"; +set @var=2; +EXECUTE stmt USING @var; + +DROP TABLE t1; # # Bug #14009: use of abs() on null value causes problems with filesort @@ -260,3 +279,34 @@ SELECT 1 FROM (SELECT ROUND(f1, f1) AS a FROM t1) AS s WHERE a LIKE 'a'; DROP TABLE t1; --echo End of 5.0 tests + +# +# Bug #31236: Inconsistent division by zero behavior for floating point numbers +# + +SELECT 1e308 + 1e308; +SELECT -1e308 - 1e308; +SELECT 1e300 * 1e300; +SELECT 1e300 / 1e-300; +SELECT EXP(750); +SELECT POW(10, 309); + +--echo # +--echo # Bug #44768: SIGFPE crash when selecting rand from a view +--echo # containing null +--echo # + +CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a; +SELECT RAND(a) FROM v1; +DROP VIEW v1; + +SELECT RAND(a) FROM (SELECT NULL AS a) b; + +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (NULL); +SELECT RAND(i) FROM t1; +DROP TABLE t1; + +--echo # + +--echo End of 5.1 tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 01c508c9b58..6590b43f2dc 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -2,6 +2,10 @@ # Testing of misc functions # +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + select format(1.5555,0),format(123.5555,1),format(1234.5555,2),format(12345.55555,3),format(123456.5555,4),format(1234567.5555,5),format("12345.2399",2); select inet_ntoa(inet_aton("255.255.255.255.255.255.255.255")); @@ -14,6 +18,12 @@ select hex(inet_aton('127.1.1')); select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8''))); +# As we can assume we are the only user for the mysqld server, the difference +# between two calls should be -1 +set @a= uuid_short(); +set @b= uuid_short(); +select cast(@a - @b as signed); + # # Test for core dump with nan # @@ -42,9 +52,6 @@ drop table t1; # # Bug#16501: IS_USED_LOCK does not appear to work # ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings CREATE TABLE t1 (conn CHAR(7), connection_id INT); INSERT INTO t1 VALUES ('default', CONNECTION_ID()); @@ -89,7 +96,9 @@ select export_set(3, _latin1'foo', _utf8'bar', ',', 4); # # Test for BUG#9535 # +--disable_warnings create table t1 as select uuid(), length(uuid()); +--enable_warnings show create table t1; drop table t1; @@ -452,3 +461,10 @@ select NAME_CONST('_id',1234) as id; --echo End of 5.0 tests +# +# Bug #30389: connection_id() always return 0 in embedded server +# + +select connection_id() > 0; + +--echo End of tests diff --git a/mysql-test/t/func_regexp.test b/mysql-test/t/func_regexp.test index 43fda0d11a8..638e0bf08ee 100644 --- a/mysql-test/t/func_regexp.test +++ b/mysql-test/t/func_regexp.test @@ -75,3 +75,20 @@ SELECT 'A' REGEXP BINARY NULL; SELECT "ABC" REGEXP BINARY NULL; --echo End of 5.0 tests + + +# +# Bug #37337: Function returns different results +# +CREATE TABLE t1(a INT, b CHAR(4)); +INSERT INTO t1 VALUES (1, '6.1'), (1, '7.0'), (1, '8.0'); +PREPARE stmt1 FROM "SELECT a FROM t1 WHERE a=1 AND '7.0' REGEXP b LIMIT 1"; +EXECUTE stmt1; +EXECUTE stmt1; +EXECUTE stmt1; +EXECUTE stmt1; +DEALLOCATE PREPARE stmt1; +DROP TABLE t1; + + +--echo End of 5.1 tests diff --git a/mysql-test/t/func_rollback.test b/mysql-test/t/func_rollback.test new file mode 100644 index 00000000000..87930909f91 --- /dev/null +++ b/mysql-test/t/func_rollback.test @@ -0,0 +1,488 @@ +# func_rollback.test +# +# Test variations inspired by +# Bug#12713 Error in a stored function called from a SELECT doesn't cause +# ROLLBACK of statement +# Essential of the bug: +# - A SELECT using a FUNCTION processes a table. +# - The SELECT affects more than row. +# - The FUNCTION modifies a table. +# - When processing the non first matching row, the function fails. +# But the modification caused by the function when the SELECT processed the +# first matching row is not reverted. +# +# Goal of this test: Attempts to catch a situation where +# - a statement A involving the execution of one or more functions is run +# - the function/functions themself contain one or more statements +# modifying a table +# - one of the modifying statements within one of the functions fails +# - the table remains at least partially modified +# +# = There is no automatic ROLLBACK of changes caused by the failing +# statement A. +# = Statement A is not atomic. +# +# Notes: +# - The table to be modified must use a transactional storage engine. +# For example MyISAM cannot avoid the situation above. +# - Some comments assume that the rows of the table t1_select are processed +# in the order of insertion. That means +# SELECT f1,f2 FROM t1_select +# should have the same result set and row order like +# SELECT f1,f2 FROM t1_select ORDER BY f1; +# - The manual says that we get in non strict sql mode a warning around INSERT: +# Inserting NULL into a column that has been declared NOT NULL. +# For multiple-row INSERT statements or INSERT INTO ... SELECT statements, +# the column is set to the implicit default value for the column data type. +# +# Created: +# 2008-04-09 mleich +# + +let $fixed_bug_35877 = 0; + +let $from_select = SELECT 1 AS f1,1 AS f2 UNION ALL SELECT 1,NULL; + +--source include/have_innodb.inc +let $engine = InnoDB; + +--disable_warnings +DROP TABLE IF EXISTS t1_select; +DROP TABLE IF EXISTS t1_aux; +DROP TABLE IF EXISTS t1_not_null; +DROP VIEW IF EXISTS v1_not_null; +DROP VIEW IF EXISTS v1_func; +DROP TABLE IF EXISTS t1_fail; +DROP FUNCTION IF EXISTS f1_simple_insert; +DROP FUNCTION IF EXISTS f1_two_inserts; +DROP FUNCTION IF EXISTS f1_insert_select; +--enable_warnings + +SET SESSION AUTOCOMMIT=0; +SET SESSION sql_mode = ''; + +CREATE TABLE t1_select (f1 BIGINT, f2 BIGINT) ENGINE = MEMORY; +INSERT INTO t1_select(f1,f2) VALUES (1,-1),(2,NULL),(3,0),(4,1),(5,2); +SELECT * FROM t1_select; + +--replace_result $engine <transactional_engine> +eval +CREATE TABLE t1_not_null (f1 BIGINT, f2 BIGINT NOT NULL) +ENGINE = $engine; +SELECT * FROM t1_not_null; + +--replace_result $engine <transactional_engine> +eval +CREATE TABLE t1_aux (f1 BIGINT, f2 BIGINT) +ENGINE = $engine; +SELECT * FROM t1_aux; +COMMIT; + +# FUNCTION with "simple" INSERT +delimiter //; +CREATE FUNCTION f1_simple_insert(my_f1 INTEGER) RETURNS INTEGER +BEGIN + INSERT INTO t1_not_null SET f1 = 10, f2 = my_f1; + RETURN 1; +END// +delimiter ;// + +--echo +--echo # One f1_simple_insert execution per row, no NOT NULL violation +SELECT f1_simple_insert(1); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null; +# +SELECT f1_simple_insert(1) FROM t1_select; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null; + +--echo +--echo # One f1_simple_insert execution per row, NOT NULL violation when the +--echo # SELECT processes the first row. +--error ER_BAD_NULL_ERROR +SELECT f1_simple_insert(NULL); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +SELECT f1_simple_insert(NULL) FROM t1_select; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +eval SELECT 1 FROM ($from_select) AS t1 WHERE f1_simple_insert(NULL) = 1; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; + +--echo +--echo # One f1_simple_insert execution per row, NOT NULL violation when the +--echo # SELECT processes the non first row +--error ER_BAD_NULL_ERROR +eval SELECT f1_simple_insert(f2) FROM ($from_select) AS t1; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +SELECT f1_simple_insert(f2) FROM t1_select; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; + +--echo +--echo # Two f1_simple_insert executions per row, NOT NULL violation when the +--echo # SELECT processes the first row. +--error ER_BAD_NULL_ERROR +SELECT f1_simple_insert(1),f1_simple_insert(NULL); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +SELECT f1_simple_insert(NULL),f1_simple_insert(1); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; + +--echo +--echo # Two f1_simple_insert executions per row, NOT NULL violation when the +--echo # SELECT processes the non first row +--error ER_BAD_NULL_ERROR +eval SELECT f1_simple_insert(f1),f1_simple_insert(f2) FROM ($from_select) AS t1; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +eval SELECT f1_simple_insert(f2),f1_simple_insert(f1) FROM ($from_select) AS t1; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +SELECT f1_simple_insert(f1),f1_simple_insert(f2) FROM t1_select; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +SELECT f1_simple_insert(f2),f1_simple_insert(f1) FROM t1_select; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +eval SELECT 1 FROM ($from_select) AS t1 +WHERE 1 = f1_simple_insert(f2) AND 1 = f1_simple_insert(f1); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; + +--echo +--echo # Nested functions, the inner fails +--error ER_BAD_NULL_ERROR +SELECT f1_simple_insert(f1_simple_insert(NULL)) FROM t1_select; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +--echo +--echo # Nested functions, the outer fails +--error ER_BAD_NULL_ERROR +SELECT f1_simple_insert(f1_simple_insert(1) + NULL) FROM t1_select; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +DROP FUNCTION f1_simple_insert; + +# FUNCTION with INSERT ... SELECT +delimiter //; +let $f1_insert_select = +CREATE FUNCTION f1_insert_select(my_f1 INTEGER) RETURNS INTEGER +BEGIN + INSERT INTO t1_not_null SELECT * FROM t1_select WHERE f1 = my_f1; + RETURN 1; +END// +delimiter ;// +eval $f1_insert_select; +# +--echo +--echo # f1_insert_select(2), tries to INSERT SELECT one row containing NULL +--echo # The fact that +--echo # - SELECT f1_insert_select(2); gives any result set and +--echo # - t1_not_null gets a row inserted +--echo # is covered by the manual. +# Non strict sqlmode + INSERT SELECT --> NULL adjusted to default +SELECT f1_insert_select(2); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +DROP FUNCTION f1_insert_select; +# +SET SESSION sql_mode = 'traditional'; +eval $f1_insert_select; +--error ER_BAD_NULL_ERROR +SELECT f1_insert_select(2); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +DROP FUNCTION f1_insert_select; +SET SESSION sql_mode = ''; + +# FUNCTION with two simple INSERTs +--echo +--echo # Function tries to +--echo # 1. INSERT statement: Insert one row with NULL -> NOT NULL violation +--echo # 2. INSERT statement: Insert one row without NULL +# I guess the execution of the function becomes aborted just when the +# error happens. +delimiter //; +CREATE FUNCTION f1_two_inserts() RETURNS INTEGER +BEGIN + INSERT INTO t1_not_null SET f1 = 10, f2 = NULL; + INSERT INTO t1_not_null SET f1 = 10, f2 = 10; + RETURN 1; +END// +delimiter ;// +--error ER_BAD_NULL_ERROR +SELECT f1_two_inserts(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +DROP FUNCTION f1_two_inserts; +# +--echo +--echo # Function tries to +--echo # 1. INSERT statement: Insert one row without NULL +--echo # 2. INSERT statement: Insert one row with NULL -> NOT NULL violation +delimiter //; +CREATE FUNCTION f1_two_inserts() RETURNS INTEGER +BEGIN + INSERT INTO t1_not_null SET f1 = 10, f2 = 10; + INSERT INTO t1_not_null SET f1 = 10, f2 = NULL; + RETURN 1; +END// +delimiter ;// +--error ER_BAD_NULL_ERROR +SELECT f1_two_inserts(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; + +--echo +--echo # Function tries to +--echo # INSERT statement: Insert two rows +--echo # first row without NULL +--echo # second row with NULL -> NOT NULL violation +--echo # -> NOT NULL violation +delimiter //; +let $f1_insert_with_two_rows = +CREATE FUNCTION f1_insert_with_two_rows() RETURNS INTEGER +BEGIN + INSERT INTO t1_not_null(f1,f2) VALUES (10,10),(10,NULL); + RETURN 1; +END// +delimiter ;// +eval $f1_insert_with_two_rows; +--echo # The fact that +--echo # - SELECT f1_insert_with_two_rows(); gives any result set and +--echo # - t1_not_null gets a row inserted +--echo # is covered by the manual. +# Non strict sqlmode + multiple-row INSERT --> NULL adjusted to default +SELECT f1_insert_with_two_rows(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +DROP FUNCTION f1_insert_with_two_rows; +# +SET SESSION sql_mode = 'traditional'; +eval $f1_insert_with_two_rows; +--error ER_BAD_NULL_ERROR +SELECT f1_insert_with_two_rows(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +SET SESSION sql_mode = ''; + +--echo +--echo # FUNCTION in Correlated Subquery +--error ER_BAD_NULL_ERROR +SELECT 1 FROM t1_select t1 +WHERE 1 = (SELECT f1_insert_with_two_rows() FROM t1_select t2 + WHERE t2.f1 = t1.f1); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; + +--echo +--echo # FUNCTION in JOIN +--error ER_BAD_NULL_ERROR +SELECT 1 FROM t1_select t1, t1_select t2 +WHERE t1.f1 = t2.f1 AND t2.f1 = f1_insert_with_two_rows(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +SELECT STRAIGHT_JOIN * FROM t1_select t2 RIGHT JOIN t1_select t1 +ON t1.f1 = t1.f1 WHERE 1 = f1_insert_with_two_rows(); + +DROP FUNCTION f1_insert_with_two_rows; + +--echo +--echo # FUNCTION in UNION +--error ER_BAD_NULL_ERROR +SELECT 1 +UNION ALL +SELECT f1_two_inserts(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; + +--echo +--echo # FUNCTION in INSERT +--error ER_BAD_NULL_ERROR +INSERT INTO t1_aux SET f1 = 1, f2 = f1_two_inserts(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +INSERT INTO t1_aux SELECT 1, f1_two_inserts(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +SELECT * FROM t1_aux ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +INSERT INTO t1_aux VALUES(1,f1_two_inserts()); +SELECT * FROM t1_not_null ORDER BY f1,f2; +SELECT * FROM t1_aux ORDER BY f1,f2; + +--echo +--echo # FUNCTION in DELETE +INSERT INTO t1_aux VALUES (1,1); +COMMIT; +--error ER_BAD_NULL_ERROR +DELETE FROM t1_aux WHERE f1 = f1_two_inserts(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +SELECT * FROM t1_aux ORDER BY f1,f2; + +--echo +--echo # FUNCTION in UPDATE SET +# FUNCTION in SET +--error ER_BAD_NULL_ERROR +UPDATE t1_aux SET f2 = f1_two_inserts() + 1; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +SELECT * FROM t1_aux ORDER BY f1,f2; +# +if ($fixed_bug_35877) +{ +--echo +--echo # FUNCTION in UPDATE WHERE +# Bug#35877 Update .. WHERE with function, constraint violation, crash +UPDATE t1_aux SET f2 = 2 WHERE f1 = f1_two_inserts(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +SELECT * FROM t1_aux ORDER BY f1,f2; +} + +--echo +--echo # FUNCTION in VIEW definition +CREATE VIEW v1_func AS SELECT f1_two_inserts() FROM t1_select; +--error ER_BAD_NULL_ERROR +SELECT * FROM v1_func; +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +DROP VIEW v1_func; + +--echo +--echo # FUNCTION in CREATE TABLE ... AS SELECT +--error ER_BAD_NULL_ERROR +CREATE TABLE t1_fail AS SELECT f1_two_inserts() FROM t1_select; +SELECT * FROM t1_not_null ORDER BY f1,f2; +# +--error ER_BAD_NULL_ERROR +CREATE TABLE t1_fail AS SELECT * FROM t1_select WHERE 1 = f1_two_inserts(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +# + +--echo +--echo # FUNCTION in ORDER BY +--error ER_BAD_NULL_ERROR +SELECT * FROM t1_select ORDER BY f1,f1_two_inserts(); +SELECT * FROM t1_not_null ORDER BY f1,f2; + +--echo +--echo # FUNCTION in aggregate function +--error ER_BAD_NULL_ERROR +SELECT AVG(f1_two_inserts()) FROM t1_select; +SELECT * FROM t1_not_null ORDER BY f1,f2; + +--echo +--echo # FUNCTION in HAVING +--error ER_BAD_NULL_ERROR +SELECT 1 FROM t1_select HAVING AVG(f1) = f1_two_inserts() + 2; +SELECT * FROM t1_not_null ORDER BY f1,f2; +DROP FUNCTION f1_two_inserts; + +--echo +--echo # FUNCTION modifies Updatable VIEW +CREATE VIEW v1_not_null AS SELECT f1,f2 FROM t1_not_null WITH CHECK OPTION; +delimiter //; +CREATE FUNCTION f1_two_inserts_v1() RETURNS INTEGER +BEGIN + INSERT INTO v1_not_null SET f1 = 10, f2 = 10; + INSERT INTO v1_not_null SET f1 = 10, f2 = NULL; + RETURN 1; +END// +delimiter ;// +--error ER_BAD_NULL_ERROR +SELECT f1_two_inserts_v1(); +SELECT * FROM t1_not_null ORDER BY f1,f2; +ROLLBACK; +SELECT * FROM t1_not_null ORDER BY f1,f2; +DROP FUNCTION f1_two_inserts_v1; +DROP VIEW v1_not_null; + +--echo +--echo # FUNCTION causes FOREIGN KEY constraint violation +eval +CREATE TABLE t1_parent (f1 BIGINT, f2 BIGINT, PRIMARY KEY(f1)) +ENGINE = $engine; +INSERT INTO t1_parent VALUES (1,1); +eval +CREATE TABLE t1_child (f1 BIGINT, f2 BIGINT, PRIMARY KEY(f1), +FOREIGN KEY (f1) REFERENCES t1_parent(f1)) +ENGINE = $engine; +--error ER_NO_REFERENCED_ROW_2 +delimiter //; +CREATE FUNCTION f1_two_inserts() RETURNS INTEGER +BEGIN + INSERT INTO t1_child SET f1 = 1, f2 = 1; + INSERT INTO t1_child SET f1 = 2, f2 = 2; + RETURN 1; +END// +delimiter ;// +--error ER_NO_REFERENCED_ROW_2 +SELECT f1_two_inserts(); +SELECT * FROM t1_child; +DROP TABLE t1_child; +DROP TABLE t1_parent; +DROP FUNCTION f1_two_inserts; + +# Cleanup +DROP TABLE t1_select; +DROP TABLE t1_aux; +DROP TABLE t1_not_null; diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test index e4fde6e0e0e..294efa8caf1 100644 --- a/mysql-test/t/func_set.test +++ b/mysql-test/t/func_set.test @@ -72,3 +72,28 @@ SELECT INTERVAL(0.0, CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL)); --echo End of 5.0 tests + +# +# Bug#44367 valgrind warnings with find_in_set() functions +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (f1 set('test1','test2','test3') character set utf8 default null) +engine=myisam default charset=latin1; +insert into t1 values (''),(null),(null),(''),(''),(''); +select find_in_set(f1,f1) as a from t1,(select find_in_set(f1,f1) as b from t1) a; +drop table t1; +# +# Bug#45168: assertion with convert() and empty set value +# +CREATE TABLE t1( a SET('a', 'b', 'c') ); +CREATE TABLE t2( a SET('a', 'b', 'c') ); + +INSERT INTO t1 VALUES ('d'); +INSERT INTO t2 VALUES (''); + +SELECT CONVERT( a USING latin1 ) FROM t1; +SELECT CONVERT( a USING latin1 ) FROM t2; + +DROP TABLE t1, t2; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index e396fbcebd8..66b9eabd385 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -468,7 +468,51 @@ drop table t7; select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2); -explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'mood' sounds like 'mud', aes_decrypt(aes_encrypt('abc','1'),'1'),concat('*',space(5),'*'), reverse('abc'), rpad('a',4,'1'), lpad('a',4,'1'), concat_ws(',','',NULL,'a'),make_set(255,_latin2'a',_latin2'b',_latin2'c'),elt(2,1),locate("a","b",2),format(130,10),char(0),conv(130,16,10),hex(130),binary 'HE', export_set(255,_latin2'y',_latin2'n',_latin2' '),FIELD('b' COLLATE latin1_bin,'A','B'),FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'),collation(conv(130,16,10)), coercibility(conv(130,16,10)),length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h'),quote(1/0),crc32("123"),replace('aaaa','a','b'),insert('txs',2,1,'hi'),left(_latin2'a',1),right(_latin2'a',1),lcase(_latin2'a'),ucase(_latin2'a'),SUBSTR('abcdefg',3,2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),trim(_latin2' a '),ltrim(_latin2' a '),rtrim(_latin2' a '), decode(encode(repeat("a",100000),"monty"),"monty"); +explain extended select md5('hello'); +explain extended select sha('abc'); +explain extended select sha1('abc'); +explain extended select soundex(''); +explain extended select 'mood' sounds like 'mud'; +explain extended select aes_decrypt(aes_encrypt('abc','1'),'1'); +explain extended select concat('*',space(5),'*'); +explain extended select reverse('abc'); +explain extended select rpad('a',4,'1'); +explain extended select lpad('a',4,'1'); +explain extended select concat_ws(',','',NULL,'a'); +explain extended select make_set(255,_latin2'a', _latin2'b', _latin2'c'); +explain extended select elt(2,1); +explain extended select locate("a","b",2); +explain extended select format(130,10); +explain extended select char(0); +explain extended select conv(130,16,10); +explain extended select hex(130); +explain extended select binary 'HE'; +explain extended select export_set(255,_latin2'y', _latin2'n', _latin2' '); +explain extended select FIELD('b' COLLATE latin1_bin,'A','B'); +explain extended select FIND_IN_SET(_latin1'B', _latin1'a,b,c,d'); +explain extended select collation(conv(130,16,10)); +explain extended select coercibility(conv(130,16,10)); +explain extended select length('\n\t\r\b\0\_\%\\'); +explain extended select bit_length('\n\t\r\b\0\_\%\\'); +explain extended select bit_length('\n\t\r\b\0\_\%\\'); +explain extended select concat('monty',' was here ','again'); +explain extended select length('hello'); +explain extended select char(ascii('h')); +explain extended select ord('h'); +explain extended select quote(1/0); +explain extended select crc32("123"); +explain extended select replace('aaaa','a','b'); +explain extended select insert('txs',2,1,'hi'); +explain extended select left(_latin2'a',1); +explain extended select right(_latin2'a',1); +explain extended select lcase(_latin2'a'); +explain extended select ucase(_latin2'a'); +explain extended select SUBSTR('abcdefg',3,2); +explain extended select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2); +explain extended select trim(_latin2' a '); +explain extended select ltrim(_latin2' a '); +explain extended select rtrim(_latin2' a '); +explain extended select decode(encode(repeat("a",100000),"monty"),"monty"); # # lpad returns incorrect result (Bug #2182) @@ -809,6 +853,76 @@ SELECT * FROM t1 INNER JOIN t2 ON code=id DROP TABLE t1,t2; +# +# Bug#22684: The Functions ENCODE, DECODE and FORMAT are not real functions +# + +select encode(NULL, NULL); +select encode("data", NULL); +select encode(NULL, "password"); + +select decode(NULL, NULL); +select decode("data", NULL); +select decode(NULL, "password"); + +select format(NULL, NULL); +select format(pi(), NULL); +select format(NULL, 2); + +select benchmark(NULL, NULL); +select benchmark(0, NULL); +select benchmark(100, NULL); +select benchmark(NULL, 1+1); + +# +# Bug #20752: BENCHMARK with many iterations returns too quickly +# + +# not a string, but belongs with the above Bug#22684 +select benchmark(-1, 1); + +# +# Please note: +# 1) The collation of the password is irrelevant, the encryption uses +# the binary representation of the string without charset/collation. +# 2) These tests can not print the encoded text directly, because it's binary, +# and doing this would cause problems with source control. +# Instead, an md5() checksum is used, to verify the result indirectly. +# 3) Each md5() result must be identical. +# 4) The md5() result must never change, and must be stable across releases. +# +set @password="password"; +set @my_data="clear text to encode"; +select md5(encode(@my_data, "password")); +select md5(encode(@my_data, _utf8 "password")); +select md5(encode(@my_data, binary "password")); +select md5(encode(@my_data, _latin1 "password")); +select md5(encode(@my_data, _koi8r "password")); +select md5(encode(@my_data, (select "password" from dual))); +select md5(encode(@my_data, concat("pass", "word"))); +select md5(encode(@my_data, @password)); + +set @my_data="binary encoded data"; +select md5(decode(@my_data, "password")); +select md5(decode(@my_data, _utf8 "password")); +select md5(decode(@my_data, binary "password")); +select md5(decode(@my_data, _latin1 "password")); +select md5(decode(@my_data, _koi8r "password")); +select md5(decode(@my_data, (select "password" from dual))); +select md5(decode(@my_data, concat("pass", "word"))); +select md5(decode(@my_data, @password)); + +set @dec=5; +select format(pi(), (1+1)); +select format(pi(), (select 3 from dual)); +select format(pi(), @dec); + +set @bench_count=10; +select benchmark(10, pi()); +select benchmark(5+5, pi()); +select benchmark((select 10 from dual), pi()); +select benchmark(@bench_count, pi()); + # # Bug #10963 @@ -1192,3 +1306,15 @@ DROP TABLE t1, t2; --echo End of 5.0 tests + +# +# Bug#44358 valgrind errors with decode() function +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1(f1 tinyint default null)engine=myisam; +insert into t1 values (-1),(null); +explain select 1 as a from t1,(select decode(f1,f1) as b from t1) a; +explain select 1 as a from t1,(select encode(f1,f1) as b from t1) a; +drop table t1; diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test index 4a526935491..a5041a83623 100644 --- a/mysql-test/t/func_system.test +++ b/mysql-test/t/func_system.test @@ -19,7 +19,7 @@ select version()>=_latin1"3.23.29"; select charset(version()); explain extended select database(), user(); -create table t1 (version char(40)) select database(), user(), version() as 'version'; +create table t1 (version char(60)) select database(), user(), version() as 'version'; show create table t1; drop table t1; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 65d8764f2ce..b9da946a55f 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -540,6 +540,8 @@ DROP TABLE t1; # # check if SEC_TO_TIME() handles BIGINT UNSIGNED values correctly SELECT SEC_TO_TIME(CAST(-1 AS UNSIGNED)); + +# # 21913: DATE_FORMAT() Crashes mysql server if I use it through # mysql-connector-j driver. # @@ -567,7 +569,6 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES (now()), (now()); SELECT 1 FROM t1 ORDER BY MAKETIME(1, 1, a); DROP TABLE t1; - # # Bug #19844 time_format in Union truncates values # @@ -605,14 +606,6 @@ explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2; # -# Bug #10568 -# - -select last_day('2005-00-00'); -select last_day('2005-00-01'); -select last_day('2005-01-00'); - -# # Bug #10590: %h, %I, and %l format specifies should all return results in # the 0-11 range # @@ -622,9 +615,13 @@ select time_format('100:00:00', '%H %k %h %I %l'); # Bug #12562: Make SYSDATE behave like it does in Oracle: always the current # time, regardless of magic to make NOW() always the same for the # entirety of a statement. +SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; +SET GLOBAL log_bin_trust_function_creators = 1; + create table t1 (a timestamp default '2005-05-05 01:01:01', b timestamp default '2005-05-05 01:01:01'); delimiter //; +drop function if exists t_slow_sysdate; create function t_slow_sysdate() returns timestamp begin do sleep(2); @@ -650,6 +647,8 @@ drop trigger t_before; drop function t_slow_sysdate; drop table t1; +SET GLOBAL log_bin_trust_function_creators = 0; + create table t1 (a datetime, i int, b datetime); insert into t1 select sysdate(), sleep(1), sysdate() from dual; select a != b from t1; @@ -667,6 +666,7 @@ end; delimiter ;// call t_sysdate(); drop procedure t_sysdate; +SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators; # # Bug #13534: timestampdiff() returned incorrect results across leap years @@ -714,30 +714,11 @@ SELECT * FROM t1, t2 DROP TABLE t1,t2; -# End of 5.0 tests # Restore timezone to default set time_zone= @@global.time_zone; # -# 21913: DATE_FORMAT() Crashes mysql server if I use it through -# mysql-connector-j driver. -# - -SET NAMES latin1; -SET character_set_results = NULL; -SHOW VARIABLES LIKE 'character_set_results'; - -CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY); -INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd'); - -SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868; - -DROP TABLE testBug8868; - -SET NAMES DEFAULT; - -# # Bug #22229: bug in DATE_ADD() # @@ -839,3 +820,22 @@ SELECT '2008-02-18' + INTERVAL 1 FRAC_SECOND; SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND; --echo End of 5.0 tests + +# +# Bug #18997 +# + +select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND); +select date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND); +select date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND); +select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND); +select date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND); +select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND); +select date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR); +select date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND); +select date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND); +select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND); +select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND); + + +--echo End of 5.1 tests diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test index b5de1ccf248..c325b3bd223 100644 --- a/mysql-test/t/gis-rtree.test +++ b/mysql-test/t/gis-rtree.test @@ -172,7 +172,7 @@ CREATE TABLE t2 (geom GEOMETRY NOT NULL, SPATIAL KEY gk(geom)); INSERT INTO t2 SELECT GeomFromText(st) FROM t1; drop table t1, t2; -CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`(32))) ENGINE=MyISAM DEFAULT CHARSET=latin1; +CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`)) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO t1 (geometry) VALUES (PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000 @@ -192,7 +192,7 @@ drop table t1; # CREATE TABLE t1 ( c1 geometry NOT NULL default '', - SPATIAL KEY i1 (c1(32)) + SPATIAL KEY i1 (c1) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO t1 (c1) VALUES ( PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, @@ -206,7 +206,7 @@ DROP TABLE t1; # CREATE TABLE t1 ( c1 geometry NOT NULL default '', - SPATIAL KEY i1 (c1(32)) + SPATIAL KEY i1 (c1) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO t1 (c1) VALUES ( PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, @@ -251,7 +251,7 @@ CREATE TABLE t1 (id bigint(12) unsigned NOT NULL auto_increment, c3 varchar(10) collate utf8_bin default NULL, spatial_point point NOT NULL, PRIMARY KEY(id), - SPATIAL KEY (spatial_point(32)) + SPATIAL KEY (spatial_point) )ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; # INSERT INTO t1 (c2, c1, c3, spatial_point) VALUES diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index c01fa205349..4a60e777cc7 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -1,5 +1,6 @@ -- source include/have_geometry.inc + # # Spatial objects # @@ -388,7 +389,7 @@ drop table t1; create table t1 (a TEXT, b GEOMETRY NOT NULL, SPATIAL KEY(b)); alter table t1 disable keys; --error 1263 -load data infile '../std_data_ln/bad_gis_data.dat' into table t1; +load data infile '../../std_data/bad_gis_data.dat' into table t1; alter table t1 enable keys; drop table t1; @@ -502,7 +503,7 @@ drop table t1; --disable_warnings drop procedure if exists fn3; --enable_warnings -create function fn3 () returns point return GeomFromText("point(1 1)"); +create function fn3 () returns point deterministic return GeomFromText("point(1 1)"); show create function fn3; select astext(fn3()); drop function fn3; @@ -655,3 +656,39 @@ select min(`col002`) from t1 union select `col002` from t1; drop table t1; --echo End of 5.0 tests + + +# +# Bug #11335 View redefines column types +# +create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime); +create view v1 as select * from t1; +desc v1; +drop view v1; +drop table t1; + +# +# Bug#44684: valgrind reports invalid reads in +# Item_func_spatial_collection::val_str +# +SELECT MultiPoint(12345,''); +SELECT MultiPoint(123451,''); +SELECT MultiPoint(1234512,''); +SELECT MultiPoint(12345123,''); + +SELECT MultiLineString(12345,''); +SELECT MultiLineString(123451,''); +SELECT MultiLineString(1234512,''); +SELECT MultiLineString(12345123,''); + +SELECT LineString(12345,''); +SELECT LineString(123451,''); +SELECT LineString(1234512,''); +SELECT LineString(12345123,''); + +SELECT Polygon(12345,''); +SELECT Polygon(123451,''); +SELECT Polygon(1234512,''); +SELECT Polygon(12345123,''); + +--echo End of 5.1 tests diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 1b2b8465c83..bcd393bd6ab 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -6,6 +6,9 @@ # Save the initial number of concurrent sessions --source include/count_sessions.inc +SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; +SET GLOBAL log_bin_trust_function_creators = 1; + # Cleanup --disable_warnings drop table if exists t1; @@ -204,7 +207,7 @@ show grants for mysqltest_1@localhost; drop user mysqltest_1@localhost; # -# Bug#3403 Wrong encoding in SHOW GRANTS, EXPLAIN SELECT output +# Bug#3403 Wrong encoding in SHOW GRANTS output # SET NAMES koi8r; CREATE DATABASE ; @@ -812,6 +815,9 @@ DROP USER 'mysqltest_1'@'localhost'; # restore the original database USE test; +connection default; +disconnect master; + # # Bug#10668 CREATE USER does not enforce username length limit @@ -827,6 +833,83 @@ create user mysqltest1_thisisreallytoolong; # statements. # +# +# Bug#22369 Alter table rename combined with other alterations causes lost tables +# +CREATE DATABASE mysqltest1; +CREATE TABLE mysqltest1.t1 ( + int_field INTEGER UNSIGNED NOT NULL, + char_field CHAR(10), + INDEX(`int_field`) +); +CREATE TABLE mysqltest1.t2 (int_field INT); + +--echo "Now check that we require equivalent grants for " +--echo "RENAME TABLE and ALTER TABLE" +CREATE USER mysqltest_1@localhost; +GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost; + +connect (conn42,localhost,mysqltest_1,,mysqltest1); +SELECT USER(); +SHOW GRANTS; +--error ER_TABLEACCESS_DENIED_ERROR +RENAME TABLE t1 TO t2; +--error ER_TABLEACCESS_DENIED_ERROR +ALTER TABLE t1 RENAME TO t2; +--disconnect conn42 +--connection default +GRANT DROP ON mysqltest1.t1 TO mysqltest_1@localhost; + +connect (conn42,localhost,mysqltest_1,,mysqltest1); +--error ER_TABLEACCESS_DENIED_ERROR +RENAME TABLE t1 TO t2; +--error ER_TABLEACCESS_DENIED_ERROR +ALTER TABLE t1 RENAME TO t2; +--disconnect conn42 +--connection default +GRANT ALTER ON mysqltest1.t1 TO mysqltest_1@localhost; + +connect (conn42,localhost,mysqltest_1,,mysqltest1); +SHOW GRANTS; +--error ER_TABLEACCESS_DENIED_ERROR +RENAME TABLE t1 TO t2; +--error ER_TABLEACCESS_DENIED_ERROR +ALTER TABLE t1 RENAME TO t2; +--disconnect conn42 +--connection default +GRANT INSERT, CREATE ON mysqltest1.t1 TO mysqltest_1@localhost; +connect (conn42,localhost,mysqltest_1,,mysqltest1); +SHOW GRANTS; +--error ER_TABLEACCESS_DENIED_ERROR +--disconnect conn42 +--connection default +GRANT INSERT, SELECT, CREATE, ALTER, DROP ON mysqltest1.t2 TO mysqltest_1@localhost; +DROP TABLE mysqltest1.t2; + +connect (conn42,localhost,mysqltest_1,,mysqltest1); +SHOW GRANTS; +RENAME TABLE t1 TO t2; +RENAME TABLE t2 TO t1; +ALTER TABLE t1 RENAME TO t2; +ALTER TABLE t2 RENAME TO t1; +--disconnect conn42 +--connection default +REVOKE DROP, INSERT ON mysqltest1.t1 FROM mysqltest_1@localhost; +REVOKE DROP, INSERT ON mysqltest1.t2 FROM mysqltest_1@localhost; + +connect (conn42,localhost,mysqltest_1,,mysqltest1); +SHOW GRANTS; +--error ER_TABLEACCESS_DENIED_ERROR +RENAME TABLE t1 TO t2; +--error ER_TABLEACCESS_DENIED_ERROR +ALTER TABLE t1 RENAME TO t2; +--disconnect conn42 +--connection default + +DROP USER mysqltest_1@localhost; +DROP DATABASE mysqltest1; +USE test; + # Working with database-level privileges. --error ER_WRONG_STRING_LENGTH @@ -869,6 +952,44 @@ REVOKE EXECUTE ON PROCEDURE p1 FROM 1234567890abcdefGHIKL@localhost; --error ER_WRONG_STRING_LENGTH REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; + +# +# Bug#23556 TRUNCATE TABLE still maps to DELETE +# +CREATE USER bug23556@localhost; +CREATE DATABASE bug23556; +GRANT SELECT ON bug23556.* TO bug23556@localhost; +connect (bug23556,localhost,bug23556,,bug23556); + +connection default; +USE bug23556; +CREATE TABLE t1 (a INT PRIMARY KEY); INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +GRANT DELETE ON t1 TO bug23556@localhost; + +connection bug23556; +USE bug23556; +--error ER_TABLEACCESS_DENIED_ERROR +TRUNCATE t1; + +connection default; +USE bug23556; +REVOKE DELETE ON t1 FROM bug23556@localhost; +GRANT DROP ON t1 TO bug23556@localhost; + +connection bug23556; +USE bug23556; +TRUNCATE t1; + +connection default; +USE bug23556; +DROP TABLE t1; +USE test; +DROP DATABASE bug23556; +DROP USER bug23556@localhost; +connection default; +disconnect bug23556; + + # # Bug#6774 Replication fails with Wrong usage of DB GRANT and GLOBAL PRIVILEGES # @@ -1137,6 +1258,14 @@ DROP DATABASE db27878; USE test; DROP TABLE t1; +--echo # +--echo # Bug#33275 Server crash when creating temporary table mysql.user +--echo # +CREATE TEMPORARY TABLE mysql.user (id INT); +FLUSH PRIVILEGES; +DROP TABLE mysql.user; + + # # Bug#33201 Crash occurs when granting update privilege on one column of a view # @@ -1168,6 +1297,233 @@ SET PASSWORD FOR CURRENT_USER() = PASSWORD(""); --echo End of 5.0 tests -disconnect master; +# +# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte +# +set names utf8; +grant select on test.* to юзер_юзер@localhost; +--exec $MYSQL --default-character-set=utf8 --user=юзер_юзер -e "select user()" +revoke all on test.* from юзер_юзер@localhost; +drop user юзер_юзер@localhost; +--error ER_WRONG_STRING_LENGTH +grant select on test.* to очень_длинный_юзер@localhost; +set names default; + +# +# Bug#20901 CREATE privilege is enough to insert into a table +# + +create database mysqltest; +use mysqltest; + +grant create on mysqltest.* to mysqltest@localhost; +create table t1 (i INT); + +connect (user1,localhost,mysqltest,,mysqltest); +connection user1; +# show we don't have INSERT +--error ER_TABLEACCESS_DENIED_ERROR +insert into t1 values (1); +# show we have CREATE +create table t2 (i INT); +create table t4 (i INT); + +connection default; +grant select, insert on mysqltest.t2 to mysqltest@localhost; +grant insert on mysqltest.t4 to mysqltest@localhost; +# to specify ACLs for non-existent objects, must explictly |CREATE +grant create, insert on mysqltest.t5 to mysqltest@localhost; +grant create, insert on mysqltest.t6 to mysqltest@localhost; +flush privileges; + +connection user1; +insert into t2 values (1); + + +# CREATE IF NOT EXISTS...SELECT, t1 exists, no INSERT, must fail +--error ER_TABLEACCESS_DENIED_ERROR +create table if not exists t1 select * from t2; + +# CREATE IF NOT EXISTS...SELECT, no t3 yet, no INSERT, must fail +--error ER_TABLEACCESS_DENIED_ERROR +create table if not exists t3 select * from t2; + +# CREATE IF NOT EXISTS...SELECT, t4 exists, have INSERT, must succeed +create table if not exists t4 select * from t2; + +# CREATE IF NOT EXISTS...SELECT, no t5 yet, have INSERT, must succeed +create table if not exists t5 select * from t2; + + +# CREATE...SELECT, no t6 yet, have INSERT, must succeed +create table t6 select * from t2; + +# CREATE...SELECT, no t7 yet, no INSERT, must fail +--error ER_TABLEACCESS_DENIED_ERROR +create table t7 select * from t2; + +# CREATE...SELECT, t4 exists, have INSERT, must still fail (exists) +--error 1050 +create table t4 select * from t2; + +# CREATE...SELECT, t1 exists, no INSERT, must fail +--error ER_TABLEACCESS_DENIED_ERROR +create table t1 select * from t2; + + +connection default; +drop table t1,t2,t4,t5,t6; + +revoke create on mysqltest.* from mysqltest@localhost; +revoke select, insert on mysqltest.t2 from mysqltest@localhost; +revoke insert on mysqltest.t4 from mysqltest@localhost; +revoke create, insert on mysqltest.t5 from mysqltest@localhost; +revoke create, insert on mysqltest.t6 from mysqltest@localhost; +drop user mysqltest@localhost; + +disconnect user1; +drop database mysqltest; +use test; + + +# +# Bug#16470 crash on grant if old grant tables +# +--echo FLUSH PRIVILEGES without procs_priv table. +RENAME TABLE mysql.procs_priv TO mysql.procs_gone; +--error ER_NO_SUCH_TABLE +FLUSH PRIVILEGES; +--echo Assigning privileges without procs_priv table. +CREATE DATABASE mysqltest1; +CREATE PROCEDURE mysqltest1.test() SQL SECURITY DEFINER + SELECT 1; +--error ER_NO_SUCH_TABLE +GRANT EXECUTE ON FUNCTION mysqltest1.test TO mysqltest_1@localhost; +GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost; +CALL mysqltest1.test(); +DROP DATABASE mysqltest1; +RENAME TABLE mysql.procs_gone TO mysql.procs_priv; +DROP USER mysqltest_1@localhost; +FLUSH PRIVILEGES; + + +# +# Bug#33464 DROP FUNCTION caused a crash. +# +CREATE DATABASE dbbug33464; +CREATE USER 'userbug33464'@'localhost'; + +GRANT CREATE ROUTINE ON dbbug33464.* TO 'userbug33464'@'localhost'; + +--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK +connect (connbug33464, localhost, userbug33464, , dbbug33464); +--source suite/funcs_1/include/show_connection.inc + +--disable_warnings +DROP PROCEDURE IF EXISTS sp3; +DROP FUNCTION IF EXISTS fn1; +--enable_warnings + +delimiter //; +CREATE PROCEDURE sp3(v1 char(20)) +BEGIN + SELECT * from dbbug33464.t6 where t6.f2= 'xyz'; +END// +delimiter ;// + +delimiter //; +CREATE FUNCTION fn1() returns char(50) SQL SECURITY INVOKER +BEGIN + return 1; +END// +delimiter ;// + +delimiter //; +CREATE FUNCTION fn2() returns char(50) SQL SECURITY DEFINER +BEGIN + return 2; +END// +delimiter ;// + +disconnect connbug33464; + +# cleanup +connection default; +USE dbbug33464; +--source suite/funcs_1/include/show_connection.inc + +SELECT fn1(); +SELECT fn2(); + +--error 0, ER_CANNOT_USER +DROP USER 'userbug33464'@'localhost'; + +DROP FUNCTION fn1; +DROP FUNCTION fn2; +DROP PROCEDURE sp3; + +--error 0, ER_CANNOT_USER +DROP USER 'userbug33464'@'localhost'; + +USE test; +DROP DATABASE dbbug33464; + + +SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators; + +# +# Bug#44658 Create procedure makes server crash when user does not have ALL privilege +# +CREATE USER user1; +CREATE USER user2; +GRANT CREATE ON db1.* TO 'user1'@'localhost'; +GRANT CREATE ROUTINE ON db1.* TO 'user1'@'localhost'; +GRANT CREATE ON db1.* TO 'user2'@'%'; +GRANT CREATE ROUTINE ON db1.* TO 'user2'@'%'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR 'user1'@'localhost'; +connect (con1,localhost,user1,,); +--echo ** Connect as user1 and create a procedure. +--echo ** The creation will imply implicitly assigned +--echo ** EXECUTE and ALTER ROUTINE privileges to +--echo ** the current user user1@localhost. +SELECT @@GLOBAL.sql_mode; +SELECT @@SESSION.sql_mode; +CREATE DATABASE db1; +DELIMITER ||; +CREATE PROCEDURE db1.proc1(p1 INT) + BEGIN + SET @x = 0; + REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT; + END ;|| +DELIMITER ;|| + +connect (con2,localhost,user2,,); +--echo ** Connect as user2 and create a procedure. +--echo ** Implicitly assignment of privileges will +--echo ** fail because the user2@localhost is an +--echo ** unknown user. +DELIMITER ||; +CREATE PROCEDURE db1.proc2(p1 INT) + BEGIN + SET @x = 0; + REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT; + END ;|| +DELIMITER ;|| + +connection default; +SHOW GRANTS FOR 'user1'@'localhost'; +SHOW GRANTS FOR 'user2'; +disconnect con1; +disconnect con2; +DROP PROCEDURE db1.proc1; +DROP PROCEDURE db1.proc2; +REVOKE ALL ON db1.* FROM 'user1'@'localhost'; +REVOKE ALL ON db1.* FROM 'user2'@'%'; +DROP USER 'user1'; +DROP USER 'user1'@'localhost'; +DROP USER 'user2'; +DROP DATABASE db1; + # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index 2393bb1c6d8..54cdf8d6cc1 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -466,13 +466,10 @@ create database TESTDB; create table t2(a int); create temporary table t1 as select * from mysql.user; delete from mysql.user where host='localhost'; -INSERT INTO mysql.user VALUES -('%','mysqltest_1',password('password'),'N','N','N','N','N','N', -'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N', -'','','','',0,0,0,0); -INSERT INTO mysql.db VALUES -('%','TESTDB','mysqltest_1','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','N','Y','Y','Y',' -Y','N'); +INSERT INTO mysql.user (host, user, password) VALUES +('%','mysqltest_1',password('password')); +INSERT INTO mysql.db (host, db, user, select_priv) VALUES +('%','TESTDB','mysqltest_1','Y'); FLUSH PRIVILEGES; connect (con1,localhost,mysqltest_1,password,TESTDB); @@ -497,6 +494,9 @@ flush privileges; # Bug#13310 incorrect user parsing by SP # +SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; +SET GLOBAL log_bin_trust_function_creators = 1; + GRANT ALL PRIVILEGES ON test.* TO `a@`@localhost; GRANT EXECUTE ON * TO `a@`@localhost; connect (bug13310,localhost,'a@',,test); @@ -519,6 +519,8 @@ connection default; REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost; DROP USER `a@`@localhost; +SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators; + # # Bug#25578 CREATE TABLE LIKE does not require any privileges on source table diff --git a/mysql-test/t/grant_cache.test b/mysql-test/t/grant_cache.test deleted file mode 100644 index 616a2746148..00000000000 --- a/mysql-test/t/grant_cache.test +++ /dev/null @@ -1,159 +0,0 @@ -# Grant tests not performed with embedded server --- source include/not_embedded.inc --- source include/have_query_cache.inc - ---source include/add_anonymous_users.inc - -# -# Test grants with query cache -# ---disable_warnings -drop table if exists test.t1,mysqltest.t1,mysqltest.t2; -drop database if exists mysqltest; ---enable_warnings - -set GLOBAL query_cache_size=1355776; - -reset query cache; -flush status; -connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); -connection root; -show grants for current_user; -show grants; ---disable_warnings -create database if not exists mysqltest; ---enable_warnings - -create table mysqltest.t1 (a int,b int,c int); -create table mysqltest.t2 (a int,b int,c int); -insert into mysqltest.t1 values (1,1,1),(2,2,2); -insert into mysqltest.t2 values (3,3,3); -create table test.t1 (a char (10)); -insert into test.t1 values ("test.t1"); -select * from t1; -connect (root2,localhost,root,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK); -connection root2; -# put queries in cache -select * from t1; -select a from t1; -select c from t1; -select * from t2; -select * from mysqltest.t1,test.t1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits%"; - -# Create the test users -grant SELECT on mysqltest.* to mysqltest_1@localhost; -grant SELECT on mysqltest.t1 to mysqltest_2@localhost; -grant SELECT on test.t1 to mysqltest_2@localhost; -grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost; - -# The following queries should be fetched from cache -connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK); -connection user1; -show grants for current_user(); -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits"; -show status like "Qcache_not_cached"; -select "user1"; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits"; -show status like "Qcache_not_cached"; -select * from t1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits"; -show status like "Qcache_not_cached"; -# The pre and end space are intentional - select a from t1 ; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits"; -show status like "Qcache_not_cached"; -select c from t1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits"; -show status like "Qcache_not_cached"; - - -# Don't use '' as user because it will pick Unix login -connect (unkuser,localhost,unkuser,,,$MASTER_MYPORT,$MASTER_MYSOCK); -connection unkuser; -show grants for current_user(); - -# The following queries should be fetched from cache -connect (user2,localhost,mysqltest_2,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK); -connection user2; -select "user2"; -select * from t1; -select a from t1; -select c from t1; -select * from mysqltest.t1,test.t1; ---replace_result 127.0.0.1 localhost ---error ER_TABLEACCESS_DENIED_ERROR -select * from t2; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits"; -show status like "Qcache_not_cached"; - -# The following queries should not be fetched from cache -connect (user3,localhost,mysqltest_3,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK); -connection user3; -select "user3"; ---replace_result 127.0.0.1 localhost ---error ER_TABLEACCESS_DENIED_ERROR -select * from t1; -select a from t1; ---replace_result 127.0.0.1 localhost ---error ER_COLUMNACCESS_DENIED_ERROR -select c from t1; ---replace_result 127.0.0.1 localhost ---error ER_TABLEACCESS_DENIED_ERROR -select * from t2; ---replace_result 127.0.0.1 localhost ---error ER_COLUMNACCESS_DENIED_ERROR -select mysqltest.t1.c from test.t1,mysqltest.t1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits"; -show status like "Qcache_not_cached"; - -# Connect without a database -connect (user4,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK); -connection user4; -select "user4"; -show grants; ---error ER_NO_DB_ERROR -select a from t1; -# The following query is not cached before (different database) -select * from mysqltest.t1,test.t1; -# Cache a query with 'no database' -select a from mysqltest.t1; -select a from mysqltest.t1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits"; -show status like "Qcache_not_cached"; - -# Cleanup - -connection root; -# -# A temporary 4.1 workaround to make this test pass if -# mysql was compiled with other than latin1 --with-charset=XXX. -# Without "set names binary" the below queries fail with -# "Illegal mix of collations" error. -# In 5.0 we will change grant tables to use NCHAR(N) instead -# of "CHAR(N) BINARY", and use cast-to-nchar: N'mysqltest_1'. -# -set names binary; -delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); -delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); -delete from mysql.tables_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); -delete from mysql.columns_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); -flush privileges; -drop table test.t1,mysqltest.t1,mysqltest.t2; -drop database mysqltest; - -set GLOBAL query_cache_size=default; - ---source include/delete_anonymous_users.inc - - -# End of 4.1 tests diff --git a/mysql-test/t/grant_cache_no_prot.test b/mysql-test/t/grant_cache_no_prot.test new file mode 100644 index 00000000000..31209f343b9 --- /dev/null +++ b/mysql-test/t/grant_cache_no_prot.test @@ -0,0 +1,25 @@ +#################### t/grant_cache_no_prot.test ################### +# +# Test grants with query cache to be run when mysqltest was started +# without any "--<whatever>-protocol". +# +# Last update: +# 2007-05-03 ML - Move t/grant_cache.test to include/grant_cache.inc +# - Create this test as non "--<whatever>-protocol" variant. +# + +# We cannot run on embedded server because we use multiple sessions. +--source include/not_embedded.inc + +--source include/have_query_cache.inc + +# The file with expected results fits only to a run without +# ps-protocol/sp-protocol/cursor-protocol/view-protocol. +if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL + + $VIEW_PROTOCOL > 0`) +{ + --skip Need normal protocol +} + +# The main testing script +--source include/grant_cache.inc diff --git a/mysql-test/t/grant_cache_ps_prot.test b/mysql-test/t/grant_cache_ps_prot.test new file mode 100644 index 00000000000..27b3f23de3f --- /dev/null +++ b/mysql-test/t/grant_cache_ps_prot.test @@ -0,0 +1,24 @@ +#################### t/grant_cache_ps_prot.test ################## +# +# Test grants with query cache to be run when mysqltest was +# started with the option "--ps-protocol". +# +# Last update: +# 2007-05-03 ML - Move t/grant_cache.test to include/grant_cache.inc +# - Create this test as "--ps-protocol" only variant. +# + +# We cannot run on embedded server because we use multiple sessions. +--source include/not_embedded.inc + +--source include/have_query_cache.inc + +# The file with expected results fits only to a run with "--ps-protocol". +if (`SELECT $SP_PROTOCOL + $CURSOR_PROTOCOL + $VIEW_PROTOCOL > 0 + OR $PS_PROTOCOL = 0`) +{ + --skip Need ps-protocol +} + +# The main testing script +--source include/grant_cache.inc diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 0e5af0133ca..5b96213034a 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -790,33 +790,6 @@ drop table t1; SET SQL_MODE = ''; # -# Bug#30596: GROUP BY optimization gives wrong result order -# -CREATE TABLE t1( - a INT, - b INT NOT NULL, - c INT NOT NULL, - d INT, - UNIQUE KEY (c,b) -); - -INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4); - -EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d; -SELECT c,b,d FROM t1 GROUP BY c,b,d; -EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; -SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; -EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d; -SELECT c,b,d FROM t1 ORDER BY c,b,d; - -EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b; -SELECT c,b,d FROM t1 GROUP BY c,b; -EXPLAIN SELECT c,b FROM t1 GROUP BY c,b; -SELECT c,b FROM t1 GROUP BY c,b; - -DROP TABLE t1; - -# # Bug #32202: ORDER BY not working with GROUP BY # @@ -849,49 +822,6 @@ SELECT * FROM t1 GROUP BY c2 ORDER BY c2 DESC, c1 DESC; DROP TABLE t1; -# Bug #31797: error while parsing subqueries -- WHERE is parsed as HAVING -# -CREATE TABLE t1 ( a INT, b INT ); - -SELECT b c, (SELECT a FROM t1 WHERE b = c) -FROM t1; - -SELECT b c, (SELECT a FROM t1 WHERE b = c) -FROM t1 -HAVING b = 10; - ---error ER_ILLEGAL_REFERENCE -SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c) -FROM t1 -HAVING b = 10; - -SET @old_sql_mode = @@sql_mode; -SET @@sql_mode='ONLY_FULL_GROUP_BY'; - -SELECT b c, (SELECT a FROM t1 WHERE b = c) -FROM t1; - ---error ER_NON_GROUPING_FIELD_USED -SELECT b c, (SELECT a FROM t1 WHERE b = c) -FROM t1 -HAVING b = 10; - ---error ER_ILLEGAL_REFERENCE -SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c) -FROM t1 -HAVING b = 10; - -INSERT INTO t1 VALUES (1, 1); -SELECT b c, (SELECT a FROM t1 WHERE b = c) -FROM t1; - -INSERT INTO t1 VALUES (2, 1); ---error ER_SUBQUERY_NO_1_ROW -SELECT b c, (SELECT a FROM t1 WHERE b = c) -FROM t1; - -DROP TABLE t1; -SET @@sql_mode = @old_sql_mode; --echo # --echo # Bug#27219: Aggregate functions in ORDER BY. @@ -1040,3 +970,191 @@ SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar'; drop table t1; --echo End of 5.0 tests +# Bug #21174: Index degrades sort performance and +# optimizer does not honor IGNORE INDEX. +# a.k.a WL3527. +# +CREATE TABLE t1 (a INT, b INT, + PRIMARY KEY (a), + KEY i2(a,b)); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8); +INSERT INTO t1 SELECT a + 8,b FROM t1; +INSERT INTO t1 SELECT a + 16,b FROM t1; +INSERT INTO t1 SELECT a + 32,b FROM t1; +INSERT INTO t1 SELECT a + 64,b FROM t1; +INSERT INTO t1 SELECT a + 128,b FROM t1 limit 16; +ANALYZE TABLE t1; +EXPLAIN SELECT a FROM t1 WHERE a < 2; +EXPLAIN SELECT a FROM t1 WHERE a < 2 ORDER BY a; +EXPLAIN SELECT a FROM t1 WHERE a < 2 GROUP BY a; +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY,i2); +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR JOIN (PRIMARY,i2); +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) + IGNORE INDEX FOR GROUP BY (i2) GROUP BY a; +EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY) IGNORE INDEX FOR ORDER BY (i2); +EXPLAIN SELECT a FROM t1 FORCE INDEX (i2); +EXPLAIN SELECT a FROM t1 USE INDEX (); +EXPLAIN SELECT a FROM t1 USE INDEX () USE INDEX (i2); +--error ER_WRONG_USAGE +EXPLAIN SELECT a FROM t1 + FORCE INDEX (PRIMARY) + IGNORE INDEX FOR GROUP BY (i2) + IGNORE INDEX FOR ORDER BY (i2) + USE INDEX (i2); +EXPLAIN SELECT a FROM t1 USE INDEX (i2) USE INDEX (); +--error ER_PARSE_ERROR +EXPLAIN SELECT a FROM t1 FORCE INDEX (); +--error ER_PARSE_ERROR +EXPLAIN SELECT a FROM t1 IGNORE INDEX (); +# disable the columns irrelevant to this test here. On some systems +# without support for large files the rowid is shorter and its size affects +# the cost calculations. This causes the optimizer to choose loose index +# scan over normal index access. +--replace_column 4 # 7 # 9 # 10 # +EXPLAIN SELECT a FROM t1 USE INDEX FOR JOIN (i2) + USE INDEX FOR GROUP BY (i2) GROUP BY a; +EXPLAIN SELECT a FROM t1 FORCE INDEX FOR JOIN (i2) + FORCE INDEX FOR GROUP BY (i2) GROUP BY a; +EXPLAIN SELECT a FROM t1 USE INDEX () IGNORE INDEX (i2); +EXPLAIN SELECT a FROM t1 IGNORE INDEX (i2) USE INDEX (); + +EXPLAIN SELECT a FROM t1 + USE INDEX FOR GROUP BY (i2) + USE INDEX FOR ORDER BY (i2) + USE INDEX FOR JOIN (i2); + +EXPLAIN SELECT a FROM t1 + USE INDEX FOR JOIN (i2) + USE INDEX FOR JOIN (i2) + USE INDEX FOR JOIN (i2,i2); + +EXPLAIN SELECT 1 FROM t1 WHERE a IN + (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); + +CREATE TABLE t2 (a INT, b INT, KEY(a)); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4); +EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2; +EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2; + +EXPLAIN SELECT 1 FROM t2 WHERE a IN + (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); + +SHOW VARIABLES LIKE 'old'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@old = off; + +DROP TABLE t1, t2; + +# +# Bug#30596: GROUP BY optimization gives wrong result order +# +CREATE TABLE t1( + a INT, + b INT NOT NULL, + c INT NOT NULL, + d INT, + UNIQUE KEY (c,b) +); + +INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4); + +CREATE TABLE t2( + a INT, + b INT, + UNIQUE KEY(a,b) +); + +INSERT INTO t2 VALUES (NULL, NULL), (NULL, NULL), (NULL, 1), (1, NULL), (1, 1), (1,2); + +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d; +SELECT c,b,d FROM t1 GROUP BY c,b,d; +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; +SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; +EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d; +SELECT c,b,d FROM t1 ORDER BY c,b,d; + +EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b; +SELECT c,b,d FROM t1 GROUP BY c,b; +EXPLAIN SELECT c,b FROM t1 GROUP BY c,b; +SELECT c,b FROM t1 GROUP BY c,b; + +EXPLAIN SELECT a,b from t2 ORDER BY a,b; +SELECT a,b from t2 ORDER BY a,b; +EXPLAIN SELECT a,b from t2 GROUP BY a,b; +SELECT a,b from t2 GROUP BY a,b; +EXPLAIN SELECT a from t2 GROUP BY a; +SELECT a from t2 GROUP BY a; +EXPLAIN SELECT b from t2 GROUP BY b; +SELECT b from t2 GROUP BY b; + +DROP TABLE t1; +DROP TABLE t2; + +# +# Bug #31797: error while parsing subqueries -- WHERE is parsed as HAVING +# +CREATE TABLE t1 ( a INT, b INT ); + +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; + +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; + +--error ER_ILLEGAL_REFERENCE +SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; + +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; + +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; + +--error ER_NON_GROUPING_FIELD_USED +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; + +--error ER_ILLEGAL_REFERENCE +SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c) +FROM t1 +HAVING b = 10; + +INSERT INTO t1 VALUES (1, 1); +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; + +INSERT INTO t1 VALUES (2, 1); +--error ER_SUBQUERY_NO_1_ROW +SELECT b c, (SELECT a FROM t1 WHERE b = c) +FROM t1; + +DROP TABLE t1; +SET @@sql_mode = @old_sql_mode; + + +# +# Bug#42567 Invalid GROUP BY error +# + +# Setup of the subtest +SET @old_sql_mode = @@sql_mode; +SET @@sql_mode='ONLY_FULL_GROUP_BY'; + +CREATE TABLE t1(i INT); +INSERT INTO t1 VALUES (1), (10); + +# The actual test +SELECT COUNT(i) FROM t1; +SELECT COUNT(i) FROM t1 WHERE i > 1; + +# Cleanup of subtest +DROP TABLE t1; +SET @@sql_mode = @old_sql_mode; + diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index c81babb42e6..c09a4fbf490 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -489,7 +489,7 @@ select a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1 # plans explain select distinct a1,a2,b from t1; explain select distinct a1,a2,b from t1 where (a2 >= 'b') and (b = 'a'); -explain select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +explain extended select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); explain select distinct b from t1 where (a2 >= 'b') and (b = 'a'); @@ -497,7 +497,7 @@ explain select distinct b from t1 where (a2 >= 'b') and (b = 'a'); explain select distinct a1,a2,b from t2; --replace_column 9 # explain select distinct a1,a2,b from t2 where (a2 >= 'b') and (b = 'a'); -explain select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); +explain extended select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); --replace_column 9 # explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); explain select distinct b from t2 where (a2 >= 'b') and (b = 'a'); @@ -568,9 +568,9 @@ select distinct b from t2 where (a2 >= 'b') and (b = 'a') group by a1,a2,b; explain select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); -explain select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); +explain extended select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c'); explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a'); -explain select ord(a1) + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); +explain extended select ord(a1) + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a'); select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121'); @@ -607,19 +607,19 @@ explain select a1,a2,b,d from t1 group by a1,a2,b; # predicate that references an attribute that is after the MIN/MAX argument # in the index -explain select a1,a2,min(b),max(b) from t1 +explain extended select a1,a2,min(b),max(b) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2; # predicate that references a non-indexed attribute -explain select a1,a2,b,min(c),max(c) from t1 +explain extended select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b; -explain select a1,a2,b,c from t1 +explain extended select a1,a2,b,c from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c; # non-equality predicate for a non-group select attribute explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1; -explain select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b; +explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b; # non-group field with an equality predicate that references a keypart after the # MIN/MAX argument @@ -638,8 +638,8 @@ explain select a1, a2, b, c, min(d), max(d) from t1 group by a1,a2,b,c; # other aggregate functions than MIN/MAX explain select a1,a2,count(a2) from t1 group by a1,a2,b; -explain select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; -explain select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; +explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; +explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; # @@ -659,7 +659,32 @@ select a1 from t1 where a2 = 'b' group by a1; explain select distinct a1 from t1 where a2 = 'b'; select distinct a1 from t1 where a2 = 'b'; +# +# Bug #12672: primary key implcitly included in every innodb index +# +# Test case moved to group_min_max_innodb + + +# +# Bug #6142: a problem with the empty innodb table +# +# Test case moved to group_min_max_innodb + + +# +# Bug #9798: group by with rollup +# +# Test case moved to group_min_max_innodb + + +# +# Bug #13293 Wrongly used index results in endless loop. +# +# Test case moved to group_min_max_innodb + + drop table t1,t2,t3; + # # Bug #14920 Ordering aggregated result sets with composite primary keys # corrupts resultset @@ -865,8 +890,9 @@ FLUSH STATUS; DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000; SHOW STATUS LIKE 'handler_read__e%'; FLUSH STATUS; +--error ER_SUBQUERY_NO_1_ROW DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x - FROM t1 WHERE a = 1 AND b = 1) > 10000; + FROM t1) > 10000; SHOW STATUS LIKE 'handler_read__e%'; DROP TABLE t1,t2,t3; @@ -951,7 +977,6 @@ INSERT INTO t1 SELECT * FROM t1; INSERT INTO t1 SELECT a,b,c+1,d FROM t1; #Should be non-empty ---ordered_result EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4; SELECT DISTINCT c FROM t1 WHERE d=4; @@ -993,3 +1018,18 @@ DROP TABLE t; --echo End of 5.0 tests + +--echo # +--echo # Bug #46607: Assertion failed: (cond_type == Item::FUNC_ITEM) results in +--echo # server crash +--echo # + +CREATE TABLE t (a INT, b INT, INDEX (a,b)); +INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1); +INSERT INTO t SELECT * FROM t; + +SELECT a, MAX(b) FROM t WHERE b GROUP BY a; + +DROP TABLE t; + +--echo End of 5.1 tests diff --git a/mysql-test/t/group_min_max_innodb.test b/mysql-test/t/group_min_max_innodb.test new file mode 100644 index 00000000000..643b4f7d55e --- /dev/null +++ b/mysql-test/t/group_min_max_innodb.test @@ -0,0 +1,119 @@ +# +# Test file for WL#1724 (Min/Max Optimization for Queries with Group By Clause). +# The queries in this file test query execution via QUICK_GROUP_MIN_MAX_SELECT +# that depends on InnoDB +# + +--source include/have_innodb.inc + +--disable_warnings +drop view if exists v1; +drop table if exists t1,t4; +--enable_warnings + +# +# Bug #12672: primary key implcitly included in every innodb index +# + +--disable_warnings +create table t4 ( + pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' +) engine=innodb; +--enable_warnings + +insert into t4 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'), +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'); + +create index idx12672_0 on t4 (a1); +create index idx12672_1 on t4 (a1,a2,b,c); +create index idx12672_2 on t4 (a1,a2,b); +analyze table t4; + +select distinct a1 from t4 where pk_col not in (1,2,3,4); + +drop table t4; + + +# +# Bug #6142: a problem with the empty innodb table +# + +--disable_warnings +create table t1 ( + a varchar(30), b varchar(30), primary key(a), key(b) +) engine=innodb; +--enable_warnings +select distinct a from t1; +drop table t1; + +# +# Bug #9798: group by with rollup +# + +--disable_warnings +create table t1(a int, key(a)) engine=innodb; +--enable_warnings +insert into t1 values(1); +select a, count(a) from t1 group by a with rollup; +drop table t1; + + +# +# Bug #13293 Wrongly used index results in endless loop. +# +create table t1 (f1 int, f2 char(1), primary key(f1,f2)) engine=innodb; +insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d"); +alter table t1 drop primary key, add primary key (f2, f1); +explain select distinct f1 a, f1 b from t1; +explain select distinct f1, f2 from t1; +drop table t1; + + +# +# Bug #36632: Select distinct from a simple view on an InnoDB table +# returns incorrect results +# +create table t1(pk int primary key) engine=innodb; +create view v1 as select pk from t1 where pk < 20; + +insert into t1 values (1), (2), (3), (4); +select distinct pk from v1; + +insert into t1 values (5), (6), (7); +select distinct pk from v1; + +drop view v1; +drop table t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test deleted file mode 100644 index 70d4157a272..00000000000 --- a/mysql-test/t/handler.test +++ /dev/null @@ -1,470 +0,0 @@ --- source include/not_embedded.inc -# -# test of HANDLER ... -# - -# should work in embedded server after mysqltest is fixed --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1,t3,t4,t5; ---enable_warnings - -create table t1 (a int, b char(10), key a(a), key b(a,b)); -insert into t1 values -(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), -(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"), -(20,"ggg"),(21,"hhh"),(22,"iii"); -handler t1 open as t2; --- error 1064 -handler t2 read a=(SELECT 1); -handler t2 read a first; -handler t2 read a next; -handler t2 read a next; -handler t2 read a prev; -handler t2 read a last; -handler t2 read a prev; -handler t2 read a prev; - -handler t2 read a first; -handler t2 read a prev; - -handler t2 read a last; -handler t2 read a prev; -handler t2 read a next; -handler t2 read a next; - -handler t2 read a=(15); -handler t2 read a=(16); - ---error 1070 -handler t2 read a=(19,"fff"); - -handler t2 read b=(19,"fff"); -handler t2 read b=(19,"yyy"); -handler t2 read b=(19); - ---error 1109 -handler t1 read a last; - -handler t2 read a=(11); -handler t2 read a>=(11); - -handler t2 read a=(18); -handler t2 read a>=(18); -handler t2 read a>(18); -handler t2 read a<=(18); -handler t2 read a<(18); - -handler t2 read a first limit 5; -handler t2 read a next limit 3; -handler t2 read a prev limit 10; - -handler t2 read a>=(16) limit 4; -handler t2 read a>=(16) limit 2,2; -handler t2 read a last limit 3; - -handler t2 read a=(19); -handler t2 read a=(19) where b="yyy"; - -handler t2 read first; -handler t2 read next; -handler t2 read next; ---error 1064 -handler t2 read last; -handler t2 close; - -# -# DROP TABLE / ALTER TABLE -# -handler t1 open as t2; -drop table t1; -create table t1 (a int); -insert into t1 values (17); ---error 1109 -handler t2 read first; -handler t1 open as t2; -alter table t1 engine=MyISAM; ---error 1109 -handler t2 read first; -drop table t1; - -# -# Test case for the bug #787 -# -create table t1 (a int); -insert into t1 values (1),(2),(3),(4),(5),(6); -delete from t1 limit 2; -handler t1 open; -handler t1 read first; -handler t1 read first limit 1,1; -handler t1 read first limit 2,2; -delete from t1 limit 3; -handler t1 read first; -drop table t1; - -# -# Test for #751 -# -create table t1(a int, index(a)); -insert into t1 values (1), (2), (3); -handler t1 open; ---error 1054 -handler t1 read a=(W); ---error 1210 -handler t1 read a=(a); -drop table t1; -# -# BUG#2304 -# -create table t1 (a char(5)); -insert into t1 values ("Ok"); -handler t1 open as t; -handler t read first; -use mysql; -handler t read first; -handler t close; -handler test.t1 open as t; -handler t read first; -handler t close; -use test; -drop table t1; - -# -# BUG#3649 -# -create table t1 ( a int, b int, INDEX a (a) ); -insert into t1 values (1,2), (2,1); -handler t1 open; -handler t1 read a=(1) where b=2; -handler t1 read a=(1) where b=3; -handler t1 read a=(1) where b=1; -handler t1 close; -drop table t1; - -# -# Check if two database names beginning the same are seen as different. -# -# This database begins like the usual 'test' database. -# ---disable_warnings -drop database if exists test_test; ---enable_warnings -create database test_test; -use test_test; -create table t1(table_id char(20) primary key); -insert into t1 values ('test_test.t1'); -insert into t1 values (''); -handler t1 open; -handler t1 read first limit 9; -create table t2(table_id char(20) primary key); -insert into t2 values ('test_test.t2'); -insert into t2 values (''); -handler t2 open; -handler t2 read first limit 9; -# -# This is the usual 'test' database. -# -use test; ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1(table_id char(20) primary key); -insert into t1 values ('test.t1'); -insert into t1 values (''); ---error 1066 -handler t1 open; -# -# Check accesibility of all the tables. -# -use test; ---error 1064 -handler test.t1 read first limit 9; ---error 1064 -handler test_test.t1 read first limit 9; -handler t1 read first limit 9; ---error 1064 -handler test_test.t2 read first limit 9; -handler t2 read first limit 9; - -# -# Cleanup. -# - ---error 1064 -handler test_test.t1 close; -handler t1 close; -drop table test_test.t1; ---error 1064 -handler test_test.t2 close; -handler t2 close; -drop table test_test.t2; -drop database test_test; - -# -use test; ---error 1064 -handler test.t1 close; ---error 1109 -handler t1 close; -drop table test.t1; - -# -# BUG#4335 -# ---disable_warnings -drop database if exists test_test; -drop table if exists t1; -drop table if exists t2; -drop table if exists t3; ---enable_warnings -create database test_test; -use test_test; -create table t1 (c1 char(20)); -insert into t1 values ('test_test.t1'); -create table t3 (c1 char(20)); -insert into t3 values ('test_test.t3'); -handler t1 open; -handler t1 read first limit 9; -handler t1 open h1; -handler h1 read first limit 9; -use test; -create table t1 (c1 char(20)); -create table t2 (c1 char(20)); -create table t3 (c1 char(20)); -insert into t1 values ('t1'); -insert into t2 values ('t2'); -insert into t3 values ('t3'); ---error 1066 -handler t1 open; ---error 1066 -handler t2 open t1; ---error 1066 -handler t3 open t1; -handler t1 read first limit 9; ---error 1064 -handler test.t1 close; ---error 1066 -handler test.t1 open h1; ---error 1066 -handler test_test.t1 open h1; -handler test_test.t3 open h3; -handler test.t1 open h2; -handler t1 read first limit 9; -handler h1 read first limit 9; -handler h2 read first limit 9; -handler h3 read first limit 9; -handler h2 read first limit 9; ---error 1064 -handler test.h1 close; -handler t1 close; -handler h1 close; -handler h2 close; ---error 1109 -handler t1 read first limit 9; ---error 1109 -handler h1 read first limit 9; ---error 1109 -handler h2 read first limit 9; -handler h3 read first limit 9; -handler h3 read first limit 9; -use test_test; -handler h3 read first limit 9; ---error 1064 -handler test.h3 read first limit 9; -handler h3 close; -use test; -drop table t3; -drop table t2; -drop table t1; -drop database test_test; - -# -# Test if fix for BUG#4286 correctly closes handler tables. -# -create table t1 (c1 char(20)); -insert into t1 values ("t1"); -handler t1 open as h1; -handler h1 read first limit 9; -create table t2 (c1 char(20)); -insert into t2 values ("t2"); -handler t2 open as h2; -handler h2 read first limit 9; -create table t3 (c1 char(20)); -insert into t3 values ("t3"); -handler t3 open as h3; -handler h3 read first limit 9; -create table t4 (c1 char(20)); -insert into t4 values ("t4"); -handler t4 open as h4; -handler h4 read first limit 9; -create table t5 (c1 char(20)); -insert into t5 values ("t5"); -handler t5 open as h5; -handler h5 read first limit 9; -# close first -alter table t1 engine=MyISAM; ---error 1109 -handler h1 read first limit 9; -handler h2 read first limit 9; -handler h3 read first limit 9; -handler h4 read first limit 9; -handler h5 read first limit 9; -# close last -alter table t5 engine=MyISAM; ---error 1109 -handler h1 read first limit 9; -handler h2 read first limit 9; -handler h3 read first limit 9; -handler h4 read first limit 9; ---error 1109 -handler h5 read first limit 9; -# close middle -alter table t3 engine=MyISAM; ---error 1109 -handler h1 read first limit 9; -handler h2 read first limit 9; ---error 1109 -handler h3 read first limit 9; -handler h4 read first limit 9; ---error 1109 -handler h5 read first limit 9; -handler h2 close; -handler h4 close; -# close all depending handler tables -handler t1 open as h1_1; -handler t1 open as h1_2; -handler t1 open as h1_3; -handler h1_1 read first limit 9; -handler h1_2 read first limit 9; -handler h1_3 read first limit 9; -alter table t1 engine=MyISAM; ---error 1109 -handler h1_1 read first limit 9; ---error 1109 -handler h1_2 read first limit 9; ---error 1109 -handler h1_3 read first limit 9; -drop table t1; -drop table t2; -drop table t3; -drop table t4; -drop table t5; - -# -# Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash -# -create table t1 (c1 int); -insert into t1 values (1); -# client 1 -handler t1 open; -handler t1 read first; -# client 2 -connect (con2,localhost,root,,); -connection con2; ---exec echo send the below to another connection, do not wait for the result -send optimize table t1; ---sleep 1 -# client 1 ---exec echo proceed with the normal connection -connection default; -handler t1 read next; -handler t1 close; -# client 2 ---exec echo read the result from the other connection -connection con2; -reap; -# client 1 ---exec echo proceed with the normal connection -connection default; -drop table t1; - -# End of 4.1 tests - -# -# Addendum to Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash -# Show that DROP TABLE can no longer deadlock against -# FLUSH TABLES WITH READ LOCK. This is a 5.0 issue. -# -create table t1 (c1 int); -insert into t1 values (14397); -flush tables with read lock; -# The thread with the global read lock cannot drop the table itself: ---error 1223 -drop table t1; -# -# client 2 -# We need a second connection to try the drop. -# The drop waits for the global read lock to go away. -# Without the addendum fix it locked LOCK_open before entering the wait loop. -connection con2; ---exec echo send the below to another connection, do not wait for the result -send drop table t1; ---sleep 1 -# -# client 1 -# Now we need something that wants LOCK_open. A simple table access which -# opens the table does the trick. ---exec echo proceed with the normal connection -connection default; -# This would hang on LOCK_open without the 5.0 addendum fix. -select * from t1; -# Release the read lock. This should make the DROP go through. -unlock tables; -# -# client 2 -# Read the result of the drop command. -connection con2; ---exec echo read the result from the other connection -reap; -# -# client 1 -# Now back to normal operation. The table should not exist any more. ---exec echo proceed with the normal connection -connection default; ---error 1146 -select * from t1; -# Just to be sure and not confuse the next test case writer. -drop table if exists t1; - -# -# Bug#25856 - HANDLER table OPEN in one connection lock DROP TABLE in another one -# ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1 (a int) ENGINE=MEMORY; ---echo --> client 2 -connection con2; ---error 1031 -handler t1 open; ---echo --> client 1 -connection default; -drop table t1; - -# -# Bug#30632 HANDLER read failure causes hang -# ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1 (a int); -handler t1 open as t1_alias; ---error 1176 -handler t1_alias read a next; ---error 1054 -handler t1_alias READ a next where inexistent > 0; ---error 1176 -handler t1_alias read a next; ---error 1054 -handler t1_alias READ a next where inexistent > 0; -handler t1_alias close; -drop table t1; - -# -# Bug#44151 using handler commands on information_schema tables crashes server -# -USE information_schema; ---error ER_WRONG_USAGE -HANDLER COLUMNS OPEN; -USE test; diff --git a/mysql-test/t/handler_innodb.test b/mysql-test/t/handler_innodb.test new file mode 100644 index 00000000000..02982716f78 --- /dev/null +++ b/mysql-test/t/handler_innodb.test @@ -0,0 +1,20 @@ +# t/handler_innodb.test +# +# test of HANDLER ... +# +# Last update: +# 2006-07-31 ML test refactored (MySQL 5.1) +# code of t/handler.test and t/innodb_handler.test united +# main testing code put into include/handler.inc +# rename t/innodb_handler.test to t/handler_innodb.test +# + +# should work in embedded server after mysqltest is fixed +--source include/not_embedded.inc + +--source include/have_innodb.inc +let $engine_type= InnoDB; +let $other_engine_type= MEMORY; +let $other_handler_engine_type= MyISAM; + +--source include/handler.inc diff --git a/mysql-test/t/handler_myisam.test b/mysql-test/t/handler_myisam.test new file mode 100644 index 00000000000..da02a90af0f --- /dev/null +++ b/mysql-test/t/handler_myisam.test @@ -0,0 +1,40 @@ +# t/handler_myisam.test +# +# test of HANDLER ... +# +# Last update: +# 2006-07-31 ML test refactored (MySQL 5.1) +# code of t/handler.test and t/innodb_handler.test united +# main testing code put into include/handler.inc +# rename t/handler.test to t/handler_myisam.test +# + +# should work in embedded server after mysqltest is fixed +--source include/not_embedded.inc + +let $engine_type= MyISAM; +let $other_engine_type= MEMORY; +# There is unfortunately no other all time available storage engine +# which supports the handler interface +let $other_handler_engine_type= MyISAM; + +--source include/handler.inc + +--echo # +--echo # BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash +--echo # +CREATE TABLE t1 AS SELECT 1 AS f1; +HANDLER t1 OPEN; +TRUNCATE t1; +--error ER_UNKNOWN_TABLE +HANDLER t1 READ FIRST; +DROP TABLE t1; + +CREATE TEMPORARY TABLE t1 AS SELECT 1 AS f1; +HANDLER t1 OPEN; +TRUNCATE t1; +--error ER_UNKNOWN_TABLE +HANDLER t1 READ FIRST; +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index adabbb711d4..af9af4fe1fc 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -427,7 +427,7 @@ create table t1(f1 int); select f1 from t1 having max(f1)=f1; select f1 from t1 group by f1 having max(f1)=f1; set session sql_mode='ONLY_FULL_GROUP_BY'; ---error 1463 +--error ER_NON_GROUPING_FIELD_USED select f1 from t1 having max(f1)=f1; select f1 from t1 group by f1 having max(f1)=f1; set session sql_mode=''; diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index e501fce1eeb..3f91b9966e7 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -128,7 +128,7 @@ SELECT * FROM t1 WHERE b=NULL; explain SELECT * FROM t1 WHERE b IS NULL; SELECT * FROM t1 WHERE b<=>NULL; ---error 1062 +--error ER_DUP_ENTRY INSERT INTO t1 VALUES (1,3); DROP TABLE t1; @@ -270,7 +270,7 @@ explain select count(*) from t1 where v like 'a%'; explain select count(*) from t1 where v between 'a' and 'a '; explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; ---error 1062 +--error ER_DUP_ENTRY alter table t1 add unique(v); select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); explain select * from t1 where v='a'; @@ -296,17 +296,17 @@ drop table t1; create table t1 (a char(10), unique (a)); insert into t1 values ('a'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('a '); alter table t1 modify a varchar(10); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('a '),('a '),('a '),('a '); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('a '); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('a '); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('a '); update t1 set a='a ' where a like 'a '; update t1 set a='a ' where a like 'a '; @@ -357,7 +357,7 @@ explain select count(*) from t1 where v between 'a' and 'a '; --replace_column 9 # explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; ---error 1062 +--error ER_DUP_ENTRY alter table t1 add unique(v); select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); # Number of rows is not constant for b-trees keys @@ -372,17 +372,17 @@ drop table t1; create table t1 (a char(10), unique using btree (a)) engine=heap; insert into t1 values ('a'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('a '); alter table t1 modify a varchar(10); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('a '),('a '),('a '),('a '); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('a '); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('a '); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ('a '); update t1 set a='a ' where a like 'a '; update t1 set a='a ' where a like 'a '; @@ -432,7 +432,7 @@ create table t1 (a int not null, b int not null auto_increment, # create table t1 (c char(255), primary key(c(90))); insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); drop table t1; @@ -471,3 +471,12 @@ SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256); DROP TABLE t1; # End of 5.0 tests + +# +# BUG#26080 - Memory Storage engine not working properly +# +CREATE TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY; +INSERT INTO t1 VALUES('', 0); +ALTER TABLE t1 MODIFY c1 VARCHAR(101); +SELECT c2 FROM t1; +DROP TABLE t1; diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index 710c8411751..637c6ba1c81 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -143,7 +143,7 @@ SELECT * FROM t1 WHERE b=NULL; explain SELECT * FROM t1 WHERE b IS NULL; SELECT * FROM t1 WHERE b<=>NULL; ---error 1062 +--error ER_DUP_ENTRY INSERT INTO t1 VALUES (1,3); DROP TABLE t1; diff --git a/mysql-test/t/heap_hash.test b/mysql-test/t/heap_hash.test index c0f37fe490e..1e3491f89a9 100644 --- a/mysql-test/t/heap_hash.test +++ b/mysql-test/t/heap_hash.test @@ -128,7 +128,7 @@ SELECT * FROM t1 WHERE b=NULL; explain SELECT * FROM t1 WHERE b IS NULL; SELECT * FROM t1 WHERE b<=>NULL; ---error 1062 +--error ER_DUP_ENTRY INSERT INTO t1 VALUES (1,3); DROP TABLE t1; diff --git a/mysql-test/t/help.test b/mysql-test/t/help.test index de0cefab76c..71821e46771 100644 --- a/mysql-test/t/help.test +++ b/mysql-test/t/help.test @@ -114,4 +114,25 @@ delete from mysql.help_relation where help_keyword_id=@keyword2_id and help_topi delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic3_id; delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic4_id; -# End of 4.1 tests +--echo End of 4.1 tests. + +# +# Test that we can use HELP even under LOCK TABLES. See bug#9953: +# CONVERT_TZ requires mysql.time_zone_name to be locked. +# +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (i INT); + +LOCK TABLES t1 WRITE; + +HELP no_such_topic; + +UNLOCK TABLES; + +DROP TABLE t1; + + +--echo End of 5.1 tests. diff --git a/mysql-test/t/im_daemon_life_cycle-im.opt b/mysql-test/t/im_daemon_life_cycle-im.opt deleted file mode 100644 index 3a45c7a41f7..00000000000 --- a/mysql-test/t/im_daemon_life_cycle-im.opt +++ /dev/null @@ -1,3 +0,0 @@ ---run-as-service ---log=$MYSQLTEST_VARDIR/log/im.log ---monitoring-interval=1 diff --git a/mysql-test/t/im_daemon_life_cycle.imtest b/mysql-test/t/im_daemon_life_cycle.imtest deleted file mode 100644 index 0ecc3f18f40..00000000000 --- a/mysql-test/t/im_daemon_life_cycle.imtest +++ /dev/null @@ -1,98 +0,0 @@ -########################################################################### -# -# This file contains test for (1.2) test suite. -# -# Consult WL#2789 for more information. -# -########################################################################### - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle im_daemon_life_cycle.imtest started. - -########################################################################### - ---source include/im_check_env.inc - -# Turn on reconnect, not on by default anymore. ---enable_reconnect - -########################################################################### -# -# The main daemon-life-cycle test case -- check that IM-angel will restart -# IM-main if it got killed: -# - kill IM-main and check that IM-angel will restart it; -# - wait for IM-main to start accepting connections before continue test -# case; -# -# NOTE: timeout is 55 seconds. Timeout should be more than shutdown-delay -# specified for managed MySQL instance. Now shutdown-delay is 10 seconds -# (set in mysql-test-run.pl). So, 55 seconds should be enough to make 5 -# attempts. -# -########################################################################### - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Main-test: starting... - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Killing IM-main... ---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 55 im_daemon_life_cycle - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Waiting for IM-main to start accepting connections... ---exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 55 im_daemon_life_cycle - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Main-test: done. - -########################################################################### -# -# BUG#12751: Instance Manager: client hangs -# - start nonguarded instance (mysqld2); -# - kill IM-main and get it restarted by IM-angel; -# - check that guarded instance (mysqld1) is accepting connections. -# - check that non-guarded instance (mysqld2) were not stopped. -# -########################################################################### - ---echo ---echo -------------------------------------------------------------------- ---echo -- Test for BUG#12751 ---echo -------------------------------------------------------------------- - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle BUG12751: starting... - -# 1. Start mysqld; - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: starting... -START INSTANCE mysqld2; - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: waiting to start... ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 55 started im_daemon_life_cycle - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: started. - -# 2. Restart IM-main; - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Killing IM-main... ---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 55 im_daemon_life_cycle - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Waiting for IM-main to start accepting connections... ---exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 55 im_daemon_life_cycle - -# 3. Issue some statement -- connection should be re-established. - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Checking that IM-main processing commands... - ---replace_column 2 STATE 3 VERSION -SHOW INSTANCE STATUS mysqld1; - -# 4. Stop mysqld2, because it will not be stopped by IM, as it is nonguarded. -# So, if it we do not stop it, it will be stopped by mysql-test-run.pl with -# warning. - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: stopping... -STOP INSTANCE mysqld2; - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: waiting to stop... ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 55 stopped im_daemon_life_cycle ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: stopped. - -########################################################################### - ---exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle BUG12751: done. diff --git a/mysql-test/t/im_life_cycle-im.opt b/mysql-test/t/im_life_cycle-im.opt deleted file mode 100644 index 34b74ce0c95..00000000000 --- a/mysql-test/t/im_life_cycle-im.opt +++ /dev/null @@ -1 +0,0 @@ ---monitoring-interval=1 diff --git a/mysql-test/t/im_life_cycle.imtest b/mysql-test/t/im_life_cycle.imtest deleted file mode 100644 index 3721b92e2b7..00000000000 --- a/mysql-test/t/im_life_cycle.imtest +++ /dev/null @@ -1,203 +0,0 @@ -########################################################################### -# -# This file contains test for (1.1) test suite. -# -# Consult WL#2789 for more information. -# -########################################################################### - ---source include/im_check_env.inc - -########################################################################### -# -# 1.1.2. Check 'START INSTANCE' command: -# - start the second instance; -# - check that it is reported as online; -# - execute some SQL-statement on mysqld2 to ensure that it is really up and -# running; -# -########################################################################### - ---echo ---echo -------------------------------------------------------------------- ---echo -- 1.1.2. ---echo -------------------------------------------------------------------- - -START INSTANCE mysqld2; -# FIXME: START INSTANCE should be synchronous. ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_life_cycle - -# FIXME: Result of SHOW INSTANCES here is not deterministic unless START -# INSTANCE is synchronous. Even waiting for mysqld to start by looking at -# its pid file is not enough, because it is unknown when IM detects that -# mysqld has started. -# SHOW INSTANCES; - ---connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD2_PORT,$IM_MYSQLD2_SOCK) ---connection mysql_con - ---replace_result $IM_MYSQLD2_PORT IM_MYSQLD2_PORT -SHOW VARIABLES LIKE 'port'; - ---connection default ---disconnect mysql_con - -########################################################################### -# -# 1.1.3. Check 'STOP INSTANCE' command: -# - stop the second instance; -# - check that it is reported as offline; -# - TODO: try to execute some SQL-statement to ensure that it is really down; -# -########################################################################### - ---echo ---echo -------------------------------------------------------------------- ---echo -- 1.1.3. ---echo -------------------------------------------------------------------- - -STOP INSTANCE mysqld2; -# FIXME: STOP INSTANCE should be synchronous. ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_life_cycle - -# FIXME: Result of SHOW INSTANCES here is not deterministic unless START -# INSTANCE is synchronous. Even waiting for mysqld to start by looking at -# its pid file is not enough, because it is unknown when IM detects that -# mysqld has started. -# SHOW INSTANCES; - -########################################################################### -# -# 1.1.4. Check that Instance Manager reports correct errors for 'START -# INSTANCE' command: -# - if the client tries to start unregistered instance; -# - if the client tries to start already started instance; -# - if the client submits invalid arguments; -# -########################################################################### - ---echo ---echo -------------------------------------------------------------------- ---echo -- 1.1.4. ---echo -------------------------------------------------------------------- - ---error 3000 # ER_BAD_INSTANCE_NAME -START INSTANCE mysqld3; - ---error 3002 # ER_INSTANCE_ALREADY_STARTED -START INSTANCE mysqld1; - -########################################################################### -# -# 1.1.5. Check that Instance Manager reports correct errors for -# 'STOP INSTANCE' command: -# - if the client tries to start unregistered instance; -# - if the client tries to start already stopped instance; -# - if the client submits invalid arguments; -# -########################################################################### - ---echo ---echo -------------------------------------------------------------------- ---echo -- 1.1.5. ---echo -------------------------------------------------------------------- - ---error 3000 # ER_BAD_INSTANCE_NAME -STOP INSTANCE mysqld3; - -# TODO: IM should be fixed. -# BUG#12673: Instance Manager allows to stop the instance many times -# --error 3002 # ER_INSTANCE_ALREADY_STARTED -# STOP INSTANCE mysqld2; - -########################################################################### -# -# 1.1.6. Check that Instance Manager is able to restart guarded instances. -# -########################################################################### - ---echo ---echo -------------------------------------------------------------------- ---echo -- 1.1.6. ---echo -------------------------------------------------------------------- - ---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30 im_life_cycle - -# Give some time to IM to detect that mysqld was restarted. It should be -# longer than monitoring interval. - ---sleep 3 - -SHOW INSTANCES; - -########################################################################### -# -# 1.1.7. Check that Instance Manager does not restart non-guarded instance. -# -########################################################################### - ---echo ---echo -------------------------------------------------------------------- ---echo -- 1.1.7. ---echo -------------------------------------------------------------------- - -START INSTANCE mysqld2; -# FIXME: START INSTANCE should be synchronous. ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_life_cycle - -# FIXME: Result of SHOW INSTANCES here is not deterministic unless START -# INSTANCE is synchronous. Even waiting for mysqld to start by looking at -# its pid file is not enough, because it is unknown when IM detects that -# mysqld has started. -# SHOW INSTANCES; - ---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10 im_life_cycle - -# FIXME: Result of SHOW INSTANCES here is not deterministic unless START -# INSTANCE is synchronous. Even waiting for mysqld to start by looking at -# its pid file is not enough, because it is unknown when IM detects that -# mysqld has started. -# SHOW INSTANCES; - -########################################################################### -# -# 1.1.8. Check that Instance Manager returns an error on -# incomplete SHOW INSTANCE STATUS command. -# -########################################################################### - ---echo ---echo -------------------------------------------------------------------- ---echo -- 1.1.8. ---echo -------------------------------------------------------------------- - ---error ER_SYNTAX_ERROR -SHOW INSTANCE STATUS; - -# -# Tests for bug fixes -# - -# -# Bug #12813 Instance Manager: START/STOP INSTANCE commands accept -# a list as argument. -# - ---echo ---echo -------------------------------------------------------------------- ---echo -- BUG#12813 ---echo -------------------------------------------------------------------- - ---error ER_SYNTAX_ERROR -START INSTANCE mysqld1,mysqld2,mysqld3; - ---error ER_SYNTAX_ERROR -STOP INSTANCE mysqld1,mysqld2,mysqld3; - -# -# Bug #12673: Instance Manager: allows to stop the instance many times -# ---error 3001 -STOP INSTANCE mysqld2; - ---echo End of 5.0 tests diff --git a/mysql-test/t/im_options_set.imtest b/mysql-test/t/im_options_set.imtest deleted file mode 100644 index 6a70c31c0a4..00000000000 --- a/mysql-test/t/im_options_set.imtest +++ /dev/null @@ -1,116 +0,0 @@ -########################################################################### -# -# This file contains test for (3) test suite. -# -# Consult WL#2789 for more information. -# -########################################################################### - -# -# Check the options-management commands: -# - SET; -# - FLUSH INSTANCES; -# -# Let's test the commands on the option 'server_id'. It's expected that -# originally the instances have the following server ids: -# - mysqld1: 1 -# - mysqld2: 2 -# -# 1. SET <instance_id>.server_id= SERVER_ID); where SERVER_ID is 11 or 12. -# 1.1. check that the configuration file has been updated (i.e. contains -# server_id=SERVER_ID for the instance); -# 1.2. (for mysqld1) check that the running instance has not been affected: -# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id'' -# returns zero; -# 1.3. check that internal cache of Instance Manager has not been affected -# (i.e. SHOW INSTANCE OPTIONS <instance> does not contain updated value). -# -# 2. FLUSH INSTANCES; -# 2.1. check that the configuration file has not been updated; -# 2.2. (for mysqld1) check that the running instance has not been affected: -# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id'' -# returns zero value; -# 2.3. check that internal cache of Instance Manager has been updated (i.e. -# SHOW INSTANCE OPTIONS <instance> contains 'server_id=SERVER_ID' line). -# -# 3. Restore options. -# - -########################################################################### - ---source include/im_check_env.inc - -########################################################################### -# -# 1. SET <instance_id>.server_id= SERVER_ID); where SERVER_ID is 11 or 12. -# -########################################################################### - -# * mysqld1 - -SET mysqld1.server_id = 11; - -# - check that the configuration file has been updated (i.e. contains -# server_id=SERVER_ID for the instance); - ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; - -# - (for mysqld1) check that the running instance has not been affected: -# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id'' -# returns zero; - ---connection mysql1_con - -SHOW VARIABLES LIKE 'server_id'; - ---connection default - -# - check that internal cache of Instance Manager has not been affected -# (i.e. SHOW INSTANCE OPTIONS <instance> does not contain updated value). -# TODO: we should check only server_id option here. - -# SHOW INSTANCE OPTIONS mysqld1; - -# * mysqld2 - -SET mysqld2.server_id = 12; - -# - check that the configuration file has been updated (i.e. contains -# server_id=SERVER_ID for the instance); - ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; - -# - check that internal cache of Instance Manager has not been affected -# (i.e. SHOW INSTANCE OPTIONS <instance> does not contain updated value). -# TODO: we should check only server_id option here. - -# SHOW INSTANCE OPTIONS mysqld2; - -########################################################################### -# -# 2. FLUSH INSTANCES; -# -########################################################################### - -FLUSH INSTANCES; - -# - check that the configuration file has not been updated; - ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; - -# - (for mysqld1) check that the running instance has not been affected: -# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id'' -# returns zero value; - ---connection mysql1_con - -SHOW VARIABLES LIKE 'server_id'; - ---connection default - -# - check that internal cache of Instance Manager has been updated (i.e. -# SHOW INSTANCE OPTIONS <instance> contains 'server_id=' line). -# TODO: we should check only server_id option here. - -# SHOW INSTANCE OPTIONS mysqld1; -# SHOW INSTANCE OPTIONS mysqld2; diff --git a/mysql-test/t/im_options_unset.imtest b/mysql-test/t/im_options_unset.imtest deleted file mode 100644 index 074c9a3b869..00000000000 --- a/mysql-test/t/im_options_unset.imtest +++ /dev/null @@ -1,124 +0,0 @@ -########################################################################### -# -# This file contains test for (3) test suite. -# -# Consult WL#2789 for more information. -# -########################################################################### - -# -# Check the options-management commands: -# - UNSET; -# - FLUSH INSTANCES; -# -# Let's test the commands on the option 'server_id'. It's expected that -# originally the instances have the following server ids: -# - mysqld1: 1 -# - mysqld2: 2 -# -# The test case: -# -# 1. UNSET <instance_id>.server_id; -# -# Do the step for both instances. -# -# 1.1. check that the configuration file has been updated (i.e. does not -# contain 'server_id=' line for the instance); -# 1.2. (for mysqld1) check that the running instance has not been affected: -# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id'' -# returns non-zero value; -# 1.3. check that internal cache of Instance Manager is not affected (i.e. -# SHOW INSTANCE OPTIONS <instance> contains non-zero value for server_id); -# -# 2. FLUSH INSTANCES; -# -# Do the step for both instances. -# -# 2.1. check that the configuration file has not been updated (i.e. does not -# contain 'server_id=' for the instance); -# 2.2. (for mysqld1) check that the running instance has not been affected: -# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id'' -# returns non-zero value; -# 2.3. check that internal cache of Instance Manager has been updated (i.e. -# SHOW INSTANCE OPTIONS <instance> does not contain 'server_id=' line). -# - -########################################################################### - ---source include/im_check_env.inc - -########################################################################### -# -# 1. UNSET <instance_id>.server_id; -# -########################################################################### - -# * mysqld1 - -UNSET mysqld1.server_id; - -# - check that the configuration file has been updated (i.e. does not -# contain 'server_id=' line for the instance); - ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; - -# - check that the running instance has not been affected: connect to the -# instance and check that 'SHOW VARIABLES LIKE 'server_id'' returns non-zero -# value; - ---connection mysql1_con - -SHOW VARIABLES LIKE 'server_id'; - ---connection default - -# - check that internal cache of Instance Manager is not affected (i.e. SHOW -# INSTANCE OPTIONS <instance> contains non-zero value for server_id); -# TODO: we should check only server_id option here. - -# SHOW INSTANCE OPTIONS mysqld1; - -# * mysqld2 - -UNSET mysqld2.server_id; - -# - check that the configuration file has been updated (i.e. does not -# contain 'server_id=' line for the instance); - ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf || true; - -# - check that internal cache of Instance Manager is not affected (i.e. SHOW -# INSTANCE OPTIONS <instance> contains non-zero value for server_id); -# TODO: we should check only server_id option here. - -# SHOW INSTANCE OPTIONS mysqld2; - -########################################################################### -# -# 2. FLUSH INSTANCES; -# -########################################################################### - -FLUSH INSTANCES; - -# - check that the configuration file has not been updated (i.e. does not -# contain 'server_id=' for the instance); - ---exec grep server_id $MYSQLTEST_VARDIR/im.cnf || true; - -# - (for mysqld1) check that the running instance has not been affected: -# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id'' -# returns non-zero value; - ---connection mysql1_con - -SHOW VARIABLES LIKE 'server_id'; - ---connection default - -# - check that internal cache of Instance Manager has been updated (i.e. -# SHOW INSTANCE OPTIONS <instance> does not contain 'server_id=' line). -# TODO: we should check only server_id option here. - -# SHOW INSTANCE OPTIONS mysqld1; -# SHOW INSTANCE OPTIONS mysqld2; diff --git a/mysql-test/t/im_utils-im.opt b/mysql-test/t/im_utils-im.opt deleted file mode 100644 index 34b74ce0c95..00000000000 --- a/mysql-test/t/im_utils-im.opt +++ /dev/null @@ -1 +0,0 @@ ---monitoring-interval=1 diff --git a/mysql-test/t/im_utils.imtest b/mysql-test/t/im_utils.imtest deleted file mode 100644 index 0866b87204a..00000000000 --- a/mysql-test/t/im_utils.imtest +++ /dev/null @@ -1,105 +0,0 @@ -########################################################################### -# -# This file contains test for (2) test suite. -# -# Consult WL#2789 for more information. -# -########################################################################### - ---source include/im_check_env.inc - -########################################################################### - -# -# Check 'SHOW INSTANCE OPTIONS' command. -# -# Since configuration of an mysqld-instance contains directories, we should -# completely ignore the second column (values) in order to make the test -# case produce the same results on different installations; -# TODO: ignore values of only directory-specific options. -# - ---replace_column 2 VALUE -SHOW INSTANCE OPTIONS mysqld1; - ---replace_column 2 VALUE -SHOW INSTANCE OPTIONS mysqld2; - -# -# Before checking log files, we should start the second instance (mysqld2) to -# give it a chance to create log files. -# - -START INSTANCE mysqld2; ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_utils - -STOP INSTANCE mysqld2; ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_utils - -# -# Check 'SHOW LOG FILES' command: -# - check that log files of both offline and online instances are accessible; -# - since placement of the log files is installation-specific, we should -# ignore it in comparisson; -# - also, we should ignore log file size, since it may depend on the version -# being tested; -# - ---replace_column 2 PATH 3 FILE_SIZE -SHOW mysqld1 LOG FILES; - ---replace_column 2 PATH 3 FILE_SIZE -SHOW mysqld2 LOG FILES; - -# -# Check 'SHOW LOG' command: -# - check that all three kinds of logs are available for both offline and -# online instances; -# - we should ignore the value, because it is very specific and depends on -# many factors; we only check that Instance Manager is able to provide log -# files. -# - -# mysqld1 (online) w/o the optional argument. - ---replace_column 1 LOG_DATA -SHOW mysqld1 LOG ERROR 10; - ---replace_column 1 LOG_DATA -SHOW mysqld1 LOG SLOW 10; - ---replace_column 1 LOG_DATA -SHOW mysqld1 LOG GENERAL 10; - -# mysqld1 (online) with the optional argument. - ---replace_column 1 LOG_DATA -SHOW mysqld1 LOG ERROR 10, 2; - ---replace_column 1 LOG_DATA -SHOW mysqld1 LOG SLOW 10, 2; - ---replace_column 1 LOG_DATA -SHOW mysqld1 LOG GENERAL 10, 2; - -# mysqld2 (offline) w/o the optional argument. - ---replace_column 1 LOG_DATA -SHOW mysqld2 LOG ERROR 10; - ---replace_column 1 LOG_DATA -SHOW mysqld2 LOG SLOW 10; - ---replace_column 1 LOG_DATA -SHOW mysqld2 LOG GENERAL 10; - -# mysqld2 (offline) with the optional argument. - ---replace_column 1 LOG_DATA -SHOW mysqld2 LOG ERROR 10, 2; - ---replace_column 1 LOG_DATA -SHOW mysqld2 LOG SLOW 10, 2; - ---replace_column 1 LOG_DATA -SHOW mysqld2 LOG GENERAL 10, 2; diff --git a/mysql-test/t/index_merge.test b/mysql-test/t/index_merge.test deleted file mode 100644 index ebe0fa42fcd..00000000000 --- a/mysql-test/t/index_merge.test +++ /dev/null @@ -1,532 +0,0 @@ -# -# Index merge tests -# ---disable_warnings -drop table if exists t0, t1, t2, t3, t4; ---enable_warnings - -# Create and fill a table with simple keys -create table t0 -( - key1 int not null, - INDEX i1(key1) -); - ---disable_query_log -insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8); - -let $1=7; -set @d=8; -while ($1) -{ - eval insert into t0 select key1+@d from t0; - eval set @d=@d*2; - dec $1; -} ---enable_query_log - -alter table t0 add key2 int not null, add index i2(key2); -alter table t0 add key3 int not null, add index i3(key3); -alter table t0 add key4 int not null, add index i4(key4); -alter table t0 add key5 int not null, add index i5(key5); -alter table t0 add key6 int not null, add index i6(key6); -alter table t0 add key7 int not null, add index i7(key7); -alter table t0 add key8 int not null, add index i8(key8); - -update t0 set key2=key1,key3=key1,key4=key1,key5=key1,key6=key1,key7=key1,key8=1024-key1; -analyze table t0; - -# 1. One index -explain select * from t0 where key1 < 3 or key1 > 1020; - -# 2. Simple cases -explain -select * from t0 where key1 < 3 or key2 > 1020; -select * from t0 where key1 < 3 or key2 > 1020; - -explain select * from t0 where key1 < 3 or key2 <4; - -explain -select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40); -select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40); - -# 3. Check that index_merge doesn't break "ignore/force/use index" -explain select * from t0 ignore index (i2) where key1 < 3 or key2 <4; -explain select * from t0 where (key1 < 3 or key2 <4) and key3 = 50; -explain select * from t0 use index (i1,i2) where (key1 < 3 or key2 <4) and key3 = 50; - -explain select * from t0 where (key1 > 1 or key2 > 2); -explain select * from t0 force index (i1,i2) where (key1 > 1 or key2 > 2); - - -# 4. Check if conjuncts are grouped by keyuse -explain - select * from t0 where key1<3 or key2<3 or (key1>5 and key1<8) or - (key1>10 and key1<12) or (key2>100 and key2<110); - -# 5. Check index_merge with conjuncts that are always true/false -# verify fallback to "range" if there is only one non-confluent condition -explain select * from t0 where key2 = 45 or key1 <=> null; - -explain select * from t0 where key2 = 45 or key1 is not null; -explain select * from t0 where key2 = 45 or key1 is null; - -# the last conj. is always false and will be discarded -explain select * from t0 where key2=10 or key3=3 or key4 <=> null; - -# the last conj. is always true and will cause 'all' scan -explain select * from t0 where key2=10 or key3=3 or key4 is null; - -# some more complicated cases -explain select key1 from t0 where (key1 <=> null) or (key2 < 5) or - (key3=10) or (key4 <=> null); -explain select key1 from t0 where (key1 <=> null) or (key1 < 5) or - (key3=10) or (key4 <=> null); - -# 6.Several ways to do index_merge, (ignored) index_merge vs. range -explain select * from t0 where - (key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 5 or key6 < 5); - -explain -select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4); - -select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4); - - -explain select * from t0 where - (key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 2 or key6 < 2); - -# now index_merge is not used at all when "range" is possible -explain select * from t0 where - (key1 < 3 or key2 < 3) and (key3 < 100); - -# this even can cause "all" scan: -explain select * from t0 where - (key1 < 3 or key2 < 3) and (key3 < 1000); - - -# 7. Complex cases -# tree_or(List<SEL_IMERGE>, range SEL_TREE). -explain select * from t0 where - ((key1 < 4 or key2 < 4) and (key2 <5 or key3 < 4)) - or - key2 > 5; - -explain select * from t0 where - ((key1 < 4 or key2 < 4) and (key2 <5 or key3 < 4)) - or - key1 < 7; - -select * from t0 where - ((key1 < 4 or key2 < 4) and (key2 <5 or key3 < 4)) - or - key1 < 7; - -# tree_or(List<SEL_IMERGE>, List<SEL_IMERGE>). -explain select * from t0 where - ((key1 < 4 or key2 < 4) and (key3 <5 or key5 < 4)) - or - ((key5 < 5 or key6 < 6) and (key7 <7 or key8 < 4)); - -explain select * from t0 where - ((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4)) - or - ((key7 <7 or key8 < 4) and (key5 < 5 or key6 < 6)); - -explain select * from t0 where - ((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4)) - or - ((key3 <7 or key5 < 2) and (key5 < 5 or key6 < 6)); - -explain select * from t0 where - ((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4)) - or - (((key3 <7 and key7 < 6) or key5 < 2) and (key5 < 5 or key6 < 6)); - -explain select * from t0 where - ((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4)) - or - ((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6)); - -explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where - ((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4)) - or - ((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6)); - -# 8. Verify that "order by" after index merge uses filesort -select * from t0 where key1 < 5 or key8 < 4 order by key1; - -explain -select * from t0 where key1 < 5 or key8 < 4 order by key1; - -# 9. Check that index_merge cost is compared to 'index' where possible -create table t2 like t0; -insert into t2 select * from t0; - -alter table t2 add index i1_3(key1, key3); -alter table t2 add index i2_3(key2, key3); -alter table t2 drop index i1; -alter table t2 drop index i2; -alter table t2 add index i321(key3, key2, key1); - -# index_merge vs 'index', index_merge is better. -explain select key3 from t2 where key1 = 100 or key2 = 100; - -# index_merge vs 'index', 'index' is better. -explain select key3 from t2 where key1 <100 or key2 < 100; - -# index_merge vs 'all', index_merge is better. -explain select key7 from t2 where key1 <100 or key2 < 100; - -# 10. Multipart keys. -create table t4 ( - key1a int not null, - key1b int not null, - key2 int not null, - key2_1 int not null, - key2_2 int not null, - key3 int not null, - - index i1a (key1a, key1b), - index i1b (key1b, key1a), - - index i2_1(key2, key2_1), - index i2_2(key2, key2_1) -); - -insert into t4 select key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 from t0; - -# the following will be handled by index_merge: -select * from t4 where key1a = 3 or key1b = 4; -explain select * from t4 where key1a = 3 or key1b = 4; - -# and the following will not -explain select * from t4 where key2 = 1 and (key2_1 = 1 or key3 = 5); - -explain select * from t4 where key2 = 1 and (key2_1 = 1 or key2_2 = 5); - -explain select * from t4 where key2_1 = 1 or key2_2 = 5; - - -# 11. Multitable selects -create table t1 like t0; -insert into t1 select * from t0; - -# index_merge on first table in join -explain select * from t0 left join t1 on (t0.key1=t1.key1) - where t0.key1=3 or t0.key2=4; - -select * from t0 left join t1 on (t0.key1=t1.key1) - where t0.key1=3 or t0.key2=4; - -explain -select * from t0,t1 where (t0.key1=t1.key1) and ( t0.key1=3 or t0.key2=4); - -# index_merge vs. ref -explain -select * from t0,t1 where (t0.key1=t1.key1) and - (t0.key1=3 or t0.key2=4) and t1.key1<200; - -# index_merge vs. ref -explain -select * from t0,t1 where (t0.key1=t1.key1) and - (t0.key1=3 or t0.key2<4) and t1.key1=2; - -# index_merge on second table in join -explain select * from t0,t1 where t0.key1 = 5 and - (t1.key1 = t0.key1 or t1.key8 = t0.key1); - -# Fix for bug#1974 -explain select * from t0,t1 where t0.key1 < 3 and - (t1.key1 = t0.key1 or t1.key8 = t0.key1); - -# index_merge inside union -explain select * from t1 where key1=3 or key2=4 - union select * from t1 where key1<4 or key3=5; - -# index merge in subselect -explain select * from (select * from t1 where key1 = 3 or key2 =3) as Z where key8 >5; - -# 12. check for long index_merges. -create table t3 like t0; -insert into t3 select * from t0; -alter table t3 add key9 int not null, add index i9(key9); -alter table t3 add keyA int not null, add index iA(keyA); -alter table t3 add keyB int not null, add index iB(keyB); -alter table t3 add keyC int not null, add index iC(keyC); -update t3 set key9=key1,keyA=key1,keyB=key1,keyC=key1; - -explain select * from t3 where - key1=1 or key2=2 or key3=3 or key4=4 or - key5=5 or key6=6 or key7=7 or key8=8 or - key9=9 or keyA=10 or keyB=11 or keyC=12; - -select * from t3 where - key1=1 or key2=2 or key3=3 or key4=4 or - key5=5 or key6=6 or key7=7 or key8=8 or - key9=9 or keyA=10 or keyB=11 or keyC=12; - -# Test for Bug#3183 -explain select * from t0 where key1 < 3 or key2 < 4; -select * from t0 where key1 < 3 or key2 < 4; - -update t0 set key8=123 where key1 < 3 or key2 < 4; -select * from t0 where key1 < 3 or key2 < 4; - -delete from t0 where key1 < 3 or key2 < 4; -select * from t0 where key1 < 3 or key2 < 4; -select count(*) from t0; - -# Test for BUG#4177 -drop table t4; -create table t4 (a int); -insert into t4 values (1),(4),(3); -set @save_join_buffer_size=@@join_buffer_size; -set join_buffer_size= 4000; -explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5) - from t0 as A force index(i1,i2), t0 as B force index (i1,i2) - where (A.key1 < 500000 or A.key2 < 3) - and (B.key1 < 500000 or B.key2 < 3); - -select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5) - from t0 as A force index(i1,i2), t0 as B force index (i1,i2) - where (A.key1 < 500000 or A.key2 < 3) - and (B.key1 < 500000 or B.key2 < 3); - -update t0 set key1=1; -explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5) - from t0 as A force index(i1,i2), t0 as B force index (i1,i2) - where (A.key1 = 1 or A.key2 = 1) - and (B.key1 = 1 or B.key2 = 1); - -select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5) - from t0 as A force index(i1,i2), t0 as B force index (i1,i2) - where (A.key1 = 1 or A.key2 = 1) - and (B.key1 = 1 or B.key2 = 1); - -alter table t0 add filler1 char(200), add filler2 char(200), add filler3 char(200); -update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500; - -# The next query will not use index i7 in intersection if the OS doesn't -# support file sizes > 2GB. (ha_myisam::ref_length depends on this and index -# scan cost estimates depend on ha_myisam::ref_length) ---replace_column 9 # ---replace_result "4,4,4,4,4,4,4" X "4,4,4,4,4,4" X "i6,i7" "i6,i7?" "i6" "i6,i7?" -explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5) - from t0 as A, t0 as B - where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1) - and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1); - -select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5) - from t0 as A, t0 as B - where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1) - and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1); - -set join_buffer_size= @save_join_buffer_size; -# Test for BUG#4177 ends - -drop table t0, t1, t2, t3, t4; - -# BUG#16166 -CREATE TABLE t1 ( - cola char(3) not null, colb char(3) not null, filler char(200), - key(cola), key(colb) -); -INSERT INTO t1 VALUES ('foo','bar', 'ZZ'),('fuz','baz', 'ZZ'); - ---disable_query_log -let $1=9; -while ($1) -{ - eval INSERT INTO t1 SELECT * from t1 WHERE cola = 'foo'; - dec $1; -} - -let $1=13; -while ($1) -{ - eval INSERT INTO t1 SELECT * from t1 WHERE cola <> 'foo'; - dec $1; -} - ---enable_query_log - -OPTIMIZE TABLE t1; -select count(*) from t1; -explain select * from t1 WHERE cola = 'foo' AND colb = 'bar'; -explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'bar'; -drop table t1; - -# -# BUG#17314: Index_merge/intersection not choosen by the optimizer for MERGE tables -# -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t1 ( - a int, b int, - filler1 char(200), filler2 char(200), - key(a),key(b) -); -insert into t1 select @v:= A.a, @v, 't1', 'filler2' from t0 A, t0 B, t0 C; -create table t2 like t1; - -create table t3 ( - a int, b int, - filler1 char(200), filler2 char(200), - key(a),key(b) -) engine=merge union=(t1,t2); - ---replace_column 9 # -explain select * from t1 where a=1 and b=1; ---replace_column 9 # -explain select * from t3 where a=1 and b=1; - -drop table t3; -drop table t0, t1, t2; - -# -# BUG#20256 - LOCK WRITE - MyISAM -# -CREATE TABLE t1(a INT); -INSERT INTO t1 VALUES(1); -CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b)); -INSERT INTO t2(a,b) VALUES -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(1,2); -LOCK TABLES t1 WRITE, t2 WRITE; -INSERT INTO t2(a,b) VALUES(1,2); -SELECT t2.a FROM t1,t2 WHERE t2.b=2 AND t2.a=1; -UNLOCK TABLES; -DROP TABLE t1, t2; - -# -# BUG#29740: HA_KEY_SCAN_NOT_ROR wasn't set for HEAP engine -# -CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `filler` char(200) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY `a` (`a`), - KEY `b` (`b`) -) ENGINE=MEMORY DEFAULT CHARSET=latin1; - -insert into t1 values -(0, 'filler', 0), (1, 'filler', 1), (2, 'filler', 2), (3, 'filler', 3), -(4, 'filler', 4), (5, 'filler', 5), (6, 'filler', 6), (7, 'filler', 7), -(8, 'filler', 8), (9, 'filler', 9), (0, 'filler', 0), (1, 'filler', 1), -(2, 'filler', 2), (3, 'filler', 3), (4, 'filler', 4), (5, 'filler', 5), -(6, 'filler', 6), (7, 'filler', 7), (8, 'filler', 8), (9, 'filler', 9), -(10, 'filler', 10), (11, 'filler', 11), (12, 'filler', 12), (13, 'filler', 13), -(14, 'filler', 14), (15, 'filler', 15), (16, 'filler', 16), (17, 'filler', 17), -(18, 'filler', 18), (19, 'filler', 19), (4, '5 ', 0), (5, '4 ', 0), -(4, '4 ', 0), (4, 'qq ', 5), (5, 'qq ', 4), (4, 'zz ', 4); - -create table t2( - `a` int(11) DEFAULT NULL, - `filler` char(200) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - KEY USING BTREE (`a`), - KEY USING BTREE (`b`) -) ENGINE=MEMORY DEFAULT CHARSET=latin1; -insert into t2 select * from t1; - ---echo must use sort-union rather than union: ---replace_column 9 # -explain select * from t1 where a=4 or b=4; ---sorted_result -select * from t1 where a=4 or b=4; ---sorted_result -select * from t1 ignore index(a,b) where a=4 or b=4; - ---echo must use union, not sort-union: ---replace_column 9 # -explain select * from t2 where a=4 or b=4; ---sorted_result -select * from t2 where a=4 or b=4; - -drop table t1, t2; - -# -# Bug #37943: Reproducible mysqld crash/sigsegv in sel_trees_can_be_ored -# - -CREATE TABLE t1 (a varchar(8), b set('a','b','c','d','e','f','g','h'), - KEY b(b), KEY a(a)); -INSERT INTO t1 VALUES ('y',''), ('z',''); - -#should not crash -SELECT b,a from t1 WHERE (b!='c' AND b!='f' && b!='h') OR - (a='pure-S') OR (a='DE80337a') OR (a='DE80799'); - -DROP TABLE t1; - ---echo # ---echo # BUG#40974: Incorrect query results when using clause evaluated using range check ---echo # -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - -create table t1 (a int); -insert into t1 values (1),(2); -create table t2(a int, b int); -insert into t2 values (1,1), (2, 1000); -create table t3 (a int, b int, filler char(100), key(a), key(b)); - -insert into t3 select 1000, 1000,'filler' from t0 A, t0 B, t0 C; -insert into t3 values (1,1,'data'); -insert into t3 values (1,1,'data'); --- echo The plan should be ALL/ALL/ALL(Range checked for each record (index map: 0x3) -explain select * from t1 -where exists (select 1 from t2, t3 - where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); - -select * from t1 -where exists (select 1 from t2, t3 - where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); - -drop table t0, t1, t2, t3; - ---echo # ---echo # BUG#44810: index merge and order by with low sort_buffer_size ---echo # crashes server! ---echo # -CREATE TABLE t1(a VARCHAR(128),b VARCHAR(128),KEY(A),KEY(B)); -INSERT INTO t1 VALUES (REPEAT('a',128),REPEAT('b',128)); -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -SET SESSION sort_buffer_size=1; -EXPLAIN -SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' - ORDER BY a,b; -# we don't actually care about the result : we're checking if it crashes ---disable_result_log -SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' - ORDER BY a,b; ---enable_result_log - -SET SESSION sort_buffer_size=DEFAULT; -DROP TABLE t1; - - ---echo End of 5.0 tests diff --git a/mysql-test/t/index_merge_bdb.test b/mysql-test/t/index_merge_bdb.test deleted file mode 100644 index c49e6ab3175..00000000000 --- a/mysql-test/t/index_merge_bdb.test +++ /dev/null @@ -1,52 +0,0 @@ -# -# 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; diff --git a/mysql-test/t/index_merge_innodb.test b/mysql-test/t/index_merge_innodb.test index 25f4e0b4e65..a3bda0ad00c 100644 --- a/mysql-test/t/index_merge_innodb.test +++ b/mysql-test/t/index_merge_innodb.test @@ -1,302 +1,28 @@ +# t/index_merge_innodb.test # # Index merge tests # --- source include/have_innodb.inc - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - -create table t1 -( - key1 int not null, - key2 int not null, - - INDEX i1(key1), - INDEX i2(key2) -) engine=innodb; - ---disable_query_log -let $1=200; -while ($1) -{ - eval insert into t1 values (200-$1, $1); - dec $1; -} ---enable_query_log - -# No primary key -explain select * from t1 where key1 < 5 or key2 > 197; - -select * from t1 where key1 < 5 or key2 > 197; - -explain select * from t1 where key1 < 3 or key2 > 195; -select * from t1 where key1 < 3 or key2 > 195; - -# Primary key as case-sensitive string with \0s. -# also make primary key be longer then max. index length of MyISAM. -alter table t1 add str1 char (255) not null, - add zeroval int not null default 0, - add str2 char (255) not null, - add str3 char (255) not null; - -update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if(key1 mod 2 = 0, 'a', 'A')); - -alter table t1 add primary key (str1, zeroval, str2, str3); - -explain select * from t1 where key1 < 5 or key2 > 197; - -select * from t1 where key1 < 5 or key2 > 197; - -explain select * from t1 where key1 < 3 or key2 > 195; -select * from t1 where key1 < 3 or key2 > 195; - -# Test for BUG#5401 -drop table t1; -create table t1 ( - pk integer not null auto_increment primary key, - key1 integer, - key2 integer not null, - filler char (200), - index (key1), - index (key2) -) engine=innodb; -show warnings; ---disable_query_log -let $1=30; -while ($1) -{ - eval insert into t1 (key1, key2, filler) values ($1/4, $1/8, 'filler-data'); - dec $1; -} ---enable_query_log -explain select pk from t1 where key1 = 1 and key2 = 1; -select pk from t1 where key2 = 1 and key1 = 1; -select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1; - -# More tests for BUG#5401. -drop table t1; -create table t1 ( - pk int primary key auto_increment, - key1a int, - key2a int, - key1b int, - key2b int, - dummy1 int, - dummy2 int, - dummy3 int, - dummy4 int, - key3a int, - key3b int, - filler1 char (200), - index i1(key1a, key1b), - index i2(key2a, key2b), - index i3(key3a, key3b) -) engine=innodb; - -create table t2 (a int); -insert into t2 values (0),(1),(2),(3),(4),(NULL); - -insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) - select A.a, B.a, C.a, D.a, C.a, D.a from t2 A,t2 B,t2 C, t2 D; -insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) - select key1a, key1b, key2a, key2b, key3a, key3b from t1; -insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b) - select key1a, key1b, key2a, key2b, key3a, key3b from t1; -analyze table t1; -select count(*) from t1; - -explain select count(*) from t1 where - key1a = 2 and key1b is null and key2a = 2 and key2b is null; - -select count(*) from t1 where - key1a = 2 and key1b is null and key2a = 2 and key2b is null; - -explain select count(*) from t1 where - key1a = 2 and key1b is null and key3a = 2 and key3b is null; - -select count(*) from t1 where - key1a = 2 and key1b is null and key3a = 2 and key3b is null; - -drop table t1,t2; - -# Test for BUG#8441 -create table t1 ( - id1 int, - id2 date , - index idx2 (id1,id2), - index idx1 (id2) -) engine = innodb; -insert into t1 values(1,'20040101'), (2,'20040102'); -select * from t1 where id1 = 1 and id2= '20040101'; -drop table t1; - -# Test for BUG#12720 ---disable_warnings -drop view if exists v1; ---enable_warnings -CREATE TABLE t1 ( - `oid` int(11) unsigned NOT NULL auto_increment, - `fk_bbk_niederlassung` int(11) unsigned NOT NULL, - `fk_wochentag` int(11) unsigned NOT NULL, - `uhrzeit_von` time NOT NULL COMMENT 'HH:MM', - `uhrzeit_bis` time NOT NULL COMMENT 'HH:MM', - `geloescht` tinyint(4) NOT NULL, - `version` int(5) NOT NULL, - PRIMARY KEY (`oid`), - KEY `fk_bbk_niederlassung` (`fk_bbk_niederlassung`), - KEY `fk_wochentag` (`fk_wochentag`), - KEY `ix_version` (`version`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -insert into t1 values -(1, 38, 1, '08:00:00', '13:00:00', 0, 1), -(2, 38, 2, '08:00:00', '13:00:00', 0, 1), -(3, 38, 3, '08:00:00', '13:00:00', 0, 1), -(4, 38, 4, '08:00:00', '13:00:00', 0, 1), -(5, 38, 5, '08:00:00', '13:00:00', 0, 1), -(6, 38, 5, '08:00:00', '13:00:00', 1, 2), -(7, 38, 3, '08:00:00', '13:00:00', 1, 2), -(8, 38, 1, '08:00:00', '13:00:00', 1, 2), -(9, 38, 2, '08:00:00', '13:00:00', 1, 2), -(10, 38, 4, '08:00:00', '13:00:00', 1, 2), -(11, 38, 1, '08:00:00', '13:00:00', 0, 3), -(12, 38, 2, '08:00:00', '13:00:00', 0, 3), -(13, 38, 3, '08:00:00', '13:00:00', 0, 3), -(14, 38, 4, '08:00:00', '13:00:00', 0, 3), -(15, 38, 5, '08:00:00', '13:00:00', 0, 3), -(16, 38, 4, '08:00:00', '13:00:00', 0, 4), -(17, 38, 5, '08:00:00', '13:00:00', 0, 4), -(18, 38, 1, '08:00:00', '13:00:00', 0, 4), -(19, 38, 2, '08:00:00', '13:00:00', 0, 4), -(20, 38, 3, '08:00:00', '13:00:00', 0, 4), -(21, 7, 1, '08:00:00', '13:00:00', 0, 1), -(22, 7, 2, '08:00:00', '13:00:00', 0, 1), -(23, 7, 3, '08:00:00', '13:00:00', 0, 1), -(24, 7, 4, '08:00:00', '13:00:00', 0, 1), -(25, 7, 5, '08:00:00', '13:00:00', 0, 1); - -create view v1 as -select - zeit1.oid AS oid, - zeit1.fk_bbk_niederlassung AS fk_bbk_niederlassung, - zeit1.fk_wochentag AS fk_wochentag, - zeit1.uhrzeit_von AS uhrzeit_von, - zeit1.uhrzeit_bis AS uhrzeit_bis, - zeit1.geloescht AS geloescht, - zeit1.version AS version -from - t1 zeit1 -where -(zeit1.version = - (select max(zeit2.version) AS `max(version)` - from t1 zeit2 - where - ((zeit1.fk_bbk_niederlassung = zeit2.fk_bbk_niederlassung) and - (zeit1.fk_wochentag = zeit2.fk_wochentag) and - (zeit1.uhrzeit_von = zeit2.uhrzeit_von) and - (zeit1.uhrzeit_bis = zeit2.uhrzeit_bis) - ) - ) -) -and (zeit1.geloescht = 0); - -select * from v1 where oid = 21; -drop view v1; -drop table t1; -## -CREATE TABLE t1( - t_cpac varchar(2) NOT NULL, - t_vers varchar(4) NOT NULL, - t_rele varchar(2) NOT NULL, - t_cust varchar(4) NOT NULL, - filler1 char(250) default NULL, - filler2 char(250) default NULL, - PRIMARY KEY (t_cpac,t_vers,t_rele,t_cust), - UNIQUE KEY IX_4 (t_cust,t_cpac,t_vers,t_rele), - KEY IX_5 (t_vers,t_rele,t_cust) -) ENGINE=InnoDB; - -insert into t1 values -('tm','2.5 ','a ',' ','',''), ('tm','2.5U','a ','stnd','',''), -('da','3.3 ','b ',' ','',''), ('da','3.3U','b ','stnd','',''), -('tl','7.6 ','a ',' ','',''), ('tt','7.6 ','a ',' ','',''), -('bc','B61 ','a ',' ','',''), ('bp','B61 ','a ',' ','',''), -('ca','B61 ','a ',' ','',''), ('ci','B61 ','a ',' ','',''), -('cp','B61 ','a ',' ','',''), ('dm','B61 ','a ',' ','',''), -('ec','B61 ','a ',' ','',''), ('ed','B61 ','a ',' ','',''), -('fm','B61 ','a ',' ','',''), ('nt','B61 ','a ',' ','',''), -('qm','B61 ','a ',' ','',''), ('tc','B61 ','a ',' ','',''), -('td','B61 ','a ',' ','',''), ('tf','B61 ','a ',' ','',''), -('tg','B61 ','a ',' ','',''), ('ti','B61 ','a ',' ','',''), -('tp','B61 ','a ',' ','',''), ('ts','B61 ','a ',' ','',''), -('wh','B61 ','a ',' ','',''), ('bc','B61U','a ','stnd','',''), -('bp','B61U','a ','stnd','',''), ('ca','B61U','a ','stnd','',''), -('ci','B61U','a ','stnd','',''), ('cp','B61U','a ','stnd','',''), -('dm','B61U','a ','stnd','',''), ('ec','B61U','a ','stnd','',''), -('fm','B61U','a ','stnd','',''), ('nt','B61U','a ','stnd','',''), -('qm','B61U','a ','stnd','',''), ('tc','B61U','a ','stnd','',''), -('td','B61U','a ','stnd','',''), ('tf','B61U','a ','stnd','',''), -('tg','B61U','a ','stnd','',''), ('ti','B61U','a ','stnd','',''), -('tp','B61U','a ','stnd','',''), ('ts','B61U','a ','stnd','',''), -('wh','B61U','a ','stnd','',''); -show create table t1; - -select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6'; -select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6' - and t_rele='a' and t_cust = ' '; - -drop table t1; - -# BUG#19021: Crash in index_merge/ROR-intersection optimizer under -# specific circumstances. -create table t1 ( - pk int(11) not null auto_increment, - a int(11) not null default '0', - b int(11) not null default '0', - c int(11) not null default '0', - - filler1 datetime, filler2 varchar(15), - filler3 longtext, - - kp1 varchar(4), kp2 varchar(7), - kp3 varchar(2), kp4 varchar(4), - kp5 varchar(7), - filler4 char(1), - - primary key (pk), - key idx1(a,b,c), - key idx2(c), - key idx3(kp1,kp2,kp3,kp4,kp5) -) engine=innodb default charset=latin1; ---disable_query_log -set @fill= uncompress(unhex(concat( -'F91D0000789CDD993D6FDB301086F7FE0A6D4E0105B8E3F1335D5BA028DA0EEDE28E1D320408', -'52A0713BF4D7571FB62C51A475924839080307B603E77DEE787C8FA41F9E9EEF7F1F8A87A7C3', -'AFE280C5DF9F8F7FEE9F8B1B2CB114D6902E918455245DB91300FA16E42D5201FA4EE29DA05D', -'B9FB3718A33718A3FA8C30AEFAFDE1F317D016AA67BA7A60FDE45BF5F8BA7B5BDE8812AA9F1A', -'069DB03C9804346644F3A3A6A1338DB572756A3C4D1BCC804CABF912C654AE9BB855A2B85962', -'3A479259CAE6A86C0411D01AE5483581EDCBD9A39C45252D532E533979EB9F82E971D979BDB4', -'8531105670740AFBFD1E34AAB0029E4AD0A1D46A6D0946A21A16038A5CD965CD2D524673F712', -'20C304477315CE18405EAF9BD0AFFEAC74FDA14F1FBF5BD34C769D73FBBEDF4750ADD4E5A99C', -'5C8DC04934AFA275D483D536D174C11B12AF27F8F888B41B6FC9DBA569E1FD7BD72D698130B7', -'91B23A98803512B3D31881E8DCDA2AC1754E3644C4BB3A8466750B911681274A39E35E8624B7', -'444A42AC1213F354758E3CF1A4CDD5A688C767CF1B11ABC5867CB15D8A18E0B91E9EC275BB94', -'58F33C2936F64690D55BC29E4A293D95A798D84217736CEAAA538CE1354269EE2162053FBC66', -'496D90CB53323CB279D3A6AF651B4B22B9E430743D83BE48E995A09D4FC9871C22D8D189B945', -'706911BCB8C3C774B9C08D2FC6ED853ADACA37A14A4CB2E027630E5B80ECACD939431B1CDF62', -'7D71487536EA2C678F59685E91F4B6C144BCCB94C1EBA9FA6F5552DDCA4E4539BE326A2720CB', -'45ED028EB3616AC93C46E775FEA9FA6DA7CFCEC6DEBA5FCD1F915EED4D983BDDB881528AD9AB', -'43C1576F29AAB35BDFBC21D422F52B307D350589D45225A887AC46C8EDD72D99EC3ED2E1BCEF', -'7AF26FC4C74097B6768A5EDAFA660CC64278F7E63F99AC954B'))); -prepare x from @fill; -execute x; -deallocate prepare x; ---enable_query_log -set @fill=NULL; -SELECT COUNT(*) FROM t1 WHERE b = 0 AND a = 0 AND c = 13286427 AND - kp1='279' AND kp2='ELM0678' AND kp3='6' AND kp4='10' AND kp5 = 'R '; - -drop table t1; - +# Last update: +# 2006-08-07 ML test refactored (MySQL 5.1) +# Main code of several index_merge tests +# -> include/index_merge*.inc +# wrapper t/index_merge_innodb.test sources now several +# include/index_merge*.inc files +# +--source include/have_innodb.inc +let $engine_type= InnoDB; +# InnoDB does not support Merge tables (affects include/index_merge1.inc) +let $merge_table_support= 0; + +# The first two tests are disabled because of non deterministic explain output. +# If include/index_merge1.inc can be enabled for InnoDB and all other +# storage engines, please remove the subtest for Bug#21277 from +# include/index_merge2.inc. +# This test exists already in include/index_merge1.inc. +# --source include/index_merge1.inc +# --source include/index_merge_ror.inc + +--source include/index_merge2.inc +--source include/index_merge_2sweeps.inc +--source include/index_merge_ror_cpk.inc diff --git a/mysql-test/t/index_merge_innodb2.test b/mysql-test/t/index_merge_innodb2.test deleted file mode 100644 index ec4ea672bc1..00000000000 --- a/mysql-test/t/index_merge_innodb2.test +++ /dev/null @@ -1,52 +0,0 @@ -# -# 2-sweeps read Index_merge test -# --- source include/have_innodb.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=innodb; - - ---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; diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test new file mode 100644 index 00000000000..dccaecef20a --- /dev/null +++ b/mysql-test/t/index_merge_myisam.test @@ -0,0 +1,188 @@ +# t/index_merge_myisam.test +# +# Index merge tests +# +# Last update: +# 2006-08-07 ML test refactored (MySQL 5.1) +# Main code of several index_merge tests +# -> include/index_merge*.inc +# wrapper t/index_merge_innodb.test sources now several +# include/index_merge*.inc files +# + +let $engine_type= MyISAM; +# MyISAM supports Merge tables +let $merge_table_support= 1; + +--source include/index_merge1.inc +--source include/index_merge_ror.inc +--source include/index_merge2.inc +--source include/index_merge_2sweeps.inc +--source include/index_merge_ror_cpk.inc + +--echo # +--echo # Generic @@optimizer_switch tests (move those into a separate file if +--echo # we get another @@optimizer_switch user) +--echo # + +select @@optimizer_switch; + +set optimizer_switch='index_merge=off,index_merge_union=off'; +select @@optimizer_switch; + +set optimizer_switch='index_merge_union=on'; +select @@optimizer_switch; + +set optimizer_switch='default,index_merge_sort_union=off'; +select @@optimizer_switch; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch=4; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch=NULL; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='default,index_merge'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge=index_merge'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge=on,but...'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge='; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='on'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge=on,index_merge=off'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge_union=on,index_merge_union=default'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='default,index_merge=on,index_merge=off,default'; + +set optimizer_switch=default; +set optimizer_switch='index_merge=off,index_merge_union=off,default'; +select @@optimizer_switch; +set optimizer_switch=default; + +# Check setting defaults for global vars +select @@global.optimizer_switch; +set @@global.optimizer_switch=default; +select @@global.optimizer_switch; + +--echo # +--echo # Check index_merge's @@optimizer_switch flags +--echo # +select @@optimizer_switch; + +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, c int, filler char(100), + key(a), key(b), key(c)); +insert into t1 select + A.a * B.a*10 + C.a*100, + A.a * B.a*10 + C.a*100, + A.a, + 'filler' +from t0 A, t0 B, t0 C; + +--echo This should use union: +explain select * from t1 where a=1 or b=1; + +--echo This should use ALL: +set optimizer_switch='default,index_merge=off'; +explain select * from t1 where a=1 or b=1; + +--echo This should use sort-union: +set optimizer_switch='default,index_merge_union=off'; +explain select * from t1 where a=1 or b=1; + +--echo This will use sort-union: +set optimizer_switch=default; +explain select * from t1 where a<1 or b <1; + +--echo This should use ALL: +set optimizer_switch='default,index_merge_sort_union=off'; +explain select * from t1 where a<1 or b <1; + + +--echo This should use ALL: +set optimizer_switch='default,index_merge=off'; +explain select * from t1 where a<1 or b <1; + +--echo This will use sort-union: +set optimizer_switch='default,index_merge_union=off'; +explain select * from t1 where a<1 or b <1; + +alter table t1 add d int, add key(d); +update t1 set d=a; + +--echo This will use sort_union: +set optimizer_switch=default; +explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4); + +--echo And if we disable sort_union, union: +set optimizer_switch='default,index_merge_sort_union=off'; +explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4); + +drop table t1; + +# Now test that intersection can be disabled +create table t1 ( + a int, b int, c int, + filler1 char(200), filler2 char(200), + key(a),key(b),key(c) +); + +insert into t1 +select A.a+10*B.a, A.a+10*B.a, A.a+10*B.a+100*C.a, 'foo', 'bar' +from t0 A, t0 B, t0 C, t0 D where D.a<5; + +--echo This should be intersect: +set optimizer_switch=default; +explain select * from t1 where a=10 and b=10; + +--echo No intersect when index_merge is disabled: +set optimizer_switch='default,index_merge=off'; +explain select * from t1 where a=10 and b=10; + +--echo No intersect if it is disabled: +set optimizer_switch='default,index_merge_intersection=off'; +explain select * from t1 where a=10 and b=10; + +--echo Do intersect when union was disabled +set optimizer_switch='default,index_merge_union=off'; +explain select * from t1 where a=10 and b=10; + +--echo Do intersect when sort_union was disabled +set optimizer_switch='default,index_merge_sort_union=off'; +explain select * from t1 where a=10 and b=10; + +# Now take union-of-intersection and see how we can disable parts of it +--echo This will use intersection inside a union: +set optimizer_switch=default; +explain select * from t1 where a=10 and b=10 or c=10; + +--echo Should be only union left: +set optimizer_switch='default,index_merge_intersection=off'; +explain select * from t1 where a=10 and b=10 or c=10; + +--echo This will switch to sort-union (intersection will be gone, too, +--echo thats a known limitation: +set optimizer_switch='default,index_merge_union=off'; +explain select * from t1 where a=10 and b=10 or c=10; + +set optimizer_switch=default; +show variables like 'optimizer_switch'; + +drop table t0, t1; + diff --git a/mysql-test/t/index_merge_ror.test b/mysql-test/t/index_merge_ror.test deleted file mode 100644 index a9de2f955ee..00000000000 --- a/mysql-test/t/index_merge_ror.test +++ /dev/null @@ -1,267 +0,0 @@ -# -# ROR-index_merge tests. -# ---disable_warnings -drop table if exists t0,t1,t2; ---enable_warnings ---disable_query_log -create table t1 -( - /* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */ - st_a int not null default 0, - swt1a int not null default 0, - swt2a int not null default 0, - - st_b int not null default 0, - swt1b int not null default 0, - swt2b int not null default 0, - - /* fields/keys for row retrieval tests */ - key1 int, - key2 int, - key3 int, - key4 int, - - /* make rows much bigger then keys */ - filler1 char (200), - filler2 char (200), - filler3 char (200), - filler4 char (200), - filler5 char (200), - filler6 char (200), - - /* order of keys is important */ - key sta_swt12a(st_a,swt1a,swt2a), - key sta_swt1a(st_a,swt1a), - key sta_swt2a(st_a,swt2a), - key sta_swt21a(st_a,swt2a,swt1a), - - key st_a(st_a), - key stb_swt1a_2b(st_b,swt1b,swt2a), - key stb_swt1b(st_b,swt1b), - key st_b(st_b), - - key(key1), - key(key2), - key(key3), - key(key4) -) ; - -# Fill table -create table t0 as select * from t1; -let $cnt=1000; -while ($cnt) -{ - eval insert into t0 values (1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 'data1', 'data2', 'data3', 'data4', 'data5', 'data6'); - dec $cnt; -} - -alter table t1 disable keys; -let $1=4; -while ($1) -{ - let $2=4; - while ($2) - { - let $3=4; - while ($3) - { - eval insert into t1 select $1, $2, $3, $1 ,$2, $3, key1, key2, key3, key4, filler1, filler2, filler3, filler4, filler5, filler6 from t0; - dec $3; - } - dec $2; - } - dec $1; -} - -# Row retrieval tests -# -1 is used for values 'out of any range we are using' -# insert enough rows for index intersection to be used for (key1,key2) -insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 100, 100,'key1-key2-key3-key4'); -let $cnt=400; -while ($cnt) -{ - eval insert into t1 (key1, key2, key3, key4, filler1) values (100, -1, 100, -1,'key1-key3'); - dec $cnt; -} -let $cnt=400; -while ($cnt) -{ - eval insert into t1 (key1, key2, key3, key4, filler1) values (-1, 100, -1, 100,'key2-key4'); - dec $cnt; -} -alter table t1 enable keys; ---enable_query_log -select count(*) from t1; - -# One row results tests for cases where a single row matches all conditions -explain select key1,key2 from t1 where key1=100 and key2=100; -select key1,key2 from t1 where key1=100 and key2=100; - -explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; -select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; - -# Several-rows results -insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, -1, -1, 'key1-key2'); -insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 100, 100, 'key4-key3'); - -# ROR-intersection, not covering -explain select key1,key2,filler1 from t1 where key1=100 and key2=100; -select key1,key2,filler1 from t1 where key1=100 and key2=100; - -# ROR-intersection, covering -explain select key1,key2 from t1 where key1=100 and key2=100; -select key1,key2 from t1 where key1=100 and key2=100; - -# ROR-union of ROR-intersections -explain select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100; -select key1,key2,key3,key4 from t1 where key1=100 and key2=100 or key3=100 and key4=100; -explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; -select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; - -# 3-way ROR-intersection -explain select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100; -select key1,key2,key3 from t1 where key1=100 and key2=100 and key3=100; - -# ROR-union(ROR-intersection, ROR-range) -insert into t1 (key1,key2,key3,key4,filler1) values (101,101,101,101, 'key1234-101'); -explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101; -select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=101; - -# Run some ROR updates/deletes -select key1,key2, filler1 from t1 where key1=100 and key2=100; -update t1 set filler1='to be deleted' where key1=100 and key2=100; -update t1 set key1=200,key2=200 where key1=100 and key2=100; -delete from t1 where key1=200 and key2=200; -select key1,key2,filler1 from t1 where key2=100 and key2=200; - -# ROR-union(ROR-intersection) with one of ROR-intersection giving empty -# results -explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; -select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; - -delete from t1 where key3=100 and key4=100; - -# ROR-union with all ROR-intersections giving empty results -explain select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; -select key1,key2,key3,key4,filler1 from t1 where key1=100 and key2=100 or key3=100 and key4=100; - -# ROR-intersection with empty result -explain select key1,key2 from t1 where key1=100 and key2=100; -select key1,key2 from t1 where key1=100 and key2=100; - -# ROR-union tests with various cases. -# All scans returning duplicate rows: -insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-1'); -insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-2'); -insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 200, 200,'key1-key2-key3-key4-3'); - -explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; -select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; - -insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, -1, 200,'key4'); - -explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; -select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; - -insert into t1 (key1, key2, key3, key4, filler1) values (-1, -1, 200, -1,'key3'); - -explain select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; -select key1,key2,key3,key4,filler1 from t1 where key3=200 or (key1=100 and key2=100) or key4=200; - -## -## Optimizer tests -## - -# Check that the shortest key is used for ROR-intersection, covering and non-covering. -explain select * from t1 where st_a=1 and st_b=1; -explain select st_a,st_b from t1 where st_a=1 and st_b=1; - -# Check if "ingore index" syntax works -explain select st_a from t1 ignore index (st_a) where st_a=1 and st_b=1; - -# Do many tests -# Check that keys that don't improve selectivity are skipped. -# - -# Different value on 32 and 64 bit ---replace_result sta_swt12a sta_swt21a sta_swt12a, sta_swt12a, -explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1; - -explain select * from t1 where st_b=1 and swt1b=1 and swt2b=1; - -explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; - -explain select * from t1 ignore index (sta_swt21a, stb_swt1a_2b) - where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; - -explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b) - where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; - -explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b, stb_swt1b) - where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1; - -explain select * from t1 - where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1; - -explain select * from t1 - where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1; - -explain select st_a from t1 - where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1; - -explain select st_a from t1 - where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1; - -drop table t0,t1; - -# 'Partially' covered fields test - -create table t2 ( - a char(10), - b char(10), - filler1 char(255), - filler2 char(255), - key(a(5)), - key(b(5)) -); - ---disable_query_log -let $1=8; -while ($1) -{ - eval insert into t2 values (repeat(char($1+64), 8),repeat(char($1+64), 8),'filler1', 'filler2'); - dec $1; -} -insert into t2 select * from t2; -insert into t2 select * from t2; ---enable_query_log - -# The table row buffer is reused. Fill it with rows that don't match. -select count(a) from t2 where a='BBBBBBBB'; -select count(a) from t2 where b='BBBBBBBB'; - -# BUG#1: ---replace_result a a_or_b b a_or_b -explain select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA'; -select count(a) from t2 where a='AAAAAAAA' and b='AAAAAAAA'; -select count(a) from t2 ignore index(a,b) where a='AAAAAAAA' and b='AAAAAAAA'; - -insert into t2 values ('ab', 'ab', 'uh', 'oh'); -explain select a from t2 where a='ab'; -drop table t2; - -# -# BUG#25048 - ERROR 126 : Incorrect key file for table '.XXXX.MYI'; try to -# repair it -# -CREATE TABLE t1(c1 INT, c2 INT DEFAULT 0, c3 CHAR(255) DEFAULT '', -KEY(c1), KEY(c2), KEY(c3)); -INSERT INTO t1(c1) VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0), -(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0); -INSERT INTO t1 VALUES(0,0,0); -CREATE TABLE t2(c1 int); -INSERT INTO t2 VALUES(1); -DELETE t1 FROM t1,t2 WHERE t1.c1=0 AND t1.c2=0; -SELECT * FROM t1; -DROP TABLE t1,t2; diff --git a/mysql-test/t/index_merge_ror_cpk.test b/mysql-test/t/index_merge_ror_cpk.test deleted file mode 100644 index 94abf395d0a..00000000000 --- a/mysql-test/t/index_merge_ror_cpk.test +++ /dev/null @@ -1,111 +0,0 @@ -# -# Clustered PK ROR-index_merge tests -# --- source include/have_innodb.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -create table t1 -( - pk1 int not null, - pk2 int not null, - - key1 int not null, - key2 int not null, - - pktail1ok int not null, - pktail2ok int not null, - pktail3bad int not null, - pktail4bad int not null, - pktail5bad int not null, - - pk2copy int not null, - badkey int not null, - - filler1 char (200), - filler2 char (200), - key (key1), - key (key2), - - /* keys with tails from CPK members */ - key (pktail1ok, pk1), - key (pktail2ok, pk1, pk2), - key (pktail3bad, pk2, pk1), - key (pktail4bad, pk1, pk2copy), - key (pktail5bad, pk1, pk2, pk2copy), - - primary key (pk1, pk2) -) engine=innodb; - ---disable_query_log -set autocommit=0; -let $1=10000; -while ($1) -{ - eval insert into t1 values ($1 div 10,$1 mod 100, $1/100,$1/100, $1/100,$1/100,$1/100,$1/100,$1/100, $1 mod 100, $1/1000,'filler-data-$1','filler2'); - dec $1; -} -set autocommit=1; ---enable_query_log - -# Verify that range scan on CPK is ROR -# (use index_intersection because it is impossible to check that for index union) -explain select * from t1 where pk1 = 1 and pk2 < 80 and key1=0; -# CPK scan + 1 ROR range scan is a special case -select * from t1 where pk1 = 1 and pk2 < 80 and key1=0; - -# Verify that CPK fields are considered to be covered by index scans -explain select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1; -select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1; - -# Verify that CPK is always used for index intersection scans -# (this is because it is used as a filter, not for retrieval) -explain select * from t1 where badkey=1 and key1=10; ---replace_result 38 ROWS 37 ROWS -explain select * from t1 where pk1 < 7500 and key1 = 10; - -# Verify that keys with 'tails' of PK members are ok. -explain select * from t1 where pktail1ok=1 and key1=10; -explain select * from t1 where pktail2ok=1 and key1=10; - -select ' The following is actually a deficiency, it uses sort_union currently:' as 'note:'; -explain select * from t1 where (pktail2ok=1 and pk1< 50000) or key1=10; - -# The expected rows differs a bit from platform to platform ---replace_result 98 ROWS 99 ROWS -explain select * from t1 where pktail3bad=1 and key1=10; -explain select * from t1 where pktail4bad=1 and key1=10; -explain select * from t1 where pktail5bad=1 and key1=10; - -# Test for problem with innodb key values prefetch buffer: -explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10; -select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10; - -drop table t1; -# Testcase for BUG#4984 -create table t1 -( - RUNID varchar(22), - SUBMITNR varchar(5), - ORDERNR char(1) , - PROGRAMM varchar(8), - TESTID varchar(4), - UCCHECK char(1), - ETEXT varchar(80), - ETEXT_TYPE char(1), - INFO char(1), - SEVERITY tinyint(3), - TADIRFLAG char(1), - PRIMARY KEY (RUNID,SUBMITNR,ORDERNR,PROGRAMM,TESTID,UCCHECK), - KEY `TVERM~KEY` (PROGRAMM,TESTID,UCCHECK) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -update t1 set `ETEXT` = '', `ETEXT_TYPE`='', `INFO`='', `SEVERITY`='', `TADIRFLAG`='' -WHERE - `RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND - `TESTID`='' AND `UCCHECK`=''; - -drop table t1; - diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 63b69ce8384..392d1062492 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1,6 +1,14 @@ # This test uses grants, which can't get tested for embedded server -- source include/not_embedded.inc +# check that CSV engine was compiled in, as the result of the test depends +# on the presence of the log tables (which are CSV-based). +--source include/have_csv.inc + +# Save the initial number of concurrent sessions +--source include/count_sessions.inc + + # Test for information_schema.schemata & # show databases @@ -33,7 +41,11 @@ create table t3(a int, KEY a_data (a)); create table mysqltest.t4(a int); create table t5 (id int auto_increment primary key); insert into t5 values (10); -create view v1 (c) as select table_name from information_schema.TABLES; +create view v1 (c) as + SELECT table_name FROM information_schema.TABLES + WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND + table_name<>'ndb_binlog_index' AND + table_name<>'ndb_apply_status'; select * from v1; select c,table_name from v1 @@ -76,6 +88,8 @@ connect (user4,localhost,mysqltest_3,,mysqltest); connection user4; select table_name, column_name, privileges from information_schema.columns where table_schema = 'mysqltest' and table_name = 'v1'; +--error ER_VIEW_NO_EXPLAIN +explain select * from v1; connection default; disconnect user4; @@ -128,25 +142,25 @@ delimiter ;| # Bug#7222 information_schema: errors in "routines" # select parameter_style, sql_data_access, dtd_identifier -from information_schema.routines; +from information_schema.routines where routine_schema='test'; --replace_column 5 # 6 # -show procedure status; +show procedure status where db='test'; --replace_column 5 # 6 # -show function status; +show function status where db='test'; select a.ROUTINE_NAME from information_schema.ROUTINES a, information_schema.SCHEMATA b where -a.ROUTINE_SCHEMA = b.SCHEMA_NAME; +a.ROUTINE_SCHEMA = b.SCHEMA_NAME AND b.SCHEMA_NAME='test'; --replace_column 3 # explain select a.ROUTINE_NAME from information_schema.ROUTINES a, information_schema.SCHEMATA b where a.ROUTINE_SCHEMA = b.SCHEMA_NAME; select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a, -mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) order by 1; -select count(*) from information_schema.ROUTINES; +mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) AND a.ROUTINE_SCHEMA='test' order by 1; +select count(*) from information_schema.ROUTINES where routine_schema='test'; -create view v1 as select routine_schema, routine_name from information_schema.routines +create view v1 as select routine_schema, routine_name from information_schema.routines where routine_schema='test' order by routine_schema, routine_name; select * from v1; drop view v1; @@ -444,7 +458,7 @@ drop table t1, t2; # # Bug#7476 crash on SELECT * FROM INFORMATION_SCHEMA.TABLES # - +use test; CREATE TABLE t_crashme ( f1 BIGINT); CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1; CREATE VIEW a2 AS SELECT t_CRASHME FROM a1; @@ -458,7 +472,7 @@ while ($tab_count) --disable_result_log SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES; --enable_result_log -SELECT count(*) FROM INFORMATION_SCHEMA.TABLES; +SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'; let $tab_count= 65; while ($tab_count) { @@ -525,7 +539,7 @@ flush privileges; # Bug#9404 information_schema: Weird error messages # with SELECT SUM() ... GROUP BY queries # -SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA; +SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA; # @@ -554,7 +568,7 @@ begin end| delimiter ;| show triggers; -select * from information_schema.triggers; +select * from information_schema.triggers where trigger_schema in ('mysql', 'information_schema', 'test', 'mysqltest'); drop trigger trg1; drop trigger trg2; @@ -729,7 +743,7 @@ BEGIN SELECT 'foo' FROM DUAL; END | delimiter ;| -select ROUTINE_NAME from routines; +select ROUTINE_NAME from routines where ROUTINE_SCHEMA='information_schema'; # # Bug#10734 Grant of privileges other than 'select' and 'create view' should fail on schema # @@ -809,7 +823,8 @@ DROP FUNCTION func2; select column_type, group_concat(table_schema, '.', table_name), count(*) as num from information_schema.columns where table_schema='information_schema' and -(column_type = 'varchar(7)' or column_type = 'varchar(20)') +(column_type = 'varchar(7)' or column_type = 'varchar(20)' + or column_type = 'varchar(27)') group by column_type order by num; # @@ -827,8 +842,8 @@ drop table t1; use mysql; INSERT INTO `proc` VALUES ('test','','PROCEDURE','','SQL','CONTAINS_SQL', 'NO','DEFINER','','','BEGIN\r\n \r\nEND','root@%','2006-03-02 18:40:03', -'2006-03-02 18:40:03','',''); -select routine_name from information_schema.routines; +'2006-03-02 18:40:03','','','utf8','utf8_general_ci','utf8_general_ci','n/a'); +select routine_name from information_schema.routines where ROUTINE_SCHEMA='test'; delete from proc where name=''; use test; @@ -877,13 +892,13 @@ CREATE USER mysql_bug20230@localhost; GRANT EXECUTE ON PROCEDURE p1 TO mysql_bug20230@localhost; GRANT EXECUTE ON FUNCTION f1 TO mysql_bug20230@localhost; -SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES; +SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test'; SHOW CREATE PROCEDURE p1; SHOW CREATE FUNCTION f1; connect (conn1, localhost, mysql_bug20230,,); -SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES; +SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test'; SHOW CREATE PROCEDURE p1; SHOW CREATE FUNCTION f1; CALL p1(); @@ -934,11 +949,10 @@ SELECT t.table_name, c1.column_name # INFORMARTION_SCHEMA.TABLES # -SELECT MAX(table_name) FROM information_schema.tables; +SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test'); SELECT table_name from information_schema.tables WHERE table_name=(SELECT MAX(table_name) - FROM information_schema.tables); - + FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test')); # # Bug#23037 Bug in field "Default" of query "SHOW COLUMNS FROM table" # @@ -958,7 +972,7 @@ BEGIN DECLARE col1, col2, col3, col4, col6 CHAR(255); DECLARE default_val VARCHAR(65532); DECLARE done INT DEFAULT 0; - DECLARE cur1 CURSOR FOR SHOW COLUMNS FROM bug23037; + DECLARE cur1 CURSOR FOR SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY, COLUMN_DEFAULT, EXTRA FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='bug23037'; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; OPEN cur1; FETCH cur1 INTO col1, col2, col3, col4, default_val, col6; @@ -1029,7 +1043,6 @@ where t.table_schema = 'information_schema' and group by c2.column_type order by num limit 1) group by t.table_name order by num1, t.table_name; - # # Bug#28266 IS_UPDATABLE field on VIEWS table in I_S database is wrong # @@ -1097,26 +1110,6 @@ show columns from t1; drop table t1; # -# Bug#31633 Information schema = NULL queries crash the server -# -select * from information_schema.columns where table_schema = NULL; -select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL; -select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL; -select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL; -select * from information_schema.schemata where schema_name = NULL; -select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL; -select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL; -select * from information_schema.tables where table_schema = NULL; -select * from information_schema.tables where table_catalog = NULL; -select * from information_schema.tables where table_name = NULL; -select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL; -select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL; -select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_SCHEMA` = NULL; -select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL; -select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL; -select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL; - -# # Bug#30079 A check for "hidden" I_S tables is flawed # --error ER_UNKNOWN_TABLE @@ -1149,3 +1142,285 @@ USE test; --echo End of 5.0 tests. +# +# Show engines +# + +select * from information_schema.engines WHERE ENGINE="MyISAM"; + +# +# INFORMATION_SCHEMA.PROCESSLIST +# + +grant select on *.* to user3148@localhost; +connect (con3148,localhost,user3148,,test); +connection con3148; +select user,db from information_schema.processlist; +connection default; +disconnect con3148; +drop user user3148@localhost; + +# +# Bug#26174 Server Crash: INSERT ... SELECT ... FROM I_S.GLOBAL_STATUS +# in Event (see also openssl_1.test) +# +--disable_warnings +DROP TABLE IF EXISTS server_status; +DROP EVENT IF EXISTS event_status; +--enable_warnings + +SET GLOBAL event_scheduler=1; + +DELIMITER $$; + +CREATE EVENT event_status + ON SCHEDULE AT NOW() + ON COMPLETION NOT PRESERVE + DO +BEGIN + CREATE TABLE server_status + SELECT variable_name + FROM information_schema.global_status + WHERE variable_name LIKE 'ABORTED_CONNECTS' OR + variable_name LIKE 'BINLOG_CACHE_DISK_USE'; +END$$ + +DELIMITER ;$$ + +let $wait_timeout= 300; +let $wait_condition=select count(*) = 0 from information_schema.events where event_name='event_status'; +--source include/wait_condition.inc + +SELECT variable_name FROM server_status; + +DROP TABLE server_status; +SET GLOBAL event_scheduler=0; + + +# +# WL#3732 Information schema optimization +# + +explain select table_name from information_schema.views where +table_schema='test' and table_name='v1'; + +explain select * from information_schema.tables; +explain select * from information_schema.collations; + +explain select * from information_schema.tables where +table_schema='test' and table_name= 't1'; +explain select table_name, table_type from information_schema.tables +where table_schema='test'; + +explain select b.table_name +from information_schema.tables a, information_schema.columns b +where a.table_name='t1' and a.table_schema='test' and b.table_name=a.table_name; + +# +# Bug#30310 wrong result on SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE .. +# +SELECT * FROM INFORMATION_SCHEMA.SCHEMATA +WHERE SCHEMA_NAME = 'mysqltest'; + +SELECT * FROM INFORMATION_SCHEMA.SCHEMATA +WHERE SCHEMA_NAME = ''; + +SELECT * FROM INFORMATION_SCHEMA.SCHEMATA +WHERE SCHEMA_NAME = 'test'; + +select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TABLE_NAME='nonexisting'; +select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TABLE_NAME=''; +select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME=''; +select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME='nonexisting'; + +# +# Bug#30689 Wrong content in I_S.VIEWS.VIEW_DEFINITION if VIEW is based on I_S +# +CREATE VIEW v1 +AS SELECT * +FROM information_schema.tables; +SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1'; +DROP VIEW v1; + +# +# Bug#30795 Query on INFORMATION_SCHEMA.SCHEMATA, wrong result +# +SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA +WHERE SCHEMA_NAME ='information_schema'; + +# +# Bug#31381 Error in retrieving Data from INFORMATION_SCHEMA +# +SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES +WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db'; + +# +# Bug#31633 Information schema = NULL queries crash the server +# +select * from information_schema.columns where table_schema = NULL; +select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL; +select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL; +select * from `information_schema`.`PARTITIONS` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`PARTITIONS` where `TABLE_NAME` = NULL; +select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL; +select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL; +select * from information_schema.schemata where schema_name = NULL; +select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL; +select * from information_schema.tables where table_schema = NULL; +select * from information_schema.tables where table_catalog = NULL; +select * from information_schema.tables where table_name = NULL; +select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL; +select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_SCHEMA` = NULL; +select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL; +select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL; + +# +# Bug#31630 debug assert with explain extended select ... from i_s +# +explain extended select 1 from information_schema.tables; + +# +# Bug#32775 problems with SHOW EVENTS and Information_Schema +# +use information_schema; +show events; +show events from information_schema; +show events where Db= 'information_schema'; +use test; + +--echo # +--echo # Bug#34166 Server crash in SHOW OPEN TABLES and prelocking +--echo # +--disable_warnings +drop table if exists t1; +drop function if exists f1; +--enable_warnings +create table t1 (a int); +delimiter |; +create function f1() returns int +begin + insert into t1 (a) values (1); + return 0; +end| +delimiter ;| +--disable_result_log +show open tables where f1()=0; +show open tables where f1()=0; +--enable_result_log +drop table t1; +drop function f1; + +# +# Bug#34656 KILL a query = Assertion failed: m_status == DA_ERROR || +# m_status == DA_OK +# +connect (conn1, localhost, root,,); +connection conn1; +let $ID= `select connection_id()`; +send select * from information_schema.tables where 1=sleep(100000); +connection default; +let $wait_timeout= 10; +let $wait_condition=select count(*)=1 from information_schema.processlist +where state='User sleep' and +info='select * from information_schema.tables where 1=sleep(100000)'; +--source include/wait_condition.inc +disable_query_log; +eval kill $ID; +enable_query_log; +disconnect conn1; +let $wait_timeout= 10; +let $wait_condition=select count(*)=0 from information_schema.processlist +where state='User sleep' and +info='select * from information_schema.tables where 1=sleep(100000)'; +--source include/wait_condition.inc + +connect (conn1, localhost, root,,); +connection conn1; +let $ID= `select connection_id()`; +send select * from information_schema.columns where 1=sleep(100000); +connection default; +let $wait_timeout= 10; +let $wait_condition=select count(*)=1 from information_schema.processlist +where state='User sleep' and +info='select * from information_schema.columns where 1=sleep(100000)'; +--source include/wait_condition.inc +disable_query_log; +eval kill $ID; +enable_query_log; +disconnect conn1; +let $wait_timeout= 10; +let $wait_condition=select count(*)=0 from information_schema.processlist +where state='User sleep' and +info='select * from information_schema.columns where 1=sleep(100000)'; +--source include/wait_condition.inc + + +# +# Bug#38918 selecting from information_schema.columns is disproportionately slow +# +explain select count(*) from information_schema.tables; +explain select count(*) from information_schema.columns; +explain select count(*) from information_schema.views; + +# +# Bug#39955 SELECT on INFORMATION_SCHEMA.GLOBAL_VARIABLES takes too long +# +set global init_connect="drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;\ +drop table if exists t1;drop table if exists t1;"; +select * from information_schema.global_variables where variable_name='init_connect'; +set global init_connect=""; + +# +# Bug#34517 SHOW GLOBAL STATUS does not work properly in embedded server. +# + +create table t0 select * from information_schema.global_status where VARIABLE_NAME='COM_SELECT'; +SELECT 1; +select a.VARIABLE_VALUE - b.VARIABLE_VALUE from t0 b, information_schema.global_status a + where a.VARIABLE_NAME = b.VARIABLE_NAME; +drop table t0; + +# +# Bug#35275 INFORMATION_SCHEMA.TABLES.CREATE_OPTIONS omits KEY_BLOCK_SIZE +# +CREATE TABLE t1(a INT) KEY_BLOCK_SIZE=1; +SELECT CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1'; +DROP TABLE t1; + +# +# Bug #22047: Time in SHOW PROCESSLIST for SQL thread in replication seems +# to become negative +# + +SET TIMESTAMP=@@TIMESTAMP + 10000000; +SELECT 'OK' AS TEST_RESULT FROM INFORMATION_SCHEMA.PROCESSLIST WHERE time < 0; +SET TIMESTAMP=DEFAULT; + +--echo End of 5.1 tests. + +# Wait till all disconnects are completed +--source include/wait_until_count_sessions.inc + diff --git a/mysql-test/t/information_schema_chmod.test b/mysql-test/t/information_schema_chmod.test index 51e67a0c956..39e2f680bb8 100644 --- a/mysql-test/t/information_schema_chmod.test +++ b/mysql-test/t/information_schema_chmod.test @@ -17,7 +17,8 @@ # create database mysqltest; create table mysqltest.t1(a int); -chmod 0000 $MYSQLTEST_VARDIR/master-data/mysqltest; +let $MYSQLD_DATADIR= `select @@datadir`; +chmod 0000 $MYSQLD_DATADIR/mysqltest; select table_schema from information_schema.tables where table_schema='mysqltest'; -chmod 0777 $MYSQLTEST_VARDIR/master-data/mysqltest; +chmod 0777 $MYSQLD_DATADIR/mysqltest; drop database mysqltest; diff --git a/mysql-test/t/information_schema_db.test b/mysql-test/t/information_schema_db.test index 0ff1d05f364..2f651057e5c 100644 --- a/mysql-test/t/information_schema_db.test +++ b/mysql-test/t/information_schema_db.test @@ -184,7 +184,6 @@ show fields from testdb_1.v7; --error ER_TABLEACCESS_DENIED_ERROR show create view testdb_1.v7; ---error ER_VIEW_NO_EXPLAIN show create view v4; #--error ER_VIEW_NO_EXPLAIN show fields from v4; diff --git a/mysql-test/t/information_schema_inno.test b/mysql-test/t/information_schema_inno.test index 9cd64a54ad9..1a537d740b7 100644 --- a/mysql-test/t/information_schema_inno.test +++ b/mysql-test/t/information_schema_inno.test @@ -1,3 +1,4 @@ +-- source include/testdb_only.inc -- source include/have_innodb.inc --disable_warnings DROP TABLE IF EXISTS t1,t2,t3; @@ -21,3 +22,70 @@ select * from information_schema.KEY_COLUMN_USAGE where TABLE_SCHEMA= "test"; drop table t3, t2, t1; + +# +# Test for REFERENTIAL_CONSTRAINTS table +# +CREATE TABLE t1(a1 INT NOT NULL, a2 INT NOT NULL, + PRIMARY KEY(a1, a2)) ENGINE=INNODB; +CREATE TABLE t2(b1 INT, b2 INT, INDEX (b1, b2), + CONSTRAINT A1 + FOREIGN KEY (b1, b2) REFERENCES t1(a1, a2) + ON UPDATE CASCADE ON DELETE NO ACTION) ENGINE=INNODB; +CREATE TABLE t3(b1 INT, b2 INT, INDEX t3_indx (b1, b2), + CONSTRAINT A2 + FOREIGN KEY (b1, b2) REFERENCES t2(b1, b2) + ON UPDATE SET NULL ON DELETE RESTRICT) ENGINE=INNODB; +CREATE TABLE t4(b1 INT, b2 INT, UNIQUE KEY t4_ukey (b1, b2), + CONSTRAINT A3 + FOREIGN KEY (b1, b2) REFERENCES t3(b1, b2) + ON UPDATE NO ACTION ON DELETE SET NULL) ENGINE=INNODB; +CREATE TABLE t5(b1 INT, b2 INT, INDEX (b1, b2), + CONSTRAINT A4 + FOREIGN KEY (b1, b2) REFERENCES t4(b1, b2) + ON UPDATE RESTRICT ON DELETE CASCADE) ENGINE=INNODB; + +select a.CONSTRAINT_SCHEMA, b.TABLE_NAME, CONSTRAINT_TYPE, + b.CONSTRAINT_NAME, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME, + MATCH_OPTION, UPDATE_RULE, DELETE_RULE, b.REFERENCED_TABLE_NAME +from information_schema.TABLE_CONSTRAINTS a, + information_schema.REFERENTIAL_CONSTRAINTS b +where a.CONSTRAINT_SCHEMA = 'test' and a.CONSTRAINT_SCHEMA = b.CONSTRAINT_SCHEMA and +a.CONSTRAINT_NAME = b.CONSTRAINT_NAME; +drop tables t5, t4, t3, t2, t1; + +# +# Bug#25026 `information_schema.KEY_COLUMN_USAGE`.`REFERENCED_TABLE_NAME` returns garbage +# +create database `db-1`; +use `db-1`; +create table `t-2` ( + id int(10) unsigned not null auto_increment, + primary key (id) +) engine=innodb; + +create table `t-1` ( + id int(10) unsigned not null auto_increment, + idtype int(10) unsigned not null, + primary key (id), + key fk_t1_1 (idtype), + constraint fk_t1_1 foreign key (idtype) references `t-2` (id) +) engine=innodb; +use test; +select referenced_table_schema, referenced_table_name +from information_schema.key_column_usage +where constraint_schema = 'db-1'; +drop database `db-1`; + +# +# Bug#35108 SELECT FROM REFERENTIAL_CONSTRAINTS crashes +# +create table t1(id int primary key) engine = Innodb; +create table t2(pid int, foreign key (pid) references t1(id)) engine = Innodb; +set foreign_key_checks = 0; +drop table t1; +select UNIQUE_CONSTRAINT_NAME +from information_schema.referential_constraints +where constraint_schema = schema(); +drop table t2; +set foreign_key_checks = 1; diff --git a/mysql-test/t/information_schema_part.test b/mysql-test/t/information_schema_part.test new file mode 100644 index 00000000000..f1415d12f79 --- /dev/null +++ b/mysql-test/t/information_schema_part.test @@ -0,0 +1,133 @@ + +-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1,t2,t3,t4; +--enable_warnings + +create table t1 (a int not null,b int not null,c int not null, primary key(a,b)) +partition by list (b*a) +(partition x1 values in (1) tablespace ts1, + partition x2 values in (3, 11, 5, 7) tablespace ts2, + partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3); + +--replace_column 16 # 19 # 20 # +select * from information_schema.partitions where table_schema="test" +and table_name="t1"; + +create table t2 (a int not null,b int not null,c int not null, primary key(a,b)) +partition by range (a) +partitions 3 +(partition x1 values less than (5) tablespace ts1, + partition x2 values less than (10) tablespace ts2, + partition x3 values less than maxvalue tablespace ts3); +--replace_column 16 # 19 # 20 # +select * from information_schema.partitions where table_schema="test" +and table_name="t2"; + +create table t3 (f1 date) +partition by hash(month(f1)) +partitions 3; +--replace_column 16 # 19 # 20 # +select * from information_schema.partitions where table_schema="test" +and table_name="t3"; + +create table t4 (f1 date, f2 int) +partition by key(f1,f2) +partitions 3; +--replace_column 16 # 19 # 20 # +select * from information_schema.partitions where table_schema="test" +and table_name="t4"; + +drop table t1,t2,t3,t4; + +create table t1 (a int not null,b int not null,c int not null,primary key (a,b)) +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 tablespace t1, + subpartition x12 tablespace t2), + partition x2 values less than (5) + ( subpartition x21 tablespace t1, + subpartition x22 tablespace t2) +); + +create table t2 (a int not null,b int not null,c int not null,primary key (a,b)) +partition by range (a) +subpartition by key (a) +( partition x1 values less than (1) + ( subpartition x11 tablespace t1, + subpartition x12 tablespace t2), + partition x2 values less than (5) + ( subpartition x21 tablespace t1, + subpartition x22 tablespace t2) +); +--replace_column 16 # 19 # 20 # +select * from information_schema.partitions where table_schema="test"; +drop table t1,t2; + +create table t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 tablespace t1 nodegroup 0, + subpartition x12 tablespace t2 nodegroup 1), + partition x2 values less than (5) +( subpartition x21 tablespace t1 nodegroup 0, + subpartition x22 tablespace t2 nodegroup 1) +); + +--replace_column 16 # 19 # 20 # +select * from information_schema.partitions where table_schema="test"; +show tables; +drop table t1; + +create table t1(f1 int, f2 int); +--replace_column 16 # 19 # 20 # +select * from information_schema.partitions where table_schema="test"; +drop table t1; + +create table t1 (f1 date) +partition by linear hash(month(f1)) +partitions 3; +--replace_column 16 # 19 # 20 # +select * from information_schema.partitions where table_schema="test" +and table_name="t1"; +drop table t1; + +# +# Bug 20161 Partitions: SUBPARTITION METHOD doesn't show LINEAR keyword +# +create table t1 (a int) +PARTITION BY RANGE (a) +SUBPARTITION BY LINEAR HASH (a) +(PARTITION p0 VALUES LESS THAN (10)); + +SHOW CREATE TABLE t1; +select SUBPARTITION_METHOD FROM information_schema.partitions WHERE +table_schema="test" AND table_name="t1"; +drop table t1; + +create table t1 (a int) +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN +(10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, + 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53)); +SHOW CREATE TABLE t1; +SELECT PARTITION_DESCRIPTION FROM information_schema.partitions WHERE +table_schema = "test" AND table_name = "t1"; +drop table t1; + +# +# Bug#38909 CREATE_OPTIONS in information_schema produces wrong results +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (f1 int key) partition by key(f1) partitions 2; +select create_options from information_schema.tables where table_schema="test"; +drop table t1; diff --git a/mysql-test/t/init_file.test b/mysql-test/t/init_file.test index 7c580afadda..7eb5381651d 100644 --- a/mysql-test/t/init_file.test +++ b/mysql-test/t/init_file.test @@ -13,6 +13,7 @@ INSERT INTO init_file.startup VALUES ( NOW() ); SELECT * INTO @X FROM init_file.startup limit 0,1; SELECT * INTO @Y FROM init_file.startup limit 1,1; SELECT YEAR(@X)-YEAR(@Y); +# Enable this DROP DATABASE only after resolving bug #42507 DROP DATABASE init_file; --echo ok @@ -26,4 +27,10 @@ select * from t1; # Expected: # 30, 3, 11, 13 select * from t2; +# Enable this DROP TABLE only after resolving bug #42507 drop table t1, t2; + +# MTR will restart server anyway, but by forcing it we avoid being warned +# about the apparent side effect + +call mtr.force_restart(); diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test new file mode 100644 index 00000000000..61c42f45733 --- /dev/null +++ b/mysql-test/t/innodb-autoinc.test @@ -0,0 +1,500 @@ +-- source include/have_innodb.inc +# embedded server ignores 'delayed', so skip this +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Bug #34335 +# +CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (9223372036854775807, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; +# +## Test AUTOINC overflow +## + +# TINYINT +CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (127, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (255, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; +# +# SMALLINT +# +CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (32767, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (65535, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; +# +# MEDIUMINT +# +CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (8388607, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (16777215, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; +# +# INT +# +CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (2147483647, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (4294967295, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; +# +# BIGINT +# +CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (9223372036854775807, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (18446744073709551615, null); +-- error ER_AUTOINC_READ_FAILED,1467 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; + +# +# Bug 37531 +# After truncate, auto_increment behaves incorrectly for InnoDB +# +CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +SELECT c1 FROM t1; +SHOW CREATE TABLE t1; +TRUNCATE TABLE t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +SELECT c1 FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# +# Deleting all records should not reset the AUTOINC counter. +# +CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +SELECT c1 FROM t1; +SHOW CREATE TABLE t1; +DELETE FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t1 VALUES (NULL), (NULL), (NULL); +SELECT c1 FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# +# Bug 38839 +# Reset the last value generated at end of statement +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL, 1); +DELETE FROM t1 WHERE c1 = 1; +INSERT INTO t1 VALUES (2,1); +INSERT INTO t1 VALUES (NULL,8); +SELECT * FROM t1; +DROP TABLE t1; +# Bug 38839 -- same as above but for multi value insert +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL, 1); +DELETE FROM t1 WHERE c1 = 1; +INSERT INTO t1 VALUES (2,1), (NULL, 8); +INSERT INTO t1 VALUES (NULL,9); +SELECT * FROM t1; +DROP TABLE t1; + +# +# Test changes to AUTOINC next value calculation +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL),(5),(NULL); +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +INSERT INTO t1 VALUES(NULL),(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# Test with SIGNED INT column, by inserting a 0 for the first column value +# 0 is treated in the same was NULL. +# Reset the AUTOINC session variables +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(0); +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +INSERT INTO t1 VALUES (-1), (NULL),(2),(NULL); +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +SET @@INSERT_ID=400; +# Duplicate error expected here for autoinc_lock_mode != TRADITIONAL +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 VALUES(NULL),(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# Test with SIGNED INT column +# Reset the AUTOINC session variables +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(-1); +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +INSERT INTO t1 VALUES (-2), (NULL),(2),(NULL); +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +INSERT INTO t1 VALUES(NULL),(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# Test with UNSIGNED INT column, single insert +# The sign in the value is ignored and a new column value is generated +# Reset the AUTOINC session variables +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(-1); +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +INSERT INTO t1 VALUES (-2); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (250); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1; +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# Test with UNSIGNED INT column, multi-value inserts +# The sign in the value is ignored and a new column value is generated +# Reset the AUTOINC session variables +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(-1); +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +INSERT INTO t1 VALUES (-2),(NULL),(2),(NULL); +INSERT INTO t1 VALUES (250),(NULL); +SELECT * FROM t1; +INSERT INTO t1 VALUES (1000); +SET @@INSERT_ID=400; +# Duplicate error expected here for autoinc_lock_mode != TRADITIONAL +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 VALUES(NULL),(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# +# Check for overflow handling when increment is > 1 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +# TODO: Fix the autoinc init code +# We have to do this because of a bug in the AUTOINC init code. +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (9223372036854775794); #-- 2^63 - 14 +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +# This should just fit +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +SELECT * FROM t1; +DROP TABLE t1; + +# +# Check for overflow handling when increment and offser are > 1 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +# TODO: Fix the autoinc init code +# We have to do this because of a bug in the AUTOINC init code. +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13 +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10; +SHOW VARIABLES LIKE "%auto_inc%"; +# This should fail because of overflow but it doesn't, it seems to be +# a MySQL server bug. It wraps around to 0 for the last value. +# See MySQL Bug# 39828 +# +# Instead of wrapping around, it asserts when MySQL is compiled --with-debug +# (see sql/handler.cc:handler::update_auto_increment()). Don't test for +# overflow until Bug #39828 is fixed. +# +# Since this asserts when compiled --with-debug, we can't properly test this +# until Bug #39828 is fixed. For now, this test is meaningless. +#if Bug #39828 is fixed +#INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +#else +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +#endif +SELECT * FROM t1; +DROP TABLE t1; + +# +# Check for overflow handling when increment and offset are odd numbers +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +# TODO: Fix the autoinc init code +# We have to do this because of a bug in the AUTOINC init code. +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13 +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=5, @@SESSION.AUTO_INCREMENT_OFFSET=7; +SHOW VARIABLES LIKE "%auto_inc%"; +# This should fail because of overflow but it doesn't. It fails with +# a duplicate entry message because of a MySQL server bug, it wraps +# around. See MySQL Bug# 39828, once MySQL fix the bug we can replace +# the ER_DUP_ENTRY, 1062 below with the appropriate error message +# +# Since this asserts when compiled --with-debug, we can't properly test this +# until Bug #39828 is fixed. For now, this test is meaningless. +#if Bug #39828 is fixed +# Still need to fix this error code, error should mention overflow +#-- error ER_DUP_ENTRY,1062 +#INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +#else +INSERT INTO t1 VALUES (NULL),(NULL); +#endif +SELECT * FROM t1; +DROP TABLE t1; + +# Check for overflow handling when increment and offset are odd numbers +# and check for large -ve numbers +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +# TODO: Fix the autoinc init code +# We have to do this because of a bug in the AUTOINC init code. +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES(-9223372036854775806); #-- -2^63 + 2 +INSERT INTO t1 VALUES(-9223372036854775807); #-- -2^63 + 1 +INSERT INTO t1 VALUES(-9223372036854775808); #-- -2^63 +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=3, @@SESSION.AUTO_INCREMENT_OFFSET=3; +SHOW VARIABLES LIKE "%auto_inc%"; +INSERT INTO t1 VALUES (NULL),(NULL), (NULL); +SELECT * FROM t1; +DROP TABLE t1; +# +# Check for overflow handling when increment and offset are very +# large numbers 2^60 +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB; +# TODO: Fix the autoinc init code +# We have to do this because of a bug in the AUTOINC init code. +INSERT INTO t1 VALUES(NULL); +INSERT INTO t1 VALUES (18446744073709551610); #-- 2^64 - 2 +SELECT * FROM t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976; +SHOW VARIABLES LIKE "%auto_inc%"; +# This should fail because of overflow but it doesn't. It wraps around +# and the autoinc values look bogus too. +# See MySQL Bug# 39828, once MySQL fix the bug we can enable the error +# code expected test. +# -- error ER_AUTOINC_READ_FAILED,1467 +# +# Since this asserts when compiled --with-debug, we can't properly test this +# until Bug #39828 is fixed. For now, this test is meaningless. +#if Bug #39828 is fixed +#-- error ER_AUTOINC_READ_FAILED,1467 +#INSERT INTO t1 VALUES (NULL),(NULL); +#else +INSERT INTO t1 VALUES (NULL); +#endif +SELECT * FROM t1; +DROP TABLE t1; + +# +# Check for floating point autoinc column handling +# +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL, 1); +INSERT INTO t1 VALUES(NULL, 2); +SELECT * FROM t1; +ALTER TABLE t1 CHANGE c1 c1 SERIAL; +SELECT * FROM t1; +INSERT INTO t1 VALUES(NULL, 3); +INSERT INTO t1 VALUES(NULL, 4); +SELECT * FROM t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL, 1); +INSERT INTO t1 VALUES(NULL, 2); +SELECT * FROM t1; +ALTER TABLE t1 CHANGE c1 c1 SERIAL; +SELECT * FROM t1; +INSERT INTO t1 VALUES(NULL, 3); +INSERT INTO t1 VALUES(NULL, 4); +SELECT * FROM t1; +DROP TABLE t1; + +# +# Bug# 42714: AUTOINC column calculated next value not greater than highest +# value stored in table. +# +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5; +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( + a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + b INT(10) UNSIGNED NOT NULL, + c ENUM('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (a)) ENGINE = InnoDB; +CREATE TABLE t2 ( + m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + n INT(10) UNSIGNED NOT NULL, + o enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (m)) ENGINE = InnoDB; +INSERT INTO t2 (n,o) VALUES + (1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'), + (3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false'); +SHOW CREATE TABLE t2; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; +DROP TABLE t2; +# +# 43203: Overflow from auto incrementing causes server segv +# + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1( + c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT + PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +CREATE TABLE t2( + c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT + PRIMARY KEY) ENGINE=InnoDB; +-- error ER_DUP_ENTRY,1062 +INSERT INTO t2 SELECT c1 FROM t1; +-- error ER_DUP_ENTRY,1467 +INSERT INTO t2 SELECT NULL FROM t1; +DROP TABLE t1; +DROP TABLE t2; +# +# 44030: Error: (1500) Couldn't read the MAX(ID) autoinc value from +# the index (PRIMARY) +# This test requires a restart of the server +CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (null); +INSERT INTO t1 VALUES (null); +ALTER TABLE t1 CHANGE c1 d1 INT NOT NULL AUTO_INCREMENT; +SELECT * FROM t1; +# Restart the server +-- source include/restart_mysqld.inc +# The MySQL and InnoDB data dictionaries should now be out of sync. +# The select should print message to the error log +SELECT * FROM t1; +-- error ER_AUTOINC_READ_FAILED,1467 +INSERT INTO t1 VALUES(null); +ALTER TABLE t1 AUTO_INCREMENT = 3; +INSERT INTO t1 VALUES(null); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/t/innodb-big.test b/mysql-test/t/innodb-big.test deleted file mode 100644 index dcb32cd8e71..00000000000 --- a/mysql-test/t/innodb-big.test +++ /dev/null @@ -1,152 +0,0 @@ -# -# Test some things that takes a long time - --- source include/big_test.inc --- source include/have_innodb.inc - ---disable_warnings -DROP TABLE IF EXISTS t1, t2, t3, t4; ---enable_warnings - -# -# Test test how filesort and buffered-record-reads works with innodb -# - -CREATE TABLE t1 (id INTEGER) ENGINE=MYISAM; -CREATE TABLE t2 (id INTEGER primary key) ENGINE=INNODB; -CREATE TABLE t3 (a char(32) primary key,id INTEGER) ENGINE=INNODB; -CREATE TABLE t4 (a char(32) primary key,id INTEGER) ENGINE=MYISAM; - -INSERT INTO t1 (id) VALUES (1); -INSERT INTO t1 SELECT id+1 FROM t1; -INSERT INTO t1 SELECT id+2 FROM t1; -INSERT INTO t1 SELECT id+4 FROM t1; -INSERT INTO t1 SELECT id+8 FROM t1; -INSERT INTO t1 SELECT id+16 FROM t1; -INSERT INTO t1 SELECT id+32 FROM t1; -INSERT INTO t1 SELECT id+64 FROM t1; -INSERT INTO t1 SELECT id+128 FROM t1; -INSERT INTO t1 SELECT id+256 FROM t1; -INSERT INTO t1 SELECT id+512 FROM t1; -INSERT INTO t1 SELECT id+1024 FROM t1; -INSERT INTO t1 SELECT id+2048 FROM t1; -INSERT INTO t1 SELECT id+4096 FROM t1; -INSERT INTO t1 SELECT id+8192 FROM t1; -INSERT INTO t1 SELECT id+16384 FROM t1; -INSERT INTO t1 SELECT id+32768 FROM t1; -INSERT INTO t1 SELECT id+65536 FROM t1; -INSERT INTO t1 SELECT id+131072 FROM t1; -INSERT INTO t1 SELECT id+262144 FROM t1; -INSERT INTO t1 SELECT id+524288 FROM t1; -INSERT INTO t1 SELECT id+1048576 FROM t1; -INSERT INTO t2 SELECT * FROM t1; -INSERT INTO t3 SELECT concat(id),id from t2 ORDER BY -id; -INSERT INTO t4 SELECT * from t3 ORDER BY concat(a); -select sum(id) from t3; -drop table t1,t2,t3,t4; - -# -# Bug#24989: The DEADLOCK error is improperly handled by InnoDB. -# -CREATE TABLE t1 (f1 int NOT NULL) ENGINE=InnoDB; -CREATE TABLE t2 (f2 int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; -DELIMITER |; -CREATE TRIGGER t1_bi before INSERT - ON t1 FOR EACH ROW -BEGIN - DECLARE CONTINUE HANDLER FOR SQLSTATE '40001' SET @a:= 'deadlock'; - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @a:= 'exception'; - INSERT INTO t2 (f2) VALUES (1); - DELETE FROM t2 WHERE f2 = 1; -END;| - -CREATE PROCEDURE proc24989() -BEGIN - DECLARE CONTINUE HANDLER FOR SQLSTATE '40001' SET @b:= 'deadlock'; - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @a:= 'exception'; - INSERT INTO t2 (f2) VALUES (1); - DELETE FROM t2 WHERE f2 = 1; -END;| - -create procedure proc24989_2() - deterministic -begin - declare continue handler for sqlexception - select 'Outer handler' as 'exception'; - - insert into t1 values(1); - select "continued"; -end| - -DELIMITER ;| - -connect (con1,localhost,root,,); -connect (con2,localhost,root,,); - -connection con1; -start transaction; -insert into t1 values(1); - -connection con2; -start transaction; -insert into t2 values(123); -send insert into t1 values(1); - -connection con1; ---sleep 1 -insert into t1 values(1); - -connection con2; ---error 1213 -reap; -select @a; -# check that the whole transaction was rolled back -select * from t2; - -connection con1; -commit; -start transaction; -insert into t1 values(1); - -connection con2; -start transaction; -insert into t2 values(123); -send call proc24989(); - -connection con1; ---sleep 1 -insert into t1 values(1); - -connection con2; -reap; -select @a,@b; -# check that the whole transaction was rolled back -select * from t2; - -connection con1; -commit; -start transaction; -insert into t1 values(1); - -connection con2; -start transaction; -insert into t2 values(123); -send call proc24989_2(); - -connection con1; ---sleep 1 -insert into t1 values(1); -commit; - -connection con2; -reap; -# check that the whole transaction was rolled back -select * from t2; - -disconnect con1; -disconnect con2; -connection default; -drop procedure proc24989; -drop procedure proc24989_2; -drop table t1,t2; - diff --git a/mysql-test/t/innodb-deadlock.test b/mysql-test/t/innodb-deadlock.test deleted file mode 100644 index 1a184f98771..00000000000 --- a/mysql-test/t/innodb-deadlock.test +++ /dev/null @@ -1,140 +0,0 @@ --- source include/have_innodb.inc - -connect (con1,localhost,root,,); -connect (con2,localhost,root,,); - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - -# -# Testing of FOR UPDATE -# - -connection con1; -create table t1 (id integer, x integer) engine=INNODB; -insert into t1 values(0, 0); -set autocommit=0; -SELECT * from t1 where id = 0 FOR UPDATE; - -connection con2; -set autocommit=0; - -# The following query should hang because con1 is locking the page ---send -update t1 set x=2 where id = 0; ---sleep 2 - -connection con1; -update t1 set x=1 where id = 0; -select * from t1; -commit; - -connection con2; -reap; -commit; - -connection con1; -select * from t1; -commit; - -drop table t1; -# -# Testing of FOR UPDATE -# - -connection con1; -create table t1 (id integer, x integer) engine=INNODB; -create table t2 (b integer, a integer) engine=INNODB; -insert into t1 values(0, 0), (300, 300); -insert into t2 values(0, 10), (1, 20), (2, 30); -commit; -set autocommit=0; -select * from t2; -update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE); -select * from t2; -select * from t1; - -connection con2; -set autocommit=0; - -# The following query should hang because con1 is locking the page ---send -update t1 set x=2 where id = 0; ---sleep 2 - -connection con1; -update t1 set x=1 where id = 0; -select * from t1; -commit; - -connection con2; -reap; -commit; - -connection con1; -select * from t1; -commit; - -drop table t1, t2; -create table t1 (id integer, x integer) engine=INNODB; -create table t2 (b integer, a integer) engine=INNODB; -insert into t1 values(0, 0), (300, 300); -insert into t2 values(0, 0), (1, 20), (2, 30); -commit; - -connection con1; -select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE; -select * from t2; -select * from t1; - -connection con2; - -# The following query should hang because con1 is locking the page -update t2 set a=2 where b = 0; -select * from t2; ---send -update t1 set x=2 where id = 0; ---sleep 2 - -connection con1; -update t1 set x=1 where id = 0; -select * from t1; -commit; - -connection con2; -reap; -commit; - -connection con1; -select * from t1; -commit; - -drop table t1, t2; - ---echo End of 4.1 tests - -# -# Bug#25164 create table `a` as select * from `A` hangs -# - -set storage_engine=innodb; - ---disable_warnings -drop table if exists a; -drop table if exists A; ---enable_warnings - -create table A (c int); -insert into A (c) values (0); ---error 0,ER_LOCK_DEADLOCK,ER_UPDATE_TABLE_USED -create table a as select * from A; -drop table A; - ---disable_warnings -drop table if exists a; ---enable_warnings - -set storage_engine=default; - ---echo End of 5.0 tests. diff --git a/mysql-test/t/innodb-master.opt b/mysql-test/t/innodb-master.opt index 4cb927540bf..4901efb416c 100644 --- a/mysql-test/t/innodb-master.opt +++ b/mysql-test/t/innodb-master.opt @@ -1 +1 @@ ---binlog_cache_size=32768 +--binlog_cache_size=32768 --innodb_lock_wait_timeout=1 diff --git a/mysql-test/t/innodb-replace.test b/mysql-test/t/innodb-replace.test index d44ede65ce8..8c3aacde5e8 100644 --- a/mysql-test/t/innodb-replace.test +++ b/mysql-test/t/innodb-replace.test @@ -11,10 +11,10 @@ drop table if exists t1; # create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb; select * from t1; ---error 1031 +--error ER_DELAYED_NOT_SUPPORTED replace delayed into t1 (c1, c2) values ( "text1","11"); select * from t1; ---error 1031 +--error ER_DELAYED_NOT_SUPPORTED replace delayed into t1 (c1, c2) values ( "text1","12"); select * from t1; drop table t1; diff --git a/mysql-test/t/innodb-semi-consistent-master.opt b/mysql-test/t/innodb-semi-consistent-master.opt new file mode 100644 index 00000000000..e76299453d3 --- /dev/null +++ b/mysql-test/t/innodb-semi-consistent-master.opt @@ -0,0 +1 @@ +--innodb_lock_wait_timeout=2 diff --git a/mysql-test/t/innodb-semi-consistent.test b/mysql-test/t/innodb-semi-consistent.test new file mode 100644 index 00000000000..61ad7815ca9 --- /dev/null +++ b/mysql-test/t/innodb-semi-consistent.test @@ -0,0 +1,68 @@ +-- source include/not_embedded.inc +-- source include/have_innodb.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# basic tests of semi-consistent reads + +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +set binlog_format=mixed; +set session transaction isolation level repeatable read; +create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; +insert into t1 values (1),(2),(3),(4),(5),(6),(7); +set autocommit=0; +# this should lock the entire table +select * from t1 where a=3 lock in share mode; +connection b; +set binlog_format=mixed; +set session transaction isolation level repeatable read; +set autocommit=0; +-- error ER_LOCK_WAIT_TIMEOUT +update t1 set a=10 where a=5; +connection a; +commit; +connection b; +# perform a semi-consisent read (and unlock non-matching rows) +set session transaction isolation level read committed; +update t1 set a=10 where a=5; +connection a; +-- error ER_LOCK_WAIT_TIMEOUT +select * from t1 where a=2 for update; +# this should lock the records (1),(2) +select * from t1 where a=2 limit 1 for update; +connection b; +# semi-consistent read will skip non-matching locked rows a=1, a=2 +update t1 set a=11 where a=6; +-- error ER_LOCK_WAIT_TIMEOUT +update t1 set a=12 where a=2; +-- error ER_LOCK_WAIT_TIMEOUT +update t1 set a=13 where a=1; +connection a; +commit; +connection b; +update t1 set a=14 where a=1; +commit; +connection a; +select * from t1; +drop table t1; + +connection default; +disconnect a; +disconnect b; + +# Bug 39320 +create table t1 (a int, b int) engine=myisam; +create table t2 (c int, d int, key (c)) engine=innodb; +insert into t1 values (1,1); +insert into t2 values (1,2); +connect (a,localhost,root,,); +connection a; +set session transaction isolation level read committed; +delete from t1 using t1 join t2 on t1.a = t2.c where t2.d in (1); +connection default; +disconnect a; +drop table t1, t2; diff --git a/mysql-test/t/innodb-ucs2.test b/mysql-test/t/innodb-ucs2.test index 6647a9d0845..7b91ef37d3f 100644 --- a/mysql-test/t/innodb-ucs2.test +++ b/mysql-test/t/innodb-ucs2.test @@ -1,6 +1,10 @@ -- source include/have_innodb.inc -- source include/have_ucs2.inc +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + # # BUG 14056 Column prefix index on UTF-8 primary key column causes: Can't find record.. # diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index f09901d1112..42c24324ebc 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -6,7 +6,9 @@ # Use innodb_mysql.[test|result] files instead. # # # # If nevertheless you need to make some changes here, please, forward # -# your commit message To: dev@innodb.com Cc: dev-innodb@mysql.com # +# your commit message # +# To: innodb_dev_ww@oracle.com # +# Cc: dev-innodb@mysql.com # # (otherwise your changes may be erased). # # # ####################################################################### @@ -21,19 +23,28 @@ # rows_deleted should be 23 + "rows_deleted before the test". This allows # the test to be run multiple times without restarting the mysqld server. # See Bug#43309 Test main.innodb can't be run twice --- let $innodb_rows_deleted_orig = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_deleted', Value, 1) --- let $innodb_rows_inserted_orig = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_inserted', Value, 1) --- let $innodb_rows_updated_orig = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_updated', Value, 1) - -# -# Small basic test with ignore -# +-- disable_query_log +SET @innodb_thread_concurrency_orig = @@innodb_thread_concurrency; + +SET @innodb_rows_deleted_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted'); +SET @innodb_rows_inserted_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_inserted'); +SET @innodb_rows_updated_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_updated'); +SET @innodb_row_lock_waits_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_waits'); +SET @innodb_row_lock_current_waits_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_current_waits'); +SET @innodb_row_lock_time_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time'); +SET @innodb_row_lock_time_max_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_max'); +SET @innodb_row_lock_time_avg_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg'); +-- enable_query_log --disable_warnings drop table if exists t1,t2,t3,t4; drop database if exists mysqltest; --enable_warnings +# +# Small basic test with ignore +# + 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; insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt'); @@ -64,7 +75,7 @@ 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), update t1 set parent_id=parent_id+100; select * from t1 where parent_id=102; update t1 set id=id+1000; --- error 1062,1022 +-- error ER_DUP_ENTRY,1022 update t1 set id=1024 where id=1009; select * from t1; update ignore t1 set id=id+1; # This will change all rows @@ -145,13 +156,13 @@ commit; select n, "after commit" from t1; commit; insert into t1 values (5); --- error 1062 +-- error ER_DUP_ENTRY insert into t1 values (4); commit; select n, "after commit" from t1; set autocommit=1; insert into t1 values (6); --- error 1062 +-- error ER_DUP_ENTRY insert into t1 values (4); select n from t1; set autocommit=0; @@ -225,7 +236,7 @@ drop table t1; CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb; insert into t1 values ('pippo', 12); --- error 1062 +-- error ER_DUP_ENTRY insert into t1 values ('pippo', 12); # Gives error delete from t1; delete from t1 where id = 'pippo'; @@ -339,39 +350,6 @@ 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=innodb; - -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 # @@ -535,7 +513,7 @@ 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; ---error 1062 +--error ER_DUP_ENTRY insert into t1 values (99,1,2,'D'),(1,1,2,'D'); select id from t1; select id from t1; @@ -546,7 +524,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); LOCK TABLES t1 WRITE; begin; ---error 1062 +--error ER_DUP_ENTRY 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'); @@ -746,6 +724,7 @@ insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha'); select id, code, name from t1 order by id; COMMIT; +SET binlog_format='MIXED'; BEGIN; SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt'); @@ -766,44 +745,37 @@ select * from t2; drop table t1,t2; # -# Bug#27716 multi-update did partially and has not binlogged +# Bug #29136 erred multi-delete on trans table does not rollback # -CREATE TABLE `t1` ( - `a` int(11) NOT NULL auto_increment, - `b` int(11) default NULL, - PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 ; +# prepare +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +CREATE TABLE t1 (a int, PRIMARY KEY (a)); +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB; +create trigger trg_del_t2 after delete on t2 for each row + insert into t1 values (1); +insert into t1 values (1); +insert into t2 values (1),(2); + -CREATE TABLE `t2` ( - `a` int(11) NOT NULL auto_increment, - `b` int(11) default NULL, - PRIMARY KEY (`a`) -) ENGINE=INNODB DEFAULT CHARSET=latin1 ; +# exec cases A, B - see multi_update.test + +# A. send_error() w/o send_eof() branch -# A. testing multi_update::send_eof() execution branch -insert into t1 values (1,1),(2,2); -insert into t2 values (1,1),(4,4); -reset master; --error ER_DUP_ENTRY -UPDATE t2,t1 SET t2.a=t1.a+2; +delete t2 from t2; + # check -select * from t2 /* must be (3,1), (4,4) */; -show master status /* there must no UPDATE in binlog */; -# B. testing multi_update::send_error() execution branch -delete 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_ENTRY -UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a; -show master status /* there must be no UPDATE query event */; +select count(*) from t2 /* must be 2 as restored after rollback caused by the error */; + +# cleanup bug#29136 -# cleanup bug#27716 drop table t1, t2; + # # Bug #29136 erred multi-delete on trans table does not rollback # @@ -987,20 +959,12 @@ insert into t2 (a) select b from t1; insert into t1 (a) select b from t2; insert into t2 (a) select b from t1; insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; select count(*) from t1; --replace_column 9 # -explain select * from t1 where c between 1 and 10000; +explain select * from t1 where c between 1 and 2500; update t1 set c=a; --replace_column 9 # -explain select * from t1 where c between 1 and 10000; +explain select * from t1 where c between 1 and 2500; drop table t1,t2; # @@ -1221,9 +1185,8 @@ drop table t2; # Test error handling -# Clean up filename -- embedded server reports whole path without .frm, -# regular server reports relative path with .frm (argh!) ---replace_result \\ / $MYSQL_TEST_DIR . /var/master-data/ / t2.frm t2 +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' --error ER_WRONG_FK_DEF create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb; @@ -1354,23 +1317,18 @@ drop table t1; # Test for testable InnoDB status variables. This test # uses previous ones(pages_created, rows_deleted, ...). -show status like "Innodb_buffer_pool_pages_total"; -show status like "Innodb_page_size"; --- let $innodb_rows_deleted = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_deleted', Value, 1) --- let $innodb_rows_inserted = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_inserted', Value, 1) --- let $innodb_rows_updated = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_updated', Value, 1) --- disable_query_log --- eval SELECT $innodb_rows_deleted - $innodb_rows_deleted_orig AS innodb_rows_deleted --- eval SELECT $innodb_rows_inserted - $innodb_rows_inserted_orig AS innodb_rows_inserted --- eval SELECT $innodb_rows_updated - $innodb_rows_updated_orig AS innodb_rows_updated --- enable_query_log +SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total'; +SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size'; +SELECT variable_value - @innodb_rows_deleted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted'; +SELECT variable_value - @innodb_rows_inserted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_inserted'; +SELECT variable_value - @innodb_rows_updated_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_updated'; # Test for row locks InnoDB status variables. -show status like "Innodb_row_lock_waits"; -show status like "Innodb_row_lock_current_waits"; -show status like "Innodb_row_lock_time"; -show status like "Innodb_row_lock_time_max"; -show status like "Innodb_row_lock_time_avg"; +SELECT variable_value - @innodb_row_lock_waits_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_waits'; +SELECT variable_value - @innodb_row_lock_current_waits_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_current_waits'; +SELECT variable_value - @innodb_row_lock_time_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time'; +SELECT variable_value - @innodb_row_lock_time_max_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_max'; +SELECT variable_value - @innodb_row_lock_time_avg_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg'; # Test for innodb_sync_spin_loops variable show variables like "innodb_sync_spin_loops"; @@ -1382,8 +1340,7 @@ set global innodb_sync_spin_loops=20; show variables like "innodb_sync_spin_loops"; # Test for innodb_thread_concurrency variable -# save the original value so we can restore it at the end --- let $innodb_thread_concurrency_orig = query_get_value(SHOW VARIABLES WHERE variable_name = 'innodb_thread_concurrency', Value, 1) +SET @old_innodb_thread_concurrency= @@global.innodb_thread_concurrency; show variables like "innodb_thread_concurrency"; set global innodb_thread_concurrency=1001; show variables like "innodb_thread_concurrency"; @@ -1391,10 +1348,7 @@ set global innodb_thread_concurrency=0; show variables like "innodb_thread_concurrency"; set global innodb_thread_concurrency=16; show variables like "innodb_thread_concurrency"; -# restore the orginal value, this way the test can be run multiple times --- disable_query_log --- eval set global innodb_thread_concurrency = $innodb_thread_concurrency_orig --- enable_query_log +SET @@global.innodb_thread_concurrency= @old_innodb_thread_concurrency; # Test for innodb_concurrency_tickets variable show variables like "innodb_concurrency_tickets"; @@ -1426,9 +1380,8 @@ source include/varchar.inc; # Some errors/warnings on create # -# Clean up filename -- embedded server reports whole path without .frm, -# regular server reports relative path with .frm (argh!) ---replace_result \\ / $MYSQL_TEST_DIR . /var/master-data/ / t1.frm t1 +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' create table t1 (v varchar(65530), key(v)); drop table t1; create table t1 (v varchar(65536)); @@ -1474,7 +1427,7 @@ create table t1 (rowid int not null auto_increment, val int not null,primary key (rowid), unique(val)) engine=innodb; replace into t1 (val) values ('1'),('2'); replace into t1 (val) values ('1'),('2'); ---error 1062 +--error ER_DUP_ENTRY insert into t1 (val) values ('1'),('2'); select * from t1; drop table t1; @@ -1487,7 +1440,7 @@ create table t1 (a int not null auto_increment primary key, val int) engine=Inno insert into t1 (val) values (1); update t1 set a=2 where a=1; # We should get the following error because InnoDB does not update the counter ---error 1062 +--error ER_DUP_ENTRY insert into t1 (val) values (1); select * from t1; drop table t1; @@ -1702,7 +1655,8 @@ disconnect b; set foreign_key_checks=0; create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb; ---replace_result $MYSQLTEST_VARDIR . master-data/ '' +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' -- error 1005 create table t1(a char(10) primary key, b varchar(20)) engine = innodb; set foreign_key_checks=1; @@ -1713,7 +1667,8 @@ drop table t2; set foreign_key_checks=0; create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1; ---replace_result $MYSQLTEST_VARDIR . master-data/ '' +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' -- error 1005 create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8; set foreign_key_checks=1; @@ -1743,7 +1698,8 @@ drop table t2,t1; set foreign_key_checks=0; create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1; create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8; ---replace_result $MYSQLTEST_VARDIR . master-data/ '' +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' -- error 1025 rename table t3 to t1; set foreign_key_checks=1; @@ -1810,13 +1766,13 @@ create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb; create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb; insert into t1 values (0x41),(0x4120),(0x4100); --- error 1062 +-- error ER_DUP_ENTRY insert into t2 values (0x41),(0x4120),(0x4100); insert into t2 values (0x41),(0x4120); --- error 1062 +-- error ER_DUP_ENTRY insert into t3 values (0x41),(0x4120),(0x4100); insert into t3 values (0x41),(0x4100); --- error 1062 +-- error ER_DUP_ENTRY insert into t4 values (0x41),(0x4120),(0x4100); insert into t4 values (0x41),(0x4100); select hex(s1) from t1; @@ -1980,6 +1936,59 @@ disconnect a; disconnect b; # +# Test that cascading updates leading to duplicate keys give the correct +# error message (bug #9680) +# + +CREATE TABLE t1 ( + field1 varchar(8) NOT NULL DEFAULT '', + field2 varchar(8) NOT NULL DEFAULT '', + PRIMARY KEY (field1, field2) +) ENGINE=InnoDB; + +CREATE TABLE t2 ( + field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, + FOREIGN KEY (field1) REFERENCES t1 (field1) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; + +INSERT INTO t1 VALUES ('old', 'somevalu'); +INSERT INTO t1 VALUES ('other', 'anyvalue'); + +INSERT INTO t2 VALUES ('old'); +INSERT INTO t2 VALUES ('other'); + +--error ER_FOREIGN_DUPLICATE_KEY +UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; + +DROP TABLE t2; +DROP TABLE t1; + +# +# Bug#18477 - MySQL/InnoDB Ignoring Foreign Keys in ALTER TABLE +# +create table t1 ( + c1 bigint not null, + c2 bigint not null, + primary key (c1), + unique key (c2) +) engine=innodb; +# +create table t2 ( + c1 bigint not null, + primary key (c1) +) engine=innodb; +# +alter table t1 add constraint c2_fk foreign key (c2) + references t2(c1) on delete cascade; +show create table t1; +# +alter table t1 drop foreign key c2_fk; +show create table t1; +# +drop table t1, t2; + +# # Bug #14360: problem with intervals # @@ -1991,8 +2000,269 @@ select * from t1, t2 where t2.a between t1.a - interval 2 day and t1.a + interval 2 day; drop table t1, t2; +create table t1 (id int not null, f_id int not null, f int not null, +primary key(f_id, id)) engine=innodb; +create table t2 (id int not null,s_id int not null,s varchar(200), +primary key(id)) engine=innodb; +INSERT INTO t1 VALUES (8, 1, 3); +INSERT INTO t1 VALUES (1, 2, 1); +INSERT INTO t2 VALUES (1, 0, ''); +INSERT INTO t2 VALUES (8, 1, ''); +commit; +DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id) +WHERE mm.id IS NULL; +select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id) +where mm.id is null lock in share mode; +drop table t1,t2; + +# +# Test case where X-locks on unused rows should be released in a +# update (because READ COMMITTED isolation level) +# + +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3); +commit; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +update t1 set b = 5 where b = 1; +connection b; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +# +# X-lock to record (7,3) should be released in a update +# +select * from t1 where a = 7 and b = 3 for update; +connection a; +commit; +connection b; +commit; +drop table t1; +connection default; +disconnect a; +disconnect b; + +# +# Test case where no locks should be released (because we are not +# using READ COMMITTED isolation level) +# + +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2); +commit; +set autocommit = 0; +select * from t1 lock in share mode; +update t1 set b = 5 where b = 1; +connection b; +set autocommit = 0; +# +# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update +# +--error 1205 +select * from t1 where a = 2 and b = 2 for update; +# +# X-lock to record (1,1),(3,1),(5,1) should not be released in a update +# +--error 1205 +connection a; +commit; +connection b; +commit; +connection default; +disconnect a; +disconnect b; +drop table t1; + +# +# Consistent read should be used in following selects +# +# 1) INSERT INTO ... SELECT +# 2) UPDATE ... = ( SELECT ...) +# 3) CREATE ... SELECT + +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values (1,2),(5,3),(4,2); +create table t2(d int not null, e int, primary key(d)) engine=innodb; +insert into t2 values (8,6),(12,1),(3,1); +commit; +set autocommit = 0; +select * from t2 for update; +connection b; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +insert into t1 select * from t2; +update t1 set b = (select e from t2 where a = d); +create table t3(d int not null, e int, primary key(d)) engine=innodb +select * from t2; +commit; +connection a; +commit; +connection default; +disconnect a; +disconnect b; +drop table t1, t2, t3; + +# +# Consistent read should not be used if +# +# (a) isolation level is serializable OR +# (b) select ... lock in share mode OR +# (c) select ... for update +# +# in following queries: +# +# 1) INSERT INTO ... SELECT +# 2) UPDATE ... = ( SELECT ...) +# 3) CREATE ... SELECT + +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connect (c,localhost,root,,); +connect (d,localhost,root,,); +connect (e,localhost,root,,); +connect (f,localhost,root,,); +connect (g,localhost,root,,); +connect (h,localhost,root,,); +connect (i,localhost,root,,); +connect (j,localhost,root,,); +connection a; +create table t1(a int not null, b int, primary key(a)) engine=innodb; +insert into t1 values (1,2),(5,3),(4,2); +create table t2(a int not null, b int, primary key(a)) engine=innodb; +insert into t2 values (8,6),(12,1),(3,1); +create table t3(d int not null, b int, primary key(d)) engine=innodb; +insert into t3 values (8,6),(12,1),(3,1); +create table t5(a int not null, b int, primary key(a)) engine=innodb; +insert into t5 values (1,2),(5,3),(4,2); +create table t6(d int not null, e int, primary key(d)) engine=innodb; +insert into t6 values (8,6),(12,1),(3,1); +create table t8(a int not null, b int, primary key(a)) engine=innodb; +insert into t8 values (1,2),(5,3),(4,2); +create table t9(d int not null, e int, primary key(d)) engine=innodb; +insert into t9 values (8,6),(12,1),(3,1); +commit; +set autocommit = 0; +select * from t2 for update; +connection b; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +--send +insert into t1 select * from t2; +connection c; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +--send +update t3 set b = (select b from t2 where a = d); +connection d; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +--send +create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2; +connection e; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +--send +insert into t5 (select * from t2 lock in share mode); +connection f; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +--send +update t6 set e = (select b from t2 where a = d lock in share mode); +connection g; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +--send +create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode; +connection h; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +--send +insert into t8 (select * from t2 for update); +connection i; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +--send +update t9 set e = (select b from t2 where a = d for update); +connection j; +SET binlog_format='MIXED'; +set autocommit = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +--send +create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update; + +connection b; +--error 1205 +reap; + +connection c; +--error 1205 +reap; + +connection d; +--error 1205 +reap; + +connection e; +--error 1205 +reap; + +connection f; +--error 1205 +reap; + +connection g; +--error 1205 +reap; + +connection h; +--error 1205 +reap; + +connection i; +--error 1205 +reap; + +connection j; +--error 1205 +reap; + +connection a; +commit; + +connection default; +disconnect a; +disconnect b; +disconnect c; +disconnect d; +disconnect e; +disconnect f; +disconnect g; +disconnect h; +disconnect i; +disconnect j; +drop table t1, t2, t3, t5, t6, t8, t9; + # bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID" ---replace_result \\ / $MYSQL_TEST_DIR . /var/master-data/ / --error 1005 CREATE TABLE t1 (DB_ROW_ID int) engine=innodb; @@ -2031,10 +2301,30 @@ SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over'; drop table t2, t1; # -# Bug #15680 (SPATIAL key in innodb) +# Test optimize on table with open transaction +# + +CREATE TABLE t1 ( a int ) ENGINE=innodb; +BEGIN; +INSERT INTO t1 VALUES (1); +OPTIMIZE TABLE t1; +DROP TABLE t1; + +# +# Bug #24741 (existing cascade clauses disappear when adding foreign keys) # ---error ER_TABLE_CANT_HANDLE_SPKEYS -create table t1 (g geometry not null, spatial gk(g)) engine=innodb; + +CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB; + +CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL, + CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id) + ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB; + +ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON +DELETE CASCADE ON UPDATE CASCADE; + +SHOW CREATE TABLE t2; +DROP TABLE t2, t1; # # Bug #25927: Prevent ALTER TABLE ... MODIFY ... NOT NULL on columns @@ -2046,7 +2336,10 @@ CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL; ---replace_regex /'\.\/test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ +# mysqltest first does replace_regex, then replace_result +--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' --error 1025 ALTER TABLE t2 MODIFY a INT NOT NULL; DELETE FROM t1; @@ -2084,6 +2377,178 @@ SHOW CREATE TABLE t1; DROP TABLE t1,t2; +# +# Bug #21101 (Prints wrong error message if max row size is too large) +# +--error 1118 +CREATE TABLE t1 ( + c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255), + c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255), + c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255), + c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255), + c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255), + c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255), + c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255), + c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255) + ) ENGINE = InnoDB; + +# +# Bug #31860 InnoDB assumes AUTOINC values can only be positive. +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1( + id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY + ) ENGINE=InnoDB; +INSERT INTO t1 VALUES(-10); +SELECT * FROM t1; +# +# NOTE: The server really needs to be restarted at this point +# for the test to be useful. +# +# Without the fix InnoDB would trip over an assertion here. +INSERT INTO t1 VALUES(NULL); +# The next value should be 1 and not -9 or a -ve number +SELECT * FROM t1; +DROP TABLE t1; + +# +# Bug #21409 Incorrect result returned when in READ-COMMITTED with +# query_cache ON +# +CONNECT (c1,localhost,root,,); +CONNECT (c2,localhost,root,,); +CONNECTION c1; +SET binlog_format='MIXED'; +SET TX_ISOLATION='read-committed'; +SET AUTOCOMMIT=0; +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( a int ) ENGINE=InnoDB; +CREATE TABLE t2 LIKE t1; +SELECT * FROM t2; +CONNECTION c2; +SET binlog_format='MIXED'; +SET TX_ISOLATION='read-committed'; +SET AUTOCOMMIT=0; +INSERT INTO t1 VALUES (1); +COMMIT; +CONNECTION c1; +SELECT * FROM t1 WHERE a=1; +DISCONNECT c1; +DISCONNECT c2; +CONNECT (c1,localhost,root,,); +CONNECT (c2,localhost,root,,); +CONNECTION c1; +SET binlog_format='MIXED'; +SET TX_ISOLATION='read-committed'; +SET AUTOCOMMIT=0; +SELECT * FROM t2; +CONNECTION c2; +SET binlog_format='MIXED'; +SET TX_ISOLATION='read-committed'; +SET AUTOCOMMIT=0; +INSERT INTO t1 VALUES (2); +COMMIT; +CONNECTION c1; +# The result set below should be the same for both selects +SELECT * FROM t1 WHERE a=2; +SELECT * FROM t1 WHERE a=2; +DROP TABLE t1; +DROP TABLE t2; +DISCONNECT c1; +DISCONNECT c2; +CONNECTION default; + +# +# Bug #29157 UPDATE, changed rows incorrect +# +create table t1 (i int, j int) engine=innodb; +insert into t1 (i, j) values (1, 1), (2, 2); +--enable_info +update t1 set j = 2; +--disable_info +drop table t1; + +# +# Bug #32440 InnoDB free space info does not appear in SHOW TABLE STATUS or +# I_S +# +create table t1 (id int) comment='this is a comment' engine=innodb; +select table_comment, data_free > 0 as data_free_is_set + from information_schema.tables + where table_schema='test' and table_name = 't1'; +drop table t1; + +# +# Bug 34920 test +# +CONNECTION default; +CREATE TABLE t1 ( + c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + c2 VARCHAR(128) NOT NULL, + PRIMARY KEY(c1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100; + +CREATE TABLE t2 ( + c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + c2 INT(10) UNSIGNED DEFAULT NULL, + PRIMARY KEY(c1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200; + +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2'; +ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2'; +DROP TABLE t2; +DROP TABLE t1; +# End 34920 test +# +# Bug #29507 TRUNCATE shows to many rows effected +# +CONNECTION default; +CREATE TABLE t1 (c1 int default NULL, + c2 int default NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +--enable_info +TRUNCATE TABLE t1; + +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +TRUNCATE TABLE t1; + +--disable_info +DROP TABLE t1; +# +# Bug#35537 Innodb doesn't increment handler_update and handler_delete. +# +-- disable_query_log +-- disable_result_log + +CONNECT (c1,localhost,root,,); + +DROP TABLE IF EXISTS bug35537; +CREATE TABLE bug35537 ( + c1 int +) ENGINE=InnoDB; + +INSERT INTO bug35537 VALUES (1); + +-- enable_result_log + +SHOW SESSION STATUS LIKE 'Handler_update%'; +SHOW SESSION STATUS LIKE 'Handler_delete%'; + +UPDATE bug35537 SET c1 = 2 WHERE c1 = 1; +DELETE FROM bug35537 WHERE c1 = 2; + +SHOW SESSION STATUS LIKE 'Handler_update%'; +SHOW SESSION STATUS LIKE 'Handler_delete%'; + +DROP TABLE bug35537; + +DISCONNECT c1; +CONNECTION default; + +SET GLOBAL innodb_thread_concurrency = @innodb_thread_concurrency_orig; + ####################################################################### # # # Please, DO NOT TOUCH this file as well as the innodb.result file. # @@ -2092,7 +2557,9 @@ DROP TABLE t1,t2; # Use innodb_mysql.[test|result] files instead. # # # # If nevertheless you need to make some changes here, please, forward # -# your commit message To: dev@innodb.com Cc: dev-innodb@mysql.com # +# your commit message # +# To: innodb_dev_ww@oracle.com # +# Cc: dev-innodb@mysql.com # # (otherwise your changes may be erased). # # # ####################################################################### diff --git a/mysql-test/t/innodb_autoinc_lock_mode_zero-master.opt b/mysql-test/t/innodb_autoinc_lock_mode_zero-master.opt new file mode 100644 index 00000000000..fad0da2ac2e --- /dev/null +++ b/mysql-test/t/innodb_autoinc_lock_mode_zero-master.opt @@ -0,0 +1 @@ +--innodb-autoinc-lock-mode=0 diff --git a/mysql-test/t/innodb_autoinc_lock_mode_zero.test b/mysql-test/t/innodb_autoinc_lock_mode_zero.test new file mode 100644 index 00000000000..96f748673c0 --- /dev/null +++ b/mysql-test/t/innodb_autoinc_lock_mode_zero.test @@ -0,0 +1,44 @@ +# This test runs with old-style locking, as: +# --innodb-autoinc-lock-mode=0 + +-- source include/have_innodb.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + + +# +# 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=innodb; + +insert into t1 (ggid,passwd) values ('test1','xxx'); +insert into t1 (ggid,passwd) values ('test2','yyy'); +-- error ER_DUP_ENTRY +insert into t1 (ggid,passwd) values ('test2','this will fail'); +-- error ER_DUP_ENTRY +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 ER_DUP_ENTRY +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; + +--echo End of tests diff --git a/mysql-test/t/innodb_bug21704.test b/mysql-test/t/innodb_bug21704.test new file mode 100644 index 00000000000..c649b61034c --- /dev/null +++ b/mysql-test/t/innodb_bug21704.test @@ -0,0 +1,96 @@ +-- source include/have_innodb.inc + +--echo # +--echo # Bug#21704: Renaming column does not update FK definition. +--echo # + +--echo +--echo # Test that it's not possible to rename columns participating in a +--echo # foreign key (either in the referencing or referenced table). +--echo + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +--enable_warnings + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT ENGINE=INNODB; + +CREATE TABLE t2 (a INT PRIMARY KEY, b INT, + CONSTRAINT fk1 FOREIGN KEY (a) REFERENCES t1(a)) +ROW_FORMAT=COMPACT ENGINE=INNODB; + +CREATE TABLE t3 (a INT PRIMARY KEY, b INT, KEY(b), C INT, + CONSTRAINT fk2 FOREIGN KEY (b) REFERENCES t3 (a)) +ROW_FORMAT=COMPACT ENGINE=INNODB; + +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); +INSERT INTO t2 VALUES (1,1),(2,2),(3,3); +INSERT INTO t3 VALUES (1,1,1),(2,2,2),(3,3,3); + +--echo +--echo # Test renaming the column in the referenced table. +--echo + +# mysqltest first does replace_regex, then replace_result +--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' +--error ER_ERROR_ON_RENAME +ALTER TABLE t1 CHANGE a c INT; + +--echo # Ensure that online column rename works. + +--enable_info +ALTER TABLE t1 CHANGE b c INT; +--disable_info + +--echo +--echo # Test renaming the column in the referencing table +--echo + +# mysqltest first does replace_regex, then replace_result +--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' +--error ER_ERROR_ON_RENAME +ALTER TABLE t2 CHANGE a c INT; + +--echo # Ensure that online column rename works. + +--enable_info +ALTER TABLE t2 CHANGE b c INT; +--disable_info + +--echo +--echo # Test with self-referential constraints +--echo + +# mysqltest first does replace_regex, then replace_result +--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' +--error ER_ERROR_ON_RENAME +ALTER TABLE t3 CHANGE a d INT; + +# mysqltest first does replace_regex, then replace_result +--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' +--error ER_ERROR_ON_RENAME +ALTER TABLE t3 CHANGE b d INT; + +--echo # Ensure that online column rename works. + +--enable_info +ALTER TABLE t3 CHANGE c d INT; +--disable_info + +--echo +--echo # Cleanup. +--echo + +DROP TABLE t3; +DROP TABLE t2; +DROP TABLE t1; diff --git a/mysql-test/t/innodb_bug30919-master.opt b/mysql-test/t/innodb_bug30919-master.opt new file mode 100644 index 00000000000..8636d2d8734 --- /dev/null +++ b/mysql-test/t/innodb_bug30919-master.opt @@ -0,0 +1 @@ +--innodb --innodb_autoinc_lock_mode=0 diff --git a/mysql-test/t/innodb_bug30919.test b/mysql-test/t/innodb_bug30919.test new file mode 100644 index 00000000000..56b2c7bc03d --- /dev/null +++ b/mysql-test/t/innodb_bug30919.test @@ -0,0 +1,68 @@ +--source include/have_innodb.inc +--source include/have_partition.inc +--vertical_results +let $engine_type= 'innodb'; + +######## Creat Table Section ######### +use test; + +eval CREATE TABLE test.part_tbl(id MEDIUMINT NOT NULL AUTO_INCREMENT, + dt TIMESTAMP, user CHAR(255), uuidf LONGBLOB, + fkid MEDIUMINT, filler VARCHAR(255), + PRIMARY KEY(id)) ENGINE=$engine_type + PARTITION BY RANGE(id) + SUBPARTITION BY hash(id) subpartitions 2 + (PARTITION pa3 values less than (42), + PARTITION pa6 values less than (60), + PARTITION pa7 values less than (70), + PARTITION pa8 values less than (80), + PARTITION pa9 values less than (90), + PARTITION pa10 values less than (100), + PARTITION pa11 values less than MAXVALUE); + +######## Create SPs, Functions, Views and Triggers Section ############## + +delimiter |; + +CREATE PROCEDURE test.proc_part() +BEGIN + DECLARE ins_count INT DEFAULT 1000; + DECLARE del_count INT; + DECLARE cur_user VARCHAR(255); + DECLARE local_uuid VARCHAR(255); + DECLARE local_time TIMESTAMP; + + SET local_time= NOW(); + SET cur_user= CURRENT_USER(); + SET local_uuid= UUID(); + + WHILE ins_count > 0 DO + INSERT INTO test.part_tbl VALUES (NULL, NOW(), USER() , UUID(), + ins_count,'Going to test MBR for MySQL'); + SET ins_count = ins_count - 1; + END WHILE; + SELECT MAX(id) FROM test.part_tbl INTO del_count; + WHILE del_count > 0 DO + DELETE FROM test.part_tbl WHERE id = del_count; + select count(*) as internal_count, del_count -- these two lines are for + FROM test.part_tbl; -- debug to show the problem + SET del_count = del_count - 2; + END WHILE; +END| + +delimiter ;| + +############ Finish Setup Section ################### + +############ Test Section ################### +--horizontal_results + +CALL test.proc_part(); + +select count(*) as Part from test.part_tbl; + +###### CLEAN UP SECTION ############## + +DROP PROCEDURE test.proc_part; +DROP TABLE test.part_tbl; + diff --git a/mysql-test/t/innodb_bug34053.test b/mysql-test/t/innodb_bug34053.test new file mode 100644 index 00000000000..b935e45c06d --- /dev/null +++ b/mysql-test/t/innodb_bug34053.test @@ -0,0 +1,50 @@ +# +# Make sure http://bugs.mysql.com/34053 remains fixed. +# + +-- source include/not_embedded.inc +-- source include/have_innodb.inc + +SET storage_engine=InnoDB; + +# we do not really care about what gets printed, we are only +# interested in getting success or failure according to our +# expectations +-- disable_query_log +-- disable_result_log + +GRANT USAGE ON *.* TO 'shane'@'localhost' IDENTIFIED BY '12345'; +FLUSH PRIVILEGES; + +-- connect (con1,localhost,shane,12345,) + +-- connection con1 +-- error ER_SPECIFIC_ACCESS_DENIED_ERROR +CREATE TABLE innodb_monitor (a INT) ENGINE=INNODB; +-- error ER_SPECIFIC_ACCESS_DENIED_ERROR +CREATE TABLE innodb_mem_validate (a INT) ENGINE=INNODB; +CREATE TABLE innodb_monitorx (a INT) ENGINE=INNODB; +DROP TABLE innodb_monitorx; +CREATE TABLE innodb_monito (a INT) ENGINE=INNODB; +DROP TABLE innodb_monito; +CREATE TABLE xinnodb_monitor (a INT) ENGINE=INNODB; +DROP TABLE xinnodb_monitor; +CREATE TABLE nnodb_monitor (a INT) ENGINE=INNODB; +DROP TABLE nnodb_monitor; + +-- connection default +CREATE TABLE innodb_monitor (a INT) ENGINE=INNODB; +CREATE TABLE innodb_mem_validate (a INT) ENGINE=INNODB; + +-- connection con1 +-- error ER_SPECIFIC_ACCESS_DENIED_ERROR +DROP TABLE innodb_monitor; +-- error ER_SPECIFIC_ACCESS_DENIED_ERROR +DROP TABLE innodb_mem_validate; + +-- connection default +DROP TABLE innodb_monitor; +DROP TABLE innodb_mem_validate; +DROP USER 'shane'@'localhost'; + +-- disconnect con1 diff --git a/mysql-test/t/innodb_bug34300.test b/mysql-test/t/innodb_bug34300.test new file mode 100644 index 00000000000..ecec381da14 --- /dev/null +++ b/mysql-test/t/innodb_bug34300.test @@ -0,0 +1,38 @@ +# +# Bug#34300 Tinyblob & tinytext fields currupted after export/import and alter in 5.1 +# http://bugs.mysql.com/34300 +# + +-- source include/have_innodb.inc + +-- disable_query_log +-- disable_result_log + +# set packet size and reconnect +let $max_packet=`select @@global.max_allowed_packet`; +SET @@global.max_allowed_packet=16777216; +--connect (newconn, localhost, root,,) + +DROP TABLE IF EXISTS bug34300; +CREATE TABLE bug34300 ( + f4 TINYTEXT, + f6 MEDIUMTEXT, + f8 TINYBLOB +) ENGINE=InnoDB; + +INSERT INTO bug34300 VALUES ('xxx', repeat('a', 8459264), 'zzz'); + +-- enable_query_log +-- enable_result_log + +SELECT f4, f8 FROM bug34300; + +ALTER TABLE bug34300 ADD COLUMN (f10 INT); + +SELECT f4, f8 FROM bug34300; + +DROP TABLE bug34300; + +disconnect newconn; +connection default; +SET @@global.max_allowed_packet=default; diff --git a/mysql-test/t/innodb_bug38231.test b/mysql-test/t/innodb_bug38231.test new file mode 100644 index 00000000000..b3fcd89f371 --- /dev/null +++ b/mysql-test/t/innodb_bug38231.test @@ -0,0 +1,75 @@ +# +# Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE + LOCK / UNLOCK +# http://bugs.mysql.com/38231 +# + +-- source include/have_innodb.inc + +SET storage_engine=InnoDB; + +# we care only that the following SQL commands do not crash the server +-- disable_query_log +-- disable_result_log + +DROP TABLE IF EXISTS bug38231; +CREATE TABLE bug38231 (a INT); + +-- connect (con1,localhost,root,,) +-- connect (con2,localhost,root,,) + +-- connection con1 +SET autocommit=0; +LOCK TABLE bug38231 WRITE; + +-- connection con2 +SET autocommit=0; +-- send +LOCK TABLE bug38231 WRITE; + +-- connection default +-- send +TRUNCATE TABLE bug38231; + +-- connection con1 +# give time to TRUNCATE and others to be executed; without sleep, sometimes +# UNLOCK executes before TRUNCATE +# TODO: Replace with wait_condition once possible under embedded server. +-- sleep 0.2 +# this crashes the server if the bug is present +UNLOCK TABLES; + +# clean up + +-- connection con2 +-- reap +UNLOCK TABLES; + +-- connection default +-- reap +-- disconnect con1 +-- disconnect con2 + +# test that TRUNCATE works with with row-level locks + +-- enable_query_log +-- enable_result_log + +INSERT INTO bug38231 VALUES (1), (10), (300); + +-- connect (con4,localhost,root,,) + +-- connection con4 +SET autocommit=0; +SELECT * FROM bug38231 FOR UPDATE; + +-- connection default +TRUNCATE TABLE bug38231; + +-- connection con4 +COMMIT; + +-- connection default + +-- disconnect con4 + +DROP TABLE bug38231; diff --git a/mysql-test/t/innodb_bug39438-master.opt b/mysql-test/t/innodb_bug39438-master.opt new file mode 100644 index 00000000000..43fac202fd4 --- /dev/null +++ b/mysql-test/t/innodb_bug39438-master.opt @@ -0,0 +1 @@ +--innodb-file-per-table=1 diff --git a/mysql-test/t/innodb_bug39438.test b/mysql-test/t/innodb_bug39438.test new file mode 100644 index 00000000000..4dc3d957c39 --- /dev/null +++ b/mysql-test/t/innodb_bug39438.test @@ -0,0 +1,27 @@ +# +# Bug#39438 Testcase for Bug#39436 crashes on 5.1 in fil_space_get_latch +# http://bugs.mysql.com/39438 +# +# This test must be run with innodb_file_per_table=1 because the crash +# only occurs if that option is turned on and DISCARD TABLESPACE only +# works with innodb_file_per_table. +# + +-- source include/have_innodb.inc + +SET storage_engine=InnoDB; + +# we care only that the following SQL commands do not crash the server +-- disable_query_log +-- disable_result_log + +DROP TABLE IF EXISTS bug39438; + +CREATE TABLE bug39438 (id INT) ENGINE=INNODB; + +ALTER TABLE bug39438 DISCARD TABLESPACE; + +# this crashes the server if the bug is present +SHOW TABLE STATUS; + +DROP TABLE bug39438; diff --git a/mysql-test/t/innodb_bug42101-nonzero-master.opt b/mysql-test/t/innodb_bug42101-nonzero-master.opt new file mode 100644 index 00000000000..d71dbe17d5b --- /dev/null +++ b/mysql-test/t/innodb_bug42101-nonzero-master.opt @@ -0,0 +1 @@ +--innodb_commit_concurrency=1 diff --git a/mysql-test/t/innodb_bug42101-nonzero.test b/mysql-test/t/innodb_bug42101-nonzero.test new file mode 100644 index 00000000000..685fdf20489 --- /dev/null +++ b/mysql-test/t/innodb_bug42101-nonzero.test @@ -0,0 +1,21 @@ +# +# Bug#42101 Race condition in innodb_commit_concurrency +# http://bugs.mysql.com/42101 +# + +-- source include/have_innodb.inc + +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=42; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=DEFAULT; +select @@innodb_commit_concurrency; +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; diff --git a/mysql-test/t/innodb_bug42101.test b/mysql-test/t/innodb_bug42101.test new file mode 100644 index 00000000000..b6536490d48 --- /dev/null +++ b/mysql-test/t/innodb_bug42101.test @@ -0,0 +1,19 @@ +# +# Bug#42101 Race condition in innodb_commit_concurrency +# http://bugs.mysql.com/42101 +# + +-- source include/have_innodb.inc + +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=42; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=DEFAULT; +select @@innodb_commit_concurrency; diff --git a/mysql-test/t/innodb_bug42419.test b/mysql-test/t/innodb_bug42419.test index 389093a8465..93c4764252a 100644 --- a/mysql-test/t/innodb_bug42419.test +++ b/mysql-test/t/innodb_bug42419.test @@ -3,6 +3,7 @@ # Bug#42419 Server crash with "Pure virtual method called" on two concurrent connections # +--source include/not_embedded.inc --source include/have_innodb.inc let $innodb_lock_wait_timeout= query_get_value(SHOW VARIABLES LIKE 'innodb_lock_wait_timeout%', Value, 1); diff --git a/mysql-test/t/innodb_bug44369.test b/mysql-test/t/innodb_bug44369.test new file mode 100644 index 00000000000..495059eb5e6 --- /dev/null +++ b/mysql-test/t/innodb_bug44369.test @@ -0,0 +1,21 @@ +# This is the test for bug 44369. We should +# block table creation with columns match +# some innodb internal reserved key words, +# both case sensitively and insensitely. + +--source include/have_innodb.inc + +# This create table operation should fail. +--error ER_CANT_CREATE_TABLE +create table bug44369 (DB_ROW_ID int) engine=innodb; + +# This create should fail as well +--error ER_CANT_CREATE_TABLE +create table bug44369 (db_row_id int) engine=innodb; + +show errors; + +--error ER_CANT_CREATE_TABLE +create table bug44369 (db_TRX_Id int) engine=innodb; + +show errors; diff --git a/mysql-test/t/innodb_bug45357.test b/mysql-test/t/innodb_bug45357.test new file mode 100644 index 00000000000..81727f352dd --- /dev/null +++ b/mysql-test/t/innodb_bug45357.test @@ -0,0 +1,10 @@ +-- source include/have_innodb.inc + +set session transaction isolation level read committed; + +create table bug45357(a int, b int,key(b))engine=innodb; +insert into bug45357 values (25170,6122); +update bug45357 set a=1 where b=30131; +delete from bug45357 where b < 20996; +delete from bug45357 where b < 7001; +drop table bug45357; diff --git a/mysql-test/t/innodb_bug46000.test b/mysql-test/t/innodb_bug46000.test new file mode 100644 index 00000000000..80c18c58ef0 --- /dev/null +++ b/mysql-test/t/innodb_bug46000.test @@ -0,0 +1,34 @@ +# This is the test for bug 46000. We shall +# block any index creation with the name of +# "GEN_CLUST_INDEX", which is the reserved +# name for innodb default primary index. + +--source include/have_innodb.inc + +# This 'create table' operation should fail because of +# using the reserve name as its index name. +--error ER_CANT_CREATE_TABLE +create table bug46000(`id` int,key `GEN_CLUST_INDEX`(`id`))engine=innodb; + +# Mixed upper/lower case of the reserved key words +--error ER_CANT_CREATE_TABLE +create table bug46000(`id` int, key `GEN_clust_INDEX`(`id`))engine=innodb; + +show errors; + +create table bug46000(id int) engine=innodb; + +# This 'create index' operation should fail. +--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +--error ER_CANT_CREATE_TABLE +create index GEN_CLUST_INDEX on bug46000(id); + +--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/ +show errors; + +# This 'create index' operation should succeed, no +# temp table left from last failed create index +# operation. +create index idx on bug46000(id); + +drop table bug46000; diff --git a/mysql-test/t/innodb_cache-master.opt b/mysql-test/t/innodb_cache-master.opt deleted file mode 100644 index 5f0ebff98f6..00000000000 --- a/mysql-test/t/innodb_cache-master.opt +++ /dev/null @@ -1 +0,0 @@ ---set-variable=query_cache_size=1M diff --git a/mysql-test/t/innodb_cache.test b/mysql-test/t/innodb_cache.test deleted file mode 100644 index 8ed2853e4f7..00000000000 --- a/mysql-test/t/innodb_cache.test +++ /dev/null @@ -1,87 +0,0 @@ --- source include/have_innodb.inc --- source include/have_query_cache.inc - -# Initialise ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings - -# -# Without auto_commit. -# -flush status; -set autocommit=0; -create table t1 (a int not null) engine=innodb; -insert into t1 values (1),(2),(3); -select * from t1; -show status like "Qcache_queries_in_cache"; -drop table t1; -commit; -set autocommit=1; -begin; -create table t1 (a int not null) engine=innodb; -insert into t1 values (1),(2),(3); -select * from t1; -show status like "Qcache_queries_in_cache"; -drop table t1; -commit; -create table t1 (a int not null) engine=innodb; -create table t2 (a int not null) engine=innodb; -create table t3 (a int not null) engine=innodb; -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 t3,t2,t1; - -CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=InnoDB; -select count(*) from t1; -insert into t1 (id) values (0); -select count(*) from t1; -drop table t1; - -# -# one statement roll back inside transation -# -let $save_query_cache_size=`select @@global.query_cache_size`; -set GLOBAL query_cache_size=1355776; -CREATE TABLE t1 ( id int(10) NOT NULL auto_increment, a varchar(25) default NULL, PRIMARY KEY (id), UNIQUE KEY a (a)) ENGINE=innodb; -CREATE TABLE t2 ( id int(10) NOT NULL auto_increment, b varchar(25) default NULL, PRIMARY KEY (id), UNIQUE KEY b (b)) ENGINE=innodb; -CREATE TABLE t3 ( id int(10) NOT NULL auto_increment, t1_id int(10) NOT NULL default '0', t2_id int(10) NOT NULL default '0', state int(11) default NULL, PRIMARY KEY (id), UNIQUE KEY t1_id (t1_id,t2_id), KEY t2_id (t2_id,t1_id), CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`), CONSTRAINT `t3_ibfk_2` FOREIGN KEY (`t2_id`) REFERENCES `t2` (`id`)) ENGINE=innodb; -INSERT INTO t1 VALUES (1,'me'); -INSERT INTO t2 VALUES (1,'you'); -INSERT INTO t3 VALUES (2,1,1,2); -delete from t3 where t1_id = 1 and t2_id = 1; -select t1.* from t1, t2, t3 where t3.state & 1 = 0 and t3.t1_id = t1.id and t3.t2_id = t2.id and t1.id = 1 order by t1.a asc; -begin; -insert into t3 VALUES ( NULL, 1, 1, 2 ); --- error 1062 -insert into t3 VALUES ( NULL, 1, 1, 2 ); -commit; -select t1.* from t1, t2, t3 where t3.state & 1 = 0 and t3.t1_id = t1.id and t3.t2_id = t2.id and t1.id = 1 order by t1.a asc; -drop table t3,t2,t1; ---disable_query_log -eval set GLOBAL query_cache_size=$save_query_cache_size; ---enable_query_log - -# End of 4.1 tests diff --git a/mysql-test/t/innodb_gis.test b/mysql-test/t/innodb_gis.test index 024d17c5363..1adb14ea482 100644 --- a/mysql-test/t/innodb_gis.test +++ b/mysql-test/t/innodb_gis.test @@ -2,3 +2,9 @@ SET storage_engine=innodb; --source include/gis_generic.inc --source include/gis_keys.inc + +# +# Bug #15680 (SPATIAL key in innodb) +# +--error ER_TABLE_CANT_HANDLE_SPKEYS +create table t1 (g geometry not null, spatial gk(g)) engine=innodb; diff --git a/mysql-test/t/innodb_handler.test b/mysql-test/t/innodb_handler.test deleted file mode 100644 index 18cec97af0d..00000000000 --- a/mysql-test/t/innodb_handler.test +++ /dev/null @@ -1,96 +0,0 @@ --- source include/have_innodb.inc - -# -# test of HANDLER ... -# - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - -create table t1 (a int, b char(10), key a(a), key b(a,b)) engine=innodb; -insert into t1 values -(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"), -(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"), -(20,"ggg"),(21,"hhh"),(22,"iii"); -handler t1 open as t2; -handler t2 read a first; -handler t2 read a next; -handler t2 read a next; -handler t2 read a prev; -handler t2 read a last; -handler t2 read a prev; -handler t2 read a prev; - -handler t2 read a first; -handler t2 read a prev; - -handler t2 read a last; -handler t2 read a prev; -handler t2 read a next; -handler t2 read a next; - -handler t2 read a=(15); -handler t2 read a=(16); - ---error 1070 -handler t2 read a=(19,"fff"); - -handler t2 read b=(19,"fff"); -handler t2 read b=(19,"yyy"); -handler t2 read b=(19); - ---error 1109 -handler t1 read a last; - -handler t2 read a=(11); -handler t2 read a>=(11); - -handler t2 read a=(18); -handler t2 read a>=(18); -handler t2 read a>(18); -handler t2 read a<=(18); -handler t2 read a<(18); - -handler t2 read a first limit 5; -handler t2 read a next limit 3; -handler t2 read a prev limit 10; - -handler t2 read a>=(16) limit 4; -handler t2 read a>=(16) limit 2,2; -handler t2 read a last limit 3; - -handler t2 read a=(19); -handler t2 read a=(19) where b="yyy"; - -handler t2 read first; -handler t2 read next; ---error 1064 -handler t2 read last; -handler t2 close; - -handler t1 open; -handler t1 read a next; # this used to crash as a bug#5373 -handler t1 read a next; -handler t1 close; - -handler t1 open; -handler t1 read a prev; # this used to crash as a bug#5373 -handler t1 read a prev; -handler t1 close; - -handler t1 open as t2; -handler t2 read first; -alter table t1 engine=innodb; ---error 1109 -handler t2 read first; - -drop table t1; -CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY (no1,no2)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2); -HANDLER t1 OPEN; -HANDLER t1 READ `primary` = (1, 1000); -HANDLER t1 READ `primary` PREV; -DROP TABLE t1; - -# End of 4.1 tests diff --git a/mysql-test/t/innodb_ignore_builtin-master.opt b/mysql-test/t/innodb_ignore_builtin-master.opt new file mode 100644 index 00000000000..f7289eed20e --- /dev/null +++ b/mysql-test/t/innodb_ignore_builtin-master.opt @@ -0,0 +1 @@ +--ignore_builtin_innodb diff --git a/mysql-test/t/innodb_ignore_builtin.test b/mysql-test/t/innodb_ignore_builtin.test new file mode 100644 index 00000000000..6f987bcf891 --- /dev/null +++ b/mysql-test/t/innodb_ignore_builtin.test @@ -0,0 +1,8 @@ +# +# Bug #42610: Dynamic plugin broken in 5.1.31 +# +show variables like 'ignore_builtin_innodb'; +select PLUGIN_NAME from information_schema.plugins +where PLUGIN_NAME = "InnoDb"; +select ENGINE from information_schema.engines +where ENGINE = "InnoDB"; diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index 3c81a27e9ac..7055879ce1a 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -1,1076 +1,493 @@ --- source include/have_innodb.inc - ---disable_warnings -drop table if exists t1,t2,t3,t4; ---enable_warnings - -# BUG#16798: Uninitialized row buffer reads in ref-or-null optimizer -# (repeatable only w/innodb). -create table t1 ( - c_id int(11) not null default '0', - org_id int(11) default null, - unique key contacts$c_id (c_id), - key contacts$org_id (org_id) -) engine=innodb; -insert into t1 values - (2,null),(120,null),(141,null),(218,7), (128,1), - (151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3), - (246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4); - -create table t2 ( - slai_id int(11) not null default '0', - owner_tbl int(11) default null, - owner_id int(11) default null, - sla_id int(11) default null, - inc_web int(11) default null, - inc_email int(11) default null, - inc_chat int(11) default null, - inc_csr int(11) default null, - inc_total int(11) default null, - time_billed int(11) default null, - activedate timestamp null default null, - expiredate timestamp null default null, - state int(11) default null, - sla_set int(11) default null, - unique key t2$slai_id (slai_id), - key t2$owner_id (owner_id), - key t2$sla_id (sla_id) -) engine=innodb; -insert into t2(slai_id, owner_tbl, owner_id, sla_id) values - (1,3,1,1), (3,3,10,2), (4,3,3,6), (5,3,2,5), (6,3,8,3), (7,3,9,7), - (8,3,6,8), (9,3,4,9), (10,3,5,10), (11,3,11,11), (12,3,7,12); - -flush tables; -select si.slai_id -from t1 c join t2 si on - ((si.owner_tbl = 3 and si.owner_id = c.org_id) or - ( si.owner_tbl = 2 and si.owner_id = c.c_id)) -where - c.c_id = 218 and expiredate is null; - -select * from t1 where org_id is null; -select si.slai_id -from t1 c join t2 si on - ((si.owner_tbl = 3 and si.owner_id = c.org_id) or - ( si.owner_tbl = 2 and si.owner_id = c.c_id)) -where - c.c_id = 218 and expiredate is null; - -drop table t1, t2; - +# t/innodb_mysql.test # -# Bug#17212: results not sorted correctly by ORDER BY when using index -# (repeatable only w/innodb because of index props) +# Last update: +# 2006-07-26 ML test refactored (MySQL 5.1) +# main testing code t/innodb_mysql.test -> include/mix1.inc # -CREATE TABLE t1 (a int, b int, KEY b (b)) Engine=InnoDB; -CREATE TABLE t2 (a int, b int, PRIMARY KEY (a,b)) Engine=InnoDB; -CREATE TABLE t3 (a int, b int, c int, PRIMARY KEY (a), - UNIQUE KEY b (b,c), KEY a (a,b,c)) Engine=InnoDB; - -INSERT INTO t1 VALUES (1, 1); -INSERT INTO t1 SELECT a + 1, b + 1 FROM t1; -INSERT INTO t1 SELECT a + 2, b + 2 FROM t1; - -INSERT INTO t2 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8); -INSERT INTO t2 SELECT a + 1, b FROM t2; -DELETE FROM t2 WHERE a = 1 AND b < 2; - -INSERT INTO t3 VALUES (1,1,1),(2,1,2); -INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3; -INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3; - -# demonstrate a problem when a must-use-sort table flag -# (sort_by_table=1) is being neglected. -SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE - t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2) - ORDER BY t1.b LIMIT 2; - -# demonstrate the problem described in the bug report -SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE - t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2) - ORDER BY t1.b LIMIT 5; -DROP TABLE t1, t2, t3; - - -# BUG#21077 (The testcase is not deterministic so correct execution doesn't -# prove anything) For proof one should track if sequence of ha_innodb::* func -# calls is correct. -CREATE TABLE `t1` (`id1` INT) ; -INSERT INTO `t1` (`id1`) VALUES (1),(5),(2); - -CREATE TABLE `t2` ( - `id1` INT, - `id2` INT NOT NULL, - `id3` INT, - `id4` INT NOT NULL, - UNIQUE (`id2`,`id4`), - KEY (`id1`) -) ENGINE=InnoDB; - -INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES -(1,1,1,0), -(1,1,2,1), -(5,1,2,2), -(6,1,2,3), -(1,2,2,2), -(1,2,1,1); -SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2); -DROP TABLE t1, t2; - -# -# Bug #22728 - Handler_rollback value is growing -# - -let $before= `show /*!50002 GLOBAL */ status like 'Handler_rollback'`; -create table t1 (c1 int) engine=innodb; -connect (con1,localhost,root,,); -connect (con2,localhost,root,,); -connection con2; -handler t1 open; -handler t1 read first; -disconnect con2; -connection con1; -let $after= `show /*!50002 GLOBAL */ status like 'Handler_rollback'`; -# Compare the before and after value, it should be equal ---disable_query_log -eval select STRCMP("$before", "$after") as "Before and after comparison"; ---enable_query_log -connection default; -drop table t1; -disconnect con1; +-- source include/have_innodb.inc +let $engine_type= InnoDB; +let $other_engine_type= MEMORY; +# InnoDB does support FOREIGN KEYFOREIGN KEYs +let $test_foreign_keys= 1; +set global innodb_support_xa=default; +set session innodb_support_xa=default; +--source include/mix1.inc +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings # -# Bug #13191: INSERT...ON DUPLICATE KEY UPDATE of UTF-8 string fields -# used in partial unique indices. +# BUG#35850: Performance regression in 5.1.23/5.1.24 # - -CREATE TABLE t1(c1 TEXT, UNIQUE (c1(1)), cnt INT DEFAULT 1) - ENGINE=INNODB CHARACTER SET UTF8; -INSERT INTO t1 (c1) VALUES ('1a'); -SELECT * FROM t1; -INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1; -SELECT * FROM t1; -DROP TABLE t1; - -CREATE TABLE t1(c1 VARCHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1) - ENGINE=INNODB CHARACTER SET UTF8; -INSERT INTO t1 (c1) VALUES ('1a'); -SELECT * FROM t1; -INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1; -SELECT * FROM t1; -DROP TABLE t1; - -CREATE TABLE t1(c1 CHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1) - ENGINE=INNODB CHARACTER SET UTF8; -INSERT INTO t1 (c1) VALUES ('1a'); -SELECT * FROM t1; -INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1; -SELECT * FROM t1; -DROP TABLE t1; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, pk int, key(a,b), primary key(pk)) engine=innodb; +insert into t2 select @a:=A.a+10*(B.a + 10*C.a),@a, @a from t1 A, t1 B, t1 C; +--echo this must use key 'a', not PRIMARY: +--replace_column 9 # +explain select a from t2 where a=b; +drop table t1, t2; # -# Bug #28272: EXPLAIN for SELECT from an empty InnoDB table +# Bug #40360: Binlog related errors with binlog off # +# This bug is triggered when the binlog format is STATEMENT and the +# binary log is turned off. In this case, no error should be shown for +# the statement since there are no replication issues. -CREATE TABLE t1 ( - a1 decimal(10,0) DEFAULT NULL, - a2 blob, - a3 time DEFAULT NULL, - a4 blob, - a5 char(175) DEFAULT NULL, - a6 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', - a7 tinyblob, - INDEX idx (a6,a7(239),a5) -) ENGINE=InnoDB; - -EXPLAIN SELECT a4 FROM t1 WHERE -a6=NULL AND -a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; - -EXPLAIN SELECT t1.a4 FROM t1, t1 t WHERE -t.a6=t.a6 AND t1.a6=NULL AND -t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; - +SET SESSION BINLOG_FORMAT=STATEMENT; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +query_vertical select @@session.sql_log_bin, @@session.binlog_format, @@session.tx_isolation; +CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); DROP TABLE t1; ---echo End of 4.1 tests # -# Bug #12882 min/max inconsistent on empty table +# Bug#37284 Crash in Field_string::type() # - --disable_warnings -create table t1m (a int) engine=myisam; -create table t1i (a int) engine=innodb; -create table t2m (a int) engine=myisam; -create table t2i (a int) engine=innodb; +DROP TABLE IF EXISTS t1; --enable_warnings -insert into t2m values (5); -insert into t2i values (5); - -# test with MyISAM -select min(a) from t1m; -select min(7) from t1m; -select min(7) from DUAL; -explain select min(7) from t2m join t1m; -select min(7) from t2m join t1m; - -select max(a) from t1m; -select max(7) from t1m; -select max(7) from DUAL; -explain select max(7) from t2m join t1m; -select max(7) from t2m join t1m; - -select 1, min(a) from t1m where a=99; -select 1, min(a) from t1m where 1=99; -select 1, min(1) from t1m where a=99; -select 1, min(1) from t1m where 1=99; - -select 1, max(a) from t1m where a=99; -select 1, max(a) from t1m where 1=99; -select 1, max(1) from t1m where a=99; -select 1, max(1) from t1m where 1=99; - -# test with InnoDB -select min(a) from t1i; -select min(7) from t1i; -select min(7) from DUAL; -explain select min(7) from t2i join t1i; -select min(7) from t2i join t1i; - -select max(a) from t1i; -select max(7) from t1i; -select max(7) from DUAL; -explain select max(7) from t2i join t1i; -select max(7) from t2i join t1i; - -select 1, min(a) from t1i where a=99; -select 1, min(a) from t1i where 1=99; -select 1, min(1) from t1i where a=99; -select 1, min(1) from t1i where 1=99; - -select 1, max(a) from t1i where a=99; -select 1, max(a) from t1i where 1=99; -select 1, max(1) from t1i where a=99; -select 1, max(1) from t1i where 1=99; - -# mixed MyISAM/InnoDB test -explain select count(*), min(7), max(7) from t1m, t1i; -select count(*), min(7), max(7) from t1m, t1i; - -explain select count(*), min(7), max(7) from t1m, t2i; -select count(*), min(7), max(7) from t1m, t2i; - -explain select count(*), min(7), max(7) from t2m, t1i; -select count(*), min(7), max(7) from t2m, t1i; - -drop table t1m, t1i, t2m, t2i; +CREATE TABLE t1 (a char(50)) ENGINE=InnoDB; +CREATE INDEX i1 on t1 (a(3)); +SELECT * FROM t1 WHERE a = 'abcde'; +DROP TABLE t1; # -# Bug #12672: primary key implcitly included in every innodb index -# (was part of group_min_max.test) +# Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of +# requested column # -create table t1 ( - a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' -); - -insert into t1 (a1, a2, b, c, d) values -('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), -('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), -('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), -('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), -('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), -('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), -('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), -('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), -('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), -('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), -('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), -('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), -('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), -('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), -('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), -('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'), -('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), -('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), -('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), -('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), -('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), -('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), -('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), -('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), -('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), -('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), -('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), -('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), -('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), -('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), -('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), -('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'); ---disable_warnings -create table t4 ( - pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' +CREATE TABLE foo (a int, b int, c char(10), + PRIMARY KEY (c(3)), + KEY b (b) ) engine=innodb; ---enable_warnings -insert into t4 (a1, a2, b, c, d, dummy) select * from t1; - -create index idx12672_0 on t4 (a1); -create index idx12672_1 on t4 (a1,a2,b,c); -create index idx12672_2 on t4 (a1,a2,b); -analyze table t1; -select distinct a1 from t4 where pk_col not in (1,2,3,4); - -drop table t1,t4; - - -# -# BUG#18819: DELETE IGNORE hangs on foreign key parent delete -# -# The bug itself does not relate to InnoDB, but we have to use foreign -# keys to reproduce it. -# ---disable_warnings -DROP TABLE IF EXISTS t2, t1; ---enable_warnings - -CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE= InnoDB; -CREATE TABLE t2 ( - i INT NOT NULL, - FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION -) ENGINE= InnoDB; +CREATE TABLE foo2 (a int, b int, c char(10), + PRIMARY KEY (c), + KEY b (b) +) engine=innodb; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (1); +CREATE TABLE bar (a int, b int, c char(10), + PRIMARY KEY (c(3)), + KEY b (b) +) engine=myisam; -DELETE IGNORE FROM t1 WHERE i = 1; +INSERT INTO foo VALUES + (1,2,'abcdefghij'), (2,3,''), (3,4,'klmnopqrst'), + (4,5,'uvwxyz'), (5,6,'meotnsyglt'), (4,5,'asfdewe'); -SELECT * FROM t1, t2; +INSERT INTO bar SELECT * FROM foo; +INSERT INTO foo2 SELECT * FROM foo; -DROP TABLE t2, t1; +--query_vertical EXPLAIN SELECT c FROM bar WHERE b>2; +--query_vertical EXPLAIN SELECT c FROM foo WHERE b>2; +--query_vertical EXPLAIN SELECT c FROM foo2 WHERE b>2; +--query_vertical EXPLAIN SELECT c FROM bar WHERE c>2; +--query_vertical EXPLAIN SELECT c FROM foo WHERE c>2; +--query_vertical EXPLAIN SELECT c FROM foo2 WHERE c>2; ---echo End of 4.1 tests. +DROP TABLE foo, bar, foo2; # -# Bug #6142: a problem with the empty innodb table -# (was part of group_min_max.test) +# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table # --disable_warnings -create table t1 ( - a varchar(30), b varchar(30), primary key(a), key(b) -) engine=innodb; +DROP TABLE IF EXISTS t1,t3,t2; +DROP FUNCTION IF EXISTS f1; --enable_warnings -select distinct a from t1; -drop table t1; - -# -# Bug #9798: group by with rollup -# (was part of group_min_max.test) -# ---disable_warnings -create table t1(a int, key(a)) engine=innodb; ---enable_warnings -insert into t1 values(1); -select a, count(a) from t1 group by a with rollup; -drop table t1; - -# -# Bug #13293 Wrongly used index results in endless loop. -# (was part of group_min_max.test) -# -create table t1 (f1 int, f2 char(1), primary key(f1,f2)) engine=innodb; -insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d"); -alter table t1 drop primary key, add primary key (f2, f1); -explain select distinct f1 a, f1 b from t1; -explain select distinct f1, f2 from t1; -drop table t1; - -# -# Test for bug #17164: ORed FALSE blocked conversion of outer join into join -# - -CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20), - INDEX (name)) ENGINE=InnoDB; -CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11), - FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); -INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); - -EXPLAIN -SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id - WHERE t1.name LIKE 'A%'; - -EXPLAIN -SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id - WHERE t1.name LIKE 'A%' OR FALSE; - -DROP TABLE t1,t2; - -# -# Bug#17530: Incorrect key truncation on table creation caused server crash. -# -create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb - character set utf8 collate utf8_general_ci; -insert into t1 values('aaa'); -drop table t1; - - -# -# Bug#22781: SQL_BIG_RESULT fails to influence sort plan -# -CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c FLOAT, KEY b(b)) ENGINE = INNODB; - -INSERT INTO t1 VALUES ( 1 , 1 , 1); -INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20), 1 FROM t1; -INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20), 1 FROM t1; -INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20), 1 FROM t1; -INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20), 1 FROM t1; -INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1; -INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1; -INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1; - -EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b; -EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b; -DROP TABLE t1; - - -# -# Bug#26159: crash for a loose scan of a table that has been emptied -# - -CREATE TABLE t1 ( - id int NOT NULL, - name varchar(20) NOT NULL, - dept varchar(20) NOT NULL, - age tinyint(3) unsigned NOT NULL, - PRIMARY KEY (id), - INDEX (name,dept) -) ENGINE=InnoDB; -INSERT INTO t1(id, dept, age, name) VALUES - (3987, 'cs1', 10, 'rs1'), (3988, 'cs2', 20, 'rs1'), (3995, 'cs3', 10, 'rs2'), - (3996, 'cs4', 20, 'rs2'), (4003, 'cs5', 10, 'rs3'), (4004, 'cs6', 20, 'rs3'), - (4011, 'cs7', 10, 'rs4'), (4012, 'cs8', 20, 'rs4'), (4019, 'cs9', 10, 'rs5'), - (4020, 'cs10', 20, 'rs5'),(4027, 'cs11', 10, 'rs6'),(4028, 'cs12', 20, 'rs6'); - -EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; -SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; -DELETE FROM t1; -EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; -SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; - -DROP TABLE t1; - ---source include/innodb_rollback_on_timeout.inc - -# -# Bug #27210: INNODB ON DUPLICATE KEY UPDATE -# - -set @save_qcache_size=@@global.query_cache_size; -set @save_qcache_type=@@global.query_cache_type; -set global query_cache_size=10*1024*1024; -set global query_cache_type=1; -connect (con1,localhost,root,,); -connection con1; -drop table if exists `test`; -CREATE TABLE `test` (`test1` varchar(3) NOT NULL, - `test2` varchar(4) NOT NULL,PRIMARY KEY (`test1`)) - ENGINE=InnoDB DEFAULT CHARSET=latin1; -INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '5678'); -disconnect con1; -connect (con2,localhost,root,,); -connection con2; -select * from test; -INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '1234') - ON DUPLICATE KEY UPDATE `test2` = '1234'; -select * from test; -flush tables; -select * from test; -disconnect con2; -connection default; -drop table test; -set global query_cache_type=@save_qcache_type; -set global query_cache_size=@save_qcache_size; - --- source include/have_innodb.inc - -# -# Bug #27650: INSERT fails after multi-row INSERT of the form: -# INSERT INTO t (id...) VALUES (NULL...) ON DUPLICATE KEY UPDATE id=VALUES(id) -# - -create table t1( -id int auto_increment, -c char(1) not null, -counter int not null default 1, -primary key (id), -unique key (c) -) engine=innodb; - -insert into t1 (id, c) values -(NULL, 'a'), -(NULL, 'a') -on duplicate key update id = values(id), counter = counter + 1; - -select * from t1; - -insert into t1 (id, c) values -(NULL, 'b') -on duplicate key update id = values(id), counter = counter + 1; - -select * from t1; - -truncate table t1; - -insert into t1 (id, c) values (NULL, 'a'); - -select * from t1; +DELIMITER |; +CREATE FUNCTION f1() RETURNS VARCHAR(250) + BEGIN + return 'hhhhhhh' ; + END| +DELIMITER ;| -insert into t1 (id, c) values (NULL, 'b'), (NULL, 'b') -on duplicate key update id = values(id), c = values(c), counter = counter + 1; +CREATE TABLE t1 (a VARCHAR(20), b VARCHAR(20), c VARCHAR(20)) ENGINE=INNODB; -select * from t1; +BEGIN WORK; -insert into t1 (id, c) values (NULL, 'a') -on duplicate key update id = values(id), c = values(c), counter = counter + 1; +CREATE TEMPORARY TABLE t2 (a VARCHAR(20), b VARCHAR(20), c varchar(20)) ENGINE=INNODB; +CREATE TEMPORARY TABLE t3 LIKE t2; -select * from t1; +INSERT INTO t1 VALUES ('a','b',NULL),('c','d',NULL),('e','f',NULL); -drop table t1; +SET @stmt := CONCAT('INSERT INTO t2 SELECT tbl.a, tbl.b, f1()',' FROM t1 tbl'); +PREPARE stmt1 FROM @stmt; -# -# Bug #28189: optimizer erroniously prefers ref access to range access -# for an InnoDB table -# +SET @stmt := CONCAT('INSERT INTO t3', ' SELECT * FROM t2'); +PREPARE stmt3 FROM @stmt; -CREATE TABLE t1( - id int AUTO_INCREMENT PRIMARY KEY, - stat_id int NOT NULL, - acct_id int DEFAULT NULL, - INDEX idx1 (stat_id, acct_id), - INDEX idx2 (acct_id) -) ENGINE=MyISAM; - -CREATE TABLE t2( - id int AUTO_INCREMENT PRIMARY KEY, - stat_id int NOT NULL, - acct_id int DEFAULT NULL, - INDEX idx1 (stat_id, acct_id), - INDEX idx2 (acct_id) -) ENGINE=InnoDB; +EXECUTE stmt1; -INSERT INTO t1(stat_id,acct_id) VALUES - (1,759), (2,831), (3,785), (4,854), (1,921), - (1,553), (2,589), (3,743), (2,827), (2,545), - (4,779), (4,783), (1,597), (1,785), (4,832), - (1,741), (1,833), (3,788), (2,973), (1,907); - -INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; -INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; -INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; -INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; -INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; -INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; -INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; -INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; -INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; -INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; -INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1; -UPDATE t1 SET acct_id=785 - WHERE MOD(stat_id,2)=0 AND MOD(id,stat_id)=MOD(acct_id,stat_id); -OPTIMIZE TABLE t1; - -SELECT COUNT(*) FROM t1; -SELECT COUNT(*) FROM t1 WHERE acct_id=785; - -EXPLAIN SELECT COUNT(*) FROM t1 WHERE stat_id IN (1,3) AND acct_id=785; - -INSERT INTO t2 SELECT * FROM t1; -OPTIMIZE TABLE t2; +COMMIT; -EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785; +DEALLOCATE PREPARE stmt1; +DEALLOCATE PREPARE stmt3; -DROP TABLE t1,t2; +DROP TABLE t1,t3,t2; +DROP FUNCTION f1; # -# Bug #28652: assert when alter innodb table operation +# Bug#37016: TRUNCATE TABLE removes some rows but not all # -create table t1(a int) engine=innodb; -alter table t1 comment '123'; -show create table t1; -drop table t1; - -# -# Bug #25866: Getting "#HY000 Can't find record in..." on and INSERT -# -CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8; -INSERT INTO t1 VALUES ('uk'),('bg'); -SELECT * FROM t1 WHERE a = 'uk'; -DELETE FROM t1 WHERE a = 'uk'; -SELECT * FROM t1 WHERE a = 'uk'; -UPDATE t1 SET a = 'us' WHERE a = 'uk'; -SELECT * FROM t1 WHERE a = 'uk'; - -CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB; -INSERT INTO t2 VALUES ('uk'),('bg'); -SELECT * FROM t2 WHERE a = 'uk'; -DELETE FROM t2 WHERE a = 'uk'; -SELECT * FROM t2 WHERE a = 'uk'; -INSERT INTO t2 VALUES ('uk'); -UPDATE t2 SET a = 'us' WHERE a = 'uk'; -SELECT * FROM t2 WHERE a = 'uk'; - -CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM; -INSERT INTO t3 VALUES ('uk'),('bg'); -SELECT * FROM t3 WHERE a = 'uk'; -DELETE FROM t3 WHERE a = 'uk'; -SELECT * FROM t3 WHERE a = 'uk'; -INSERT INTO t3 VALUES ('uk'); -UPDATE t3 SET a = 'us' WHERE a = 'uk'; -SELECT * FROM t3 WHERE a = 'uk'; - -DROP TABLE t1,t2,t3; - -# -# Test bug when trying to drop data file which no InnoDB directory entry -# - -create table t1 (a int) engine=innodb; -copy_file $MYSQLTEST_VARDIR/master-data/test/t1.frm $MYSQLTEST_VARDIR/master-data/test/t2.frm; ---error 1146 -select * from t2; -drop table t1; ---error 1051 -drop table t2; -create table t2 (a int); -drop table t2; +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings -# -# Bug #29154: LOCK TABLES is not atomic when >1 InnoDB tables are locked -# +CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, + t1_id INT, INDEX par_ind (t1_id), + FOREIGN KEY (t1_id) REFERENCES t1(id)) ENGINE=INNODB; +INSERT INTO t1 VALUES (1),(2); +INSERT INTO t2 VALUES (3,2); -CREATE TABLE t1 (a INT) ENGINE=InnoDB; -CREATE TABLE t2 (a INT) ENGINE=InnoDB; +SET AUTOCOMMIT = 0; -CONNECT (c1,localhost,root,,); -CONNECT (c2,localhost,root,,); +START TRANSACTION; +--error ER_ROW_IS_REFERENCED_2 +TRUNCATE TABLE t1; +SELECT * FROM t1; +COMMIT; +SELECT * FROM t1; ---echo switch to connection c1 -CONNECTION c1; -SET AUTOCOMMIT=0; -INSERT INTO t2 VALUES (1); +START TRANSACTION; +--error ER_ROW_IS_REFERENCED_2 +TRUNCATE TABLE t1; +SELECT * FROM t1; +ROLLBACK; +SELECT * FROM t1; ---echo switch to connection c2 -CONNECTION c2; -SET AUTOCOMMIT=0; ---error ER_LOCK_WAIT_TIMEOUT -LOCK TABLES t1 READ, t2 READ; +SET AUTOCOMMIT = 1; ---echo switch to connection c1 -CONNECTION c1; +START TRANSACTION; +SELECT * FROM t1; COMMIT; -INSERT INTO t1 VALUES (1); ---echo switch to connection default -CONNECTION default; -SET AUTOCOMMIT=default; -DISCONNECT c1; -DISCONNECT c2; -DROP TABLE t1,t2; +--error ER_ROW_IS_REFERENCED_2 +TRUNCATE TABLE t1; +SELECT * FROM t1; +DELETE FROM t2 WHERE id = 3; -# -# Bug #25798: a query with forced index merge returns wrong result -# +START TRANSACTION; +SELECT * FROM t1; +TRUNCATE TABLE t1; +ROLLBACK; +SELECT * FROM t1; +TRUNCATE TABLE t2; +DROP TABLE t2; +DROP TABLE t1; + +--echo # +--echo # Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0 +--echo # CREATE TABLE t1 ( - id int NOT NULL auto_increment PRIMARY KEY, - b int NOT NULL, - c datetime NOT NULL, - INDEX idx_b(b), - INDEX idx_c(c) + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + PRIMARY KEY (id) ) ENGINE=InnoDB; CREATE TABLE t2 ( - b int NOT NULL auto_increment PRIMARY KEY, - c datetime NOT NULL -) ENGINE= MyISAM; - -INSERT INTO t2(c) VALUES ('2007-01-01'); -INSERT INTO t2(c) SELECT c FROM t2; -INSERT INTO t2(c) SELECT c FROM t2; -INSERT INTO t2(c) SELECT c FROM t2; -INSERT INTO t2(c) SELECT c FROM t2; -INSERT INTO t2(c) SELECT c FROM t2; -INSERT INTO t2(c) SELECT c FROM t2; -INSERT INTO t2(c) SELECT c FROM t2; -INSERT INTO t2(c) SELECT c FROM t2; -INSERT INTO t2(c) SELECT c FROM t2; -INSERT INTO t2(c) SELECT c FROM t2; - -INSERT INTO t1(b,c) SELECT b,c FROM t2; -UPDATE t2 SET c='2007-01-02'; -INSERT INTO t1(b,c) SELECT b,c FROM t2; -UPDATE t2 SET c='2007-01-03'; -INSERT INTO t1(b,c) SELECT b,c FROM t2; - -set @@sort_buffer_size=8192; - -SELECT COUNT(*) FROM t1; - ---replace_column 9 # -EXPLAIN -SELECT COUNT(*) FROM t1 - WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; -SELECT COUNT(*) FROM t1 - WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; - ---replace_column 9 # -EXPLAIN -SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c) - WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; -SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c) - WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; - -set @@sort_buffer_size=default; - -DROP TABLE t1,t2; - + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + aid INT UNSIGNED NOT NULL, + PRIMARY KEY (id), + FOREIGN KEY (aid) REFERENCES t1 (id) +) ENGINE=InnoDB; -# Bug#27296 Assertion in ALTER TABLE SET DEFAULT in Linux Debug build -# (possible deadlock). -# -# The bug is applicable only to a transactoinal table. -# Cover with tests behavior that no longer causes an -# assertion. -# ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1 (a int) engine=innodb; -alter table t1 alter a set default 1; -drop table t1; +CREATE TABLE t3 ( + bid INT UNSIGNED NOT NULL, + FOREIGN KEY (bid) REFERENCES t2 (id) +) ENGINE=InnoDB; +CREATE TABLE t4 ( + a INT +) ENGINE=InnoDB; ---echo ---echo Bug#24918 drop table and lock / inconsistent between ---echo perm and temp tables ---echo ---echo Check transactional tables under LOCK TABLES ---echo ---disable_warnings -drop table if exists t24918, t24918_tmp, t24918_trans, t24918_trans_tmp, -t24918_access; ---enable_warnings -create table t24918_access (id int); -create table t24918 (id int) engine=myisam; -create temporary table t24918_tmp (id int) engine=myisam; -create table t24918_trans (id int) engine=innodb; -create temporary table t24918_trans_tmp (id int) engine=innodb; - -lock table t24918 write, t24918_tmp write, t24918_trans write, t24918_trans_tmp write; -drop table t24918; ---error ER_TABLE_NOT_LOCKED -select * from t24918_access; -drop table t24918_trans; ---error ER_TABLE_NOT_LOCKED -select * from t24918_access; -drop table t24918_trans_tmp; ---error ER_TABLE_NOT_LOCKED -select * from t24918_access; -drop table t24918_tmp; ---error ER_TABLE_NOT_LOCKED -select * from t24918_access; -unlock tables; - -drop table t24918_access; -# -# Bug #28591: MySQL need not sort the records in case of ORDER BY -# primary_key on InnoDB table -# +CREATE TABLE t5 ( + a INT +) ENGINE=InnoDB; -CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY bkey (b)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1,2),(3,2),(2,2),(4,2),(5,2),(6,2),(7,2),(8,2); -INSERT INTO t1 SELECT a + 8, 2 FROM t1; -INSERT INTO t1 SELECT a + 16, 1 FROM t1; -query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a; -SELECT * FROM t1 WHERE b=2 ORDER BY a; -query_vertical EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a; -SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a; -query_vertical EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY b,a; -SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY b,a; - -CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a), KEY bkey (b,c)) - ENGINE=InnoDB; -INSERT INTO t2 VALUES (1,1,1),(3,1,1),(2,1,1),(4,1,1); -INSERT INTO t2 SELECT a + 4, 1, 1 FROM t2; -INSERT INTO t2 SELECT a + 8, 1, 1 FROM t2; - -query_vertical EXPLAIN SELECT * FROM t2 WHERE b=1 ORDER BY a; -SELECT * FROM t2 WHERE b=1 ORDER BY a; -query_vertical EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY a; -SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY a; -query_vertical EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY b,c,a; -SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY b,c,a; -query_vertical EXPLAIN SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY c,a; -SELECT * FROM t2 WHERE b=1 AND c=1 ORDER BY c,a; +INSERT INTO t1 (id) VALUES (1); +INSERT INTO t2 (id, aid) VALUES (1, 1),(2,1),(3,1),(4,1); +INSERT INTO t3 (bid) VALUES (1); -DROP TABLE t1,t2; +INSERT INTO t4 VALUES (1),(2),(3),(4),(5); +INSERT INTO t5 VALUES (1); +DELETE t5 FROM t4 LEFT JOIN t5 ON t4.a= t5.a; -# -# Bug #29644: alter table hangs if records locked in share mode by long -# running transaction -# +--error ER_ROW_IS_REFERENCED_2 +DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1; +--error ER_ROW_IS_REFERENCED_2 +DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1; -CREATE TABLE t1 (a INT, PRIMARY KEY (a)) ENGINE=InnoDB; +DELETE IGNORE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1; -INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8); -INSERT INTO t1 SELECT a + 8 FROM t1; -INSERT INTO t1 SELECT a + 16 FROM t1; +DROP TABLE t3; +DROP TABLE t2; +DROP TABLE t1; +DROP TABLES t4,t5; -DELIMITER |; -CREATE PROCEDURE p1 () +--echo # Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0 +--echo # Testing for any side effects of IGNORE on AFTER DELETE triggers used with +--echo # transactional tables. +--echo # +CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (a VARCHAR(100)) ENGINE=InnoDB; +CREATE TABLE t3 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t4 (i INT NOT NULL PRIMARY KEY, t1i INT, + FOREIGN KEY (t1i) REFERENCES t1(i)) + ENGINE=InnoDB; +delimiter ||; +CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW BEGIN - DECLARE i INT DEFAULT 50; - DECLARE cnt INT; - START TRANSACTION; - ALTER TABLE t1 ENGINE=InnoDB; - COMMIT; - START TRANSACTION; - WHILE (i > 0) DO - SET i = i - 1; - SELECT COUNT(*) INTO cnt FROM t1 LOCK IN SHARE MODE; - END WHILE; - COMMIT; -END;| - -DELIMITER ;| - -CONNECT (con1,localhost,root,,); -CONNECT (con2,localhost,root,,); - -CONNECTION con1; -SEND CALL p1(); -CONNECTION con2; -SEND CALL p1(); -CONNECTION default; -CALL p1(); - -CONNECTION con1; -REAP; -CONNECTION con2; -REAP; -CONNECTION default; -DISCONNECT con1; -DISCONNECT con2; - -DROP PROCEDURE p1; + SET @b:='EXECUTED TRIGGER'; + INSERT INTO t2 VALUES (@b); + SET @a:= error_happens_here; +END|| +delimiter ;|| + +SET @b:=""; +SET @a:=""; +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t3 SELECT * FROM t1; +--echo ** An error in a trigger causes rollback of the statement. +--error ER_BAD_FIELD_ERROR +DELETE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +SELECT @a,@b; +SELECT * FROM t2; +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; + +--echo ** Same happens with the IGNORE option +--error ER_BAD_FIELD_ERROR +DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +SELECT * FROM t2; +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; + +--echo ** +--echo ** The following is an attempt to demonstrate +--echo ** error handling inside a row iteration. +--echo ** +DROP TRIGGER trg; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; + +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t3 VALUES (1),(2),(3),(4); +INSERT INTO t4 VALUES (3,3),(4,4); + +delimiter ||; +CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW +BEGIN + SET @b:= CONCAT('EXECUTED TRIGGER FOR ROW ',CAST(OLD.i AS CHAR)); + INSERT INTO t2 VALUES (@b); +END|| +delimiter ;|| + +--echo ** DELETE is prevented by foreign key constrains but errors are silenced. +--echo ** The AFTER trigger isn't fired. +DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +--echo ** Tables are modified by best effort: +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; +--echo ** The AFTER trigger was only executed on successful rows: +SELECT * FROM t2; + +DROP TRIGGER trg; + +--echo ** +--echo ** Induce an error midway through an AFTER-trigger +--echo ** +TRUNCATE TABLE t4; +TRUNCATE TABLE t1; +TRUNCATE TABLE t3; +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t3 VALUES (1),(2),(3),(4); +delimiter ||; +CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW +BEGIN + SET @a:= @a+1; + IF @a > 2 THEN + INSERT INTO t4 VALUES (5,5); + END IF; +END|| +delimiter ;|| + +SET @a:=0; +--echo ** Errors in the trigger causes the statement to abort. +--error ER_NO_REFERENCED_ROW_2 +DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i; +SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i; +SELECT * FROM t4; + +DROP TRIGGER trg; +DROP TABLE t4; DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; # -# Bug #28125: ERROR 2013 when adding index. -# -create table t1(a text) engine=innodb default charset=utf8; -insert into t1 values('aaa'); -alter table t1 add index(a(1024)); -show create table t1; -drop table t1; -# Bug #28570: handler::index_read() is called with different find_flag when -# ORDER BY is used +# Bug#43580: Issue with Innodb on multi-table update # +CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB; +CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; -CREATE TABLE t1 ( - a INT, - b INT, - KEY (b) -) ENGINE=InnoDB; - -INSERT INTO t1 VALUES (1,10), (2,10), (2,20), (3,30); - -START TRANSACTION; -SELECT * FROM t1 WHERE b=20 FOR UPDATE; +CREATE TABLE t3 (a INT, b INT KEY, KEY (a)) ENGINE = INNODB; +CREATE TABLE t4 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; ---connect (conn2, localhost, root,,test) +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); -# This statement gives a "failed: 1205: Lock wait timeout exceeded; try -# restarting transaction" message when the bug is present. -START TRANSACTION; -SELECT * FROM t1 WHERE b=10 ORDER BY A FOR UPDATE; -ROLLBACK; +INSERT INTO t3 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); ---disconnect conn2 ---connection default +UPDATE t1, t2 SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b; +--sorted_result +SELECT * FROM t2; -ROLLBACK; -DROP TABLE t1; +UPDATE t3, t4 SET t3.a = t3.a + 100, t4.b = t3.a + 10 +WHERE t3.a BETWEEN 2 AND 4 AND t4.a = t3.b - 100; +--sorted_result +SELECT * FROM t4; -# -# Bug#30596: GROUP BY optimization gives wrong result order -# -CREATE TABLE t1( - a INT, - b INT NOT NULL, - c INT NOT NULL, - d INT, - UNIQUE KEY (c,b) -) engine=innodb; +DROP TABLE t1, t2, t3, t4; -INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4); - -EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d; -SELECT c,b,d FROM t1 GROUP BY c,b,d; -EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; -SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; -EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d; -SELECT c,b,d FROM t1 ORDER BY c,b,d; - -EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b; -SELECT c,b,d FROM t1 GROUP BY c,b; -EXPLAIN SELECT c,b FROM t1 GROUP BY c,b; -SELECT c,b FROM t1 GROUP BY c,b; - -DROP TABLE t1; - -# -# Bug #31001: ORDER BY DESC in InnoDB not working -# -CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), INDEX b (b)) ENGINE=InnoDB; -INSERT INTO t1(a,b) VALUES (1,1), (2,2), (3,2); - -#The two queries below should produce different results, but they don't. -query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a ASC; -SELECT * FROM t1 WHERE b=2 ORDER BY a ASC; -query_vertical EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a DESC; -SELECT * FROM t1 WHERE b=2 ORDER BY a DESC; - -query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a ASC; -SELECT * FROM t1 ORDER BY b ASC, a ASC; -query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a DESC; -SELECT * FROM t1 ORDER BY b DESC, a DESC; -query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a DESC; -SELECT * FROM t1 ORDER BY b ASC, a DESC; -query_vertical EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a ASC; -SELECT * FROM t1 ORDER BY b DESC, a ASC; - -DROP TABLE t1; - -# -# Bug #32815: query with ORDER BY and a possible ref_or_null access -# - -CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB; -INSERT INTO t1 VALUES - (191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2); +--echo # +--echo # Bug#44886: SIGSEGV in test_if_skip_sort_order() - +--echo # uninitialized variable used as subscript +--echo # -EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d; -SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d; +CREATE TABLE t1 (a INT, b INT, c INT, d INT, PRIMARY KEY (b), KEY (a,c)) + ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1,0); -DROP TABLE t1; +CREATE TABLE t2 (a INT, b INT, e INT, KEY (e)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,1,2); +CREATE TABLE t3 (a INT, b INT) ENGINE=MyISAM; +INSERT INTO t3 VALUES (1, 1); -# Bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0 -# -create table t1(a char(10) not null, unique key aa(a(1)), - b char(4) not null, unique key bb(b(4))) engine=innodb; -desc t1; -show create table t1; -drop table t1; +SELECT * FROM t1, t2, t3 + WHERE t1.a = t3.a AND (t1.b = t3.b OR t1.d) AND t2.b = t1.b AND t2.e = 2 + GROUP BY t1.b; +DROP TABLE t1, t2, t3; -# -# Bug #34223: Assertion failed: (optp->var_type & 127) == 8, -# file .\my_getopt.c, line 830 -# +--echo # +--echo # Bug #45828: Optimizer won't use partial primary key if another +--echo # index can prevent filesort +--echo # -set @my_innodb_autoextend_increment=@@global.innodb_autoextend_increment; -set global innodb_autoextend_increment=8; -set global innodb_autoextend_increment=@my_innodb_autoextend_increment; +# Create the table +CREATE TABLE `t1` ( + c1 int NOT NULL, + c2 int NOT NULL, + c3 int NOT NULL, + PRIMARY KEY (c1,c2), + KEY (c3) +) ENGINE=InnoDB; -set @my_innodb_commit_concurrency=@@global.innodb_commit_concurrency; -set global innodb_commit_concurrency=0; -set global innodb_commit_concurrency=@my_innodb_commit_concurrency; +# populate with data +INSERT INTO t1 VALUES (5,2,1246276747); +INSERT INTO t1 VALUES (2,1,1246281721); +INSERT INTO t1 VALUES (7,3,1246281756); +INSERT INTO t1 VALUES (4,2,1246282139); +INSERT INTO t1 VALUES (3,1,1246282230); +INSERT INTO t1 VALUES (1,0,1246282712); +INSERT INTO t1 VALUES (8,3,1246282765); +INSERT INTO t1 SELECT c1+10,c2+10,c3+10 FROM t1; +INSERT INTO t1 SELECT c1+100,c2+100,c3+100 from t1; +INSERT INTO t1 SELECT c1+1000,c2+1000,c3+1000 from t1; +INSERT INTO t1 SELECT c1+10000,c2+10000,c3+10000 from t1; +INSERT INTO t1 SELECT c1+100000,c2+100000,c3+100000 from t1; +INSERT INTO t1 SELECT c1+1000000,c2+1000000,c3+1000000 from t1; -# -# Bug #37830: ORDER BY ASC/DESC - no difference -# +# query and no rows will match the c1 condition, whereas all will match c3 +SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; -CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY (a), KEY t1_b (b)) - ENGINE=InnoDB; +# SHOULD use the pk. +# index on c3 will be used instead of primary key +EXPLAIN SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; -INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1); -INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1; +# if we force the primary key, we can see the estimate is 1 +EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; -# should be range access -EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5; -# should produce '8 7 6 5 4' for a -SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5; +CREATE TABLE t2 ( + c1 int NOT NULL, + c2 int NOT NULL, + c3 int NOT NULL, + KEY (c1,c2), + KEY (c3) +) ENGINE=InnoDB; -DROP TABLE t1; +# SHOULD use the pk. +# if we switch it from a primary key to a regular index, it works correctly as well +explain SELECT * FROM t2 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; -# -# Bug#37284 Crash in Field_string::type() -# ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings -CREATE TABLE t1 (a char(50)) ENGINE=InnoDB; -CREATE INDEX i1 on t1 (a(3)); -SELECT * FROM t1 WHERE a = 'abcde'; -DROP TABLE t1; +DROP TABLE t1,t2; --echo # ---echo # BUG #26288: savepoint are not deleted on comit, if the transaction ---echo # was otherwise empty +--echo # 36259: Optimizing with ORDER BY --echo # -BEGIN; -SAVEPOINT s1; -COMMIT; ---error 1305 -RELEASE SAVEPOINT s1; - -BEGIN; -SAVEPOINT s2; -COMMIT; ---error 1305 -ROLLBACK TO SAVEPOINT s2; -BEGIN; -SAVEPOINT s3; -ROLLBACK; ---error 1305 -RELEASE SAVEPOINT s3; - -BEGIN; -SAVEPOINT s4; -ROLLBACK; ---error 1305 -ROLLBACK TO SAVEPOINT s4; +CREATE TABLE t1 ( + a INT NOT NULL AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL, + d VARCHAR(5), + e INT NOT NULL, + PRIMARY KEY (a), KEY i2 (b,c,d) +) ENGINE=InnoDB; -# -# Bug#39793 Foreign keys not constructed when column has a '#' in a comment or default value -# +INSERT INTO t1 (b,c,d,e) VALUES (1,1,'a',1), (2,2,'b',2); +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +EXPLAIN SELECT * FROM t1 WHERE b=1 AND c=1 ORDER BY a; +EXPLAIN SELECT * FROM t1 FORCE INDEX(i2) WHERE b=1 and c=1 ORDER BY a; +EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a; -#This statement should be written on a single line for proper testing -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY COMMENT 'My ID#', f2 INTEGER DEFAULT NULL, f3 CHAR(10) DEFAULT 'My ID#', CONSTRAINT f2_ref FOREIGN KEY (f2) REFERENCES t1 (f1)) ENGINE=INNODB; -SHOW CREATE TABLE t1; DROP TABLE t1; --echo # ---echo # Bug #36995: valgrind error in remove_const during subquery executions +--echo # Bug #47963: Wrong results when index is used --echo # +CREATE TABLE t1( + a VARCHAR(5) NOT NULL, + b VARCHAR(5) NOT NULL, + c DATETIME NOT NULL, + KEY (c) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES('TEST', 'TEST', '2009-10-09 00:00:00'); +SELECT * FROM t1 WHERE a = 'TEST' AND + c >= '2009-10-09 00:00:00' AND c <= '2009-10-09 00:00:00'; +SELECT * FROM t1 WHERE a = 'TEST' AND + c >= '2009-10-09 00:00:00.0' AND c <= '2009-10-09 00:00:00.0'; +SELECT * FROM t1 WHERE a = 'TEST' AND + c >= '2009-10-09 00:00:00.0' AND c <= '2009-10-09 00:00:00'; +SELECT * FROM t1 WHERE a = 'TEST' AND + c >= '2009-10-09 00:00:00' AND c <= '2009-10-09 00:00:00.0'; +SELECT * FROM t1 WHERE a = 'TEST' AND + c >= '2009-10-09 00:00:00.000' AND c <= '2009-10-09 00:00:00.000'; +SELECT * FROM t1 WHERE a = 'TEST' AND + c >= '2009-10-09 00:00:00.00' AND c <= '2009-10-09 00:00:00.001'; +SELECT * FROM t1 WHERE a = 'TEST' AND + c >= '2009-10-09 00:00:00.001' AND c <= '2009-10-09 00:00:00.00'; +EXPLAIN SELECT * FROM t1 WHERE a = 'TEST' AND + c >= '2009-10-09 00:00:00.001' AND c <= '2009-10-09 00:00:00.00'; +DROP TABLE t1; -create table t1 (a bit(1) not null,b int) engine=myisam; -create table t2 (c int) engine=innodb; -explain -select b from t1 where a not in (select b from t1,t2 group by a) group by a; -DROP TABLE t1,t2; ---echo End of 5.0 tests +--echo End of 5.1 tests diff --git a/mysql-test/t/innodb_mysql_rbk-master.opt b/mysql-test/t/innodb_mysql_rbk-master.opt new file mode 100644 index 00000000000..0e400f9c36b --- /dev/null +++ b/mysql-test/t/innodb_mysql_rbk-master.opt @@ -0,0 +1 @@ +--innodb_lock_wait_timeout=1 --innodb_rollback_on_timeout=1 diff --git a/mysql-test/t/innodb_mysql_rbk.test b/mysql-test/t/innodb_mysql_rbk.test new file mode 100644 index 00000000000..d2368c81f95 --- /dev/null +++ b/mysql-test/t/innodb_mysql_rbk.test @@ -0,0 +1,35 @@ +-- source include/have_innodb.inc + +# +# Bug #41453: Assertion `m_status == DA_ERROR' failed in +# Diagnostics_area::sql_errno +# + +CREATE TABLE t1(a INT, b INT NOT NULL, PRIMARY KEY (a)) ENGINE=innodb +DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7); +CONNECT (con1,localhost,root,,); +CONNECT (con2,localhost,root,,); + +CONNECTION con1; +START TRANSACTION; +SELECT * FROM t1 WHERE b=3 LIMIT 1 FOR UPDATE; +CONNECTION con2; +START TRANSACTION; +--error ER_LOCK_WAIT_TIMEOUT +UPDATE t1 SET b=b+12 WHERE a > 2 ORDER BY a; +ROLLBACK; + +CONNECTION con1; +START TRANSACTION; +SELECT * FROM t1 WHERE b=3 LIMIT 1 FOR UPDATE; +CONNECTION con2; +START TRANSACTION; +--error ER_LOCK_WAIT_TIMEOUT +UPDATE t1 SET b=10 WHERE a > 1 ORDER BY a; +SELECT * FROM t1 WHERE b = 10; + +CONNECTION default; +DISCONNECT con1; +DISCONNECT con2; +DROP TABLE t1; diff --git a/mysql-test/t/innodb_notembedded.test b/mysql-test/t/innodb_notembedded.test index 4c29781184d..c74dc931505 100644 --- a/mysql-test/t/innodb_notembedded.test +++ b/mysql-test/t/innodb_notembedded.test @@ -5,6 +5,8 @@ drop table if exists t1; --enable_warnings +SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; + connect (a,localhost,root,,); connect (b,localhost,root,,); @@ -13,6 +15,7 @@ connect (b,localhost,root,,); # BUG#11238 - in prelocking mode SELECT .. FOR UPDATE is changed to # non-blocking SELECT # +SET GLOBAL log_bin_trust_function_creators = 1; create table t1 (col1 integer primary key, col2 integer) engine=innodb; insert t1 values (1,100); delimiter |; @@ -44,4 +47,4 @@ disconnect b; connection default; drop table t1; drop function f1; - +SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators; diff --git a/mysql-test/t/innodb_trx_weight.test b/mysql-test/t/innodb_trx_weight.test new file mode 100644 index 00000000000..b72eaad345f --- /dev/null +++ b/mysql-test/t/innodb_trx_weight.test @@ -0,0 +1,108 @@ +# +# Ensure that the number of locks (SELECT FOR UPDATE for example) is +# added to the number of altered rows when choosing the smallest +# transaction to kill as a victim when a deadlock is detected. +# Also transactions what had edited non-transactional tables should +# be heavier than ones that had not. +# + +-- source include/have_innodb.inc + +SET storage_engine=InnoDB; + +# we do not really care about what gets printed, we are only +# interested in getting the deadlock resolved according to our +# expectations +-- disable_query_log +-- disable_result_log + +# we want to use "-- eval statement1; statement2" which does not work with +# prepared statements. Because this test should not behave differently with +# or without prepared statements we disable them so the test does not fail +# if someone runs ./mysql-test-run.pl --ps-protocol +-- disable_ps_protocol + +-- disable_warnings +DROP TABLE IF EXISTS t1, t2, t3, t4, t5_nontrans; +-- enable_warnings + +# we will create a simple deadlock with t1, t2 and two connections +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); + +# auxiliary table with a bulk of rows which will be locked by a +# transaction to increase its weight +CREATE TABLE t3 (a INT); + +# auxiliary empty table which will be inserted by a +# transaction to increase its weight +CREATE TABLE t4 (a INT); + +# auxiliary non-transactional table which will be edited by a +# transaction to tremendously increase its weight +CREATE TABLE t5_nontrans (a INT) ENGINE=MyISAM; + +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +# insert a lot of rows in t3 +INSERT INTO t3 VALUES (1); +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t3; + +# test locking weight + +-- let $con1_extra_sql = +-- let $con1_extra_sql_present = 0 +-- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE +-- let $con2_extra_sql_present = 1 +-- let $con1_should_be_rolledback = 1 +-- source include/innodb_trx_weight.inc + +-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1) +-- let $con1_extra_sql_present = 1 +-- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE +-- let $con2_extra_sql_present = 1 +-- let $con1_should_be_rolledback = 1 +-- source include/innodb_trx_weight.inc + +-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1), (1), (1), (1) +-- let $con1_extra_sql_present = 1 +-- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE +-- let $con2_extra_sql_present = 1 +-- let $con1_should_be_rolledback = 0 +-- source include/innodb_trx_weight.inc + +# test weight when non-transactional tables are edited + +-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1) +-- let $con1_extra_sql_present = 1 +-- let $con2_extra_sql = +-- let $con2_extra_sql_present = 0 +-- let $con1_should_be_rolledback = 0 +-- source include/innodb_trx_weight.inc + +-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1) +-- let $con1_extra_sql_present = 1 +-- let $con2_extra_sql = INSERT INTO t5_nontrans VALUES (1) +-- let $con2_extra_sql_present = 1 +-- let $con1_should_be_rolledback = 1 +-- source include/innodb_trx_weight.inc + +-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1) +-- let $con1_extra_sql = $con1_extra_sql; INSERT INTO t5_nontrans VALUES (1) +-- let $con1_extra_sql_present = 1 +-- let $con2_extra_sql = INSERT INTO t5_nontrans VALUES (1) +-- let $con2_extra_sql_present = 1 +-- let $con1_should_be_rolledback = 0 +-- source include/innodb_trx_weight.inc + +DROP TABLE t1, t2, t3, t4, t5_nontrans; diff --git a/mysql-test/t/innodb_unsafe_binlog-master.opt b/mysql-test/t/innodb_unsafe_binlog-master.opt deleted file mode 100644 index 5c0136b5db3..00000000000 --- a/mysql-test/t/innodb_unsafe_binlog-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-innodb_locks_unsafe_for_binlog=true diff --git a/mysql-test/t/innodb_unsafe_binlog.test b/mysql-test/t/innodb_unsafe_binlog.test deleted file mode 100644 index fa240eb7608..00000000000 --- a/mysql-test/t/innodb_unsafe_binlog.test +++ /dev/null @@ -1,67 +0,0 @@ --- source include/have_innodb.inc -# -# Note that these tests uses a innodb_locks_unsafe_for_binlog option. -# -# Test cases for a bug #15650 DELETE with LEFT JOIN crashes server -# - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings -create table t1 (id int not null, f_id int not null, f int not null, -primary key(f_id, id)) engine=innodb; -create table t2 (id int not null,s_id int not null,s varchar(200), -primary key(id)) engine=innodb; -INSERT INTO t1 VALUES (8, 1, 3); -INSERT INTO t1 VALUES (1, 2, 1); -INSERT INTO t2 VALUES (1, 0, ''); -INSERT INTO t2 VALUES (8, 1, ''); -commit; -DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id) -WHERE mm.id IS NULL; -select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id) -where mm.id is null lock in share mode; -drop table t1,t2; - -create table t1 (id int not null, f_id int not null, f int not null, -primary key(id),key(f_id)) engine=innodb; -create table t2 (id int not null,s_id int not null,s varchar(200), -primary key(id),key(s_id)) engine=innodb; -INSERT INTO t1 VALUES (8, 1, 3); -INSERT INTO t1 VALUES (1, 2, 1); -INSERT INTO t2 VALUES (1, 0, ''); -INSERT INTO t2 VALUES (8, 1, ''); -commit; -delete ml.* from t1 as ml left join t2 as mm on (mm.s_id=ml.f_id) where mm.s is null; -select ml.* from t1 as ml left join t2 as mm on (mm.s_id=ml.f_id) where mm.s is null lock in share mode; -drop table t1,t2; - -# -# Test case for unlock row bug where unlock releases all locks granted for -# a row. Only the latest lock should be released. -# - -connect (a,localhost,root,,); -connect (b,localhost,root,,); -connection a; -create table t1(a int not null, b int, primary key(a)) engine=innodb; -insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2); -commit; -set autocommit = 0; -select * from t1 lock in share mode; -update t1 set b = 5 where b = 1; -connection b; -set autocommit = 0; -# -# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update -# ---error 1205 -select * from t1 where a = 2 and b = 2 for update; -connection a; -commit; -connection b; -commit; -drop table t1; -disconnect a; -disconnect b; - diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index a1735c1a91f..8f9ed6c7d06 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -9,8 +9,8 @@ drop table if exists t1,t2,t3; create table t1 (a int not null); insert into t1 values (1); insert into t1 values (a+2); -insert into t1 values (a+3); -insert into t1 values (4),(a+5); +insert into t1 values (a+3),(a+4); +insert into t1 values (5),(a+6); select * from t1; drop table t1; @@ -177,6 +177,32 @@ select count(*) from t2; drop table t1,t2,t3; # +# Test different cases of duplicate fields +# + +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); +prepare stmt1 from ' replace into t1 (a,a) select 100, ''hundred'' '; +--error 1110 +execute stmt1; +--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; + +# # Test for values returned by ROW_COUNT() function # (and thus for values returned by mysql_affected_rows()) # for various forms of INSERT @@ -216,6 +242,14 @@ select * from t1; drop view v1; drop table t1,t2; +# Test of INSERT IGNORE and re-using auto_increment values +create table t1 (id int primary key auto_increment, data int, unique(data)); +insert ignore into t1 values(NULL,100),(NULL,110),(NULL,120); +insert ignore into t1 values(NULL,10),(NULL,20),(NULL,110),(NULL,120),(NULL,100),(NULL,90); +insert ignore into t1 values(NULL,130),(NULL,140),(500,110),(550,120),(450,100),(NULL,150); +select * from t1 order by id; + +drop table t1; # # BUG#21483: Server abort or deadlock on INSERT DELAYED with another diff --git a/mysql-test/t/insert_notembedded.test b/mysql-test/t/insert_notembedded.test index bdea72e9eca..24040f9c310 100644 --- a/mysql-test/t/insert_notembedded.test +++ b/mysql-test/t/insert_notembedded.test @@ -152,3 +152,38 @@ disconnect root; connection default; DROP DATABASE meow; + +# +# Bug#28587 SELECT is blocked by INSERT waiting on read lock, even with low_priority_updates +# +--echo connection: default +set low_priority_updates=1; +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int, b int, unique key t1$a (a)); +lock table t1 read; +connect (update,localhost,root,,); +connection update; +--echo connection: update +set low_priority_updates=1; +show variables like 'low_priority_updates'; +let $ID= `select connection_id()`; +--send insert into t1 values (1, 2) ON DUPLICATE KEY UPDATE b = 2; +connection default; +# we must wait till the insert opens and locks the table +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and id = $ID; +--source include/wait_condition.inc +connect (select,localhost,root,,); +--echo connection: select +select * from t1; +connection default; +--echo connection: default +select * from t1; +connection default; +disconnect update; +disconnect select; +drop table t1; +set low_priority_updates=default; diff --git a/mysql-test/t/insert_select-binlog.test b/mysql-test/t/insert_select-binlog.test deleted file mode 100644 index 4bff09577a7..00000000000 --- a/mysql-test/t/insert_select-binlog.test +++ /dev/null @@ -1,36 +0,0 @@ -# Embedded server doesn't support binlog --- source include/not_embedded.inc --- source include/have_log_bin.inc - -# Check if a partly-completed INSERT SELECT in a MyISAM table goes into the -# binlog - -create table t1(a int, unique(a)); -insert into t1 values(2); -create table t2(a int); -insert into t2 values(1),(2); -reset master; ---error 1062 -insert into t1 select * from t2; -# The above should produce an error, but still be in the binlog; -# verify the binlog : -let $VERSION=`select version()`; ---replace_result $VERSION VERSION -show binlog events; -select * from t1; -drop table t1, t2; - -# Verify that a partly-completed CREATE TABLE .. SELECT does not -# get into the binlog (Bug #6682) -create table t1(a int); -insert into t1 values(1),(1); -reset master; ---error 1062 -create table t2(unique(a)) select a from t1; -# The above should produce an error, *and* not appear in the binlog -let $VERSION=`select version()`; ---replace_result $VERSION VERSION -show binlog events; -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 06ed858b696..7318e45889a 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -10,7 +10,7 @@ create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLI insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12); create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY); insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1; ---error 1062 +--error ER_DUP_ENTRY insert into t2 (payoutID) SELECT payoutID+10 FROM t1; insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1; select * from t2; @@ -101,7 +101,7 @@ create table t1 (a int not null primary key, b char(10)); create table t2 (a int not null, b char(10)); insert into t1 values (1,"t1:1"),(3,"t1:3"); insert into t2 values (2,"t2:2"), (3,"t2:3"); ---error 1062 +--error ER_DUP_ENTRY insert into t1 select * from t2; select * from t1; # REPLACE .. SELECT is not yet supported by PS @@ -311,19 +311,6 @@ select * from t1; drop table t1; # -# Bug#23170: LAST_INSERT_ID isn't reset to 0 in INSERT .. SELECT if no rows -# were inserted. -# -create table t1(f1 int primary key auto_increment, f2 int unique); -insert into t1(f2) values(1); -select @@identity; -insert ignore t1(f2) values(1); -select @@identity; -insert ignore t1(f2) select 1; -select @@identity; -drop table t1; - -# # Bug#16630: wrong result, when INSERT t1 SELECT ... FROM t1 ON DUPLICATE # CREATE TABLE t1 (f1 INT, f2 INT ); @@ -337,6 +324,16 @@ SELECT * FROM t2; DROP TABLE t1, t2; # +# Bug#44306: Assertion fail on duplicate key error in 'INSERT ... SELECT' +# statements +# +CREATE TABLE t1 ( a INT KEY, b INT ); +INSERT INTO t1 VALUES ( 0, 1 ); +--error ER_DUP_ENTRY +INSERT INTO t1 ( b ) SELECT MAX( b ) FROM t1 WHERE b = 2; +DROP TABLE t1; + +# # Bug #26207: inserts don't work with shortened index # SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; @@ -410,7 +407,8 @@ SET GLOBAL myisam_data_pointer_size = 2; INSERT INTO t1 VALUES (1), (2), (3), (4), (5); ---error ER_RECORD_FILE_FULL +call mtr.add_suppression("mysqld: The table '.*#sql.*' is full"); +--error ER_RECORD_FILE_FULL,ER_RECORD_FILE_FULL INSERT IGNORE INTO t1 SELECT t1.a FROM t1,t1 t2,t1 t3,t1 t4,t1 t5,t1 t6,t1 t7; # Cleanup diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 6c4de33950e..1cd05c8cb65 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -660,5 +660,93 @@ explain select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b; show status like 'Handler_read%'; drop table t1, t2, t3; +# +# BUG#14940: Make E(#rows) from "range" access be re-used by range optimizer +# +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t2 (a int, b int, filler char(100), key(a), key(b)); +create table t3 (a int, b int, filler char(100), key(a), key(b)); + +insert into t2 + select @a:= A.a + 10*(B.a + 10*C.a), @a, 'filler' from t1 A, t1 B, t1 C; +insert into t3 select * from t2 where a < 800; + +# The order of tables must be t2,t3: +explain select * from t2,t3 where t2.a < 200 and t2.b=t3.b; + +drop table t1, t2, t3; + +# BUG#14940 {Wrong query plan is chosen because of odd results of +# prev_record_reads() function } +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t2 (a int, b int, primary key(a)); +insert into t2 select @v:=A.a+10*B.a, @v from t1 A, t1 B; + +explain select * from t1; +show status like '%cost%'; +select 'The cost of accessing t1 (dont care if it changes' '^'; + +select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z; + +explain select * from t1, t2 A, t2 B where A.a = t1.a and B.a=A.b; +show status like '%cost%'; +select '^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error' Z; + + + +drop table t1, t2; + +# +# Bug #31094: Forcing index-based sort doesn't work anymore if joins are +# done +# + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +CREATE TABLE t2 (c INT PRIMARY KEY, d INT); + +INSERT INTO t1 VALUES(1,NULL),(2,NULL),(3,NULL),(4,NULL); +INSERT INTO t1 SELECT a + 4, b FROM t1; +INSERT INTO t1 SELECT a + 8, b FROM t1; +INSERT INTO t1 SELECT a + 16, b FROM t1; +INSERT INTO t1 SELECT a + 32, b FROM t1; +INSERT INTO t1 SELECT a + 64, b FROM t1; +INSERT INTO t2 SELECT a, b FROM t1; + +#expect indexed ORDER BY +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; + +#expect filesort +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; + +DROP TABLE IF EXISTS t1,t2; --echo End of 5.0 tests. + + +# +# Bug#47150 Assertion in Field_long::val_int() on MERGE + TRIGGER + multi-table UPDATE +# +CREATE TABLE t1 (f1 int); + +CREATE TABLE t2 (f1 int); +INSERT INTO t2 VALUES (1); +CREATE VIEW v1 AS SELECT * FROM t2; + +PREPARE stmt FROM 'UPDATE t2 AS A NATURAL JOIN v1 B SET B.f1 = 1'; +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +DROP VIEW v1; +DROP TABLE t1, t2; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 1a59dbf8fc2..35aec71ebb8 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -97,7 +97,7 @@ WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); ---error 1062 +--error ER_DUP_ENTRY INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); @@ -760,6 +760,12 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a > IF(t1.a = t2.b DROP TABLE t1,t2; # +# Test for bug #17164: ORed FALSE blocked conversion of outer join into join +# + +# Test case moved to join_outer_innodb + +# # Bug 19396: LEFT OUTER JOIN over views in curly braces # --disable_warnings diff --git a/mysql-test/t/join_outer_innodb.test b/mysql-test/t/join_outer_innodb.test new file mode 100644 index 00000000000..40add7f488f --- /dev/null +++ b/mysql-test/t/join_outer_innodb.test @@ -0,0 +1,26 @@ +# +# test of left outer join for tests that depends on innodb +# + +--source include/have_innodb.inc + +# +# Test for bug #17164: ORed FALSE blocked conversion of outer join into join +# + +CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20), + INDEX (name)) ENGINE=InnoDB; +CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11), + FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B'); +INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3); + +EXPLAIN +SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id + WHERE t1.name LIKE 'A%'; + +EXPLAIN +SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id + WHERE t1.name LIKE 'A%' OR FALSE; + +DROP TABLE t1,t2; diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index f63336a9864..9a4158d8e13 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -150,7 +150,7 @@ create table t1 ); INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); INSERT INTO t1 VALUES (1, 1, 1, 1, 'b'); ---error 1062 +--error ER_DUP_ENTRY INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); drop table t1; @@ -243,13 +243,13 @@ show create table t1; insert t1 values ('cccc', 'tttt'), (0xD0B1212223D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1212223D0B1D0B1D0B1D0B1), (0xD0B1222123D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1222123D0B1D0B1D0B1D0B1); ---error 1062 +--error ER_DUP_ENTRY insert t1 (c) values ('cc22'); ---error 1062 +--error ER_DUP_ENTRY insert t1 (t) values ('ttt22'); ---error 1062 +--error ER_DUP_ENTRY insert t1 (c) values (0xD0B1212322D0B1D0B1D0B1D0B1D0B1); ---error 1062 +--error ER_DUP_ENTRY insert t1 (t) values (0xD0B1D0B1212322D0B1D0B1D0B1D0B1); select c from t1 where c='cccc'; select t from t1 where t='tttt'; @@ -386,6 +386,75 @@ drop table t1; # End of 4.1 tests # +# WL#1563 - Modify MySQL to support on-line CREATE/DROP INDEX +# To test if this really works, you need to run with --debug +# and check the trace file. +# +# Create a table with named and unnamed indexes. +create table t1 ( + c1 int, + c2 char(12), + c3 varchar(123), + c4 timestamp, + index (c1), + index i1 (c1), + index i2 (c2), + index i3 (c3), + unique i4 (c4), + index i5 (c1, c2, c3, c4), + primary key (c2, c3), + index (c2, c4)); +show create table t1; +# Some simple tests. +alter table t1 drop index c1; +alter table t1 add index (c1); +# This creates index 'c1_2'. +alter table t1 add index (c1); +alter table t1 drop index i3; +alter table t1 add index i3 (c3); +# Two indexes at the same time. +alter table t1 drop index i2, drop index i4; +alter table t1 add index i2 (c2), add index i4 (c4); +# Three indexes, one of them reversely. +alter table t1 drop index i2, drop index i4, add index i6 (c2, c4); +alter table t1 add index i2 (c2), add index i4 (c4), drop index i6; +# include an unique index. +alter table t1 drop index i2, drop index i4, add unique i4 (c4); +alter table t1 add index i2 (c2), drop index i4, add index i4 (c4); +# Modify an index by changing its definition. +alter table t1 drop index c2, add index (c2(4),c3(7)); +# Change nothing. The new key definition is the same as the old one. +alter table t1 drop index c2, add index (c2(4),c3(7)); +# Test primary key handling. +alter table t1 add primary key (c1, c2), drop primary key; +alter table t1 drop primary key; +# Drop is checked first. Primary key must exist. +--error 1091 +alter table t1 add primary key (c1, c2), drop primary key; +show create table t1; +# Insert non-unique values. +insert into t1 values(1, 'a', 'a', NULL); +insert into t1 values(1, 'b', 'b', NULL); +# Drop some indexes for new adds. +alter table t1 drop index i3, drop index i2, drop index i1; +# Add indexes, one is unique on non-unique values. +--error ER_DUP_ENTRY +alter table t1 add index i3 (c3), add index i2 (c2), add unique index i1 (c1); +drop table t1; + + +# +# Bug #20604: Test for disabled keys with aggregate functions and FORCE INDEX. +# + +CREATE TABLE t1( a TINYINT, KEY(a) ) ENGINE=MyISAM; +INSERT INTO t1 VALUES( 1 ); +ALTER TABLE t1 DISABLE KEYS; +EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a); + +drop table t1; + +# # Bug #24778: Innodb: No result when using ORDER BY # CREATE TABLE t1 ( @@ -433,16 +502,6 @@ ORDER BY c.b, c.d DROP TABLE t1, t2; - -# -# Bug #20604: Test for disabled keys with aggregate functions and FORCE INDEX. -# -CREATE TABLE t1( a TINYINT, KEY(a) ) ENGINE=MyISAM; -INSERT INTO t1 VALUES( 1 ); -ALTER TABLE t1 DISABLE KEYS; -EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a); -DROP TABLE t1; - # # Bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0 # @@ -461,4 +520,44 @@ desc t1; show create table t1; drop table t1; ---echo End of 5.0 tests. +--echo End of 5.0 tests + +# +# Bug #31148: bool close_thread_table(THD*, TABLE**): Assertion +# `table->key_read == 0' failed. +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT); + +INSERT INTO t1 VALUES (), (), (); + +SELECT 1 AS c1 +FROM t1 +ORDER BY ( + SELECT 1 AS c2 + FROM t1 + GROUP BY GREATEST(LAST_INSERT_ID(), t1.a) ASC + LIMIT 1); + +DROP TABLE t1; + + +# +# Bug #31974: Wrong EXPLAIN output +# + +CREATE TABLE t1 (a INT, b INT, INDEX (a,b)); +INSERT INTO t1 (a, b) + VALUES + (1,1), (1,2), (1,3), (1,4), (1,5), + (2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6); +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE + (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; +SELECT 1 as RES FROM t1 AS t1_outer WHERE + (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; + +DROP TABLE t1; diff --git a/mysql-test/t/keywords.test b/mysql-test/t/keywords.test index 46933a230ee..3080c4847b4 100644 --- a/mysql-test/t/keywords.test +++ b/mysql-test/t/keywords.test @@ -20,6 +20,29 @@ drop table events; # End of 4.1 tests +# +# Bug#19939 "AUTHORS is not a keyword" +# +delimiter |; +create procedure p1() +begin + declare n int default 2; + authors: while n > 0 do + set n = n -1; + end while authors; +end| +create procedure p2() +begin + declare n int default 2; + contributors: while n > 0 do + set n = n -1; + end while contributors; +end| +delimiter ;| +drop procedure p1; +drop procedure p2; + +# End of 5.1 tests # # Bug#12204 - CONNECTION should not be a reserved word diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index 651f24d2457..02b033df2e5 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -6,6 +6,11 @@ # -- source include/not_embedded.inc +# Disable concurrent inserts to avoid test failures when reading the +# connection id which was inserted into a table by another thread. +set @old_concurrent_insert= @@global.concurrent_insert; +set @@global.concurrent_insert= 0; + connect (con1, localhost, root,,); connect (con2, localhost, root,,); @@ -48,7 +53,7 @@ select 4; drop table t1; connection default; ---error 1064 +--error ER_NOT_SUPPORTED_YET kill (select count(*) from mysql.user); # @@ -304,3 +309,27 @@ while ($i) dec $i ; } --enable_query_log + +########################################################################### + +--echo # +--echo # Bug#19723: kill of active connection yields different error code +--echo # depending on platform. +--echo # + +--echo +--echo # Connection: con2. +--connection con2 + +KILL CONNECTION_ID(); + +--echo # CR_SERVER_LOST, CR_SERVER_GONE_ERROR, depending on the timing +--echo # of close of the connection socket +--error 2013, 2006 +SELECT 1; +--connection default + +########################################################################### + +# Restore global concurrent_insert value. Keep in the end of the test file. +set @@global.concurrent_insert= @old_concurrent_insert; diff --git a/mysql-test/t/kill_n_check.sh b/mysql-test/t/kill_n_check.sh deleted file mode 100755 index 6f2a0825dcd..00000000000 --- a/mysql-test/t/kill_n_check.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/bin/sh - -########################################################################### - -# NOTE: this script returns 0 (success) even in case of failure (except for -# usage-error). This is because this script is executed under -# mysql-test-run[.pl] and it's better to examine particular problem in log -# file, than just having said that the test case has failed. - -########################################################################### - -basename=`basename "$0"` -dirname=`dirname "$0"` - -########################################################################### - -. "$dirname/utils.sh" - -########################################################################### - -check_restart() -{ - if [ ! -r "$pid_path" ]; then - log_debug "No '$pid_path' found." - user_msg='the process was killed' - return 1 - fi - - new_pid=`cat "$pid_path" 2>/dev/null` - err_code=$? - - log_debug "err_code: $err_code; original_pid: $original_pid; new_pid: $new_pid." - - if [ $err_code -eq 0 -a "$original_pid" = "$new_pid" ]; then - log_debug "The process was not restarted." - user_msg='the process was not restarted' - return 1 - fi - - log_debug "The process was restarted." - user_msg='the process was restarted' - return 0 -} - -########################################################################### - -if [ $# -ne 4 ]; then - echo "Usage: $basename <pid file path> killed|restarted <timeout> <test id>" - exit 1 -fi - -pid_path="$1" -expected_result="$2" -total_timeout="$3" -test_id="$4" -log_file="$MYSQLTEST_VARDIR/log/$test_id.script.log" - -log_debug "-- $basename: starting --" -log_debug "pid_path: '$pid_path'" -log_debug "expected_result: '$expected_result'" -log_debug "total_timeout: '$total_timeout'" -log_debug "test_id: '$test_id'" -log_debug "log_file: '$log_file'" - -########################################################################### - -if [ "$expected_result" != 'killed' -a \ - "$expected_result" != 'restarted' ]; then - log_error "Invalid second argument ($expected_result): 'killed' or 'restarted' expected." - quit 0 -fi - -if [ -z "$pid_path" ]; then - log_error "Invalid PID path ($pid_path)." - quit 0 -fi - -if [ ! -r "$pid_path" ]; then - log_error "PID file ($pid_path) does not exist." - quit 0 -fi - -if [ -z "$total_timeout" ]; then - log_error "Timeout is not specified." - quit 0 -fi - -########################################################################### - -original_pid=`cat "$pid_path"` -log_debug "original_pid: $original_pid." - -log_info "Killing the process..." - -kill -9 $original_pid - -########################################################################### - -log_info "Waiting..." - -if [ "$expected_result" = "restarted" ]; then - - # Wait for the process to restart. - - cur_attempt=1 - - while true; do - - log_debug "cur_attempt: $cur_attempt." - - if check_restart; then - log_info "Success: $user_msg." - quit 0 - fi - - [ $cur_attempt -ge $total_timeout ] && break - - log_debug "Sleeping for 1 second..." - sleep 1 - - cur_attempt=`expr $cur_attempt + 1` - - done - - log_error "$user_msg." - quit 0 - -else # $expected_result == killed - - # Here we have to sleep for some long time to ensure that the process will - # not be restarted. - - log_debug "Sleeping for $total_timeout seconds..." - sleep $total_timeout - - new_pid=`cat "$pid_path" 2>/dev/null` - log_debug "new_pid: $new_pid." - - if [ "$new_pid" -a "$new_pid" -ne "$original_pid" ]; then - log_error "The process was restarted." - else - log_info "Success: the process was killed." - fi - - quit 0 - -fi diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index cd22b700430..7bfe2491c7c 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -7,25 +7,25 @@ drop table if exists t1, t2; --enable_warnings create table t1 (a date, b date, c date not null, d date); -load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ','; -load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; +load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ','; +load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; SELECT * from t1; truncate table t1; -load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); +load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); SELECT * from t1; drop table t1; create table t1 (a text, b text); -load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; +load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; select concat('|',a,'|'), concat('|',b,'|') from t1; drop table t1; create table t1 (a int, b char(10)); -load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; +load data infile '../../std_data/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; select * from t1; truncate table t1; -load data infile '../std_data_ln/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; +load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; # The empty line last comes from the end line field in the file select * from t1; @@ -63,7 +63,7 @@ drop table t1; # ENCLOSED # create table t1 (a varchar(20), b varchar(20)); -load data infile '../std_data_ln/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b); +load data infile '../../std_data/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b); select * from t1; drop table t1; @@ -108,40 +108,44 @@ DROP TABLE t1,t2; # create table t1 (a int default 100, b int, c varchar(60)); # we can do something like this -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b); +load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b); select * from t1; truncate table t1; # we can use filled fields in expressions # we also assigning NULL value to field with non-NULL default here -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a); +load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a); select * from t1; truncate table t1; # we even can use variables in set clause, and missed columns will be set # with default values set @c:=123; -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b); +load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b); select * from t1; # let us test side-effect of such load -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, @b); +load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, @b); select * from t1; select @a, @b; truncate table t1; +# Reading of all columns with set +load data infile '../../std_data/rpl_loaddata.dat' into table t1 set c=b; +select * from t1; +truncate table t1; # now going to test fixed field-row file format -load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow"; +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow"; select * from t1; truncate table t1; # this also should work -load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c)); +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c)); select * from t1; # and this should bark --error 1409 -load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b); +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b); # Now let us test LOAD DATA with subselect create table t2 (num int primary key, str varchar(10)); insert into t2 values (10,'Ten'), (15,'Fifteen'); truncate table t1; -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n); +load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n); select * from t1; # @@ -159,7 +163,7 @@ set @@secure_file_priv= 0; # Test "load data" truncate table t1; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---error 1290 +--error ER_OPTION_PREVENTS_STATEMENT, ER_TEXTFILE_NOT_READABLE eval load data infile '$MYSQL_TEST_DIR/t/loaddata.test' into table t1; select * from t1; @@ -260,7 +264,7 @@ CREATE VIEW v2 AS SELECT 1 + 2 AS c0, c1, c2 FROM t1; CREATE VIEW v3 AS SELECT 1 AS d1, 2 AS d2; --echo -LOAD DATA INFILE '../std_data_ln/bug35469.dat' INTO TABLE v1 +LOAD DATA INFILE '../../std_data/bug35469.dat' INTO TABLE v1 FIELDS ESCAPED BY '\\' TERMINATED BY ',' ENCLOSED BY '"' @@ -276,7 +280,7 @@ SELECT * FROM v1; DELETE FROM t1; --echo -LOAD DATA INFILE '../std_data_ln/bug35469.dat' INTO TABLE v2 +LOAD DATA INFILE '../../std_data/bug35469.dat' INTO TABLE v2 FIELDS ESCAPED BY '\\' TERMINATED BY ',' ENCLOSED BY '"' @@ -293,7 +297,7 @@ DELETE FROM t1; --echo --error ER_LOAD_DATA_INVALID_COLUMN -LOAD DATA INFILE '../std_data_ln/bug35469.dat' INTO TABLE v2 +LOAD DATA INFILE '../../std_data/bug35469.dat' INTO TABLE v2 FIELDS ESCAPED BY '\\' TERMINATED BY ',' ENCLOSED BY '"' @@ -301,7 +305,7 @@ LOAD DATA INFILE '../std_data_ln/bug35469.dat' INTO TABLE v2 --echo --error ER_NON_UPDATABLE_TABLE -LOAD DATA INFILE '../std_data_ln/bug35469.dat' INTO TABLE v3 +LOAD DATA INFILE '../../std_data/bug35469.dat' INTO TABLE v3 FIELDS ESCAPED BY '\\' TERMINATED BY ',' ENCLOSED BY '"' @@ -316,9 +320,10 @@ DROP VIEW v3; --echo --echo # -- End of Bug#35469. -########################################################################### +########################################################################### + # # Bug#37114: sql_mode NO_BACKSLASH_ESCAPES does not work properly with # LOAD DATA INFILE @@ -499,3 +504,33 @@ DROP TABLE t1,t2; --echo End of 5.0 tests + + + +# +# Bug#12448 LOAD DATA / SELECT INTO OUTFILE +# doesn't work with multibyte path name +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1); +SET NAMES latin1; +SET character_set_filesystem=filename; +select @@character_set_filesystem; +SELECT * INTO OUTFILE 't-1' FROM t1; +DELETE FROM t1; +LOAD DATA INFILE 't-1' INTO TABLE t1; +SELECT * FROM t1; +DELETE FROM t1; +SET character_set_filesystem=latin1; +select @@character_set_filesystem; +LOAD DATA INFILE 't@002d1' INTO TABLE t1; +SELECT * FROM t1; +DROP TABLE t1; +let $MYSQLD_DATADIR= `select @@datadir`; +remove_file $MYSQLD_DATADIR/test/t@002d1; +SET character_set_filesystem=default; +select @@character_set_filesystem; + + + +--echo End of 5.1 tests diff --git a/mysql-test/t/loaddata_autocom_ndb.test b/mysql-test/t/loaddata_autocom_ndb.test deleted file mode 100644 index f4a6743aabe..00000000000 --- a/mysql-test/t/loaddata_autocom_ndb.test +++ /dev/null @@ -1,4 +0,0 @@ ---source include/have_ndb.inc -let $engine_type=ndbcluster; - ---source include/loaddata_autocom.inc diff --git a/mysql-test/t/locale.test b/mysql-test/t/locale.test new file mode 100644 index 00000000000..7ceb49fd1f4 --- /dev/null +++ b/mysql-test/t/locale.test @@ -0,0 +1,18 @@ +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo Start of 5.4 tests +--echo # +--echo # Bug#43207 wrong LC_TIME names for romanian locale +--echo # +SET NAMES utf8; +SET lc_time_names=ro_RO; +SELECT DATE_FORMAT('2001-01-01', '%w %a %W'); +SELECT DATE_FORMAT('2001-01-02', '%w %a %W'); +SELECT DATE_FORMAT('2001-01-03', '%w %a %W'); +SELECT DATE_FORMAT('2001-01-04', '%w %a %W'); +SELECT DATE_FORMAT('2001-01-05', '%w %a %W'); +SELECT DATE_FORMAT('2001-01-06', '%w %a %W'); +SELECT DATE_FORMAT('2001-01-07', '%w %a %W'); +--echo End of 5.4 tests diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test index 8300219b3d4..30f4d4d6c61 100644 --- a/mysql-test/t/lock.test +++ b/mysql-test/t/lock.test @@ -92,4 +92,156 @@ delete from t2 using t1,t2 where t1.a=t2.a; delete t2 from t1,t2 where t1.a=t2.a; drop table t1,t2; -# End of 4.1 tests +--echo End of 4.1 tests. + + +# +# Bug#18884 "lock table + global read lock = crash" +# The bug is not repeatable, just add the test case. +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +lock table t1 write; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +flush tables with read lock; +unlock tables; +drop table t1; + + +# +# Test LOCK TABLE on system tables. See bug#9953: CONVERT_TZ requires +# mysql.time_zone_name to be locked. +# +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (i INT); + +LOCK TABLES mysql.time_zone READ, mysql.proc READ, t1 READ; +UNLOCK TABLES; + +LOCK TABLES mysql.time_zone READ, mysql.proc READ, t1 WRITE; +UNLOCK TABLES; + +LOCK TABLES mysql.time_zone READ, mysql.proc READ; +UNLOCK TABLES; + +LOCK TABLES mysql.time_zone WRITE, mysql.proc WRITE; +UNLOCK TABLES; + +# If at least one system table is locked for WRITE, then all other +# tables should be system tables locked also for WRITE. +--error ER_WRONG_LOCK_OF_SYSTEM_TABLE +LOCK TABLES mysql.time_zone READ, mysql.proc WRITE, t1 READ; + +--error ER_WRONG_LOCK_OF_SYSTEM_TABLE +LOCK TABLES mysql.time_zone WRITE, mysql.proc WRITE, t1 READ; + +--error ER_WRONG_LOCK_OF_SYSTEM_TABLE +LOCK TABLES mysql.time_zone WRITE, mysql.proc WRITE, t1 WRITE; + +--error ER_WRONG_LOCK_OF_SYSTEM_TABLE +LOCK TABLES mysql.time_zone READ, mysql.proc WRITE; + +DROP TABLE t1; + +--echo +--echo Bug#5719 impossible to lock VIEW +--echo +--echo Just covering existing behaviour with tests. +--echo Consistency has not been found here. +--echo +--disable_warnings +drop view if exists v_bug5719; +drop table if exists t1, t2, t3; +--enable_warnings +create table t1 (a int); +create temporary table t2 (a int); +create table t3 (a int); +create view v_bug5719 as select 1; +lock table v_bug5719 write; +--error ER_TABLE_NOT_LOCKED +select * from t1; +--echo +--echo Allowed to select from a temporary talbe under LOCK TABLES +--echo +select * from t2; +--error ER_TABLE_NOT_LOCKED +select * from t3; +select * from v_bug5719; +drop view v_bug5719; +--echo +--echo sic: did not left LOCK TABLES mode automatically +--echo +--error ER_TABLE_NOT_LOCKED +select * from t1; +unlock tables; +create view v_bug5719 as select * from t1; +lock tables v_bug5719 write; +select * from v_bug5719; +--echo +--echo Allowed to use an underlying table under LOCK TABLES <view> +--echo +select * from t1; +--echo +--echo Allowed to select from a temporary table under LOCK TABLES +--echo +select * from t2; +--error ER_TABLE_NOT_LOCKED +select * from t3; +drop table t1; +--echo +--echo sic: left LOCK TABLES mode +--echo +select * from t3; +--error ER_VIEW_INVALID +select * from v_bug5719; +unlock tables; +drop view v_bug5719; +--echo +--echo When limitation to use temporary tables in views is removed, please +--echo add a test that shows what happens under LOCK TABLES when a view +--echo references a temporary table, is locked, and the underlying table +--echo is dropped. +--echo +--error ER_VIEW_SELECT_TMPTABLE +create view v_bug5719 as select * from t2; +--echo +--echo Cleanup. +--echo +drop table t2, t3; + +--echo # +--echo # Bug#39843 DELETE requires write access to table in subquery in where clause +--echo # +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings +CREATE TABLE t1 ( +table1_rowid SMALLINT NOT NULL +); +CREATE TABLE t2 ( +table2_rowid SMALLINT NOT NULL +); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +LOCK TABLES t1 WRITE, t2 READ; +--echo # Sub-select should not try to aquire a write lock. +DELETE FROM t1 +WHERE EXISTS +( +SELECT 'x' +FROM t2 +WHERE t1.table1_rowid = t2.table2_rowid +) ; +--echo # While implementing the patch we didn't break old behavior; +--echo # The following sub-select should still requires a write lock: +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +SELECT * FROM t1 WHERE 1 IN (SELECT * FROM t2 FOR UPDATE); +UNLOCK TABLES; +DROP TABLE t1,t2; + +--echo End of 5.1 tests. diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index fa6af85f29c..47b5aa0292b 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -22,19 +22,18 @@ send update low_priority t1 set n = 4; connection reader; # Sleep a bit till the update of connection writer is in work and hangs -let $wait_timeout= 5; -let $show_statement= SHOW PROCESSLIST; -let $field= State; -let $condition= = 'Locked'; ---source include/wait_show_condition.inc +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "update low_priority t1 set n = 4"; +--source include/wait_condition.inc send select n from t1; connection locker; # Sleep a bit till the select of connection reader is in work and hangs -# Here we cannot use include/wait_show_condition.inc because this routine -# cannot count the number of 'Locked' sessions or access two columns within -# the same query_get_value call. ---sleep 3 +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "select n from t1"; +--source include/wait_condition.inc unlock tables; connection writer; reap; @@ -51,24 +50,15 @@ send update low_priority t1 set n = 4; connection reader; # Sleep a bit till the update of connection writer is in work and hangs -let $wait_timeout= 5; -let $show_statement= SHOW PROCESSLIST; -let $field= State; -let $condition= = 'Locked'; ---source include/wait_show_condition.inc -# -send +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "update low_priority t1 set n = 4"; +--source include/wait_condition.inc select n from t1; connection locker; -# Sleep a bit till the select of connection reader is in work and hangs -# Here we cannot use include/wait_show_condition.inc. ---sleep 3 -# unlock tables; connection writer; reap; -connection reader; -reap; drop table t1; # @@ -84,16 +74,9 @@ insert into t1 values(2,2); insert into t2 values(1,2); lock table t1 read; connection writer; -send update t1,t2 set c=a where b=d; connection reader; -# Sleep a bit till the update of connection writer is finished -# Here we cannot use include/wait_show_condition.inc. ---sleep 3 -# select c from t2; -connection writer; -reap; connection locker; drop table t1; drop table t2; @@ -102,7 +85,7 @@ drop table t2; # Test problem when using locks on many tables and dropping a table that # is to-be-locked by another thread # - +# connection locker; create table t1 (a int); create table t2 (a int); @@ -111,12 +94,34 @@ connection reader; send insert t1 select * from t2; connection locker; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "insert t1 select * from t2"; +--source include/wait_condition.inc +drop table t2; +connection reader; +--error ER_NO_SUCH_TABLE +reap; +connection locker; +drop table t1; + +# +# Same test as above, but with the dropped table locked twice +# + +connection locker; +create table t1 (a int); +create table t2 (a int); +lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write; +connection reader; +send +insert t1 select * from t2; +connection locker; # Sleep a bit till the insert of connection reader is in work and hangs -let $wait_timeout= 5; -let $show_statement= SHOW PROCESSLIST; -let $field= State; -let $condition= = 'Locked'; ---source include/wait_show_condition.inc +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "insert t1 select * from t2"; +--source include/wait_condition.inc drop table t2; connection reader; --error ER_NO_SUCH_TABLE @@ -124,7 +129,8 @@ reap; connection locker; drop table t1; -# End of 4.1 tests + +--echo End of 4.1 tests # # Bug#9998 MySQL client hangs on USE "database" @@ -138,47 +144,6 @@ unlock tables; drop table t1; # -# Bug#19815 CREATE/RENAME/DROP DATABASE can deadlock on a global read lock -# -connect (con1,localhost,root,,); -connect (con2,localhost,root,,); -# -connection con1; -CREATE DATABASE mysqltest_1; -FLUSH TABLES WITH READ LOCK; -# -# With bug in place: acquire LOCK_mysql_create_table and -# wait in wait_if_global_read_lock(). -connection con2; -send -DROP DATABASE mysqltest_1; -# -# With bug in place: try to acquire LOCK_mysql_create_table... -# When fixed: Reject dropping db because of the read lock. -connection con1; -# Wait a bit so that the session con2 is in state "Waiting for release of readlock" -let $wait_timeout= 5; -let $show_statement= SHOW PROCESSLIST; -let $field= State; -let $condition= = 'Waiting for release of readlock'; ---source include/wait_show_condition.inc ---error ER_CANT_UPDATE_WITH_READLOCK -DROP DATABASE mysqltest_1; -UNLOCK TABLES; -# -connection con2; -reap; -# -connection default; -disconnect con1; -disconnect con2; -# This must have been dropped by connection 2 already, -# which waited until the global read lock was released. ---error ER_DB_DROP_EXISTS -DROP DATABASE mysqltest_1; - - -# # Bug#16986 Deadlock condition with MyISAM tables # @@ -189,8 +154,7 @@ connection locker; USE mysql; LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE; FLUSH TABLES; - - +# connection reader; USE mysql; # Note: This must be a multi-table select, otherwise the deadlock will not occur @@ -199,11 +163,11 @@ SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1; # connection locker; # Sleep a bit till the select of connection reader is in work and hangs -let $wait_timeout= 5; -let $show_statement= SHOW PROCESSLIST; -let $field= State; -let $condition= = 'Locked'; ---source include/wait_show_condition.inc +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table" and info = + "SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1"; +--source include/wait_condition.inc # Make test case independent from earlier grants. --replace_result "Table is already up to date" "OK" OPTIMIZE TABLES columns_priv, db, host, user; @@ -229,14 +193,13 @@ connection locker; send FLUSH TABLES WITH READ LOCK; # -# This must not block. connection writer; # Sleep a bit till the flush of connection locker is in work and hangs -let $wait_timeout= 5; -let $show_statement= SHOW PROCESSLIST; -let $field= State; -let $condition= = 'Flushing tables'; ---source include/wait_show_condition.inc +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK"; +--source include/wait_condition.inc +# This must not block. CREATE TABLE t2 (c1 int); UNLOCK TABLES; # @@ -262,11 +225,10 @@ FLUSH TABLES WITH READ LOCK; # This must not block. connection writer; # Sleep a bit till the flush of connection locker is in work and hangs -let $wait_timeout= 5; -let $show_statement= SHOW PROCESSLIST; -let $field= State; -let $condition= = 'Flushing tables'; ---source include/wait_show_condition.inc +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK"; +--source include/wait_condition.inc --error ER_TABLE_NOT_LOCKED CREATE TABLE t2 AS SELECT * FROM t1; UNLOCK TABLES; @@ -281,6 +243,45 @@ DROP TABLE t1; --source include/delete_anonymous_users.inc +# +# Bug#19815 CREATE/RENAME/DROP DATABASE can deadlock on a global read lock +# +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +# +connection con1; +CREATE DATABASE mysqltest_1; +FLUSH TABLES WITH READ LOCK; +# +# With bug in place: acquire LOCK_mysql_create_table and +# wait in wait_if_global_read_lock(). +connection con2; +send +DROP DATABASE mysqltest_1; +# +# With bug in place: try to acquire LOCK_mysql_create_table... +# When fixed: Reject dropping db because of the read lock. +connection con1; +# Wait a bit so that the session con2 is in state "Waiting for release of readlock" +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for release of readlock" + and info = "DROP DATABASE mysqltest_1"; +--source include/wait_condition.inc +--error ER_CANT_UPDATE_WITH_READLOCK +DROP DATABASE mysqltest_1; +UNLOCK TABLES; +# +connection con2; +reap; +# +connection default; +disconnect con1; +disconnect con2; +# This must have been dropped by connection 2 already, +# which waited until the global read lock was released. +--error ER_DB_DROP_EXISTS +DROP DATABASE mysqltest_1; # # Bug#17264 MySQL Server freeze @@ -292,29 +293,22 @@ create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) e --enable_warnings lock tables t1 write; connection writer; -# mleich: I have doubts if the next sleep is really necessary -# Therefore I set it to comment but don't remove it -# in case it hat to be enabled again. -# --sleep 2 -delimiter //; send -alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // -delimiter ;// +alter table t1 auto_increment=0; connection reader; # Wait till connection writer is blocked -let $wait_timeout= 5; -let $show_statement= SHOW PROCESSLIST; -let $field= State; -let $condition= = 'Locked'; ---source include/wait_show_condition.inc -delimiter //; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "alter table t1 auto_increment=0"; +--source include/wait_condition.inc send -alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // -delimiter ;// +alter table t1 auto_increment=0; connection locker; # Wait till connection reader is blocked -# Here we cannot use include/wait_show_condition.inc. ---sleep 3 +let $wait_condition= + select count(*) = 2 from information_schema.processlist + where state = "Locked" and info = "alter table t1 auto_increment=0"; +--source include/wait_condition.inc unlock tables; connection writer; reap; @@ -324,366 +318,6 @@ connection locker; drop table t1; # -# Bug#31479 Bad lock interaction if CREATE TABLE LIKE is killed -# - ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1 (a int); ---echo connection: locker -connection locker; -lock tables t1 read; ---echo connection: writer -connection writer; -let $ID= `select connection_id()`; -send create table t2 like t1; ---echo connection: default -connection default; -let $show_type= open tables where in_use=2 and name_locked=1; -let $show_pattern= '%t1%2%1'; ---source include/wait_show_pattern.inc ---echo kill query -disable_query_log; -eval kill query $ID; -enable_query_log; -connection writer; ---error ER_QUERY_INTERRUPTED ---reap -connection locker; -unlock tables; -connection default; -drop table t1; - -# -# Bug#38691 segfault/abort in ``UPDATE ...JOIN'' while -# ``FLUSH TABLES WITH READ LOCK'' -# - ---connection default -CREATE TABLE t1 ( - a int(11) unsigned default NULL, - b varchar(255) default NULL, - UNIQUE KEY a (a), - KEY b (b) -); - -INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); -CREATE TABLE t2 SELECT * FROM t1; -CREATE TABLE t3 SELECT * FROM t1; - ---echo # test altering of columns that multiupdate doesn't use - ---echo # normal mode - ---disable_query_log -let $i = 100; -while ($i) { ---dec $i - ---connection writer - send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) - SET a = NULL WHERE t1.b <> t2.b; - ---connection locker - ALTER TABLE t2 ADD COLUMN (c INT); - ALTER TABLE t2 DROP COLUMN c; - ---connection writer ---reap -} - ---echo # PS mode - ---connection writer -PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) - SET a = NULL WHERE t1.b <> t2.b'; - -let $i = 100; -while ($i) { ---dec $i - ---connection writer ---send EXECUTE stmt - ---connection locker - ALTER TABLE t2 ADD COLUMN (c INT); - ALTER TABLE t2 DROP COLUMN c; - ---connection writer ---reap -} ---enable_query_log - - ---echo # test altering of columns that multiupdate uses - ---echo # normal mode - ---connection default - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,ER_DUP_FIELDNAME - ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL; - UPDATE t2 SET a=b; - ---connection writer ---send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b - ---connection locker ---error 0,ER_CANT_DROP_FIELD_OR_KEY - ALTER TABLE t2 DROP COLUMN a; - ---connection writer ---error 0,ER_BAD_FIELD_ERROR ---reap -} ---enable_query_log - ---echo # PS mode - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,ER_DUP_FIELDNAME - ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL; - UPDATE t2 SET a=b; - ---connection writer - PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b'; ---send EXECUTE stmt - ---connection locker ---error 0,ER_CANT_DROP_FIELD_OR_KEY - ALTER TABLE t2 DROP COLUMN a; - ---connection writer ---error 0,ER_BAD_FIELD_ERROR ---reap - -} ---enable_query_log ---connection default -DROP TABLE t1, t2, t3; - - -# -# Bug#38499: flush tables and multitable table update with derived table cause -# crash -# - -CREATE TABLE t1( a INT, b INT ); -INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4); - ---echo # 1. test regular tables ---echo # 1.1. test altering of columns that multiupdate doesn't use ---echo # 1.1.1. normal mode - ---disable_query_log -let $i = 100; -while ($i) { ---dec $i - ---connection writer - send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0; - ---connection locker - ALTER TABLE t1 ADD COLUMN (c INT); - ALTER TABLE t1 DROP COLUMN c; - ---connection writer ---reap -} - ---echo # 1.1.2. PS mode - ---connection writer -PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0'; - -let $i = 100; -while ($i) { ---dec $i - ---connection writer ---send EXECUTE stmt - ---connection locker - ALTER TABLE t1 ADD COLUMN (c INT); - ALTER TABLE t1 DROP COLUMN c; - ---connection writer ---reap -} ---enable_query_log - ---echo # 1.2. test altering of columns that multiupdate uses ---echo # 1.2.1. normal mode - ---connection default - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,ER_DUP_FIELDNAME - ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL; - UPDATE t1 SET a=b; - ---connection writer ---send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0; - ---connection locker ---error 0,ER_CANT_DROP_FIELD_OR_KEY - ALTER TABLE t1 DROP COLUMN a; - ---connection writer ---error 0,ER_BAD_FIELD_ERROR # unknown column error ---reap -} ---enable_query_log - ---echo # 1.2.2. PS mode - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,ER_DUP_FIELDNAME - ALTER TABLE t1 ADD COLUMN a INT; - UPDATE t1 SET a=b; - ---connection writer - PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0'; ---send EXECUTE stmt - ---connection locker ---error 0,ER_CANT_DROP_FIELD_OR_KEY - ALTER TABLE t1 DROP COLUMN a; - ---connection writer ---error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list' ---reap -} ---enable_query_log ---connection default -ALTER TABLE t1 ADD COLUMN a INT; - ---echo # 2. test UNIONs ---echo # 2.1. test altering of columns that multiupdate doesn't use ---echo # 2.1.1. normal mode - ---disable_query_log -let $i = 100; -while ($i) { ---dec $i - ---connection writer - send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0; - ---connection locker - ALTER TABLE t1 ADD COLUMN (c INT); - ALTER TABLE t1 DROP COLUMN c; - ---connection writer ---reap -} - ---echo # 2.1.2. PS mode - ---connection writer -PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0'; - -let $i = 100; -while ($i) { ---dec $i - ---connection writer ---send EXECUTE stmt - ---connection locker - ALTER TABLE t1 ADD COLUMN (c INT); - ALTER TABLE t1 DROP COLUMN c; - ---connection writer ---reap -} ---enable_query_log - ---echo # 2.2. test altering of columns that multiupdate uses ---echo # 2.2.1. normal mode - ---connection default - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,ER_DUP_FIELDNAME - ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL; - UPDATE t1 SET a=b; - ---connection writer ---send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0; - ---connection locker ---error 0,ER_CANT_DROP_FIELD_OR_KEY - ALTER TABLE t1 DROP COLUMN a; - ---connection writer ---error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list' ---reap -} ---enable_query_log - ---echo # 2.2.2. PS mode - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,ER_DUP_FIELDNAME - ALTER TABLE t1 ADD COLUMN a INT; - UPDATE t1 SET a=b; - ---connection writer - PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0'; ---send EXECUTE stmt - ---connection locker ---error 0,ER_CANT_DROP_FIELD_OR_KEY - ALTER TABLE t1 DROP COLUMN a; - ---connection writer ---error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list' ---reap -} ---enable_query_log ---connection default -DROP TABLE t1; - - -# Close connections used in many subtests ---disconnect reader ---disconnect locker ---disconnect writer - -# # Bug#43230: SELECT ... FOR UPDATE can hang with FLUSH TABLES WITH READ LOCK indefinitely # @@ -811,7 +445,197 @@ disconnect con1; drop table t1,t2; -# End of 5.0 tests + +--echo End of 5.0 tests + + +# +# Bug#21281 Pending write lock is incorrectly removed when its +# statement being KILLed +# +create table t1 (i int); +connection locker; +lock table t1 read; +connection writer; +send +update t1 set i= 10; +connection reader; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "update t1 set i= 10"; +--source include/wait_condition.inc +send +select * from t1; +connection default; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "select * from t1"; +--source include/wait_condition.inc +let $ID= `select id from information_schema.processlist where state = "Locked" and info = "update t1 set i= 10"`; +--replace_result $ID ID +eval kill query $ID; +connection reader; +--reap +connection writer; +--error ER_QUERY_INTERRUPTED +--reap +connection locker; +unlock tables; +connection default; +drop table t1; + +# +# Bug#25856 HANDLER table OPEN in one connection lock DROP TABLE in another one +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int) ENGINE=MEMORY; +--echo --> client 2 +connection locker; +--error ER_ILLEGAL_HA +handler t1 open; +--echo --> client 1 +connection default; +drop table t1; + + +# Disconnect sessions used in many subtests above +disconnect locker; +disconnect reader; +disconnect writer; + + +# +# Bug#32395 Alter table under a impending global read lock causes a server crash +# + +# +# Test ALTER TABLE under LOCK TABLES and FLUSH TABLES WITH READ LOCK +# + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (i int); +connect (flush,localhost,root,,test,,); +connection default; +--echo connection: default +lock tables t1 write; +connection flush; +--echo connection: flush +--send flush tables with read lock; +connection default; +--echo connection: default +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Flushing tables"; +--source include/wait_condition.inc +alter table t1 add column j int; +connect (insert,localhost,root,,test,,); +connection insert; +--echo connection: insert +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Flushing tables"; +--source include/wait_condition.inc +--send insert into t1 values (1,2); +--echo connection: default +connection default; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for release of readlock"; +--source include/wait_condition.inc +unlock tables; +connection flush; +--echo connection: flush +--reap +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for release of readlock"; +--source include/wait_condition.inc +select * from t1; +unlock tables; +connection insert; +--reap +connection default; +let $wait_condition= + select count(*) = 1 from t1; +--source include/wait_condition.inc +select * from t1; +drop table t1; +disconnect flush; +disconnect insert; + +# +# Test that FLUSH TABLES under LOCK TABLES protects write locked tables +# from a impending FLUSH TABLES WITH READ LOCK +# + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (i int); +connect (flush,localhost,root,,test,,); +connection default; +--echo connection: default +lock tables t1 write; +connection flush; +--echo connection: flush +--send flush tables with read lock; +connection default; +--echo connection: default +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Flushing tables"; +--source include/wait_condition.inc +flush tables; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Flushing tables"; +--source include/wait_condition.inc +unlock tables; +let $wait_condition= + select count(*) = 0 from information_schema.processlist + where state = "Flushing tables"; +--source include/wait_condition.inc +connection flush; +--reap +connection default; +disconnect flush; +drop table t1; + +# +# Bug#30331 Table_locks_waited shows inaccurate values +# + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings +create table t1 (a int); +flush status; +lock tables t1 read; +let $tlwa= `show status like 'Table_locks_waited'`; +connect (waiter,localhost,root,,); +connection waiter; +--send insert into t1 values(1); +connection default; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and info = "insert into t1 values(1)"; +--source include/wait_condition.inc +let $tlwb= `show status like 'Table_locks_waited'`; +unlock tables; +drop table t1; +disconnect waiter; +connection default; +--disable_query_log +eval SET @tlwa= SUBSTRING_INDEX('$tlwa', ' ', -1); +eval SET @tlwb= SUBSTRING_INDEX('$tlwb', ' ', -1); +--enable_query_log +select @tlwa < @tlwb; + +--echo End of 5.1 tests # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/lock_multi_bug38499.test b/mysql-test/t/lock_multi_bug38499.test index def58187ced..3d3f084ba5f 100644 --- a/mysql-test/t/lock_multi_bug38499.test +++ b/mysql-test/t/lock_multi_bug38499.test @@ -1,11 +1,13 @@ # Bug38499 flush tables and multitable table update with derived table cause crash # MySQL >= 5.0 # ---source include/big_test.inc # Save the initial number of concurrent sessions --source include/count_sessions.inc +SET @odl_sync_frm = @@global.sync_frm; +SET @@global.sync_frm = OFF; + connect (locker,localhost,root,,); connect (writer,localhost,root,,); @@ -215,6 +217,8 @@ DROP TABLE t1; --disconnect locker --disconnect writer +SET @@global.sync_frm = @odl_sync_frm; + # End of 5.0 tests # Wait till all disconnects are completed diff --git a/mysql-test/t/lock_multi_bug38691.test b/mysql-test/t/lock_multi_bug38691.test index 0458f31579e..881a0d8e502 100644 --- a/mysql-test/t/lock_multi_bug38691.test +++ b/mysql-test/t/lock_multi_bug38691.test @@ -8,6 +8,9 @@ # Save the initial number of concurrent sessions --source include/count_sessions.inc +SET @odl_sync_frm = @@global.sync_frm; +SET @@global.sync_frm = OFF; + # Test to see if select will get the lock ahead of low priority update connect (locker,localhost,root,,); @@ -136,6 +139,8 @@ DROP TABLE t1, t2, t3; --disconnect locker --disconnect writer +SET @@global.sync_frm = @odl_sync_frm; + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/log.sh b/mysql-test/t/log.sh deleted file mode 100755 index 33ef6d6701f..00000000000 --- a/mysql-test/t/log.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -########################################################################### - -basename=`basename "$0"` -dirname=`dirname "$0"` - -########################################################################### - -. "$dirname/utils.sh" - -########################################################################### - -if [ $# -lt 2 ]; then - echo "Usage: $basename <test id> log message ..." - exit 1 -fi - -test_id="$1" -log_file="$MYSQLTEST_VARDIR/log/$test_id.script.log" - -shift - -log_debug "$*" diff --git a/mysql-test/t/log_state-master.opt b/mysql-test/t/log_state-master.opt new file mode 100644 index 00000000000..445c6223d47 --- /dev/null +++ b/mysql-test/t/log_state-master.opt @@ -0,0 +1 @@ +--log-output=TABLE,FILE --log --general-log=0 --log-slow-queries --slow-query-log=0 diff --git a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test new file mode 100644 index 00000000000..e40dd1e3491 --- /dev/null +++ b/mysql-test/t/log_state.test @@ -0,0 +1,396 @@ +### t/log_state.test ### +# +# This test suffers from server +# Bug#38124 "general_log_file" variable silently unset when using expression +# In short: +# SET GLOBAL general_log_file = @<whatever> +# SET GLOBAL slow_query_log = @<whatever> +# cause that the value of these server system variables is set to default +# instead of the assigned values. There comes no error message or warning. +# If this bug is fixed please +# 1. try this test with "let $fixed_bug38124 = 0;" +# 2. remove all workarounds if 1. was successful. +let $fixed_bug38124 = 0; + +--source include/not_embedded.inc +--source include/have_csv.inc + +# Several subtests modify global variables. Save the initial values only here, +# but reset to the initial values per subtest. +SET @old_general_log= @@global.general_log; +SET @old_general_log_file= @@global.general_log_file; +SET @old_slow_query_log= @@global.slow_query_log; +SET @old_slow_query_log_file= @@global.slow_query_log_file; + + +--disable_ps_protocol + +set global general_log= OFF; +truncate table mysql.general_log; +truncate table mysql.slow_log; +show global variables +where Variable_name = 'log' or Variable_name = 'log_slow_queries' or +Variable_name = 'general_log' or Variable_name = 'slow_query_log'; +flush logs; +set global general_log= ON; +create table t1(f1 int); +--replace_column 1 TIMESTAMP 2 USER_HOST 3 # +select * from mysql.general_log; +set global general_log= OFF; +drop table t1; +--replace_column 1 TIMESTAMP 2 USER_HOST 3 # +select * from mysql.general_log; +set global general_log= ON; +flush logs; +show global variables +where Variable_name = 'log' or Variable_name = 'log_slow_queries' or +Variable_name = 'general_log' or Variable_name = 'slow_query_log'; + +--echo # Establish connection con1 (user=root) +connect (con1,localhost,root,,); +--echo # Switch to connection con1 +connection con1; +# Please increase @long_query_time if the corresponding selects show an +# additional unexpected entry like +# start_time ... sql_text +# TIMESTAMP ... set session long_query_time=... +# (Bug#40377 sporadic pushbuild failure in log_state: result mismatch) +--replace_result 2 <long_query_time> +set @long_query_time = 2; +set session long_query_time = @long_query_time; +select sleep(@long_query_time + 1); +--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME +select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; +--echo # Switch to connection default +connection default; + +set global slow_query_log= ON; +--echo # Switch to connection con1 +connection con1; +set session long_query_time = @long_query_time; +select sleep(@long_query_time + 1); +--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME +select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; +--echo # Switch to connection default +connection default; +show global variables +where Variable_name = 'log' or Variable_name = 'log_slow_queries' or +Variable_name = 'general_log' or Variable_name = 'slow_query_log'; + +set global general_log= ON; +set global general_log= OFF; +set global general_log= OFF; +set global slow_query_log= ON; +set global slow_query_log= OFF; +set global slow_query_log= OFF; + +set global general_log= ON; +truncate table mysql.general_log; +create table t1(f1 int); +drop table t1; +--replace_column 1 TIMESTAMP 2 USER_HOST 3 # +select * from mysql.general_log; +set global general_log= OFF; +truncate table mysql.general_log; +--replace_column 1 TIMESTAMP 2 USER_HOST 3 # +select * from mysql.general_log; +set global general_log= ON; +show global variables +where Variable_name = 'log' or Variable_name = 'log_slow_queries' or +Variable_name = 'general_log' or Variable_name = 'slow_query_log'; + +--replace_column 2 # +show variables like 'general_log_file'; +--replace_column 2 # +show variables like 'slow_query_log_file'; +show variables like 'log_output'; + +# Can't set general_log_file to a non existing file +--error ER_WRONG_VALUE_FOR_VAR +set global general_log_file='/not existing path/log.master'; + +# Can't set general_log_file to a directory +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--error ER_WRONG_VALUE_FOR_VAR +eval set global general_log_file='$MYSQLTEST_VARDIR'; + +# Can't set general_log_file to empty string +--error ER_WRONG_VALUE_FOR_VAR +set global general_log_file=''; + +--replace_column 2 # +show variables like 'general_log_file'; +set global general_log= OFF; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval set global general_log_file='$MYSQLTEST_VARDIR/tmp/log.master'; +set global general_log= ON; +create table t1(f1 int); +drop table t1; +set global general_log= OFF; +set global general_log_file=default; +set global general_log= ON; +create table t1(f1 int); +drop table t1; +--replace_column 2 # +show variables like 'general_log_file'; +--replace_column 2 # +show variables like 'slow_query_log_file'; + +set global general_log= default; +set global slow_query_log= default; +set global general_log_file= default; +set global slow_query_log_file= default; +show variables like 'general_log'; +show variables like 'slow_query_log'; +set global general_log=ON; +set global log_output=default; +show variables like 'log_output'; +set global general_log=OFF; +set global log_output=FILE; +truncate table mysql.general_log; +show variables like 'log_output'; +set global general_log=ON; +create table t1(f1 int); +--replace_column 1 TIMESTAMP 2 USER_HOST 3 # +select * from mysql.general_log; +set global general_log=OFF; +set global log_output="FILE,TABLE"; +show variables like 'log_output'; +set global general_log=ON; +drop table t1; +--replace_column 1 TIMESTAMP 2 USER_HOST 3 # +select * from mysql.general_log; + +# Reset to initial values +SET @@global.general_log = @old_general_log; +SET @@global.general_log_file = @old_general_log_file; +SET @@global.slow_query_log = @old_slow_query_log; +SET @@global.slow_query_log_file = @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} + + +########################################################################### + +# +# Bug#29129 (Resetting general_log while the GLOBAL READ LOCK is set causes +# a deadlock) +# + +# Test ON->OFF transition under a GLOBAL READ LOCK +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; + +FLUSH TABLES WITH READ LOCK; + +SET GLOBAL general_log = OFF; +SET GLOBAL slow_query_log = OFF; + +UNLOCK TABLES; + +# Test OFF->ON transition under a GLOBAL READ LOCK +FLUSH TABLES WITH READ LOCK; + +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; + +UNLOCK TABLES; + +# Test ON->OFF transition under a GLOBAL READ_ONLY +SET GLOBAL READ_ONLY = ON; + +SET GLOBAL general_log = OFF; +SET GLOBAL slow_query_log = OFF; + +SET GLOBAL READ_ONLY = OFF; + +# Test OFF->ON transition under a GLOBAL READ_ONLY +SET GLOBAL READ_ONLY = ON; + +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; + +SET GLOBAL READ_ONLY = OFF; + +# Reset to initial values +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; + + +########################################################################### + +# +# Bug#29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it +# + +SET GLOBAL general_log = ON; + +SHOW VARIABLES LIKE 'general_log'; +SHOW VARIABLES LIKE 'log'; +SELECT @@general_log, @@log; +SET GLOBAL log = 0; +SHOW VARIABLES LIKE 'general_log'; +SHOW VARIABLES LIKE 'log'; +SELECT @@general_log, @@log; +SET GLOBAL general_log = 1; +SHOW VARIABLES LIKE 'general_log'; +SHOW VARIABLES LIKE 'log'; +SELECT @@general_log, @@log; + +SHOW VARIABLES LIKE 'slow_query_log'; +SHOW VARIABLES LIKE 'log_slow_queries'; +SELECT @@slow_query_log, @@log_slow_queries; +SET GLOBAL log_slow_queries = 0; +SHOW VARIABLES LIKE 'slow_query_log'; +SHOW VARIABLES LIKE 'log_slow_queries'; +SELECT @@slow_query_log, @@log_slow_queries; +SET GLOBAL slow_query_log = 1; +SHOW VARIABLES LIKE 'slow_query_log'; +SHOW VARIABLES LIKE 'log_slow_queries'; +SELECT @@slow_query_log, @@log_slow_queries; + +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; + + +########################################################################### + +# +# Bug#31604: server crash when setting slow_query_log_file/general_log_file +# + +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL general_log_file= CONCAT('/not existing path/log.maste', 'r'); +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL general_log_file= NULL; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL slow_query_log_file= CONCAT('/not existing path/log.maste', 'r'); +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL slow_query_log_file= NULL; + +# Reset to initial values in case a setting above was successful. +SET GLOBAL general_log_file= @old_general_log_file; +SET GLOBAL slow_query_log_file= @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} + +########################################################################### + +--echo +--echo # -- +--echo # -- Bug#32748: Inconsistent handling of assignments to +--echo # -- general_log_file/slow_query_log_file. +--echo # -- + +--echo +SET GLOBAL general_log_file = 'bug32748.query.log'; +SET GLOBAL slow_query_log_file = 'bug32748.slow.log'; + +--echo +SHOW VARIABLES LIKE '%log_file'; + +# Reset to initial values +--echo +SET GLOBAL general_log_file = @old_general_log_file; +SET GLOBAL slow_query_log_file = @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} + +--echo +--echo # -- End of Bug#32748. + + +########################################################################### + +# WL#4403 - deprecate @log and @slow_log_queries variables + +# These server system variables are all deprecated +# -- show for command-line as well! +--echo deprecated: +SET GLOBAL log = 0; +SET GLOBAL log_slow_queries = 0; +SET GLOBAL log = DEFAULT; +SET GLOBAL log_slow_queries = DEFAULT; + +# These server system variables are NOT deprecated. +--echo not deprecated: +SELECT @@global.general_log_file INTO @my_glf; +SELECT @@global.slow_query_log_file INTO @my_sqlf; +SET GLOBAL general_log = 0; +SET GLOBAL slow_query_log = 0; +SET GLOBAL general_log_file = 'WL4403_G.log'; +SET GLOBAL slow_query_log_file = 'WL4403_SQ.log'; +SET GLOBAL general_log_file = @my_glf; +SET GLOBAL slow_query_log_file = @my_sqlf; +SET GLOBAL general_log = DEFAULT; +SET GLOBAL slow_query_log = DEFAULT; + +## Reset to initial values +SET @@global.general_log = @old_general_log; +SET @@global.general_log_file = @old_general_log_file; +SET @@global.slow_query_log = @old_slow_query_log; +SET @@global.slow_query_log_file = @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} + + +--echo End of 5.1 tests + +--enable_ps_protocol + +# +# Cleanup +# +# Disconnect must be done last to avoid delayed 'Quit' message in general log +--echo # Close connection con1 +disconnect con1; +# set back the saved default values +connection default; + +# Reset global system variables to initial values if forgotten somewhere above. +SET global general_log = @old_general_log; +SET global general_log_file = @old_general_log_file; +SET global slow_query_log = @old_slow_query_log; +SET global slow_query_log_file = @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} + +# Remove the log files that was created in the "default location" +# i.e var/run +--remove_file $MYSQLTEST_VARDIR/run/mysqld.log +--remove_file $MYSQLTEST_VARDIR/tmp/log.master diff --git a/mysql-test/t/log_tables-big-master.opt b/mysql-test/t/log_tables-big-master.opt new file mode 100644 index 00000000000..35ff7911705 --- /dev/null +++ b/mysql-test/t/log_tables-big-master.opt @@ -0,0 +1 @@ +--log-slow-queries diff --git a/mysql-test/t/log_tables-big.test b/mysql-test/t/log_tables-big.test new file mode 100644 index 00000000000..8c956fa6f55 --- /dev/null +++ b/mysql-test/t/log_tables-big.test @@ -0,0 +1,35 @@ +# this test needs multithreaded mysqltest +-- source include/not_embedded.inc + +# Test sleeps for long times +--source include/big_test.inc + +# check that CSV engine was compiled in +--source include/have_csv.inc + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); + +# +# Bug #27638: slow logging to CSV table inserts bad query_time and lock_time values +# +connection con1; +set session long_query_time=10; +select get_lock('bug27638', 1); +connection con2; +set session long_query_time=1; +truncate table mysql.slow_log; +select get_lock('bug27638', 2); +select if (query_time between '00:00:01' and '00:00:10', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log; +truncate table mysql.slow_log; +select get_lock('bug27638', 60); +select if (query_time between '00:00:59' and '00:01:10', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log; +truncate table mysql.slow_log; +select get_lock('bug27638', 101); +select if (query_time between '00:01:40' and '00:01:50', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log; +connection con1; +select release_lock('bug27638'); +connection default; + +disconnect con1; +disconnect con2; diff --git a/mysql-test/t/log_tables-master.opt b/mysql-test/t/log_tables-master.opt new file mode 100644 index 00000000000..3ece9710a45 --- /dev/null +++ b/mysql-test/t/log_tables-master.opt @@ -0,0 +1 @@ +--log-output=table,file --log-slow-queries diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test new file mode 100644 index 00000000000..076f2e8bc3b --- /dev/null +++ b/mysql-test/t/log_tables.test @@ -0,0 +1,1034 @@ +# this test needs multithreaded mysqltest +-- source include/not_embedded.inc +# +# Basic log tables test +# + +# check that CSV engine was compiled in +--source include/have_csv.inc + +SET @old_general_log_state = @@global.general_log; +SET @old_log_output= @@global.log_output; +SET @old_slow_query_log= @@global.slow_query_log; +SET @old_general_log= @@global.general_log; +SET @old_long_query_time= @@session.long_query_time; + +--disable_ps_protocol +use mysql; + +# Capture initial settings of system variables +# so that we can revert to old state after manipulation for testing +# NOTE: PLEASE USE THESE VALUES TO 'RESET' SYSTEM VARIABLES +# Capturing old values within the tests results in loss of values +# due to people not paying attention to previous tests' changes, captures +# or improper cleanup +SET @saved_long_query_time = @@long_query_time; +SET @saved_log_output = @@log_output; +SET @saved_general_log = @@GLOBAL.general_log; +SET @saved_slow_query_log = @@GLOBAL.slow_query_log; + +SELECT @saved_long_query_time, @saved_log_output, @saved_general_log, @saved_slow_query_log; + + + +# +# Check that log tables work and we can do basic selects. This also +# tests truncate, which works in a special mode with the log tables +# + +truncate table general_log; +--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID +select * from general_log; +truncate table slow_log; +--replace_column 1 TIMESTAMP 2 USER_HOST +select * from slow_log; + +# +# We want to check that a record newly written to a log table shows up for +# the query: since log tables use concurrent insert machinery and log tables +# are always locked by artificial THD, this feature requires additional +# check in ha_tina::write_row. This simple test should prove that the +# log table flag in the table handler is triggered and working. +# + +truncate table general_log; +--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID +select * from general_log where argument like '%general_log%'; + + +# +# Check some basic queries interfering with the log tables. +# In our test we'll use a tbale with verbose comments to the short +# command type names, used in the tables +# + +create table join_test (verbose_comment varchar (80), command_type varchar(64)); + +insert into join_test values ("User performed a usual SQL query", "Query"); +insert into join_test values ("New DB connection was registered", "Connect"); +insert into join_test values ("Get the table info", "Field List"); + +--replace_column 2 USER_HOST +select verbose_comment, user_host, argument + from mysql.general_log join join_test + on (mysql.general_log.command_type = join_test.command_type); + +drop table join_test; + +# +# check that flush of the log table work fine +# + +flush logs; + +# +# check locking of the log tables +# + +--error ER_CANT_LOCK_LOG_TABLE +lock tables mysql.general_log WRITE; + +--error ER_CANT_LOCK_LOG_TABLE +lock tables mysql.slow_log WRITE; + +# +# This attemts to get TL_READ_NO_INSERT lock, which is incompatible with +# TL_WRITE_CONCURRENT_INSERT. This should fail. We issue this error as log +# tables are always opened and locked by the logger. +# + +--error ER_CANT_LOCK_LOG_TABLE +lock tables mysql.general_log READ; + +--error ER_CANT_LOCK_LOG_TABLE +lock tables mysql.slow_log READ; + +# +# This call should result in TL_READ lock on the log table. +# This is not ok and should fail. +# + +--error ER_CANT_LOCK_LOG_TABLE +lock tables mysql.slow_log READ LOCAL, mysql.general_log READ LOCAL; + +# Misc locking tests + +show create table mysql.general_log; +show fields from mysql.general_log; + +show create table mysql.slow_log; +show fields from mysql.slow_log; + +# +# check that FLUSH LOGS does not flush the log tables +# + +flush logs; +flush tables; + +SET GLOBAL GENERAL_LOG=ON; +SET GLOBAL SLOW_QUERY_LOG=ON; + +show open tables; +flush logs; +show open tables; + +# +# check that FLUSH TABLES does flush the log tables +# + +flush tables; +# Since the flush is logged, mysql.general_log will be in the cache +show open tables; + +SET GLOBAL GENERAL_LOG=OFF; +SET GLOBAL SLOW_QUERY_LOG=OFF; + +flush tables; +# Here the table cache is empty +show open tables; + +SET GLOBAL GENERAL_LOG=ON; +SET GLOBAL SLOW_QUERY_LOG=ON; + +# +# Bug#23924 general_log truncates queries with character set introducers. +# +truncate table mysql.general_log; +set names binary; +select _koi8r'' as test; +--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID +select * from mysql.general_log; +set names utf8; + +# +# Bug #16905 Log tables: unicode statements are logged incorrectly +# + +truncate table mysql.general_log; +set names utf8; +create table bug16905 (s char(15) character set utf8 default 'пусто'); +insert into bug16905 values ('новое'); +--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID +select * from mysql.general_log; +drop table bug16905; + +# +# Bug #17600: Invalid data logged into mysql.slow_log +# + +truncate table mysql.slow_log; +set session long_query_time=1; +select sleep(2); +--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME +select * from mysql.slow_log; +set @@session.long_query_time = @saved_long_query_time; + +# +# Bug #18559 log tables cannot change engine, and gets deadlocked when +# dropping w/ log on +# + +# check that appropriate error messages are given when one attempts to alter +# or drop a log tables, while corresponding logs are enabled +--error ER_BAD_LOG_STATEMENT +alter table mysql.general_log engine=myisam; +--error ER_BAD_LOG_STATEMENT +alter table mysql.slow_log engine=myisam; + +--error ER_BAD_LOG_STATEMENT +drop table mysql.general_log; +--error ER_BAD_LOG_STATEMENT +drop table mysql.slow_log; + +# check that one can alter log tables to MyISAM +set global general_log='OFF'; + +# cannot convert another log table +--error ER_BAD_LOG_STATEMENT +alter table mysql.slow_log engine=myisam; + +# alter both tables +set global slow_query_log='OFF'; +# check that both tables use CSV engine +show create table mysql.general_log; +show create table mysql.slow_log; + +alter table mysql.general_log engine=myisam; +alter table mysql.slow_log engine=myisam; + +# check that the tables were converted +show create table mysql.general_log; +show create table mysql.slow_log; + +# enable log tables and chek that new tables indeed work +set global general_log='ON'; +set global slow_query_log='ON'; + +--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID +select * from mysql.general_log; + +# check that flush of myisam-based log tables work fine +flush logs; + +# check locking of myisam-based log tables + +--error ER_CANT_LOCK_LOG_TABLE +lock tables mysql.general_log WRITE; + +--error ER_CANT_LOCK_LOG_TABLE +lock tables mysql.slow_log WRITE; + +# +# This attemts to get TL_READ_NO_INSERT lock, which is incompatible with +# TL_WRITE_CONCURRENT_INSERT. This should fail. We issue this error as log +# tables are always opened and locked by the logger. +# + +--error ER_CANT_LOCK_LOG_TABLE +lock tables mysql.general_log READ; + +--error ER_CANT_LOCK_LOG_TABLE +lock tables mysql.slow_log READ; + +# check that we can drop them +set global general_log='OFF'; +set global slow_query_log='OFF'; + +# check that alter table doesn't work for other engines +set @save_storage_engine= @@session.storage_engine; +set storage_engine= MEMORY; +--error ER_UNSUPORTED_LOG_ENGINE +alter table mysql.slow_log engine=ndb; +--error ER_UNSUPORTED_LOG_ENGINE +alter table mysql.slow_log engine=innodb; +--error ER_UNSUPORTED_LOG_ENGINE +alter table mysql.slow_log engine=archive; +--error ER_UNSUPORTED_LOG_ENGINE +alter table mysql.slow_log engine=blackhole; +set storage_engine= @save_storage_engine; + +drop table mysql.slow_log; +drop table mysql.general_log; + +# check that table share cleanup is performed correctly (double drop) + +--error ER_BAD_TABLE_ERROR +drop table mysql.general_log; +--error ER_BAD_TABLE_ERROR +drop table mysql.slow_log; + +# recreate tables and enable logs + +use mysql; + +CREATE TABLE `general_log` ( + `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP + ON UPDATE CURRENT_TIMESTAMP, + `user_host` mediumtext NOT NULL, + `thread_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, + `command_type` varchar(64) NOT NULL, + `argument` mediumtext NOT NULL +) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'; + +CREATE TABLE `slow_log` ( + `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP + ON UPDATE CURRENT_TIMESTAMP, + `user_host` mediumtext NOT NULL, + `query_time` time NOT NULL, + `lock_time` time NOT NULL, + `rows_sent` int(11) NOT NULL, + `rows_examined` int(11) NOT NULL, + `db` varchar(512) NOT NULL, + `last_insert_id` int(11) NOT NULL, + `insert_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, + `sql_text` mediumtext NOT NULL +) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'; + +set global general_log='ON'; +set global slow_query_log='ON'; +use test; + +# +# Bug #20139 Infinite loop after "FLUSH" and "LOCK tabX, general_log" +# + +flush tables with read lock; +unlock tables; +use mysql; +--error ER_CANT_LOCK_LOG_TABLE +lock tables general_log read local, help_category read local; +unlock tables; + +# +# Bug #17544 Cannot do atomic log rotate and +# Bug #21785 Server crashes after rename of the log table +# + +SET SESSION long_query_time = 1000; +--disable_warnings +drop table if exists mysql.renamed_general_log; +drop table if exists mysql.renamed_slow_log; +drop table if exists mysql.general_log_new; +drop table if exists mysql.slow_log_new; +--enable_warnings + +use mysql; +# Should result in error +--error ER_CANT_RENAME_LOG_TABLE +RENAME TABLE general_log TO renamed_general_log; +--error ER_CANT_RENAME_LOG_TABLE +RENAME TABLE slow_log TO renamed_slow_log; + +#check rotate logs +truncate table general_log; +--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID +select * from general_log; + +truncate table slow_log; +--replace_column 1 TIMESTAMP 2 USER_HOST +select * from slow_log; + +create table general_log_new like general_log; +rename table general_log TO renamed_general_log, general_log_new TO general_log; + +create table slow_log_new like slow_log; +rename table slow_log TO renamed_slow_log, slow_log_new TO slow_log; + +# check that rename checks more then first table in the list +--error ER_CANT_RENAME_LOG_TABLE +rename table general_log TO general_log_new, renamed_general_log TO general_log, slow_log to renamed_slow_log; + +# now check the content of tables +--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID +select * from general_log; +--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID +select * from renamed_general_log; + +# the content of the slow log is empty, but we will try a select anyway +--replace_column 1 TIMESTAMP 2 USER_HOST +select * from slow_log; +--replace_column 1 TIMESTAMP 2 USER_HOST +select * from renamed_slow_log; + +# check that we can do whatever we want with disabled log +set global general_log='OFF'; +RENAME TABLE general_log TO general_log2; + +set global slow_query_log='OFF'; +RENAME TABLE slow_log TO slow_log2; + +# this should fail +--error ER_NO_SUCH_TABLE +set global general_log='ON'; +--error ER_NO_SUCH_TABLE +set global slow_query_log='ON'; + +RENAME TABLE general_log2 TO general_log; +RENAME TABLE slow_log2 TO slow_log; +SET SESSION long_query_time = @saved_long_query_time; + +# this should work +set global general_log='ON'; +set global slow_query_log='ON'; +# now check flush logs +flush logs; +flush logs; +drop table renamed_general_log, renamed_slow_log; +use test; + +# +# Bug#27858 (Failing to log to a log table doesn't log anything to error log) +# +# This test works as expected, it's a negative test. +# The message "[ERROR] Failed to write to mysql.general_log" +# is printed to master.err when writing to the table mysql.general_log +# failed. +# However, this message is picked up by mysql-test-run.pl, +# and reported as a test failure, which is a false negative. +# There is no current way to *selectively* filter out these expected error conditions +# (see mysql-test/lib/mtr_report.pl, mtr_report_stats()). +# Instead of filtering all occurences of "Failed to write to +# mysql.general_log", which could hide bugs when the error is not expected, +# this test case is commented instead. +# TODO: improve filtering of expected errors in master.err in +# mysql-test-run.pl (based on the test name ?), and uncomment this test. + +# --disable_warnings +# drop table if exists mysql.bad_general_log; +# drop table if exists mysql.bad_slow_log; +# drop table if exists mysql.general_log_hide; +# drop table if exists mysql.slow_log_hide; +# --enable_warnings +# +# create table mysql.bad_general_log (a int) engine= CSV; +# create table mysql.bad_slow_log (a int) engine= CSV; +# +# # Rename does not perform checks on the table structure, +# # exploiting this to force a failure to log +# rename table mysql.general_log to mysql.general_log_hide, mysql.bad_general_log TO mysql.general_log; +# rename table mysql.slow_log to mysql.slow_log_hide, mysql.bad_slow_log TO mysql.slow_log; +# +# # The following message should be printed in master.log: +# # [ERROR] Failed to write to mysql.general_log +# # TODO: See how verifying this could be automated +# +# flush tables; +# select "logging this should fail"; +# +# # Restore the log tables +# +# rename table mysql.general_log to mysql.bad_general_log, mysql.general_log_hide TO mysql.general_log; +# rename table mysql.slow_log to mysql.bad_slow_log, mysql.slow_log_hide TO mysql.slow_log; +# +# flush tables; +# +# drop table mysql.bad_general_log; +# drop table mysql.bad_slow_log; + +# +# Bug #21966 Strange warnings on repair of the log tables +# + +use mysql; +# check that no warning occurs on repair of the log tables +repair table general_log; +repair table slow_log; +# check that no warning occurs on "create like" for the log tables +create table general_log_new like general_log; +create table slow_log_new like slow_log; +show tables like "%log%"; +drop table slow_log_new, general_log_new; +use test; + +# +# Bug#27857 (Log tables supplies the wrong value for generating +# AUTO_INCREMENT numbers) +# + +SET GLOBAL LOG_OUTPUT = 'TABLE'; + +## test the general log + +SET GLOBAL general_log = 0; +FLUSH LOGS; + +TRUNCATE TABLE mysql.general_log; +ALTER TABLE mysql.general_log ENGINE = MyISAM; +ALTER TABLE mysql.general_log + ADD COLUMN seq BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY; + +SET GLOBAL general_log = 1; +FLUSH LOGS; + +--replace_column 1 EVENT_TIME 2 USER_HOST 3 THREAD_ID 4 SERVER_ID +SELECT * FROM mysql.general_log; +--replace_column 1 EVENT_TIME 2 USER_HOST 3 THREAD_ID 4 SERVER_ID +SELECT * FROM mysql.general_log; +SELECT "My own query 1"; +SELECT "My own query 2"; +--replace_column 1 EVENT_TIME 2 USER_HOST 3 THREAD_ID 4 SERVER_ID +SELECT * FROM mysql.general_log; + +SET GLOBAL general_log = 0; +FLUSH LOGS; + +ALTER TABLE mysql.general_log DROP COLUMN seq; +ALTER TABLE mysql.general_log ENGINE = CSV; + +## test the slow query log + +SET GLOBAL slow_query_log = 0; +FLUSH LOGS; + +TRUNCATE TABLE mysql.slow_log; +ALTER TABLE mysql.slow_log ENGINE = MyISAM; + +ALTER TABLE mysql.slow_log + ADD COLUMN seq BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY; + +SET SESSION long_query_time = 1; +SET GLOBAL slow_query_log = 1; +FLUSH LOGS; + +## FLUSH LOGS above might be slow, so the following is +## logged as either seq 1-4 or seq 2-5 +SELECT "My own slow query", sleep(2); +SELECT "My own slow query", sleep(2); +SELECT "My own slow query", sleep(2); +SELECT "My own slow query", sleep(2); + +## So we look for seq 2-4 +--replace_column 1 START_TIME 2 USER_HOST 3 QUERY_TIME +SELECT * FROM mysql.slow_log WHERE seq >= 2 LIMIT 3; + +SET GLOBAL slow_query_log = 0; +SET SESSION long_query_time =@saved_long_query_time; +FLUSH LOGS; + +ALTER TABLE mysql.slow_log DROP COLUMN seq; +ALTER TABLE mysql.slow_log ENGINE = CSV; + +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; + +# +# Bug#25422 (Hang with log tables) +# + +--disable_warnings +drop procedure if exists proc25422_truncate_slow; +drop procedure if exists proc25422_truncate_general; +drop procedure if exists proc25422_alter_slow; +drop procedure if exists proc25422_alter_general; +--enable_warnings + +delimiter //; + +use test// +create procedure proc25422_truncate_slow (loops int) +begin + declare v1 int default 0; + declare continue handler for sqlexception /* errors from truncate */ + begin end; + while v1 < loops do + truncate mysql.slow_log; + set v1 = v1 + 1; + end while; +end// + +create procedure proc25422_truncate_general (loops int) +begin + declare v1 int default 0; + declare continue handler for sqlexception /* errors from truncate */ + begin end; + while v1 < loops do + truncate mysql.general_log; + set v1 = v1 + 1; + end while; +end// + +create procedure proc25422_alter_slow (loops int) +begin + declare v1 int default 0; + declare ER_BAD_LOG_STATEMENT condition for 1575; + declare continue handler for ER_BAD_LOG_STATEMENT begin end; + + while v1 < loops do + set @old_log_state = @@global.slow_query_log; + set global slow_query_log = 'OFF'; + alter table mysql.slow_log engine = CSV; + set global slow_query_log = @old_log_state; + set v1 = v1 + 1; + end while; +end// + +create procedure proc25422_alter_general (loops int) +begin + declare v1 int default 0; + declare ER_BAD_LOG_STATEMENT condition for 1575; + declare continue handler for ER_BAD_LOG_STATEMENT begin end; + + while v1 < loops do + set @old_log_state = @@global.general_log; + set global general_log = 'OFF'; + alter table mysql.general_log engine = CSV; + set global general_log = @old_log_state; + set v1 = v1 + 1; + end while; +end// + +delimiter ;// + +set @iterations=100; + +--echo "Serial test (proc25422_truncate_slow)" +call proc25422_truncate_slow(@iterations); +--echo "Serial test (proc25422_truncate_general)" +call proc25422_truncate_general(@iterations); +--echo "Serial test (proc25422_alter_slow)" +call proc25422_alter_slow(@iterations); +--echo "Serial test (proc25422_alter_general)" +call proc25422_alter_general(@iterations); + +--echo "Parallel test" + +# ER_BAD_LOG_STATEMENT errors will occur, +# since concurrent threads do SET GLOBAL general_log= ... +# This is silenced by handlers and will not affect the test + +connect (addconroot1, localhost, root,,); +connect (addconroot2, localhost, root,,); +connect (addconroot3, localhost, root,,); +connect (addconroot4, localhost, root,,); +connect (addconroot5, localhost, root,,); +connect (addconroot6, localhost, root,,); +connect (addconroot7, localhost, root,,); +connect (addconroot8, localhost, root,,); + +connection addconroot1; +send call proc25422_truncate_slow(@iterations); +connection addconroot2; +send call proc25422_truncate_slow(@iterations); + +connection addconroot3; +send call proc25422_truncate_general(@iterations); +connection addconroot4; +send call proc25422_truncate_general(@iterations); + +connection addconroot5; +send call proc25422_alter_slow(@iterations); +connection addconroot6; +send call proc25422_alter_slow(@iterations); + +connection addconroot7; +send call proc25422_alter_general(@iterations); +connection addconroot8; +send call proc25422_alter_general(@iterations); + +connection addconroot1; +reap; +connection addconroot2; +reap; +connection addconroot3; +reap; +connection addconroot4; +reap; +connection addconroot5; +reap; +connection addconroot6; +reap; +connection addconroot7; +reap; +connection addconroot8; +reap; + +connection default; + +disconnect addconroot1; +disconnect addconroot2; +disconnect addconroot3; +disconnect addconroot4; +disconnect addconroot5; +disconnect addconroot6; +disconnect addconroot7; +disconnect addconroot8; + +drop procedure proc25422_truncate_slow; +drop procedure proc25422_truncate_general; +drop procedure proc25422_alter_slow; +drop procedure proc25422_alter_general; + +--enable_ps_protocol + + +# +# Bug#23044 (Warnings on flush of a log table) +# + +FLUSH TABLE mysql.general_log; +show warnings; + +FLUSH TABLE mysql.slow_log; +show warnings; + +# +# Bug#17876 (Truncating mysql.slow_log in a SP after using cursor locks the +# thread) +# + +--disable_warnings +DROP TABLE IF EXISTS `db_17876.slow_log_data`; +DROP TABLE IF EXISTS `db_17876.general_log_data`; +DROP PROCEDURE IF EXISTS `db_17876.archiveSlowLog`; +DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`; +DROP DATABASE IF EXISTS `db_17876`; +--enable_warnings + +CREATE DATABASE db_17876; + +CREATE TABLE `db_17876.slow_log_data` ( + `start_time` timestamp default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `user_host` mediumtext , + `query_time` time , + `lock_time` time , + `rows_sent` int(11) , + `rows_examined` int(11) , + `db` varchar(512) default NULL, + `last_insert_id` int(11) default NULL, + `insert_id` int(11) default NULL, + `server_id` int(11) default NULL, + `sql_text` mediumtext +); + +CREATE TABLE `db_17876.general_log_data` ( + `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `user_host` mediumtext, + `thread_id` int(11) DEFAULT NULL, + `server_id` int(11) DEFAULT NULL, + `command_type` varchar(64) DEFAULT NULL, + `argument` mediumtext +); + +DELIMITER //; + +CREATE procedure `db_17876.archiveSlowLog`() +BEGIN + DECLARE start_time, query_time, lock_time CHAR(20); + DECLARE user_host MEDIUMTEXT; + DECLARE rows_set, rows_examined, last_insert_id, insert_id, server_id INT; + DECLARE dbname MEDIUMTEXT; + DECLARE sql_text BLOB; + DECLARE done INT DEFAULT 0; + DECLARE ER_SP_FETCH_NO_DATA CONDITION for 1329; + + DECLARE cur1 CURSOR FOR SELECT * FROM mysql.slow_log; + + OPEN cur1; + + REPEAT + BEGIN + BEGIN + DECLARE CONTINUE HANDLER FOR ER_SP_FETCH_NO_DATA SET done = 1; + + FETCH cur1 INTO + start_time, user_host, query_time, lock_time, + rows_set, rows_examined, dbname, last_insert_id, + insert_id, server_id, sql_text; + END; + + IF NOT done THEN + BEGIN + INSERT INTO + `db_17876.slow_log_data` + VALUES(start_time, user_host, query_time, lock_time, rows_set, rows_examined, + dbname, last_insert_id, insert_id, server_id, sql_text); + END; + END IF; + END; + UNTIL done END REPEAT; + + CLOSE cur1; + TRUNCATE mysql.slow_log; +END // + +CREATE procedure `db_17876.archiveGeneralLog`() +BEGIN + DECLARE event_time CHAR(20); + DECLARE user_host, argument MEDIUMTEXT; + DECLARE thread_id, server_id INT; + DECLARE sql_text BLOB; + DECLARE done INT DEFAULT 0; + DECLARE command_type VARCHAR(64); + DECLARE ER_SP_FETCH_NO_DATA CONDITION for 1329; + + DECLARE cur1 CURSOR FOR SELECT * FROM mysql.general_log; + + OPEN cur1; + + REPEAT + BEGIN + BEGIN + DECLARE CONTINUE HANDLER FOR ER_SP_FETCH_NO_DATA SET done = 1; + + FETCH cur1 INTO + event_time, user_host, thread_id, server_id, + command_type, argument; + END; + + IF NOT done THEN + BEGIN + INSERT INTO + `db_17876.general_log_data` + VALUES(event_time, user_host, thread_id, server_id, + command_type, argument); + END; + END IF; + END; + UNTIL done END REPEAT; + + CLOSE cur1; + TRUNCATE mysql.general_log; +END // + +DELIMITER ;// + +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; + +select "put something into general_log"; +select "... and something more ..."; + +call `db_17876.archiveSlowLog`(); +call `db_17876.archiveGeneralLog`(); + +SET GLOBAL general_log = OFF; +SET GLOBAL slow_query_log = OFF; + +call `db_17876.archiveSlowLog`(); +call `db_17876.archiveGeneralLog`(); + +DROP TABLE `db_17876.slow_log_data`; +DROP TABLE `db_17876.general_log_data`; +DROP PROCEDURE IF EXISTS `db_17876.archiveSlowLog`; +DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`; +DROP DATABASE IF EXISTS `db_17876`; + +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; + +# +# Bug#21557 entries in the general query log truncated at 1000 characters. +# + +select CONNECTION_ID() into @thread_id; +truncate table mysql.general_log; +set global general_log = on; +--disable_result_log +set @lparam = "000 001 002 003 004 005 006 007 008 009" + "010 011 012 013 014 015 016 017 018 019" + "020 021 022 023 024 025 026 027 028 029" + "030 031 032 033 034 035 036 037 038 039" + "040 041 042 043 044 045 046 047 048 049" + "050 051 052 053 054 055 056 057 058 059" + "060 061 062 063 064 065 066 067 068 069" + "070 071 072 073 074 075 076 077 078 079" + "080 081 082 083 084 085 086 087 088 089" + "090 091 092 093 094 095 096 097 098 099" + "100 101 102 103 104 105 106 107 108 109" + "110 111 112 113 114 115 116 117 118 119" + "120 121 122 123 124 125 126 127 128 129" + "130 131 132 133 134 135 136 137 138 139" + "140 141 142 143 144 145 146 147 148 149" + "150 151 152 153 154 155 156 157 158 159" + "160 161 162 163 164 165 166 167 168 169" + "170 171 172 173 174 175 176 177 178 179" + "180 181 182 183 184 185 186 187 188 189" + "190 191 192 193 194 195 196 197 198 199" + "200 201 202 203 204 205 206 207 208 209" + "210 211 212 213 214 215 216 217 218 219" + "220 221 222 223 224 225 226 227 228 229" + "230 231 232 233 234 235 236 237 238 239" + "240 241 242 243 244 245 246 247 248 249" + "250 251 252 253 254 255 256 257 258 259" + "260 261 262 263 264 265 266 267 268 269" + "270 271 272 273 274 275 276 277 278 279" + "280 281 282 283 284 285 286 287 288 289" + "290 291 292 293 294 295 296 297 298 299" + "300 301 302 303 304 305 306 307 308 309" + "310 311 312 313 314 315 316 317 318 319" + "320 321 322 323 324 325 326 327 328 329" + "330 331 332 333 334 335 336 337 338 339" + "340 341 342 343 344 345 346 347 348 349" + "350 351 352 353 354 355 356 357 358 359" + "360 361 362 363 364 365 366 367 368 369" + "370 371 372 373 374 375 376 377 378 379" + "380 381 382 383 384 385 386 387 388 389" + "390 391 392 393 394 395 396 397 398 399" + "400 401 402 403 404 405 406 407 408 409" + "410 411 412 413 414 415 416 417 418 419" + "420 421 422 423 424 425 426 427 428 429" + "430 431 432 433 434 435 436 437 438 439" + "440 441 442 443 444 445 446 447 448 449" + "450 451 452 453 454 455 456 457 458 459" + "460 461 462 463 464 465 466 467 468 469" + "470 471 472 473 474 475 476 477 478 479" + "480 481 482 483 484 485 486 487 488 489" + "490 491 492 493 494 495 496 497 498 499" + "500 501 502 503 504 505 506 507 508 509" + "510 511 512 513 514 515 516 517 518 519" + "520 521 522 523 524 525 526 527 528 529" + "530 531 532 533 534 535 536 537 538 539" + "540 541 542 543 544 545 546 547 548 549" + "550 551 552 553 554 555 556 557 558 559" + "560 561 562 563 564 565 566 567 568 569" + "570 571 572 573 574 575 576 577 578 579" + "580 581 582 583 584 585 586 587 588 589" + "590 591 592 593 594 595 596 597 598 599" + "600 601 602 603 604 605 606 607 608 609" + "610 611 612 613 614 615 616 617 618 619" + "620 621 622 623 624 625 626 627 628 629" + "630 631 632 633 634 635 636 637 638 639" + "640 641 642 643 644 645 646 647 648 649" + "650 651 652 653 654 655 656 657 658 659" + "660 661 662 663 664 665 666 667 668 669" + "670 671 672 673 674 675 676 677 678 679" + "680 681 682 683 684 685 686 687 688 689" + "690 691 692 693 694 695 696 697 698 699" + "700 701 702 703 704 705 706 707 708 709" + "710 711 712 713 714 715 716 717 718 719" + "720 721 722 723 724 725 726 727 728 729" + "730 731 732 733 734 735 736 737 738 739" + "740 741 742 743 744 745 746 747 748 749" + "750 751 752 753 754 755 756 757 758 759" + "760 761 762 763 764 765 766 767 768 769" + "770 771 772 773 774 775 776 777 778 779" + "780 781 782 783 784 785 786 787 788 789" + "790 791 792 793 794 795 796 797 798 799" + "800 801 802 803 804 805 806 807 808 809" + "810 811 812 813 814 815 816 817 818 819" + "820 821 822 823 824 825 826 827 828 829" + "830 831 832 833 834 835 836 837 838 839" + "840 841 842 843 844 845 846 847 848 849" + "850 851 852 853 854 855 856 857 858 859" + "860 861 862 863 864 865 866 867 868 869" + "870 871 872 873 874 875 876 877 878 879" + "880 881 882 883 884 885 886 887 888 889" + "890 891 892 893 894 895 896 897 898 899" + "900 901 902 903 904 905 906 907 908 909" + "910 911 912 913 914 915 916 917 918 919" + "920 921 922 923 924 925 926 927 928 929" + "930 931 932 933 934 935 936 937 938 939" + "940 941 942 943 944 945 946 947 948 949" + "950 951 952 953 954 955 956 957 958 959" + "960 961 962 963 964 965 966 967 968 969" + "970 971 972 973 974 975 976 977 978 979" + "980 981 982 983 984 985 986 987 988 989" + "990 991 992 993 994 995 996 997 998 999"; +--enable_result_log +prepare long_query from "select ? as long_query"; +--disable_result_log +execute long_query using @lparam; +--enable_result_log +set global general_log = off; +select command_type, argument from mysql.general_log where thread_id = @thread_id; +deallocate prepare long_query; +set global general_log = @old_general_log; + +# +# Bug#34306: Can't make copy of log tables when server binary log is enabled +# + +--disable_warnings +DROP TABLE IF EXISTS log_count; +DROP TABLE IF EXISTS slow_log_copy; +DROP TABLE IF EXISTS general_log_copy; +--enable_warnings + +CREATE TABLE log_count (count BIGINT(21)); + +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; + +CREATE TABLE slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.slow_log)); +DROP TABLE slow_log_copy; + +CREATE TABLE general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); +DROP TABLE general_log_copy; + +SET GLOBAL general_log = OFF; +SET GLOBAL slow_query_log = OFF; + +CREATE TABLE slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.slow_log)); +DROP TABLE slow_log_copy; + +CREATE TABLE general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); +DROP TABLE general_log_copy; + +SET GLOBAL general_log = @saved_general_log; +SET GLOBAL slow_query_log = @saved_slow_query_log; + +DROP TABLE log_count; + +# +# Bug #31700: thd->examined_row_count not incremented for 'const' type queries +# + +SET SESSION long_query_time = 0; +SET GLOBAL slow_query_log = ON; +FLUSH LOGS; +TRUNCATE TABLE mysql.slow_log; + +# Let there be three columns, unique, non-unique, and non-indexed: +CREATE TABLE t1 (f1 SERIAL,f2 INT, f3 INT, PRIMARY KEY(f1), KEY(f2)); +INSERT INTO t1 VALUES (1,1,1); +INSERT INTO t1 VALUES (2,2,2); +INSERT INTO t1 VALUES (3,3,3); +INSERT INTO t1 VALUES (4,4,4); + +SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f3=4; +SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f2=3; +SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2; + +--replace_column 1 TIMESTAMP +SELECT start_time, rows_examined, rows_sent, sql_text FROM mysql.slow_log WHERE sql_text LIKE '%Bug#31700%' ORDER BY start_time; + +DROP TABLE t1; + +TRUNCATE TABLE mysql.slow_log; + +SET @@session.long_query_time= @old_long_query_time; + +SET @@global.log_output= @old_log_output; +SET @@global.slow_query_log= @old_slow_query_log; +SET @@global.general_log= @old_general_log; diff --git a/mysql-test/t/log_tables_debug.test b/mysql-test/t/log_tables_debug.test new file mode 100644 index 00000000000..19a62614608 --- /dev/null +++ b/mysql-test/t/log_tables_debug.test @@ -0,0 +1,94 @@ +### t/log_tables_debug.test +# +# Log-related tests requiring a debug-build server. +# + +# extra clean-up required due to Bug#38124, set to 1 when behavior has +# changed (see explanation in log_state.test) +let $fixed_bug38124 = 0; + +--source include/have_debug.inc + +# Several subtests modify global variables. Save the initial values only here, +# but reset to the initial values per subtest. +SET @old_general_log= @@global.general_log; +SET @old_general_log_file= @@global.general_log_file; +SET @old_slow_query_log= @@global.slow_query_log; +SET @old_slow_query_log_file= @@global.slow_query_log_file; + + +--echo # +--echo # Bug#45387 Information about statement id for prepared +--echo # statements missed from general log +--echo # + +let MYSQLD_DATADIR= `SELECT @@datadir`; + +# set logging to our specific bug log to control the entries added +SET @@global.general_log = ON; +SET @@global.general_log_file = 'bug45387_general.log'; + +# turn on output of timestamps on all log file entries +SET SESSION debug='+d,reset_log_last_time'; + +let CONN_ID= `SELECT CONNECTION_ID()`; +FLUSH LOGS; + +# reset log settings +SET @@global.general_log = @old_general_log; +SET @@global.general_log_file = @old_general_log_file; +SET SESSION debug='-d'; + +perl; + # get the relevant info from the surrounding perl invocation + $datadir= $ENV{'MYSQLD_DATADIR'}; + $conn_id= $ENV{'CONN_ID'}; + + # loop through the log file looking for the stmt querying for conn id + open(FILE, "$datadir/bug45387_general.log") or + die("Unable to read log file $datadir/bug45387_general.log: $!\n"); + while(<FILE>) { + if (/\d{6}\s+\d+:\d+:\d+[ \t]+(\d+)[ \t]+Query[ \t]+SELECT CONNECTION_ID/) { + $found= $1; + break; + } + } + + # print the result + if ($found == $conn_id) { + print "Bug#45387: ID match.\n"; + } else { + print "Bug#45387: Expected ID '$conn_id', found '$found' in log file.\n"; + print "Contents of log file:\n"; + seek(FILE, 0, 0); + while($line= <FILE>) { + print $line; + } + } + + close(FILE); +EOF + +--remove_file $MYSQLD_DATADIR/bug45387_general.log + +--echo End of 5.1 tests + + +--echo # +--echo # Cleanup +--echo # + +# Reset global system variables to initial values if forgotten somewhere above. +SET global general_log = @old_general_log; +SET global general_log_file = @old_general_log_file; +SET global slow_query_log = @old_slow_query_log; +SET global slow_query_log_file = @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} diff --git a/mysql-test/t/lowercase_fs_off.test b/mysql-test/t/lowercase_fs_off.test index 414027cb485..878564c32ab 100644 --- a/mysql-test/t/lowercase_fs_off.test +++ b/mysql-test/t/lowercase_fs_off.test @@ -14,16 +14,18 @@ flush privileges; connect (sample,localhost,sample,password,d1); connection sample; select database(); ---error 1044 +--error ER_DBACCESS_DENIED_ERROR create database d2; ---error 1044 +--error ER_DBACCESS_DENIED_ERROR create database D1; disconnect sample; +--source include/wait_until_disconnected.inc connection master; drop user 'sample'@'localhost'; drop database if exists d1; disconnect master; +--source include/wait_until_disconnected.inc connection default; # End of 4.1 tests diff --git a/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.opt b/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.opt new file mode 100644 index 00000000000..272f91d629c --- /dev/null +++ b/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.opt @@ -0,0 +1,2 @@ +--lower-case-table-names=2 +--tmpdir=$MYSQLTEST_VARDIR/tmp/MixedCase diff --git a/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh b/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh new file mode 100644 index 00000000000..95c26e3aa02 --- /dev/null +++ b/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh @@ -0,0 +1,6 @@ +# This test requires a non-lowercase tmpdir directory on a case-sensitive +# filesystem. + +d="$MYSQLTEST_VARDIR/tmp/MixedCase" +test -d "$d" || mkdir "$d" +rm -f "$d"/* diff --git a/mysql-test/t/lowercase_mixed_tmpdir_innodb.test b/mysql-test/t/lowercase_mixed_tmpdir_innodb.test new file mode 100644 index 00000000000..e3b9b7b2a32 --- /dev/null +++ b/mysql-test/t/lowercase_mixed_tmpdir_innodb.test @@ -0,0 +1,12 @@ +--source include/have_lowercase2.inc +--source include/have_innodb.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (id int) engine=InnoDB; +insert into t1 values (1); +create temporary table t2 engine=InnoDB select * from t1; +drop temporary table t2; +drop table t1; diff --git a/mysql-test/t/lowercase_table3.test b/mysql-test/t/lowercase_table3.test index 75f6e5188c5..f7ca8211288 100644 --- a/mysql-test/t/lowercase_table3.test +++ b/mysql-test/t/lowercase_table3.test @@ -6,8 +6,11 @@ --source include/have_innodb.inc --source include/have_lowercase0.inc +--source include/have_case_insensitive_file_system.inc --source include/not_windows.inc +call mtr.add_suppression("Cannot find or open table test/BUG29839 from"); + --disable_warnings DROP TABLE IF EXISTS t1,T1; --enable_warnings @@ -15,11 +18,10 @@ DROP TABLE IF EXISTS t1,T1; # # This is actually an error, but ok as the user has forced this # by using --lower-case-table-names=0 - -CREATE TABLE t1 (a int); -SELECT * from T1; -drop table t1; -flush tables; +CREATE TABLE t1 (a INT); +SELECT * FROM T1; +FLUSH TABLES; +DROP TABLE t1; # # InnoDB should in this case be case sensitive @@ -27,9 +29,9 @@ flush tables; # storing things in lower case. # -CREATE TABLE t1 (a int) ENGINE=INNODB; ---error 1146 -SELECT * from T1; -drop table t1; +CREATE TABLE bug29839 (a INT) ENGINE=INNODB; +--error ER_NO_SUCH_TABLE +SELECT * FROM BUG29839; +DROP TABLE bug29839; # End of 4.1 tests diff --git a/mysql-test/t/lowercase_utf8.test b/mysql-test/t/lowercase_utf8.test index a0d847d5b9f..01b154598fd 100644 --- a/mysql-test/t/lowercase_utf8.test +++ b/mysql-test/t/lowercase_utf8.test @@ -2,8 +2,8 @@ # Bug#25830 SHOW TABLE STATUS behaves differently depending on table name # set names utf8; -create table `А` (id int); -show tables from test like 'А'; -show tables from test like 'а'; -drop table `А`; +create table `Ö` (id int); +show tables from test like 'Ö'; +show tables from test like 'ö'; +drop table `Ö`; diff --git a/mysql-test/t/merge-big.test b/mysql-test/t/merge-big.test new file mode 100644 index 00000000000..b687973c9d1 --- /dev/null +++ b/mysql-test/t/merge-big.test @@ -0,0 +1,82 @@ +# +# Test of MERGE tables with multisession and many waits. +# +# This test takes rather long time so let us run it only in --big-test mode +--source include/big_test.inc +# We use some debug-only features in this test +--source include/have_debug.inc +# We use INFORMATION_SCHEMA.PROCESSLIST in this test +--source include/not_embedded.inc + +--disable_warnings +drop table if exists t1,t2,t3,t4,t5,t6; +--enable_warnings + +--echo # +--echo # Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE +--echo # corrupts a MERGE table +--echo # Problem #3 +--echo # +# Two FLUSH TABLES within a LOCK TABLES segment could invalidate the lock. +# This did *not* require a MERGE table. +# +# To increase reproducibility it was necessary to enter a sleep of 2 +# seconds at the end of wait_for_tables() after unlock of LOCK_open. In +# 5.0 and 5.1 the sleep must be inserted in open_and_lock_tables() after +# open_tables() instead. wait_for_tables() is not used in this case. The +# problem was that FLUSH TABLES releases LOCK_open while having unlocked +# and closed all tables. When this happened while a thread was in the +# loop in mysql_lock_tables() right after wait_for_tables() +# (open_tables()) and before retrying to lock, the thread got the lock. +# And it did not notice that the table needed a refresh after the +# [re-]open. So it executed its statement on the table. +# +# The first FLUSH TABLES kicked the INSERT out of thr_multi_lock() and +# let it wait in wait_for_tables() (open_table()). The second FLUSH +# TABLES must happen while the INSERT was on its way from +# wait_for_tables() (open_table()) to the next call of thr_multi_lock(). +# This needed to be supported by a sleep to make it repeatable. +# +CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; +LOCK TABLE t1 WRITE; +#SELECT NOW(); + --echo # connection con1 + connect (con1,localhost,root,,); + let $con1_id= `SELECT CONNECTION_ID()`; + SET SESSION debug="+d,sleep_open_and_lock_after_open"; + send INSERT INTO t1 VALUES (1); +--echo # connection default +connection default; +--echo # Let INSERT go into thr_multi_lock(). +#--sleep 8 +#SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST; +let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST + WHERE ID = $con1_id AND STATE = 'Locked'; +--source include/wait_condition.inc +#SELECT NOW(); +--echo # Kick INSERT out of thr_multi_lock(). +FLUSH TABLES; +#SELECT NOW(); +--echo # Let INSERT go through open_tables() where it sleeps. +#--sleep 8 +#SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST; +let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST + WHERE ID = $con1_id AND STATE = 'Waiting for table'; +--source include/wait_condition.inc +#SELECT NOW(); +--echo # Unlock and close table and wait for con1 to close too. +FLUSH TABLES; +#SELECT NOW(); +--echo # This should give no result. +SELECT * FROM t1; +#SELECT NOW(); +UNLOCK TABLES; + --echo # connection con1 + connection con1; + reap; + SET SESSION debug="-d,sleep_open_and_lock_after_open"; + disconnect con1; +--echo # connection default +connection default; +DROP TABLE t1; + diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 341296dbe8e..015ae28c155 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -51,6 +51,9 @@ create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2); select * from t4; --error 1168 alter table t4 add column c int; +flush tables; +--error 1168 +select * from t4; # # Test tables in different databases @@ -121,6 +124,7 @@ drop table t3,t2,t1; # Test table without unions # create table t1 (a int not null, key(a)) engine=merge; +--error 1030 select * from t1; drop table t1; @@ -191,9 +195,9 @@ select * from t6 order by a,b; insert into t1 values (99,NULL); select * from t4 where a+0 > 90; # bug#4008 - cannot determine a unique key that caused "dupl. key error" ---error 1062 +--error ER_DUP_ENTRY insert t5 values (1,1); ---error 1062 +--error ER_DUP_ENTRY insert t6 values (2,1); insert t5 values (1,1) on duplicate key update b=b+10; insert t6 values (2,1) on duplicate key update b=b+20; @@ -217,6 +221,7 @@ create table t2 (a int not null); insert into t1 values (1); insert into t2 values (2); create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); +--error ER_WRONG_MRG_TABLE select * from t3; create temporary table t4 (a int not null); create temporary table t5 (a int not null); @@ -225,6 +230,58 @@ insert into t5 values (2); create temporary table t6 (a int not null) ENGINE=MERGE UNION=(t4,t5); select * from t6; drop table t6, t3, t1, t2, t4, t5; +# +# Bug#19627 - temporary merge table locking +# MERGE table and its children must match in temporary type. +# Forbid temporary merge on non-temporary children: shown above. +# Forbid non-temporary merge on temporary children: +create temporary table t1 (a int not null); +create temporary table t2 (a int not null); +insert into t1 values (1); +insert into t2 values (2); +create table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); +--error ER_WRONG_MRG_TABLE +select * from t3; +drop table t3, t2, t1; +# Forbid children mismatch in temporary: +create table t1 (a int not null); +create temporary table t2 (a int not null); +insert into t1 values (1); +insert into t2 values (2); +create table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); +--error ER_WRONG_MRG_TABLE +select * from t3; +drop table t3; +create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); +--error ER_WRONG_MRG_TABLE +select * from t3; +drop table t3, t2, t1; +--echo # CREATE...SELECT is not implemented for MERGE tables. +CREATE TEMPORARY TABLE t1 (c1 INT NOT NULL); +CREATE TEMPORARY TABLE t2 (c1 INT NOT NULL); +CREATE TABLE t3 (c1 INT NOT NULL); +INSERT INTO t3 VALUES (3), (33); +LOCK TABLES t3 READ; +--error ER_WRONG_OBJECT +CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL) ENGINE=MERGE UNION=(t1,t2) + INSERT_METHOD=LAST SELECT * FROM t3; +--error ER_TABLE_NOT_LOCKED +SELECT * FROM t4; +UNLOCK TABLES; +CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL) ENGINE=MERGE UNION=(t1,t2) + INSERT_METHOD=LAST; +INSERT INTO t4 SELECT * FROM t3; +--echo # Alter temporary MERGE table. +ALTER TABLE t4 UNION=(t1); +LOCK TABLES t4 WRITE; +--echo # Alter temporary MERGE table under LOCk tables. +ALTER TABLE t4 UNION=(t1,t2); +UNLOCK TABLES; +--echo # MERGE table and function. +CREATE FUNCTION f1 () RETURNS INT RETURN (SELECT max(c1) FROM t3); +SELECT * FROM t4 WHERE c1 < f1(); +DROP FUNCTION f1; +DROP TABLE t4, t3, t2, t1; # # testing merge::records_in_range and optimizer @@ -280,11 +337,11 @@ create table t1 (a int); create table t2 (a int); insert into t1 values (0); insert into t2 values (1); ---error 1093 +--error ER_WRONG_OBJECT create table t3 engine=merge union=(t1, t2) select * from t1; ---error 1093 +--error ER_WRONG_OBJECT create table t3 engine=merge union=(t1, t2) select * from t2; ---error 1093 +--error ER_WRONG_OBJECT create table t3 engine=merge union=(t1, t2) select (select max(a) from t2); drop table t1, t2; @@ -570,3 +627,1010 @@ SELECT * FROM m2; DROP TABLE t1, t2, m1, m2; --echo End of 5.0 tests + +# +# Bug #8306: TRUNCATE leads to index corruption +# +create table t1 (c1 int, index(c1)); +create table t2 (c1 int, index(c1)) engine=merge union=(t1); +insert into t1 values (1); +# Close all tables. +flush tables; +# Open t2 and (implicitly) t1. +select * from t2; +# Truncate after flush works (unless another threads reopens t2 in between). +flush tables; +truncate table t1; +insert into t1 values (1); +# Close all tables. +flush tables; +# Open t2 and (implicitly) t1. +select * from t2; +# Truncate t1, wich was not recognized as open without the bugfix. +# After fix for Bug#8306 and before fix for Bug#26379, +# it should fail with a table-in-use error message, otherwise succeed. +truncate table t1; +# The insert used to fail on the crashed table. +insert into t1 values (1); +drop table t1,t2; +--echo # +--echo # Extra tests for TRUNCATE. +--echo # +--echo # Truncate MERGE table. +CREATE TABLE t1 (c1 INT, INDEX(c1)); +CREATE TABLE t2 (c1 INT, INDEX(c1)); +CREATE TABLE t3 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1,t2); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +SELECT * FROM t3; +TRUNCATE TABLE t3; +SELECT * FROM t3; +--echo # +--echo # Truncate child table. +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +TRUNCATE TABLE t1; +SELECT * FROM t3; +--echo # +--echo # Truncate MERGE table under locked tables. +LOCK TABLE t1 WRITE, t2 WRITE, t3 WRITE; +INSERT INTO t1 VALUES (1); +--error ER_LOCK_OR_ACTIVE_TRANSACTION +TRUNCATE TABLE t3; +SELECT * FROM t3; +--echo # +--echo # Truncate child table under locked tables. +--error ER_LOCK_OR_ACTIVE_TRANSACTION +TRUNCATE TABLE t1; +SELECT * FROM t3; +UNLOCK TABLES; +DROP TABLE t1, t2, t3; +--echo # +--echo # Truncate temporary MERGE table. +CREATE TEMPORARY TABLE t1 (c1 INT, INDEX(c1)); +CREATE TEMPORARY TABLE t2 (c1 INT, INDEX(c1)); +CREATE TEMPORARY TABLE t3 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1,t2); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +SELECT * FROM t3; +TRUNCATE TABLE t3; +SELECT * FROM t3; +--echo # +--echo # Truncate temporary child table. +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +TRUNCATE TABLE t1; +SELECT * FROM t3; +--echo # +--echo # Truncate temporary MERGE table under locked tables. +INSERT INTO t1 VALUES (1); +CREATE TABLE t4 (c1 INT, INDEX(c1)); +LOCK TABLE t4 WRITE; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +TRUNCATE TABLE t3; +SELECT * FROM t3; +--echo # +--echo # Truncate temporary child table under locked tables. +--error ER_LOCK_OR_ACTIVE_TRANSACTION +TRUNCATE TABLE t1; +SELECT * FROM t3; +UNLOCK TABLES; +DROP TABLE t1, t2, t3, t4; + +# +# Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table +# Preparation +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +connection default; +# +# Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table +# Problem #1 +# A thread trying to lock a MERGE table performed busy waiting while +# REPAIR TABLE or a similar table administration task was ongoing on one or +# more of its MyISAM tables. +# To allow for observability it was necessary to enter a multi-second sleep +# in mysql_admin_table() after remove_table_from_cache(), which comes after +# mysql_abort_lock(). The sleep faked a long running operation. One could +# watch a high CPU load during the sleep time. +# The problem was that mysql_abort_lock() upgrades the write lock to +# TL_WRITE_ONLY. This lock type persisted until the final unlock at the end +# of the administration task. The effect of TL_WRITE_ONLY is to reject any +# attempt to lock the table. The trying thread must close the table and wait +# until it is no longer used. Unfortunately there is no way to detect that +# one of the MyISAM tables of a MERGE table is in use. When trying to lock +# the MERGE table, all MyISAM tables are locked. If one fails on +# TL_WRITE_ONLY, all locks are aborted and wait_for_tables() is entered. +# But this doesn't see the MERGE table as used, so it seems appropriate to +# retry a lock... +# +CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; +CREATE TABLE t2 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1) INSERT_METHOD= LAST; +send REPAIR TABLE t1; + connection con1; + sleep 1; # let repair run into its sleep + INSERT INTO t2 VALUES (1); +connection default; +reap; +DROP TABLE t1, t2; +# +# Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table +# Problem #2 +# A thread trying to lock a MERGE table performed busy waiting until all +# threads that did REPAIR TABLE or similar table administration tasks on +# one or more of its MyISAM tables in LOCK TABLES segments did +# UNLOCK TABLES. +# The difference against problem #1 is that the busy waiting took place +# *after* the administration task. It was terminated by UNLOCK TABLES only. +# +# This is the same test case as for +# Bug#26867 - LOCK TABLES + REPAIR + merge table result in memory/cpu hogging +# +# +CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; +CREATE TABLE t2 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1) INSERT_METHOD= LAST; +LOCK TABLE t1 WRITE; + connection con1; + send INSERT INTO t2 VALUES (1); +connection default; +sleep 1; # Let INSERT go into thr_multi_lock(). +REPAIR TABLE t1; +sleep 2; # con1 performs busy waiting during this sleep. +UNLOCK TABLES; + connection con1; + reap; +connection default; +DROP TABLE t1, t2; +# +# Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table +# Problem #3 +# Two FLUSH TABLES within a LOCK TABLES segment could invalidate the lock. +# This did *not* require a MERGE table. +# To increase reproducibility it was necessary to enter a sleep of 2 seconds +# at the end of wait_for_tables() after unlock of LOCK_open. In 5.0 and 5.1 +# the sleep must be inserted in open_and_lock_tables() after open_tables() +# instead. wait_for_tables() is not used in this case. +# The problem was that FLUSH TABLES releases LOCK_open while having unlocked +# and closed all tables. When this happened while a thread was in the loop in +# mysql_lock_tables() right after wait_for_tables() and before retrying to +# lock, the thread got the lock. (Translate to similar code places in 5.0 +# and 5.1). And it did not notice that the table needed a refresh. So it +# executed its statement on the table. +# The first FLUSH TABLES kicked the INSERT out of thr_multi_lock() and let +# it wait in wait_for_tables(). (open_table() in 5.0 and 5.1). The second +# FLUSH TABLES must happen while the INSERT was on its way from +# wait_for_tables() to the next call of thr_multi_lock(). This needed to be +# supported by a sleep to make it repeatable. +# +CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; +LOCK TABLE t1 WRITE; + connection con1; + send INSERT INTO t1 VALUES (1); +connection default; +sleep 1; # Let INSERT go into thr_multi_lock(). +FLUSH TABLES; +sleep 1; # Let INSERT go through wait_for_tables() where it sleeps. +FLUSH TABLES; +# This should give no result. But it will with sleep(2) at the right place. +SELECT * FROM t1; +UNLOCK TABLES; + connection con1; + reap; +connection default; +DROP TABLE t1; +# +# Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table +# Cleanup +disconnect con1; +disconnect con2; +# +--echo # +--echo # Extra tests for Bug#26379 - Combination of FLUSH TABLE and +--echo # REPAIR TABLE corrupts a MERGE table +# +--echo # +--echo # CREATE ... SELECT is disabled for MERGE tables. +--echo # +CREATE TABLE t1(c1 INT); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; +--error ER_OPEN_AS_READONLY +CREATE TABLE t3 ENGINE=MRG_MYISAM INSERT_METHOD=LAST SELECT * FROM t2; +--error ER_NO_SUCH_TABLE +SHOW CREATE TABLE t3; +--error ER_WRONG_OBJECT +CREATE TABLE t3 ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST + SELECT * FROM t2; +--error ER_NO_SUCH_TABLE +SHOW CREATE TABLE t3; +DROP TABLE t1, t2; +# +--echo # +--echo # CREATE ... LIKE +--echo # +--echo # 1. Create like. +CREATE TABLE t1 (c1 INT); +CREATE TABLE t2 (c1 INT); +CREATE TABLE t3 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2) + INSERT_METHOD=LAST; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +CREATE TABLE t4 LIKE t3; +SHOW CREATE TABLE t4; +--error ER_OPEN_AS_READONLY +INSERT INTO t4 VALUES (4); +DROP TABLE t4; +--echo # +--echo # 1. Create like with locked tables. +LOCK TABLES t3 WRITE, t2 WRITE, t1 WRITE; +CREATE TABLE t4 LIKE t3; +--error ER_TABLE_NOT_LOCKED +SHOW CREATE TABLE t4; +--error ER_TABLE_NOT_LOCKED +INSERT INTO t4 VALUES (4); +UNLOCK TABLES; +SHOW CREATE TABLE t4; +--error ER_OPEN_AS_READONLY +INSERT INTO t4 VALUES (4); +DROP TABLE t4; +# +--echo # +--echo # Rename child. +--echo # +--echo # 1. Normal rename of non-MERGE table. +CREATE TABLE t4 (c1 INT); +INSERT INTO t4 VALUES (4); +SELECT * FROM t4 ORDER BY c1; +RENAME TABLE t4 TO t5; +SELECT * FROM t5 ORDER BY c1; +RENAME TABLE t5 TO t4; +SELECT * FROM t4 ORDER BY c1; +DROP TABLE t4; +--echo # +--echo # 2. Normal rename. +SELECT * FROM t3 ORDER BY c1; +RENAME TABLE t2 TO t5; +--error 1168 +SELECT * FROM t3 ORDER BY c1; +RENAME TABLE t5 TO t2; +SELECT * FROM t3 ORDER BY c1; +--echo # +--echo # 3. Normal rename with locked tables. +LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE; +SELECT * FROM t3 ORDER BY c1; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +RENAME TABLE t2 TO t5; +SELECT * FROM t3 ORDER BY c1; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +RENAME TABLE t5 TO t2; +SELECT * FROM t3 ORDER BY c1; +UNLOCK TABLES; +--echo # +--echo # 4. Alter table rename. +ALTER TABLE t2 RENAME TO t5; +--error 1168 +SELECT * FROM t3 ORDER BY c1; +ALTER TABLE t5 RENAME TO t2; +SELECT * FROM t3 ORDER BY c1; +--echo # +--echo # 5. Alter table rename with locked tables. +LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE; +ALTER TABLE t2 RENAME TO t5; +--error ER_TABLE_NOT_LOCKED +SELECT * FROM t3 ORDER BY c1; +--error ER_TABLE_NOT_LOCKED +ALTER TABLE t5 RENAME TO t2; +UNLOCK TABLES; +ALTER TABLE t5 RENAME TO t2; +SELECT * FROM t3 ORDER BY c1; +# +--echo # +--echo # Rename parent. +--echo # +--echo # 1. Normal rename with locked tables. +LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE; +SELECT * FROM t3 ORDER BY c1; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +RENAME TABLE t3 TO t5; +SELECT * FROM t3 ORDER BY c1; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +RENAME TABLE t5 TO t3; +SELECT * FROM t3 ORDER BY c1; +--echo # +--echo # 5. Alter table rename with locked tables. +ALTER TABLE t3 RENAME TO t5; +--error ER_TABLE_NOT_LOCKED +SELECT * FROM t5 ORDER BY c1; +--error ER_TABLE_NOT_LOCKED +ALTER TABLE t5 RENAME TO t3; +UNLOCK TABLES; +ALTER TABLE t5 RENAME TO t3; +SELECT * FROM t3 ORDER BY c1; +DROP TABLE t1, t2, t3; +# +--echo # +--echo # Drop locked tables. +--echo # +--echo # 1. Drop parent. +CREATE TABLE t1 (c1 INT, INDEX(c1)); +CREATE TABLE t2 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1) + INSERT_METHOD=LAST; +LOCK TABLES t1 WRITE, t2 WRITE; +INSERT INTO t1 VALUES (1); +DROP TABLE t2; +--error ER_TABLE_NOT_LOCKED +SELECT * FROM t2; +SELECT * FROM t1; +UNLOCK TABLES; +--echo # 2. Drop child. +CREATE TABLE t2 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1) + INSERT_METHOD=LAST; +LOCK TABLES t1 WRITE, t2 WRITE; +INSERT INTO t1 VALUES (1); +DROP TABLE t1; +--error 1168 +SELECT * FROM t2; +--error ER_NO_SUCH_TABLE +SELECT * FROM t1; +UNLOCK TABLES; +DROP TABLE t2; +# +--echo # +--echo # ALTER TABLE. Change child list. +--echo # +CREATE TABLE t1 (c1 INT, INDEX(c1)); +CREATE TABLE t2 (c1 INT, INDEX(c1)); +CREATE TABLE t3 (c1 INT, INDEX(c1)); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +CREATE TABLE t4 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t3,t2) + INSERT_METHOD=LAST; +--echo # Shrink child list. +ALTER TABLE t4 UNION=(t3); +SHOW CREATE TABLE t4; +SELECT * FROM t4 ORDER BY c1; +--echo # Extend child list. +ALTER TABLE t4 UNION=(t3,t2); +SHOW CREATE TABLE t4; +SELECT * FROM t4 ORDER BY c1; +# +--echo # +--echo # ALTER TABLE under LOCK TABLES. Change child list. +--echo # +LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE; +--echo # Shrink child list. +--error ER_LOCK_OR_ACTIVE_TRANSACTION +ALTER TABLE t4 UNION=(t3); +--echo # Extend child list within locked tables. +--error ER_LOCK_OR_ACTIVE_TRANSACTION +ALTER TABLE t4 UNION=(t3,t2); +--echo # Extend child list beyond locked tables. +--error ER_LOCK_OR_ACTIVE_TRANSACTION +ALTER TABLE t4 UNION=(t3,t2,t1); +SHOW CREATE TABLE t4; +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +DROP TABLE t4; +# +--echo # +--echo # ALTER TABLE under LOCK TABLES. Grave change, table re-creation. +--echo # +CREATE TABLE t4 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1,t2,t3) + INSERT_METHOD=LAST; +--echo # Lock parent first and then children. +LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE, t1 WRITE; +ALTER TABLE t4 DROP INDEX c1, ADD UNIQUE INDEX (c1); +SELECT * FROM t4 ORDER BY c1; +ALTER TABLE t2 DROP INDEX c1, ADD UNIQUE INDEX (c1); +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +--echo # Lock children first and then parent. +LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE; +ALTER TABLE t4 DROP INDEX c1, ADD UNIQUE INDEX (c1); +SELECT * FROM t4 ORDER BY c1; +ALTER TABLE t2 DROP INDEX c1, ADD UNIQUE INDEX (c1); +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +--echo # Lock parent between children. +LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; +ALTER TABLE t4 DROP INDEX c1, ADD UNIQUE INDEX (c1); +SELECT * FROM t4 ORDER BY c1; +ALTER TABLE t2 DROP INDEX c1, ADD UNIQUE INDEX (c1); +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +DROP TABLE t1, t2, t3, t4; +# +--echo # +--echo # ALTER TABLE under LOCK TABLES. Simple change, no re-creation. +--echo # +CREATE TABLE t1 (c1 INT); +CREATE TABLE t2 (c1 INT); +CREATE TABLE t3 (c1 INT); +CREATE TABLE t4 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2,t3) + INSERT_METHOD=LAST; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t3 VALUES (3); +--echo # Lock parent first and then children. +LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE, t1 WRITE; +ALTER TABLE t4 ALTER COLUMN c1 SET DEFAULT 44; +SELECT * FROM t4 ORDER BY c1; +ALTER TABLE t2 ALTER COLUMN c1 SET DEFAULT 22; +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +--echo # Lock children first and then parent. +LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE; +ALTER TABLE t4 ALTER COLUMN c1 SET DEFAULT 44; +SELECT * FROM t4 ORDER BY c1; +ALTER TABLE t2 ALTER COLUMN c1 SET DEFAULT 22; +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +--echo # Lock parent between children. +LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; +ALTER TABLE t4 ALTER COLUMN c1 SET DEFAULT 44; +SELECT * FROM t4 ORDER BY c1; +ALTER TABLE t2 ALTER COLUMN c1 SET DEFAULT 22; +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +# +--echo # +--echo # FLUSH TABLE under LOCK TABLES. +--echo # +--echo # Lock parent first and then children. +LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE, t1 WRITE; +FLUSH TABLE t4; +SELECT * FROM t4 ORDER BY c1; +FLUSH TABLE t2; +SELECT * FROM t4 ORDER BY c1; +FLUSH TABLES; +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +--echo # Lock children first and then parent. +LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE; +FLUSH TABLE t4; +SELECT * FROM t4 ORDER BY c1; +FLUSH TABLE t2; +SELECT * FROM t4 ORDER BY c1; +FLUSH TABLES; +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +--echo # Lock parent between children. +LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; +FLUSH TABLE t4; +SELECT * FROM t4 ORDER BY c1; +FLUSH TABLE t2; +SELECT * FROM t4 ORDER BY c1; +FLUSH TABLES; +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +# +--echo # +--echo # Triggers +--echo # +--echo # Trigger on parent +DELETE FROM t4 WHERE c1 = 4; +CREATE TRIGGER t4_ai AFTER INSERT ON t4 FOR EACH ROW SET @a=1; +SET @a=0; +INSERT INTO t4 VALUES (4); +SELECT @a; +SELECT * FROM t4 ORDER BY c1; +DROP TRIGGER t4_ai; +--echo # Trigger on parent under LOCK TABLES +LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; +CREATE TRIGGER t4_ai AFTER INSERT ON t4 FOR EACH ROW SET @a=1; +SET @a=0; +INSERT INTO t4 VALUES (4); +SELECT @a; +SELECT * FROM t4 ORDER BY c1; +DROP TRIGGER t4_ai; +UNLOCK TABLES; +--echo # +--echo # Trigger on child +DELETE FROM t4 WHERE c1 = 4; +CREATE TRIGGER t3_ai AFTER INSERT ON t3 FOR EACH ROW SET @a=1; +SET @a=0; +INSERT INTO t4 VALUES (4); +SELECT @a; +INSERT INTO t3 VALUES (33); +SELECT @a; +SELECT * FROM t4 ORDER BY c1; +DROP TRIGGER t3_ai; +--echo # Trigger on child under LOCK TABLES +LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; +CREATE TRIGGER t3_ai AFTER INSERT ON t3 FOR EACH ROW SET @a=1; +SET @a=0; +INSERT INTO t4 VALUES (4); +SELECT @a; +INSERT INTO t3 VALUES (33); +SELECT @a; +SELECT * FROM t4 ORDER BY c1; +DELETE FROM t4 WHERE c1 = 33; +DROP TRIGGER t3_ai; +--echo # +--echo # Trigger with table use on child +DELETE FROM t4 WHERE c1 = 4; +CREATE TRIGGER t3_ai AFTER INSERT ON t3 FOR EACH ROW INSERT INTO t2 VALUES(22); +INSERT INTO t4 VALUES (4); +SELECT * FROM t4 ORDER BY c1; +INSERT INTO t3 VALUES (33); +SELECT * FROM t4 ORDER BY c1; +DELETE FROM t4 WHERE c1 = 22; +DELETE FROM t4 WHERE c1 = 33; +DROP TRIGGER t3_ai; +--echo # Trigger with table use on child under LOCK TABLES +LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; +CREATE TRIGGER t3_ai AFTER INSERT ON t3 FOR EACH ROW INSERT INTO t2 VALUES(22); +INSERT INTO t4 VALUES (4); +SELECT * FROM t4 ORDER BY c1; +INSERT INTO t3 VALUES (33); +SELECT * FROM t4 ORDER BY c1; +DROP TRIGGER t3_ai; +DELETE FROM t4 WHERE c1 = 22; +DELETE FROM t4 WHERE c1 = 33; +UNLOCK TABLES; +# +--echo # +--echo # Repair +--echo # +REPAIR TABLE t4; +REPAIR TABLE t2; +SELECT * FROM t4 ORDER BY c1; +LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; +REPAIR TABLE t4; +REPAIR TABLE t2; +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +# +--echo # +--echo # Optimize +--echo # +OPTIMIZE TABLE t4; +OPTIMIZE TABLE t2; +SELECT * FROM t4 ORDER BY c1; +LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; +OPTIMIZE TABLE t4; +OPTIMIZE TABLE t2; +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +# +--echo # +--echo # Checksum +--echo # +CHECKSUM TABLE t4; +CHECKSUM TABLE t2; +SELECT * FROM t4 ORDER BY c1; +LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; +CHECKSUM TABLE t4; +CHECKSUM TABLE t2; +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +# +--echo # +--echo # Insert delayed +--echo # +# See also Bug#26464 - insert delayed + update + merge = corruption +# Succeeds in embedded server - is converted to normal insert +# Fails in normal server, ps-protocol - not supported by engine +# Fails in normal server, normal protocol - not a base table +--error 0, ER_DELAYED_NOT_SUPPORTED, ER_WRONG_OBJECT +INSERT DELAYED INTO t4 VALUES(44); +# Get rid of row in embedded server +DELETE FROM t4 WHERE c1 = 44; +INSERT DELAYED INTO t3 VALUES(33); + let $wait_cmd= SHOW STATUS LIKE 'Not_flushed_delayed_rows'; + let $run= query_get_value($wait_cmd, Value, 1); + while ($run) + { + let $run= query_get_value($wait_cmd, Value, 1); + } +SELECT * FROM t4 ORDER BY c1; +LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; +--error ER_DELAYED_INSERT_TABLE_LOCKED, ER_DELAYED_NOT_SUPPORTED +INSERT DELAYED INTO t4 VALUES(444); +--error ER_DELAYED_INSERT_TABLE_LOCKED, ER_DELAYED_NOT_SUPPORTED +INSERT DELAYED INTO t3 VALUES(333); +SELECT * FROM t4 ORDER BY c1; +UNLOCK TABLES; +DROP TABLE t1, t2, t3, t4; +# +--echo # +--echo # Recursive inclusion of merge tables in their union clauses. +--echo # +CREATE TABLE t1 (c1 INT, INDEX(c1)); +CREATE TABLE t2 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1) + INSERT_METHOD=LAST; +CREATE TABLE t3 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t2,t1) + INSERT_METHOD=LAST; +ALTER TABLE t2 UNION=(t3,t1); +--error ER_ADMIN_WRONG_MRG_TABLE +SELECT * FROM t2; +DROP TABLE t1, t2, t3; + + +# +# Bug#25038 - Waiting TRUNCATE +# +# Show that truncate of child table after use of parent table works. +CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; +CREATE TABLE t2 (c1 INT) ENGINE= MyISAM; +CREATE TABLE t3 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1, t2); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +SELECT * FROM t3; +TRUNCATE TABLE t1; +SELECT * FROM t3; +DROP TABLE t1, t2, t3; +# +# Show that truncate of child table waits while parent table is used. +# (test partly borrowed from count_distinct3.) +CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER); +SET @rnd_max= 2147483647; +let $1 = 10; +while ($1) +{ + SET @rnd= RAND(); + SET @id = CAST(@rnd * @rnd_max AS UNSIGNED); + SET @id_rev= @rnd_max - @id; + SET @grp= CAST(127.0 * @rnd AS UNSIGNED); + INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev); + dec $1; +} +set @@read_buffer_size=2*1024*1024; +CREATE TABLE t2 SELECT * FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; +INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; +CREATE TABLE t3 (id INTEGER, grp TINYINT, id_rev INTEGER) + ENGINE= MRG_MYISAM UNION= (t1, t2); +SELECT COUNT(*) FROM t1; +SELECT COUNT(*) FROM t2; +SELECT COUNT(*) FROM t3; +connect (con1,localhost,root,,); + # As t3 contains random numbers, results are different from test to test. + # That's okay, because we test only that select doesn't yield an + # error. Note, that --disable_result_log doesn't suppress error output. + --disable_result_log + send SELECT COUNT(DISTINCT a1.id) FROM t3 AS a1, t3 AS a2 + WHERE a1.id = a2.id GROUP BY a2.grp; +connection default; +sleep 1; +TRUNCATE TABLE t1; + connection con1; + reap; + --enable_result_log + disconnect con1; +connection default; +SELECT COUNT(*) FROM t1; +SELECT COUNT(*) FROM t2; +SELECT COUNT(*) FROM t3; +DROP TABLE t1, t2, t3; + +# +# Bug#25700 - merge base tables get corrupted by optimize/analyze/repair table +# +# Using FLUSH TABLES before REPAIR. +CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; +CREATE TABLE t2 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; +INSERT INTO t2 VALUES (1); +SELECT * FROM t2; +LOCK TABLES t2 WRITE, t1 WRITE; +FLUSH TABLES; +REPAIR TABLE t1; +CHECK TABLE t1; +REPAIR TABLE t1; +UNLOCK TABLES; +CHECK TABLE t1 EXTENDED; +# +# Not using FLUSH TABLES before REPAIR. +LOCK TABLES t2 WRITE, t1 WRITE; +REPAIR TABLE t1; +CHECK TABLE t1; +REPAIR TABLE t1; +UNLOCK TABLES; +CHECK TABLE t1 EXTENDED; +DROP TABLE t1, t2; + +# +# Bug#26377 - Deadlock with MERGE and FLUSH TABLE +# +CREATE TABLE t1 ( a INT ) ENGINE=MyISAM; +CREATE TABLE m1 ( a INT ) ENGINE=MRG_MYISAM UNION=(t1); +# Lock t1 first. This did always work. +LOCK TABLES t1 WRITE, m1 WRITE; +FLUSH TABLE t1; +UNLOCK TABLES; +DROP TABLE m1, t1; +# +CREATE TABLE t1 ( a INT ) ENGINE=MyISAM; +CREATE TABLE m1 ( a INT ) ENGINE=MRG_MYISAM UNION=(t1); +# Lock m1 first. This did deadlock. +LOCK TABLES m1 WRITE, t1 WRITE; +FLUSH TABLE t1; +UNLOCK TABLES; +DROP TABLE m1, t1; + +# +# Bug#27660 - Falcon: merge table possible +# +# Normal MyISAM MERGE operation. +CREATE TABLE t1 (c1 INT, c2 INT) ENGINE= MyISAM; +CREATE TABLE t2 (c1 INT, c2 INT) ENGINE= MyISAM; +CREATE TABLE t3 (c1 INT, c2 INT) ENGINE= MRG_MYISAM UNION(t1, t2); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t2 VALUES (2, 2); +SELECT * FROM t3; +# Try an unsupported engine. +ALTER TABLE t1 ENGINE= MEMORY; +INSERT INTO t1 VALUES (0, 0); +# Before fixing, this succeeded, but (0, 0) was missing. +--error 1168 +SELECT * FROM t3; +DROP TABLE t1, t2, t3; + +# +# Bug#30275 - Merge tables: flush tables or unlock tables causes server to crash +# +CREATE TABLE t1 (c1 INT, KEY(c1)); +CREATE TABLE t2 (c1 INT, KEY(c1)) ENGINE=MRG_MYISAM UNION=(t1) + INSERT_METHOD=FIRST; +LOCK TABLE t1 WRITE, t2 WRITE; +FLUSH TABLES t2, t1; +OPTIMIZE TABLE t1; +FLUSH TABLES t1; +UNLOCK TABLES; +# +FLUSH TABLES; +INSERT INTO t1 VALUES (1); +LOCK TABLE t1 WRITE, t2 WRITE; +FLUSH TABLES t2, t1; +OPTIMIZE TABLE t1; +FLUSH TABLES t1; +UNLOCK TABLES; +DROP TABLE t1, t2; + +# +# Test derived from test program for +# Bug#30273 - merge tables: Can't lock file (errno: 155) +# +CREATE TABLE t1 (ID INT) ENGINE=MYISAM; +CREATE TABLE m1 (ID INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=FIRST; +INSERT INTO t1 VALUES (); +INSERT INTO m1 VALUES (); +LOCK TABLE t1 WRITE, m1 WRITE; +FLUSH TABLES m1, t1; +OPTIMIZE TABLE t1; +FLUSH TABLES m1, t1; +UNLOCK TABLES; +DROP TABLE t1, m1; + +# +# Bug#35068 - Assertion fails when reading from i_s.tables +# and there is incorrect merge table +# +CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=FIRST; +--replace_column 8 # 9 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # 17 # 19 # 20 # +SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE +TABLE_SCHEMA = 'test' and TABLE_NAME='tm1'; + +DROP TABLE tm1; + +# +# Bug#36006 - Optimizer does table scan for select count(*) +# +CREATE TABLE t1(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM; +CREATE TABLE t2(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM; +CREATE TABLE t3(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM; +CREATE TABLE t4(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) + ENGINE=MRG_MYISAM UNION=(t1, t2, t3); +INSERT INTO t1 VALUES (1,1), (1,2),(1,3), (1,4); +INSERT INTO t2 VALUES (2,1), (2,2),(2,3), (2,4); +INSERT INTO t3 VALUES (3,1), (3,2),(3,3), (3,4); +EXPLAIN SELECT COUNT(*) FROM t1; +EXPLAIN SELECT COUNT(*) FROM t4; +DROP TABLE t1, t2, t3, t4; + +# +# BUG#39185 - Cardinality for merge tables calculated incorrectly. +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES(0),(1),(2),(3),(4); +ANALYZE TABLE t1; +CREATE TABLE m1(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); +SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; +SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; +SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; +SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; +DROP TABLE t1, m1; + +--echo # +--echo # Bug #40675 MySQL 5.1 crash with index merge algorithm and Merge tables +--echo # + +--echo # create MYISAM table t1 and insert values into it +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(1); + +--echo # create MYISAM table t2 and insert values into it +CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b)); +INSERT INTO t2(a,b) VALUES +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), +(1,2); + +--echo # Create the merge table t3 +CREATE TABLE t3(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b)) +ENGINE=MERGE UNION=(t2) INSERT_METHOD=FIRST; + +--echo # Lock tables t1 and t3 for write +LOCK TABLES t1 WRITE, t3 WRITE; + +--echo # Insert values into the merge table t3 +INSERT INTO t3(a,b) VALUES(1,2); + +--echo # select from the join of t2 and t3 (The merge table) +SELECT t3.a FROM t1,t3 WHERE t3.b=2 AND t3.a=1; + +--echo # Unlock the tables +UNLOCK TABLES; + +--echo # drop the created tables +DROP TABLE t1, t2, t3; + +# +# Bug #41305 server crashes when inserting duplicate row into a merge table +# +--echo # insert duplicate value in child table while merge table doesn't have key +create table t1 ( + col1 int(10), + primary key (col1) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +CREATE TABLE m1 ( + col1 int(10) NOT NULL +) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(t1); + +insert into m1 (col1) values (1); +--error ER_DUP_ENTRY +insert into m1 (col1) values (1); + +drop table m1, t1; + +--echo # +--echo # Bug#45800 crash when replacing into a merge table and there is a duplicate +--echo # + +--echo # Replace duplicate value in child table when merge table doesn't have key +CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE=MyISAM; +CREATE TABLE m1 (c1 INT NOT NULL) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); +INSERT INTO m1 VALUES (666); +SELECT * FROM m1; +--echo # insert the duplicate value into the merge table +REPLACE INTO m1 VALUES (666); +SELECT * FROM m1; +DROP TABLE m1, t1; + +--echo # Insert... on duplicate key update (with duplicate values in the table) +CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE=MyISAM; +CREATE TABLE m1 (c1 INT NOT NULL) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); +INSERT INTO m1 VALUES (666); +SELECT * FROM m1; +--echo # insert the duplicate value into the merge table +INSERT INTO m1 VALUES (666) ON DUPLICATE KEY UPDATE c1=c1+1; +SELECT * FROM m1; +DROP TABLE m1, t1; + +--echo # Insert duplicate value on MERGE table, where, MERGE has a key but MyISAM has more keys +CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE (c1), UNIQUE (c2)); +CREATE TABLE m1 (c1 INT, c2 INT, UNIQUE (c1)) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); +INSERT INTO m1 VALUES (1,2); +--echo # insert the duplicate value into the merge table +--error ER_DUP_ENTRY +INSERT INTO m1 VALUES (3,2); +DROP TABLE m1,t1; + +--echo # Try to define MERGE and MyISAM with keys on different columns +CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE (c1)); +CREATE TABLE m1 (c1 INT, c2 INT, UNIQUE (c2)) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); +--echo # Try accessing the merge table for inserts (error occurs) +--error ER_WRONG_MRG_TABLE +INSERT INTO m1 VALUES (1,2); +--error ER_WRONG_MRG_TABLE +INSERT INTO m1 VALUES (1,4); +DROP TABLE m1,t1; + +# +#Bug #44040 MySQL allows creating a MERGE table upon VIEWs but crashes +#when using it +# + +CREATE TABLE t1 ( + col1 INT(10) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +CREATE VIEW v1 as SELECT * FROM t1; +CREATE TABLE m1 ( + col1 INT(10) +)ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(v1); + +--echo #Select should detect that the child table is a view and fail. +--error ER_WRONG_MRG_TABLE +SELECT * FROM m1; + +DROP VIEW v1; +DROP TABLE m1, t1; + +--echo # +--echo # Bug #45796: invalid memory reads and writes when altering merge and +--echo # base tables +--echo # + +CREATE TABLE t1(c1 INT) ENGINE=MyISAM; +CREATE TABLE m1(c1 INT) ENGINE=MERGE UNION=(t1); +ALTER TABLE m1 ADD INDEX idx_c1(c1); +# Open the MERGE table and allocate buffers based on children's definition. +--error ER_WRONG_MRG_TABLE +SELECT * FROM m1; +# Change the child table definition. +ALTER TABLE t1 ADD INDEX idx_c1(c1); +# Check that old buffers are not reused +SELECT * FROM m1; + +DROP TABLE m1; +DROP TABLE t1; + +--echo # +--echo # Bug45781 infinite hang/crash in "opening tables" after handler tries to +--echo # open merge table +--echo # + +--disable_warnings +DROP TABLE IF EXISTS m1,t1; +--enable_warnings + +CREATE TABLE t1(a int)engine=myisam; +CREATE TABLE t2(a int)engine=myisam; +CREATE TABLE t3(a int)engine=myisam; +CREATE TABLE t4(a int)engine=myisam; +CREATE TABLE t5(a int)engine=myisam; +CREATE TABLE t6(a int)engine=myisam; +CREATE TABLE t7(a int)engine=myisam; +CREATE TABLE m1(a int)engine=merge union=(t1,t2,t3,t4,t5,t6,t7); +SELECT 1 FROM m1; +--error ER_ILLEGAL_HA +HANDLER m1 OPEN; +DROP TABLE m1,t1,t2,t3,t4,t5,t6,t7; +--error ER_NO_SUCH_TABLE +SELECT 1 FROM m1; # Should not hang! + +--echo # +--echo # Bug #46614: Assertion in show_create_trigger() +--echo # +CREATE TABLE t1(a int); +CREATE TABLE t2(a int); +CREATE TABLE t3(a int) ENGINE = MERGE UNION(t1, t2); +CREATE TRIGGER tr1 AFTER INSERT ON t3 FOR EACH ROW CALL foo(); +SHOW CREATE TRIGGER tr1; +DROP TRIGGER tr1; +DROP TABLE t1, t2, t3; + +--echo End of 5.1 tests diff --git a/mysql-test/t/merge_innodb.test b/mysql-test/t/merge_innodb.test new file mode 100644 index 00000000000..7f0b1a0c36e --- /dev/null +++ b/mysql-test/t/merge_innodb.test @@ -0,0 +1,41 @@ +# t/merge_innodb.test +# +# Tests with MERGE tables over InnoDB tables +# + +--source include/have_innodb.inc + +--disable_warnings +DROP TABLE IF EXISTS t1, t2, t3, t4, t5; +--enable_warnings + +# +# Bug#30491 - MERGE doesn't report error when one table is Innodb +# +CREATE TABLE t1 (c1 varchar(100)) ENGINE=MyISAM; +CREATE TABLE t2 (c1 varchar(100)) ENGINE=MyISAM; +CREATE TABLE t3 (c1 varchar(100)) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('Ann'), ('Alice'); +INSERT INTO t2 VALUES ('Bob'), ('Brian'); +INSERT INTO t3 VALUES ('Chris'), ('Charlie'); +CREATE TABLE t4 (c1 varchar(100)) ENGINE=MRG_MYISAM UNION=(t1,t2) + INSERT_METHOD=LAST; +CREATE TABLE t5 (c1 varchar(100)) ENGINE=MRG_MYISAM UNION=(t1,t3) + INSERT_METHOD=LAST; +--error ER_WRONG_MRG_TABLE +SELECT * FROM t5; +SELECT * FROM t4; +ALTER TABLE t2 ENGINE=InnoDB; +--error ER_WRONG_MRG_TABLE +SELECT * FROM t4; +DELETE FROM t2 LIMIT 1; +--error ER_WRONG_MRG_TABLE +SELECT * FROM t4; +--error ER_WRONG_MRG_TABLE +INSERT INTO t4 VALUES ('Beware'); +--error ER_WRONG_MRG_TABLE +SELECT * FROM t4; +SELECT * FROM t2; +SELECT * FROM t1; +DROP TABLE t1, t2, t3, t4, t5; + diff --git a/mysql-test/t/mix2_myisam.test b/mysql-test/t/mix2_myisam.test new file mode 100644 index 00000000000..afb3caca0ea --- /dev/null +++ b/mysql-test/t/mix2_myisam.test @@ -0,0 +1,26 @@ +# t/mix2_myisam.test +# +# Last update: 2006-07-26 ML create this test as derivate from innodb.test +# + +let $engine_type= MyISAM; +let $other_engine_type= MEMORY; +# There are unfortunately only MyISAM and MEMORY all time available +# Therefore use here MEMORY again. +let $other_engine_type1= MEMORY; +let $other_non_trans_engine_type= MEMORY; +let $other_non_live_chks_engine_type= MEMORY; +# Therefore use here MyISAM again. +let $other_live_chks_engine_type= MyISAM; +# MyISAM does not support transactions +let $test_transactions= 0; +# MyISAM does not support FOREIGN KEYFOREIGN KEYs +let $test_foreign_keys= 0; +# MyISAM supports fulltext queries +let $fulltext_query_unsupported= 0; +# MyISAM internal autoincrement values are updated during updates +let $no_autoinc_update= 0; +# MyISAM supports keys on spatial data types +let $no_spatial_key= 0; + +-- source include/mix2.inc diff --git a/mysql-test/t/mix2_myisam_ucs2.test b/mysql-test/t/mix2_myisam_ucs2.test new file mode 100644 index 00000000000..fe22fa50238 --- /dev/null +++ b/mysql-test/t/mix2_myisam_ucs2.test @@ -0,0 +1,27 @@ +# +# Tests which require ucs2 character set +# + +-- source include/have_ucs2.inc + +let $engine_type= MyISAM; +let $other_engine_type= MEMORY; +# There are unfortunately only MyISAM and MEMORY all time available +# Therefore use here MEMORY again. +let $other_engine_type1= MEMORY; +let $other_non_trans_engine_type= MEMORY; +let $other_non_live_chks_engine_type= MEMORY; +# Therefore use here MyISAM again. +let $other_live_chks_engine_type= MyISAM; +# MyISAM does not support transactions +let $test_transactions= 0; +# MyISAM does not support FOREIGN KEYFOREIGN KEYs +let $test_foreign_keys= 0; +# MyISAM supports fulltext queries +let $fulltext_query_unsupported= 0; +# MyISAM internal autoincrement values are updated during updates +let $no_autoinc_update= 0; +# MyISAM supports keys on spatial data types +let $no_spatial_key= 0; + +-- source include/mix2_ucs2.inc diff --git a/mysql-test/t/mix_innodb_myisam_binlog-master.opt b/mysql-test/t/mix_innodb_myisam_binlog-master.opt deleted file mode 100644 index cb48f1aaf60..00000000000 --- a/mysql-test/t/mix_innodb_myisam_binlog-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-innodb_lock_wait_timeout=2 diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test deleted file mode 100644 index 8ab639661b8..00000000000 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ /dev/null @@ -1,570 +0,0 @@ -# Check that binlog is ok when a transaction mixes updates to InnoDB and -# MyISAM. -# It would be nice to make this a replication test, but in 4.0 the -# slave is always with --skip-innodb in the testsuite. I (Guilhem) however -# did some tests manually on a slave; tables are replicated fine and -# Exec_Master_Log_Pos advances as expected. - --- source include/have_log_bin.inc --- source include/have_innodb.inc - ---disable_warnings -drop table if exists t1, t2; ---enable_warnings - -connect (con1,localhost,root,,); -connect (con2,localhost,root,,); - -connection con1; -create table t1 (a int) engine=innodb; -create table t2 (a int) engine=myisam; - -reset master; - -begin; -insert into t1 values(1); -insert into t2 select * from t1; -commit; - -source include/show_binlog_events.inc; - -delete from t1; -delete from t2; -reset master; - -begin; -insert into t1 values(2); -insert into t2 select * from t1; -# should say some changes to non-transact1onal tables couldn't be rolled back -rollback; - -source include/show_binlog_events.inc; - -delete from t1; -delete from t2; -reset master; - -begin; -insert into t1 values(3); -savepoint my_savepoint; -insert into t1 values(4); -insert into t2 select * from t1; -rollback to savepoint my_savepoint; -commit; - -source include/show_binlog_events.inc; - -delete from t1; -delete from t2; -reset master; - -begin; -insert into t1 values(5); -savepoint my_savepoint; -insert into t1 values(6); -insert into t2 select * from t1; -rollback to savepoint my_savepoint; -insert into t1 values(7); -commit; -select a from t1 order by a; # check that savepoints work :) - -source include/show_binlog_events.inc; - -# and when ROLLBACK is not explicit? -delete from t1; -delete from t2; -reset master; - -select get_lock("a",10); -begin; -insert into t1 values(8); -insert into t2 select * from t1; -disconnect con1; - -connection con2; -# We want to SHOW BINLOG EVENTS, to know what was logged. But there is no -# guarantee that logging of the terminated con1 has been done yet (it may not -# even be started, so con1 may have not even attempted to lock the binlog yet; -# so SHOW BINLOG EVENTS may come before con1 does the loggin. To be sure that -# logging has been done, we use a user lock. -select get_lock("a",10); -source include/show_binlog_events.inc; - -# and when not in a transact1on? -delete from t1; -delete from t2; -reset master; - -insert into t1 values(9); -insert into t2 select * from t1; - -source include/show_binlog_events.inc; - -# Check that when the query updat1ng the MyISAM table is the first in the -# transaction, we log it immediately. -delete from t1; -delete from t2; -reset master; - -insert into t1 values(10); # first make t1 non-empty -begin; -insert into t2 select * from t1; -source include/show_binlog_events.inc; -insert into t1 values(11); -commit; - -source include/show_binlog_events.inc; - -# Check that things work like before this BEGIN/ROLLBACK code was added, -# when t2 is INNODB - -alter table t2 engine=INNODB; - -delete from t1; -delete from t2; -reset master; - -begin; -insert into t1 values(12); -insert into t2 select * from t1; -commit; - -source include/show_binlog_events.inc; - -delete from t1; -delete from t2; -reset master; - -begin; -insert into t1 values(13); -insert into t2 select * from t1; -rollback; - -source include/show_binlog_events.inc; - -delete from t1; -delete from t2; -reset master; - -begin; -insert into t1 values(14); -savepoint my_savepoint; -insert into t1 values(15); -insert into t2 select * from t1; -rollback to savepoint my_savepoint; -commit; - -source include/show_binlog_events.inc; - -delete from t1; -delete from t2; -reset master; - -begin; -insert into t1 values(16); -savepoint my_savepoint; -insert into t1 values(17); -insert into t2 select * from t1; -rollback to savepoint my_savepoint; -insert into t1 values(18); -commit; -select a from t1 order by a; # check that savepoints work :) - -source include/show_binlog_events.inc; - -# Test for BUG#5714, where a MyISAM update in the transaction used to -# release row-level locks in InnoDB - -connect (con3,localhost,root,,); - -connection con3; -delete from t1; -delete from t2; ---disable_warnings -alter table t2 type=MyISAM; ---enable_warnings -insert into t1 values (1); -begin; -select * from t1 for update; - -connection con2; -select (@before:=unix_timestamp())*0; # always give repeatable output -begin; -send select * from t1 for update; - -connection con3; -insert into t2 values (20); - -connection con2; ---error 1205 -reap; -select (@after:=unix_timestamp())*0; # always give repeatable output -# verify that innodb_lock_wait_timeout was exceeded. When there was -# the bug, the reap would return immediately after the insert into t2. -select (@after-@before) >= 2; - -drop table t1,t2; -commit; - -# test for BUG#7947 - DO RELEASE_LOCK() not written to binlog on rollback in the middle -# of a transaction - -connection con2; -begin; -create temporary table ti (a int) engine=innodb; -rollback; -insert into ti values(1); -set autocommit=0; -create temporary table t1 (a int) engine=myisam; -commit; -insert t1 values (1); -rollback; -create table t0 (n int); -insert t0 select * from t1; -set autocommit=1; -insert into t0 select GET_LOCK("lock1",null); -set autocommit=0; -create table t2 (n int) engine=innodb; -insert into t2 values (3); -disconnect con2; -connection con3; -select get_lock("lock1",60); -source include/show_binlog_events.inc; -do release_lock("lock1"); -drop table t0,t2; - -# Test for BUG#16559 (ROLLBACK should always have a zero error code in -# binlog). Has to be here and not earlier, as the SELECTs influence -# XIDs differently between normal and ps-protocol (and SHOW BINLOG -# EVENTS above read XIDs). - -connect (con4,localhost,root,,); -connection con3; -reset master; -create table t1 (a int) engine=innodb; -create table t2 (a int) engine=myisam; -select get_lock("a",10); -begin; -insert into t1 values(8); -insert into t2 select * from t1; -disconnect con3; - -connection con4; -select get_lock("a",10); # wait for rollback to finish - -# we check that the error code of the "ROLLBACK" event is 0 and not -# ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction -# and does not make slave to stop) ---exec $MYSQL_BINLOG --start-position=547 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval select -(@a:=load_file("$MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output")) -is not null; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval select -@a like "%#%error_code=0%ROLLBACK\\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" OR -@a like "%#%error_code=0%ROLLBACK\\r\\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%", -@a not like "%#%error_code=%error_code=%"; -drop table t1, t2; - -# -# Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack -# bug #28960 non-trans temp table changes with insert .. select -# not binlogged after rollback -# -# testing appearence of insert into temp_table in binlog. -# There are two branches of execution that require different setup. - -## send_eof() branch - -# prepare - -create temporary table tt (a int unique); -create table ti (a int) engine=innodb; -reset master; -show master status; - -# action - -begin; -insert into ti values (1); -insert into ti values (2) ; -insert into tt select * from ti; -rollback; - -# check - -select count(*) from tt /* 2 */; -show master status; ---replace_column 2 # 5 # -show binlog events from 98; -select count(*) from ti /* zero */; -insert into ti select * from tt; -select * from ti /* that is what slave would miss - a bug */; - - -## send_error() branch -delete from ti; -delete from tt where a=1; -reset master; -show master status; - -# action - -begin; -insert into ti values (1); -insert into ti values (2) /* to make the dup error in the following */; ---error ER_DUP_ENTRY -insert into tt select * from ti /* one affected and error */; -rollback; - -# check - -show master status; ---replace_column 2 # 5 # -show binlog events from 98; -select count(*) from ti /* zero */; -insert into ti select * from tt; -select * from tt /* that is what otherwise slave missed - the bug */; - -drop table ti; - - -# -# Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack -# -# Testing asserts: if there is a side effect of modifying non-transactional -# table thd->no_trans_update.stmt must be TRUE; -# the assert is active with debug build -# - ---disable_warnings -drop function if exists bug27417; -drop table if exists t1,t2; ---enable_warnings -# side effect table -CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM; -# target tables -CREATE TABLE t2 (a int NOT NULL auto_increment, PRIMARY KEY (a)); - -delimiter |; -create function bug27417(n int) -RETURNS int(11) -begin - insert into t1 values (null); - return n; -end| -delimiter ;| - -reset master; - -# execute - -insert into t2 values (bug27417(1)); -insert into t2 select bug27417(2); -reset master; - ---error ER_DUP_ENTRY -insert into t2 values (bug27417(2)); -show master status; /* only (!) with fixes for #23333 will show there is the query */; -select count(*) from t1 /* must be 3 */; - -reset master; -select count(*) from t2; -delete from t2 where a=bug27417(3); -select count(*) from t2 /* nothing got deleted */; -show master status; /* the query must be in regardless of #23333 */; -select count(*) from t1 /* must be 5 */; - ---enable_info -delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */; ---disable_info -select count(*) from t1 /* must be 7 */; - -# function bug27417 remains for the following testing of bug#23333 -drop table t1,t2; - -# -# Bug#23333 using the patch (and the test) for bug#27471 -# -# throughout the bug tests -# t1 - non-trans side effects gatherer; -# t2 - transactional table; -# - -CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM; -CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB; -CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique) ENGINE=MyISAM; -CREATE TABLE t4 (a int, PRIMARY KEY (a), b int unique) ENGINE=Innodb; -CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB; - - -# -# INSERT -# - -# prepare - - insert into t2 values (1); - reset master; - -# execute - - --error ER_DUP_ENTRY - insert into t2 values (bug27417(1)); - -# check - - show master status /* the offset must denote there is the query */; - select count(*) from t1 /* must be 1 */; - -# -# INSERT SELECT -# - -# prepare - delete from t1; - delete from t2; - insert into t2 values (2); - reset master; - -# execute - - --error ER_DUP_ENTRY - insert into t2 select bug27417(1) union select bug27417(2); - -# check - - show master status /* the offset must denote there is the query */; - select count(*) from t1 /* must be 2 */; - -# -# UPDATE inc multi-update -# - -# prepare - delete from t1; - insert into t3 values (1,1),(2,3),(3,4); - reset master; - -# execute - --error ER_DUP_ENTRY - update t3 set b=b+bug27417(1); - -# check - show master status /* the offset must denote there is the query */; - select count(*) from t1 /* must be 2 */; - -## multi_update::send_eof() branch - -# prepare - delete from t3; - delete from t4; - insert into t3 values (1,1); - insert into t4 values (1,1),(2,2); - - reset master; - -# execute - --error ER_DUP_ENTRY - UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */; - -# check - show master status /* the offset must denote there is the query */; - select count(*) from t1 /* must be 4 */; - -## send_error() branch of multi_update - -# prepare - delete from t1; - delete from t3; - delete from t4; - insert into t3 values (1,1),(2,2); - insert into t4 values (1,1),(2,2); - - reset master; - -# execute - --error ER_DUP_ENTRY - UPDATE t3,t4 SET t3.a=t4.a + bug27417(1); - -# check - select count(*) from t1 /* must be 1 */; - -# cleanup - drop table t4; - - -# -# DELETE incl multi-delete -# - -# prepare - delete from t1; - delete from t2; - delete from t3; - insert into t2 values (1); - insert into t3 values (1,1); - create trigger trg_del before delete on t2 for each row - insert into t3 values (bug27417(1), 2); - reset master; - -# execute - --error ER_DUP_ENTRY - delete from t2; -# check - show master status /* the offset must denote there is the query */; - select count(*) from t1 /* must be 1 */; - -# cleanup - drop trigger trg_del; - -# prepare - delete from t1; - delete from t2; - delete from t5; - create trigger trg_del_t2 after delete on t2 for each row - insert into t1 values (1); - insert into t2 values (2),(3); - insert into t5 values (1),(2); - reset master; - -# execute - --error ER_DUP_ENTRY - delete t2.* from t2,t5 where t2.a=t5.a + 1; - -# check - show master status /* the offset must denote there is the query */; - select count(*) from t1 /* must be 1 */; - - -# -# LOAD DATA -# - -# prepare - delete from t1; - create table t4 (a int default 0, b int primary key) engine=innodb; - insert into t4 values (0, 17); - reset master; - -# execute - --error ER_DUP_ENTRY - load data infile '../std_data_ln/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2); -# check - select * from t4; - select count(*) from t1 /* must be 2 */; - show master status /* the offset must denote there is the query */; - -# -# bug#23333 cleanup -# - - -drop trigger trg_del_t2; -drop table t1,t2,t3,t4,t5; -drop function bug27417; - - ---echo end of tests - diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 9f493189e6d..fc37fd6a27d 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -3,7 +3,8 @@ # # Requires grants, so won't work with embedded server test --- source include/not_embedded.inc +source include/not_embedded.inc; +source include/have_log_bin.inc; --disable_warnings drop table if exists t1,t2,t3; @@ -453,7 +454,7 @@ delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; drop table t1,t2; --disable_warnings -create table t1 ( c char(8) not null ) engine=bdb; +create table t1 ( c char(8) not null ) engine=innodb; --enable_warnings insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); @@ -471,6 +472,11 @@ delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; drop table t1,t2; +# +# Test alter table and a concurrent multi update +# (This will force update to reopen tables) +# + create table t1 (a int, b int); insert into t1 values (1, 2), (2, 3), (3, 4); create table t2 (a int); @@ -487,13 +493,22 @@ send alter table t1 add column c int default 100 after a; connect (updater,localhost,root,,test); connection updater; -# Wait till "alter table t1 ..." is in work. -sleep 2; +# Wait till "alter table t1 ..." of session changer is in work. +# = There is one session is in state "Locked". +let $wait_condition= select count(*)= 1 from information_schema.processlist + where state= 'Locked'; +--source include/wait_condition.inc send update t1, v1 set t1.b=t1.a+t1.b+v1.b where t1.a=v1.a; connection locker; -# Wait till "update t1, v1 ..." is in work. -sleep 2; +# Wait till +# - "alter table t1 ..." of session changer and +# - "update t1, v1 ..." of session updater +# are in work. +# = There are two session is in state "Locked". +let $wait_condition= select count(*)= 2 from information_schema.processlist + where state= 'Locked'; +--source include/wait_condition.inc unlock tables; connection changer; @@ -511,6 +526,35 @@ disconnect locker; disconnect changer; disconnect updater; +# +# Test multi updates and deletes using primary key and without. +# +create table t1 (i1 int, i2 int, i3 int); +create table t2 (id int, c1 varchar(20), c2 varchar(20)); +insert into t1 values (1,5,10),(3,7,12),(4,5,2),(9,10,15),(2,2,2); +insert into t2 values (9,"abc","def"),(5,"opq","lmn"),(2,"test t","t test"); +select * from t1 order by i1; +select * from t2; +update t1,t2 set t1.i2=15, t2.c2="ppc" where t1.i1=t2.id; +select * from t1 order by i1; +select * from t2 order by id; +delete t1.*,t2.* from t1,t2 where t1.i2=t2.id; +select * from t1 order by i1; +select * from t2 order by id; +drop table t1, t2; +create table t1 (i1 int auto_increment not null, i2 int, i3 int, primary key (i1)); +create table t2 (id int auto_increment not null, c1 varchar(20), c2 varchar(20), primary key(id)); +insert into t1 values (1,5,10),(3,7,12),(4,5,2),(9,10,15),(2,2,2); +insert into t2 values (9,"abc","def"),(5,"opq","lmn"),(2,"test t","t test"); +select * from t1 order by i1; +select * from t2 order by id; +update t1,t2 set t1.i2=15, t2.c2="ppc" where t1.i1=t2.id; +select * from t1 order by i1; +select * from t2 order by id; +delete t1.*,t2.* from t1,t2 where t1.i2=t2.id; +select * from t1 order by i1; +select * from t2 order by id; +drop table t1, t2; # # Bug#27716 multi-update did partially and has not binlogged @@ -528,7 +572,12 @@ CREATE TABLE `t2` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ; -# A. testing multi_update::send_eof() execution branch +# as the test is about to see erroed queries in binlog +set @sav_binlog_format= @@session.binlog_format; +set @@session.binlog_format= mixed; + + +# A. testing multi_update::send_error() effective update insert into t1 values (1,1),(2,2); insert into t2 values (1,1),(4,4); reset master; @@ -538,7 +587,8 @@ UPDATE t2,t1 SET t2.a=t1.a+2; select * from t2 /* must be (3,1), (4,4) */; show master status /* there must be the UPDATE query event */; -# B. testing multi_update::send_error() execution branch +# B. testing multi_update::send_error() ineffective update +# (as there is a policy described at mysql_update() still go to binlog) delete from t1; delete from t2; insert into t1 values (1,2),(3,4),(4,4); @@ -550,7 +600,7 @@ show master status /* there must be the UPDATE query event */; # cleanup drop table t1, t2; - +set @@session.binlog_format= @sav_binlog_format; # # Bug#29136 erred multi-delete on trans table does not rollback @@ -579,11 +629,13 @@ delete t3.* from t2,t3 where t2.a=t3.a; # check select count(*) from t1 /* must be 1 */; select count(*) from t3 /* must be 1 */; -# the query must be in binlog (no surprise though) -source include/show_binlog_events.inc; # cleanup drop table t1, t2, t3; +# +# Add further tests from here +# + --echo end of tests diff --git a/mysql-test/t/multi_update2.test b/mysql-test/t/multi_update2.test index 47f9bc7bad7..a04518f4964 100644 --- a/mysql-test/t/multi_update2.test +++ b/mysql-test/t/multi_update2.test @@ -2,14 +2,46 @@ # Test of update statement that uses many tables. # ---disable_warnings -DROP TABLE IF EXISTS t1,t2; ---enable_warnings +# +# If we are running with +# - Valgrind -> $VALGRIND_TEST <> 0 +# - debug tracing -> @@session.debug LIKE '%trace%' +# the resource consumption (storage space needed, runtime) will be extreme. +# Therefore we require that the option "--big-test" is also set. +# + +let $need_big= 0; +--disable_query_log +--error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET @aux = @@session.debug; +if (!$mysql_errno) +{ + # We have returncode 0 = the server system variable @@session.debug exists. + # But we only need "--big-test" in case of tracing. + if (`SELECT @@session.debug LIKE '%trace%'`) + { + let $need_big= 1; + } +} +--enable_query_log +if ($VALGRIND_TEST) +{ + # We are running with Valgrind + inc $need_big; +} +if (`SELECT '$BIG_TEST' = '' AND $need_big = 1`) +{ + --skip Need "--big-test" when running with the option "--debug" or "--valgrind" +} # # Bug#1820 Rows not deleted from second table on multi-table delete # +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings + CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL) ; --echo # The protocolling of many inserts into t1 is suppressed. --disable_query_log diff --git a/mysql-test/t/myisam-blob-master.opt b/mysql-test/t/myisam-blob-master.opt index 1a1076c7bad..ededac33ec7 100644 --- a/mysql-test/t/myisam-blob-master.opt +++ b/mysql-test/t/myisam-blob-master.opt @@ -1 +1 @@ ---max-allowed-packet=24M --skip-innodb --key-buffer-size=1M +--max-allowed-packet=24M --loose-skip-innodb --key-buffer-size=1M diff --git a/mysql-test/t/myisam-system.test b/mysql-test/t/myisam-system.test new file mode 100644 index 00000000000..d908e639a4e --- /dev/null +++ b/mysql-test/t/myisam-system.test @@ -0,0 +1,22 @@ +# +# Test how DROP TABLE works if the index or data file doesn't exists + +# Initialise +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +create table t1 (a int) engine=myisam; +let $MYSQLD_DATADIR= `select @@datadir`; +--remove_file $MYSQLD_DATADIR/test/t1.MYI +drop table if exists t1; +create table t1 (a int) engine=myisam; +--remove_file $MYSQLD_DATADIR/test/t1.MYI +--error ER_BAD_TABLE_ERROR,6 +drop table t1; +create table t1 (a int) engine=myisam; +--remove_file $MYSQLD_DATADIR/test/t1.MYD +--error ER_BAD_TABLE_ERROR,6,29 +drop table t1; +--error ER_BAD_TABLE_ERROR +drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 254b0378aa8..e4ea939f348 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -453,9 +453,9 @@ create table t1 (a int not null auto_increment primary key, b text not null, uni insert into t1 (b) values ('a'),('b'),('c'); select concat(b,'.') from t1; update t1 set b='b ' where a=2; ---error 1062 +--error ER_DUP_ENTRY update t1 set b='b ' where a > 1; ---error 1062 +--error ER_DUP_ENTRY insert into t1 (b) values ('b'); select * from t1; delete from t1 where b='b'; @@ -576,32 +576,6 @@ select count(*) from t1 where a is null; drop table t1; # -# Bug #8306: TRUNCATE leads to index corruption -# -create table t1 (c1 int, index(c1)); -create table t2 (c1 int, index(c1)) engine=merge union=(t1); -insert into t1 values (1); -# Close all tables. -flush tables; -# Open t2 and (implicitly) t1. -select * from t2; -# Truncate after flush works (unless another threads reopens t2 in between). -flush tables; -truncate table t1; -insert into t1 values (1); -# Close all tables. -flush tables; -# Open t2 and (implicitly) t1. -select * from t2; -# Truncate t1, wich was not recognized as open without the bugfix. -# Now, it should fail with a table-in-use error message. ---error 1105 -truncate table t1; -# The insert used to fail on the crashed table. -insert into t1 values (1); -drop table t1,t2; - -# # bug9188 - Corruption Can't open file: 'table.MYI' (errno: 145) # create table t1 (c1 int, c2 varchar(4) not null default '', @@ -1048,23 +1022,6 @@ create table t1 (v varchar(65535)); eval set storage_engine=$default; # -# Test how DROP TABLE works if the index or data file doesn't exists - -create table t1 (a int) engine=myisam; -remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYI ; -drop table if exists t1; -create table t1 (a int) engine=myisam; -remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYI ; ---error 1051,6 -drop table t1; -create table t1 (a int) engine=myisam; -remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD ; ---error 1105,6,29 -drop table t1; ---error 1051 -drop table t1; - -# # Test concurrent insert # First with static record length # @@ -1135,6 +1092,7 @@ show keys from t1; drop table t1; + # # Bug#10056 - PACK_KEYS option take values greater than 1 while creating table # @@ -1145,6 +1103,7 @@ create table t3 (c1 int) engine=myisam pack_keys=default; create table t4 (c1 int) engine=myisam pack_keys=2; drop table t1, t2, t3; + # # Bug#28476: force index on a disabled myisam index gives error 124 # @@ -1226,3 +1185,369 @@ CHECK TABLE t1; DROP TABLE t1; --echo End of 5.0 tests + + +# +# Test of key_block_size +# + +create table t1 (a int not null, key `a` (a) key_block_size=1024); +show create table t1; +drop table t1; + +create table t1 (a int not null, key `a` (a) key_block_size=2048); +show create table t1; +drop table t1; + +create table t1 (a varchar(2048), key `a` (a)); +show create table t1; +drop table t1; + +create table t1 (a varchar(2048), key `a` (a) key_block_size=1024); +show create table t1; +drop table t1; + +create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=1024; +show create table t1; +alter table t1 key_block_size=2048; +show create table t1; +alter table t1 add c int, add key (c); +show create table t1; +alter table t1 key_block_size=0; +alter table t1 add d int, add key (d); +show create table t1; +drop table t1; + +create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=8192; +show create table t1; +drop table t1; + +create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) key_block_size=8192; +show create table t1; +drop table t1; + +create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_block_size=8192) key_block_size=16384; +show create table t1; +drop table t1; + + +# Test limits and errors of key_block_size + +create table t1 (a int not null, key `a` (a) key_block_size=512); +show create table t1; +drop table t1; + +create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000); +show create table t1; +drop table t1; + +create table t1 (a int not null, key `a` (a) key_block_size=1025); +show create table t1; +drop table t1; + +--error 1064 +create table t1 (a int not null, key key_block_size=1024 (a)); +--error 1064 +create table t1 (a int not null, key `a` key_block_size=1024 (a)); + +# +# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk +# +CREATE TABLE t1 ( + c1 INT, + c2 VARCHAR(300), + KEY (c1) KEY_BLOCK_SIZE 1024, + KEY (c2) KEY_BLOCK_SIZE 8192 + ); +INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))), + (11, REPEAT('b', CEIL(RAND() * 300))), + (12, REPEAT('c', CEIL(RAND() * 300))), + (13, REPEAT('d', CEIL(RAND() * 300))), + (14, REPEAT('e', CEIL(RAND() * 300))), + (15, REPEAT('f', CEIL(RAND() * 300))), + (16, REPEAT('g', CEIL(RAND() * 300))), + (17, REPEAT('h', CEIL(RAND() * 300))), + (18, REPEAT('i', CEIL(RAND() * 300))), + (19, REPEAT('j', CEIL(RAND() * 300))), + (20, REPEAT('k', CEIL(RAND() * 300))), + (21, REPEAT('l', CEIL(RAND() * 300))), + (22, REPEAT('m', CEIL(RAND() * 300))), + (23, REPEAT('n', CEIL(RAND() * 300))), + (24, REPEAT('o', CEIL(RAND() * 300))), + (25, REPEAT('p', CEIL(RAND() * 300))), + (26, REPEAT('q', CEIL(RAND() * 300))), + (27, REPEAT('r', CEIL(RAND() * 300))), + (28, REPEAT('s', CEIL(RAND() * 300))), + (29, REPEAT('t', CEIL(RAND() * 300))), + (30, REPEAT('u', CEIL(RAND() * 300))), + (31, REPEAT('v', CEIL(RAND() * 300))), + (32, REPEAT('w', CEIL(RAND() * 300))), + (33, REPEAT('x', CEIL(RAND() * 300))), + (34, REPEAT('y', CEIL(RAND() * 300))), + (35, REPEAT('z', CEIL(RAND() * 300))); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +CHECK TABLE t1; +REPAIR TABLE t1; +DELETE FROM t1 WHERE c1 >= 10; +CHECK TABLE t1; +DROP TABLE t1; + +# +# Bug#33222 - myisam-table drops rows when column is added +# and a char-field > 128 exists +# +# Test #1 - CHECK TABLE sees wrong record, REPAR TABLE deletes it. +# Using a CHAR column that can have > 127 characters. +# Using a VARCHAR to create a table with dynamic row format. +CREATE TABLE t1 ( + c1 CHAR(130), + c2 VARCHAR(1) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES(REPEAT("a",128), 'b'); +SELECT COUNT(*) FROM t1; +CHECK TABLE t1; +REPAIR TABLE t1; +SELECT COUNT(*) FROM t1; +CHECK TABLE t1; +DROP TABLE t1; +# +# Test #2 - same as test #1, but using EXTENDED. +# Using a CHAR column that can have > 127 characters. +# Using a VARCHAR to create a table with dynamic row format. +CREATE TABLE t1 ( + c1 CHAR(130), + c2 VARCHAR(1) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES(REPEAT("a",128), 'b'); +SELECT COUNT(*) FROM t1; +CHECK TABLE t1 EXTENDED; +REPAIR TABLE t1 EXTENDED; +SELECT COUNT(*) FROM t1; +CHECK TABLE t1 EXTENDED; +DROP TABLE t1; +# +# Test #3 - same as test #1, but using OPTIMIZE TABLE. +# Using a CHAR column that can have > 127 characters. +# Using a VARCHAR to create a table with dynamic row format. +CREATE TABLE t1 ( + c1 CHAR(130), + c2 VARCHAR(1) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES(REPEAT("a",128), 'b'); +# Insert more rows and delete one in the middle to force optimize. +INSERT INTO t1 VALUES('b', 'b'); +INSERT INTO t1 VALUES('c', 'b'); +DELETE FROM t1 WHERE c1='b'; +SELECT COUNT(*) FROM t1; +OPTIMIZE TABLE t1; +SELECT COUNT(*) FROM t1; +DROP TABLE t1; +# +# Test #4 - ALTER TABLE deletes rows. +# Using a CHAR column that can have > 127 characters. +# Using a VARCHAR to create a table with dynamic row format. +# Using an index which can be disabled during bulk insert. +CREATE TABLE t1 ( + c1 CHAR(130), + c2 VARCHAR(1), + KEY (c1) +) ENGINE=MyISAM; +# +# Insert 100 rows. This turns bulk insert on during the copy phase of +# ALTER TABLE. Bulk insert disables keys before the insert and re-enables +# them by repair after the insert. +--disable_query_log +let $count= 100; +--echo # Insert $count rows. Query log disabled. +while ($count) +{ + INSERT INTO t1 VALUES ('a', 'b'); + dec $count; +} +--enable_query_log +# +# Change most of the rows into long character values with > 127 characters. +UPDATE t1 SET c1=REPEAT("a",128) LIMIT 90; +SELECT COUNT(*) FROM t1; +ALTER TABLE t1 ENGINE=MyISAM; +# +# With bug present, this shows that all long rows are gone. +SELECT COUNT(*) FROM t1; +CHECK TABLE t1; +CHECK TABLE t1 EXTENDED; +DROP TABLE t1; +# +# Test #5 - same as test #1 but UTF-8. +# Using a CHAR column that can have > 127 characters. +# Using a VARCHAR to create a table with dynamic row format. +CREATE TABLE t1 ( + c1 CHAR(50), + c2 VARCHAR(1) +) ENGINE=MyISAM DEFAULT CHARSET UTF8; +# Using Tamil Letter A, Unicode U+0B85 +INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b'); +SELECT COUNT(*) FROM t1; +CHECK TABLE t1; +REPAIR TABLE t1; +SELECT COUNT(*) FROM t1; +CHECK TABLE t1; +DROP TABLE t1; +# +# Test #6 - same as test #2, but UTF-8. +# Using a CHAR column that can have > 127 characters. +# Using a VARCHAR to create a table with dynamic row format. +CREATE TABLE t1 ( + c1 CHAR(50), + c2 VARCHAR(1) +) ENGINE=MyISAM DEFAULT CHARSET UTF8; +# Using Tamil Letter A, Unicode U+0B85 +INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b'); +SELECT COUNT(*) FROM t1; +CHECK TABLE t1 EXTENDED; +REPAIR TABLE t1 EXTENDED; +SELECT COUNT(*) FROM t1; +CHECK TABLE t1 EXTENDED; +DROP TABLE t1; +# +# Test #7 - same as test #3, but UTF-8. +# Using a CHAR column that can have > 127 characters. +# Using a VARCHAR to create a table with dynamic row format. +CREATE TABLE t1 ( + c1 CHAR(50), + c2 VARCHAR(1) +) ENGINE=MyISAM DEFAULT CHARSET UTF8; +# Using Tamil Letter A, Unicode U+0B85 +INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b'); +# Insert more rows and delete one in the middle to force optimize. +INSERT INTO t1 VALUES('b', 'b'); +INSERT INTO t1 VALUES('c', 'b'); +DELETE FROM t1 WHERE c1='b'; +SELECT COUNT(*) FROM t1; +OPTIMIZE TABLE t1; +SELECT COUNT(*) FROM t1; +DROP TABLE t1; +# +# Test #8 - same as test #4, but UTF-8. +# Using a CHAR column that can have > 42 UTF-8 characters. +# Using a VARCHAR to create a table with dynamic row format. +# Using an index which can be disabled during bulk insert. +CREATE TABLE t1 ( + c1 CHAR(50), + c2 VARCHAR(1), + KEY (c1) +) ENGINE=MyISAM DEFAULT CHARSET UTF8; +# +# Insert 100 rows. This turns bulk insert on during the copy phase of +# ALTER TABLE. Bulk insert disables keys before the insert and re-enables +# them by repair after the insert. +--disable_query_log +let $count= 100; +--echo # Insert $count rows. Query log disabled. +while ($count) +{ + INSERT INTO t1 VALUES ('a', 'b'); + dec $count; +} +--enable_query_log +# +# Change most of the rows into long character values with > 42 characters. +# Using Tamil Letter A, Unicode U+0B85 +UPDATE t1 SET c1=REPEAT(_utf8 x'e0ae85',43) LIMIT 90; +SELECT COUNT(*) FROM t1; +ALTER TABLE t1 ENGINE=MyISAM; +# +# With bug present, this shows that all long rows are gone. +SELECT COUNT(*) FROM t1; +CHECK TABLE t1; +CHECK TABLE t1 EXTENDED; +DROP TABLE t1; + +# +# Bug#29182 - MyISAMCHK reports wrong character set +# +CREATE TABLE t1 ( + c1 VARCHAR(10) NOT NULL, + c2 CHAR(10) DEFAULT NULL, + c3 VARCHAR(10) NOT NULL, + KEY (c1), + KEY (c2) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0; +let $MYSQLD_DATADIR= `select @@datadir`; +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--exec $MYISAMCHK -d $MYSQLD_DATADIR/test/t1 +DROP TABLE t1; + +# +# Bug#43737: Select query return bad result +# +CREATE TABLE t1 ( + c INT, + d bit(1), + e INT, + f VARCHAR(1), + g BIT(1), + h BIT(1), + KEY (h, d, e, g) +); +INSERT INTO t1 VALUES + ( 3, 1, 1, 'a', 0, 0 ), + ( 3, 1, 5, 'a', 0, 0 ), + ( 10, 1, 2, 'a', 0, 1 ), + ( 10, 1, 3, 'a', 0, 1 ), + ( 10, 1, 4, 'a', 0, 1 ); + +SELECT f FROM t1 WHERE d = 1 AND e = 2 AND g = 0 AND h = 1; + +SELECT h+0, d + 0, e, g + 0 FROM t1; + +DROP TABLE t1; + +--echo # +--echo # Test of BUG#35570 CHECKSUM TABLE unreliable if LINESTRING field +--echo # (same content / differen checksum) +--echo # + +CREATE TABLE t1 (line LINESTRING NOT NULL) engine=myisam; +INSERT INTO t1 VALUES (GeomFromText("POINT(0 0)")); +checksum table t1; +CREATE TABLE t2 (line LINESTRING NOT NULL) engine=myisam; +INSERT INTO t2 VALUES (GeomFromText("POINT(0 0)")); +checksum table t2; +CREATE TABLE t3 select * from t1; +checksum table t3; +drop table t1,t2,t3; + + +# +# BUG#47073 - valgrind errs, corruption,failed repair of partition, +# low myisam_sort_buffer_size +# +CREATE TABLE t1(a INT, b CHAR(10), KEY(a), KEY(b)); +INSERT INTO t1 VALUES(1,'0'),(2,'0'),(3,'0'),(4,'0'),(5,'0'), + (6,'0'),(7,'0'); +INSERT INTO t1 SELECT a+10,b FROM t1; +INSERT INTO t1 SELECT a+20,b FROM t1; +INSERT INTO t1 SELECT a+40,b FROM t1; +INSERT INTO t1 SELECT a+80,b FROM t1; +INSERT INTO t1 SELECT a+160,b FROM t1; +INSERT INTO t1 SELECT a+320,b FROM t1; +INSERT INTO t1 SELECT a+640,b FROM t1; +INSERT INTO t1 SELECT a+1280,b FROM t1; +INSERT INTO t1 SELECT a+2560,b FROM t1; +INSERT INTO t1 SELECT a+5120,b FROM t1; +SET myisam_sort_buffer_size=4; +REPAIR TABLE t1; + +# !!! Disabled until additional fix for BUG#47073 is pushed. +#SET myisam_repair_threads=2; +# May report different values depending on threads activity. +#--replace_regex /changed from [0-9]+/changed from #/ +#REPAIR TABLE t1; +#SET myisam_repair_threads=@@global.myisam_repair_threads; + +SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; +DROP TABLE t1; + +--echo End of 5.1 tests + diff --git a/mysql-test/t/myisam_crash_before_flush_keys-master.opt b/mysql-test/t/myisam_crash_before_flush_keys-master.opt new file mode 100644 index 00000000000..425fda95086 --- /dev/null +++ b/mysql-test/t/myisam_crash_before_flush_keys-master.opt @@ -0,0 +1 @@ +--skip-stack-trace --skip-core-file diff --git a/mysql-test/t/myisam_crash_before_flush_keys.test b/mysql-test/t/myisam_crash_before_flush_keys.test new file mode 100644 index 00000000000..1860ddd27e3 --- /dev/null +++ b/mysql-test/t/myisam_crash_before_flush_keys.test @@ -0,0 +1,41 @@ +--echo # +--echo # BUG#41330 - Myisam table open count set to zero before index blocks are written. +--echo # +--source include/not_embedded.inc +--echo # Don't test this under valgrind, memory leaks will occur +--source include/not_valgrind.inc + +--echo # Binary must be compiled with debug for crash to occur +--source include/have_debug.inc + +let $MYSQLD_DATADIR= `select @@datadir`; +SET GLOBAL delay_key_write=ALL; +CREATE TABLE t1(a INT, + b INT, + PRIMARY KEY(a , b), + KEY(b)) ENGINE=MyISAM DELAY_KEY_WRITE = 1; +INSERT INTO t1 VALUES (1,2),(2,3),(3,4),(4,5),(5,6); + +--echo # Setup the mysqld to crash at certain point +SET SESSION debug="d,crash_before_flush_keys"; + +--echo # Write file to make mysql-test-run.pl expect crash +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +--echo # Run the crashing query +--error 2013 +FLUSH TABLE t1; + +--echo # Write file to make mysql-test-run.pl start the server +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +--echo # Turn on reconnect +--enable_reconnect + +--echo # Call script that will poll the server waiting for +--echo # it to be back online again +--source include/wait_until_connected_again.inc + +# Must report that the table wasn't closed properly +CHECK TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/t/myisam_debug.test b/mysql-test/t/myisam_debug.test new file mode 100644 index 00000000000..913668c5f22 --- /dev/null +++ b/mysql-test/t/myisam_debug.test @@ -0,0 +1,57 @@ +--source include/have_debug.inc + +# We disable this test in embedded mode because of BUG#43733 +--source include/not_embedded.inc + +--echo # +--echo # BUG#40827 - Killing insert-select to MyISAM can cause table corruption +--echo # + +CONNECT (insertConn, localhost, root,,); + +CREATE TABLE `t1` ( +`id` BIGINT(20) , +`id1` BIGINT(20) AUTO_INCREMENT, + KEY(id1), KEY(id) +) ENGINE=MyISAM; + +CREATE TABLE `t2` ( +`id` BIGINT(20) , +`id1` BIGINT(20) AUTO_INCREMENT, + KEY (id1), KEY(id) +) ENGINE=MyISAM; + +INSERT INTO t2 (id) VALUES (123); + +let $i = 10; +while ($i) +{ + INSERT INTO t2 (id) SELECT id FROM t2; + dec $i; +} + +--echo # Switch to insert Connection +CONNECTION insertConn; +SET SESSION debug='+d,wait_in_enable_indexes'; +--echo # Send insert data +SEND INSERT INTO t1(id) SELECT id FROM t2; + +--echo # Switch to default Connection +CONNECTION default; +--echo # Wait for insert data to reach the debug point + +let $wait_condition= + SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST + WHERE STATE = "wait_in_enable_indexes" AND + INFO = "INSERT INTO t1(id) SELECT id FROM t2"; +--source include/wait_condition.inc + +SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST +WHERE STATE = 'wait_in_enable_indexes' AND +INFO = "INSERT INTO t1(id) SELECT id FROM t2" +INTO @thread_id; + +KILL QUERY @thread_id; +CHECK TABLE t1; +DROP TABLE t1,t2; +DISCONNECT insertConn; diff --git a/mysql-test/t/myisampack.test b/mysql-test/t/myisampack.test index ce27071bcf8..9d27ed53254 100644 --- a/mysql-test/t/myisampack.test +++ b/mysql-test/t/myisampack.test @@ -26,12 +26,42 @@ INSERT INTO t1 VALUES (2.22402118719591e-05,2.37546284320705e-05,2.58463051055541e-05,1.83391609130854e-05,1.6300720519646e-05,1.74559091886791e-05,1.63733785575587e-05,2.26616253279828e-05,1.79541237435621e-05,45), (3.01092775359837e-05,3.23865212934412e-05,4.09444584045994e-05,0,2.15470966302776e-05,2.39082636344032e-05,2.28296706429177e-05,2.9007671511595e-05,2.44201138973326e-05,46); FLUSH TABLES; ---exec $MYISAMPACK -s $MYSQLTEST_VARDIR/master-data/test/t1 ---exec $MYISAMCHK -srq $MYSQLTEST_VARDIR/master-data/test/t1 ---exec $MYISAMCHK -s --unpack $MYSQLTEST_VARDIR/master-data/test/t1 +let $MYSQLD_DATADIR= `select @@datadir`; +--exec $MYISAMPACK -s $MYSQLD_DATADIR/test/t1 +--exec $MYISAMCHK -srq $MYSQLD_DATADIR/test/t1 +--exec $MYISAMCHK -s --unpack $MYSQLD_DATADIR/test/t1 CHECK TABLE t1 EXTENDED; DROP TABLE t1; +# +# Bug#40949 Debug version of MySQL server crashes when run OPTIMIZE on compressed table. +# expanded with testcase for +# BUG#41574 - REPAIR TABLE: crashes for compressed tables +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1(f1 int, f2 char(255)); +insert into t1 values(1, 'foo'), (2, 'bar'); +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +flush tables; +let $MYSQLD_DATADIR= `select @@datadir`; +--exec $MYISAMPACK $MYSQLD_DATADIR/test/t1 +optimize table t1; +repair table t1; +drop table t1; + --echo # --echo # BUG#41541 - Valgrind warnings on packed MyISAM table --echo # @@ -47,7 +77,8 @@ while ($i) --enable_query_log FLUSH TABLE t1; --echo # Compress the table using MYISAMPACK tool ---exec $MYISAMPACK $MYSQLTEST_VARDIR/master-data/test/t1 +let $MYSQLD_DATADIR= `select @@datadir`; +--exec $MYISAMPACK $MYSQLD_DATADIR/test/t1 SELECT COUNT(*) FROM t1; DROP TABLE t1; @@ -68,9 +99,10 @@ INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; FLUSH TABLE mysql_db1.t1; # --echo # Compress the table using MYISAMPACK tool ---exec $MYISAMPACK -s $MYSQLTEST_VARDIR/master-data/mysql_db1/t1 +let $MYSQLD_DATADIR= `select @@datadir`; +--exec $MYISAMPACK -s $MYSQLD_DATADIR/mysql_db1/t1 --echo # Run MYISAMCHK tool on the compressed table ---exec $MYISAMCHK -srq $MYSQLTEST_VARDIR/master-data/mysql_db1/t1 +--exec $MYISAMCHK -srq $MYSQLD_DATADIR/mysql_db1/t1 SELECT COUNT(*) FROM mysql_db1.t1 WHERE c2 < 5; # DROP TABLE mysql_db1.t1; diff --git a/mysql-test/t/mysql-bug41486.test b/mysql-test/t/mysql-bug41486.test index 805c0f99480..6e014bca7d1 100644 --- a/mysql-test/t/mysql-bug41486.test +++ b/mysql-test/t/mysql-bug41486.test @@ -9,6 +9,8 @@ # on debx86-b in PB # +-- source include/not_embedded.inc + --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings @@ -30,9 +32,12 @@ let $outfile= $MYSQLTEST_VARDIR/tmp/bug41486.sql; --error 0,1 remove_file $outfile; --exec $MYSQL_DUMP test t1 > $outfile +SET @old_general_log = @@global.general_log; +SET @@global.general_log = 0; # Check that the mysql client does not insert extra newlines when loading # strings longer than client's max_allowed_packet --exec $MYSQL --max_allowed_packet=1M test < $outfile 2>&1 +SET @@global.general_log = @old_general_log; SELECT LENGTH(data) FROM t1; DROP TABLE t1; diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index b2d7400d156..cffa6392fa3 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -240,6 +240,7 @@ drop table t17583; --error 1 --exec $MYSQL test -e "\r test cyrils_superlonghostnameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1 + # # Bug #21412: mysql cmdline client allows backslash(es) # as delimiter but can't recognize them @@ -357,3 +358,48 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql; --exec $MYSQL --default-character-set=binary test -e "DELIMITER //" 2>&1 --echo End of 5.0 tests + +# +# Bug #29903: The CMake build method does not produce the embedded library. +# +--disable_query_log +--exec $MYSQL --server-arg=no-defaults test -e "quit" +--enable_query_log + +# +# Bug #25146: Some warnings/errors not shown when using --show-warnings +# + +# This one should succeed with no warnings +--exec $MYSQL --show-warnings test -e "create table t1 (id int)" + +# This should succeed, with warnings about conversion from nonexistent engine +--exec $MYSQL --show-warnings test -e "create table t2 (id int) engine=nonexistent" + +# This should fail, with warnings as well +--error 1 +--exec $MYSQL --show-warnings test -e "create table t2 (id int) engine=nonexistent2" + +drop tables t1, t2; + +# +# Bug #27884: mysql --html does not quote HTML special characters in output +# +--exec $MYSQL --html test -e "select '< & >' as '<'" + +# +# Bug #27884: mysql client + null byte +# +create table t1 (a char(5)); +insert into t1 values ('\0b\0'); +--exec $MYSQL test -e "select a from t1" +--exec $MYSQL -r test -e "select a from t1" +--exec $MYSQL -s test -e "select a from t1" +--exec $MYSQL --table test -e "select a from t1" +--exec $MYSQL --vertical test -e "select a from t1" +--exec $MYSQL --html test -e "select a from t1" +--exec $MYSQL --xml test -e "select a from t1" +drop table t1; + +--echo +--echo End of tests diff --git a/mysql-test/t/mysql_client_test-master.opt b/mysql-test/t/mysql_client_test-master.opt new file mode 100644 index 00000000000..4c683f7f0a2 --- /dev/null +++ b/mysql-test/t/mysql_client_test-master.opt @@ -0,0 +1 @@ +--log=$MYSQLTEST_VARDIR/log/master.log --log-output=FILE,TABLE diff --git a/mysql-test/t/mysql_client_test.opt b/mysql-test/t/mysql_client_test.opt deleted file mode 100644 index 968ba95c6cc..00000000000 --- a/mysql-test/t/mysql_client_test.opt +++ /dev/null @@ -1 +0,0 @@ ---log diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test index 7667522feaf..15c0cd4ac84 100644 --- a/mysql-test/t/mysql_client_test.test +++ b/mysql-test/t/mysql_client_test.test @@ -1,6 +1,8 @@ # This test should work in embedded server after we fix mysqltest -- source include/not_embedded.inc +SET @old_general_log= @@global.general_log; + # We run with different binaries for normal and --embedded-server # # If this test fails with "command "$MYSQL_CLIENT_TEST" failed", @@ -14,3 +16,4 @@ # End of 4.1 tests echo ok; +SET @@global.general_log= @old_general_log; diff --git a/mysql-test/t/mysql_comments.sql b/mysql-test/t/mysql_comments.sql index 60b223a240f..2497c35e465 100644 --- a/mysql-test/t/mysql_comments.sql +++ b/mysql-test/t/mysql_comments.sql @@ -167,8 +167,49 @@ delimiter ; show create procedure nicesp; drop procedure nicesp; -# Triggers can be tested only in 5.1, since 5.0 does not have -# SHOW CREATE TRIGGER +##============================================================================ +## Comments inside triggers +##============================================================================ + +drop trigger if exists t1_empty; + +create trigger t1_empty after delete on t1 +for each row +begin +end; + +show create trigger t1_empty; + +drop trigger if exists t1_bi; + +delimiter | + +create trigger t1_bi before insert on t1 +for each row +begin +# comment 1a +-- comment 1b +/* + comment 1c +*/ + -- declare some variables here + declare b int; + declare c float; + + -- do more stuff here + -- commented nicely and so on + + -- famous last words ... + set NEW.data := 12; +end| + +delimiter ; + +show create trigger t1_bi; + +# also make sure the trigger still works +insert into t1(id) value ("trig"); +select * from t1; ##============================================================================ ## Cleanup diff --git a/mysql-test/t/mysql_cp932.test b/mysql-test/t/mysql_cp932.test new file mode 100644 index 00000000000..60a129c3805 --- /dev/null +++ b/mysql-test/t/mysql_cp932.test @@ -0,0 +1,22 @@ +# This test should work in embedded server after we fix mysqltest +-- source include/not_embedded.inc + +# +# Tests from mysql.test which require the cp932 character set +# +-- source include/have_cp932.inc + +# +# BUG#16217 - MySQL client misinterprets multi-byte char as escape `\' +# + +# new command \C or charset +--exec $MYSQL --default-character-set=utf8 test -e "\C cp932 \g" +--exec $MYSQL --default-character-set=cp932 test -e "charset utf8;" + +# its usage to switch internally in mysql to requested charset +--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select '\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('\'); select * from t1; drop table t1;" +--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select '\'" +--exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select '\'" +--exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select '\'" + diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test index 233e8c7c256..d1f97d7287e 100644 --- a/mysql-test/t/mysql_upgrade.test +++ b/mysql-test/t/mysql_upgrade.test @@ -8,6 +8,26 @@ select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade; --enable_query_log # +# Hack: +# +# If running with Valgrind ($VALGRIND_TEST <> 0) then the resource +# consumption (CPU) for upgrading a large log table will be intense. +# Therefore, truncate the log table in advance and issue a statement +# that should be logged. +# +if (`SELECT $VALGRIND_TEST`) +{ + --disable_query_log + --disable_result_log + --disable_abort_on_error + TRUNCATE TABLE mysql.general_log; + SELECT 1; + --enable_abort_on_error + --enable_result_log + --enable_query_log +} + +# # Basic test that we can run mysql_upgrde and that it finds the # expected binaries it uses. # @@ -15,7 +35,8 @@ select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade; --exec $MYSQL_UPGRADE --skip-verbose 2>&1 # It should have created a file in the MySQL Servers datadir -file_exists $MYSQLTEST_VARDIR/master-data/mysql_upgrade_info; +let $MYSQLD_DATADIR= `select @@datadir`; +file_exists $MYSQLD_DATADIR/mysql_upgrade_info; --echo Run it again - should say already completed --replace_result $MYSQL_SERVER_VERSION VERSION @@ -23,13 +44,13 @@ file_exists $MYSQLTEST_VARDIR/master-data/mysql_upgrade_info; --exec $MYSQL_UPGRADE --skip-verbose 2>&1 # It should have created a file in the MySQL Servers datadir -file_exists $MYSQLTEST_VARDIR/master-data/mysql_upgrade_info; +file_exists $MYSQLD_DATADIR/mysql_upgrade_info; --echo Force should run it regardless of wether it's been run before --exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 # It should have created a file in the MySQL Servers datadir -file_exists $MYSQLTEST_VARDIR/master-data/mysql_upgrade_info; +file_exists $MYSQLD_DATADIR/mysql_upgrade_info; # diff --git a/mysql-test/t/mysqlbinlog-cp932.test b/mysql-test/t/mysqlbinlog-cp932.test index 1c9f91fd9a8..2a210bea0e0 100644 --- a/mysql-test/t/mysqlbinlog-cp932.test +++ b/mysql-test/t/mysqlbinlog-cp932.test @@ -1,17 +1,21 @@ # disabled in embedded until tools running is fixed with embedded --- source include/not_embedded.inc +--source include/not_embedded.inc + +-- source include/have_binlog_format_mixed_or_statement.inc -- source include/have_cp932.inc -- source include/have_log_bin.inc +RESET MASTER; + # Bug#16217 (mysql client did not know how not switch its internal charset) -flush logs; create table t3 (f text character set utf8); create table t4 (f text character set cp932); --exec $MYSQL --default-character-set=utf8 test -e "insert into t3 values(_utf8'ソ')" --exec $MYSQL --default-character-set=cp932 test -e "insert into t4 values(_cp932'\');" flush logs; rename table t3 to t03, t4 to t04; ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000002 | $MYSQL --default-character-set=utf8 +let $MYSQLD_DATADIR= `select @@datadir`; +--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000001 | $MYSQL --default-character-set=utf8 # original and recovered data must be equal select HEX(f) from t03; select HEX(f) from t3; diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index c5b46b81207..78661b1bbc4 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -1,6 +1,12 @@ # We are using .opt file since we need small binlog size +# TODO: Need to look at making a row based version once the new row based client is completed. [jbm] +-- source include/have_binlog_format_mixed_or_statement.inc + -- source include/have_log_bin.inc +# Deletes all the binary logs +reset master; + # we need this for getting fixed timestamps inside of this test set timestamp=1000000000; @@ -20,11 +26,11 @@ insert into t2 values (); # test for load data and load data distributed among the several # files (we need to fill up first binlog) -load data infile '../std_data_ln/words.dat' into table t1; -load data infile '../std_data_ln/words.dat' into table t1; -load data infile '../std_data_ln/words.dat' into table t1; -load data infile '../std_data_ln/words.dat' into table t1; -load data infile '../std_data_ln/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1; # simple query to show more in second binlog insert into t1 values ("Alas"); flush logs; @@ -38,10 +44,10 @@ select "--- Local --" as ""; # We should use --short-form everywhere because in other case output will # be time dependend. Better than nothing. # - +let $MYSQLD_DATADIR= `select @@datadir`; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000001 # this should not fail but shouldn't produce any working statements --disable_query_log @@ -49,7 +55,7 @@ select "--- Broken LOAD DATA --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000002 2> /dev/null +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000002 2> /dev/null # this should show almost nothing --disable_query_log @@ -57,7 +63,7 @@ select "--- --database --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLTEST_VARDIR/log/master-bin.000001 2> /dev/null +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLD_DATADIR/master-bin.000001 2> /dev/null # this test for position option --disable_query_log @@ -65,7 +71,8 @@ select "--- --position --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=231 $MYSQLTEST_VARDIR/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=330 $MYSQLD_DATADIR/master-bin.000002 + # These are tests for remote binlog. # They should return the same as previous test. @@ -101,7 +108,7 @@ select "--- --position --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=231 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=330 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 # Bug#7853 mysqlbinlog does not accept input from stdin --disable_query_log @@ -133,7 +140,8 @@ EOF # resulted binlog, parly consisting of multi-byte utf8 chars, # must be digestable for both client and server. In 4.1 the client # should use default-character-set same as the server. ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000004 | $MYSQL +flush logs; +--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000004 | $MYSQL select * from t5 /* must be (1),(1) */; drop table t5; @@ -152,7 +160,7 @@ insert into t5 values (3, date_format('2001-01-01','%W')); select * from t5 order by c1; flush logs; drop table t5; ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000005 | $MYSQL +--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000006 | $MYSQL select * from t5 order by c1; drop table t5; @@ -176,8 +184,8 @@ drop procedure p1; --error ER_SP_DOES_NOT_EXIST call p1(); --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000007 ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000007 | $MYSQL +--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008 +--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008 | $MYSQL call p1(); drop procedure p1; @@ -196,23 +204,23 @@ drop procedure p1; flush logs; create table t1 (a varchar(64) character set utf8); -load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../../std_data/loaddata6.dat' into table t1; set character_set_database=koi8r; -load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../../std_data/loaddata6.dat' into table t1; set character_set_database=latin1; -load data infile '../std_data_ln/loaddata6.dat' into table t1; -load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../../std_data/loaddata6.dat' into table t1; +load data infile '../../std_data/loaddata6.dat' into table t1; set character_set_database=koi8r; -load data infile '../std_data_ln/loaddata6.dat' into table t1; +load data infile '../../std_data/loaddata6.dat' into table t1; set character_set_database=latin1; -load data infile '../std_data_ln/loaddata6.dat' into table t1; -load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r; +load data infile '../../std_data/loaddata6.dat' into table t1; +load data infile '../../std_data/loaddata6.dat' into table t1 character set koi8r; select hex(a) from t1; drop table t1; flush logs; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000009 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000010 # # Bug#28293 missed '#' sign in the hex dump when the dump length @@ -233,7 +241,7 @@ DROP TABLE t1; --disable_query_log CREATE TABLE patch (a BLOB); ---exec $MYSQL_BINLOG --hexdump --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000011 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat +--exec $MYSQL_BINLOG --hexdump --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000012 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat' INTO TABLE patch FIELDS TERMINATED BY '' LINES STARTING BY '#'; --remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat @@ -254,12 +262,13 @@ CREATE TABLE t1(a INT); INSERT INTO t1 VALUES(connection_id()); let $a= `SELECT a FROM t1`; FLUSH LOGS; ---exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000013 > $MYSQLTEST_VARDIR/tmp/bug29928.sql +let $outfile= $MYSQLTEST_VARDIR/tmp/bug29928.sql; +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000014 > $outfile DROP TABLE t1; connect (con1, localhost, root, , test); connection con1; ---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug29928.sql ---remove_file $MYSQLTEST_VARDIR/tmp/bug29928.sql +--exec $MYSQL test < $outfile +--remove_file $outfile let $b= `SELECT a FROM t1`; disconnect con1; connection default; @@ -270,7 +279,72 @@ DROP TABLE t1; echo shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql; error 1; exec $MYSQL_BINLOG $MYSQL_TEST_DIR/std_data/corrupt-relay-bin.000624 > $MYSQLTEST_VARDIR/tmp/bug31793.sql; -remove_file $MYSQLTEST_VARDIR/tmp/bug31793.sql; +--remove_file $MYSQLTEST_VARDIR/tmp/bug31793.sql + + +# +# Test --disable-force-if-open and --force-if-open +# +FLUSH LOGS; +--error 1 +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000016 >/dev/null 2>/dev/null +--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000016 >/dev/null 2>/dev/null + +--echo Bug#31611 Security risk with BINLOG statement + +SET BINLOG_FORMAT=ROW; +CREATE DATABASE mysqltest1; +CREATE USER untrusted@localhost; +GRANT SELECT ON mysqltest1.* TO untrusted@localhost; + +SHOW GRANTS FOR untrusted@localhost; +USE mysqltest1; +CREATE TABLE t1 (a INT, b CHAR(64)); +flush logs; +INSERT INTO t1 VALUES (1,USER()); +flush logs; +echo mysqlbinlog var/log/master-bin.000017 > var/tmp/bug31611.sql; +exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000017 > $MYSQLTEST_VARDIR/tmp/bug31611.sql; +connect (unsecure,localhost,untrusted,,mysqltest1); +echo mysql mysqltest1 -uuntrusted < var/tmp/bug31611.sql; +error 1; +exec $MYSQL mysqltest1 -uuntrusted < $MYSQLTEST_VARDIR/tmp/bug31611.sql; +--remove_file $MYSQLTEST_VARDIR/tmp/bug31611.sql +connection unsecure; +error ER_TABLEACCESS_DENIED_ERROR; +INSERT INTO t1 VALUES (1,USER()); + +SELECT * FROM t1; +connection default; +DROP DATABASE mysqltest1; +DROP USER untrusted@localhost; + +--echo Bug#32580 mysqlbinlog cannot read binlog event with user variables + +# Testing that various kinds of events can be read and restored properly. + +connection default; +USE test; +SET BINLOG_FORMAT = STATEMENT; +FLUSH LOGS; +CREATE TABLE t1 (a_real FLOAT, an_int INT, a_decimal DECIMAL(5,2), a_string CHAR(32)); +SET @a_real = rand(20) * 1000; +SET @an_int = 1000; +SET @a_decimal = CAST(rand(19) * 999 AS DECIMAL(5,2)); +SET @a_string = 'Just a test'; +INSERT INTO t1 VALUES (@a_real, @an_int, @a_decimal, @a_string); +FLUSH LOGS; +query_vertical SELECT * FROM t1; +DROP TABLE t1; + +echo >> mysqlbinlog var/log/master-bin.000019 > var/tmp/bug32580.sql; +exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000019 > $MYSQLTEST_VARDIR/tmp/bug32580.sql; +echo >> mysql test < var/tmp/bug32580.sql; +exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug32580.sql; +remove_file $MYSQLTEST_VARDIR/tmp/bug32580.sql; + +query_vertical SELECT * FROM t1; +DROP TABLE t1; # # Bug#37313 BINLOG Contains Incorrect server id @@ -283,7 +357,7 @@ eval SET @@global.server_id= $s_id_max; RESET MASTER; FLUSH LOGS; ---exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $binlog_file +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $binlog_file --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval SELECT (@a:=LOAD_FILE("$binlog_file")) @@ -361,9 +435,11 @@ FLUSH LOGS; --echo # --echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is exist ---exec $MYSQL_BINLOG --database=test --short-form $MYSQLTEST_VARDIR/std_data_ln/binlog_transaction.000001 +--exec $MYSQL_BINLOG --database=test --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001 --echo # --echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is not exist ---exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data_ln/binlog_transaction.000001 +--exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001 --echo End of 5.0 tests + +--echo End of 5.1 tests diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test index c6869d67da1..d6be029ea56 100644 --- a/mysql-test/t/mysqlbinlog2.test +++ b/mysql-test/t/mysqlbinlog2.test @@ -1,7 +1,9 @@ # Test for the new options --start-datetime, stop-datetime, # and a few others. --- source include/have_log_bin.inc +# TODO: Need to look at making row based version once new binlog client is complete. +-- source include/have_binlog_format_mixed_or_statement.inc + --disable_warnings drop table if exists t1; @@ -38,33 +40,33 @@ select "--- Local --" as ""; # We should use --short-form everywhere because in other case output will # be time dependent (the Start events). Better than nothing. # - ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 +let $MYSQLD_DATADIR= `select @@datadir`; +--exec $MYSQL_BINLOG --short-form --base64-output=never $MYSQLD_DATADIR/master-bin.000001 --disable_query_log select "--- offset --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --offset=2 $MYSQLTEST_VARDIR/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --offset=2 $MYSQLD_DATADIR/master-bin.000001 --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=600 $MYSQLTEST_VARDIR/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --start-position=608 $MYSQLD_DATADIR/master-bin.000001 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=600 $MYSQLTEST_VARDIR/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --stop-position=608 $MYSQLD_DATADIR/master-bin.000001 --disable_query_log select "--- start and stop positions ---" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=600 --stop-position 725 $MYSQLTEST_VARDIR/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 $MYSQLD_DATADIR/master-bin.000001 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLD_DATADIR/master-bin.000001 --disable_query_log select "--- stop-datetime --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQLD_DATADIR/master-bin.000001 --disable_query_log select "--- Local with 2 binlogs on command line --" as ""; @@ -72,28 +74,29 @@ select "--- Local with 2 binlogs on command line --" as ""; # This is to verify that some options apply only to first, or last binlog ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 +flush logs; +--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002 --disable_query_log select "--- offset --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --offset=2 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --offset=2 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002 --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=600 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --start-position=608 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=126 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --stop-position=134 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002 --disable_query_log select "--- stop-datetime --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002 --disable_query_log select "--- Remote --" as ""; @@ -108,15 +111,15 @@ select "--- offset --" as ""; --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 +--exec $MYSQL_BINLOG --short-form --start-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 +--exec $MYSQL_BINLOG --short-form --stop-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --disable_query_log select "--- start and stop positions ---" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=600 --stop-position 725 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 +--exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log @@ -139,11 +142,11 @@ select "--- offset --" as ""; --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 +--exec $MYSQL_BINLOG --short-form --start-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=126 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 +--exec $MYSQL_BINLOG --short-form --stop-position=134 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log diff --git a/mysql-test/t/mysqlbinlog_base64.test b/mysql-test/t/mysqlbinlog_base64.test new file mode 100644 index 00000000000..fb21e28fdcb --- /dev/null +++ b/mysql-test/t/mysqlbinlog_base64.test @@ -0,0 +1,73 @@ +-- source include/have_binlog_format_row.inc +# +# Reset master to cleanup binlog +# +reset master; + +# +# Write different events to binlog +# +create table t1 (a int); +insert into t1 values (1); +insert into t1 values (2); +insert into t1 values (3); +update t1 set a=a+2 where a=2; +update t1 set a=a+2 where a=3; + +create table t2 (word varchar(20)); +load data infile '../../std_data/words.dat' into table t2; + +# +# Save binlog +# +let $MYSQLD_DATADIR=`select @@datadir`; +flush logs; +--exec $MYSQL_BINLOG --hexdump $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql + +# +# Clear database and restore from binlog +# +drop table t1; +drop table t2; +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql + +# +# Verify that all binlog events have been executed +# +select * from t1; +select * from t2; + +# +# Verify that events larger than the default IO_CACHE buffer +# are handled correctly (BUG#25628). +# +flush logs; +drop table t2; +create table t2 (word varchar(20)); +load data infile '../../std_data/words.dat' into table t2; +insert into t2 select * from t2; +insert into t2 select * from t2; +insert into t2 select * from t2; +insert into t2 select * from t2; +insert into t2 select * from t2; +insert into t2 select * from t2; +insert into t2 select * from t2; +insert into t2 select * from t2; +insert into t2 select * from t2; +select count(*) from t2; + +flush logs; +--exec $MYSQL_BINLOG --hexdump $MYSQLD_DATADIR/master-bin.000003 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql + +# +# Verify that all binlog events have been executed +# +select count(*) from t2; + +# +# Test cleanup +# +--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql +drop table t1; +drop table t2; diff --git a/mysql-test/t/mysqlbinlog_row.test b/mysql-test/t/mysqlbinlog_row.test new file mode 100644 index 00000000000..9b41c63d195 --- /dev/null +++ b/mysql-test/t/mysqlbinlog_row.test @@ -0,0 +1,446 @@ +--source include/have_log_bin.inc +--source include/have_binlog_format_row.inc +--source include/have_ucs2.inc + +--echo # +--echo # Preparatory cleanup. +--echo # +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo # +--echo # We need a fixed timestamp to avoid varying results. +--echo # +SET timestamp=1000000000; + +--echo # +--echo # Delete all existing binary logs. +--echo # +RESET MASTER; + + +CREATE TABLE t1 (c01 BIT); +INSERT INTO t1 VALUES (0); +INSERT INTO t1 VALUES (1); +DROP TABLE t1; + +CREATE TABLE t1 (c01 BIT(7)); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (8); +INSERT INTO t1 VALUES (16); +INSERT INTO t1 VALUES (32); +INSERT INTO t1 VALUES (64); +INSERT INTO t1 VALUES (127); +DELETE FROM t1 WHERE c01=127; +UPDATE t1 SET c01=15 WHERE c01=16; +DROP TABLE t1; + +CREATE TABLE t1 (a BIT(20), b CHAR(2)); +INSERT INTO t1 VALUES (b'00010010010010001001', 'ab'); +DROP TABLE t1; + +CREATE TABLE t1 (c02 BIT(64)); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (128); +INSERT INTO t1 VALUES (b'1111111111111111111111111111111111111111111111111111111111111111'); +DROP TABLE t1; + + +CREATE TABLE t1 (c03 TINYINT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t1 VALUES (-128); +UPDATE t1 SET c03=2 WHERE c03=1; +DELETE FROM t1 WHERE c03=-128; +DROP TABLE t1; + +CREATE TABLE t1 (c04 TINYINT UNSIGNED); +INSERT INTO t1 VALUES (128), (255); +UPDATE t1 SET c04=2 WHERE c04=1; +DELETE FROM t1 WHERE c04=255; +DROP TABLE t1; + +CREATE TABLE t1 (c06 BOOL); +INSERT INTO t1 VALUES (TRUE); +DELETE FROM t1 WHERE c06=TRUE; +DROP TABLE t1; + +CREATE TABLE t1 (c07 SMALLINT); +INSERT INTO t1 VALUES (1234); +DELETE FROM t1 WHERE c07=1234; +DROP TABLE t1; + +CREATE TABLE t1 (c08 SMALLINT UNSIGNED); +INSERT INTO t1 VALUES (32768), (65535); +UPDATE t1 SET c08=2 WHERE c08=32768; +DELETE FROM t1 WHERE c08=65535; +DROP TABLE t1; + +CREATE TABLE t1 (c10 MEDIUMINT); +INSERT INTO t1 VALUES (12345); +DELETE FROM t1 WHERE c10=12345; +DROP TABLE t1; + +CREATE TABLE t1 (c11 MEDIUMINT UNSIGNED); +INSERT INTO t1 VALUES (8388608), (16777215); +UPDATE t1 SET c11=2 WHERE c11=8388608; +DELETE FROM t1 WHERE c11=16777215; +DROP TABLE t1; + +CREATE TABLE t1 (c13 INT); +INSERT INTO t1 VALUES (123456); +DELETE FROM t1 WHERE c13=123456; +DROP TABLE t1; + +CREATE TABLE t1 (c14 INT UNSIGNED); +INSERT INTO t1 VALUES (2147483648), (4294967295); +UPDATE t1 SET c14=2 WHERE c14=2147483648; +DELETE FROM t1 WHERE c14=4294967295; +DROP TABLE t1; + +CREATE TABLE t1 (c16 BIGINT); +INSERT INTO t1 VALUES (1234567890); +DELETE FROM t1 WHERE c16=1234567890; +DROP TABLE t1; + +CREATE TABLE t1 (c17 BIGINT UNSIGNED); +INSERT INTO t1 VALUES (9223372036854775808), (18446744073709551615); +UPDATE t1 SET c17=2 WHERE c17=9223372036854775808; +DELETE FROM t1 WHERE c17=18446744073709551615; +DROP TABLE t1; + +CREATE TABLE t1 (c19 FLOAT); +INSERT INTO t1 VALUES (123.2234); +DELETE FROM t1 WHERE c19>123; +DROP TABLE t1; + +CREATE TABLE t1 (c22 DOUBLE); +INSERT INTO t1 VALUES (123434.22344545); +DELETE FROM t1 WHERE c22>123434; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c25 DECIMAL(10,5)); +INSERT INTO t1 VALUES (124.45); +INSERT INTO t1 VALUES (-543.21); +DELETE FROM t1 WHERE c25=124.45; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c28 DATE); +INSERT INTO t1 VALUES ('2001-02-03'); +DELETE FROM t1 WHERE c28='2001-02-03'; +DROP TABLE t1; + +CREATE TABLE t1 (c29 DATETIME); +INSERT INTO t1 VALUES ('2001-02-03 10:20:30'); +DELETE FROM t1 WHERE c29='2001-02-03 10:20:30'; +DROP TABLE t1; + +CREATE TABLE t1 (c30 TIMESTAMP); +INSERT INTO t1 VALUES ('2001-02-03 10:20:30'); +DELETE FROM t1 WHERE c30='2001-02-03 10:20:30'; +DROP TABLE t1; + +CREATE TABLE t1 (c31 TIME); +INSERT INTO t1 VALUES ('11:22:33'); +DELETE FROM t1 WHERE c31='11:22:33'; +DROP TABLE t1; + +CREATE TABLE t1 (c32 YEAR); +INSERT INTO t1 VALUES ('2001'); +DELETE FROM t1 WHERE c32=2001; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c33 CHAR); +INSERT INTO t1 VALUES ('a'); +DELETE FROM t1 WHERE c33='a'; +DROP TABLE t1; + +CREATE TABLE t1 (c34 CHAR(0)); +INSERT INTO t1 VALUES (''); +DELETE FROM t1 WHERE c34=''; +DROP TABLE t1; + +CREATE TABLE t1 (c35 CHAR(1)); +INSERT INTO t1 VALUES ('b'); +DELETE FROM t1 WHERE c35='b'; +DROP TABLE t1; + +CREATE TABLE t1 (c36 CHAR(255)); +INSERT INTO t1 VALUES (repeat('c',255)); +DELETE FROM t1 WHERE c36>'c'; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c37 NATIONAL CHAR); +INSERT INTO t1 VALUES ('a'); +DELETE FROM t1 WHERE c37='a'; +DROP TABLE t1; + +CREATE TABLE t1 (c38 NATIONAL CHAR(0)); +INSERT INTO t1 VALUES (''); +DELETE FROM t1 WHERE c38=''; +DROP TABLE t1; + +CREATE TABLE t1 (c39 NATIONAL CHAR(1)); +INSERT INTO t1 VALUES ('a'); +DELETE FROM t1 WHERE c39='a'; +DROP TABLE t1; + +CREATE TABLE t1 (c40 NATIONAL CHAR(255)); +INSERT INTO t1 VALUES (repeat('a', 255)); +INSERT INTO t1 VALUES (repeat(_latin1 0xDF, 255)); +DELETE FROM t1 WHERE c40>'a'; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c41 CHAR CHARACTER SET UCS2); +INSERT INTO t1 VALUES ('a'); +DELETE FROM t1 WHERE c41='a'; +DROP TABLE t1; + +CREATE TABLE t1 (c42 CHAR(0) CHARACTER SET UCS2); +INSERT INTO t1 VALUES (''); +DELETE FROM t1 WHERE c42=''; +DROP TABLE t1; + +CREATE TABLE t1 (c43 CHAR(1) CHARACTER SET UCS2); +INSERT INTO t1 VALUES ('a'); +DELETE FROM t1 WHERE c43='a'; +DROP TABLE t1; + +CREATE TABLE t1 (c44 CHAR(255) CHARACTER SET UCS2); +INSERT INTO t1 VALUES (repeat('a', 255)); +INSERT INTO t1 VALUES (repeat(_latin1 0xDF, 255)); +DELETE FROM t1 WHERE c44>'a'; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c45 VARCHAR(0)); +INSERT INTO t1 VALUES (''); +DELETE FROM t1 WHERE c45=''; +DROP TABLE t1; + +CREATE TABLE t1 (c46 VARCHAR(1)); +INSERT INTO t1 VALUES ('a'); +DELETE FROM t1 WHERE c46='a'; +DROP TABLE t1; + +CREATE TABLE t1 (c47 VARCHAR(255)); +INSERT INTO t1 VALUES (repeat('a',255)); +DELETE FROM t1 WHERE c47>'a'; +DROP TABLE t1; + +CREATE TABLE t1 (c48 VARCHAR(261)); +INSERT INTO t1 VALUES (repeat('a',261)); +DELETE FROM t1 WHERE c48>'a'; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c49 NATIONAL VARCHAR(0)); +INSERT INTO t1 VALUES (''); +DELETE FROM t1 WHERE c49=''; +DROP TABLE t1; + +CREATE TABLE t1 (c50 NATIONAL VARCHAR(1)); +INSERT INTO t1 VALUES ('a'); +DELETE FROM t1 WHERE c50='a'; +DROP TABLE t1; + +CREATE TABLE t1 (c51 NATIONAL VARCHAR(255)); +INSERT INTO t1 VALUES (repeat('a',255)); +INSERT INTO t1 VALUES (repeat(_latin1 0xDF, 255)); +DELETE FROM t1 WHERE c51>'a'; +DROP TABLE t1; + +CREATE TABLE t1 (c52 NATIONAL VARCHAR(261)); +INSERT INTO t1 VALUES (repeat('a',261)); +INSERT INTO t1 VALUES (repeat(_latin1 0xDF, 261)); +DELETE FROM t1 WHERE c52>'a'; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c53 VARCHAR(0) CHARACTER SET ucs2); +INSERT INTO t1 VALUES (''); +DELETE FROM t1 WHERE c53=''; +DROP TABLE t1; + +CREATE TABLE t1 (c54 VARCHAR(1) CHARACTER SET ucs2); +INSERT INTO t1 VALUES ('a'); +DELETE FROM t1 WHERE c54='a'; +DROP TABLE t1; + +CREATE TABLE t1 (c55 VARCHAR(255) CHARACTER SET ucs2); +INSERT INTO t1 VALUES (repeat('ab', 127)); +DELETE FROM t1 WHERE c55>'a'; +DROP TABLE t1; + +CREATE TABLE t1 (c56 VARCHAR(261) CHARACTER SET ucs2); +INSERT INTO t1 VALUES (repeat('ab', 130)); +DELETE FROM t1 WHERE c56>'a'; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c57 BINARY); +INSERT INTO t1 VALUES (0x00); +INSERT INTO t1 VALUES (0x02); +INSERT INTO t1 VALUES ('a'); +DELETE FROM t1 WHERE c57='a'; +DROP TABLE t1; + +CREATE TABLE t1 (c58 BINARY(0)); +INSERT INTO t1 VALUES (''); +DELETE FROM t1 WHERE c58=''; +DROP TABLE t1; + +CREATE TABLE t1 (c59 BINARY(1)); +INSERT INTO t1 VALUES (0x00); +INSERT INTO t1 VALUES (0x02); +INSERT INTO t1 VALUES ('a'); +DELETE FROM t1 WHERE c59='a'; +DROP TABLE t1; + +CREATE TABLE t1 (c60 BINARY(255)); +INSERT INTO t1 VALUES (0x00); +INSERT INTO t1 VALUES (0x02); +INSERT INTO t1 VALUES (repeat('a\0',120)); +DELETE FROM t1 WHERE c60<0x02; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c61 VARBINARY(0)); +INSERT INTO t1 VALUES (''); +DELETE FROM t1 WHERE c61=''; +DROP TABLE t1; + +CREATE TABLE t1 (c62 VARBINARY(1)); +INSERT INTO t1 VALUES (0x00); +INSERT INTO t1 VALUES (0x02); +INSERT INTO t1 VALUES ('a'); +DELETE FROM t1 WHERE c62=0x02; +DROP TABLE t1; + +CREATE TABLE t1 (c63 VARBINARY(255)); +INSERT INTO t1 VALUES (0x00); +INSERT INTO t1 VALUES (0x02); +INSERT INTO t1 VALUES (repeat('a\0',120)); +DELETE FROM t1 WHERE c63=0x02; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c65 TINYBLOB); +INSERT INTO t1 VALUES ('tinyblob1'); +DELETE FROM t1 WHERE c65='tinyblob1'; +DROP TABLE t1; + +CREATE TABLE t1 (c68 BLOB); +INSERT INTO t1 VALUES ('blob1'); +DELETE FROM t1 WHERE c68='blob1'; +DROP TABLE t1; + +CREATE TABLE t1 (c71 MEDIUMBLOB); +INSERT INTO t1 VALUES ('mediumblob1'); +DELETE FROM t1 WHERE c71='mediumblob1'; +DROP TABLE t1; + +CREATE TABLE t1 (c74 LONGBLOB); +INSERT INTO t1 VALUES ('longblob1'); +DELETE FROM t1 WHERE c74='longblob1'; +DROP TABLE t1; + +CREATE TABLE t1 (c66 TINYTEXT); +INSERT INTO t1 VALUES ('tinytext1'); +DELETE FROM t1 WHERE c66='tinytext1'; +DROP TABLE t1; + +CREATE TABLE t1 (c69 TEXT); +INSERT INTO t1 VALUES ('text1'); +DELETE FROM t1 WHERE c69='text1'; +DROP TABLE t1; + +CREATE TABLE t1 (c72 MEDIUMTEXT); +INSERT INTO t1 VALUES ('mediumtext1'); +DELETE FROM t1 WHERE c72='mediumtext1'; +DROP TABLE t1; + +CREATE TABLE t1 (c75 LONGTEXT); +INSERT INTO t1 VALUES ('longtext1'); +DELETE FROM t1 WHERE c75='longtext1'; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c67 TINYTEXT CHARACTER SET UCS2); +INSERT INTO t1 VALUES ('tinytext1'); +DELETE FROM t1 WHERE c67='tinytext1'; +DROP TABLE t1; + +CREATE TABLE t1 (c70 TEXT CHARACTER SET UCS2); +INSERT INTO t1 VALUES ('text1'); +DELETE FROM t1 WHERE c70='text1'; +DROP TABLE t1; + +CREATE TABLE t1 (c73 MEDIUMTEXT CHARACTER SET UCS2); +INSERT INTO t1 VALUES ('mediumtext1'); +DELETE FROM t1 WHERE c73='mediumtext1'; +DROP TABLE t1; + +CREATE TABLE t1 (c76 LONGTEXT CHARACTER SET UCS2); +INSERT INTO t1 VALUES ('longtext1'); +DELETE FROM t1 WHERE c76='longtext1'; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c77 ENUM('a','b','c')); +INSERT INTO t1 VALUES ('b'); +DELETE FROM t1 WHERE c77='b'; +DROP TABLE t1; + +# + +CREATE TABLE t1 (c78 SET('a','b','c','d','e','f')); +INSERT INTO t1 VALUES ('a,b'); +INSERT INTO t1 VALUES ('a,c'); +INSERT INTO t1 VALUES ('b,c'); +INSERT INTO t1 VALUES ('a,b,c'); +INSERT INTO t1 VALUES ('a,b,c,d'); +INSERT INTO t1 VALUES ('a,b,c,d,e'); +INSERT INTO t1 VALUES ('a,b,c,d,e,f'); +DELETE FROM t1 WHERE c78='a,b'; +DROP TABLE t1; + +# +# Check multi-table update +# +CREATE TABLE t1 (a int NOT NULL DEFAULT 0, b int NOT NULL DEFAULT 0); +CREATE TABLE t2 (a int NOT NULL DEFAULT 0, b int NOT NULL DEFAULT 0); +INSERT INTO t1 SET a=1; +INSERT INTO t1 SET b=1; +INSERT INTO t2 SET a=1; +INSERT INTO t2 SET b=1; +UPDATE t1, t2 SET t1.a=10, t2.a=20; +DROP TABLE t1,t2; + +flush logs; + +let $MYSQLD_DATADIR= `select @@datadir`; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9]*[.][0-9]{1,3})[0-9e+-]*[^ ]*(.*(FLOAT|DOUBLE).*[*].)/\1...\2/ +--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001 diff --git a/mysql-test/t/mysqlbinlog_row_big.test b/mysql-test/t/mysqlbinlog_row_big.test new file mode 100644 index 00000000000..75f3b90269f --- /dev/null +++ b/mysql-test/t/mysqlbinlog_row_big.test @@ -0,0 +1,152 @@ +# mysqlbinlog_big.test +# +# Show that mysqlbinlog can handle big rows. +# + +# +# The *huge* output of mysqlbinlog will be redirected to +# $MYSQLTEST_VARDIR/$mysqlbinlog_output +# +--let $mysqlbinlog_output= tmp/mysqlbinlog_big_1.out + +#--source include/have_myisam.inc +--let $engine_type= MyISAM + +# +# This test case is insensitive to the binlog format +# because we don't display the output of mysqlbinlog. +# +#--source include/have_binlog_format_row.inc + +--source include/have_log_bin.inc + +# This is a big test. +--source include/big_test.inc + +--echo # +--echo # Preparatory cleanup. +--echo # +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo # +--echo # We need a fixed timestamp to avoid varying results. +--echo # +SET timestamp=1000000000; + +--echo # +--echo # We need big packets. +--echo # +--echo # Capture initial value to reset at the end of the test +# use let $<var> = query_get_value as FLUSH statements +# in the test will set @<var> values to NULL +let $orig_max_allowed_packet = +query_get_value(SELECT @@global.max_allowed_packet, @@global.max_allowed_packet, 1); + +--echo # Now adjust max_allowed_packet +SET @@global.max_allowed_packet= 1024*1024*1024; + +--echo max_allowed_packet is a global variable. +--echo In order for the preceding change in max_allowed_packets' value +--echo to be seen and used, we must start a new connection. +--echo The change does not take effect with the current one. +--echo For simplicity, we just disconnect / reconnect connection default here. +--echo Disconnecting default connection... +disconnect default; +--echo Reconnecting default connection... +connect (default, localhost,root,,); +--echo default connection established, continuing with the test + +--echo # +--echo # Delete all existing binary logs. +--echo # +RESET MASTER; + +--echo # +--echo # Create a test table. +--echo # +eval CREATE TABLE t1 ( + c1 LONGTEXT + ) ENGINE=$engine_type DEFAULT CHARSET latin1; + +--echo # +--echo # Show how many rows are affected by each statement. +--echo # +--enable_info + +--echo # +--echo # Insert some big rows. +--echo # + +--echo 256MB +INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 16777216)); + +--echo 32MB +INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 2097152)); + +--echo 4MB +INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 262144)); + +--echo 512KB +INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 32768)); + +--echo # +--echo # Show what we have in the table. +--echo # Do not display the column value itself, just its length. +--echo # +--sorted_result +query_vertical SELECT LENGTH(c1) FROM t1; + +--echo # +--echo # Grow the rows by updating. +--echo # +UPDATE t1 SET c1 = CONCAT(c1, c1); + +--echo # +--echo # Show what we have in the table. +--echo # Do not display the column value itself, just its length. +--echo # +--sorted_result +query_vertical SELECT LENGTH(c1) FROM t1; + +--echo # +--echo # Delete the rows. +--echo # +DELETE FROM t1 WHERE c1 >= 'ManyMegaByteBlck'; + +--echo # +--echo # Hide how many rows are affected by each statement. +--echo # +--disable_info + +--echo # +--echo # Flush all log buffers to the log file. +--echo # +FLUSH LOGS; + +--echo # +--echo # Call mysqlbinlog to display the log file contents. +--echo # NOTE: The output of mysqlbinlog is redirected to +--echo # \$MYSQLTEST_VARDIR/$mysqlbinlog_output +--echo # If you want to examine it, disable remove_file +--echo # at the bottom of the test script. +--echo # +let $MYSQLD_DATADIR= `select @@datadir`; +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ +--exec $MYSQL_BINLOG -v -v $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/$mysqlbinlog_output + +--echo # +--echo # Cleanup. +--echo # +--echo # reset variable value to pass testcase checks +eval SET @@global.max_allowed_packet = $orig_max_allowed_packet; +DROP TABLE t1; + +--echo remove_file \$MYSQLTEST_VARDIR/$mysqlbinlog_output +# +# NOTE: If you want to see the *huge* mysqlbinlog output, disable next line: +# +--remove_file $MYSQLTEST_VARDIR/$mysqlbinlog_output + diff --git a/mysql-test/t/mysqlbinlog_row_innodb.test b/mysql-test/t/mysqlbinlog_row_innodb.test new file mode 100644 index 00000000000..cef1a712f7d --- /dev/null +++ b/mysql-test/t/mysqlbinlog_row_innodb.test @@ -0,0 +1,24 @@ +# mysqlbinlog_row_innodb.test +# +# Show that mysqlbinlog displays human readable comments to +# row-based log events. +# +# Main module for the InnoDB storage engine. +# +# Calls include/mysqlbinlog_row.inc +# See there for more informaton. +# + +--source include/have_innodb.inc +let $engine_type=InnoDB; + +# +# The test case would also work with statement based or mixed mode logging. +# But this would require different result files. To handle this with the +# current test suite, new main test cases are required. +# +--source include/have_binlog_format_row.inc +--source include/have_ucs2.inc + +--source include/mysqlbinlog_row_engine.inc + diff --git a/mysql-test/t/mysqlbinlog_row_myisam.test b/mysql-test/t/mysqlbinlog_row_myisam.test new file mode 100644 index 00000000000..e7b0335812a --- /dev/null +++ b/mysql-test/t/mysqlbinlog_row_myisam.test @@ -0,0 +1,23 @@ +# mysqlbinlog_row.test +# +# Show that mysqlbinlog displays human readable comments to +# row-based log events. +# +# Main module for the MyISAM storage engine. +# +# Calls include/mysqlbinlog_row.inc +# See there for more informaton. +# + +#--source include/have_myisam.inc +let $engine_type=MyISAM; + +# +# The test case would also work with statement based or mixed mode logging. +# But this would require different result files. To handle this with the +# current test suite, new main test cases are required. +# +--source include/have_binlog_format_row.inc +--source include/have_ucs2.inc + +--source include/mysqlbinlog_row_engine.inc diff --git a/mysql-test/t/mysqlbinlog_row_trans.test b/mysql-test/t/mysqlbinlog_row_trans.test new file mode 100644 index 00000000000..24abc441c4c --- /dev/null +++ b/mysql-test/t/mysqlbinlog_row_trans.test @@ -0,0 +1,161 @@ +# mysqlbinlog_trans.test +# +# Show that mysqlbinlog work correctly with transactions. +# + +#--source include/have_myisam.inc +--let $engine_type_nontrans= MyISAM +--source include/have_innodb.inc +--let $engine_type= InnoDB + +# +# The test case would also work with statement based or mixed mode logging. +# But this would require different result files. To handle this with the +# current test suite, new main test cases are required. +# +--source include/have_binlog_format_row.inc + +--source include/have_log_bin.inc + +--echo # +--echo # Preparatory cleanup. +--echo # +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +--echo # +--echo # We need a fixed timestamp to avoid varying results. +--echo # +SET timestamp=1000000000; + +--echo # +--echo # Delete all existing binary logs. +--echo # +RESET MASTER; + +--echo # +--echo # Create test tables. +--echo # +eval CREATE TABLE t1 ( + c1 INT, + c2 VARCHAR(20) + ) ENGINE=$engine_type DEFAULT CHARSET latin1; +eval CREATE TABLE t2 ( + c1 INT, + c2 VARCHAR(20) + ) ENGINE=$engine_type_nontrans DEFAULT CHARSET latin1; + +--echo # +--echo # Start transaction #1, transactional table only, commit. +--echo # +START TRANSACTION; + +--echo # +--echo # Do some statements. +--echo # +INSERT INTO t1 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3'); +UPDATE t1 SET c1 = c1 + 10; +DELETE FROM t1 WHERE c1 = 12; + +--echo # +--echo # Commit transaction. +--echo # +COMMIT; +SELECT * FROM t1; +TRUNCATE TABLE t1; + +--echo # +--echo # Start transaction #2, transactional table only, rollback. +--echo # +START TRANSACTION; + +--echo # +--echo # Do some statements. +--echo # +INSERT INTO t1 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3'); +UPDATE t1 SET c1 = c1 + 10; +DELETE FROM t1 WHERE c1 = 12; + +--echo # +--echo # Rollback transaction. +--echo # +ROLLBACK; +SELECT * FROM t1; +TRUNCATE TABLE t1; + +--echo # +--echo # Start transaction #3, both tables, commit. +--echo # +START TRANSACTION; + +--echo # +--echo # Do some statements on the transactional table. +--echo # +INSERT INTO t1 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3'); +UPDATE t1 SET c1 = c1 + 10; +DELETE FROM t1 WHERE c1 = 12; + +--echo # +--echo # Do some statements on the non-transactional table. +--echo # +INSERT INTO t2 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3'); +UPDATE t2 SET c1 = c1 + 10; +DELETE FROM t2 WHERE c1 = 12; + +--echo # +--echo # Commit transaction. +--echo # +COMMIT; +SELECT * FROM t1; +SELECT * FROM t2; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; + +--echo # +--echo # Start transaction #4, both tables, rollback. +--echo # +START TRANSACTION; + +--echo # +--echo # Do some statements on the transactional table. +--echo # +INSERT INTO t1 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3'); +UPDATE t1 SET c1 = c1 + 10; +DELETE FROM t1 WHERE c1 = 12; + +--echo # +--echo # Do some statements on the non-transactional table. +--echo # +INSERT INTO t2 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3'); +UPDATE t2 SET c1 = c1 + 10; +DELETE FROM t2 WHERE c1 = 12; + +--echo # +--echo # Rollback transaction. +--echo # +ROLLBACK; +SELECT * FROM t1; +SELECT * FROM t2; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; + +--echo # +--echo # Flush all log buffers to the log file. +--echo # +FLUSH LOGS; + +--echo # +--echo # Call mysqlbinlog to display the log file contents. +--echo # +let $MYSQLD_DATADIR= `select @@datadir`; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ +--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001 + +--echo # +--echo # Cleanup. +--echo # +DROP TABLE t1, t2; + + diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test index 3dbd17440d3..986b5aba385 100644 --- a/mysql-test/t/mysqlcheck.test +++ b/mysql-test/t/mysqlcheck.test @@ -1,3 +1,12 @@ + +# Embedded server doesn't support external clients +--source include/not_embedded.inc + +# check that CSV engine was compiled in, as the result of the test +# depends on the presence of the log tables (which are CSV-based). +--source include/have_csv.inc + +# # Clean up after previous tests # @@ -5,11 +14,11 @@ DROP TABLE IF EXISTS t1, `t``1`, `t 1`; drop view if exists v1; drop database if exists client_test_db; +# Repair any tables in mysql, sometimes the slow_log is marked as crashed +# after server has been killed +--exec $MYSQL_CHECK --repair --databases mysql > /dev/null 2>&1 --enable_warnings -# Embedded server doesn't support external clients ---source include/not_embedded.inc - # # Bug #13783 mysqlcheck tries to optimize and analyze information_schema # @@ -47,12 +56,20 @@ create database d_bug25347; use d_bug25347; create table t_bug25347 (a int); create view v_bug25347 as select * from t_bug25347; +insert into t_bug25347 values (1),(2),(3); flush tables; +let $MYSQLD_DATADIR= `select @@datadir`; --echo removing and creating ---remove_file $MYSQLTEST_VARDIR/master-data/d_bug25347/t_bug25347.MYI ---write_file $MYSQLTEST_VARDIR/master-data/d_bug25347/t_bug25347.MYI +--remove_file $MYSQLD_DATADIR/d_bug25347/t_bug25347.MYI +--write_file $MYSQLD_DATADIR/d_bug25347/t_bug25347.MYI EOF ---exec $MYSQL_CHECK --repair --databases --use-frm d_bug25347 +--exec $MYSQL_CHECK --repair --databases d_bug25347 +--error 130 +insert into t_bug25347 values (4),(5),(6); +--exec $MYSQL_CHECK --repair --use-frm --databases d_bug25347 +insert into t_bug25347 values (7),(8),(9); +select * from t_bug25347; +select * from v_bug25347; drop view v_bug25347; drop table t_bug25347; drop database d_bug25347; @@ -65,7 +82,6 @@ create view v1 as select * from information_schema.routines; check table v1, information_schema.routines; drop view v1; - # # Bug#37527: mysqlcheck fails to report entire database # when frm file corruption @@ -73,16 +89,126 @@ drop view v1; CREATE TABLE t1(a INT); CREATE TABLE t2(a INT); # backup then null t1.frm ---copy_file $MYSQLTEST_VARDIR/master-data/test/t1.frm $MYSQLTEST_VARDIR/master-data/test/t1.frm.bak ---remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm ---write_file $MYSQLTEST_VARDIR/master-data/test/t1.frm +--copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/t1.frm.bak +--remove_file $MYSQLD_DATADIR/test/t1.frm +--write_file $MYSQLD_DATADIR/test/t1.frm EOF --exec $MYSQL_CHECK test # restore t1.frm ---remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm ---copy_file $MYSQLTEST_VARDIR/master-data/test/t1.frm.bak $MYSQLTEST_VARDIR/master-data/test/t1.frm ---remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm.bak +--remove_file $MYSQLD_DATADIR/test/t1.frm +--copy_file $MYSQLD_DATADIR/test/t1.frm.bak $MYSQLD_DATADIR/test/t1.frm +--remove_file $MYSQLD_DATADIR/test/t1.frm.bak DROP TABLE t1, t2; --echo End of 5.0 tests + + +# +# Bug #30679: 5.1 name encoding not performed for views during upgrade +# +create table t1(a int); +create view v1 as select * from t1; +show tables; +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file $MYSQLD_DATADIR/test/v1.frm $MYSQLD_DATADIR/test/v-1.frm +show tables; +--exec $MYSQL_CHECK --check-upgrade --fix-table-names --databases test +show tables; +drop view v1, `v-1`; +drop table t1; + + +# +# Bug #33094: Error in upgrading from 5.0 to 5.1 when table contains triggers +# Bug #41385: Crash when attempting to repair a #mysql50# upgraded table with +# triggers +# +SET NAMES utf8; +CREATE TABLE `#mysql50#@` (a INT); +SHOW TABLES; +SET NAMES DEFAULT; +--echo mysqlcheck --fix-table-names --databases test +--exec $MYSQL_CHECK --fix-table-names --databases test +SET NAMES utf8; +SHOW TABLES; +DROP TABLE `@`; + +CREATE TABLE `я` (a INT); +SET NAMES DEFAULT; +--echo mysqlcheck --default-character-set="latin1" --databases test +# Error returned depends on platform, replace it with "Table doesn't exist" +--replace_result "Can't find file: './test/@003f.frm' (errno: 22)" "Table doesn't exist" "Table 'test.?' doesn't exist" "Table doesn't exist" +--exec $MYSQL_CHECK --default-character-set="latin1" --databases test +--echo mysqlcheck --default-character-set="utf8" --databases test +--exec $MYSQL_CHECK --default-character-set="utf8" --databases test +SET NAMES utf8; +DROP TABLE `я`; +SET NAMES DEFAULT; + +CREATE DATABASE `#mysql50#a@b`; +USE `#mysql50#a@b`; +CREATE TABLE `#mysql50#c@d` (a INT); +CREATE TABLE t1 (a INT); + +# Create 5.0 like triggers +let $MYSQLTEST_VARDIR= `select @@datadir`; +--write_file $MYSQLTEST_VARDIR/a@b/c@d.TRG +TYPE=TRIGGERS +triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON `c@d` FOR EACH ROW SET NEW.a = 10 * NEW.a' +sql_modes=0 +definers='root@localhost' +EOF +--write_file $MYSQLTEST_VARDIR/a@b/tr1.TRN +TYPE=TRIGGERNAME +trigger_table=c@d +EOF +--write_file $MYSQLTEST_VARDIR/a@b/t1.TRG +TYPE=TRIGGERS +triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr2 BEFORE INSERT ON `a@b`.t1 FOR EACH ROW SET NEW.a = 100 * NEW.a' +sql_modes=0 +definers='root@localhost' +EOF +--write_file $MYSQLTEST_VARDIR/a@b/tr2.TRN +TYPE=TRIGGERNAME +trigger_table=t1 +EOF + +SELECT * FROM INFORMATION_SCHEMA.TRIGGERS + WHERE TRIGGER_SCHEMA="#mysql50#a@b" ORDER BY trigger_name; + +--echo mysqlcheck --fix-db-names --fix-table-names --all-databases +--exec $MYSQL_CHECK --fix-db-names --fix-table-names --all-databases + +USE `a@b`; +SELECT * FROM INFORMATION_SCHEMA.TRIGGERS + WHERE TRIGGER_SCHEMA="a@b" ORDER BY trigger_name; + +INSERT INTO `c@d` VALUES (2), (1); +SELECT * FROM `c@d`; +INSERT INTO t1 VALUES (3), (5); +SELECT * FROM t1; + +DROP DATABASE `a@b`; + +USE test; + +--echo # +--echo # Bug #31821: --all-in-1 and --fix-table-names don't work together +--echo # + +--disable_warnings +drop table if exists `#mysql50#t1-1`; +--enable_warnings + +create table `#mysql50#t1-1` (a int); +--exec $MYSQL_CHECK --all-in-1 --fix-table-names --databases test +show tables like 't1-1'; +drop table `t1-1`; + +create table `#mysql50#t1-1` (a int); +--exec $MYSQL_CHECK --all-in-1 --fix-table-names test "#mysql50#t1-1" +show tables like 't1-1'; +drop table `t1-1`; + +--echo End of 5.1 tests diff --git a/mysql-test/t/mysqldump-max.test b/mysql-test/t/mysqldump-max.test index 359c4ea5793..1e8b9647503 100644 --- a/mysql-test/t/mysqldump-max.test +++ b/mysql-test/t/mysqldump-max.test @@ -66,3 +66,1061 @@ drop table t3; drop table t4; drop table t5; drop table t6; + + +# +# Bug#31434 - mysqldump dumps view as table +# + +# Show that mysqldump's stand-in tables for views are always of MyISAM +# type to avoid Inno's column-number limits (~1000 columns) etc. +# Here because it needs Inno-engine. + +SELECT @@global.storage_engine INTO @old_engine; +SET GLOBAL storage_engine=InnoDB; + +--disable_query_log +CREATE TABLE `t1` ( + `col_0` tinyint(1) default NULL, + `col_1` tinyint(1) default NULL, + `col_2` tinyint(1) default NULL, + `col_3` tinyint(1) default NULL, + `col_4` tinyint(1) default NULL, + `col_5` tinyint(1) default NULL, + `col_6` tinyint(1) default NULL, + `col_7` tinyint(1) default NULL, + `col_8` tinyint(1) default NULL, + `col_9` tinyint(1) default NULL, + `col_10` tinyint(1) default NULL, + `col_11` tinyint(1) default NULL, + `col_12` tinyint(1) default NULL, + `col_13` tinyint(1) default NULL, + `col_14` tinyint(1) default NULL, + `col_15` tinyint(1) default NULL, + `col_16` tinyint(1) default NULL, + `col_17` tinyint(1) default NULL, + `col_18` tinyint(1) default NULL, + `col_19` tinyint(1) default NULL, + `col_20` tinyint(1) default NULL, + `col_21` tinyint(1) default NULL, + `col_22` tinyint(1) default NULL, + `col_23` tinyint(1) default NULL, + `col_24` tinyint(1) default NULL, + `col_25` tinyint(1) default NULL, + `col_26` tinyint(1) default NULL, + `col_27` tinyint(1) default NULL, + `col_28` tinyint(1) default NULL, + `col_29` tinyint(1) default NULL, + `col_30` tinyint(1) default NULL, + `col_31` tinyint(1) default NULL, + `col_32` tinyint(1) default NULL, + `col_33` tinyint(1) default NULL, + `col_34` tinyint(1) default NULL, + `col_35` tinyint(1) default NULL, + `col_36` tinyint(1) default NULL, + `col_37` tinyint(1) default NULL, + `col_38` tinyint(1) default NULL, + `col_39` tinyint(1) default NULL, + `col_40` tinyint(1) default NULL, + `col_41` tinyint(1) default NULL, + `col_42` tinyint(1) default NULL, + `col_43` tinyint(1) default NULL, + `col_44` tinyint(1) default NULL, + `col_45` tinyint(1) default NULL, + `col_46` tinyint(1) default NULL, + `col_47` tinyint(1) default NULL, + `col_48` tinyint(1) default NULL, + `col_49` tinyint(1) default NULL, + `col_50` tinyint(1) default NULL, + `col_51` tinyint(1) default NULL, + `col_52` tinyint(1) default NULL, + `col_53` tinyint(1) default NULL, + `col_54` tinyint(1) default NULL, + `col_55` tinyint(1) default NULL, + `col_56` tinyint(1) default NULL, + `col_57` tinyint(1) default NULL, + `col_58` tinyint(1) default NULL, + `col_59` tinyint(1) default NULL, + `col_60` tinyint(1) default NULL, + `col_61` tinyint(1) default NULL, + `col_62` tinyint(1) default NULL, + `col_63` tinyint(1) default NULL, + `col_64` tinyint(1) default NULL, + `col_65` tinyint(1) default NULL, + `col_66` tinyint(1) default NULL, + `col_67` tinyint(1) default NULL, + `col_68` tinyint(1) default NULL, + `col_69` tinyint(1) default NULL, + `col_70` tinyint(1) default NULL, + `col_71` tinyint(1) default NULL, + `col_72` tinyint(1) default NULL, + `col_73` tinyint(1) default NULL, + `col_74` tinyint(1) default NULL, + `col_75` tinyint(1) default NULL, + `col_76` tinyint(1) default NULL, + `col_77` tinyint(1) default NULL, + `col_78` tinyint(1) default NULL, + `col_79` tinyint(1) default NULL, + `col_80` tinyint(1) default NULL, + `col_81` tinyint(1) default NULL, + `col_82` tinyint(1) default NULL, + `col_83` tinyint(1) default NULL, + `col_84` tinyint(1) default NULL, + `col_85` tinyint(1) default NULL, + `col_86` tinyint(1) default NULL, + `col_87` tinyint(1) default NULL, + `col_88` tinyint(1) default NULL, + `col_89` tinyint(1) default NULL, + `col_90` tinyint(1) default NULL, + `col_91` tinyint(1) default NULL, + `col_92` tinyint(1) default NULL, + `col_93` tinyint(1) default NULL, + `col_94` tinyint(1) default NULL, + `col_95` tinyint(1) default NULL, + `col_96` tinyint(1) default NULL, + `col_97` tinyint(1) default NULL, + `col_98` tinyint(1) default NULL, + `col_99` tinyint(1) default NULL, + `col_100` tinyint(1) default NULL, + `col_101` tinyint(1) default NULL, + `col_102` tinyint(1) default NULL, + `col_103` tinyint(1) default NULL, + `col_104` tinyint(1) default NULL, + `col_105` tinyint(1) default NULL, + `col_106` tinyint(1) default NULL, + `col_107` tinyint(1) default NULL, + `col_108` tinyint(1) default NULL, + `col_109` tinyint(1) default NULL, + `col_110` tinyint(1) default NULL, + `col_111` tinyint(1) default NULL, + `col_112` tinyint(1) default NULL, + `col_113` tinyint(1) default NULL, + `col_114` tinyint(1) default NULL, + `col_115` tinyint(1) default NULL, + `col_116` tinyint(1) default NULL, + `col_117` tinyint(1) default NULL, + `col_118` tinyint(1) default NULL, + `col_119` tinyint(1) default NULL, + `col_120` tinyint(1) default NULL, + `col_121` tinyint(1) default NULL, + `col_122` tinyint(1) default NULL, + `col_123` tinyint(1) default NULL, + `col_124` tinyint(1) default NULL, + `col_125` tinyint(1) default NULL, + `col_126` tinyint(1) default NULL, + `col_127` tinyint(1) default NULL, + `col_128` tinyint(1) default NULL, + `col_129` tinyint(1) default NULL, + `col_130` tinyint(1) default NULL, + `col_131` tinyint(1) default NULL, + `col_132` tinyint(1) default NULL, + `col_133` tinyint(1) default NULL, + `col_134` tinyint(1) default NULL, + `col_135` tinyint(1) default NULL, + `col_136` tinyint(1) default NULL, + `col_137` tinyint(1) default NULL, + `col_138` tinyint(1) default NULL, + `col_139` tinyint(1) default NULL, + `col_140` tinyint(1) default NULL, + `col_141` tinyint(1) default NULL, + `col_142` tinyint(1) default NULL, + `col_143` tinyint(1) default NULL, + `col_144` tinyint(1) default NULL, + `col_145` tinyint(1) default NULL, + `col_146` tinyint(1) default NULL, + `col_147` tinyint(1) default NULL, + `col_148` tinyint(1) default NULL, + `col_149` tinyint(1) default NULL, + `col_150` tinyint(1) default NULL, + `col_151` tinyint(1) default NULL, + `col_152` tinyint(1) default NULL, + `col_153` tinyint(1) default NULL, + `col_154` tinyint(1) default NULL, + `col_155` tinyint(1) default NULL, + `col_156` tinyint(1) default NULL, + `col_157` tinyint(1) default NULL, + `col_158` tinyint(1) default NULL, + `col_159` tinyint(1) default NULL, + `col_160` tinyint(1) default NULL, + `col_161` tinyint(1) default NULL, + `col_162` tinyint(1) default NULL, + `col_163` tinyint(1) default NULL, + `col_164` tinyint(1) default NULL, + `col_165` tinyint(1) default NULL, + `col_166` tinyint(1) default NULL, + `col_167` tinyint(1) default NULL, + `col_168` tinyint(1) default NULL, + `col_169` tinyint(1) default NULL, + `col_170` tinyint(1) default NULL, + `col_171` tinyint(1) default NULL, + `col_172` tinyint(1) default NULL, + `col_173` tinyint(1) default NULL, + `col_174` tinyint(1) default NULL, + `col_175` tinyint(1) default NULL, + `col_176` tinyint(1) default NULL, + `col_177` tinyint(1) default NULL, + `col_178` tinyint(1) default NULL, + `col_179` tinyint(1) default NULL, + `col_180` tinyint(1) default NULL, + `col_181` tinyint(1) default NULL, + `col_182` tinyint(1) default NULL, + `col_183` tinyint(1) default NULL, + `col_184` tinyint(1) default NULL, + `col_185` tinyint(1) default NULL, + `col_186` tinyint(1) default NULL, + `col_187` tinyint(1) default NULL, + `col_188` tinyint(1) default NULL, + `col_189` tinyint(1) default NULL, + `col_190` tinyint(1) default NULL, + `col_191` tinyint(1) default NULL, + `col_192` tinyint(1) default NULL, + `col_193` tinyint(1) default NULL, + `col_194` tinyint(1) default NULL, + `col_195` tinyint(1) default NULL, + `col_196` tinyint(1) default NULL, + `col_197` tinyint(1) default NULL, + `col_198` tinyint(1) default NULL, + `col_199` tinyint(1) default NULL, + `col_200` tinyint(1) default NULL, + `col_201` tinyint(1) default NULL, + `col_202` tinyint(1) default NULL, + `col_203` tinyint(1) default NULL, + `col_204` tinyint(1) default NULL, + `col_205` tinyint(1) default NULL, + `col_206` tinyint(1) default NULL, + `col_207` tinyint(1) default NULL, + `col_208` tinyint(1) default NULL, + `col_209` tinyint(1) default NULL, + `col_210` tinyint(1) default NULL, + `col_211` tinyint(1) default NULL, + `col_212` tinyint(1) default NULL, + `col_213` tinyint(1) default NULL, + `col_214` tinyint(1) default NULL, + `col_215` tinyint(1) default NULL, + `col_216` tinyint(1) default NULL, + `col_217` tinyint(1) default NULL, + `col_218` tinyint(1) default NULL, + `col_219` tinyint(1) default NULL, + `col_220` tinyint(1) default NULL, + `col_221` tinyint(1) default NULL, + `col_222` tinyint(1) default NULL, + `col_223` tinyint(1) default NULL, + `col_224` tinyint(1) default NULL, + `col_225` tinyint(1) default NULL, + `col_226` tinyint(1) default NULL, + `col_227` tinyint(1) default NULL, + `col_228` tinyint(1) default NULL, + `col_229` tinyint(1) default NULL, + `col_230` tinyint(1) default NULL, + `col_231` tinyint(1) default NULL, + `col_232` tinyint(1) default NULL, + `col_233` tinyint(1) default NULL, + `col_234` tinyint(1) default NULL, + `col_235` tinyint(1) default NULL, + `col_236` tinyint(1) default NULL, + `col_237` tinyint(1) default NULL, + `col_238` tinyint(1) default NULL, + `col_239` tinyint(1) default NULL, + `col_240` tinyint(1) default NULL, + `col_241` tinyint(1) default NULL, + `col_242` tinyint(1) default NULL, + `col_243` tinyint(1) default NULL, + `col_244` tinyint(1) default NULL, + `col_245` tinyint(1) default NULL, + `col_246` tinyint(1) default NULL, + `col_247` tinyint(1) default NULL, + `col_248` tinyint(1) default NULL, + `col_249` tinyint(1) default NULL, + `col_250` tinyint(1) default NULL, + `col_251` tinyint(1) default NULL, + `col_252` tinyint(1) default NULL, + `col_253` tinyint(1) default NULL, + `col_254` tinyint(1) default NULL, + `col_255` tinyint(1) default NULL, + `col_256` tinyint(1) default NULL, + `col_257` tinyint(1) default NULL, + `col_258` tinyint(1) default NULL, + `col_259` tinyint(1) default NULL, + `col_260` tinyint(1) default NULL, + `col_261` tinyint(1) default NULL, + `col_262` tinyint(1) default NULL, + `col_263` tinyint(1) default NULL, + `col_264` tinyint(1) default NULL, + `col_265` tinyint(1) default NULL, + `col_266` tinyint(1) default NULL, + `col_267` tinyint(1) default NULL, + `col_268` tinyint(1) default NULL, + `col_269` tinyint(1) default NULL, + `col_270` tinyint(1) default NULL, + `col_271` tinyint(1) default NULL, + `col_272` tinyint(1) default NULL, + `col_273` tinyint(1) default NULL, + `col_274` tinyint(1) default NULL, + `col_275` tinyint(1) default NULL, + `col_276` tinyint(1) default NULL, + `col_277` tinyint(1) default NULL, + `col_278` tinyint(1) default NULL, + `col_279` tinyint(1) default NULL, + `col_280` tinyint(1) default NULL, + `col_281` tinyint(1) default NULL, + `col_282` tinyint(1) default NULL, + `col_283` tinyint(1) default NULL, + `col_284` tinyint(1) default NULL, + `col_285` tinyint(1) default NULL, + `col_286` tinyint(1) default NULL, + `col_287` tinyint(1) default NULL, + `col_288` tinyint(1) default NULL, + `col_289` tinyint(1) default NULL, + `col_290` tinyint(1) default NULL, + `col_291` tinyint(1) default NULL, + `col_292` tinyint(1) default NULL, + `col_293` tinyint(1) default NULL, + `col_294` tinyint(1) default NULL, + `col_295` tinyint(1) default NULL, + `col_296` tinyint(1) default NULL, + `col_297` tinyint(1) default NULL, + `col_298` tinyint(1) default NULL, + `col_299` tinyint(1) default NULL, + `col_300` tinyint(1) default NULL, + `col_301` tinyint(1) default NULL, + `col_302` tinyint(1) default NULL, + `col_303` tinyint(1) default NULL, + `col_304` tinyint(1) default NULL, + `col_305` tinyint(1) default NULL, + `col_306` tinyint(1) default NULL, + `col_307` tinyint(1) default NULL, + `col_308` tinyint(1) default NULL, + `col_309` tinyint(1) default NULL, + `col_310` tinyint(1) default NULL, + `col_311` tinyint(1) default NULL, + `col_312` tinyint(1) default NULL, + `col_313` tinyint(1) default NULL, + `col_314` tinyint(1) default NULL, + `col_315` tinyint(1) default NULL, + `col_316` tinyint(1) default NULL, + `col_317` tinyint(1) default NULL, + `col_318` tinyint(1) default NULL, + `col_319` tinyint(1) default NULL, + `col_320` tinyint(1) default NULL, + `col_321` tinyint(1) default NULL, + `col_322` tinyint(1) default NULL, + `col_323` tinyint(1) default NULL, + `col_324` tinyint(1) default NULL, + `col_325` tinyint(1) default NULL, + `col_326` tinyint(1) default NULL, + `col_327` tinyint(1) default NULL, + `col_328` tinyint(1) default NULL, + `col_329` tinyint(1) default NULL, + `col_330` tinyint(1) default NULL, + `col_331` tinyint(1) default NULL, + `col_332` tinyint(1) default NULL, + `col_333` tinyint(1) default NULL, + `col_334` tinyint(1) default NULL, + `col_335` tinyint(1) default NULL, + `col_336` tinyint(1) default NULL, + `col_337` tinyint(1) default NULL, + `col_338` tinyint(1) default NULL, + `col_339` tinyint(1) default NULL, + `col_340` tinyint(1) default NULL, + `col_341` tinyint(1) default NULL, + `col_342` tinyint(1) default NULL, + `col_343` tinyint(1) default NULL, + `col_344` tinyint(1) default NULL, + `col_345` tinyint(1) default NULL, + `col_346` tinyint(1) default NULL, + `col_347` tinyint(1) default NULL, + `col_348` tinyint(1) default NULL, + `col_349` tinyint(1) default NULL, + `col_350` tinyint(1) default NULL, + `col_351` tinyint(1) default NULL, + `col_352` tinyint(1) default NULL, + `col_353` tinyint(1) default NULL, + `col_354` tinyint(1) default NULL, + `col_355` tinyint(1) default NULL, + `col_356` tinyint(1) default NULL, + `col_357` tinyint(1) default NULL, + `col_358` tinyint(1) default NULL, + `col_359` tinyint(1) default NULL, + `col_360` tinyint(1) default NULL, + `col_361` tinyint(1) default NULL, + `col_362` tinyint(1) default NULL, + `col_363` tinyint(1) default NULL, + `col_364` tinyint(1) default NULL, + `col_365` tinyint(1) default NULL, + `col_366` tinyint(1) default NULL, + `col_367` tinyint(1) default NULL, + `col_368` tinyint(1) default NULL, + `col_369` tinyint(1) default NULL, + `col_370` tinyint(1) default NULL, + `col_371` tinyint(1) default NULL, + `col_372` tinyint(1) default NULL, + `col_373` tinyint(1) default NULL, + `col_374` tinyint(1) default NULL, + `col_375` tinyint(1) default NULL, + `col_376` tinyint(1) default NULL, + `col_377` tinyint(1) default NULL, + `col_378` tinyint(1) default NULL, + `col_379` tinyint(1) default NULL, + `col_380` tinyint(1) default NULL, + `col_381` tinyint(1) default NULL, + `col_382` tinyint(1) default NULL, + `col_383` tinyint(1) default NULL, + `col_384` tinyint(1) default NULL, + `col_385` tinyint(1) default NULL, + `col_386` tinyint(1) default NULL, + `col_387` tinyint(1) default NULL, + `col_388` tinyint(1) default NULL, + `col_389` tinyint(1) default NULL, + `col_390` tinyint(1) default NULL, + `col_391` tinyint(1) default NULL, + `col_392` tinyint(1) default NULL, + `col_393` tinyint(1) default NULL, + `col_394` tinyint(1) default NULL, + `col_395` tinyint(1) default NULL, + `col_396` tinyint(1) default NULL, + `col_397` tinyint(1) default NULL, + `col_398` tinyint(1) default NULL, + `col_399` tinyint(1) default NULL, + `col_400` tinyint(1) default NULL, + `col_401` tinyint(1) default NULL, + `col_402` tinyint(1) default NULL, + `col_403` tinyint(1) default NULL, + `col_404` tinyint(1) default NULL, + `col_405` tinyint(1) default NULL, + `col_406` tinyint(1) default NULL, + `col_407` tinyint(1) default NULL, + `col_408` tinyint(1) default NULL, + `col_409` tinyint(1) default NULL, + `col_410` tinyint(1) default NULL, + `col_411` tinyint(1) default NULL, + `col_412` tinyint(1) default NULL, + `col_413` tinyint(1) default NULL, + `col_414` tinyint(1) default NULL, + `col_415` tinyint(1) default NULL, + `col_416` tinyint(1) default NULL, + `col_417` tinyint(1) default NULL, + `col_418` tinyint(1) default NULL, + `col_419` tinyint(1) default NULL, + `col_420` tinyint(1) default NULL, + `col_421` tinyint(1) default NULL, + `col_422` tinyint(1) default NULL, + `col_423` tinyint(1) default NULL, + `col_424` tinyint(1) default NULL, + `col_425` tinyint(1) default NULL, + `col_426` tinyint(1) default NULL, + `col_427` tinyint(1) default NULL, + `col_428` tinyint(1) default NULL, + `col_429` tinyint(1) default NULL, + `col_430` tinyint(1) default NULL, + `col_431` tinyint(1) default NULL, + `col_432` tinyint(1) default NULL, + `col_433` tinyint(1) default NULL, + `col_434` tinyint(1) default NULL, + `col_435` tinyint(1) default NULL, + `col_436` tinyint(1) default NULL, + `col_437` tinyint(1) default NULL, + `col_438` tinyint(1) default NULL, + `col_439` tinyint(1) default NULL, + `col_440` tinyint(1) default NULL, + `col_441` tinyint(1) default NULL, + `col_442` tinyint(1) default NULL, + `col_443` tinyint(1) default NULL, + `col_444` tinyint(1) default NULL, + `col_445` tinyint(1) default NULL, + `col_446` tinyint(1) default NULL, + `col_447` tinyint(1) default NULL, + `col_448` tinyint(1) default NULL, + `col_449` tinyint(1) default NULL, + `col_450` tinyint(1) default NULL, + `col_451` tinyint(1) default NULL, + `col_452` tinyint(1) default NULL, + `col_453` tinyint(1) default NULL, + `col_454` tinyint(1) default NULL, + `col_455` tinyint(1) default NULL, + `col_456` tinyint(1) default NULL, + `col_457` tinyint(1) default NULL, + `col_458` tinyint(1) default NULL, + `col_459` tinyint(1) default NULL, + `col_460` tinyint(1) default NULL, + `col_461` tinyint(1) default NULL, + `col_462` tinyint(1) default NULL, + `col_463` tinyint(1) default NULL, + `col_464` tinyint(1) default NULL, + `col_465` tinyint(1) default NULL, + `col_466` tinyint(1) default NULL, + `col_467` tinyint(1) default NULL, + `col_468` tinyint(1) default NULL, + `col_469` tinyint(1) default NULL, + `col_470` tinyint(1) default NULL, + `col_471` tinyint(1) default NULL, + `col_472` tinyint(1) default NULL, + `col_473` tinyint(1) default NULL, + `col_474` tinyint(1) default NULL, + `col_475` tinyint(1) default NULL, + `col_476` tinyint(1) default NULL, + `col_477` tinyint(1) default NULL, + `col_478` tinyint(1) default NULL, + `col_479` tinyint(1) default NULL, + `col_480` tinyint(1) default NULL, + `col_481` tinyint(1) default NULL, + `col_482` tinyint(1) default NULL, + `col_483` tinyint(1) default NULL, + `col_484` tinyint(1) default NULL, + `col_485` tinyint(1) default NULL, + `col_486` tinyint(1) default NULL, + `col_487` tinyint(1) default NULL, + `col_488` tinyint(1) default NULL, + `col_489` tinyint(1) default NULL, + `col_490` tinyint(1) default NULL, + `col_491` tinyint(1) default NULL, + `col_492` tinyint(1) default NULL, + `col_493` tinyint(1) default NULL, + `col_494` tinyint(1) default NULL, + `col_495` tinyint(1) default NULL, + `col_496` tinyint(1) default NULL, + `col_497` tinyint(1) default NULL, + `col_498` tinyint(1) default NULL, + `col_499` tinyint(1) default NULL, + `col_500` tinyint(1) default NULL, + `col_501` tinyint(1) default NULL, + `col_502` tinyint(1) default NULL, + `col_503` tinyint(1) default NULL, + `col_504` tinyint(1) default NULL, + `col_505` tinyint(1) default NULL, + `col_506` tinyint(1) default NULL, + `col_507` tinyint(1) default NULL, + `col_508` tinyint(1) default NULL, + `col_509` tinyint(1) default NULL, + `col_510` tinyint(1) default NULL, + `col_511` tinyint(1) default NULL, + `col_512` tinyint(1) default NULL, + `col_513` tinyint(1) default NULL, + `col_514` tinyint(1) default NULL, + `col_515` tinyint(1) default NULL, + `col_516` tinyint(1) default NULL, + `col_517` tinyint(1) default NULL, + `col_518` tinyint(1) default NULL, + `col_519` tinyint(1) default NULL, + `col_520` tinyint(1) default NULL, + `col_521` tinyint(1) default NULL, + `col_522` tinyint(1) default NULL, + `col_523` tinyint(1) default NULL, + `col_524` tinyint(1) default NULL, + `col_525` tinyint(1) default NULL, + `col_526` tinyint(1) default NULL, + `col_527` tinyint(1) default NULL, + `col_528` tinyint(1) default NULL, + `col_529` tinyint(1) default NULL, + `col_530` tinyint(1) default NULL, + `col_531` tinyint(1) default NULL, + `col_532` tinyint(1) default NULL, + `col_533` tinyint(1) default NULL, + `col_534` tinyint(1) default NULL, + `col_535` tinyint(1) default NULL, + `col_536` tinyint(1) default NULL, + `col_537` tinyint(1) default NULL, + `col_538` tinyint(1) default NULL, + `col_539` tinyint(1) default NULL, + `col_540` tinyint(1) default NULL, + `col_541` tinyint(1) default NULL, + `col_542` tinyint(1) default NULL, + `col_543` tinyint(1) default NULL, + `col_544` tinyint(1) default NULL, + `col_545` tinyint(1) default NULL, + `col_546` tinyint(1) default NULL, + `col_547` tinyint(1) default NULL, + `col_548` tinyint(1) default NULL, + `col_549` tinyint(1) default NULL, + `col_550` tinyint(1) default NULL, + `col_551` tinyint(1) default NULL, + `col_552` tinyint(1) default NULL, + `col_553` tinyint(1) default NULL, + `col_554` tinyint(1) default NULL, + `col_555` tinyint(1) default NULL, + `col_556` tinyint(1) default NULL, + `col_557` tinyint(1) default NULL, + `col_558` tinyint(1) default NULL, + `col_559` tinyint(1) default NULL, + `col_560` tinyint(1) default NULL, + `col_561` tinyint(1) default NULL, + `col_562` tinyint(1) default NULL, + `col_563` tinyint(1) default NULL, + `col_564` tinyint(1) default NULL, + `col_565` tinyint(1) default NULL, + `col_566` tinyint(1) default NULL, + `col_567` tinyint(1) default NULL, + `col_568` tinyint(1) default NULL, + `col_569` tinyint(1) default NULL, + `col_570` tinyint(1) default NULL, + `col_571` tinyint(1) default NULL, + `col_572` tinyint(1) default NULL, + `col_573` tinyint(1) default NULL, + `col_574` tinyint(1) default NULL, + `col_575` tinyint(1) default NULL, + `col_576` tinyint(1) default NULL, + `col_577` tinyint(1) default NULL, + `col_578` tinyint(1) default NULL, + `col_579` tinyint(1) default NULL, + `col_580` tinyint(1) default NULL, + `col_581` tinyint(1) default NULL, + `col_582` tinyint(1) default NULL, + `col_583` tinyint(1) default NULL, + `col_584` tinyint(1) default NULL, + `col_585` tinyint(1) default NULL, + `col_586` tinyint(1) default NULL, + `col_587` tinyint(1) default NULL, + `col_588` tinyint(1) default NULL, + `col_589` tinyint(1) default NULL, + `col_590` tinyint(1) default NULL, + `col_591` tinyint(1) default NULL, + `col_592` tinyint(1) default NULL, + `col_593` tinyint(1) default NULL, + `col_594` tinyint(1) default NULL, + `col_595` tinyint(1) default NULL, + `col_596` tinyint(1) default NULL, + `col_597` tinyint(1) default NULL, + `col_598` tinyint(1) default NULL, + `col_599` tinyint(1) default NULL, + `col_600` tinyint(1) default NULL, + `col_601` tinyint(1) default NULL, + `col_602` tinyint(1) default NULL, + `col_603` tinyint(1) default NULL, + `col_604` tinyint(1) default NULL, + `col_605` tinyint(1) default NULL, + `col_606` tinyint(1) default NULL, + `col_607` tinyint(1) default NULL, + `col_608` tinyint(1) default NULL, + `col_609` tinyint(1) default NULL, + `col_610` tinyint(1) default NULL, + `col_611` tinyint(1) default NULL, + `col_612` tinyint(1) default NULL, + `col_613` tinyint(1) default NULL, + `col_614` tinyint(1) default NULL, + `col_615` tinyint(1) default NULL, + `col_616` tinyint(1) default NULL, + `col_617` tinyint(1) default NULL, + `col_618` tinyint(1) default NULL, + `col_619` tinyint(1) default NULL, + `col_620` tinyint(1) default NULL, + `col_621` tinyint(1) default NULL, + `col_622` tinyint(1) default NULL, + `col_623` tinyint(1) default NULL, + `col_624` tinyint(1) default NULL, + `col_625` tinyint(1) default NULL, + `col_626` tinyint(1) default NULL, + `col_627` tinyint(1) default NULL, + `col_628` tinyint(1) default NULL, + `col_629` tinyint(1) default NULL, + `col_630` tinyint(1) default NULL, + `col_631` tinyint(1) default NULL, + `col_632` tinyint(1) default NULL, + `col_633` tinyint(1) default NULL, + `col_634` tinyint(1) default NULL, + `col_635` tinyint(1) default NULL, + `col_636` tinyint(1) default NULL, + `col_637` tinyint(1) default NULL, + `col_638` tinyint(1) default NULL, + `col_639` tinyint(1) default NULL, + `col_640` tinyint(1) default NULL, + `col_641` tinyint(1) default NULL, + `col_642` tinyint(1) default NULL, + `col_643` tinyint(1) default NULL, + `col_644` tinyint(1) default NULL, + `col_645` tinyint(1) default NULL, + `col_646` tinyint(1) default NULL, + `col_647` tinyint(1) default NULL, + `col_648` tinyint(1) default NULL, + `col_649` tinyint(1) default NULL, + `col_650` tinyint(1) default NULL, + `col_651` tinyint(1) default NULL, + `col_652` tinyint(1) default NULL, + `col_653` tinyint(1) default NULL, + `col_654` tinyint(1) default NULL, + `col_655` tinyint(1) default NULL, + `col_656` tinyint(1) default NULL, + `col_657` tinyint(1) default NULL, + `col_658` tinyint(1) default NULL, + `col_659` tinyint(1) default NULL, + `col_660` tinyint(1) default NULL, + `col_661` tinyint(1) default NULL, + `col_662` tinyint(1) default NULL, + `col_663` tinyint(1) default NULL, + `col_664` tinyint(1) default NULL, + `col_665` tinyint(1) default NULL, + `col_666` tinyint(1) default NULL, + `col_667` tinyint(1) default NULL, + `col_668` tinyint(1) default NULL, + `col_669` tinyint(1) default NULL, + `col_670` tinyint(1) default NULL, + `col_671` tinyint(1) default NULL, + `col_672` tinyint(1) default NULL, + `col_673` tinyint(1) default NULL, + `col_674` tinyint(1) default NULL, + `col_675` tinyint(1) default NULL, + `col_676` tinyint(1) default NULL, + `col_677` tinyint(1) default NULL, + `col_678` tinyint(1) default NULL, + `col_679` tinyint(1) default NULL, + `col_680` tinyint(1) default NULL, + `col_681` tinyint(1) default NULL, + `col_682` tinyint(1) default NULL, + `col_683` tinyint(1) default NULL, + `col_684` tinyint(1) default NULL, + `col_685` tinyint(1) default NULL, + `col_686` tinyint(1) default NULL, + `col_687` tinyint(1) default NULL, + `col_688` tinyint(1) default NULL, + `col_689` tinyint(1) default NULL, + `col_690` tinyint(1) default NULL, + `col_691` tinyint(1) default NULL, + `col_692` tinyint(1) default NULL, + `col_693` tinyint(1) default NULL, + `col_694` tinyint(1) default NULL, + `col_695` tinyint(1) default NULL, + `col_696` tinyint(1) default NULL, + `col_697` tinyint(1) default NULL, + `col_698` tinyint(1) default NULL, + `col_699` tinyint(1) default NULL, + `col_700` tinyint(1) default NULL, + `col_701` tinyint(1) default NULL, + `col_702` tinyint(1) default NULL, + `col_703` tinyint(1) default NULL, + `col_704` tinyint(1) default NULL, + `col_705` tinyint(1) default NULL, + `col_706` tinyint(1) default NULL, + `col_707` tinyint(1) default NULL, + `col_708` tinyint(1) default NULL, + `col_709` tinyint(1) default NULL, + `col_710` tinyint(1) default NULL, + `col_711` tinyint(1) default NULL, + `col_712` tinyint(1) default NULL, + `col_713` tinyint(1) default NULL, + `col_714` tinyint(1) default NULL, + `col_715` tinyint(1) default NULL, + `col_716` tinyint(1) default NULL, + `col_717` tinyint(1) default NULL, + `col_718` tinyint(1) default NULL, + `col_719` tinyint(1) default NULL, + `col_720` tinyint(1) default NULL, + `col_721` tinyint(1) default NULL, + `col_722` tinyint(1) default NULL, + `col_723` tinyint(1) default NULL, + `col_724` tinyint(1) default NULL, + `col_725` tinyint(1) default NULL, + `col_726` tinyint(1) default NULL, + `col_727` tinyint(1) default NULL, + `col_728` tinyint(1) default NULL, + `col_729` tinyint(1) default NULL, + `col_730` tinyint(1) default NULL, + `col_731` tinyint(1) default NULL, + `col_732` tinyint(1) default NULL, + `col_733` tinyint(1) default NULL, + `col_734` tinyint(1) default NULL, + `col_735` tinyint(1) default NULL, + `col_736` tinyint(1) default NULL, + `col_737` tinyint(1) default NULL, + `col_738` tinyint(1) default NULL, + `col_739` tinyint(1) default NULL, + `col_740` tinyint(1) default NULL, + `col_741` tinyint(1) default NULL, + `col_742` tinyint(1) default NULL, + `col_743` tinyint(1) default NULL, + `col_744` tinyint(1) default NULL, + `col_745` tinyint(1) default NULL, + `col_746` tinyint(1) default NULL, + `col_747` tinyint(1) default NULL, + `col_748` tinyint(1) default NULL, + `col_749` tinyint(1) default NULL, + `col_750` tinyint(1) default NULL, + `col_751` tinyint(1) default NULL, + `col_752` tinyint(1) default NULL, + `col_753` tinyint(1) default NULL, + `col_754` tinyint(1) default NULL, + `col_755` tinyint(1) default NULL, + `col_756` tinyint(1) default NULL, + `col_757` tinyint(1) default NULL, + `col_758` tinyint(1) default NULL, + `col_759` tinyint(1) default NULL, + `col_760` tinyint(1) default NULL, + `col_761` tinyint(1) default NULL, + `col_762` tinyint(1) default NULL, + `col_763` tinyint(1) default NULL, + `col_764` tinyint(1) default NULL, + `col_765` tinyint(1) default NULL, + `col_766` tinyint(1) default NULL, + `col_767` tinyint(1) default NULL, + `col_768` tinyint(1) default NULL, + `col_769` tinyint(1) default NULL, + `col_770` tinyint(1) default NULL, + `col_771` tinyint(1) default NULL, + `col_772` tinyint(1) default NULL, + `col_773` tinyint(1) default NULL, + `col_774` tinyint(1) default NULL, + `col_775` tinyint(1) default NULL, + `col_776` tinyint(1) default NULL, + `col_777` tinyint(1) default NULL, + `col_778` tinyint(1) default NULL, + `col_779` tinyint(1) default NULL, + `col_780` tinyint(1) default NULL, + `col_781` tinyint(1) default NULL, + `col_782` tinyint(1) default NULL, + `col_783` tinyint(1) default NULL, + `col_784` tinyint(1) default NULL, + `col_785` tinyint(1) default NULL, + `col_786` tinyint(1) default NULL, + `col_787` tinyint(1) default NULL, + `col_788` tinyint(1) default NULL, + `col_789` tinyint(1) default NULL, + `col_790` tinyint(1) default NULL, + `col_791` tinyint(1) default NULL, + `col_792` tinyint(1) default NULL, + `col_793` tinyint(1) default NULL, + `col_794` tinyint(1) default NULL, + `col_795` tinyint(1) default NULL, + `col_796` tinyint(1) default NULL, + `col_797` tinyint(1) default NULL, + `col_798` tinyint(1) default NULL, + `col_799` tinyint(1) default NULL, + `col_800` tinyint(1) default NULL, + `col_801` tinyint(1) default NULL, + `col_802` tinyint(1) default NULL, + `col_803` tinyint(1) default NULL, + `col_804` tinyint(1) default NULL, + `col_805` tinyint(1) default NULL, + `col_806` tinyint(1) default NULL, + `col_807` tinyint(1) default NULL, + `col_808` tinyint(1) default NULL, + `col_809` tinyint(1) default NULL, + `col_810` tinyint(1) default NULL, + `col_811` tinyint(1) default NULL, + `col_812` tinyint(1) default NULL, + `col_813` tinyint(1) default NULL, + `col_814` tinyint(1) default NULL, + `col_815` tinyint(1) default NULL, + `col_816` tinyint(1) default NULL, + `col_817` tinyint(1) default NULL, + `col_818` tinyint(1) default NULL, + `col_819` tinyint(1) default NULL, + `col_820` tinyint(1) default NULL, + `col_821` tinyint(1) default NULL, + `col_822` tinyint(1) default NULL, + `col_823` tinyint(1) default NULL, + `col_824` tinyint(1) default NULL, + `col_825` tinyint(1) default NULL, + `col_826` tinyint(1) default NULL, + `col_827` tinyint(1) default NULL, + `col_828` tinyint(1) default NULL, + `col_829` tinyint(1) default NULL, + `col_830` tinyint(1) default NULL, + `col_831` tinyint(1) default NULL, + `col_832` tinyint(1) default NULL, + `col_833` tinyint(1) default NULL, + `col_834` tinyint(1) default NULL, + `col_835` tinyint(1) default NULL, + `col_836` tinyint(1) default NULL, + `col_837` tinyint(1) default NULL, + `col_838` tinyint(1) default NULL, + `col_839` tinyint(1) default NULL, + `col_840` tinyint(1) default NULL, + `col_841` tinyint(1) default NULL, + `col_842` tinyint(1) default NULL, + `col_843` tinyint(1) default NULL, + `col_844` tinyint(1) default NULL, + `col_845` tinyint(1) default NULL, + `col_846` tinyint(1) default NULL, + `col_847` tinyint(1) default NULL, + `col_848` tinyint(1) default NULL, + `col_849` tinyint(1) default NULL, + `col_850` tinyint(1) default NULL, + `col_851` tinyint(1) default NULL, + `col_852` tinyint(1) default NULL, + `col_853` tinyint(1) default NULL, + `col_854` tinyint(1) default NULL, + `col_855` tinyint(1) default NULL, + `col_856` tinyint(1) default NULL, + `col_857` tinyint(1) default NULL, + `col_858` tinyint(1) default NULL, + `col_859` tinyint(1) default NULL, + `col_860` tinyint(1) default NULL, + `col_861` tinyint(1) default NULL, + `col_862` tinyint(1) default NULL, + `col_863` tinyint(1) default NULL, + `col_864` tinyint(1) default NULL, + `col_865` tinyint(1) default NULL, + `col_866` tinyint(1) default NULL, + `col_867` tinyint(1) default NULL, + `col_868` tinyint(1) default NULL, + `col_869` tinyint(1) default NULL, + `col_870` tinyint(1) default NULL, + `col_871` tinyint(1) default NULL, + `col_872` tinyint(1) default NULL, + `col_873` tinyint(1) default NULL, + `col_874` tinyint(1) default NULL, + `col_875` tinyint(1) default NULL, + `col_876` tinyint(1) default NULL, + `col_877` tinyint(1) default NULL, + `col_878` tinyint(1) default NULL, + `col_879` tinyint(1) default NULL, + `col_880` tinyint(1) default NULL, + `col_881` tinyint(1) default NULL, + `col_882` tinyint(1) default NULL, + `col_883` tinyint(1) default NULL, + `col_884` tinyint(1) default NULL, + `col_885` tinyint(1) default NULL, + `col_886` tinyint(1) default NULL, + `col_887` tinyint(1) default NULL, + `col_888` tinyint(1) default NULL, + `col_889` tinyint(1) default NULL, + `col_890` tinyint(1) default NULL, + `col_891` tinyint(1) default NULL, + `col_892` tinyint(1) default NULL, + `col_893` tinyint(1) default NULL, + `col_894` tinyint(1) default NULL, + `col_895` tinyint(1) default NULL, + `col_896` tinyint(1) default NULL, + `col_897` tinyint(1) default NULL, + `col_898` tinyint(1) default NULL, + `col_899` tinyint(1) default NULL, + `col_900` tinyint(1) default NULL, + `col_901` tinyint(1) default NULL, + `col_902` tinyint(1) default NULL, + `col_903` tinyint(1) default NULL, + `col_904` tinyint(1) default NULL, + `col_905` tinyint(1) default NULL, + `col_906` tinyint(1) default NULL, + `col_907` tinyint(1) default NULL, + `col_908` tinyint(1) default NULL, + `col_909` tinyint(1) default NULL, + `col_910` tinyint(1) default NULL, + `col_911` tinyint(1) default NULL, + `col_912` tinyint(1) default NULL, + `col_913` tinyint(1) default NULL, + `col_914` tinyint(1) default NULL, + `col_915` tinyint(1) default NULL, + `col_916` tinyint(1) default NULL, + `col_917` tinyint(1) default NULL, + `col_918` tinyint(1) default NULL, + `col_919` tinyint(1) default NULL, + `col_920` tinyint(1) default NULL, + `col_921` tinyint(1) default NULL, + `col_922` tinyint(1) default NULL, + `col_923` tinyint(1) default NULL, + `col_924` tinyint(1) default NULL, + `col_925` tinyint(1) default NULL, + `col_926` tinyint(1) default NULL, + `col_927` tinyint(1) default NULL, + `col_928` tinyint(1) default NULL, + `col_929` tinyint(1) default NULL, + `col_930` tinyint(1) default NULL, + `col_931` tinyint(1) default NULL, + `col_932` tinyint(1) default NULL, + `col_933` tinyint(1) default NULL, + `col_934` tinyint(1) default NULL, + `col_935` tinyint(1) default NULL, + `col_936` tinyint(1) default NULL, + `col_937` tinyint(1) default NULL, + `col_938` tinyint(1) default NULL, + `col_939` tinyint(1) default NULL, + `col_940` tinyint(1) default NULL, + `col_941` tinyint(1) default NULL, + `col_942` tinyint(1) default NULL, + `col_943` tinyint(1) default NULL, + `col_944` tinyint(1) default NULL, + `col_945` tinyint(1) default NULL, + `col_946` tinyint(1) default NULL, + `col_947` tinyint(1) default NULL, + `col_948` tinyint(1) default NULL, + `col_949` tinyint(1) default NULL, + `col_950` tinyint(1) default NULL, + `col_951` tinyint(1) default NULL, + `col_952` tinyint(1) default NULL, + `col_953` tinyint(1) default NULL, + `col_954` tinyint(1) default NULL, + `col_955` tinyint(1) default NULL, + `col_956` tinyint(1) default NULL, + `col_957` tinyint(1) default NULL, + `col_958` tinyint(1) default NULL, + `col_959` tinyint(1) default NULL, + `col_960` tinyint(1) default NULL, + `col_961` tinyint(1) default NULL, + `col_962` tinyint(1) default NULL, + `col_963` tinyint(1) default NULL, + `col_964` tinyint(1) default NULL, + `col_965` tinyint(1) default NULL, + `col_966` tinyint(1) default NULL, + `col_967` tinyint(1) default NULL, + `col_968` tinyint(1) default NULL, + `col_969` tinyint(1) default NULL, + `col_970` tinyint(1) default NULL, + `col_971` tinyint(1) default NULL, + `col_972` tinyint(1) default NULL, + `col_973` tinyint(1) default NULL, + `col_974` tinyint(1) default NULL, + `col_975` tinyint(1) default NULL, + `col_976` tinyint(1) default NULL, + `col_977` tinyint(1) default NULL, + `col_978` tinyint(1) default NULL, + `col_979` tinyint(1) default NULL, + `col_980` tinyint(1) default NULL, + `col_981` tinyint(1) default NULL, + `col_982` tinyint(1) default NULL, + `col_983` tinyint(1) default NULL, + `col_984` tinyint(1) default NULL, + `col_985` tinyint(1) default NULL, + `col_986` tinyint(1) default NULL, + `col_987` tinyint(1) default NULL, + `col_988` tinyint(1) default NULL, + `col_989` tinyint(1) default NULL, + `col_990` tinyint(1) default NULL, + `col_991` tinyint(1) default NULL, + `col_992` tinyint(1) default NULL, + `col_993` tinyint(1) default NULL, + `col_994` tinyint(1) default NULL, + `col_995` tinyint(1) default NULL, + `col_996` tinyint(1) default NULL, + `col_997` tinyint(1) default NULL, + `col_998` tinyint(1) default NULL, + `col_999` tinyint(1) default NULL, + `col_1000` tinyint(1) default NULL, + `col_1001` tinyint(1) default NULL, + `col_1002` tinyint(1) default NULL, + `col_1003` tinyint(1) default NULL, + `col_1004` tinyint(1) default NULL, + `col_1005` tinyint(1) default NULL, + `col_1006` tinyint(1) default NULL, + `col_1007` tinyint(1) default NULL, + `col_1008` tinyint(1) default NULL, + `col_1009` tinyint(1) default NULL, + `col_1010` tinyint(1) default NULL, + `col_1011` tinyint(1) default NULL, + `col_1012` tinyint(1) default NULL, + `col_1013` tinyint(1) default NULL, + `col_1014` tinyint(1) default NULL, + `col_1015` tinyint(1) default NULL, + `col_1016` tinyint(1) default NULL, + `col_1017` tinyint(1) default NULL, + `col_1018` tinyint(1) default NULL, + `col_1019` tinyint(1) default NULL, + `col_1020` tinyint(1) default NULL, + `col_1021` tinyint(1) default NULL, + `col_1022` tinyint(1) default NULL, + `col_1023` tinyint(1) default NULL, + `col_1024` tinyint(1) default NULL, + `col_1025` tinyint(1) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +--enable_query_log +CREATE VIEW v1 AS SELECT * FROM t1; + +INSERT INTO t1 VALUES(); +SELECT COUNT(*) FROM v1; + +--exec $MYSQL_DUMP --allow-keywords --single-transaction --quick --verbose test --result-file $MYSQLTEST_VARDIR/tmp/bug31434.sql +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug31434.sql +--remove_file $MYSQLTEST_VARDIR/tmp/bug31434.sql + +SELECT COUNT(*) FROM v1; + +DROP VIEW v1; +DROP TABLE t1; + +SET GLOBAL storage_engine=@old_engine; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 1aceb113b65..07ab9cecd28 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -25,7 +25,7 @@ drop view if exists v1, v2, v3; # XML output -CREATE TABLE t1(a INT); +CREATE TABLE t1(a INT, KEY (a)) KEY_BLOCK_SIZE=1024; INSERT INTO t1 VALUES (1), (2); --exec $MYSQL_DUMP --skip-create --skip-comments -X test t1 DROP TABLE t1; @@ -1008,7 +1008,7 @@ CREATE FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11) RETURN a+b // CREATE PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT) BEGIN SELECT a+b INTO c; end // -create function bug9056_func2(f1 char binary) returns char binary +create function bug9056_func2(f1 char binary) returns char begin set f1= concat( 'hello', f1 ); return f1; @@ -1385,8 +1385,9 @@ grant RELOAD on *.* to mysqltest_1@localhost; grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; # Execute mysqldump, should now succeed ---replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=#/ +--disable_result_log --exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1 +--enable_result_log # Clean up drop table t1; @@ -1394,9 +1395,6 @@ drop user mysqltest_1@localhost; --echo # ---echo # Bug#21527 mysqldump incorrectly tries to LOCK TABLES on the ---echo # information_schema database. ---echo # --echo # Bug#21424 mysqldump failing to export/import views --echo # @@ -1462,6 +1460,13 @@ disconnect root; --remove_file $MYSQLTEST_VARDIR/tmp/bug21527.sql use test; +--echo # +--echo # Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the +--echo # information_schema database. +--echo # +--echo # Bug #33762: mysqldump can not dump INFORMATION_SCHEMA +--echo # +--exec $MYSQL_DUMP --compact --opt -d information_schema TABLES --echo # --echo # Bug#19745 mysqldump --xml produces invalid xml @@ -1491,8 +1496,11 @@ INSERT INTO t1 VALUES (1), (2); --exec $MYSQL_DUMP --tab=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test 2>&1 --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-terminated-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--error 2 --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-enclosed-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--error 2 --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-optionally-enclosed-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--error 2 --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-escaped-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test --exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --lines-terminated-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test @@ -1659,7 +1667,6 @@ create view db42635.v2 (c) as select * from db42635.t1; use test; drop database db42635; - --echo # --echo # Bug#33550 mysqldump 4.0 compatibility broken --echo # @@ -1677,12 +1684,458 @@ CREATE TABLE `כדשגכחךלדגכחשךדגחכךלדגכ` ( f1 INT ); DROP TABLE `כדשגכחךלדגכחשךדגחכךלדגכ`; SET NAMES latin1; -# We reset concurrent_inserts value to whatever it was at the start of the test -# This line must be executed _after_ all test cases. +--echo # +--echo # End of 5.0 tests +--echo # + +# Check new --replace option + +--disable_warnings +drop table if exists t1; +--enable_warnings + +CREATE TABLE t1(a int, b int); +INSERT INTO t1 VALUES (1,1); +INSERT INTO t1 VALUES (2,3); +INSERT INTO t1 VALUES (3,4), (4,5); +--exec $MYSQL_DUMP --replace --skip-comments test t1 +DROP TABLE t1; + +# +# Added for use-thread option +# + +create table t1 (a text , b text); +create table t2 (a text , b text); +insert t1 values ("Duck, Duck", "goose"); +insert t1 values ("Duck, Duck", "pidgeon"); +insert t2 values ("We the people", "in order to perform"); +insert t2 values ("a more perfect", "union"); +select * from t1; +select * from t2; +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ test +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t2.sql +# The first load tests the pausing code +--exec $MYSQL_IMPORT --use-threads=1 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt +# Now we test with multiple threads! +--exec $MYSQL_IMPORT --silent --use-threads=5 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt +select * from t1; +select * from t2; +# Now we test with multiple threads, but less threads than files. +create table words(a varchar(255)); +create table words2(b varchar(255)); +--exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data/words.dat $MYSQLTEST_VARDIR/std_data/words2.dat +select * from t1; +select * from t2; +select * from words; +select * from words2; + +# Drop table "words" and run with threads, should fail +drop table words; +--replace_regex /.*mysqlimport(\.exe)*/mysql-import/ +--error 1 +--exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data/words.dat $MYSQLTEST_VARDIR/std_data/words2.dat 2>&1 + +drop table t1; +drop table t2; + +drop table words2; + +--echo # +--echo # Bug#16853 mysqldump doesn't show events +--echo # + +create database first; +use first; +set time_zone = 'UTC'; + +## prove one works (with spaces and tabs on the end) +create event ee1 on schedule at '2035-12-31 20:01:23' do set @a=5; +show events; +show create event ee1; +--exec $MYSQL_DUMP --events first > $MYSQLTEST_VARDIR/tmp/bug16853-1.sql +drop database first; + +create database second; +use second; +--exec $MYSQL second < $MYSQLTEST_VARDIR/tmp/bug16853-1.sql +show events; +show create event ee1; +--remove_file $MYSQLTEST_VARDIR/tmp/bug16853-1.sql + +## prove three works (with spaces and tabs on the end) +# start with one from the previous restore +create event ee2 on schedule at '2018-12-31 21:01:23' do set @a=5; +create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5; +show events; +--exec $MYSQL_DUMP --events second > $MYSQLTEST_VARDIR/tmp/bug16853-2.sql +drop database second; + +create database third; +use third; +--exec $MYSQL third < $MYSQLTEST_VARDIR/tmp/bug16853-2.sql +show events; +drop database third; +--remove_file $MYSQLTEST_VARDIR/tmp/bug16853-2.sql + +# revert back to normal settings +set time_zone = 'SYSTEM'; +use test; + +--echo # +--echo # Bug#17201 Spurious 'DROP DATABASE' in output, +--echo # also confusion between tables and views. +--echo # Example code from Markus Popp +--echo # + +create database mysqldump_test_db; +use mysqldump_test_db; +create table t1 (id int); +create view v1 as select * from t1; +insert into t1 values (1232131); +insert into t1 values (4711); +insert into t1 values (3231); +insert into t1 values (0815); +--exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_test_db +drop view v1; +drop table t1; +drop database mysqldump_test_db; + +# +# Bug#26121 mysqldump includes LOCK TABLES general_log WRITE +# +--exec $MYSQL_DUMP --all-databases > $MYSQLTEST_VARDIR/tmp/bug26121.sql +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug26121.sql +--remove_file $MYSQLTEST_VARDIR/tmp/bug26121.sql + +########################################################################### + +--echo # +--echo # Bug#30027 mysqldump does not dump views properly. +--echo # + +--echo +--echo # Cleanup. + +--disable_warnings +DROP DATABASE IF EXISTS mysqldump_test_db; +--enable_warnings + +--echo +--echo # Create objects. + +CREATE DATABASE mysqldump_test_db; + +set names koi8r; + +CREATE VIEW mysqldump_test_db.v2 AS SELECT 1 AS 1; +CREATE VIEW mysqldump_test_db.v1 AS SELECT 1 FROM mysqldump_test_db.v2; + +set names latin1; + +--echo +--echo # Dump mysqldump_test_db to bug30027.sql. + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=latin1 --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30027.sql + +--echo +--echo # Drop mysqldump_test_db. + +DROP DATABASE mysqldump_test_db; + +--echo +--echo # Restore mysqldump_test_db from bug30027.sql. + +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug30027.sql + +--echo +--echo # Check the view. + +set names utf8; + +SHOW CREATE VIEW mysqldump_test_db.v1; +SHOW CREATE VIEW mysqldump_test_db.v2; + +set names latin1; + +--echo +--echo # Cleanup. + +DROP DATABASE mysqldump_test_db; +--remove_file $MYSQLTEST_VARDIR/tmp/bug30027.sql + +########################################################################### + +--echo # +--echo # Bug#29938 wrong behavior of mysqldump --skip-events +--echo # with --all-databases +--echo # + +TRUNCATE mysql.event; + +USE test; +CREATE event e29938 ON SCHEDULE AT '2035-12-31 20:01:23' DO SET @bug29938=29938; +SHOW EVENTS; +--exec $MYSQL_DUMP --skip-events --all-databases > $MYSQLTEST_VARDIR/tmp/bug29938.sql + +TRUNCATE mysql.event; +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29938.sql +SHOW EVENTS; +--remove_file $MYSQLTEST_VARDIR/tmp/bug29938.sql + + +--echo # +--echo # Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names +--echo # +create database `test-database`; +use `test-database`; +create table test (a int); +--exec $MYSQL_DUMP --compact --opt --quote-names test-database +drop database `test-database`; +use test; + +########################################################################### + +--echo +--echo # ----------------------------------------------------------------- +--echo # -- Bug#30217 Views: changes in metadata behaviour between 5.0 and 5.1. +--echo # ----------------------------------------------------------------- +--echo + +--disable_warnings +DROP DATABASE IF EXISTS mysqldump_test_db; +--enable_warnings + +CREATE DATABASE mysqldump_test_db; +use mysqldump_test_db; + +--echo + +CREATE VIEW v1(x, y) AS SELECT 'a', 'a'; + +--echo + +SELECT view_definition +FROM INFORMATION_SCHEMA.VIEWS +WHERE table_schema = 'mysqldump_test_db' AND table_name = 'v1'; + +--echo + +--echo ---> Dumping mysqldump_test_db to bug30217.sql +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30217.sql + +--echo + +DROP DATABASE mysqldump_test_db; +use test; + +--echo + +--echo ---> Restoring mysqldump_test_db... +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug30217.sql + +--echo + +SELECT view_definition +FROM INFORMATION_SCHEMA.VIEWS +WHERE table_schema = 'mysqldump_test_db' AND table_name = 'v1'; + +--echo + +DROP DATABASE mysqldump_test_db; +--remove_file $MYSQLTEST_VARDIR/tmp/bug30217.sql + +--echo +--echo # -- End of test case for Bug#32538. +--echo + +--echo # +--echo # Bug#37377 Incorrect DROP TABLE statement in dump of a VIEW using --tab +--echo # + +create table t1 (a int); +create view v1 as select a from t1; + +--exec $MYSQL_DUMP --skip-comments --tab=$MYSQLTEST_VARDIR/tmp/ test t1 v1 + +drop view v1; +drop table t1; + +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/v1.sql + +drop view v1; +drop table t1; + +--remove_file $MYSQLTEST_VARDIR/tmp/t1.sql +--remove_file $MYSQLTEST_VARDIR/tmp/t1.txt +--remove_file $MYSQLTEST_VARDIR/tmp/v1.sql + + +--echo # +--echo # Bug#28071 mysqlimport does not quote or escape table name +--echo # + +--disable_warnings +drop table if exists `load`; +--enable_warnings +create table `load` (a varchar(255)); + +--copy_file std_data/words.dat $MYSQLTEST_VARDIR/tmp/load.txt + +--exec $MYSQL_IMPORT --ignore test $MYSQLTEST_VARDIR/tmp/load.txt + +select count(*) from `load`; + +--remove_file $MYSQLTEST_VARDIR/tmp/load.txt + +drop table `load`; + +# We reset concurrent_inserts value to whatever it was at the start of the +# test This line must be executed _after_ all test cases. SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT; + +########################################################################### + +--echo +--echo Bug #34861 - mysqldump with --tab gives weird output for triggers. +--echo + +CREATE TABLE t1 (f1 INT); +CREATE TRIGGER tr1 BEFORE UPDATE ON t1 FOR EACH ROW SET @f1 = 1; +CREATE PROCEDURE pr1 () SELECT "Meow"; +CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO SELECT "Meow"; + +--echo +SHOW TRIGGERS; +SHOW EVENTS; +SELECT name,body FROM mysql.proc WHERE NAME = 'pr1'; + +--echo +--echo dump table; if anything goes to stdout, it ends up here: --------------- +--exec $MYSQL_DUMP --compact --routines --triggers --events --result-file=$MYSQLTEST_VARDIR/tmp/test_34861.sql --tab=$MYSQLTEST_VARDIR/tmp/ test + +--echo +--echo drop everything +DROP EVENT ev1; +DROP TRIGGER tr1; +DROP TABLE t1; +DROP PROCEDURE pr1; + +--echo +--echo reload table; this should restore table and trigger +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql +SHOW TRIGGERS; +SHOW EVENTS; +SELECT name,body FROM mysql.proc WHERE NAME = 'pr1'; + +--echo +--echo reload db; this should restore routines and events +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/test_34861.sql +SHOW TRIGGERS; +SHOW EVENTS; +SELECT name,body FROM mysql.proc WHERE NAME = 'pr1'; + +--echo +--echo cleanup +--remove_file $MYSQLTEST_VARDIR/tmp/t1.txt +--remove_file $MYSQLTEST_VARDIR/tmp/t1.sql +--remove_file $MYSQLTEST_VARDIR/tmp/test_34861.sql +--disable_warnings +DROP EVENT IF EXISTS ev1; +DROP PROCEDURE IF EXISTS pr1; +DROP TRIGGER IF EXISTS tr1; +DROP TABLE IF EXISTS t1; +--enable_warnings + +########################################################################### + --echo # ---echo # End of 5.0 tests +--echo # Bug #30946: mysqldump silently ignores --default-character-set +--echo # when used with --tab +--echo # +--echo # Also see outfile_loaddata.test +--echo # + +SET NAMES utf8; +CREATE TABLE t1 (a INT, b CHAR(10) CHARSET koi8r, c CHAR(10) CHARSET latin1); +CREATE TABLE t2 LIKE t1; +INSERT INTO t1 VALUES (1, 'ABC-АБВ', 'DEF-ÂÃÄ'), (2, NULL, NULL); + +--let $file=$MYSQLTEST_VARDIR/tmp/t1.txt + + +--echo # error on multi-character ENCLOSED/ESCAPED BY + +--error 2 +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-enclosed-by='12345' test t1 +--remove_file $file + +--error 2 +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-escaped-by='12345' test t1 +--remove_file $file + +--echo # default '--default-charset' (binary): + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --tab=$MYSQLTEST_VARDIR/tmp/ test t1 +--echo ################################################## +--cat_file $file +--echo ################################################## +TRUNCATE t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary +--remove_file $file +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; + + +--echo # utf8: + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=utf8 --tab=$MYSQLTEST_VARDIR/tmp/ test t1 +--echo ################################################## +--cat_file $file +--echo ################################################## +TRUNCATE t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET utf8 +--remove_file $file +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; + + +--echo # latin1 (data corruption is expected): + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=latin1 --tab=$MYSQLTEST_VARDIR/tmp/ test t1 +--echo ################################################## +--cat_file $file +--echo ################################################## +TRUNCATE t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET latin1 +--remove_file $file +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; + + +--echo # koi8r (data corruption is expected): + +--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=koi8r --tab=$MYSQLTEST_VARDIR/tmp/ test t1 +--echo ################################################## +--cat_file $file +--echo ################################################## +TRUNCATE t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET koi8r +--remove_file $file +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; + + +SET NAMES default; + +DROP TABLE t1, t2; + +########################################################################### +--echo # +--echo # End of 5.1 tests --echo # # Wait till we reached the initial number of concurrent sessions diff --git a/mysql-test/t/mysqlslap.test b/mysql-test/t/mysqlslap.test new file mode 100644 index 00000000000..28042f62fe6 --- /dev/null +++ b/mysql-test/t/mysqlslap.test @@ -0,0 +1,55 @@ +# Can't run test of external client with embedded server +--source include/not_embedded.inc +--source include/not_windows.inc + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql + +--exec $MYSQL_SLAP --only-print --iterations=20 --query="select * from t1" --create="CREATE TABLE t1 (id int, name varchar(64)); INSERT INTO t1 VALUES (1, 'This is a test')" --delimiter=";" +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --query="select * from t1" --create="CREATE TABLE t1 (id int, name varchar(64)); INSERT INTO t1 VALUES (1, 'This is a test')" --delimiter=";" + +--exec $MYSQL_SLAP --only-print --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')" --engine="heap,myisam" + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')" + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --create-schema=test_env + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --create-schema=test_env --auto-generate-sql-add-autoincrement + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=update + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=read + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=write + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --auto-generate-sql-load-type=update + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --auto-generate-sql-load-type=update --auto-generate-sql-execute-number=5 + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --auto-generate-sql-load-type=key --auto-generate-sql-execute-number=5 + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --auto-generate-sql-load-type=key --auto-generate-sql-execute-number=5 --auto-generate-sql-secondary-indexes=3 + +--exec $MYSQL_SLAP --only-print --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')" --engine="heap,myisam" --post-query="SHOW TABLES" --pre-query="SHOW TABLES"; + + --exec $MYSQL_SLAP --only-print --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')" --engine="heap,myisam" --post-query="SHOW TABLES" --pre-query="SHOW TABLES" --number-of-queries=6 --commit=1; + +--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=write --detach=2 + +--echo # +--echo # Bug #29985: mysqlslap -- improper handling of resultsets in SPROCs +--echo # + +--disable_warnings +DROP PROCEDURE IF EXISTS p1; +--enable_warnings +CREATE PROCEDURE p1() SELECT 1; + +--exec $MYSQL_SLAP --create-schema=test --delimiter=";" --query="CALL p1; SELECT 1;" --silent 2>&1 + +DROP PROCEDURE p1; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 0c104a4a6b3..bcf33aa8c27 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -95,6 +95,10 @@ select otto from (select 1 as otto) as t1; --error 1 --exec echo "error S42S22; select otto from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1 +# expecting a SQL-state for a command that can't give one should fail +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--error 1 +--exec echo "error S00000; remove_file $MYSQLTEST_VARDIR/tmp/test_nonexistent.tmp;" | $MYSQL_TEST 2>&1 # ---------------------------------------------------------------------------- @@ -706,7 +710,7 @@ echo Not a banana: $cat; --error 1 --exec echo "let hi;" | $MYSQL_TEST 2>&1 -# More advanced test for bug#17280 +# More advanced test for Bug#17280 let $success= 1; --echo # Execute: --echo # <whatever> success: \$success --echo # <whatever> success: $success @@ -849,16 +853,21 @@ while ($outer) eval SELECT '$outer = outer loop variable after dec' AS ""; } +# Test source in an if in a while which is false on 1st iteration +# Also test --error in same context let $outer= 2; # Number of outer loops +let $ifval= 0; # false 1st time while ($outer) { - eval SELECT '$outer = outer loop variable after while' AS ""; - - echo here is the sourced script; + echo outer=$outer ifval=$ifval; - eval SELECT '$outer = outer loop variable before dec' AS ""; + if ($ifval) { + --source $MYSQLTEST_VARDIR/tmp/sourced.inc + --error ER_NO_SUCH_TABLE + SELECT * from nowhere; + } dec $outer; - eval SELECT '$outer = outer loop variable after dec' AS ""; + inc $ifval; } @@ -1250,7 +1259,7 @@ select "a" as col1, "c" as col2; --exec echo "replace_result a;" | $MYSQL_TEST 2>&1 --error 1 --exec echo "replace_result a ;" | $MYSQL_TEST 2>&1 ---exec echo "replace_result a b; echo OK;" | $MYSQL_TEST 2>&1 +--exec echo "replace_result a b; echo OK; exit;" | $MYSQL_TEST 2>&1 --error 1 --exec echo "--replace_result a b c" | $MYSQL_TEST 2>&1 --error 1 @@ -1314,7 +1323,7 @@ while ($i) dec $i; } EOF ---exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK;" | $MYSQL_TEST 2>&1 +--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK; exit;" | $MYSQL_TEST 2>&1 remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; # Repeat connect/disconnect @@ -1390,7 +1399,7 @@ connection default; # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Test bug#12386 +# Test Bug#12386 # ---------------------------------------------------------------------------- let $num= 2; while ($num) @@ -1406,7 +1415,7 @@ SELECT 1 as a; # -# Bug #10251: Identifiers containing quotes not handled correctly +# Bug#10251 Identifiers containing quotes not handled correctly # select 1 as `a'b`, 2 as `a"b`; @@ -1464,6 +1473,8 @@ remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result; --error 0,1 remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.reject; --error 0,1 +remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.log; +--error 0,1 remove_file $MYSQL_TEST_DIR/r/zero_length_file.reject; # @@ -1486,8 +1497,8 @@ remove_file $MYSQLTEST_VARDIR/tmp/query.sql; #--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/result_file.result 2>&1 # -# Bug #11731 mysqltest in multi-statement queries ignores errors in -# non-1st queries +# Bug#11731 mysqltest in multi-statement queries ignores errors in +# non-1st queries # echo Failing multi statement query; @@ -1523,6 +1534,7 @@ echo Multi statement using expected error; --exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql --exec echo "insertz "error query"||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql --exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "exit;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql # These two should work since the error is expected --exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1 @@ -1537,7 +1549,7 @@ remove_file $MYSQLTEST_VARDIR/log/bug11731.log; remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql; # -# Bug#19890 mysqltest: "query" command is broken +# Bug#19890 mysqltest "query" command is broken # # It should be possible to use the command "query" to force mysqltest to @@ -1656,6 +1668,20 @@ EOF remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; +# Test append_file within while +let $outer= 2; # Number of outer loops +while ($outer) +{ + append_file $MYSQLTEST_VARDIR/tmp/app_while.tmp; +These lines should be repeated, +if things work as expected +EOF + dec $outer; +} + +cat_file $MYSQLTEST_VARDIR/tmp/app_while.tmp; +remove_file $MYSQLTEST_VARDIR/tmp/app_while.tmp; + # ---------------------------------------------------------------------------- # test for cat_file # ---------------------------------------------------------------------------- @@ -1703,10 +1729,6 @@ EOF --diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp --diff_files $MYSQLTEST_VARDIR/tmp/diff2.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp -# Write the below commands to a intermediary file and execute them with -# mysqltest in --exec, since the output will vary depending on what "diff" -# is available it is sent to /dev/null ---write_file $MYSQLTEST_VARDIR/tmp/diff.test # Compare files that differ in size --error 2 --diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff3.tmp @@ -1718,12 +1740,6 @@ EOF --diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff4.tmp --error 1 --diff_files $MYSQLTEST_VARDIR/tmp/diff4.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp -EOF - -# Execute the above diffs, and send their output to /dev/null - only -# interesting to see that it returns correct error codes ---exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/diff.test > /dev/null 2>&1 - # Compare equal files, again... --diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp @@ -1732,7 +1748,6 @@ EOF --remove_file $MYSQLTEST_VARDIR/tmp/diff2.tmp --remove_file $MYSQLTEST_VARDIR/tmp/diff3.tmp --remove_file $MYSQLTEST_VARDIR/tmp/diff4.tmp ---remove_file $MYSQLTEST_VARDIR/tmp/diff.test # ---------------------------------------------------------------------------- @@ -1772,6 +1787,56 @@ remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp; --error 1 --exec echo "copy_file from_file;" | $MYSQL_TEST 2>&1 + +# ---------------------------------------------------------------------------- +# test for move_file +# ---------------------------------------------------------------------------- + +# - Check that if source file does not exist, nothing will be created. + +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; +--error 1 +move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp; +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; + +# - Check that if source file exists, everything works properly. + +--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +file1 +EOF + +move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp; +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; +file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; + +# - Check that if destination file exists, everything works properly. +# (file2.tmp exists from the previous check; file1.tmp needs to be created) + +--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +file1 +EOF + +move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp; +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; +file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; +remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp; + +# - Check usage. + +--error 1 +--exec echo "move_file ;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "move_file from_file;" | $MYSQL_TEST 2>&1 + # ---------------------------------------------------------------------------- # test for chmod # ---------------------------------------------------------------------------- @@ -2029,6 +2094,10 @@ let $value= query_get_value(SELECT 'A B' AS "MyColumn", MyColumn, 1); let $value= query_get_value(SELECT 1 AS "My Column", My Column, 1); --echo value= $value # +# 4.1 Query containing , protected by quotes, quotes also on column +let $value= query_get_value('SELECT 1 as a, 2 as b', "b", 1); +--echo value= $value +# #------------ Negative tests ------------ # 5. Incomplete statement including missing parameters # 5.1 incomplete statement @@ -2148,14 +2217,105 @@ mkdir $MYSQLTEST_VARDIR/tmp/testdir; write_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt; hello EOF + +list_files $MYSQLTEST_VARDIR/tmp/testdir; +# list_files gets the directory list before creating the new file +list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir *; +list_files_append_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir *2*; +list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir file?.txt; +list_files_append_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt $MYSQLTEST_VARDIR/tmp/testdir file*.txt; +diff_files $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir/file3.txt; --error 1 rmdir $MYSQLTEST_VARDIR/tmp/testdir; +cat_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt; + remove_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt; +remove_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt; +remove_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt; rmdir $MYSQLTEST_VARDIR/tmp/testdir; +# +# Bug#36041 mysql-test-run doesn't seem to string match 100% effectively +# on Windows +# + +--replace_result c:\\a.txt z +SELECT 'c:\\a.txt' AS col; + +# +# Bug#32307 mysqltest - does not detect illegal if syntax +# + +let $test= 1; +if ($test){ + echo hej; +} + +--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql +if ($mysql_errno != 1436) +{ + echo ^ Should not be allowed! +} +EOF +--error 1 +--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 +remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; + + +# ---------------------------------------------------------------------------- +# Test that -- is not allowed as comment, only as mysqltest builtin command +# ---------------------------------------------------------------------------- + +# valid +select 1; +--query select 1 +--query -- a comment for the server + +# Not valid, "select" is not a mysqltest command +--error 1 +--exec echo "--select 1;" | $MYSQL_TEST 2>&1 + + +# ---------------------------------------------------------------------------- +# BUG#35701 please allow test language variables in connection and sync_slave_with_master +# Test that "connection $variable" works and that $CURRENT_CONNECTION has the right value. +# ---------------------------------------------------------------------------- + +connect (con1,localhost,root,,); +--echo $CURRENT_CONNECTION +connect (con2,localhost,root,,); +--echo $CURRENT_CONNECTION + +connection default; +--echo $CURRENT_CONNECTION + +connection con1; +--echo $CURRENT_CONNECTION + +connection con2; +--echo $CURRENT_CONNECTION + +let $x= con1; +let $y= con2; + +connection $x; +--echo $CURRENT_CONNECTION + +connection $y; +--echo $CURRENT_CONNECTION + +# Disconnect the not selected connection +disconnect $x; +--echo $CURRENT_CONNECTION + +# Disconnect the selected connection +disconnect $y; +--echo $CURRENT_CONNECTION + --echo End of tests +connection default; # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test deleted file mode 100644 index 957b95c6fd9..00000000000 --- a/mysql-test/t/ndb_alter_table.test +++ /dev/null @@ -1,345 +0,0 @@ --- source include/have_ndb.inc --- source include/have_multi_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1, t2; -drop database if exists mysqltest; ---enable_warnings - -connect (con1,localhost,root,,test); -connect (con2,localhost,root,,test); - -connection con2; --- sleep 2 -connection con1; - -# -# Basic test to show that the ALTER TABLE -# is working -# -CREATE TABLE t1 ( - a INT NOT NULL, - b INT NOT NULL -) ENGINE=ndbcluster; - -INSERT INTO t1 VALUES (9410,9412); - -ALTER TABLE t1 ADD COLUMN c int not null; -SELECT * FROM t1; - -DROP TABLE t1; - -# -# Verfify changing table names between databases -# -CREATE DATABASE mysqltest; -USE mysqltest; -CREATE TABLE t1 ( - a INT NOT NULL, - b INT NOT NULL -) ENGINE=ndbcluster; -RENAME TABLE t1 TO test.t1; -SHOW TABLES; -DROP DATABASE mysqltest; -USE test; -SHOW TABLES; -DROP TABLE t1; - -# -# More advanced test -# -create table t1 ( -col1 int not null auto_increment primary key, -col2 varchar(30) not null, -col3 varchar (20) not null, -col4 varchar(4) not null, -col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, -col6 int not null, to_be_deleted int) ENGINE=ndbcluster; ---replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # -show table status; -SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; -insert into t1 values -(0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7); ---replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # -show table status; -select * from t1 order by col1; -alter table t1 -add column col4_5 varchar(20) not null after col4, -add column col7 varchar(30) not null after col5, -add column col8 datetime not null, drop column to_be_deleted, -change column col2 fourth varchar(30) not null after col3, -modify column col6 int not null first; ---replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # -show table status; -select * from t1 order by col1; -insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); ---replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # -show table status; -select * from t1 order by col1; -delete from t1; -insert into t1 values (0,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); -SET SQL_MODE=''; -insert into t1 values (1,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); -select * from t1 order by col1; -alter table t1 drop column col4_5; -insert into t1 values (2,0,4,3,5,"PENDING","EXTRA",'2004-01-01 00:00:00'); -select * from t1 order by col1; -drop table t1; - - -# -# Check that invalidating dictionary cache works -# - -CREATE TABLE t1 ( - a INT NOT NULL, - b INT NOT NULL -) ENGINE=ndbcluster; - -INSERT INTO t1 VALUES (9410,9412); - -ALTER TABLE t1 ADD COLUMN c int not null; -select * from t1 order by a; - -connection con2; -select * from t1 order by a; -alter table t1 drop c; - -connection con1; -select * from t1 order by a; -drop table t1; - -connection con2; ---error 1146 -select * from t1 order by a; - -CREATE TABLE t1 ( - a INT NOT NULL PRIMARY KEY, - b INT NOT NULL -) ENGINE=ndbcluster; - -INSERT INTO t1 VALUES (0,1),(17,18); -select * from t1 order by a; -SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; -alter table t1 modify column a int not null auto_increment; -SET SQL_MODE=''; -select * from t1 order by a; -INSERT INTO t1 VALUES (0,19),(20,21); -select * from t1 order by a; -drop table t1; - -CREATE TABLE t1 ( - a INT NOT NULL PRIMARY KEY, - b INT NOT NULL -) ENGINE=ndbcluster; - -INSERT INTO t1 VALUES (0,1),(17,18); -select * from t1 order by a; -alter table t1 add c int not null unique auto_increment; -select c from t1 order by c; -INSERT INTO t1 VALUES (1,2,0),(18,19,4),(20,21,0); -select c from t1 order by c; -drop table t1; - ---disable_ps_protocol -create table t1 ( a int primary key, b varchar(10), c varchar(10), index (b) ) -engine=ndb; -insert into t1 values (1,'one','one'), (2,'two','two'), (3,'three','three'); -create index c on t1(c); -connection server2; -select * from t1 where b = 'two'; -connection server1; -alter table t1 drop index c; -connection server2; -# This should fail since index information is not automatically refreshed ---error 1015 -select * from t1 where b = 'two'; -select * from t1 where b = 'two'; -connection server1; -drop table t1; ---enable_ps_protocol - -#--disable_warnings -#DROP TABLE IF EXISTS t2; -#--enable_warnings - -#create table t2 (a int NOT NULL PRIMARY KEY) engine=myisam; -#let $1=12001; -#disable_query_log; -#while ($1) -#{ -# eval insert into t2 values($1); -# dec $1; -#} -#enable_query_log; -#alter table t2 engine=ndbcluster; -#alter table t2 add c int; -#--error 1297 -#delete from t2; -#to make sure we do a full table scan -#select count(*) from t2 where a+0 > 0; -#truncate table t2; -#select count(*) from t2; -#drop table t2; - -connection server1; -create table t3 (a int primary key) engine=ndbcluster; - -connection server2; -begin; -insert into t3 values (1); - -connection server1; -alter table t3 rename t4; - -connection server2; -# This should work as transaction is ongoing... -delete from t3; -insert into t3 values (1); -commit; - -# This should fail as its a new transaction ---error 1015 -select * from t3; -select * from t4; -drop table t4; -show tables; -connection server1; - -create table t1 ( -ai bigint auto_increment, -c001 int(11) not null, -c002 int(11) not null, -c003 int(11) not null, -c004 int(11) not null, -c005 int(11) not null, -c006 int(11) not null, -c007 int(11) not null, -c008 int(11) not null, -c009 int(11) not null, -c010 int(11) not null, -c011 int(11) not null, -c012 int(11) not null, -c013 int(11) not null, -c014 int(11) not null, -c015 int(11) not null, -c016 int(11) not null, -c017 int(11) not null, -c018 int(11) not null, -c019 int(11) not null, -c020 int(11) not null, -c021 int(11) not null, -c022 int(11) not null, -c023 int(11) not null, -c024 int(11) not null, -c025 int(11) not null, -c026 int(11) not null, -c027 int(11) not null, -c028 int(11) not null, -c029 int(11) not null, -c030 int(11) not null, -c031 int(11) not null, -c032 int(11) not null, -c033 int(11) not null, -c034 int(11) not null, -c035 int(11) not null, -c036 int(11) not null, -c037 int(11) not null, -c038 int(11) not null, -c039 int(11) not null, -c040 int(11) not null, -c041 int(11) not null, -c042 int(11) not null, -c043 int(11) not null, -c044 int(11) not null, -c045 int(11) not null, -c046 int(11) not null, -c047 int(11) not null, -c048 int(11) not null, -c049 int(11) not null, -c050 int(11) not null, -c051 int(11) not null, -c052 int(11) not null, -c053 int(11) not null, -c054 int(11) not null, -c055 int(11) not null, -c056 int(11) not null, -c057 int(11) not null, -c058 int(11) not null, -c059 int(11) not null, -c060 int(11) not null, -c061 int(11) not null, -c062 int(11) not null, -c063 int(11) not null, -c064 int(11) not null, -c065 int(11) not null, -c066 int(11) not null, -c067 int(11) not null, -c068 int(11) not null, -c069 int(11) not null, -c070 int(11) not null, -c071 int(11) not null, -c072 int(11) not null, -c073 int(11) not null, -c074 int(11) not null, -c075 int(11) not null, -c076 int(11) not null, -c077 int(11) not null, -c078 int(11) not null, -c079 int(11) not null, -c080 int(11) not null, -c081 int(11) not null, -c082 int(11) not null, -c083 int(11) not null, -c084 int(11) not null, -c085 int(11) not null, -c086 int(11) not null, -c087 int(11) not null, -c088 int(11) not null, -c089 int(11) not null, -c090 int(11) not null, -c091 int(11) not null, -c092 int(11) not null, -c093 int(11) not null, -c094 int(11) not null, -c095 int(11) not null, -c096 int(11) not null, -c097 int(11) not null, -c098 int(11) not null, -c099 int(11) not null, -c100 int(11) not null, -c101 int(11) not null, -c102 int(11) not null, -c103 int(11) not null, -c104 int(11) not null, -c105 int(11) not null, -c106 int(11) not null, -c107 int(11) not null, -c108 int(11) not null, -c109 int(11) not null, -primary key (ai), -unique key tx1 (c002, c003, c004, c005)) engine=ndb; - -create index tx2 -on t1 (c010, c011, c012, c013); - -drop table t1; - -# simple test that auto incr is not lost at rename or alter -create table t1 (a int primary key auto_increment, b int) engine=ndb; -insert into t1 (b) values (101),(102),(103); -select * from t1 where a = 3; -alter table t1 rename t2; -insert into t2 (b) values (201),(202),(203); -select * from t2 where a = 6; -alter table t2 add c int; -insert into t2 (b) values (301),(302),(303); -select * from t2 where a = 9; -alter table t2 rename t1; -insert into t1 (b) values (401),(402),(403); -select * from t1 where a = 12; -drop table t1; - -# End of 4.1 tests - diff --git a/mysql-test/t/ndb_alter_table2.test b/mysql-test/t/ndb_alter_table2.test deleted file mode 100644 index 99c201f7370..00000000000 --- a/mysql-test/t/ndb_alter_table2.test +++ /dev/null @@ -1,114 +0,0 @@ --- source include/have_ndb.inc --- source include/have_multi_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - -connect (con1,localhost,root,,test); -connect (con2,localhost,root,,test); -connect (con3,localhost,root,,test); -connect (con4,localhost,root,,test); -connect (con5,localhost,root,,test); -connect (con6,localhost,root,,test); - -CREATE TABLE t1 ( - a INT NOT NULL PRIMARY KEY, - b INT NOT NULL -) ENGINE=ndbcluster; - -connection con1; -BEGIN; -INSERT INTO t1 VALUES (9410,9412); -connection con2; -BEGIN; ---send -INSERT INTO t1 VALUES (9411,9412); -connection con3; -BEGIN; ---send -INSERT INTO t1 VALUES (9412,9412); -connection con4; -BEGIN; ---send -INSERT INTO t1 VALUES (9413,9412); -connection con5; -BEGIN; ---send -INSERT INTO t1 VALUES (9414,9412); -connection con6; -BEGIN; ---send -INSERT INTO t1 VALUES (9415,9412); -connection con1; -sleep 1; - -ROLLBACK; -connection con2; -reap; -ROLLBACK; -connection con3; -reap; -ROLLBACK; -connection con4; -reap; -ROLLBACK; -connection con5; -reap; -ROLLBACK; -connection con6; -reap; -ROLLBACK; - -connection server2; - -drop table t1; -CREATE TABLE t1 ( - a INT NOT NULL PRIMARY KEY, - b INT NOT NULL, - c INT NOT NULL -) ENGINE=ndbcluster; - -connection server1; - ---error 1296 -select * from t1; -select * from t1; -select * from t1; -select * from t1; -select * from t1; -select * from t1; - -drop table t1; - -#For BUG#29851 TRUNCATE causes error 4350 from cluster in INSERT... ON DUPLICATE KEY UPDATE - -connection con1; - ---disable_warnings -DROP TABLE IF EXISTS truncate_test; ---enable_warnings - -CREATE TABLE truncate_test ( - i INT PRIMARY KEY, - a INT, - b VARCHAR(11), - UNIQUE KEY (a) -) ENGINE = NDB; - -INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; -INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; - -connection con2; -TRUNCATE truncate_test; - -connection con1; -INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; -SELECT * FROM truncate_test; - -connection con2; -INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; -SELECT * FROM truncate_test; - -DROP TABLE truncate_test; diff --git a/mysql-test/t/ndb_auto_increment.test b/mysql-test/t/ndb_auto_increment.test deleted file mode 100644 index 9801f2de564..00000000000 --- a/mysql-test/t/ndb_auto_increment.test +++ /dev/null @@ -1,294 +0,0 @@ --- source include/have_ndb.inc --- source include/have_multi_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -connection server1; -DROP TABLE IF EXISTS t1,t2; -connection server2; -DROP TABLE IF EXISTS t1; -connection server1; ---enable_warnings - -set @old_auto_increment_offset = @@session.auto_increment_offset; -set @old_auto_increment_increment = @@session.auto_increment_increment; -set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz; - -flush status; - -create table t1 (a int not null auto_increment primary key) engine ndb; - -# Step 1: Verify simple insert -insert into t1 values (NULL); -select * from t1 order by a; - -# Step 2: Verify simple update with higher than highest value causes -# next insert to use updated_value + 1 -update t1 set a = 5 where a = 1; -insert into t1 values (NULL); -select * from t1 order by a; - -# Step 3: Verify insert that inserts higher than highest value causes -# next insert to use inserted_value + 1 -insert into t1 values (7); -insert into t1 values (NULL); -select * from t1 order by a; - -# Step 4: Verify that insert into hole, lower than highest value doesn't -# affect next insert -insert into t1 values (2); -insert into t1 values (NULL); -select * from t1 order by a; - -# Step 5: Verify that update into hole, lower than highest value doesn't -# affect next insert -update t1 set a = 4 where a = 2; -insert into t1 values (NULL); -select * from t1 order by a; - -# Step 6: Verify that delete of highest value doesn't cause the next -# insert to reuse this value -delete from t1 where a = 10; -insert into t1 values (NULL); -select * from t1 order by a; - -# Step 7: Verify that REPLACE has the same effect as INSERT -replace t1 values (NULL); -select * from t1 order by a; -replace t1 values (15); -select * from t1 order by a; -replace into t1 values (NULL); -select * from t1 order by a; - -# Step 8: Verify that REPLACE has the same effect as UPDATE -replace t1 values (15); -select * from t1 order by a; - -# Step 9: Verify that IGNORE doesn't affect auto_increment -insert ignore into t1 values (NULL); -select * from t1 order by a; -insert ignore into t1 values (15), (NULL); -select * from t1 order by a; - -# Step 10: Verify that on duplicate key as UPDATE behaves as an -# UPDATE -insert into t1 values (15) -on duplicate key update a = 20; -insert into t1 values (NULL); -select * from t1 order by a; - -# Step 11: Verify that on duplicate key as INSERT behaves as INSERT -insert into t1 values (NULL) on duplicate key update a = 30; -select * from t1 order by a; -insert into t1 values (30) on duplicate key update a = 40; -select * from t1 order by a; - -#Step 12: Vefify INSERT IGNORE (bug#32055) -insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL); -select * from t1 order by a; -drop table t1; - -#Step 13: Verify auto_increment of unique key -create table t1 (a int not null primary key, - b int not null unique auto_increment) engine ndb; -insert into t1 values (1, NULL); -insert into t1 values (3, NULL); -update t1 set b = 3 where a = 3; -insert into t1 values (4, NULL); -select * from t1 order by a; -drop table t1; - -#Step 14: Verify that auto_increment_increment and auto_increment_offset -# work as expected - -CREATE TABLE t1 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=NDBCLUSTER; - -CREATE TABLE t2 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=MYISAM; - -SET @@session.auto_increment_increment=10; -INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); -INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); -SELECT * FROM t1 ORDER BY pk; -SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; -TRUNCATE t1; -TRUNCATE t2; -SET @@session.auto_increment_offset=5; -INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); -INSERT INTO t1 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6); -INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); -INSERT INTO t2 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6); -SELECT * FROM t1 ORDER BY pk; -SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; -TRUNCATE t1; -TRUNCATE t2; -SET @@session.auto_increment_increment=2; -INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); -INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); -SELECT * FROM t1 ORDER BY pk; -SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; -DROP TABLE t1, t2; - -CREATE TABLE t1 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7; - -CREATE TABLE t2 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=MYISAM AUTO_INCREMENT = 7; - -SET @@session.auto_increment_offset=1; -SET @@session.auto_increment_increment=1; -INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); -INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); -SELECT * FROM t1 ORDER BY pk; -SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; -DROP TABLE t1, t2; - -CREATE TABLE t1 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=NDBCLUSTER AUTO_INCREMENT = 3; - -CREATE TABLE t2 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=MYISAM AUTO_INCREMENT = 3; - -SET @@session.auto_increment_offset=5; -SET @@session.auto_increment_increment=10; -INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); -INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); -SELECT * FROM t1 ORDER BY pk; -SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; -DROP TABLE t1, t2; - -CREATE TABLE t1 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7; - -CREATE TABLE t2 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=MYISAM AUTO_INCREMENT = 7; - -SET @@session.auto_increment_offset=5; -SET @@session.auto_increment_increment=10; -INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); -INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); -SELECT * FROM t1 ORDER BY pk; -SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; -DROP TABLE t1, t2; - -CREATE TABLE t1 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=NDBCLUSTER AUTO_INCREMENT = 5; - -CREATE TABLE t2 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=MYISAM AUTO_INCREMENT = 5; - -SET @@session.auto_increment_offset=5; -SET @@session.auto_increment_increment=10; -INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); -INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); -SELECT * FROM t1 ORDER BY pk; -SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; -DROP TABLE t1, t2; - -CREATE TABLE t1 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=NDBCLUSTER AUTO_INCREMENT = 100; - -CREATE TABLE t2 ( - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=MYISAM AUTO_INCREMENT = 100; - -SET @@session.auto_increment_offset=5; -SET @@session.auto_increment_increment=10; -INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); -INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); -SELECT * FROM t1 ORDER BY pk; -SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; -DROP TABLE t1, t2; - -#Step 15: Now verify that behaviour on multiple MySQL Servers behave -# properly. Start by dropping table and recreating it to start -# counters and id caches from zero again. ---disable_warnings -connection server2; -SET @@session.auto_increment_offset=1; -SET @@session.auto_increment_increment=1; -set ndb_autoincrement_prefetch_sz = 32; -drop table if exists t1; -connection server1; -SET @@session.auto_increment_offset=1; -SET @@session.auto_increment_increment=1; -set ndb_autoincrement_prefetch_sz = 32; ---enable_warnings - - -create table t1 (a int not null auto_increment primary key) engine ndb; -# Basic test, ensure that the second server gets a new range. -#Generate record with key = 1 -insert into t1 values (NULL); -connection server2; -#Generate record with key = 33 -insert into t1 values (NULL); -connection server1; -select * from t1 order by a; - -#This insert should not affect the range of the second server -insert into t1 values (20); -connection server2; -insert into t1 values (NULL); -select * from t1 order by a; - -connection server1; -#This insert should remove cached values but also skip values already -#taken by server2, given that there is no method of communicating with -#the other server it should also cause a conflict -connection server1; - -insert into t1 values (35); -insert into t1 values (NULL); -connection server2; ---error ER_DUP_ENTRY -insert into t1 values (NULL); -select * from t1 order by a; - -insert into t1 values (100); -insert into t1 values (NULL); -connection server1; -insert into t1 values (NULL); -select * from t1 order by a; - -set auto_increment_offset = @old_auto_increment_offset; -set auto_increment_increment = @old_auto_increment_increment; -set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz; - -drop table t1; diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test deleted file mode 100644 index 73c04ad6764..00000000000 --- a/mysql-test/t/ndb_autodiscover.test +++ /dev/null @@ -1,555 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - -# Bug#41308: Test main.ndb_autodiscover.test doesn't work on Windows due -# to 'grep' calls -# Test is currently disabled on Windows via the next line until this bug -# can be resolved. ---source include/not_windows.inc - ---disable_warnings -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; ---enable_warnings - -################################################ -# Test that a table that does not exist as a -# frm file on disk can be "discovered" from a -# connected NDB Cluster -# - -flush status; - -# -# Test discover + SELECT -# - -create table t1( - id int not null primary key, - name char(20) -) engine=ndb; - -insert into t1 values(1, "Autodiscover"); -flush tables; -remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm ; -select * from t1; -show status like 'handler_discover%'; - -# -# Test discover + INSERT -# - -flush tables; -remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm ; -insert into t1 values (2, "Auto 2"); -show status like 'handler_discover%'; -insert into t1 values (3, "Discover 3"); -show status like 'handler_discover%'; -flush tables; -remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm ; -select * from t1 order by id; -show status like 'handler_discover%'; - -# -# Test discover + UPDATE -# - -flush tables; -remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm ; -update t1 set name="Autodiscover" where id = 2; -show status like 'handler_discover%'; -select * from t1 order by id; -show status like 'handler_discover%'; - -# -# Test discover + DELETE -# - -flush tables; -remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm ; -delete from t1 where id = 3; -select * from t1 order by id; -show status like 'handler_discover%'; - -drop table t1; - - - -###################################################### -# Test that a table that is outdated on disk -# can be "discovered" from a connected NDB Cluster -# - -flush status; - -create table t2( - id int not null primary key, - name char(22) -) engine=ndb; -insert into t2 values (1, "Discoverer"); -select * from t2; -show status like 'handler_discover%'; -flush tables; - -# Modify the frm file on disk -system echo "blaj" >> $MYSQLTEST_VARDIR/master-data/test/t2.frm ; -select * from t2; - -show status like 'handler_discover%'; - -drop table t2; - - -################################################## -# Test that a table that already exists in NDB -# is only discovered if CREATE TABLE IF NOT EXISTS -# is used -# - -flush status; - -create table t3( - id int not null primary key, - name char(255) -) engine=ndb; -insert into t3 values (1, "Explorer"); -select * from t3; -show status like 'handler_discover%'; -flush tables; - -# Remove the frm file from disk -remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm ; - ---error ER_TABLE_EXISTS_ERROR -create table t3( - id int not null primary key, - name char(20), a int, b float, c char(24) -) engine=ndb; - -# The table shall not have been discovered since -# IF NOT EXISTS wasn't specified - -show status like 'handler_discover%'; - -# now it should be discovered -create table IF NOT EXISTS t3( - id int not null primary key, - id2 int not null, - name char(20) -) engine=ndb; - -# NOTE! the table called t3 have now been updated to -# use the same frm as in NDB, thus it's not certain that -# the table schema is the same as was stated in the -# CREATE TABLE statement above - -show status like 'handler_discover%'; - -SHOW CREATE TABLE t3; - -select * from t3; -show status like 'handler_discover%'; - -drop table t3; - -################################################## -# Test that a table that already exists in NDB -# is discovered when SHOW TABLES -# is used -# - -flush status; - -create table t7( - id int not null primary key, - name char(255) -) engine=ndb; -create table t6( - id int not null primary key, - name char(255) -) engine=MyISAM; -insert into t7 values (1, "Explorer"); -insert into t6 values (2, "MyISAM table"); -select * from t7; -show status like 'handler_discover%'; - -# Remove the frm file from disk -flush tables; -remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm ; - -show tables from test; -show status like 'handler_discover%'; - -# Remove the frm file from disk again -flush tables; -remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm ; - ---replace_column 7 # 8 # 9 # 12 # 13 # 15 # 18 # -show table status; -show status like 'handler_discover%'; - -drop table t6, t7; - - -####################################################### -# Test that a table that has been dropped from NDB -# but still exists on disk, get a consistent error message -# saying "No such table existed" -# - -flush status; - -create table t4( - id int not null primary key, - name char(27) -) engine=ndb; -insert into t4 values (1, "Automatic"); -select * from t4; - -# Remove the table from NDB -system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t4 >> $NDB_TOOLS_OUTPUT ; - -# -# Test that correct error is returned ---error ER_NO_SUCH_TABLE -select * from t4; ---error ER_NO_SUCH_TABLE -select * from t4; - -show status like 'handler_discover%'; ---error ER_BAD_TABLE_ERROR -drop table t4; - -create table t4( - id int not null primary key, - name char(27) -) engine=ndb; -insert into t4 values (1, "Automatic"); -select * from t4; - -# Remove the table from NDB -system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t4 >> $NDB_TOOLS_OUTPUT ; - ---error ER_NO_SUCH_TABLE -select * from t4; - -drop table if exists t4; - -# Test that dropping a table that does not exists -# on disk or in NDB gives same result as above ---error ER_BAD_TABLE_ERROR -drop table t5; -drop table if exists t5; - - -####################################################### -# Test that a table that has been dropped from NDB -# but still exists on disk is deleted from disk -# when SHOW TABLES is called -# - -flush status; - -create table t4( - id int not null primary key, - id2 int, - name char(27) -) engine=ndb; -insert into t4 values (1, 76, "Automatic2"); -select * from t4; -flush tables; - -# Remove the table from NDB -system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t4 >> $NDB_TOOLS_OUTPUT ; - -SHOW TABLES; - ---error ER_NO_SUCH_TABLE -select * from t4; - -####################################################### -# Test SHOW TABLES ability to detect new and delete old -# tables. Test all at once using many tables -# - -flush status; - -# Create tables -create table t1(id int) engine=ndbcluster; -create table t2(id int, b char(255)) engine=myisam; -create table t3(id int, c char(255)) engine=ndbcluster; -create table t4(id int) engine=myisam; -create table t5(id int, d char(56)) engine=ndbcluster; -create table t6(id int) engine=ndbcluster; -create table t7(id int) engine=ndbcluster; -create table t8(id int, e char(34)) engine=myisam; -create table t9(id int) engine=myisam; - -# Populate tables -insert into t2 values (2, "myisam table 2"); -insert into t3 values (3, "ndb table 3"); -insert into t5 values (5, "ndb table 5"); -insert into t6 values (6); -insert into t8 values (8, "myisam table 8"); -insert into t9 values (9); - -# Remove t3, t5 from NDB -system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 >> $NDB_TOOLS_OUTPUT ; -system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 >> $NDB_TOOLS_OUTPUT ; -# Remove t6, t7 from disk -remove_file $MYSQLTEST_VARDIR/master-data/test/t6.frm; -remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm; - -SHOW TABLES; - -select * from t6; -select * from t7; - -show status like 'handler_discover%'; - -drop table t1, t2, t4, t6, t7, t8, t9; - -####################################################### -# Test SHOW TABLES LIKE ability to detect new and delete old -# tables. Test all at once using many tables. -# - -flush status; - -# Create tables -create table t1(id int) engine=ndbcluster; -create table t2(id int, b char(255)) engine=myisam; -create table t3(id int, c char(255)) engine=ndbcluster; -create table t4(id int) engine=myisam; -create table t5(id int, d char(56)) engine=ndbcluster; -create table t6(id int) engine=ndbcluster; -create table t7(id int) engine=ndbcluster; -create table t8(id int, e char(34)) engine=myisam; -create table t9(id int) engine=myisam; - -# Populate tables -insert into t2 values (2, "myisam table 2"); -insert into t3 values (3, "ndb table 3"); -insert into t5 values (5, "ndb table 5"); -insert into t6 values (6); -insert into t8 values (8, "myisam table 8"); -insert into t9 values (9); - -# Remove t3, t5 from NDB -system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 > /dev/null ; -system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 > /dev/null ; -# Remove t6, t7 from disk -remove_file $MYSQLTEST_VARDIR/master-data/test/t6.frm; -remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm; - - -SHOW TABLES LIKE 't6'; - -show status like 'handler_discover%'; - -# Check that t3 or t5 can't be created -# frm files for these tables is stilll on disk ---error ER_TABLE_EXISTS_ERROR -create table t3(a int); ---error ER_TABLE_EXISTS_ERROR -create table t5(a int); - -SHOW TABLES LIKE 't%'; - -show status like 'handler_discover%'; - -drop table t1, t2, t4, t6, t7, t8, t9; - - - -###################################################### -# Test that several tables can be discovered when -# one statement access several table at once. -# - -flush status; - -# Create tables -create table t1(id int) engine=ndbcluster; -create table t2(id int, b char(255)) engine=ndbcluster; -create table t3(id int, c char(255)) engine=ndbcluster; -create table t4(id int) engine=myisam; - -# Populate tables -insert into t1 values (1); -insert into t2 values (2, "table 2"); -insert into t3 values (3, "ndb table 3"); -insert into t4 values (4); - -# Remove t1, t2, t3 from disk -remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm; -remove_file $MYSQLTEST_VARDIR/master-data/test/t2.frm; -remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm; -flush tables; - -# Select from the table which only exists in NDB. -select * from t1, t2, t3, t4; - -# 3 table should have been discovered -show status like 'handler_discover%'; - -drop table t1, t2, t3, t4; - - -######################################################### -# Test that a table that has been changed in NDB -# since it's been opened will be refreshed and discovered -# again -# - -flush status; - -show status like 'handler_discover%'; - -create table t5( - id int not null primary key, - name char(200) -) engine=ndb; -insert into t5 values (1, "Magnus"); -select * from t5; - -ALTER TABLE t5 ADD COLUMN adress char(255) FIRST; - -select * from t5; - -insert into t5 values - ("Adress for record 2", 2, "Carl-Gustav"), - ("Adress for record 3", 3, "Karl-Emil"); -update t5 set name="Bertil" where id = 2; -select * from t5 order by id; - -show status like 'handler_discover%'; - -drop table t5; - - -################################################################ -# Test that a table that has been changed with ALTER TABLE -# can be used from the same thread -# - -flush status; - -show status like 'handler_discover%'; - -create table t6( - id int not null primary key, - name char(20) -) engine=ndb; -insert into t6 values (1, "Magnus"); -select * from t6; - -ALTER TABLE t6 ADD COLUMN adress char(255) FIRST; - -select * from t6; -insert into t6 values - ("Adress for record 2", 2, "Carl-Gustav"), - ("Adress for record 3", 3, "Karl-Emil"); -update t6 set name="Bertil" where id = 2; -select * from t6 order by id; - -show status like 'handler_discover%'; - -drop table t6; - -##################################################### -# Test that only tables in the current database shows -# up in SHOW TABLES -# - -show tables; - -create table t1 (a int,b longblob) engine=ndb; -show tables; -create database test2; -use test2; -show tables; ---error ER_NO_SUCH_TABLE -select * from t1; -create table t2 (b int,c longblob) engine=ndb; -use test; -select * from t1; -show tables; -drop table t1; -use test2; -drop table t2; -drop database test2; -use test; - -######################################################### -# Bug#8035 -# mysqld would segfault on second select * before bug was fixed -# ---disable_warnings -drop database if exists test_only_ndb_tables; ---enable_warnings -create database test_only_ndb_tables; -use test_only_ndb_tables; -create table t1 (a int primary key) engine=ndb; -select * from t1; ---exec $NDB_MGM --no-defaults -e "all restart -n" > /dev/null ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --not-started > /dev/null ---error ER_CANT_LOCK -select * from t1; ---exec $NDB_MGM --no-defaults -e "all start" > /dev/null ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults > /dev/null ---source include/ndb_wait_connected.inc -use test; -drop database test_only_ndb_tables; - -##################################################### -# Test that it's not possible to create tables -# with same name as NDB internal tables -# This will also test that it's not possible to create -# a table with tha same name as a table that can't be -# discovered( for example a table created via NDBAPI) - -# Test disabled since it doesn't work on case insensitive systems -#--error ER_TABLE_EXISTS_ERROR -#CREATE TABLE sys.SYSTAB_0 (a int); -#--error ER_UNKNOWN_ERROR -#select * from sys.SYSTAB_0; - -#CREATE TABLE IF NOT EXISTS sys.SYSTAB_0 (a int); -#show warnings; -#--error ER_UNKNOWN_ERROR -#select * from sys.SYSTAB_0; - -#--error ER_BAD_TABLE_ERROR -#drop table sys.SYSTAB_0; -#drop table IF EXISTS sys.SYSTAB_0; - -###################################################### -# Note! This should always be the last step in this -# file, the table t9 will be used and dropped -# by ndb_autodiscover2 -# - -CREATE TABLE t9 ( - a int NOT NULL PRIMARY KEY, - b int -) engine=ndb; - -insert t9 values(1, 2), (2,3), (3, 4), (4, 5); - -#Don't drop the table, instead remove the frm file -remove_file $MYSQLTEST_VARDIR/master-data/test/t9.frm ; - -# Now leave test case, when ndb_autodiscover2 will run, this -# MySQL Server will have been restarted because it has a -# ndb_autodiscover2-master.opt file. - -create table t10 ( - a int not null primary key, - b blob -) engine=ndb; - -insert into t10 values (1, 'kalle'); - ---exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test `$NDB_TOOLS_DIR/ndb_show_tables --no-defaults | grep BLOB` >> $NDB_TOOLS_OUTPUT 2>&1 || true - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_autodiscover2-master.opt b/mysql-test/t/ndb_autodiscover2-master.opt deleted file mode 100644 index e0d075c3fbd..00000000000 --- a/mysql-test/t/ndb_autodiscover2-master.opt +++ /dev/null @@ -1 +0,0 @@ ---skip-external-locking diff --git a/mysql-test/t/ndb_autodiscover2.test b/mysql-test/t/ndb_autodiscover2.test deleted file mode 100644 index ebe14696cd2..00000000000 --- a/mysql-test/t/ndb_autodiscover2.test +++ /dev/null @@ -1,21 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - -# -# Simple test to show use of discover when the server has been restarted -# The previous step has simply removed the frm file -# from disk, but left the table in NDB -# ---sleep 3 -select * from t9 order by a; - -# handler_discover should be 1 -show status like 'handler_discover%'; - -drop table t9; - ---error 1296 -select * from t10; -drop table t10; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_autodiscover3.test b/mysql-test/t/ndb_autodiscover3.test deleted file mode 100644 index 4a20e7dd430..00000000000 --- a/mysql-test/t/ndb_autodiscover3.test +++ /dev/null @@ -1,80 +0,0 @@ --- source include/have_ndb.inc --- source include/have_multi_ndb.inc --- source include/ndb_default_cluster.inc --- source include/not_embedded.inc - - ---disable_warnings -drop table if exists t1, t2; ---enable_warnings - -# Workaround for Bug#27644 -# ndb: connecting api node/mysqld may "steal" node_id from running mysqld -# - let ndb_waiter use a fixed node id so "steal" cannot happen ---let connect_str = "nodeid=6;$NDB_CONNECTSTRING" - -# -# Transaction ongoing while cluster is restarted -# ---connection server1 -create table t1 (a int key) engine=ndbcluster; - -begin; -insert into t1 values (1); - ---exec $NDB_MGM --no-defaults -e "all restart" >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT - -# Create separate connection and use that for detecting -# when mysqld has reconnected to ndbd -connect (ndb_wait_con,127.0.0.1,root,,test,$MASTER_MYPORT,); ---source include/ndb_wait_connected.inc -disconnect ndb_wait_con; -connection server1; - ---error 1297 -insert into t1 values (2); ---error 1296 -commit; - -drop table t1; - -# -# Stale cache after restart -i -# ---connection server1 -create table t2 (a int, b int, primary key(a,b)) engine=ndbcluster; -insert into t2 values (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1); -select * from t2 order by a limit 3; - ---exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT - ---connection server2 ---source include/ndb_wait_connected.inc -create table t2 (a int key) engine=ndbcluster; -insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); -select * from t2 order by a limit 3; - -# server 1 should have a stale cache, and in this case wrong frm, transaction must be retried ---connection server1 ---error 1015 -select * from t2 order by a limit 3; -select * from t2 order by a limit 3; - ---exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT - ---connection server1 ---source include/ndb_wait_connected.inc -show tables; -create table t2 (a int key) engine=ndbcluster; -insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); -select * from t2 order by a limit 3; - -# server 2 should have a stale cache, but with right frm, transaction need not be retried ---connection server2 -select * from t2 order by a limit 3; - -drop table t2; -# End of 4.1 tests diff --git a/mysql-test/t/ndb_backup_print.test b/mysql-test/t/ndb_backup_print.test deleted file mode 100644 index 1e516f03ae6..00000000000 --- a/mysql-test/t/ndb_backup_print.test +++ /dev/null @@ -1,66 +0,0 @@ --- source include/have_ndb.inc --- source include/ndb_default_cluster.inc --- source include/not_embedded.inc - ---disable_warnings -use test; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; ---enable_warnings - -#NO.1 test output of backup ---exec $NDB_MGM --no-defaults -e "start backup" |sed -e 's/[0-9]//g' |sed -e 's/localhost//g' |sed -e 's/\.\.\.*//g' - -create table t1 - (pk int key - ,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64) - ,b1 TINYINT, b2 TINYINT UNSIGNED - ,c1 SMALLINT, c2 SMALLINT UNSIGNED - ,d1 INT, d2 INT UNSIGNED - ,e1 BIGINT, e2 BIGINT UNSIGNED - ,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY - ,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY - ,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255) - ,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) - ) engine ndb; - -insert into t1 values - (1 - ,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001 - ,127, 255 - ,32767, 65535 - ,2147483647, 4294967295 - ,9223372036854775807, 18446744073709551615 - ,'1','12345678901234567890123456789012','123456789' - ,'1','12345678901234567890123456789012','123456789' - ,0x12,0x123456789abcdef0, 0x012345 - ,0x12,0x123456789abcdef0, 0x00123450 - ); - -insert into t1 values - (2 - ,0, 0, 0, 0, 0 - ,-128, 0 - ,-32768, 0 - ,-2147483648, 0 - ,-9223372036854775808, 0 - ,'','','' - ,'','','' - ,0x0,0x0,0x0 - ,0x0,0x0,0x0 - ); - -insert into t1 values - (3 - ,NULL,NULL,NULL,NULL,NULL - ,NULL,NULL - ,NULL,NULL - ,NULL,NULL - ,NULL,NULL - ,NULL,NULL,NULL - ,NULL,NULL,NULL - ,NULL,NULL,NULL - ,NULL,NULL,NULL - ); - -#NO.2 test output of backup after some simple SQL operations ---exec $NDB_MGM --no-defaults -e "start backup" |sed -e 's/[0-9]//g' |sed -e 's/localhost//g' |sed -e 's/\.\.\.*//g' diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test deleted file mode 100644 index e9401ff3894..00000000000 --- a/mysql-test/t/ndb_basic.test +++ /dev/null @@ -1,804 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; -drop database if exists mysqltest; ---enable_warnings - -# -# Basic test to show that the NDB -# table handler is working -# - -# -# Create a normal table with primary key -# -CREATE TABLE t1 ( - pk1 INT NOT NULL PRIMARY KEY, - attr1 INT NOT NULL, - attr2 INT, - attr3 VARCHAR(10) -) ENGINE=ndbcluster; - -SHOW INDEX FROM t1; -INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413'); -SHOW INDEX FROM t1; -SELECT pk1 FROM t1 ORDER BY pk1; -SELECT * FROM t1 ORDER BY pk1; -SELECT t1.* FROM t1 ORDER BY pk1; - -# Update on record by primary key -UPDATE t1 SET attr1=1 WHERE pk1=9410; -SELECT * FROM t1 ORDER BY pk1; - -# Update primary key -UPDATE t1 SET pk1=2 WHERE attr1=1; -SELECT * FROM t1 ORDER BY pk1; -UPDATE t1 SET pk1=pk1 + 1; -SELECT * FROM t1 ORDER BY pk1; -UPDATE t1 SET pk1=4 WHERE pk1 = 3; -SELECT * FROM t1 ORDER BY pk1; - -# Delete the record -DELETE FROM t1; -SELECT * FROM t1; - -# Insert more records and update them all at once -INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9408, 8765, NULL, '8765'), -(7,8, NULL, NULL), (8,9, NULL, NULL), (9,10, NULL, NULL), (10,11, NULL, NULL), (11,12, NULL, NULL), (12,13, NULL, NULL), (13,14, NULL, NULL); -UPDATE t1 SET attr1 = 9999; -SELECT * FROM t1 ORDER BY pk1; - -UPDATE t1 SET attr1 = 9998 WHERE pk1 < 1000; -SELECT * FROM t1 ORDER BY pk1; - -UPDATE t1 SET attr1 = 9997 WHERE attr1 = 9999; -SELECT * FROM t1 ORDER BY pk1; - -# Delete one record by specifying pk -DELETE FROM t1 WHERE pk1 = 9410; -SELECT * FROM t1 ORDER BY pk1; - -# Delete all from table -DELETE FROM t1; -SELECT * FROM t1; - -# Insert three records with attr1=4 and two with attr1=5 -# Delete all with attr1=4 -INSERT INTO t1 values (1, 4, NULL, NULL), (2, 4, NULL, NULL), (3, 5, NULL, NULL), (4, 4, NULL, NULL), (5, 5, NULL, NULL); -DELETE FROM t1 WHERE attr1=4; -SELECT * FROM t1 order by pk1; -DELETE FROM t1; - -# Insert two records and delete one -INSERT INTO t1 VALUES (9410,9412, NULL, NULL), (9411, 9413, NULL, NULL); -DELETE FROM t1 WHERE pk1 = 9410; -SELECT * FROM t1; -DROP TABLE t1; - -# -# Create table without primary key -# a hidden primary key column is created by handler -# -CREATE TABLE t1 (id INT, id2 int) engine=ndbcluster; -INSERT INTO t1 values(3456, 7890); -SELECT * FROM t1; -UPDATE t1 SET id=2 WHERE id2=12; -SELECT * FROM t1; -UPDATE t1 SET id=1234 WHERE id2=7890; -SELECT * FROM t1; -DELETE FROM t1; - -INSERT INTO t1 values(3456, 7890), (3456, 7890), (3456, 7890), (3454, 7890); -SELECT * FROM t1 ORDER BY id; -DELETE FROM t1 WHERE id = 3456; -SELECT * FROM t1 ORDER BY id; - -DROP TABLE t1; - -# test create with the keyword "engine=NDBCLUSTER" -CREATE TABLE t1 ( - pk1 INT NOT NULL PRIMARY KEY, - attr1 INT NOT NULL -) ENGINE=NDBCLUSTER; - -INSERT INTO t1 values(1, 9999); - -DROP TABLE t1; - -# test create with the keyword "engine=NDB" -CREATE TABLE t1 ( - pk1 INT NOT NULL PRIMARY KEY, - attr1 INT NOT NULL -) ENGINE=NDB; - -INSERT INTO t1 values(1, 9999); - -DROP TABLE t1; - - -# -# A more extensive test with a lot more records -# - -CREATE TABLE t2 ( - a bigint unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned -) engine=ndbcluster; - -CREATE TABLE t3 ( - a bigint unsigned NOT NULL, - b bigint unsigned not null, - c bigint unsigned, - PRIMARY KEY(a) -) engine=ndbcluster; - -CREATE TABLE t4 ( - a bigint unsigned NOT NULL, - b bigint unsigned not null, - c bigint unsigned NOT NULL, - d int unsigned, - PRIMARY KEY(a, b, c) -) engine=ndbcluster; - - -# -# insert more records into tables -# -let $1=1000; -disable_query_log; -while ($1) -{ - eval insert into t2 values($1, $1+9, 5); - eval insert into t3 values($1, $1+9, 5); - eval insert into t4 values($1, $1+9, 5, $1+26000); - dec $1; -} -enable_query_log; - - -# -# delete every other record in the tables -# -let $1=1000; -disable_query_log; -while ($1) -{ - eval delete from t2 where a=$1; - eval delete from t3 where a=$1; - eval delete from t4 where a=$1 and b=$1+9 and c=5; - dec $1; - dec $1; -} -enable_query_log; - - -select * from t2 where a = 7 order by b; -select * from t2 where a = 7 order by a; -select * from t2 where a = 7 order by 2; -select * from t2 where a = 7 order by c; - -select * from t2 where a = 7 and b = 16 order by b; -select * from t2 where a = 7 and b = 16 order by a; -select * from t2 where a = 7 and b = 17 order by a; -select * from t2 where a = 7 and b != 16 order by b; - -select * from t2 where a = 7 and b = 16 and c = 5 order by b; -select * from t2 where a = 7 and b = 16 and c = 5 order by a; -select * from t2 where a = 7 and b = 16 and c = 6 order by a; -select * from t2 where a = 7 and b != 16 and c = 5 order by b; - -select * from t3 where a = 7 order by b; -select * from t3 where a = 7 order by a; -select * from t3 where a = 7 order by 2; -select * from t3 where a = 7 order by c; - -select * from t3 where a = 7 and b = 16 order by b; -select * from t3 where a = 7 and b = 16 order by a; -select * from t3 where a = 7 and b = 17 order by a; -select * from t3 where a = 7 and b != 16 order by b; - -select * from t4 where a = 7 order by b; -select * from t4 where a = 7 order by a; -select * from t4 where a = 7 order by 2; -select * from t4 where a = 7 order by c; - -select * from t4 where a = 7 and b = 16 order by b; -select * from t4 where a = 7 and b = 16 order by a; -select * from t4 where a = 7 and b = 17 order by a; -select * from t4 where a = 7 and b != 16 order by b; - -# -# update records -# -let $1=1000; -disable_query_log; -while ($1) -{ - eval update t2 set c=$1 where a=$1; - eval update t3 set c=7 where a=$1 and b=$1+9 and c=5; - eval update t4 set d=$1+21987 where a=$1 and b=$1+9 and c=5; - dec $1; - dec $1; -} -enable_query_log; - -delete from t2 where a > 5; -select x1.a, x1.b from t2 x1, t2 x2 where x1.b = x2.b order by x1.a; -select a, b FROM t2 outer_table where -a = (select a from t2 where b = outer_table.b ) order by a; - - -delete from t2; -delete from t3; -delete from t4; - -drop table t2; -drop table t3; -drop table t4; - -# -# Test delete and update from table with 3 keys -# - -CREATE TABLE t5 ( - a bigint unsigned NOT NULL, - b bigint unsigned not null, - c bigint unsigned NOT NULL, - d int unsigned, - PRIMARY KEY(a, b, c) -) engine=ndbcluster; - -insert into t5 values(10, 19, 5, 26010); - -delete from t5 where a=10 and b=19 and c=5; - -select * from t5; - -insert into t5 values(10, 19, 5, 26010); - -update t5 set d=21997 where a=10 and b=19 and c=5; - -select * from t5; - -delete from t5; - -drop table t5; - -# -# Test using table with a char(255) column first in table -# - -CREATE TABLE t6 ( - adress char(255), - a int NOT NULL PRIMARY KEY, - b int -) engine = NDB; - -insert into t6 values - ("Nice road 3456", 1, 23), - ("Street Road 78", 3, 92), - ("Road street 89C", 5, 71), - (NULL, 7, NULL); -select * from t6 order by a; -select a, b from t6 order by a; - -update t6 set adress="End of road 09" where a=3; -update t6 set b=181, adress="Street 76" where a=7; -select * from t6 order by a; -select * from t6 where a=1; -delete from t6 where a=1; -select * from t6 order by a; -delete from t6 where b=71; -select * from t6 order by a; - -drop table t6; - -# -# Test using table with a char(255) column first in table and a -# primary key consisting of two columns -# - -CREATE TABLE t7 ( - adress char(255), - a int NOT NULL, - b int, - c int NOT NULL, - PRIMARY KEY(a, c) -) engine = NDB; - -insert into t7 values - ("Highway 3456", 1, 23, 2), - ("Street Road 78", 3, 92, 3), - ("Main street 89C", 5, 71, 4), - (NULL, 8, NULL, 12); -select * from t7 order by a; -select a, b from t7 order by a; - -update t7 set adress="End of road 09" where a=3; -update t7 set adress="Gatuvägen 90C" where a=5 and c=4; -update t7 set adress="No adress" where adress is NULL; -select * from t7 order by a; -select * from t7 where a=1 and c=2; -delete from t7 where a=1; -delete from t7 where a=3 and c=3; -delete from t7 where a=5 and c=4; -select * from t7; -delete from t7 where b=23; -select * from t7; - -drop table t7; - -# -# Test multiple databases in one statement -# - -CREATE TABLE t1 ( - pk1 INT NOT NULL PRIMARY KEY, - attr1 INT NOT NULL, - attr2 INT, - attr3 VARCHAR(10) -) ENGINE=ndbcluster; - -INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413'); - -create database mysqltest; -use mysqltest; - -CREATE TABLE t2 ( - a bigint unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned -) engine=ndbcluster; - -insert into t2 select pk1,attr1,attr2 from test.t1; -select * from t2 order by a; -select b from test.t1, t2 where c = test.t1.attr2; -select b,test.t1.attr1 from test.t1, t2 where test.t1.pk1 < a; - -drop table test.t1, t2; -drop database mysqltest; - -# -# BUG#6031 - DROP DATABASE doesn't drop database on first try -# - ---disable_warnings -drop database if exists ndbtest1; ---enable_warnings - -create database ndbtest1; -use ndbtest1; -create table t1(id int) engine=ndbcluster; -drop database ndbtest1; ---error 1008 -drop database ndbtest1; - -# -# test support of char(0) -# - -use test; -create table t1 (a int primary key, b char(0)); -insert into t1 values (1,""); -insert into t1 values (2,NULL); -select * from t1 order by a; -select * from t1 order by b; -select * from t1 where b IS NULL; -select * from t1 where b IS NOT NULL; -drop table t1; - -# -# test the limit of no of attributes in one table -# - -create table t1 ( -c1 int, -c2 int, -c3 int, -c4 int, -c5 int, -c6 int, -c7 int, -c8 int, -c9 int, -c10 int, -c11 int, -c12 int, -c13 int, -c14 int, -c15 int, -c16 int, -c17 int, -c18 int, -c19 int, -c20 int, -c21 int, -c22 int, -c23 int, -c24 int, -c25 int, -c26 int, -c27 int, -c28 int, -c29 int, -c30 int, -c31 int, -c32 int, -c33 int, -c34 int, -c35 int, -c36 int, -c37 int, -c38 int, -c39 int, -c40 int, -c41 int, -c42 int, -c43 int, -c44 int, -c45 int, -c46 int, -c47 int, -c48 int, -c49 int, -c50 int, -c51 int, -c52 int, -c53 int, -c54 int, -c55 int, -c56 int, -c57 int, -c58 int, -c59 int, -c60 int, -c61 int, -c62 int, -c63 int, -c64 int, -c65 int, -c66 int, -c67 int, -c68 int, -c69 int, -c70 int, -c71 int, -c72 int, -c73 int, -c74 int, -c75 int, -c76 int, -c77 int, -c78 int, -c79 int, -c80 int, -c81 int, -c82 int, -c83 int, -c84 int, -c85 int, -c86 int, -c87 int, -c88 int, -c89 int, -c90 int, -c91 int, -c92 int, -c93 int, -c94 int, -c95 int, -c96 int, -c97 int, -c98 int, -c99 int, -c100 int, -c101 int, -c102 int, -c103 int, -c104 int, -c105 int, -c106 int, -c107 int, -c108 int, -c109 int, -c110 int, -c111 int, -c112 int, -c113 int, -c114 int, -c115 int, -c116 int, -c117 int, -c118 int, -c119 int, -c120 int, -c121 int, -c122 int, -c123 int, -c124 int, -c125 int, -c126 int, -c127 int, -c128 int, -primary key(c1)) engine=ndb; -drop table t1; - -# -# test max size of attribute name and truncation -# - -create table t1 ( -a1234567890123456789012345678901234567890 int primary key, -a12345678901234567890123456789a1234567890 int, -index(a12345678901234567890123456789a1234567890) -) engine=ndb; -show tables; -insert into t1 values (1,1),(2,1),(3,1),(4,1),(5,2),(6,1),(7,1); -explain select * from t1 where a12345678901234567890123456789a1234567890=2; -select * from t1 where a12345678901234567890123456789a1234567890=2; -drop table t1; - -# -# test fragment creation -# -# first a table with _many_ fragments per node group -# then a table with just one fragment per node group -# -create table t1 - (a bigint, b bigint, c bigint, d bigint, - primary key (a,b,c,d)) - engine=ndb - max_rows=800000000; -insert into t1 values - (1,2,3,4),(2,3,4,5),(3,4,5,6), - (3,2,3,4),(1,3,4,5),(2,4,5,6), - (1,2,3,5),(2,3,4,8),(3,4,5,9), - (3,2,3,5),(1,3,4,8),(2,4,5,9), - (1,2,3,6),(2,3,4,6),(3,4,5,7), - (3,2,3,6),(1,3,4,6),(2,4,5,7), - (1,2,3,7),(2,3,4,7),(3,4,5,8), - (3,2,3,7),(1,3,4,7),(2,4,5,8), - (1,3,3,4),(2,4,4,5),(3,5,5,6), - (3,3,3,4),(1,4,4,5),(2,5,5,6), - (1,3,3,5),(2,4,4,8),(3,5,5,9), - (3,3,3,5),(1,4,4,8),(2,5,5,9), - (1,3,3,6),(2,4,4,6),(3,5,5,7), - (3,3,3,6),(1,4,4,6),(2,5,5,7), - (1,3,3,7),(2,4,4,7),(3,5,5,8), - (3,3,3,7),(1,4,4,7),(2,5,5,8); -select count(*) from t1; -drop table t1; - -create table t1 - (a bigint, b bigint, c bigint, d bigint, - primary key (a)) - engine=ndb - max_rows=1; -drop table t1; - -# -# Test auto_increment -# - -connect (con1,localhost,root,,test); -connect (con2,localhost,root,,test); - -create table t1 - (counter int(64) NOT NULL auto_increment, - datavalue char(40) default 'XXXX', - primary key (counter) - ) ENGINE=ndbcluster; - -connection con1; -insert into t1 (datavalue) values ('newval'); -insert into t1 (datavalue) values ('newval'); -select * from t1 order by counter; -insert into t1 (datavalue) select datavalue from t1 where counter < 100; -insert into t1 (datavalue) select datavalue from t1 where counter < 100; -select * from t1 order by counter; -connection con2; -insert into t1 (datavalue) select datavalue from t1 where counter < 100; -insert into t1 (datavalue) select datavalue from t1 where counter < 100; -select * from t1 order by counter; - -drop table t1; - -# -# bug#27437 -connection con1; -create table t1 (a int primary key auto_increment) engine = ndb; -insert into t1() values (),(),(),(),(),(),(),(),(),(),(),(); -connection con2; -insert into t1(a) values (20),(28); -connection con1; -insert into t1() values (),(),(),(),(),(),(),(),(),(),(),(); -connection con2; -insert into t1() values (21), (22); -connection con1; - -drop table t1; - -# -# BUG#14514 Creating table with packed key fails silently -# - -CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb; -select * from t1; -drop table t1; - -# -# Bug #17249 delete statement with join where clause fails -# when table do not have pk - # - -create table t1 (a int) engine=ndb; -create table t2 (a int) engine=ndb; -insert into t1 values (1); -insert into t2 values (1); -delete t1.* from t1, t2 where t1.a = t2.a; -select * from t1; -select * from t2; -drop table t1; -drop table t2; - -# -# Bug #17257 update fails for inner joins if tables -# do not have Primary Key -# - -CREATE TABLE t1 ( - i INT, - j INT, - x INT, - y INT, - z INT -) engine=ndb; - -CREATE TABLE t2 ( - i INT, - k INT, - x INT, - y INT, - z INT -) engine=ndb; - -CREATE TABLE t3 ( - j INT, - k INT, - x INT, - y INT, - z INT -) engine=ndb; - -INSERT INTO t1 VALUES ( 1, 2,13,14,15); -INSERT INTO t2 VALUES ( 1, 3,23,24,25); -INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36); - -UPDATE t1 AS a -INNER JOIN t2 AS b - ON a.i = b.i -INNER JOIN t3 AS c - ON a.j = c.j AND b.k = c.k -SET a.x = b.x, - a.y = b.y, - a.z = ( - SELECT sum(z) - FROM t3 - WHERE y = 34 - ) -WHERE b.x = 23; -select * from t1; -drop table t1; -drop table t2; -drop table t3; - -# End of 4.1 tests - -# -# Test long table name -# -create table atablewithareallylongandirritatingname (a int); -insert into atablewithareallylongandirritatingname values (2); -select * from atablewithareallylongandirritatingname; -drop table atablewithareallylongandirritatingname; - -# -# Bug#15682 -# -create table t1 (f1 varchar(50), f2 text,f3 int, primary key(f1)) engine=NDB; -insert into t1 (f1,f2,f3)VALUES("111111","aaaaaa",1); -insert into t1 (f1,f2,f3)VALUES("222222","bbbbbb",2); -select * from t1 order by f1; -select * from t1 order by f2; -select * from t1 order by f3; -drop table t1; - -# -# Bug#16561 Unknown ERROR msg "ERROR 1186 (HY000): Binlog closed" by perror -# - -# As long there is no error code 1186 defined by NDB -# we should get a message "Illegal ndb error code: 1186" ---error 1 ---exec $MY_PERROR --ndb 1186 2>&1 - -# -# Bug #25746 - VARCHAR UTF8 PK issue -# - prior to bugfix 4209, illegal length parameter would be -# returned in SELECT * - -CREATE TABLE t1 ( -a VARBINARY(40) NOT NULL, -b VARCHAR (256) CHARACTER SET UTF8 NOT NULL, -c VARCHAR(256) CHARACTER SET UTF8 NOT NULL, -PRIMARY KEY (b,c)) ENGINE=ndbcluster; -INSERT INTO t1 VALUES -("a","ab","abc"),("b","abc","abcd"),("c","abc","ab"),("d","ab","ab"),("e","abc","abc"); -SELECT * FROM t1 ORDER BY a; -DROP TABLE t1; - -# delete -create table t1 (a int not null primary key, b int not null) engine=ndb; -create table t2 (a int not null primary key, b int not null) engine=ndb; -insert into t1 values (1,10), (2,20), (3,30); -insert into t2 values (1,10), (2,20), (3,30); -select * from t1 order by a; -delete from t1 where a > 0 order by a desc limit 1; -select * from t1 order by a; -delete from t1,t2 using t1,t2 where t1.a = t2.a; -select * from t2 order by a; -drop table t1,t2; - -# insert ignore -create table t1 (a int not null primary key, b int not null) engine=ndb; -insert into t1 values (1,10), (2,20), (3,30); ---error ER_DUP_ENTRY -insert into t1 set a=1, b=100; -insert ignore into t1 set a=1, b=100; -select * from t1 order by a; -insert into t1 set a=1, b=1000 on duplicate key update b=b+1; -select * from t1 order by a; -drop table t1; - -# update -create table t1 (a int not null primary key, b int not null) engine=ndb; -create table t2 (c int not null primary key, d int not null) engine=ndb; -insert into t1 values (1,10), (2,10), (3,30), (4, 30); -insert into t2 values (1,10), (2,10), (3,30), (4, 30); ---error ER_DUP_ENTRY -update t1 set a = 1 where a = 3; -select * from t1 order by a; -update t1 set b = 1 where a > 1 order by a desc limit 1; -select * from t1 order by a; ---error ER_DUP_ENTRY -update t1,t2 set a = 1, c = 1 where a = 3 and c = 3; -select * from t1 order by a; -update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3; -select * from t1 order by a; -drop table t1,t2; - -# -# Bug#31635 -# -create table t1 (a varchar(100) primary key, b varchar(100)) engine = NDB; -insert into t1 values - ('a', 'a'),('b','b'),('c', 'c'),('aa', 'aa'),('bb', 'bb'),('cc', 'cc'); -replace into t1 values ('a', '-a'); -replace into t1 values ('b', '-b'); -replace into t1 values ('c', '-c'); - -replace into t1 values ('aa', '-aa'); -replace into t1 values ('bb', '-bb'); -replace into t1 values ('cc', '-cc'); - -replace into t1 values ('aaa', '-aaa'); -replace into t1 values ('bbb', '-bbb'); -replace into t1 values ('ccc', '-ccc'); -select * from t1 order by 1,2; -drop table t1; - -# End of 5.0 tests ---echo End of 5.0 tests diff --git a/mysql-test/t/ndb_blob.test b/mysql-test/t/ndb_blob.test deleted file mode 100644 index 32699017c03..00000000000 --- a/mysql-test/t/ndb_blob.test +++ /dev/null @@ -1,492 +0,0 @@ ---source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1; -drop database if exists test2; ---enable_warnings - -# -# Minimal NDB blobs test. -# -# On NDB API level there is an extensive test program "testBlobs". -# A prerequisite for this handler test is that "testBlobs" succeeds. -# - -# -- general test starts -- - -# make test harder with autocommit off -set autocommit=0; - -create table t1 ( - a int not null primary key, - b text not null, - c int not null, - d longblob, - key (c) -) engine=ndbcluster; - -# -- values -- - -# x0 size 256 (current inline size) -set @x0 = '01234567012345670123456701234567'; -set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0); - -# b1 length 2000+256 (blob part aligned) -set @b1 = 'b1'; -set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); -set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); -set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); -set @b1 = concat(@b1,@x0); -# d1 length 3000 -set @d1 = 'dd1'; -set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); -set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); -set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); - -# b2 length 20000 -set @b2 = 'b2'; -set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); -set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); -set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); -set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); -# d2 length 30000 -set @d2 = 'dd2'; -set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); -set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); -set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); -set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); - -select length(@x0),length(@b1),length(@d1) from dual; -select length(@x0),length(@b2),length(@d2) from dual; - -# -- pk ops -- - -insert into t1 values(1,@b1,111,@d1); -insert into t1 values(2,@b2,222,@d2); -commit; -explain select * from t1 where a = 1; - -# pk read -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 where a=1; -select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) -from t1 where a=2; - -# pk update -update t1 set b=@b2,d=@d2 where a=1; -update t1 set b=@b1,d=@d1 where a=2; -commit; -select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) -from t1 where a=1; -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 where a=2; - -# pk update -update t1 set b=concat(b,b),d=concat(d,d) where a=1; -update t1 set b=concat(b,b),d=concat(d,d) where a=2; -commit; -select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) -from t1 where a=1; -select a,length(b),substr(b,1+4*900,2),length(d),substr(d,1+6*900,3) -from t1 where a=2; - -# pk update to null -update t1 set d=null where a=1; -commit; -select a from t1 where d is null; - -# bug#24028 - does not occur on MySQL level -# bug#17986 - not seen by us anymore but could show as warning here -delete from t1 where a=45567; -commit; - -# pk delete -delete from t1 where a=1; -delete from t1 where a=2; -commit; -select count(*) from t1; - -# -- replace ( bug-6018 ) -- - -# insert -replace t1 set a=1,b=@b1,c=111,d=@d1; -replace t1 set a=2,b=@b2,c=222,d=@d2; -commit; -explain select * from t1 where a = 1; - -# pk read -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 where a=1; -select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) -from t1 where a=2; - -# update -replace t1 set a=1,b=@b2,c=111,d=@d2; -replace t1 set a=2,b=@b1,c=222,d=@d1; -commit; -select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) -from t1 where a=1; -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 where a=2; - -# update -replace t1 set a=1,b=concat(@b2,@b2),c=111,d=concat(@d2,@d2); -replace t1 set a=2,b=concat(@b1,@b1),c=222,d=concat(@d1,@d1); -commit; -select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) -from t1 where a=1; -select a,length(b),substr(b,1+4*900,2),length(d),substr(d,1+6*900,3) -from t1 where a=2; - -# update to null -replace t1 set a=1,b='xyz',c=111,d=null; -commit; -select a,b from t1 where d is null; - -# pk delete -delete from t1 where a=1; -delete from t1 where a=2; -commit; -select count(*) from t1; - -# -- hash index ops -- - -insert into t1 values(1,@b1,111,@d1); -insert into t1 values(2,@b2,222,@d2); -commit; -explain select * from t1 where c = 111; - -# hash key read -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 where c=111; -select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) -from t1 where c=222; - -# hash key update -update t1 set b=@b2,d=@d2 where c=111; -update t1 set b=@b1,d=@d1 where c=222; -commit; -select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) -from t1 where c=111; -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 where c=222; - -# hash key update to null -update t1 set d=null where c=111; -commit; -select a from t1 where d is null; - -# hash key delete -delete from t1 where c=111; -delete from t1 where c=222; -commit; -select count(*) from t1; - -# -- table scan ops, short values -- - -insert into t1 values(1,'b1',111,'dd1'); -insert into t1 values(2,'b2',222,'dd2'); -insert into t1 values(3,'b3',333,'dd3'); -insert into t1 values(4,'b4',444,'dd4'); -insert into t1 values(5,'b5',555,'dd5'); -insert into t1 values(6,'b6',666,'dd6'); -insert into t1 values(7,'b7',777,'dd7'); -insert into t1 values(8,'b8',888,'dd8'); -insert into t1 values(9,'b9',999,'dd9'); -commit; -explain select * from t1; - -# table scan read -select * from t1 order by a; - -# table scan update -update t1 set b=concat(a,'x',b),d=concat(a,'x',d); -commit; -select * from t1 order by a; - -# table scan delete -delete from t1; -commit; -select count(*) from t1; - -# -- table scan ops, long values -- - -insert into t1 values(1,@b1,111,@d1); -insert into t1 values(2,@b2,222,@d2); -commit; -explain select * from t1; - -# table scan read -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 order by a; - -# table scan update -update t1 set b=concat(b,b),d=concat(d,d); -commit; -select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) -from t1 order by a; - -# table scan delete -delete from t1; -commit; -select count(*) from t1; - -# -- range scan ops, short values -- - -insert into t1 values(1,'b1',111,'dd1'); -insert into t1 values(2,'b2',222,'dd2'); -insert into t1 values(3,'b3',333,'dd3'); -insert into t1 values(4,'b4',444,'dd4'); -insert into t1 values(5,'b5',555,'dd5'); -insert into t1 values(6,'b6',666,'dd6'); -insert into t1 values(7,'b7',777,'dd7'); -insert into t1 values(8,'b8',888,'dd8'); -insert into t1 values(9,'b9',999,'dd9'); -commit; -explain select * from t1 where c >= 100 order by a; - -# range scan read -select * from t1 where c >= 100 order by a; - -# range scan update -update t1 set b=concat(a,'x',b),d=concat(a,'x',d) -where c >= 100; -commit; -select * from t1 where c >= 100 order by a; - -# range scan delete -delete from t1 where c >= 100; -commit; -select count(*) from t1; - -# -- range scan ops, long values -- - -insert into t1 values(1,@b1,111,@d1); -insert into t1 values(2,@b2,222,@d2); -commit; -explain select * from t1 where c >= 100 order by a; - -# range scan read -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 where c >= 100 order by a; - -# range scan update -update t1 set b=concat(b,b),d=concat(d,d); -commit; -select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) -from t1 where c >= 100 order by a; - -# range scan delete -delete from t1 where c >= 100; -commit; -select count(*) from t1; - -# -- rollback -- - -insert into t1 values(1,@b1,111,@d1); -insert into t1 values(2,@b2,222,@d2); -# 626 -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 where a = 0; -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 where a = 1; -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 where a = 2; -select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) -from t1 order by a; -rollback; -select count(*) from t1; - -# -- alter table and multi db -- - -insert into t1 values(1,'b1',111,'dd1'); -insert into t1 values(2,'b2',222,'dd2'); -insert into t1 values(3,'b3',333,'dd3'); -insert into t1 values(4,'b4',444,'dd4'); -insert into t1 values(5,'b5',555,'dd5'); -insert into t1 values(6,'b6',666,'dd6'); -insert into t1 values(7,'b7',777,'dd7'); -insert into t1 values(8,'b8',888,'dd8'); -insert into t1 values(9,'b9',999,'dd9'); -commit; - -select * from t1 order by a; -alter table t1 add x int; -select * from t1 order by a; -alter table t1 drop x; -select * from t1 order by a; - -create database test2; -use test2; - -CREATE TABLE t2 ( - a bigint unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned -) engine=ndbcluster; - -insert into t2 values (1,1,1),(2,2,2); -select * from test.t1,t2 where test.t1.a = t2.a order by test.t1.a; - -drop table t2; -use test; - -select * from t1 order by a; -alter table t1 add x int; -select * from t1 order by a; -alter table t1 drop x; -select * from t1 order by a; - -# -- end general test -- - -drop table t1; -drop database test2; - -# -- bug-5252 tinytext crashes + no-commit result + replace -- - -set autocommit=0; -create table t1 ( - a int not null primary key, - b tinytext -) engine=ndbcluster; - -insert into t1 values(1, 'x'); -update t1 set b = 'y'; -select * from t1; -delete from t1; -select * from t1; -commit; -replace t1 set a=2, b='y'; -select * from t1; -delete from t1; -select * from t1; -drop table t1; - -# -- bug-5013 insert empty string to text -- - -set autocommit=0; -create table t1 ( - a int not null primary key, - b text not null -) engine=ndbcluster; - -insert into t1 values(1, ''); -select * from t1; -commit; -drop table t1; - -# -- bug #5349 -- -set autocommit=1; -use test; -CREATE TABLE t1 ( - a int, - b text, - PRIMARY KEY (a) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -INSERT INTO t1 VALUES -(1,'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); -INSERT INTO t1 VALUES -(2,'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'); - -select * from t1 order by a; -alter table t1 engine=ndb; -select * from t1 order by a; - -# -- bug #5872 -- -set autocommit=1; -alter table t1 engine=myisam; -select * from t1 order by a; -drop table t1; - -# -- bug #7340 -- -create table t1 ( - id int(11) unsigned primary key NOT NULL auto_increment, - msg text NOT NULL -) engine=ndbcluster default charset=utf8; -insert into t1 (msg) values( -'Tries to validate (8 byte length + inline bytes) as UTF8 :( -Fast fix: removed validation for Text. It is not yet indexable -so bad data will not crash kernel.'); -select * from t1; -drop table t1; - -# -- bug #19201 -create table t1 ( - a int primary key not null auto_increment, - b text -) engine=ndbcluster; ---disable_query_log -set autocommit=1; -# more rows than batch size (64) -# for this bug no blob parts would be necessary -let $1 = 500; -while ($1) -{ - insert into t1 (b) values (repeat('x',4000)); - dec $1; -} ---enable_query_log -select count(*) from t1; -truncate t1; -select count(*) from t1; -drop table t1; - -# -- bug#19956 - var* key, complex key - -create table t1 ( - a varchar(40) not null, - b mediumint not null, - t text, - c varchar(2) not null, - d bigint not null, - primary key (a,b,c), - key (c,a), - unique key (d) -) engine=ndb; - ---disable_query_log -set @s1 = 'rggurloniukyehuxdbfkkyzlceixzrehqhvxvxbpwizzvjzpucqmzrhzxzfau'; -set @s2 = 'ykyymbzqgqlcjhlhmyqelfoaaohvtbekvifukdtnvcrrjveevfakxarxexomz'; -set @s3 = 'dbnfqyzgtqxalcrwtfsqabknvtfcbpoonxsjiqvmhnfikxxhcgoexlkoezvah'; -set @v1 = repeat(@s1,123); -set @v2 = repeat(@s2,234); -set @v3 = repeat(@s3,345); -set @v4 = NULL; ---enable_query_log - -insert into t1 (a,b,c,d,t) values ('a',1110,'a',1,@v1); -insert into t1 (a,b,c,d,t) values ('b',1110,'a',2,@v2); -insert into t1 (a,b,c,d,t) values ('a',1110,'b',3,@v3); -insert into t1 (a,b,c,d,t) values ('b',1110,'b',4,@v4); -select a,b,c,d,sha1(t) from t1 order by c,a; - -select a,b,c,d,sha1(t) from t1 where a='a' and b=1110 and c='a'; -select a,b,c,d,sha1(t) from t1 where a='a' and b=1110 and c='b'; - -update t1 set t=@v4 where a='b' and b=1110 and c='a'; -update t1 set t=@v2 where a='b' and b=1110 and c='b'; -select a,b,c,d,sha1(t) from t1 order by c,a; - -update t1 set t=@v2 where d=2; -update t1 set t=@v4 where d=4; -select a,b,c,d,sha1(t) from t1 order by c,a; - -update t1 set t=@v4 where a='b' and c='a'; -update t1 set t=@v2 where a='b' and c='b'; -select a,b,c,d,sha1(t) from t1 order by c,a; - -update t1 set t=@v2 where b+d=1112; -update t1 set t=@v4 where b+d=1114; -select a,b,c,d,sha1(t) from t1 order by c,a; - -delete from t1 where a='a' and b=1110 and c='a'; -delete from t1 where a='b' and c='a'; -delete from t1 where d=3; -delete from t1 where b+d=1114; -select count(*) from t1; - -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_bug26793.test b/mysql-test/t/ndb_bug26793.test deleted file mode 100644 index f35d8808c1a..00000000000 --- a/mysql-test/t/ndb_bug26793.test +++ /dev/null @@ -1,35 +0,0 @@ --- source include/have_ndb.inc - ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - -CREATE TABLE `test` ( -`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , -`t` VARCHAR( 10 ) NOT NULL -) ENGINE = ndbcluster; - -# Add user1@localhost with a specific password -# and connect as that user -GRANT USAGE ON *.* TO user1@localhost IDENTIFIED BY 'pass'; -connect (user1,localhost,user1,pass,*NO-ONE*); - -# Run the query 100 times -disable_query_log; -disable_result_log; -let $i= 100; -while ($i) -{ -select count(*) from information_schema.tables union all select count(*) from information_schema.tables union all select count(*) from information_schema.tables; -dec $i; -} -enable_query_log; -enable_result_log; - -disconnect user1; - -# Switch back to the default connection and cleanup -connection default; -DROP TABLE `test`.`test`; -drop user user1@localhost; - diff --git a/mysql-test/t/ndb_bug31477.test b/mysql-test/t/ndb_bug31477.test deleted file mode 100644 index 41c519e56fd..00000000000 --- a/mysql-test/t/ndb_bug31477.test +++ /dev/null @@ -1,109 +0,0 @@ ---source include/have_ndb.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -# setup - -connect (con1,localhost,root,,test); -connect (con2,localhost,root,,test); - -# unique index -connection con1; -create table t1(a int primary key, b int, c int, unique(b)) engine = ndb; -insert into t1 values (2,2,2); -insert into t1 values (3,3,3); -insert into t1 values (4,4,4); - -begin; -insert into t1 values (1,1,1); - -connection con2; -begin; ---error 1205 -update t1 set c = 2 where b = 1; -rollback; - -connection con1; -rollback; -drop table t1; -# ordered index - -connection con1; -create table t1(a int primary key, b int, c int, key(b)) engine = ndb; -insert into t1 values (2,2,2); -insert into t1 values (3,3,3); -insert into t1 values (4,4,4); - -begin; -insert into t1 values (1,1,1); - -connection con2; -begin; ---error 1205 -update t1 set c = 2 where b = 1; -rollback; - -connection con1; -rollback; -drop table t1; - -# multiple versions - ---echo --con1 -connection con1; -create table t1(a int primary key, b int, c int, key(b)) engine = ndb; -insert into t1 values (1,1,1); -insert into t1 values (2,2,2); -insert into t1 values (3,3,3); -insert into t1 values (4,4,4); - -begin; -update t1 set c = 10 where a = 1; -update t1 set c = 20 where a = 1; -update t1 set c = 30 where a = 1; - ---echo --con1 c=30 -select * from t1 where b >= 1 order by b; ---echo --con2 c=1 -connection con2; -select * from t1 where b >= 1 order by b; - ---echo --con1 -connection con1; -delete from t1 where a = 1; - ---echo --con1 c=none -select * from t1 where b >= 1 order by b; ---echo --con2 c=1 -connection con2; -select * from t1 where b >= 1 order by b; - ---echo --con1 -connection con1; -commit; - ---echo --con1 c=none -select * from t1 where b >= 1 order by b; ---echo --con2 c=none -connection con2; -select * from t1 where b >= 1 order by b; - ---echo --con1 -connection con1; -begin; -insert into t1 values (1,1,1); -update t1 set c = 10 where a = 1; -update t1 set c = 20 where a = 1; -update t1 set c = 30 where a = 1; - ---echo --con1 c=30 -select * from t1 where b >= 1 order by b; ---echo --con2 c=none -connection con2; -select * from t1 where b >= 1 order by b; - -# this fails with "no such table" via con2 ??? -connection con1; -drop table t1; diff --git a/mysql-test/t/ndb_cache.test b/mysql-test/t/ndb_cache.test deleted file mode 100644 index 9c299b61c24..00000000000 --- a/mysql-test/t/ndb_cache.test +++ /dev/null @@ -1,122 +0,0 @@ --- source include/have_query_cache.inc --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -# Turn on and reset query cache -set GLOBAL query_cache_type=on; -set GLOBAL query_cache_size=1355776; -reset query cache; -flush status; - -# Create test table in NDB -CREATE TABLE t1 ( pk int not null primary key, - a int, b int not null, c varchar(20)) ENGINE=ndbcluster; -insert into t1 value (1, 2, 3, 'First row'); - -# Perform one query which should be inerted in query cache -select * from t1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -# Perform the same query and make sure the query cache is hit -select * from t1; -show status like "Qcache_hits"; - -# Update the table and make sure the correct data is returned -update t1 set a=3 where pk=1; -select * from t1; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -# Insert a new record and make sure the correct data is returned -insert into t1 value (2, 7, 8, 'Second row'); -insert into t1 value (4, 5, 6, 'Fourth row'); -select * from t1 order by pk; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -select * from t1 order by pk; -show status like "Qcache_hits"; - -# Perform a "new" query and make sure the query cache is not hit -select * from t1 where b=3; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits"; - -# Same query again... -select * from t1 where b=3; -show status like "Qcache_hits"; - -# Delete from the table -delete from t1 where c='Fourth row'; -show status like "Qcache_queries_in_cache"; -select * from t1 where b=3; -show status like "Qcache_hits"; - -# Start another connection and check that the query cache is hit -connect (con1,localhost,root,,); -connection con1; -use test; -select * from t1 order by pk; -select * from t1 where b=3; -show status like "Qcache_hits"; - -# Update the table and switch to other connection -update t1 set a=4 where b=3; -connect (con2,localhost,root,,); -connection con2; -use test; -show status like "Qcache_queries_in_cache"; -select * from t1 order by pk desc; -select * from t1 order by pk desc; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con1; -select * from t1 order by pk desc; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -# Use transactions and make sure the query cache is not updated until -# transaction is commited -begin; -update t1 set a=5 where pk=1; -# Note!! the below test shows that table is invalidated -# before transaction is committed -# TODO Fix so that cache is not invalidated HERE! -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con2; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con1; -commit; -# TODO Here query is invalidated once again, commit count in NDB has changed -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con2; -select * from t1 order by pk desc; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con1; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -drop table t1; - -show status like "Qcache_queries_in_cache"; - -SET GLOBAL query_cache_size=0; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_cache2.test b/mysql-test/t/ndb_cache2.test deleted file mode 100644 index 352b01ef73f..00000000000 --- a/mysql-test/t/ndb_cache2.test +++ /dev/null @@ -1,361 +0,0 @@ --- source include/have_query_cache.inc --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1, t2, t3, t4, t5; ---enable_warnings - - -# Turn on and reset query cache -set GLOBAL query_cache_type=on; -set GLOBAL query_cache_size=1355776; -# Turn on thread that will fetch commit count for open tables -set GLOBAL ndb_cache_check_time=100; -reset query cache; -flush status; - -# Create test tables in NDB -CREATE TABLE t1 ( - pk int not null primary key, - a1 int, - b1 int not null, - c1 varchar(20) -) ENGINE=ndb; -CREATE TABLE t2 ( - pk int not null primary key, - a2 int, - b2 int not null -) ENGINE=ndb; -CREATE TABLE t3 ( - pk int not null primary key, - a3 int, - b3 int not null, - c3 int not null, - d3 varchar(20) -) ENGINE=ndb; -CREATE TABLE t4 ( - a4 int, - b4 int not null, - c4 char(20) -) ENGINE=ndbcluster; -CREATE TABLE t5 ( - pk int not null primary key, - a5 int, - b5 int not null, - c5 varchar(255) -) ENGINE=ndbcluster; -insert into t1 value (1, 2, 3, 'First row'); -insert into t2 value (1, 2, 3); -insert into t3 value (1, 2, 3, 4, '3 - First row'); -insert into t4 value (2, 3, '4 - First row'); -insert into t5 value (1, 2, 3, '5 - First row'); - -# Perform one query which should be inserted in query cache -select * from t1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -# Perform the same query and make sure the query cache is hit -select * from t1; -show status like "Qcache_hits"; - -# Update the table and make sure the correct data is returned -update t1 set a1=3 where pk=1; -select * from t1; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -# Insert a new record and make sure the correct data is returned -insert into t1 value (2, 7, 8, 'Second row'); -insert into t1 value (4, 5, 6, 'Fourth row'); -select * from t1 order by pk desc; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -select * from t1 order by pk desc; -show status like "Qcache_hits"; - -# Perform a "new" query and make sure the query cache is not hit -select * from t1 where b1=3; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits"; - -# Same query again... -select * from t1 where b1=3; -show status like "Qcache_hits"; - -# Delete from the table -delete from t1 where c1='Fourth row'; -show status like "Qcache_queries_in_cache"; -select * from t1 where b1=3; -show status like "Qcache_hits"; - -# Start another connection and check that the query cache is hit -connect (con1,localhost,root,,); -connection con1; -use test; -select * from t1 order by pk desc; -select * from t1 where b1=3; -show status like "Qcache_hits"; - -# Update the table and switch to other connection -update t1 set a1=4 where b1=3; -connect (con2,localhost,root,,); -connection con2; -use test; -show status like "Qcache_queries_in_cache"; -select * from t1 order by pk desc; -select * from t1 order by pk desc; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con1; -select * from t1 order by pk desc; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -# Load all tables into cache -select * from t2; -select * from t3; -select * from t4; -select * from t5; -show status like "Qcache_queries_in_cache"; - -##################################################################### -# Start transaction and perform update -# Switch to other transaction and check that update does not show up -# Switch back and commit transaction -# Switch to other transaction and check that update shows up -##################################################################### -connection con1; -flush status; -begin; -update t1 set a1=5 where pk=1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con2; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con1; -commit; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con2; -select * from t1 order by pk desc; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con1; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -##################################################################### -# Start transaction and perform update -# Switch to other transaction and check that update does not show up -# Switch back, perform selects and commit transaction -# Switch to other transaction and check that update shows up -##################################################################### -connection con1; -flush status; -begin; -update t1 set a1=6 where pk=1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con2; -select * from t1 order by pk desc; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con1; -# The two queries below will not hit cache since transaction is ongoing -select * from t1 order by pk desc; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -commit; - -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con2; -select * from t1 order by pk desc; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con1; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -##################################################################### -# Start transaction and perform insert -# Switch to other transaction and check that insert does not show up -# Switch back, perform selects and commit transaction -# Switch to other transaction and check that update shows up -##################################################################### -connection con1; -flush status; -begin; -insert into t1 set pk=5, a1=6, b1=3, c1="New row"; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con2; -select * from t1 where pk=5; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con1; -# The below four queries will not be cached, trans is ongoing -select * from t1 where pk=5; -select * from t1 where pk=5; -select * from t1 order by pk desc; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -commit; - -connection con2; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -connection con1; - -##################################################################### -# Start transaction and perform delete -# Switch to other transaction and check that delete does not show up -# Switch back, perform selects and commit transaction -# Switch to other transaction and check that update shows up -##################################################################### -connection con1; -flush status; -begin; -delete from t1 where pk=2; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con2; -select * from t1 where pk=2; -select * from t1 order by pk desc; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con1; -# The below four queries will not be cached, trans is ongoing -select * from t1 where pk=2; -select * from t1 order by pk desc; -select * from t1 order by pk desc; -select * from t1 where pk=2; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -commit; - -connection con2; -select * from t1 order by pk desc; -select * from t1 where pk=2; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -connection con1; - -##################################################################### -# Start a transaction which updates all tables -# Switch to other transaction and check updates does not show up -# Switch back, perform selects and commit transaction -# Switch to other transaction and check that update shows up -##################################################################### -flush status; -begin; -update t1 set a1=9 where pk=1; -update t2 set a2=9 where pk=1; -update t3 set a3=9 where pk=1; -update t4 set a4=9 where a4=2; -update t5 set a5=9 where pk=1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con2; -select * from t1 order by pk desc; -select * from t2; -select * from t3; -select * from t4; -select * from t5; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -connection con1; -# The below five queries will not be cached, trans is ongoing -select * from t1 order by pk desc; -select * from t1 order by pk desc; -select * from t2; -select * from t3; -select * from t4; -select * from t5; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -commit; - -connection con2; -select * from t1 order by pk desc; -select * from t2; -select * from t3; -select * from t4; -select * from t5; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -connection con1; -select * from t1 order by pk desc; -select * from t2; -select * from t3; -select * from t4; -select * from t5; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -select * from t1 order by pk desc; -select * from t2; -select * from t3; -select * from t4; -select * from t5; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -connection con2; -select * from t1 order by pk desc; -select * from t2; -select * from t3; -select * from t4; -select * from t5; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -drop table t1, t2, t3, t4, t5; - -# There should be no queries in cache, when tables have been dropped -show status like "Qcache_queries_in_cache"; - -SET GLOBAL query_cache_size=0; -SET GLOBAL ndb_cache_check_time=0; - - diff --git a/mysql-test/t/ndb_cache_multi.test b/mysql-test/t/ndb_cache_multi.test deleted file mode 100644 index beb8e4bc2ac..00000000000 --- a/mysql-test/t/ndb_cache_multi.test +++ /dev/null @@ -1,65 +0,0 @@ --- source include/have_query_cache.inc --- source include/have_ndb.inc --- source include/have_multi_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1, t2; ---enable_warnings - - -# Turn on and reset query cache on server1 -connection server1; -set GLOBAL query_cache_type=on; -set GLOBAL query_cache_size=1355776; -reset query cache; -flush status; - -# Turn on and reset query cache on server2 -connection server2; -set GLOBAL query_cache_type=on; -set GLOBAL query_cache_size=1355776; -reset query cache; -flush status; - - - -# Create test tables in NDB and load them into cache -# on server1 -connection server1; -create table t1 (a int) engine=ndbcluster; -create table t2 (a int) engine=ndbcluster; -insert into t1 value (2); -insert into t2 value (3); -select * from t1; -select * from t2; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - - -# Connect server2, load table in to cache, then update the table -connection server2; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -select * from t1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -update t1 set a=3 where a=2; - -# Connect to server1 and check that cache is invalidated -# and correct data is returned -connection server1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -select * from t1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - -drop table t1, t2; - - diff --git a/mysql-test/t/ndb_cache_multi2.test b/mysql-test/t/ndb_cache_multi2.test deleted file mode 100644 index 4abb537624a..00000000000 --- a/mysql-test/t/ndb_cache_multi2.test +++ /dev/null @@ -1,95 +0,0 @@ --- source include/have_query_cache.inc --- source include/have_ndb.inc --- source include/have_multi_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1, t2; ---enable_warnings - - -# Turn on and reset query cache on server1 -connection server1; -echo == Connected to server1 ==; -set GLOBAL query_cache_type=on; -set GLOBAL query_cache_size=1355776; -set GLOBAL ndb_cache_check_time=1; -reset query cache; -flush status; - -# Turn on and reset query cache on server2 -connection server2; -echo == Connected to server2 ==; -set GLOBAL query_cache_type=on; -set GLOBAL query_cache_size=1355776; -set GLOBAL ndb_cache_check_time=1; -reset query cache; -flush status; - -# Create test tables in NDB and load them into cache -# on server1 -connection server1; -echo == Connected to server1 ==; -create table t1 (a int) engine=ndbcluster; -create table t2 (a int) engine=ndbcluster; -insert into t1 value (2); -insert into t2 value (3); -select * from t1; -# Run the check query once to load it into qc on server1 -select a != 3 from t1; -select * from t2; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; - - -# Connect server2, load table in to cache, then update the table -connection server2; -echo == Connected to server2 ==; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -select * from t1; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_inserts"; -show status like "Qcache_hits"; -update t1 set a=3 where a=2; - -# Connect to server1 and check that cache is invalidated -# and correct data is returned -connection server1; -echo == Connected to server1 ==; - -# Loop and wait for max 10 seconds until query cache thread -# has invalidated the cache and the column a in t1 is equal to 3 -let $retries=20; -while (`select a != 3 from t1`) -{ - dec $retries; - if (!$retries) - { - The query_cache thread failed to invalidate query_cache in 10 seconds; - } - sleep 0.5; -} - -# Select from t1 one last time for the result file -# Column a should be 3 -select * from t1; - -# There should now be three queries in the cache -show status like "Qcache_queries_in_cache"; - -drop table t1, t2; - -# Turn off and reset query cache on server1 and server2 -connection server1; -set GLOBAL query_cache_size=0; -set GLOBAL ndb_cache_check_time=0; -reset query cache; -flush status; -connection server2; -set GLOBAL query_cache_size=0; -set GLOBAL ndb_cache_check_time=0; -reset query cache; -flush status; diff --git a/mysql-test/t/ndb_charset.test b/mysql-test/t/ndb_charset.test deleted file mode 100644 index 5941e5750db..00000000000 --- a/mysql-test/t/ndb_charset.test +++ /dev/null @@ -1,255 +0,0 @@ ---source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -# -# Minimal NDB charset test. -# - -# pk - binary - -create table t1 ( - a char(3) character set latin1 collate latin1_bin primary key -) engine=ndb; -# ok -insert into t1 values('aAa'); -insert into t1 values('aaa'); -insert into t1 values('AAA'); -# 3 -select * from t1 order by a; -# 1 -select * from t1 where a = 'aAa'; -# 1 -select * from t1 where a = 'aaa'; -# 0 -select * from t1 where a = 'AaA'; -# 1 -select * from t1 where a = 'AAA'; -drop table t1; - -# pk - case insensitive - -create table t1 ( - a char(3) character set latin1 collate latin1_swedish_ci primary key -) engine=ndb; -# ok -insert into t1 values('aAa'); -# fail ---error 1062 -insert into t1 values('aaa'); ---error 1062 -insert into t1 values('AAA'); -# 1 -select * from t1 order by a; -# 1 -select * from t1 where a = 'aAa'; -# 1 -select * from t1 where a = 'aaa'; -# 1 -select * from t1 where a = 'AaA'; -# 1 -select * from t1 where a = 'AAA'; -drop table t1; - -# pk - varchar - -create table t1 ( - a varchar(20) character set latin1 collate latin1_swedish_ci primary key -) engine=ndb; -# -insert into t1 values ('A'),('b '),('C '),('d '),('E'),('f'); --- error 1062 -insert into t1 values('b'); --- error 1062 -insert into t1 values('a '); -# -select a,length(a) from t1 order by a; -select a,length(a) from t1 order by a desc; -select * from t1 where a = 'a'; -select * from t1 where a = 'a '; -select * from t1 where a = 'd'; -drop table t1; - -# unique hash index - binary - -create table t1 ( - p int primary key, - a char(3) character set latin1 collate latin1_bin not null, - unique key(a) -) engine=ndb; -# ok -insert into t1 values(1, 'aAa'); -insert into t1 values(2, 'aaa'); -insert into t1 values(3, 'AAA'); -# 3 -select * from t1 order by p; -# 1 -select * from t1 where a = 'aAa'; -# 1 -select * from t1 where a = 'aaa'; -# 0 -select * from t1 where a = 'AaA'; -# 1 -select * from t1 where a = 'AAA'; -drop table t1; - -# unique hash index - case insensitive - -create table t1 ( - p int primary key, - a char(3) character set latin1 collate latin1_swedish_ci not null, - unique key(a) -) engine=ndb; -# ok -insert into t1 values(1, 'aAa'); -# fail ---error 1062 -insert into t1 values(2, 'aaa'); ---error 1062 -insert into t1 values(3, 'AAA'); -# 1 -select * from t1 order by p; -# 1 -select * from t1 where a = 'aAa'; -# 1 -select * from t1 where a = 'aaa'; -# 1 -select * from t1 where a = 'AaA'; -# 1 -select * from t1 where a = 'AAA'; -drop table t1; - -# unique hash index - varchar - -create table t1 ( - p int primary key, - a varchar(20) character set latin1 collate latin1_swedish_ci not null, - unique key(a) -) engine=ndb; -# -insert into t1 values (1,'A'),(2,'b '),(3,'C '),(4,'d '),(5,'E'),(6,'f'); --- error 1062 -insert into t1 values(99,'b'); --- error 1062 -insert into t1 values(99,'a '); -# -select a,length(a) from t1 order by a; -select a,length(a) from t1 order by a desc; -select * from t1 where a = 'a'; -select * from t1 where a = 'a '; -select * from t1 where a = 'd'; -drop table t1; - -# ordered index - binary - -create table t1 ( - p int primary key, - a char(3) character set latin1 collate latin1_bin not null, - index(a) -) engine=ndb; -# ok -insert into t1 values(1, 'aAa'); -insert into t1 values(2, 'aaa'); -insert into t1 values(3, 'AAA'); -insert into t1 values(4, 'aAa'); -insert into t1 values(5, 'aaa'); -insert into t1 values(6, 'AAA'); -# 6 -select * from t1 order by p; -# plan -explain select * from t1 where a = 'zZz' order by p; -# 2 -select * from t1 where a = 'aAa' order by p; -# 2 -select * from t1 where a = 'aaa' order by p; -# 0 -select * from t1 where a = 'AaA' order by p; -# 2 -select * from t1 where a = 'AAA' order by p; -drop table t1; - -# ordered index - case insensitive - -create table t1 ( - p int primary key, - a char(3) character set latin1 collate latin1_swedish_ci not null, - index(a) -) engine=ndb; -# ok -insert into t1 values(1, 'aAa'); -insert into t1 values(2, 'aaa'); -insert into t1 values(3, 'AAA'); -insert into t1 values(4, 'aAa'); -insert into t1 values(5, 'aaa'); -insert into t1 values(6, 'AAA'); -# 6 -select * from t1 order by p; -# plan -explain select * from t1 where a = 'zZz' order by p; -# 6 -select * from t1 where a = 'aAa' order by p; -# 6 -select * from t1 where a = 'aaa' order by p; -# 6 -select * from t1 where a = 'AaA' order by p; -# 6 -select * from t1 where a = 'AAA' order by p; -drop table t1; - -# ordered index - varchar - -create table t1 ( - p int primary key, - a varchar(20) character set latin1 collate latin1_swedish_ci not null, - index(a, p) -) engine=ndb; -# -insert into t1 values (1,'A'),(2,'b '),(3,'C '),(4,'d '),(5,'E'),(6,'f'); -insert into t1 values (7,'a'),(8,'B '),(9,'c '),(10,'D'),(11,'e'),(12,'F '); -select p,a,length(a) from t1 order by a, p; -select * from t1 where a = 'a ' order by a desc, p desc; -select * from t1 where a >= 'D' order by a, p; -select * from t1 where a < 'D' order by a, p; -# -select count(*) from t1 x, t1 y, t1 z where x.a = y.a and y.a = z.a; -drop table t1; - -# minimal multi-byte test -# removed by jonas as this requires a configure --with-extra-charsets -#create table t1 ( -# a char(5) character set ucs2, -# b varchar(7) character set utf8, -# primary key(a, b) -#) engine=ndb; -# -#insert into t1 values -# ('a','A '),('B ','b'),('c','C '),('D','d'),('e ','E'),('F','f '), -# ('A','b '),('b ','C'),('C','d '),('d','E'),('E ','f'), -# ('a','C '),('B ','d'),('c','E '),('D','f'); -#-- error 1062 -#insert into t1 values('d','f'); -# -#select a,b,length(a),length(b) from t1 order by a,b limit 3; -#select a,b,length(a),length(b) from t1 order by a desc, b desc limit 3; -#select a,b,length(a),length(b) from t1 where a='c' and b='c'; -#drop table t1; - -# bug#14007 -create table t1 ( - a char(10) primary key -) engine=ndbcluster default charset=latin1; - -insert into t1 values ('aaabb'); -select * from t1; -replace into t1 set a = 'AAABB'; -select * from t1; -replace into t1 set a = 'aAaBb'; -select * from t1; -replace into t1 set a = 'aaabb'; -select * from t1; -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_condition_pushdown.test b/mysql-test/t/ndb_condition_pushdown.test deleted file mode 100644 index ebfd9c7231a..00000000000 --- a/mysql-test/t/ndb_condition_pushdown.test +++ /dev/null @@ -1,2020 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1,t2; ---enable_warnings - -# -# Test of condition pushdown to storage engine -# -CREATE TABLE t1 ( - auto int(5) unsigned NOT NULL auto_increment, - string char(10), - vstring varchar(10), - bin binary(2), - vbin varbinary(7), - tiny tinyint(4) DEFAULT '0' NOT NULL , - short smallint(6) DEFAULT '1' NOT NULL , - medium mediumint(8) DEFAULT '0' NOT NULL, - long_int int(11) DEFAULT '0' NOT NULL, - longlong bigint(13) DEFAULT '0' NOT NULL, - real_float float(13,1) DEFAULT 0.0 NOT NULL, - real_double double(16,4), - real_decimal decimal(16,4), - utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, - ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, - umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, - ulong int(11) unsigned DEFAULT '0' NOT NULL, - ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, - bits bit(3), - options enum('zero','one','two','three','four') not null, - flags set('zero','one','two','three','four') not null, - date_field date, - year_field year, - time_field time, - date_time datetime, - time_stamp timestamp, - PRIMARY KEY (auto) -) engine=ndb; - -insert into t1 values -(NULL,"aaaa","aaaa",0xAAAA,0xAAAA,-1,-1,-1,-1,-1,1.1,1.1,1.1,1,1,1,1,1, - b'001','one','one', - '1901-01-01','1901', -'01:01:01','1901-01-01 01:01:01',NULL), -(NULL,"bbbb","bbbb",0xBBBB,0xBBBB,-2,-2,-2,-2,-2,2.2,2.2,2.2,2,2,2,2,2, - b'010','two','one,two', - '1902-02-02','1902', -'02:02:02','1902-02-02 02:02:02',NULL), -(NULL,"cccc","cccc",0xCCCC,0xCCCC,-3,-3,-3,-3,-3,3.3,3.3,3.3,3,3,3,3,3, - b'011','three','one,two,three', - '1903-03-03','1903', -'03:03:03','1903-03-03 03:03:03',NULL), -(NULL,"dddd","dddd",0xDDDD,0xDDDD,-4,-4,-4,-4,-4,4.4,4.4,4.4,4,4,4,4,4, - b'100','four','one,two,three,four', - '1904-04-04','1904', -'04:04:04','1904-04-04 04:04:04',NULL); - -CREATE TABLE t2 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NOT NULL, attr2 int unsigned, attr3 VARCHAR(10) ) ENGINE=ndbcluster; - -insert into t2 values (0,0,0, "a"),(1,1,1,"b"),(2,2,NULL,NULL),(3,3,3,"d"),(4,4,4,"e"),(5,5,5,"f"); - -CREATE TABLE t3 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NOT NULL, attr2 bigint unsigned, attr3 tinyint unsigned, attr4 VARCHAR(10) ) ENGINE=ndbcluster; - -insert into t3 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f"); - -CREATE TABLE t4 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NOT NULL, attr2 bigint unsigned, attr3 tinyint unsigned, attr4 VARCHAR(10) , KEY (attr1)) ENGINE=ndbcluster; - -insert into t4 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f"); - -set @old_ecpd = @@session.engine_condition_pushdown; -set engine_condition_pushdown = off; - -# Test all types and compare operators -select auto from t1 where -string = "aaaa" and -vstring = "aaaa" and -bin = 0xAAAA and -vbin = 0xAAAA and -tiny = -1 and -short = -1 and -medium = -1 and -long_int = -1 and -longlong = -1 and -real_float > 1.0 and real_float < 2.0 and -real_double > 1.0 and real_double < 2.0 and -real_decimal > 1.0 and real_decimal < 2.0 and -utiny = 1 and -ushort = 1 and -umedium = 1 and -ulong = 1 and -ulonglong = 1 and -bits = b'001' and -options = 'one' and -flags = 'one' and -date_field = '1901-01-01' and -year_field = '1901' and -time_field = '01:01:01' and -date_time = '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string != "aaaa" and -vstring != "aaaa" and -bin != 0xAAAA and -vbin != 0xAAAA and -tiny != -1 and -short != -1 and -medium != -1 and -long_int != -1 and -longlong != -1 and -(real_float < 1.0 or real_float > 2.0) and -(real_double < 1.0 or real_double > 2.0) and -(real_decimal < 1.0 or real_decimal > 2.0) and -utiny != 1 and -ushort != 1 and -umedium != 1 and -ulong != 1 and -ulonglong != 1 and -bits != b'001' and -options != 'one' and -flags != 'one' and -date_field != '1901-01-01' and -year_field != '1901' and -time_field != '01:01:01' and -date_time != '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string > "aaaa" and -vstring > "aaaa" and -bin > 0xAAAA and -vbin > 0xAAAA and -tiny < -1 and -short < -1 and -medium < -1 and -long_int < -1 and -longlong < -1 and -real_float > 1.1 and -real_double > 1.1 and -real_decimal > 1.1 and -utiny > 1 and -ushort > 1 and -umedium > 1 and -ulong > 1 and -ulonglong > 1 and -bits > b'001' and -(options = 'two' or options = 'three' or options = 'four') and -(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field > '1901-01-01' and -year_field > '1901' and -time_field > '01:01:01' and -date_time > '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string >= "aaaa" and -vstring >= "aaaa" and -bin >= 0xAAAA and -vbin >= 0xAAAA and -tiny <= -1 and -short <= -1 and -medium <= -1 and -long_int <= -1 and -longlong <= -1 and -real_float >= 1.0 and -real_double >= 1.0 and -real_decimal >= 1.0 and -utiny >= 1 and -ushort >= 1 and -umedium >= 1 and -ulong >= 1 and -ulonglong >= 1 and -bits >= b'001' and -(options = 'one' or options = 'two' or options = 'three' or options = 'four') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field >= '1901-01-01' and -year_field >= '1901' and -time_field >= '01:01:01' and -date_time >= '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string < "dddd" and -vstring < "dddd" and -bin < 0xDDDD and -vbin < 0xDDDD and -tiny > -4 and -short > -4 and -medium > -4 and -long_int > -4 and -longlong > -4 and -real_float < 4.4 and -real_double < 4.4 and -real_decimal < 4.4 and -utiny < 4 and -ushort < 4 and -umedium < 4 and -ulong < 4 and -ulonglong < 4 and -bits < b'100' and -(options = 'one' or options = 'two' or options = 'three') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and -date_field < '1904-01-01' and -year_field < '1904' and -time_field < '04:04:04' and -date_time < '1904-04-04 04:04:04' -order by auto; - -select auto from t1 where -string <= "dddd" and -vstring <= "dddd" and -bin <= 0xDDDD and -vbin <= 0xDDDD and -tiny >= -4 and -short >= -4 and -medium >= -4 and -long_int >= -4 and -longlong >= -4 and -real_float <= 4.5 and -real_double <= 4.5 and -real_decimal <= 4.5 and -utiny <= 4 and -ushort <= 4 and -umedium <= 4 and -ulong <= 4 and -ulonglong <= 4 and -bits <= b'100' and -(options = 'one' or options = 'two' or options = 'three' or options = 'four') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field <= '1904-04-04' and -year_field <= '1904' and -time_field <= '04:04:04' and -date_time <= '1904-04-04 04:04:04' -order by auto; - -# Test LIKE/NOT LIKE -select auto from t1 where -string like "b%" and -vstring like "b%" and -bin like concat(0xBB, '%') and -vbin like concat(0xBB, '%') -order by auto; - -select auto from t1 where -string not like "b%" and -vstring not like "b%" and -bin not like concat(0xBB, '%') and -vbin not like concat(0xBB, '%') -order by auto; - -# BETWEEN -select auto from t1 where -(string between "aaaa" and "cccc") and -(vstring between "aaaa" and "cccc") and -(bin between 0xAAAA and 0xCCCC) and -(vbin between 0xAAAA and 0xCCCC) and -(tiny between -3 and -1) and -(short between -3 and -1) and -(medium between -3 and -1) and -(long_int between -3 and -1) and -(longlong between -3 and -1) and -(utiny between 1 and 3) and -(ushort between 1 and 3) and -(umedium between 1 and 3) and -(ulong between 1 and 3) and -(ulonglong between 1 and 3) and -(bits between b'001' and b'011') and -(options between 'one' and 'three') and -(flags between 'one' and 'one,two,three') and -(date_field between '1901-01-01' and '1903-03-03') and -(year_field between '1901' and '1903') and -(time_field between '01:01:01' and '03:03:03') and -(date_time between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') -order by auto; - -select auto from t1 where -("aaaa" between string and string) and -("aaaa" between vstring and vstring) and -(0xAAAA between bin and bin) and -(0xAAAA between vbin and vbin) and -(-1 between tiny and tiny) and -(-1 between short and short) and -(-1 between medium and medium) and -(-1 between long_int and long_int) and -(-1 between longlong and longlong) and -(1 between utiny and utiny) and -(1 between ushort and ushort) and -(1 between umedium and umedium) and -(1 between ulong and ulong) and -(1 between ulonglong and ulonglong) and -(b'001' between bits and bits) and -('one' between options and options) and -('one' between flags and flags) and -('1901-01-01' between date_field and date_field) and -('1901' between year_field and year_field) and -('01:01:01' between time_field and time_field) and -('1901-01-01 01:01:01' between date_time and date_time) -order by auto; - -# NOT BETWEEN -select auto from t1 where -(string not between "aaaa" and "cccc") and -(vstring not between "aaaa" and "cccc") and -(bin not between 0xAAAA and 0xCCCC) and -(vbin not between 0xAAAA and 0xCCCC) and -(tiny not between -3 and -1) and -(short not between -3 and -1) and -(medium not between -3 and -1) and -(long_int not between -3 and -1) and -(longlong not between -3 and -1) and -(utiny not between 1 and 3) and -(ushort not between 1 and 3) and -(umedium not between 1 and 3) and -(ulong not between 1 and 3) and -(ulonglong not between 1 and 3) and -(bits not between b'001' and b'011') and -(options not between 'one' and 'three') and -(flags not between 'one' and 'one,two,three') and -(date_field not between '1901-01-01' and '1903-03-03') and -(year_field not between '1901' and '1903') and -(time_field not between '01:01:01' and '03:03:03') and -(date_time not between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') -order by auto; - -select auto from t1 where -("aaaa" not between string and string) and -("aaaa" not between vstring and vstring) and -(0xAAAA not between bin and bin) and -(0xAAAA not between vbin and vbin) and -(-1 not between tiny and tiny) and -(-1 not between short and short) and -(-1 not between medium and medium) and -(-1 not between long_int and long_int) and -(-1 not between longlong and longlong) and -(1 not between utiny and utiny) and -(1 not between ushort and ushort) and -(1 not between umedium and umedium) and -(1 not between ulong and ulong) and -(1 not between ulonglong and ulonglong) and -(b'001' not between bits and bits) and -('one' not between options and options) and -('one' not between flags and flags) and -('1901-01-01' not between date_field and date_field) and -('1901' not between year_field and year_field) and -('01:01:01' not between time_field and time_field) and -('1901-01-01 01:01:01' not between date_time and date_time) -order by auto; - -# IN -select auto from t1 where -string in("aaaa","cccc") and -vstring in("aaaa","cccc") and -bin in(0xAAAA,0xCCCC) and -vbin in(0xAAAA,0xCCCC) and -tiny in(-1,-3) and -short in(-1,-3) and -medium in(-1,-3) and -long_int in(-1,-3) and -longlong in(-1,-3) and -utiny in(1,3) and -ushort in(1,3) and -umedium in(1,3) and -ulong in(1,3) and -ulonglong in(1,3) and -bits in(b'001',b'011') and -options in('one','three') and -flags in('one','one,two,three') and -date_field in('1901-01-01','1903-03-03') and -year_field in('1901','1903') and -time_field in('01:01:01','03:03:03') and -date_time in('1901-01-01 01:01:01','1903-03-03 03:03:03') -order by auto; - -select auto from t1 where -"aaaa" in(string) and -"aaaa" in(vstring) and -0xAAAA in(bin) and -0xAAAA in(vbin) and -(-1 in(tiny)) and -(-1 in(short)) and -(-1 in(medium)) and -(-1 in(long_int)) and -(-1 in(longlong)) and -1 in(utiny) and -1 in(ushort) and -1 in(umedium) and -1 in(ulong) and -1 in(ulonglong) and -b'001' in(bits) and -'one' in(options) and -'one' in(flags) and -'1901-01-01' in(date_field) and -'1901' in(year_field) and -'01:01:01' in(time_field) and -'1901-01-01 01:01:01' in(date_time) -order by auto; - -# NOT IN -select auto from t1 where -string not in("aaaa","cccc") and -vstring not in("aaaa","cccc") and -bin not in(0xAAAA,0xCCCC) and -vbin not in(0xAAAA,0xCCCC) and -tiny not in(-1,-3) and -short not in(-1,-3) and -medium not in(-1,-3) and -long_int not in(-1,-3) and -longlong not in(-1,-3) and -utiny not in(1,3) and -ushort not in(1,3) and -umedium not in(1,3) and -ulong not in(1,3) and -ulonglong not in(1,3) and -bits not in(b'001',b'011') and -options not in('one','three') and -flags not in('one','one,two,three') and -date_field not in('1901-01-01','1903-03-03') and -year_field not in('1901','1903') and -time_field not in('01:01:01','03:03:03') and -date_time not in('1901-01-01 01:01:01','1903-03-03 03:03:03') -order by auto; - -select auto from t1 where -"aaaa" not in(string) and -"aaaa" not in(vstring) and -0xAAAA not in(bin) and -0xAAAA not in(vbin) and -(-1 not in(tiny)) and -(-1 not in(short)) and -(-1 not in(medium)) and -(-1 not in(long_int)) and -(-1 not in(longlong)) and -1 not in(utiny) and -1 not in(ushort) and -1 not in(umedium) and -1 not in(ulong) and -1 not in(ulonglong) and -b'001' not in(bits) and -'one' not in(options) and -'one' not in(flags) and -'1901-01-01' not in(date_field) and -'1901' not in(year_field) and -'01:01:01' not in(time_field) and -'1901-01-01 01:01:01' not in(date_time) -order by auto; - -# Various tests -select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; -select * from t2 where attr3 is not null and attr1 > 2 order by pk1; -select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; -select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; -select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; -select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; - -set engine_condition_pushdown = on; - -# Test all types and compare operators -explain -select auto from t1 where -string = "aaaa" and -vstring = "aaaa" and -bin = 0xAAAA and -vbin = 0xAAAA and -tiny = -1 and -short = -1 and -medium = -1 and -long_int = -1 and -longlong = -1 and -real_float > 1.0 and real_float < 2.0 and -real_double > 1.0 and real_double < 2.0 and -real_decimal > 1.0 and real_decimal < 2.0 and -utiny = 1 and -ushort = 1 and -umedium = 1 and -ulong = 1 and -ulonglong = 1 and -/* bits = b'001' and */ -options = 'one' and -flags = 'one' and -date_field = '1901-01-01' and -year_field = '1901' and -time_field = '01:01:01' and -date_time = '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string = "aaaa" and -vstring = "aaaa" and -bin = 0xAAAA and -vbin = 0xAAAA and -tiny = -1 and -short = -1 and -medium = -1 and -long_int = -1 and -longlong = -1 and -real_float > 1.0 and real_float < 2.0 and -real_double > 1.0 and real_double < 2.0 and -real_decimal > 1.0 and real_decimal < 2.0 and -utiny = 1 and -ushort = 1 and -umedium = 1 and -ulong = 1 and -ulonglong = 1 and -/* bits = b'001' and */ -options = 'one' and -flags = 'one' and -date_field = '1901-01-01' and -year_field = '1901' and -time_field = '01:01:01' and -date_time = '1901-01-01 01:01:01' -order by auto; - -explain -select auto from t1 where -string != "aaaa" and -vstring != "aaaa" and -bin != 0xAAAA and -vbin != 0xAAAA and -tiny != -1 and -short != -1 and -medium != -1 and -long_int != -1 and -longlong != -1 and -(real_float < 1.0 or real_float > 2.0) and -(real_double < 1.0 or real_double > 2.0) and -(real_decimal < 1.0 or real_decimal > 2.0) and -utiny != 1 and -ushort != 1 and -umedium != 1 and -ulong != 1 and -ulonglong != 1 and -/* bits != b'001' and */ -options != 'one' and -flags != 'one' and -date_field != '1901-01-01' and -year_field != '1901' and -time_field != '01:01:01' and -date_time != '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string != "aaaa" and -vstring != "aaaa" and -bin != 0xAAAA and -vbin != 0xAAAA and -tiny != -1 and -short != -1 and -medium != -1 and -long_int != -1 and -longlong != -1 and -(real_float < 1.0 or real_float > 2.0) and -(real_double < 1.0 or real_double > 2.0) and -(real_decimal < 1.0 or real_decimal > 2.0) and -utiny != 1 and -ushort != 1 and -umedium != 1 and -ulong != 1 and -ulonglong != 1 and -/* bits != b'001' and */ -options != 'one' and -flags != 'one' and -date_field != '1901-01-01' and -year_field != '1901' and -time_field != '01:01:01' and -date_time != '1901-01-01 01:01:01' -order by auto; - -explain -select auto from t1 where -string > "aaaa" and -vstring > "aaaa" and -bin > 0xAAAA and -vbin > 0xAAAA and -tiny < -1 and -short < -1 and -medium < -1 and -long_int < -1 and -longlong < -1 and -real_float > 1.1 and -real_double > 1.1 and -real_decimal > 1.1 and -utiny > 1 and -ushort > 1 and -umedium > 1 and -ulong > 1 and -ulonglong > 1 and -/* bits > b'001' and */ -(options = 'two' or options = 'three' or options = 'four') and -(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field > '1901-01-01' and -year_field > '1901' and -time_field > '01:01:01' and -date_time > '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string > "aaaa" and -vstring > "aaaa" and -bin > 0xAAAA and -vbin > 0xAAAA and -tiny < -1 and -short < -1 and -medium < -1 and -long_int < -1 and -longlong < -1 and -real_float > 1.1 and -real_double > 1.1 and -real_decimal > 1.1 and -utiny > 1 and -ushort > 1 and -umedium > 1 and -ulong > 1 and -ulonglong > 1 and -/* bits > b'001' and */ -(options = 'two' or options = 'three' or options = 'four') and -(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field > '1901-01-01' and -year_field > '1901' and -time_field > '01:01:01' and -date_time > '1901-01-01 01:01:01' -order by auto; - -explain -select auto from t1 where -string >= "aaaa" and -vstring >= "aaaa" and -bin >= 0xAAAA and -vbin >= 0xAAAA and -tiny <= -1 and -short <= -1 and -medium <= -1 and -long_int <= -1 and -longlong <= -1 and -real_float >= 1.0 and -real_double >= 1.0 and -real_decimal >= 1.0 and -utiny >= 1 and -ushort >= 1 and -umedium >= 1 and -ulong >= 1 and -ulonglong >= 1 and -/* bits >= b'001' and */ -(options = 'one' or options = 'two' or options = 'three' or options = 'four') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field >= '1901-01-01' and -year_field >= '1901' and -time_field >= '01:01:01' and -date_time >= '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string >= "aaaa" and -vstring >= "aaaa" and -bin >= 0xAAAA and -vbin >= 0xAAAA and -tiny <= -1 and -short <= -1 and -medium <= -1 and -long_int <= -1 and -longlong <= -1 and -real_float >= 1.0 and -real_double >= 1.0 and -real_decimal >= 1.0 and -utiny >= 1 and -ushort >= 1 and -umedium >= 1 and -ulong >= 1 and -ulonglong >= 1 and -/* bits >= b'001' and */ -(options = 'one' or options = 'two' or options = 'three' or options = 'four') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field >= '1901-01-01' and -year_field >= '1901' and -time_field >= '01:01:01' and -date_time >= '1901-01-01 01:01:01' -order by auto; - -explain -select auto from t1 where -string < "dddd" and -vstring < "dddd" and -bin < 0xDDDD and -vbin < 0xDDDD and -tiny > -4 and -short > -4 and -medium > -4 and -long_int > -4 and -longlong > -4 and -real_float < 4.4 and -real_double < 4.4 and -real_decimal < 4.4 and -utiny < 4 and -ushort < 4 and -umedium < 4 and -ulong < 4 and -ulonglong < 4 and -/* bits < b'100' and */ -(options = 'one' or options = 'two' or options = 'three') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and -date_field < '1904-01-01' and -year_field < '1904' and -time_field < '04:04:04' and -date_time < '1904-04-04 04:04:04' -order by auto; - -select auto from t1 where -string < "dddd" and -vstring < "dddd" and -bin < 0xDDDD and -vbin < 0xDDDD and -tiny > -4 and -short > -4 and -medium > -4 and -long_int > -4 and -longlong > -4 and -real_float < 4.4 and -real_double < 4.4 and -real_decimal < 4.4 and -utiny < 4 and -ushort < 4 and -umedium < 4 and -ulong < 4 and -ulonglong < 4 and -/* bits < b'100' and */ -(options = 'one' or options = 'two' or options = 'three') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and -date_field < '1904-01-01' and -year_field < '1904' and -time_field < '04:04:04' and -date_time < '1904-04-04 04:04:04' -order by auto; - -explain -select auto from t1 where -string <= "dddd" and -vstring <= "dddd" and -bin <= 0xDDDD and -vbin <= 0xDDDD and -tiny >= -4 and -short >= -4 and -medium >= -4 and -long_int >= -4 and -longlong >= -4 and -real_float <= 4.5 and -real_double <= 4.5 and -real_decimal <= 4.5 and -utiny <= 4 - 1 + 1 and /* Checking function composition */ -ushort <= 4 and -umedium <= 4 and -ulong <= 4 and -ulonglong <= 4 and -/* bits <= b'100' and */ -(options = 'one' or options = 'two' or options = 'three' or options = 'four') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field <= '1904-04-04' and -year_field <= '1904' and -time_field <= '04:04:04' and -date_time <= '1904-04-04 04:04:04' -order by auto; - -select auto from t1 where -string <= "dddd" and -vstring <= "dddd" and -bin <= 0xDDDD and -vbin <= 0xDDDD and -tiny >= -4 and -short >= -4 and -medium >= -4 and -long_int >= -4 and -longlong >= -4 and -real_float <= 4.5 and -real_double <= 4.5 and -real_decimal <= 4.5 and -utiny <= 4 - 1 + 1 and /* Checking function composition */ -ushort <= 4 and -umedium <= 4 and -ulong <= 4 and -ulonglong <= 4 and -/* bits <= b'100' and */ -(options = 'one' or options = 'two' or options = 'three' or options = 'four') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field <= '1904-04-04' and -year_field <= '1904' and -time_field <= '04:04:04' and -date_time <= '1904-04-04 04:04:04' -order by auto; - -# Test index scan with filter -create index medium_index on t1(medium); - -# Test all types and compare operators -explain -select auto from t1 where -string = "aaaa" and -vstring = "aaaa" and -bin = 0xAAAA and -vbin = 0xAAAA and -tiny = -1 and -short = -1 and -medium = -1 and -long_int = -1 and -longlong = -1 and -real_float > 1.0 and real_float < 2.0 and -real_double > 1.0 and real_double < 2.0 and -real_decimal > 1.0 and real_decimal < 2.0 and -utiny = 1 and -ushort = 1 and -umedium = 1 and -ulong = 1 and -ulonglong = 1 and -/* bits = b'001' and */ -options = 'one' and -flags = 'one' and -date_field = '1901-01-01' and -year_field = '1901' and -time_field = '01:01:01' and -date_time = '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string = "aaaa" and -vstring = "aaaa" and -bin = 0xAAAA and -vbin = 0xAAAA and -tiny = -1 and -short = -1 and -medium = -1 and -long_int = -1 and -longlong = -1 and -real_float > 1.0 and real_float < 2.0 and -real_double > 1.0 and real_double < 2.0 and -real_decimal > 1.0 and real_decimal < 2.0 and -utiny = 1 and -ushort = 1 and -umedium = 1 and -ulong = 1 and -ulonglong = 1 and -/* bits = b'001' and */ -options = 'one' and -flags = 'one' and -date_field = '1901-01-01' and -year_field = '1901' and -time_field = '01:01:01' and -date_time = '1901-01-01 01:01:01' -order by auto; - -explain -select auto from t1 where -string != "aaaa" and -vstring != "aaaa" and -bin != 0xAAAA and -vbin != 0xAAAA and -tiny != -1 and -short != -1 and -medium != -1 and -long_int != -1 and -longlong != -1 and -(real_float < 1.0 or real_float > 2.0) and -(real_double < 1.0 or real_double > 2.0) and -(real_decimal < 1.0 or real_decimal > 2.0) and -utiny != 1 and -ushort != 1 and -umedium != 1 and -ulong != 1 and -ulonglong != 1 and -/* bits != b'001' and */ -options != 'one' and -flags != 'one' and -date_field != '1901-01-01' and -year_field != '1901' and -time_field != '01:01:01' and -date_time != '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string != "aaaa" and -vstring != "aaaa" and -bin != 0xAAAA and -vbin != 0xAAAA and -tiny != -1 and -short != -1 and -medium != -1 and -long_int != -1 and -longlong != -1 and -(real_float < 1.0 or real_float > 2.0) and -(real_double < 1.0 or real_double > 2.0) and -(real_decimal < 1.0 or real_decimal > 2.0) and -utiny != 1 and -ushort != 1 and -umedium != 1 and -ulong != 1 and -ulonglong != 1 and -/* bits != b'001' and */ -options != 'one' and -flags != 'one' and -date_field != '1901-01-01' and -year_field != '1901' and -time_field != '01:01:01' and -date_time != '1901-01-01 01:01:01' -order by auto; - -explain -select auto from t1 where -string > "aaaa" and -vstring > "aaaa" and -bin > 0xAAAA and -vbin > 0xAAAA and -tiny < -1 and -short < -1 and -medium < -1 and -long_int < -1 and -longlong < -1 and -real_float > 1.1 and -real_double > 1.1 and -real_decimal > 1.1 and -utiny > 1 and -ushort > 1 and -umedium > 1 and -ulong > 1 and -ulonglong > 1 and -/* bits > b'001' and */ -(options = 'two' or options = 'three' or options = 'four') and -(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field > '1901-01-01' and -year_field > '1901' and -time_field > '01:01:01' and -date_time > '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string > "aaaa" and -vstring > "aaaa" and -bin > 0xAAAA and -vbin > 0xAAAA and -tiny < -1 and -short < -1 and -medium < -1 and -long_int < -1 and -longlong < -1 and -real_float > 1.1 and -real_double > 1.1 and -real_decimal > 1.1 and -utiny > 1 and -ushort > 1 and -umedium > 1 and -ulong > 1 and -ulonglong > 1 and -/* bits > b'001' and */ -(options = 'two' or options = 'three' or options = 'four') and -(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field > '1901-01-01' and -year_field > '1901' and -time_field > '01:01:01' and -date_time > '1901-01-01 01:01:01' -order by auto; - -explain -select auto from t1 where -string >= "aaaa" and -vstring >= "aaaa" and -bin >= 0xAAAA and -vbin >= 0xAAAA and -tiny <= -1 and -short <= -1 and -medium <= -1 and -long_int <= -1 and -longlong <= -1 and -real_float >= 1.0 and -real_double >= 1.0 and -real_decimal >= 1.0 and -utiny >= 1 and -ushort >= 1 and -umedium >= 1 and -ulong >= 1 and -ulonglong >= 1 and -/* bits >= b'001' and */ -(options = 'one' or options = 'two' or options = 'three' or options = 'four') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field >= '1901-01-01' and -year_field >= '1901' and -time_field >= '01:01:01' and -date_time >= '1901-01-01 01:01:01' -order by auto; - -select auto from t1 where -string >= "aaaa" and -vstring >= "aaaa" and -bin >= 0xAAAA and -vbin >= 0xAAAA and -tiny <= -1 and -short <= -1 and -medium <= -1 and -long_int <= -1 and -longlong <= -1 and -real_float >= 1.0 and -real_double >= 1.0 and -real_decimal >= 1.0 and -utiny >= 1 and -ushort >= 1 and -umedium >= 1 and -ulong >= 1 and -ulonglong >= 1 and -/* bits >= b'001' and */ -(options = 'one' or options = 'two' or options = 'three' or options = 'four') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field >= '1901-01-01' and -year_field >= '1901' and -time_field >= '01:01:01' and -date_time >= '1901-01-01 01:01:01' -order by auto; - -explain -select auto from t1 where -string < "dddd" and -vstring < "dddd" and -bin < 0xDDDD and -vbin < 0xDDDD and -tiny > -4 and -short > -4 and -medium > -4 and -long_int > -4 and -longlong > -4 and -real_float < 4.4 and -real_double < 4.4 and -real_decimal < 4.4 and -utiny < 4 and -ushort < 4 and -umedium < 4 and -ulong < 4 and -ulonglong < 4 and -/* bits < b'100' and */ -(options = 'one' or options = 'two' or options = 'three') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and -date_field < '1904-01-01' and -year_field < '1904' and -time_field < '04:04:04' and -date_time < '1904-04-04 04:04:04' -order by auto; - -select auto from t1 where -string < "dddd" and -vstring < "dddd" and -bin < 0xDDDD and -vbin < 0xDDDD and -tiny > -4 and -short > -4 and -medium > -4 and -long_int > -4 and -longlong > -4 and -real_float < 4.4 and -real_double < 4.4 and -real_decimal < 4.4 and -utiny < 4 and -ushort < 4 and -umedium < 4 and -ulong < 4 and -ulonglong < 4 and -/* bits < b'100' and */ -(options = 'one' or options = 'two' or options = 'three') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and -date_field < '1904-01-01' and -year_field < '1904' and -time_field < '04:04:04' and -date_time < '1904-04-04 04:04:04' -order by auto; - -explain -select auto from t1 where -string <= "dddd" and -vstring <= "dddd" and -bin <= 0xDDDD and -vbin <= 0xDDDD and -tiny >= -4 and -short >= -4 and -medium >= -4 and -long_int >= -4 and -longlong >= -4 and -real_float <= 4.5 and -real_double <= 4.5 and -real_decimal <= 4.5 and -utiny <= 4 - 1 + 1 and /* Checking function composition */ -ushort <= 4 and -umedium <= 4 and -ulong <= 4 and -ulonglong <= 4 and -/* bits <= b'100' and */ -(options = 'one' or options = 'two' or options = 'three' or options = 'four') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field <= '1904-04-04' and -year_field <= '1904' and -time_field <= '04:04:04' and -date_time <= '1904-04-04 04:04:04' -order by auto; - -select auto from t1 where -string <= "dddd" and -vstring <= "dddd" and -bin <= 0xDDDD and -vbin <= 0xDDDD and -tiny >= -4 and -short >= -4 and -medium >= -4 and -long_int >= -4 and -longlong >= -4 and -real_float <= 4.5 and -real_double <= 4.5 and -real_decimal <= 4.5 and -utiny <= 4 - 1 + 1 and /* Checking function composition */ -ushort <= 4 and -umedium <= 4 and -ulong <= 4 and -ulonglong <= 4 and -/* bits <= b'100' and */ -(options = 'one' or options = 'two' or options = 'three' or options = 'four') and -(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and -date_field <= '1904-04-04' and -year_field <= '1904' and -time_field <= '04:04:04' and -date_time <= '1904-04-04 04:04:04' -order by auto; - -# Test LIKE/NOT LIKE -explain -select auto from t1 where -string like "b%" and -vstring like "b%" and -bin like concat(0xBB, '%') and -vbin like concat(0xBB, '%') -order by auto; - -select auto from t1 where -string like "b%" and -vstring like "b%" and -bin like concat(0xBB, '%') and -vbin like concat(0xBB, '%') -order by auto; - -explain -select auto from t1 where -string not like "b%" and -vstring not like "b%" and -bin not like concat(0xBB, '%') and -vbin not like concat(0xBB, '%') -order by auto; - -select auto from t1 where -string not like "b%" and -vstring not like "b%" and -bin not like concat(0xBB, '%') and -vbin not like concat(0xBB, '%') -order by auto; - -# BETWEEN -explain -select auto from t1 where -(string between "aaaa" and "cccc") and -(vstring between "aaaa" and "cccc") and -(bin between 0xAAAA and 0xCCCC) and -(vbin between 0xAAAA and 0xCCCC) and -(tiny between -3 and -1) and -(short between -3 and -1) and -(medium between -3 and -1) and -(long_int between -3 and -1) and -(longlong between -3 and -1) and -(utiny between 1 and 3) and -(ushort between 1 and 3) and -(umedium between 1 and 3) and -(ulong between 1 and 3) and -(ulonglong between 1 and 3) and -/* (bits between b'001' and b'011') and */ -(options between 'one' and 'three') and -(flags between 'one' and 'one,two,three') and -(date_field between '1901-01-01' and '1903-03-03') and -(year_field between '1901' and '1903') and -(time_field between '01:01:01' and '03:03:03') and -(date_time between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') -order by auto; - -select auto from t1 where -(string between "aaaa" and "cccc") and -(vstring between "aaaa" and "cccc") and -(bin between 0xAAAA and 0xCCCC) and -(vbin between 0xAAAA and 0xCCCC) and -(tiny between -3 and -1) and -(short between -3 and -1) and -(medium between -3 and -1) and -(long_int between -3 and -1) and -(longlong between -3 and -1) and -(utiny between 1 and 3) and -(ushort between 1 and 3) and -(umedium between 1 and 3) and -(ulong between 1 and 3) and -(ulonglong between 1 and 3) and -/* (bits between b'001' and b'011') and */ -(options between 'one' and 'three') and -(flags between 'one' and 'one,two,three') and -(date_field between '1901-01-01' and '1903-03-03') and -(year_field between '1901' and '1903') and -(time_field between '01:01:01' and '03:03:03') and -(date_time between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') -order by auto; - -explain -select auto from t1 where -("aaaa" between string and string) and -("aaaa" between vstring and vstring) and -(0xAAAA between bin and bin) and -(0xAAAA between vbin and vbin) and -(-1 between tiny and tiny) and -(-1 between short and short) and -(-1 between medium and medium) and -(-1 between long_int and long_int) and -(-1 between longlong and longlong) and -(1 between utiny and utiny) and -(1 between ushort and ushort) and -(1 between umedium and umedium) and -(1 between ulong and ulong) and -(1 between ulonglong and ulonglong) and -/* (b'001' between bits and bits) and */ -('one' between options and options) and -('one' between flags and flags) and -('1901-01-01' between date_field and date_field) and -('1901' between year_field and year_field) and -('01:01:01' between time_field and time_field) and -('1901-01-01 01:01:01' between date_time and date_time) -order by auto; - -select auto from t1 where -("aaaa" between string and string) and -("aaaa" between vstring and vstring) and -(0xAAAA between bin and bin) and -(0xAAAA between vbin and vbin) and -(-1 between tiny and tiny) and -(-1 between short and short) and -(-1 between medium and medium) and -(-1 between long_int and long_int) and -(-1 between longlong and longlong) and -(1 between utiny and utiny) and -(1 between ushort and ushort) and -(1 between umedium and umedium) and -(1 between ulong and ulong) and -(1 between ulonglong and ulonglong) and -/* (b'001' between bits and bits) and */ -('one' between options and options) and -('one' between flags and flags) and -('1901-01-01' between date_field and date_field) and -('1901' between year_field and year_field) and -('01:01:01' between time_field and time_field) and -('1901-01-01 01:01:01' between date_time and date_time) -order by auto; - -# NOT BETWEEN -explain -select auto from t1 where -(string not between "aaaa" and "cccc") and -(vstring not between "aaaa" and "cccc") and -(bin not between 0xAAAA and 0xCCCC) and -(vbin not between 0xAAAA and 0xCCCC) and -(tiny not between -3 and -1) and -(short not between -3 and -1) and -(medium not between -3 and -1) and -(long_int not between -3 and -1) and -(longlong not between -3 and -1) and -(utiny not between 1 and 3) and -(ushort not between 1 and 3) and -(umedium not between 1 and 3) and -(ulong not between 1 and 3) and -(ulonglong not between 1 and 3) and -/* (bits not between b'001' and b'011') and */ -(options not between 'one' and 'three') and -(flags not between 'one' and 'one,two,three') and -(date_field not between '1901-01-01' and '1903-03-03') and -(year_field not between '1901' and '1903') and -(time_field not between '01:01:01' and '03:03:03') and -(date_time not between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') -order by auto; - -select auto from t1 where -(string not between "aaaa" and "cccc") and -(vstring not between "aaaa" and "cccc") and -(bin not between 0xAAAA and 0xCCCC) and -(vbin not between 0xAAAA and 0xCCCC) and -(tiny not between -3 and -1) and -(short not between -3 and -1) and -(medium not between -3 and -1) and -(long_int not between -3 and -1) and -(longlong not between -3 and -1) and -(utiny not between 1 and 3) and -(ushort not between 1 and 3) and -(umedium not between 1 and 3) and -(ulong not between 1 and 3) and -(ulonglong not between 1 and 3) and -/* (bits not between b'001' and b'011') and */ -(options not between 'one' and 'three') and -(flags not between 'one' and 'one,two,three') and -(date_field not between '1901-01-01' and '1903-03-03') and -(year_field not between '1901' and '1903') and -(time_field not between '01:01:01' and '03:03:03') and -(date_time not between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') -order by auto; - -explain -select auto from t1 where -("aaaa" not between string and string) and -("aaaa" not between vstring and vstring) and -(0xAAAA not between bin and bin) and -(0xAAAA not between vbin and vbin) and -(-1 not between tiny and tiny) and -(-1 not between short and short) and -(-1 not between medium and medium) and -(-1 not between long_int and long_int) and -(-1 not between longlong and longlong) and -(1 not between utiny and utiny) and -(1 not between ushort and ushort) and -(1 not between umedium and umedium) and -(1 not between ulong and ulong) and -(1 not between ulonglong and ulonglong) and -/* (b'001' not between bits and bits) and */ -('one' not between options and options) and -('one' not between flags and flags) and -('1901-01-01' not between date_field and date_field) and -('1901' not between year_field and year_field) and -('01:01:01' not between time_field and time_field) and -('1901-01-01 01:01:01' not between date_time and date_time) -order by auto; - -select auto from t1 where -("aaaa" not between string and string) and -("aaaa" not between vstring and vstring) and -(0xAAAA not between bin and bin) and -(0xAAAA not between vbin and vbin) and -(-1 not between tiny and tiny) and -(-1 not between short and short) and -(-1 not between medium and medium) and -(-1 not between long_int and long_int) and -(-1 not between longlong and longlong) and -(1 not between utiny and utiny) and -(1 not between ushort and ushort) and -(1 not between umedium and umedium) and -(1 not between ulong and ulong) and -(1 not between ulonglong and ulonglong) and -/* (b'001' not between bits and bits) and */ -('one' not between options and options) and -('one' not between flags and flags) and -('1901-01-01' not between date_field and date_field) and -('1901' not between year_field and year_field) and -('01:01:01' not between time_field and time_field) and -('1901-01-01 01:01:01' not between date_time and date_time) -order by auto; - -# IN -explain -select auto from t1 where -string in("aaaa","cccc") and -vstring in("aaaa","cccc") and -bin in(0xAAAA,0xCCCC) and -vbin in(0xAAAA,0xCCCC) and -tiny in(-1,-3) and -short in(-1,-3) and -medium in(-1,-3) and -long_int in(-1,-3) and -longlong in(-1,-3) and -utiny in(1,3) and -ushort in(1,3) and -umedium in(1,3) and -ulong in(1,3) and -ulonglong in(1,3) and -/* bits in(b'001',b'011') and */ -options in('one','three') and -flags in('one','one,two,three') and -date_field in('1901-01-01','1903-03-03') and -year_field in('1901','1903') and -time_field in('01:01:01','03:03:03') and -date_time in('1901-01-01 01:01:01','1903-03-03 03:03:03') -order by auto; - -select auto from t1 where -string in("aaaa","cccc") and -vstring in("aaaa","cccc") and -bin in(0xAAAA,0xCCCC) and -vbin in(0xAAAA,0xCCCC) and -tiny in(-1,-3) and -short in(-1,-3) and -medium in(-1,-3) and -long_int in(-1,-3) and -longlong in(-1,-3) and -utiny in(1,3) and -ushort in(1,3) and -umedium in(1,3) and -ulong in(1,3) and -ulonglong in(1,3) and -/* bits in(b'001',b'011') and */ -options in('one','three') and -flags in('one','one,two,three') and -date_field in('1901-01-01','1903-03-03') and -year_field in('1901','1903') and -time_field in('01:01:01','03:03:03') and -date_time in('1901-01-01 01:01:01','1903-03-03 03:03:03') -order by auto; - -explain -select auto from t1 where -"aaaa" in(string) and -"aaaa" in(vstring) and -0xAAAA in(bin) and -0xAAAA in(vbin) and -(-1 in(tiny)) and -(-1 in (short)) and -(-1 in(medium)) and -(-1 in(long_int)) and -(-1 in(longlong)) and -1 in(utiny) and -1 in(ushort) and -1 in(umedium) and -1 in(ulong) and -1 in(ulonglong) and -/* b'001' in(bits) and */ -'one' in(options) and -'one' in(flags) and -'1901-01-01' in(date_field) and -'1901' in(year_field) and -'01:01:01' in(time_field) and -'1901-01-01 01:01:01' in(date_time) -order by auto; - -select auto from t1 where -"aaaa" in(string) and -"aaaa" in(vstring) and -0xAAAA in(bin) and -0xAAAA in(vbin) and -(-1 in(tiny)) and -(-1 in (short)) and -(-1 in(medium)) and -(-1 in(long_int)) and -(-1 in(longlong)) and -1 in(utiny) and -1 in(ushort) and -1 in(umedium) and -1 in(ulong) and -1 in(ulonglong) and -/* b'001' in(bits) and */ -'one' in(options) and -'one' in(flags) and -'1901-01-01' in(date_field) and -'1901' in(year_field) and -'01:01:01' in(time_field) and -'1901-01-01 01:01:01' in(date_time) -order by auto; - -# NOT IN -explain -select auto from t1 where -string not in("aaaa","cccc") and -vstring not in("aaaa","cccc") and -bin not in(0xAAAA,0xCCCC) and -vbin not in(0xAAAA,0xCCCC) and -tiny not in(-1,-3) and -short not in(-1,-3) and -medium not in(-1,-3) and -long_int not in(-1,-3) and -longlong not in(-1,-3) and -utiny not in(1,3) and -ushort not in(1,3) and -umedium not in(1,3) and -ulong not in(1,3) and -ulonglong not in(1,3) and -/* bits not in(b'001',b'011') and */ -options not in('one','three') and -flags not in('one','one,two,three') and -date_field not in('1901-01-01','1903-03-03') and -year_field not in('1901','1903') and -time_field not in('01:01:01','03:03:03') and -date_time not in('1901-01-01 01:01:01','1903-03-03 03:03:03') -order by auto; - -select auto from t1 where -string not in("aaaa","cccc") and -vstring not in("aaaa","cccc") and -bin not in(0xAAAA,0xCCCC) and -vbin not in(0xAAAA,0xCCCC) and -tiny not in(-1,-3) and -short not in(-1,-3) and -medium not in(-1,-3) and -long_int not in(-1,-3) and -longlong not in(-1,-3) and -utiny not in(1,3) and -ushort not in(1,3) and -umedium not in(1,3) and -ulong not in(1,3) and -ulonglong not in(1,3) and -/* bits not in(b'001',b'011') and */ -options not in('one','three') and -flags not in('one','one,two,three') and -date_field not in('1901-01-01','1903-03-03') and -year_field not in('1901','1903') and -time_field not in('01:01:01','03:03:03') and -date_time not in('1901-01-01 01:01:01','1903-03-03 03:03:03') -order by auto; - -explain -select auto from t1 where -"aaaa" not in(string) and -"aaaa" not in(vstring) and -0xAAAA not in(bin) and -0xAAAA not in(vbin) and -(-1 not in(tiny)) and -(-1 not in(short)) and -(-1 not in(medium)) and -(-1 not in(long_int)) and -(-1 not in(longlong)) and -1 not in(utiny) and -1 not in(ushort) and -1 not in(umedium) and -1 not in(ulong) and -1 not in(ulonglong) and -/* b'001' not in(bits) and */ -'one' not in(options) and -'one' not in(flags) and -'1901-01-01' not in(date_field) and -'1901' not in(year_field) and -'01:01:01' not in(time_field) and -'1901-01-01 01:01:01' not in(date_time) -order by auto; - -select auto from t1 where -"aaaa" not in(string) and -"aaaa" not in(vstring) and -0xAAAA not in(bin) and -0xAAAA not in(vbin) and -(-1 not in(tiny)) and -(-1 not in(short)) and -(-1 not in(medium)) and -(-1 not in(long_int)) and -(-1 not in(longlong)) and -1 not in(utiny) and -1 not in(ushort) and -1 not in(umedium) and -1 not in(ulong) and -1 not in(ulonglong) and -/* b'001' not in(bits) and */ -'one' not in(options) and -'one' not in(flags) and -'1901-01-01' not in(date_field) and -'1901' not in(year_field) and -'01:01:01' not in(time_field) and -'1901-01-01 01:01:01' not in(date_time) -order by auto; - -# Update test -update t1 -set medium = 17 -where -string = "aaaa" and -vstring = "aaaa" and -bin = 0xAAAA and -vbin = 0xAAAA and -tiny = -1 and -short = -1 and -medium = -1 and -long_int = -1 and -longlong = -1 and -real_float > 1.0 and real_float < 2.0 and -real_double > 1.0 and real_double < 2.0 and -real_decimal > 1.0 and real_decimal < 2.0 and -utiny = 1 and -ushort = 1 and -umedium = 1 and -ulong = 1 and -ulonglong = 1 and -/* bits = b'001' and */ -options = 'one' and -flags = 'one' and -date_field = '1901-01-01' and -year_field = '1901' and -time_field = '01:01:01' and -date_time = '1901-01-01 01:01:01'; - -# Delete test -delete from t1 -where -string = "aaaa" and -vstring = "aaaa" and -bin = 0xAAAA and -vbin = 0xAAAA and -tiny = -1 and -short = -1 and -medium = 17 and -long_int = -1 and -longlong = -1 and -real_float > 1.0 and real_float < 2.0 and -real_double > 1.0 and real_double < 2.0 and -real_decimal > 1.0 and real_decimal < 2.0 and -utiny = 1 and -ushort = 1 and -umedium = 1 and -ulong = 1 and -ulonglong = 1 and -/* bits = b'001' and */ -options = 'one' and -flags = 'one' and -date_field = '1901-01-01' and -year_field = '1901' and -time_field = '01:01:01' and -date_time = '1901-01-01 01:01:01'; - -select count(*) from t1; - -# Various tests -explain -select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; -select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; - -explain -select * from t2 where attr3 is not null and attr1 > 2 order by pk1; -select * from t2 where attr3 is not null and attr1 > 2 order by pk1; - -explain -select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; -select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; - -explain -select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; -select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; - -explain -select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; -select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; - -explain -select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; -select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; - -# Some tests that are currently not supported and should not push condition -explain -select auto from t1 where string = "aaaa" collate latin1_general_ci order by auto; -explain -select * from t2 where (attr1 < 2) = (attr2 < 2) order by pk1; -explain -select * from t3 left join t4 on t4.attr2 = t3.attr2 where t4.attr1 > 1 and t4.attr3 < 5 or t4.attr1 is null order by t4.pk1; - -# bug#15722 -create table t5 (a int primary key auto_increment, b tinytext not null) -engine = ndb; -insert into t5 (b) values ('jonas'), ('jensing'), ('johan'); -set engine_condition_pushdown = off; -select * from t5 where b like '%jo%' order by a; -set engine_condition_pushdown = on; -explain select * from t5 where b like '%jo%'; -select * from t5 where b like '%jo%' order by a; - -# bug#21056 ndb pushdown equal/setValue error on datetime -set engine_condition_pushdown = off; -select auto from t1 where date_time like '1902-02-02 %' order by auto; -select auto from t1 where date_time not like '1902-02-02 %' order by auto; -set engine_condition_pushdown = on; -explain select auto from t1 where date_time like '1902-02-02 %'; -select auto from t1 where date_time like '1902-02-02 %' order by auto; -explain select auto from t1 where date_time not like '1902-02-02 %'; -select auto from t1 where date_time not like '1902-02-02 %' order by auto; - -# bug#17421 -1 -drop table t1; -create table t1 (a int, b varchar(3), primary key using hash(a)) -engine=ndb; -insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); -# in TUP the constants 'ab' 'abc' were expected in varchar format -# "like" returned error which became "false" -# scan filter negates "or" which exposes the bug -set engine_condition_pushdown = off; -select * from t1 where b like 'ab'; -select * from t1 where b like 'ab' or b like 'ab'; -select * from t1 where b like 'abc'; -select * from t1 where b like 'abc' or b like 'abc'; -set engine_condition_pushdown = on; -select * from t1 where b like 'ab'; -select * from t1 where b like 'ab' or b like 'ab'; -select * from t1 where b like 'abc'; -select * from t1 where b like 'abc' or b like 'abc'; - -# bug#17421 -2 -drop table t1; -create table t1 (a int, b char(3), primary key using hash(a)) -engine=ndb; -insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); -# test that incorrect MySQL behaviour is preserved -# 'ab ' LIKE 'ab' is true in MySQL -set engine_condition_pushdown = off; -select * from t1 where b like 'ab'; -select * from t1 where b like 'ab' or b like 'ab'; -select * from t1 where b like 'abc'; -select * from t1 where b like 'abc' or b like 'abc'; -set engine_condition_pushdown = on; -select * from t1 where b like 'ab'; -select * from t1 where b like 'ab' or b like 'ab'; -select * from t1 where b like 'abc'; -select * from t1 where b like 'abc' or b like 'abc'; - -# bug#20406 (maybe same as bug#17421 -1, not seen on 32-bit x86) -drop table t1; -create table t1 ( fname varchar(255), lname varchar(255) ) -engine=ndbcluster; -insert into t1 values ("Young","Foo"); - -set engine_condition_pushdown = 0; -SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); -set engine_condition_pushdown = 1; -SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); - -# make sure optimizer does not do some crazy shortcut -insert into t1 values ("aaa", "aaa"); -insert into t1 values ("bbb", "bbb"); -insert into t1 values ("ccc", "ccc"); -insert into t1 values ("ddd", "ddd"); - -set engine_condition_pushdown = 0; -SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); -set engine_condition_pushdown = 1; -SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); - -# bug#29390 (scan filter is too large, discarded) -# bug#34107 (previous limit was too large for TUP) - -drop table t1; - -create table t1 (a int, b int, c int, d int, primary key using hash(a)) - engine=ndbcluster; - -insert into t1 values (10,1,100,0+0x1111); -insert into t1 values (20,2,200,0+0x2222); -insert into t1 values (30,3,300,0+0x3333); -insert into t1 values (40,4,400,0+0x4444); -insert into t1 values (50,5,500,0+0x5555); - -set engine_condition_pushdown = on; - -select a,b,d from t1 - where b in (0,1,2,5) - order by b; - ---echo -- big filter just below limit ---disable_query_log -select a,b,d from t1 - where b in ( -0,1,2,5,0,1,2,5,0,1, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2) - order by b; ---enable_query_log - ---echo -- big filter just above limit ---disable_query_log -select a,b,d from t1 - where b in ( -0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2, -0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2,5,0,1,2) - order by b; ---enable_query_log - -set engine_condition_pushdown = @old_ecpd; -DROP TABLE t1,t2,t3,t4,t5; diff --git a/mysql-test/t/ndb_config.test b/mysql-test/t/ndb_config.test deleted file mode 100644 index f63c0087c1e..00000000000 --- a/mysql-test/t/ndb_config.test +++ /dev/null @@ -1,23 +0,0 @@ --- source include/have_ndb.inc --- source include/ndb_default_cluster.inc --- source include/not_embedded.inc - ---exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=type,nodeid,host 2> /dev/null ---exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null ---exec $NDB_TOOLS_DIR/ndb_config --no-defaults -r \\\n -f " " --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null ---exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --type=ndbd --host=localhost 2> /dev/null ---exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=type,nodeid,host --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null - -# End of 4.1 tests - ---exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.jonas --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf1.cnf --query=type,nodeid,host,IndexMemory,DataMemory --mycnf 2> /dev/null - ---exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster0 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null ---exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster1 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null ---exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null ---exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --ndb-shm --connections --query=type,nodeid1,nodeid2,group,nodeidserver --mycnf 2> /dev/null - - ---exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --host=localhost --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null ---exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --host=1.2.3.4 --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null ---exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --host=127.0.0.1 --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null diff --git a/mysql-test/t/ndb_database.test b/mysql-test/t/ndb_database.test deleted file mode 100644 index 2e924ba2dcc..00000000000 --- a/mysql-test/t/ndb_database.test +++ /dev/null @@ -1,52 +0,0 @@ --- source include/have_ndb.inc --- source include/have_multi_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -connection server1; -drop table if exists t1; -drop database if exists mysqltest; -connection server2; -drop table if exists t1; -drop database if exists mysqltest; ---enable_warnings - -# -# Check that all tables in a database are dropped when database is dropped -# - -connection server1; -create database mysqltest; - -connection server2; -create database mysqltest; -create table mysqltest.t1 (a int primary key, b int) engine=ndb; -use mysqltest; -show tables; - -connection server1; -drop database mysqltest; - -connection server2; -use mysqltest; -show tables; - -connection server1; -create database mysqltest; -create table mysqltest.t1 (c int, d int primary key) engine=ndb; -use mysqltest; -show tables; - -connection server2; -drop database mysqltest; - -connection server1; -use mysqltest; -show tables; - ---disable_warnings -drop table if exists t1; -drop database if exists mysqltest; ---enable_warnings - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_gis.test b/mysql-test/t/ndb_gis.test deleted file mode 100644 index e14f462c32d..00000000000 --- a/mysql-test/t/ndb_gis.test +++ /dev/null @@ -1,5 +0,0 @@ ---source include/have_ndb.inc -SET storage_engine=ndbcluster; ---source include/gis_generic.inc -set engine_condition_pushdown = on; ---source include/gis_generic.inc diff --git a/mysql-test/t/ndb_grant.later b/mysql-test/t/ndb_grant.later deleted file mode 100644 index 5431d94e1f8..00000000000 --- a/mysql-test/t/ndb_grant.later +++ /dev/null @@ -1,385 +0,0 @@ --- source include/have_ndb.inc -# Test of GRANT commands - -# Cleanup ---disable_warnings -drop table if exists t1; ---enable_warnings - -SET NAMES binary; - -# -# Alter mysql system tables to ndb -# make sure you alter all back in the end -# -use mysql; -alter table columns_priv engine=ndb; -alter table db engine=ndb; -alter table func engine=ndb; -alter table help_category engine=ndb; -alter table help_keyword engine=ndb; -alter table help_relation engine=ndb; -alter table help_topic engine=ndb; -alter table host engine=ndb; -alter table tables_priv engine=ndb; -alter table time_zone engine=ndb; -alter table time_zone_leap_second engine=ndb; -alter table time_zone_name engine=ndb; -alter table time_zone_transition engine=ndb; -alter table time_zone_transition_type engine=ndb; -alter table user engine=ndb; -use test; - -# -# Test that SSL options works properly -# -delete from mysql.user where user='mysqltest_1'; -delete from mysql.db where user='mysqltest_1'; -flush privileges; -begin; -grant select on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA"; -commit; -show grants for mysqltest_1@localhost; -begin; -grant delete on mysqltest.* to mysqltest_1@localhost; -commit; -select * from mysql.user where user="mysqltest_1"; -show grants for mysqltest_1@localhost; -begin; -revoke delete on mysqltest.* from mysqltest_1@localhost; -commit; -show grants for mysqltest_1@localhost; -begin; -grant select on mysqltest.* to mysqltest_1@localhost require NONE; -commit; -show grants for mysqltest_1@localhost; -begin; -grant USAGE on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "testsubject" ISSUER "MySQL AB"; -commit; -show grants for mysqltest_1@localhost; -begin; -revoke all privileges on mysqltest.* from mysqltest_1@localhost; -commit; -show grants for mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; -flush privileges; - -# -# Test that the new db privileges are stored/retrieved correctly -# - -begin; -grant CREATE TEMPORARY TABLES, LOCK TABLES on mysqltest.* to mysqltest_1@localhost; -commit; -show grants for mysqltest_1@localhost; -flush privileges; -show grants for mysqltest_1@localhost; -begin; -revoke CREATE TEMPORARY TABLES on mysqltest.* from mysqltest_1@localhost; -commit; -show grants for mysqltest_1@localhost; -begin; -grant ALL PRIVILEGES on mysqltest.* to mysqltest_1@localhost with GRANT OPTION; -commit; -flush privileges; -show grants for mysqltest_1@localhost; -begin; -revoke LOCK TABLES, ALTER on mysqltest.* from mysqltest_1@localhost; -commit; -show grants for mysqltest_1@localhost; -begin; -revoke all privileges on mysqltest.* from mysqltest_1@localhost; -commit; -delete from mysql.user where user='mysqltest_1'; -flush privileges; -begin; -grant usage on test.* to mysqltest_1@localhost with grant option; -commit; -show grants for mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; -delete from mysql.db where user='mysqltest_1'; -delete from mysql.tables_priv where user='mysqltest_1'; -delete from mysql.columns_priv where user='mysqltest_1'; -flush privileges; ---error 1141 -show grants for mysqltest_1@localhost; - -# -# Test what happens when you have same table and colum level grants -# - -create table t1 (a int); -begin; -GRANT select,update,insert on t1 to mysqltest_1@localhost; -GRANT select (a), update (a),insert(a), references(a) on t1 to mysqltest_1@localhost; -commit; -show grants for mysqltest_1@localhost; -select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; -begin; -REVOKE select (a), update on t1 from mysqltest_1@localhost; -commit; -show grants for mysqltest_1@localhost; -begin; -REVOKE select,update,insert,insert (a) on t1 from mysqltest_1@localhost; -commit; -show grants for mysqltest_1@localhost; -begin; -GRANT select,references on t1 to mysqltest_1@localhost; -commit; -select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; -begin; -grant all on test.* to mysqltest_3@localhost with grant option; -revoke all on test.* from mysqltest_3@localhost; -commit; -show grants for mysqltest_3@localhost; -begin; -revoke grant option on test.* from mysqltest_3@localhost; -commit; -show grants for mysqltest_3@localhost; -begin; -grant all on test.t1 to mysqltest_2@localhost with grant option; -revoke all on test.t1 from mysqltest_2@localhost; -commit; -show grants for mysqltest_2@localhost; -begin; -revoke grant option on test.t1 from mysqltest_2@localhost; -commit; -show grants for mysqltest_2@localhost; -delete from mysql.user where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; -delete from mysql.db where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; -delete from mysql.tables_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; -delete from mysql.columns_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; -flush privileges; -drop table t1; - -# -# Test some error conditions -# -begin; ---error 1221 -GRANT FILE on mysqltest.* to mysqltest_1@localhost; -commit; -select 1; -- To test that the previous command didn't cause problems - -# -# Bug#6123: GRANT USAGE inserts useless Db row -# -create database mysqltest1; -begin; -grant usage on mysqltest1.* to test6123 identified by 'magic123'; -commit; -select host,db,user,select_priv,insert_priv from mysql.db where db="mysqltest1"; -delete from mysql.user where user='test6123'; -drop database mysqltest1; - -# -# Test for 'drop user', 'revoke privileges, grant' -# - -create table t1 (a int); -begin; -grant ALL PRIVILEGES on *.* to drop_user2@localhost with GRANT OPTION; -commit; -show grants for drop_user2@localhost; -begin; -revoke all privileges, grant option from drop_user2@localhost; -commit; -drop user drop_user2@localhost; - -begin; -grant ALL PRIVILEGES on *.* to drop_user@localhost with GRANT OPTION; -grant ALL PRIVILEGES on test.* to drop_user@localhost with GRANT OPTION; -grant select(a) on test.t1 to drop_user@localhost; -commit; -show grants for drop_user@localhost; - -# -# Bug3086 -# -set sql_mode=ansi_quotes; -show grants for drop_user@localhost; -set sql_mode=default; - -set sql_quote_show_create=0; -show grants for drop_user@localhost; -set sql_mode="ansi_quotes"; -show grants for drop_user@localhost; -set sql_quote_show_create=1; -show grants for drop_user@localhost; -set sql_mode=""; -show grants for drop_user@localhost; - -revoke all privileges, grant option from drop_user@localhost; -show grants for drop_user@localhost; -drop user drop_user@localhost; -begin; ---error 1269 -revoke all privileges, grant option from drop_user@localhost; -commit; - -begin; -grant select(a) on test.t1 to drop_user1@localhost; -commit; -flush privileges; -begin; -grant select on test.t1 to drop_user2@localhost; -grant select on test.* to drop_user3@localhost; -grant select on *.* to drop_user4@localhost; -commit; -flush privileges; -# Drop user now implicitly revokes all privileges. -drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, -drop_user4@localhost; -begin; ---error 1269 -revoke all privileges, grant option from drop_user1@localhost, drop_user2@localhost, -drop_user3@localhost, drop_user4@localhost; -commit; -flush privileges; -#--error 1268 -drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, -drop_user4@localhost; -drop table t1; -begin; -grant usage on *.* to mysqltest_1@localhost identified by "password"; -grant select, update, insert on test.* to mysqltest_1@localhost; -commit; -show grants for mysqltest_1@localhost; -drop user mysqltest_1@localhost; - -# -# Bug #3403 Wrong encodin in SHOW GRANTS output -# -SET NAMES koi8r; -CREATE DATABASE ; -USE ; -CREATE TABLE ( int); - -begin; -GRANT SELECT ON .* TO @localhost; -commit; -SHOW GRANTS FOR @localhost; -begin; -REVOKE SELECT ON .* FROM @localhost; -commit; - -begin; -GRANT SELECT ON . TO @localhost; -commit; -SHOW GRANTS FOR @localhost; -begin; -REVOKE SELECT ON . FROM @localhost; -commit; - -begin; -GRANT SELECT () ON . TO @localhost; -commit; -SHOW GRANTS FOR @localhost; -begin; -REVOKE SELECT () ON . FROM @localhost; -commit; - -DROP DATABASE ; -SET NAMES latin1; - -# -# Bug #5831: REVOKE ALL PRIVILEGES, GRANT OPTION does not revoke everything -# -USE test; -CREATE TABLE t1 (a int ); -CREATE TABLE t2 LIKE t1; -CREATE TABLE t3 LIKE t1; -CREATE TABLE t4 LIKE t1; -CREATE TABLE t5 LIKE t1; -CREATE TABLE t6 LIKE t1; -CREATE TABLE t7 LIKE t1; -CREATE TABLE t8 LIKE t1; -CREATE TABLE t9 LIKE t1; -CREATE TABLE t10 LIKE t1; -CREATE DATABASE testdb1; -CREATE DATABASE testdb2; -CREATE DATABASE testdb3; -CREATE DATABASE testdb4; -CREATE DATABASE testdb5; -CREATE DATABASE testdb6; -CREATE DATABASE testdb7; -CREATE DATABASE testdb8; -CREATE DATABASE testdb9; -CREATE DATABASE testdb10; -begin; -GRANT ALL ON testdb1.* TO testuser@localhost; -GRANT ALL ON testdb2.* TO testuser@localhost; -GRANT ALL ON testdb3.* TO testuser@localhost; -GRANT ALL ON testdb4.* TO testuser@localhost; -GRANT ALL ON testdb5.* TO testuser@localhost; -GRANT ALL ON testdb6.* TO testuser@localhost; -GRANT ALL ON testdb7.* TO testuser@localhost; -GRANT ALL ON testdb8.* TO testuser@localhost; -GRANT ALL ON testdb9.* TO testuser@localhost; -GRANT ALL ON testdb10.* TO testuser@localhost; -GRANT SELECT ON test.t1 TO testuser@localhost; -GRANT SELECT ON test.t2 TO testuser@localhost; -GRANT SELECT ON test.t3 TO testuser@localhost; -GRANT SELECT ON test.t4 TO testuser@localhost; -GRANT SELECT ON test.t5 TO testuser@localhost; -GRANT SELECT ON test.t6 TO testuser@localhost; -GRANT SELECT ON test.t7 TO testuser@localhost; -GRANT SELECT ON test.t8 TO testuser@localhost; -GRANT SELECT ON test.t9 TO testuser@localhost; -GRANT SELECT ON test.t10 TO testuser@localhost; -GRANT SELECT (a) ON test.t1 TO testuser@localhost; -GRANT SELECT (a) ON test.t2 TO testuser@localhost; -GRANT SELECT (a) ON test.t3 TO testuser@localhost; -GRANT SELECT (a) ON test.t4 TO testuser@localhost; -GRANT SELECT (a) ON test.t5 TO testuser@localhost; -GRANT SELECT (a) ON test.t6 TO testuser@localhost; -GRANT SELECT (a) ON test.t7 TO testuser@localhost; -GRANT SELECT (a) ON test.t8 TO testuser@localhost; -GRANT SELECT (a) ON test.t9 TO testuser@localhost; -GRANT SELECT (a) ON test.t10 TO testuser@localhost; -commit; -begin; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM testuser@localhost; -commit; -SHOW GRANTS FOR testuser@localhost; -DROP USER testuser@localhost; -DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; -DROP DATABASE testdb1; -DROP DATABASE testdb2; -DROP DATABASE testdb3; -DROP DATABASE testdb4; -DROP DATABASE testdb5; -DROP DATABASE testdb6; -DROP DATABASE testdb7; -DROP DATABASE testdb8; -DROP DATABASE testdb9; -DROP DATABASE testdb10; - -# -# just SHOW PRIVILEGES test -# -SHOW PRIVILEGES; - -# -# Alter mysql system tables back to myisam -# -use mysql; -alter table columns_priv engine=myisam; -alter table db engine=myisam; -alter table func engine=myisam; -alter table help_category engine=myisam; -alter table help_keyword engine=myisam; -alter table help_relation engine=myisam; -alter table help_topic engine=myisam; -alter table host engine=myisam; -alter table tables_priv engine=myisam; -alter table time_zone engine=myisam; -alter table time_zone_leap_second engine=myisam; -alter table time_zone_name engine=myisam; -alter table time_zone_transition engine=myisam; -alter table time_zone_transition_type engine=myisam; -alter table user engine=myisam; -use test; -flush privileges; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_index.test b/mysql-test/t/ndb_index.test deleted file mode 100644 index 272f30e3e6f..00000000000 --- a/mysql-test/t/ndb_index.test +++ /dev/null @@ -1,131 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -CREATE TABLE t1 ( - PORT varchar(16) NOT NULL, - ACCESSNODE varchar(16) NOT NULL, - POP varchar(48) NOT NULL, - ACCESSTYPE int unsigned NOT NULL, - CUSTOMER_ID varchar(20) collate latin1_bin NOT NULL, - PROVIDER varchar(16), - TEXPIRE int unsigned, - NUM_IP int unsigned, - LEASED_NUM_IP int unsigned, - LOCKED_IP int unsigned, - STATIC_DNS int unsigned, - SUSPENDED_SERVICE int unsigned, - SUSPENDED_REASON int unsigned, - BGP_COMMUNITY int unsigned, - INDEX CUSTOMER_ID_INDEX(CUSTOMER_ID), - INDEX FQPN_INDEX(POP,ACCESSNODE,PORT), - PRIMARY KEY(POP,ACCESSNODE,PORT,ACCESSTYPE) -) engine=ndbcluster; - -INSERT INTO t1 VALUES ('port67', 'node78', 'pop98', 1, 'kllopmn', 'pr_43', 121212, 1, 2, 3, 8, NULL, NULL, NULL); -INSERT INTO t1 VALUES ('port67', 'node78', 'pop99', 2, 'klkighh', 'pr_44', 121213, 3, 3, 6, 7, NULL, NULL, NULL); -INSERT INTO t1 VALUES ('port79', 'node79', 'pop79', 2, 'kpongfaa', 'pr_44', 981213, 2, 4, 10, 11, 2, 99, 1278); - - -# Test select using port -select port, accessnode, pop, accesstype from t1 where port='port67' order by accesstype; -select port, accessnode, pop, accesstype from t1 where port='foo'; - -# Test select using accessnode -select port, accessnode, pop, accesstype from t1 where accessnode='node78' order by accesstype; -select port, accessnode, pop, accesstype from t1 where accessnode='foo'; - -# Test select using pop -select port, accessnode, pop, accesstype from t1 where pop='pop98'; -select port, accessnode, pop, accesstype from t1 where pop='pop98'; -select port, accessnode, pop, accesstype from t1 where pop='pop98'; -select port, accessnode, pop, accesstype from t1 where pop='pop98' order by accesstype; -# The following two querys will not return any rows since -# the index used for access is case sensitive -# They are thus disabled for now -#select port, accessnode, pop, accesstype from t1 where pop='POP98'; -#select port, accessnode, pop, accesstype from t1 where pop='POP98' order by accesstype; -select port, accessnode, pop, accesstype from t1 where pop='foo'; - -# Test select using accesstype -select port, accessnode, pop, accesstype from t1 where accesstype=1; -select port, accessnode, pop, accesstype from t1 where accesstype=2 order by port; -select port, accessnode, pop, accesstype from t1 where accesstype=98 order by port; - -# Test select using customer_id -# NOTE! customer_id has a INDEX (ordered index in NDB), it's case sensitive! -select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn'; -select port, accessnode, pop, accesstype from t1 where customer_id='KLLOPMN'; -select port, accessnode, pop, accesstype from t1 where customer_id='kLLoPMn'; -select port, accessnode, pop, accesstype from t1 where customer_id='foo'; - -# Test select using provider -select port, accessnode, pop, accesstype from t1 where provider='pr_43'; -select port, accessnode, pop, accesstype from t1 where provider='foo'; - -# Test select using texpire -select port, accessnode from t1 where texpire=121212; -select port, accessnode from t1 where texpire=2323; - -# Test select using num_ip -select port, accessnode, pop, accesstype from t1 where num_ip=1; -select port, accessnode, pop, accesstype from t1 where num_ip=89; - -# Test select using leased_num_ip -select port, accessnode, pop, accesstype from t1 where leased_num_ip=2; -select port, accessnode, pop, accesstype from t1 where leased_num_ip=89; - -# Test select using locked_ip -select port, accessnode, pop, accesstype from t1 where locked_ip=3; -select port, accessnode, pop, accesstype from t1 where locked_ip=89; - -# Test select using static_dns -select port, accessnode, pop, accesstype from t1 where static_dns=8; -select port, accessnode, pop, accesstype from t1 where static_dns=89; - -# Test select using suspended_service -select port, accessnode, pop, accesstype from t1 where suspended_service=8; -select port, accessnode, pop, accesstype from t1 where suspended_service=89; - -# Test select using suspended_reason -select port, accessnode, pop, accesstype from t1 where suspended_reason=NULL; -select port, accessnode, pop, accesstype from t1 where suspended_reason=89; -select port, accessnode, pop, accesstype from t1 where suspended_reason=0; - -# Test select using bgp_community -select port, accessnode, pop, accesstype from t1 where bgp_community=NULL; -select port, accessnode, pop, accesstype from t1 where bgp_community=89; -select port, accessnode, pop, accesstype from t1 where bgp_community=0; - -# Test select using full primary key -select port, accessnode, pop, accesstype from t1 where port='port67' and accessnode='node78' and pop='pop98' and accesstype=1; -select port, accessnode, pop, accesstype from t1 where port='port67' and accesstype=1 and accessnode='node78' and pop='pop98'; -select port, accessnode, pop, accesstype from t1 where pop='pop98' and port='port67' and accesstype=1 and accessnode='node78'; -select port, accessnode from t1 where port='foo' and accessnode='foo' and pop='foo' and accesstype=99; - -# Test select using partial primary key -select port, accessnode, pop, accesstype from t1 where port='port67' and pop='pop98' and accesstype=1; -select port, accessnode, pop, accesstype from t1 where accesstype=1 and accessnode='node78' and pop='pop98'; -select port, accessnode, pop, accesstype from t1 where port='port67' and accesstype=1 and accessnode='node78'; -select port, accessnode from t1 where port='foo' and accessnode='foo' and pop='foo'; - -# Test select using CUSTOMER_ID_INDEX -select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn'; -select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn' and accesstype=1; -select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn' and accesstype=2; -select port, accessnode, pop, accesstype from t1 where accesstype=2 and customer_id='kllopmn'; - -# Test select using FQPN_INDEX -select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67'; -#select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67' order by accesstype; -#select port, accessnode, pop, accesstype from t1 where accessnode='node78' and port='port67' and pop='pop98' order by accesstype; -#select port, accessnode, pop, accesstype from t1 where port='port67' and pop='pop98' and accessnode='node78' order by accesstype; -select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67' and customer_id='kllopmn'; -select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67' and customer_id='foo'; - -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test deleted file mode 100644 index 31385fd56b2..00000000000 --- a/mysql-test/t/ndb_index_ordered.test +++ /dev/null @@ -1,370 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1, test1, test2; ---enable_warnings - -# -# Simple test to show use of ordered indexes -# - -CREATE TABLE t1 ( - a int unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned, - KEY(b) -) engine=ndbcluster; - -insert t1 values(1, 2, 3), (2,3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); -select * from t1 order by b; -select * from t1 where b >= 4 order by b; -select * from t1 where b = 4 order by b; -select * from t1 where b > 4 order by b; -select * from t1 where b < 4 order by b; -select * from t1 where b <= 4 order by b; - -# Test of reset_bounds -select tt1.* from t1 as tt1, t1 as tt2 use index(b) where tt1.b = tt2.b order by tt1.b; -select a, b, c from t1 where a!=2 and c=6; -select a, b, c from t1 where a!=2 order by a; - -# -# Here we should add some "explain select" to verify that the ordered index is -# used for these queries. -# - -# -# Update using ordered index scan -# - -update t1 set c = 3 where b = 3; -select * from t1 order by a; -update t1 set c = 10 where b >= 6; -select * from t1 order by a; -update t1 set c = 11 where b < 5; -select * from t1 order by a; -update t1 set c = 12 where b > 0; -select * from t1 order by a; -update t1 set c = 13 where b <= 3; -select * from t1 order by a; -update t1 set b = b + 1 where b > 4 and b < 7; -select * from t1 order by a; -# Update primary key -update t1 set a = a + 10 where b > 1 and b < 7; -select * from t1 order by a; - -# -# Delete using ordered index scan -# - -drop table t1; - -CREATE TABLE t1 ( - a int unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned, - KEY(b) -) engine=ndbcluster; - -insert t1 values(1, 2, 13), (2,3, 13), (3, 4, 12), (4, 5, 12), (5,6, 12), (6,7, 12); - -delete from t1 where b = 3; -select * from t1 order by a; -delete from t1 where b >= 6; -select * from t1 order by a; -delete from t1 where b < 4; -select * from t1 order by a; -delete from t1 where b > 5; -select * from t1 order by a; -delete from t1 where b <= 4; -select * from t1 order by a; - -drop table t1; - - -# -#multi part key -# -CREATE TABLE t1 ( - a int unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned not null -) engine = ndb; - -create index a1 on t1 (b, c); - -insert into t1 values (1, 2, 13); -insert into t1 values (2,3, 13); -insert into t1 values (3, 4, 12); -insert into t1 values (4, 5, 12); -insert into t1 values (5,6, 12); -insert into t1 values (6,7, 12); -insert into t1 values (7, 2, 1); -insert into t1 values (8,3, 6); -insert into t1 values (9, 4, 12); -insert into t1 values (14, 5, 4); -insert into t1 values (15,5,5); -insert into t1 values (16,5, 6); -insert into t1 values (17,4,4); -insert into t1 values (18,1, 7); - - - -select * from t1 order by a; -select * from t1 where b<=5 order by a; -select * from t1 where b<=5 and c=0; -insert into t1 values (19,4, 0); -select * from t1 where b<=5 and c=0; -select * from t1 where b=4 and c<=5 order by a; -select * from t1 where b<=4 and c<=5 order by a; -select * from t1 where b<=5 and c=0 or b<=5 and c=2; - -select count(*) from t1 where b = 0; -select count(*) from t1 where b = 1; -drop table t1; - -# -# Indexing NULL values -# - -CREATE TABLE t1 ( - a int unsigned NOT NULL PRIMARY KEY, - b int unsigned, - c int unsigned, - KEY bc(b,c) -) engine = ndb; - -insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); -select * from t1 use index (bc) where b IS NULL order by a; - -select * from t1 use index (bc)order by a; -select * from t1 use index (bc) order by a; -select * from t1 use index (PRIMARY) where b IS NULL order by a; -select * from t1 use index (bc) where b IS NULL order by a; -select * from t1 use index (bc) where b IS NULL and c IS NULL order by a; -select * from t1 use index (bc) where b IS NULL and c = 2 order by a; -select * from t1 use index (bc) where b < 4 order by a; -select * from t1 use index (bc) where b IS NOT NULL order by a; -drop table t1; - -# -# Order by again, including descending. -# - -create table t1 ( - a int unsigned primary key, - b int unsigned, - c char(10), - key bc (b, c) -) engine=ndb; - -insert into t1 values(1,1,'a'),(2,2,'b'),(3,3,'c'),(4,4,'d'),(5,5,'e'); -insert into t1 select a*7,10*b,'f' from t1; -insert into t1 select a*13,10*b,'g' from t1; -insert into t1 select a*17,10*b,'h' from t1; -insert into t1 select a*19,10*b,'i' from t1; -insert into t1 select a*23,10*b,'j' from t1; -insert into t1 select a*29,10*b,'k' from t1; -# -select b, c from t1 where b <= 10 and c <'f' order by b, c; -select b, c from t1 where b <= 10 and c <'f' order by b desc, c desc; -# -select b, c from t1 where b=4000 and c<'k' order by b, c; -select b, c from t1 where b=4000 and c<'k' order by b desc, c desc; -select b, c from t1 where 1000<=b and b<=100000 and c<'j' order by b, c; -select b, c from t1 where 1000<=b and b<=100000 and c<'j' order by b desc, c desc; -# -select min(b), max(b) from t1; -# -drop table t1; - -# -# Bug #6435 -CREATE TABLE test1 ( -SubscrID int(11) NOT NULL auto_increment, -UsrID int(11) NOT NULL default '0', -PRIMARY KEY (SubscrID), -KEY idx_usrid (UsrID) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; - -INSERT INTO test1 VALUES (2,224),(3,224),(1,224); - -CREATE TABLE test2 ( -SbclID int(11) NOT NULL auto_increment, -SbcrID int(11) NOT NULL default '0', -PRIMARY KEY (SbclID), -KEY idx_sbcrid (SbcrID) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; - -INSERT INTO test2 VALUES (3,2),(1,1),(2,1),(4,2); -select * from test1 order by 1; -select * from test2 order by 1; -SELECT s.SubscrID,l.SbclID FROM test1 s left JOIN test2 l ON -l.SbcrID=s.SubscrID WHERE s.UsrID=224 order by 1, 2; -drop table test1; -drop table test2; - -# bug#7424 + bug#7725 - -create table t1 ( - pk int primary key, - dt datetime not null, - da date not null, - ye year not null, - ti time not null, - ts timestamp not null, - index(dt), - index(da), - index(ye), - index(ti), - index(ts) -) engine=ndb; - -insert into t1 (pk,dt,da,ye,ti,ts) values - (1, '1901-05-05 23:00:59', '1901-05-05', '1901', '23:00:59', '2001-01-01 23:00:59'), - (2, '1912-09-05 13:00:59', '1912-09-05', '1912', '13:00:59', '2001-01-01 13:00:59'), - (3, '1945-12-31 00:00:00', '1945-12-31', '1945', '00:00:00', '2001-01-01 00:00:00'), - (4, '1955-12-31 00:00:00', '1955-12-31', '1955', '00:00:00', '2001-01-01 00:00:00'), - (5, '1963-06-06 06:06:06', '1963-06-06', '1963', '06:06:06', '2001-01-01 06:06:06'), - (6, '1993-06-06 06:06:06', '1993-06-06', '1993', '06:06:06', '2001-01-01 06:06:06'), - (7, '2001-01-01 10:11:10', '2001-01-01', '2001', '10:11:10', '2001-01-01 10:11:10'), - (8, '2001-01-01 10:11:11', '2001-01-01', '2001', '10:11:11', '2001-01-01 10:11:11'), - (9, '2005-01-31 23:59:59', '2005-01-31', '2005', '23:59:59', '2001-01-01 23:59:59'); - -# datetime -select count(*)-9 from t1 use index (dt) where dt > '1900-01-01 00:00:00'; -select count(*)-6 from t1 use index (dt) where dt >= '1955-12-31 00:00:00'; -select count(*)-5 from t1 use index (dt) where dt > '1955-12-31 00:00:00'; -select count(*)-5 from t1 use index (dt) where dt < '1970-03-03 22:22:22'; -select count(*)-7 from t1 use index (dt) where dt < '2001-01-01 10:11:11'; -select count(*)-8 from t1 use index (dt) where dt <= '2001-01-01 10:11:11'; -select count(*)-9 from t1 use index (dt) where dt <= '2055-01-01 00:00:00'; - -# date -select count(*)-9 from t1 use index (da) where da > '1900-01-01'; -select count(*)-6 from t1 use index (da) where da >= '1955-12-31'; -select count(*)-5 from t1 use index (da) where da > '1955-12-31'; -select count(*)-5 from t1 use index (da) where da < '1970-03-03'; -select count(*)-6 from t1 use index (da) where da < '2001-01-01'; -select count(*)-8 from t1 use index (da) where da <= '2001-01-02'; -select count(*)-9 from t1 use index (da) where da <= '2055-01-01'; - -# year -select count(*)-9 from t1 use index (ye) where ye > '1900'; -select count(*)-6 from t1 use index (ye) where ye >= '1955'; -select count(*)-5 from t1 use index (ye) where ye > '1955'; -select count(*)-5 from t1 use index (ye) where ye < '1970'; -select count(*)-6 from t1 use index (ye) where ye < '2001'; -select count(*)-8 from t1 use index (ye) where ye <= '2001'; -select count(*)-9 from t1 use index (ye) where ye <= '2055'; - -# time -select count(*)-9 from t1 use index (ti) where ti >= '00:00:00'; -select count(*)-7 from t1 use index (ti) where ti > '00:00:00'; -select count(*)-7 from t1 use index (ti) where ti > '05:05:05'; -select count(*)-5 from t1 use index (ti) where ti > '06:06:06'; -select count(*)-5 from t1 use index (ti) where ti < '10:11:11'; -select count(*)-6 from t1 use index (ti) where ti <= '10:11:11'; -select count(*)-8 from t1 use index (ti) where ti < '23:59:59'; -select count(*)-9 from t1 use index (ti) where ti <= '23:59:59'; - -# timestamp -select count(*)-9 from t1 use index (ts) where ts >= '2001-01-01 00:00:00'; -select count(*)-7 from t1 use index (ts) where ts > '2001-01-01 00:00:00'; -select count(*)-7 from t1 use index (ts) where ts > '2001-01-01 05:05:05'; -select count(*)-5 from t1 use index (ts) where ts > '2001-01-01 06:06:06'; -select count(*)-5 from t1 use index (ts) where ts < '2001-01-01 10:11:11'; -select count(*)-6 from t1 use index (ts) where ts <= '2001-01-01 10:11:11'; -select count(*)-8 from t1 use index (ts) where ts < '2001-01-01 23:59:59'; -select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; - -drop table t1; - -# decimal (not the new 5.0 thing) - -create table t1 ( - a int primary key, - s decimal(12), - t decimal(12, 5), - u decimal(12) unsigned, - v decimal(12, 5) unsigned, - key (s), - key (t), - key (u), - key (v) -) engine=ndb; -# -insert into t1 values - ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), - ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), - ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), - ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), - ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), - ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), - ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), - ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), - ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), - ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); -# -select count(*)- 5 from t1 use index (s) where s < -000000000007; -select count(*)- 7 from t1 use index (s) where s <= -000000000007; -select count(*)- 2 from t1 use index (s) where s = -000000000007; -select count(*)- 5 from t1 use index (s) where s >= -000000000007; -select count(*)- 3 from t1 use index (s) where s > -000000000007; -# -select count(*)- 4 from t1 use index (t) where t < -0000061.00003; -select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; -select count(*)- 1 from t1 use index (t) where t = -0000061.00003; -select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; -select count(*)- 5 from t1 use index (t) where t > -0000061.00003; -# -select count(*)- 2 from t1 use index (u) where u < 000000000061; -select count(*)- 4 from t1 use index (u) where u <= 000000000061; -select count(*)- 2 from t1 use index (u) where u = 000000000061; -select count(*)- 8 from t1 use index (u) where u >= 000000000061; -select count(*)- 6 from t1 use index (u) where u > 000000000061; -# -select count(*)- 5 from t1 use index (v) where v < 0000965.00042; -select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; -select count(*)- 1 from t1 use index (v) where v = 0000965.00042; -select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; -select count(*)- 4 from t1 use index (v) where v > 0000965.00042; - -drop table t1; - -# bug#7798 -create table t1(a int primary key, b int not null, index(b)); -insert into t1 values (1,1), (2,2); -connect (con1,localhost,root,,test); -connect (con2,localhost,root,,test); -connection con1; -set autocommit=0; -begin; -select count(*) from t1; -connection con2; -ALTER TABLE t1 ADD COLUMN c int; -connection con1; -select a from t1 where b = 2; -show tables; -drop table t1; - -# mysqld 5.0.13 crash, no bug# -create table t1 (a int, c varchar(10), - primary key using hash (a), index(c)) engine=ndb; -insert into t1 (a, c) values (1,'aaa'),(3,'bbb'); -select count(*) from t1 where c<'bbb'; - -# End of 4.1 tests - -# bug#24820 CREATE INDEX ....USING HASH on NDB table creates ordered index, not HASH index - ---error ER_CANT_CREATE_TABLE -create table nationaldish (DishID int(10) unsigned NOT NULL AUTO_INCREMENT, - CountryCode char(3) NOT NULL, - DishTitle varchar(64) NOT NULL, - calories smallint(5) unsigned DEFAULT NULL, - PRIMARY KEY (DishID), - INDEX i USING HASH (countrycode,calories) - ) ENGINE=ndbcluster; - diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test deleted file mode 100644 index 18eec046074..00000000000 --- a/mysql-test/t/ndb_index_unique.test +++ /dev/null @@ -1,347 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1, t2, t3, t4, t5, t6, t7, t8; ---enable_warnings - -# -# Simple test to show use of UNIQUE indexes -# - -CREATE TABLE t1 ( - a int unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned, - UNIQUE(b) -) engine=ndbcluster; - -insert t1 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); -select * from t1 order by b; -select * from t1 where b = 4 order by b; -insert into t1 values(7,8,3); -select * from t1 where b = 4 order by a; - --- error 1062 -insert into t1 values(8, 2, 3); -select * from t1 order by a; -delete from t1 where a = 1; -insert into t1 values(8, 2, 3); -select * from t1 order by a; - -drop table t1; - -# -# Indexing NULL values -# - -CREATE TABLE t1 ( - a int unsigned NOT NULL PRIMARY KEY, - b int unsigned, - c int unsigned, - UNIQUE bc(b,c) -) engine = ndb; - -insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); -select * from t1 use index (bc) where b IS NULL order by a; - -select * from t1 use index (bc)order by a; -select * from t1 use index (bc) order by a; -select * from t1 use index (PRIMARY) where b IS NULL order by a; -select * from t1 use index (bc) where b IS NULL order by a; -select * from t1 use index (bc) where b IS NULL and c IS NULL order by a; -select * from t1 use index (bc) where b IS NULL and c = 2 order by a; -select * from t1 use index (bc) where b < 4 order by a; -select * from t1 use index (bc) where b IS NOT NULL order by a; --- error 1062 -insert into t1 values(5,1,1); -drop table t1; - - -# -# Show use of UNIQUE USING HASH indexes -# - -CREATE TABLE t2 ( - a int unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned not null, - UNIQUE USING HASH (b, c) -) engine=ndbcluster; - -insert t2 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); -select * from t2 where a = 3; -select * from t2 where b = 4; -select * from t2 where c = 6; -insert into t2 values(7,8,3); -select * from t2 where b = 4 order by a; - --- error 1062 -insert into t2 values(8, 2, 3); -select * from t2 order by a; -delete from t2 where a = 1; -insert into t2 values(8, 2, 3); -select * from t2 order by a; - -# Bug #24818 CREATE UNIQUE INDEX (...) USING HASH on a NDB table crashes mysqld -create unique index bi using hash on t2(b); --- error 1062 -insert into t2 values(9, 3, 1); -alter table t2 drop index bi; -insert into t2 values(9, 3, 1); -select * from t2 order by a; - -drop table t2; - -CREATE TABLE t2 ( - a int unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned, - UNIQUE USING HASH (b, c) -) engine=ndbcluster; - - -insert t2 values(1,1,NULL),(2,2,2),(3,3,NULL),(4,4,4),(5,5,NULL),(6,6,6),(7,7,NULL),(8,3,NULL),(9,3,NULL); - -select * from t2 where c IS NULL order by a; -select * from t2 where b = 3 AND c IS NULL order by a; -select * from t2 where (b = 3 OR b = 5) AND c IS NULL order by a; -set @old_ecpd = @@session.engine_condition_pushdown; -set engine_condition_pushdown = true; -explain select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a; -select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a; -set engine_condition_pushdown = @old_ecpd; - -drop table t2; - -# -# Show use of PRIMARY KEY USING HASH indexes -# - -CREATE TABLE t3 ( - a int unsigned NOT NULL, - b int unsigned not null, - c int unsigned, - PRIMARY KEY USING HASH (a, b) -) engine=ndbcluster; - -insert t3 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); -select * from t3 where a = 3; -select * from t3 where b = 4; -select * from t3 where c = 6; -insert into t3 values(7,8,3); -select * from t3 where b = 4 order by a; - -drop table t3; - -# -# Indexes on NULL-able columns -# - -CREATE TABLE t1 ( - pk int NOT NULL PRIMARY KEY, - a int unsigned, - UNIQUE KEY (a) -) engine=ndbcluster; - -insert into t1 values (-1,NULL), (0,0), (1,NULL),(2,2),(3,NULL),(4,4); - -select * from t1 order by pk; - ---error 1062 -insert into t1 values (5,0); -select * from t1 order by pk; -delete from t1 where a = 0; -insert into t1 values (5,0); -select * from t1 order by pk; - -CREATE TABLE t2 ( - pk int NOT NULL PRIMARY KEY, - a int unsigned, - b tinyint NOT NULL, - c VARCHAR(10), - UNIQUE KEY si(a, c) -) engine=ndbcluster; - -insert into t2 values (-1,1,17,NULL),(0,NULL,18,NULL),(1,3,19,'abc'); - -select * from t2 order by pk; - ---error 1062 -insert into t2 values(2,3,19,'abc'); -select * from t2 order by pk; -delete from t2 where c IS NOT NULL; -insert into t2 values(2,3,19,'abc'); -select * from t2 order by pk; - -drop table t1, t2; - -# -# More complex tables -# - -CREATE TABLE t1 ( - cid smallint(5) unsigned NOT NULL default '0', - cv varchar(250) NOT NULL default '', - PRIMARY KEY (cid), - UNIQUE KEY cv (cv) -) engine=ndbcluster; -INSERT INTO t1 VALUES (8,'dummy'); -CREATE TABLE t2 ( - cid bigint(20) unsigned NOT NULL auto_increment, - cap varchar(255) NOT NULL default '', - PRIMARY KEY (cid), - UNIQUE KEY (cid, cap) -) engine=ndbcluster; -INSERT INTO t2 VALUES (NULL,'another dummy'); -CREATE TABLE t3 ( - gid bigint(20) unsigned NOT NULL auto_increment, - gn varchar(255) NOT NULL default '', - must tinyint(4) default NULL, - PRIMARY KEY (gid) -) engine=ndbcluster; -INSERT INTO t3 VALUES (1,'V1',NULL); -CREATE TABLE t4 ( - uid bigint(20) unsigned NOT NULL default '0', - gid bigint(20) unsigned NOT NULL, - rid bigint(20) unsigned NOT NULL, - cid bigint(20) unsigned NOT NULL, - UNIQUE KEY m (uid,gid,rid,cid) -) engine=ndbcluster; -INSERT INTO t4 VALUES (1,1,2,4); -INSERT INTO t4 VALUES (1,1,2,3); -INSERT INTO t4 VALUES (1,1,5,7); -INSERT INTO t4 VALUES (1,1,10,8); -CREATE TABLE t5 ( - rid bigint(20) unsigned NOT NULL auto_increment, - rl varchar(255) NOT NULL default '', - PRIMARY KEY (rid) -) engine=ndbcluster; -CREATE TABLE t6 ( - uid bigint(20) unsigned NOT NULL auto_increment, - un varchar(250) NOT NULL default '', - uc smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (uid), - UNIQUE KEY nc (un,uc) -) engine=ndbcluster; -INSERT INTO t6 VALUES (1,'test',8); -INSERT INTO t6 VALUES (2,'test2',9); -INSERT INTO t6 VALUES (3,'tre',3); -CREATE TABLE t7 ( - mid bigint(20) unsigned NOT NULL PRIMARY KEY, - uid bigint(20) unsigned NOT NULL default '0', - gid bigint(20) unsigned NOT NULL, - rid bigint(20) unsigned NOT NULL, - cid bigint(20) unsigned NOT NULL, - UNIQUE KEY m (uid,gid,rid,cid) -) engine=ndbcluster; -INSERT INTO t7 VALUES(1, 1, 1, 1, 1); -INSERT INTO t7 VALUES(2, 2, 1, 1, 1); -INSERT INTO t7 VALUES(3, 3, 1, 1, 1); -INSERT INTO t7 VALUES(4, 4, 1, 1, 1); -INSERT INTO t7 VALUES(5, 5, 1, 1, 1); -INSERT INTO t7 VALUES(6, 1, 1, 1, 6); -INSERT INTO t7 VALUES(7, 2, 1, 1, 7); -INSERT INTO t7 VALUES(8, 3, 1, 1, 8); -INSERT INTO t7 VALUES(9, 4, 1, 1, 9); -INSERT INTO t7 VALUES(10, 5, 1, 1, 10); - -select * from t1 where cv = 'dummy'; -select * from t1 where cv = 'test'; -select * from t2 where cap = 'another dummy'; -select * from t4 where uid = 1 and gid=1 and rid=2 and cid=4; -select * from t4 where uid = 1 and gid=1 and rid=1 and cid=4; -select * from t4 where uid = 1 order by cid; -select * from t4 where rid = 2 order by cid; -select * from t6 where un='test' and uc=8; -select * from t6 where un='test' and uc=7; -select * from t6 where un='test'; -select * from t7 where mid = 8; -select * from t7 where uid = 8; -select * from t7 where uid = 1 order by mid; -select * from t7 where uid = 4 order by mid; -select * from t7 where gid = 4; -select * from t7 where gid = 1 order by mid; -select * from t7 where cid = 4; -select * from t7 where cid = 8; - -# -# insert more records into t4 -# -let $1=100; -disable_query_log; -while ($1) -{ - eval insert into t4 values(1, $1, 5, 12); - eval insert into t4 values($1, 3, 9, 11); - dec $1; -} -enable_query_log; - -select * from t4 where uid = 1 and gid=1 and rid=2 and cid=4; -select * from t4 where uid = 1 and gid=1 and rid=1 and cid=4; -select * from t4 where uid = 1 order by gid,cid; -select * from t4 where uid = 1 order by gid,cid; -select * from t4 where rid = 2 order by cid; - - -drop table t1,t2,t3,t4,t5,t6,t7; - -# test null in indexes -CREATE TABLE t1 ( - a int unsigned NOT NULL PRIMARY KEY, - b int unsigned, - c int unsigned, - UNIQUE bc(b,c) ) engine = ndb; - -insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); -select * from t1 where b=1 and c=1; -select * from t1 where b is null and c is null; -select * from t1 where b is null and c = 2; -select * from t1 where b = 4 and c is null; -create table t8 as -select * from t1 where (b = 1 and c = 1) - or (b is null and c is null) - or (b is null and c = 2) - or (b = 4 and c is null); -select * from t8 order by a; -select * from t1 order by a; -drop table t1, t8; - -############################### -# Bug 8101 -# -# Unique index not specified in the same order as in table -# - -create table t1( - id integer not null auto_increment, - month integer not null, - year integer not null, - code varchar( 2) not null, - primary key ( id), - unique idx_t1( month, code, year) -) engine=ndb; - -INSERT INTO t1 (month, year, code) VALUES (4,2004,'12'); -INSERT INTO t1 (month, year, code) VALUES (5,2004,'12'); - -select * from t1 where code = '12' and month = 4 and year = 2004 ; - -drop table t1; - -# bug#15918 Unique Key Limit in NDB Engine - -create table t1 (a int primary key, b varchar(1000) not null, unique key (b)) -engine=ndb charset=utf8; - -insert into t1 values (1, repeat(_utf8 0xe288ab6474, 200)); ---error 1062 -insert into t1 values (2, repeat(_utf8 0xe288ab6474, 200)); -select a, sha1(b) from t1; - -# perl -e 'print pack("H2000","e288ab6474"x200)' | sha1sum - -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_insert.test b/mysql-test/t/ndb_insert.test deleted file mode 100644 index f85d193f0d4..00000000000 --- a/mysql-test/t/ndb_insert.test +++ /dev/null @@ -1,641 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - -# -# Basic test of INSERT in NDB -# - -# -# Create a normal table with primary key -# -CREATE TABLE t1 ( - pk1 INT NOT NULL PRIMARY KEY, - b INT NOT NULL, - c INT NOT NULL -) ENGINE=ndbcluster; - -INSERT INTO t1 VALUES (0, 0, 0); -SELECT * FROM t1; - -INSERT INTO t1 VALUES -(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), -(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), -(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), -(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), -(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), -(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), -(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), -(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), -(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45), -(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50), -(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55), -(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60), -(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65), -(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70), -(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75), -(76,76,76),(77,77,77),(78,78,78),(79,79,79),(80,80,80), -(81,81,81),(82,82,82),(83,83,83),(84,84,84),(85,85,85), -(86,86,86),(87,87,87),(88,88,88),(89,89,89),(90,90,90), -(91,91,91),(92,92,92),(93,93,93),(94,94,94),(95,95,95), -(96,96,96),(97,97,97),(98,98,98),(99,99,99),(100,100,100), -(101,101,101),(102,102,102),(103,103,103),(104,104,104),(105,105,105), -(106,106,106),(107,107,107),(108,108,108),(109,109,109),(110,110,110), -(111,111,111),(112,112,112),(113,113,113),(114,114,114),(115,115,115), -(116,116,116),(117,117,117),(118,118,118),(119,119,119),(120,120,120), -(121,121,121),(122,122,122),(123,123,123),(124,124,124),(125,125,125), -(126,126,126),(127,127,127),(128,128,128),(129,129,129),(130,130,130), -(131,131,131),(132,132,132),(133,133,133),(134,134,134),(135,135,135), -(136,136,136),(137,137,137),(138,138,138),(139,139,139),(140,140,140), -(141,141,141),(142,142,142),(143,143,143),(144,144,144),(145,145,145), -(146,146,146),(147,147,147),(148,148,148),(149,149,149),(150,150,150), -(151,151,151),(152,152,152),(153,153,153),(154,154,154),(155,155,155), -(156,156,156),(157,157,157),(158,158,158),(159,159,159),(160,160,160), -(161,161,161),(162,162,162),(163,163,163),(164,164,164),(165,165,165), -(166,166,166),(167,167,167),(168,168,168),(169,169,169),(170,170,170), -(171,171,171),(172,172,172),(173,173,173),(174,174,174),(175,175,175), -(176,176,176),(177,177,177),(178,178,178),(179,179,179),(180,180,180), -(181,181,181),(182,182,182),(183,183,183),(184,184,184),(185,185,185), -(186,186,186),(187,187,187),(188,188,188),(189,189,189),(190,190,190), -(191,191,191),(192,192,192),(193,193,193),(194,194,194),(195,195,195), -(196,196,196),(197,197,197),(198,198,198),(199,199,199),(200,200,200), -(201,201,201),(202,202,202),(203,203,203),(204,204,204),(205,205,205), -(206,206,206),(207,207,207),(208,208,208),(209,209,209),(210,210,210), -(211,211,211),(212,212,212),(213,213,213),(214,214,214),(215,215,215), -(216,216,216),(217,217,217),(218,218,218),(219,219,219),(220,220,220), -(221,221,221),(222,222,222),(223,223,223),(224,224,224),(225,225,225), -(226,226,226),(227,227,227),(228,228,228),(229,229,229),(230,230,230), -(231,231,231),(232,232,232),(233,233,233),(234,234,234),(235,235,235), -(236,236,236),(237,237,237),(238,238,238),(239,239,239),(240,240,240), -(241,241,241),(242,242,242),(243,243,243),(244,244,244),(245,245,245), -(246,246,246),(247,247,247),(248,248,248),(249,249,249),(250,250,250), -(251,251,251),(252,252,252),(253,253,253),(254,254,254),(255,255,255), -(256,256,256),(257,257,257),(258,258,258),(259,259,259),(260,260,260), -(261,261,261),(262,262,262),(263,263,263),(264,264,264),(265,265,265), -(266,266,266),(267,267,267),(268,268,268),(269,269,269),(270,270,270), -(271,271,271),(272,272,272),(273,273,273),(274,274,274),(275,275,275), -(276,276,276),(277,277,277),(278,278,278),(279,279,279),(280,280,280), -(281,281,281),(282,282,282),(283,283,283),(284,284,284),(285,285,285), -(286,286,286),(287,287,287),(288,288,288),(289,289,289),(290,290,290), -(291,291,291),(292,292,292),(293,293,293),(294,294,294),(295,295,295), -(296,296,296),(297,297,297),(298,298,298),(299,299,299),(300,300,300), -(301,301,301),(302,302,302),(303,303,303),(304,304,304),(305,305,305), -(306,306,306),(307,307,307),(308,308,308),(309,309,309),(310,310,310), -(311,311,311),(312,312,312),(313,313,313),(314,314,314),(315,315,315), -(316,316,316),(317,317,317),(318,318,318),(319,319,319),(320,320,320), -(321,321,321),(322,322,322),(323,323,323),(324,324,324),(325,325,325), -(326,326,326),(327,327,327),(328,328,328),(329,329,329),(330,330,330), -(331,331,331),(332,332,332),(333,333,333),(334,334,334),(335,335,335), -(336,336,336),(337,337,337),(338,338,338),(339,339,339),(340,340,340), -(341,341,341),(342,342,342),(343,343,343),(344,344,344),(345,345,345), -(346,346,346),(347,347,347),(348,348,348),(349,349,349),(350,350,350), -(351,351,351),(352,352,352),(353,353,353),(354,354,354),(355,355,355), -(356,356,356),(357,357,357),(358,358,358),(359,359,359),(360,360,360), -(361,361,361),(362,362,362),(363,363,363),(364,364,364),(365,365,365), -(366,366,366),(367,367,367),(368,368,368),(369,369,369),(370,370,370), -(371,371,371),(372,372,372),(373,373,373),(374,374,374),(375,375,375), -(376,376,376),(377,377,377),(378,378,378),(379,379,379),(380,380,380), -(381,381,381),(382,382,382),(383,383,383),(384,384,384),(385,385,385), -(386,386,386),(387,387,387),(388,388,388),(389,389,389),(390,390,390), -(391,391,391),(392,392,392),(393,393,393),(394,394,394),(395,395,395), -(396,396,396),(397,397,397),(398,398,398),(399,399,399),(400,400,400), -(401,401,401),(402,402,402),(403,403,403),(404,404,404),(405,405,405), -(406,406,406),(407,407,407),(408,408,408),(409,409,409),(410,410,410), -(411,411,411),(412,412,412),(413,413,413),(414,414,414),(415,415,415), -(416,416,416),(417,417,417),(418,418,418),(419,419,419),(420,420,420), -(421,421,421),(422,422,422),(423,423,423),(424,424,424),(425,425,425), -(426,426,426),(427,427,427),(428,428,428),(429,429,429),(430,430,430), -(431,431,431),(432,432,432),(433,433,433),(434,434,434),(435,435,435), -(436,436,436),(437,437,437),(438,438,438),(439,439,439),(440,440,440), -(441,441,441),(442,442,442),(443,443,443),(444,444,444),(445,445,445), -(446,446,446),(447,447,447),(448,448,448),(449,449,449),(450,450,450), -(451,451,451),(452,452,452),(453,453,453),(454,454,454),(455,455,455), -(456,456,456),(457,457,457),(458,458,458),(459,459,459),(460,460,460), -(461,461,461),(462,462,462),(463,463,463),(464,464,464),(465,465,465), -(466,466,466),(467,467,467),(468,468,468),(469,469,469),(470,470,470), -(471,471,471),(472,472,472),(473,473,473),(474,474,474),(475,475,475), -(476,476,476),(477,477,477),(478,478,478),(479,479,479),(480,480,480), -(481,481,481),(482,482,482),(483,483,483),(484,484,484),(485,485,485), -(486,486,486),(487,487,487),(488,488,488),(489,489,489),(490,490,490), -(491,491,491),(492,492,492),(493,493,493),(494,494,494),(495,495,495), -(496,496,496),(497,497,497),(498,498,498),(499,499,499),(500, 500, 500); - -SELECT COUNT(*) FROM t1; - -INSERT INTO t1 VALUES -(501,501,501),(502,502,502),(503,503,503),(504,504,504),(505,505,505), -(506,506,506),(507,507,507),(508,508,508),(509,509,509),(510,510,510), -(511,511,511),(512,512,512),(513,513,513),(514,514,514),(515,515,515), -(516,516,516),(517,517,517),(518,518,518),(519,519,519),(520,520,520), -(521,521,521),(522,522,522),(523,523,523),(524,524,524),(525,525,525), -(526,526,526),(527,527,527),(528,528,528),(529,529,529),(530,530,530), -(531,531,531),(532,532,532),(533,533,533),(534,534,534),(535,535,535), -(536,536,536),(537,537,537),(538,538,538),(539,539,539),(540,540,540), -(541,541,541),(542,542,542),(543,543,543),(544,544,544),(545,545,545), -(546,546,546),(547,547,547),(548,548,548),(549,549,549),(550,550,550), -(551,551,551),(552,552,552),(553,553,553),(554,554,554),(555,555,555), -(556,556,556),(557,557,557),(558,558,558),(559,559,559),(560,560,560), -(561,561,561),(562,562,562),(563,563,563),(564,564,564),(565,565,565), -(566,566,566),(567,567,567),(568,568,568),(569,569,569),(570,570,570), -(571,571,571),(572,572,572),(573,573,573),(574,574,574),(575,575,575), -(576,576,576),(577,577,577),(578,578,578),(579,579,579),(580,580,580), -(581,581,581),(582,582,582),(583,583,583),(584,584,584),(585,585,585), -(586,586,586),(587,587,587),(588,588,588),(589,589,589),(590,590,590), -(591,591,591),(592,592,592),(593,593,593),(594,594,594),(595,595,595), -(596,596,596),(597,597,597),(598,598,598),(599,599,599),(600,600,600), -(601,601,601),(602,602,602),(603,603,603),(604,604,604),(605,605,605), -(606,606,606),(607,607,607),(608,608,608),(609,609,609),(610,610,610), -(611,611,611),(612,612,612),(613,613,613),(614,614,614),(615,615,615), -(616,616,616),(617,617,617),(618,618,618),(619,619,619),(620,620,620), -(621,621,621),(622,622,622),(623,623,623),(624,624,624),(625,625,625), -(626,626,626),(627,627,627),(628,628,628),(629,629,629),(630,630,630), -(631,631,631),(632,632,632),(633,633,633),(634,634,634),(635,635,635), -(636,636,636),(637,637,637),(638,638,638),(639,639,639),(640,640,640), -(641,641,641),(642,642,642),(643,643,643),(644,644,644),(645,645,645), -(646,646,646),(647,647,647),(648,648,648),(649,649,649),(650,650,650), -(651,651,651),(652,652,652),(653,653,653),(654,654,654),(655,655,655), -(656,656,656),(657,657,657),(658,658,658),(659,659,659),(660,660,660), -(661,661,661),(662,662,662),(663,663,663),(664,664,664),(665,665,665), -(666,666,666),(667,667,667),(668,668,668),(669,669,669),(670,670,670), -(671,671,671),(672,672,672),(673,673,673),(674,674,674),(675,675,675), -(676,676,676),(677,677,677),(678,678,678),(679,679,679),(680,680,680), -(681,681,681),(682,682,682),(683,683,683),(684,684,684),(685,685,685), -(686,686,686),(687,687,687),(688,688,688),(689,689,689),(690,690,690), -(691,691,691),(692,692,692),(693,693,693),(694,694,694),(695,695,695), -(696,696,696),(697,697,697),(698,698,698),(699,699,699),(700,700,700), -(701,701,701),(702,702,702),(703,703,703),(704,704,704),(705,705,705), -(706,706,706),(707,707,707),(708,708,708),(709,709,709),(710,710,710), -(711,711,711),(712,712,712),(713,713,713),(714,714,714),(715,715,715), -(716,716,716),(717,717,717),(718,718,718),(719,719,719),(720,720,720), -(721,721,721),(722,722,722),(723,723,723),(724,724,724),(725,725,725), -(726,726,726),(727,727,727),(728,728,728),(729,729,729),(730,730,730), -(731,731,731),(732,732,732),(733,733,733),(734,734,734),(735,735,735), -(736,736,736),(737,737,737),(738,738,738),(739,739,739),(740,740,740), -(741,741,741),(742,742,742),(743,743,743),(744,744,744),(745,745,745), -(746,746,746),(747,747,747),(748,748,748),(749,749,749),(750,750,750), -(751,751,751),(752,752,752),(753,753,753),(754,754,754),(755,755,755), -(756,756,756),(757,757,757),(758,758,758),(759,759,759),(760,760,760), -(761,761,761),(762,762,762),(763,763,763),(764,764,764),(765,765,765), -(766,766,766),(767,767,767),(768,768,768),(769,769,769),(770,770,770), -(771,771,771),(772,772,772),(773,773,773),(774,774,774),(775,775,775), -(776,776,776),(777,777,777),(778,778,778),(779,779,779),(780,780,780), -(781,781,781),(782,782,782),(783,783,783),(784,784,784),(785,785,785), -(786,786,786),(787,787,787),(788,788,788),(789,789,789),(790,790,790), -(791,791,791),(792,792,792),(793,793,793),(794,794,794),(795,795,795), -(796,796,796),(797,797,797),(798,798,798),(799,799,799),(800,800,800), -(801,801,801),(802,802,802),(803,803,803),(804,804,804),(805,805,805), -(806,806,806),(807,807,807),(808,808,808),(809,809,809),(810,810,810), -(811,811,811),(812,812,812),(813,813,813),(814,814,814),(815,815,815), -(816,816,816),(817,817,817),(818,818,818),(819,819,819),(820,820,820), -(821,821,821),(822,822,822),(823,823,823),(824,824,824),(825,825,825), -(826,826,826),(827,827,827),(828,828,828),(829,829,829),(830,830,830), -(831,831,831),(832,832,832),(833,833,833),(834,834,834),(835,835,835), -(836,836,836),(837,837,837),(838,838,838),(839,839,839),(840,840,840), -(841,841,841),(842,842,842),(843,843,843),(844,844,844),(845,845,845), -(846,846,846),(847,847,847),(848,848,848),(849,849,849),(850,850,850), -(851,851,851),(852,852,852),(853,853,853),(854,854,854),(855,855,855), -(856,856,856),(857,857,857),(858,858,858),(859,859,859),(860,860,860), -(861,861,861),(862,862,862),(863,863,863),(864,864,864),(865,865,865), -(866,866,866),(867,867,867),(868,868,868),(869,869,869),(870,870,870), -(871,871,871),(872,872,872),(873,873,873),(874,874,874),(875,875,875), -(876,876,876),(877,877,877),(878,878,878),(879,879,879),(880,880,880), -(881,881,881),(882,882,882),(883,883,883),(884,884,884),(885,885,885), -(886,886,886),(887,887,887),(888,888,888),(889,889,889),(890,890,890), -(891,891,891),(892,892,892),(893,893,893),(894,894,894),(895,895,895), -(896,896,896),(897,897,897),(898,898,898),(899,899,899),(900,900,900), -(901,901,901),(902,902,902),(903,903,903),(904,904,904),(905,905,905), -(906,906,906),(907,907,907),(908,908,908),(909,909,909),(910,910,910), -(911,911,911),(912,912,912),(913,913,913),(914,914,914),(915,915,915), -(916,916,916),(917,917,917),(918,918,918),(919,919,919),(920,920,920), -(921,921,921),(922,922,922),(923,923,923),(924,924,924),(925,925,925), -(926,926,926),(927,927,927),(928,928,928),(929,929,929),(930,930,930), -(931,931,931),(932,932,932),(933,933,933),(934,934,934),(935,935,935), -(936,936,936),(937,937,937),(938,938,938),(939,939,939),(940,940,940), -(941,941,941),(942,942,942),(943,943,943),(944,944,944),(945,945,945), -(946,946,946),(947,947,947),(948,948,948),(949,949,949),(950,950,950), -(951,951,951),(952,952,952),(953,953,953),(954,954,954),(955,955,955), -(956,956,956),(957,957,957),(958,958,958),(959,959,959),(960,960,960), -(961,961,961),(962,962,962),(963,963,963),(964,964,964),(965,965,965), -(966,966,966),(967,967,967),(968,968,968),(969,969,969),(970,970,970), -(971,971,971),(972,972,972),(973,973,973),(974,974,974),(975,975,975), -(976,976,976),(977,977,977),(978,978,978),(979,979,979),(980,980,980), -(981,981,981),(982,982,982),(983,983,983),(984,984,984),(985,985,985), -(986,986,986),(987,987,987),(988,988,988),(989,989,989),(990,990,990), -(991,991,991),(992,992,992),(993,993,993),(994,994,994),(995,995,995), -(996,996,996),(997,997,997),(998,998,998),(999,999,999),(1000,1000,1000), -(1001,1001,1001),(1002,1002,1002),(1003,1003,1003),(1004,1004,1004),(1005,1005,1005), -(1006,1006,1006),(1007,1007,1007),(1008,1008,1008),(1009,1009,1009),(1010,1010,1010), -(1011,1011,1011),(1012,1012,1012),(1013,1013,1013),(1014,1014,1014),(1015,1015,1015), -(1016,1016,1016),(1017,1017,1017),(1018,1018,1018),(1019,1019,1019),(1020,1020,1020), -(1021,1021,1021),(1022,1022,1022),(1023,1023,1023),(1024,1024,1024),(1025,1025,1025), -(1026,1026,1026),(1027,1027,1027),(1028,1028,1028),(1029,1029,1029),(1030,1030,1030), -(1031,1031,1031),(1032,1032,1032),(1033,1033,1033),(1034,1034,1034),(1035,1035,1035), -(1036,1036,1036),(1037,1037,1037),(1038,1038,1038),(1039,1039,1039),(1040,1040,1040), -(1041,1041,1041),(1042,1042,1042),(1043,1043,1043),(1044,1044,1044),(1045,1045,1045), -(1046,1046,1046),(1047,1047,1047),(1048,1048,1048),(1049,1049,1049),(1050,1050,1050), -(1051,1051,1051),(1052,1052,1052),(1053,1053,1053),(1054,1054,1054),(1055,1055,1055), -(1056,1056,1056),(1057,1057,1057),(1058,1058,1058),(1059,1059,1059),(1060,1060,1060), -(1061,1061,1061),(1062,1062,1062),(1063,1063,1063),(1064,1064,1064),(1065,1065,1065), -(1066,1066,1066),(1067,1067,1067),(1068,1068,1068),(1069,1069,1069),(1070,1070,1070), -(1071,1071,1071),(1072,1072,1072),(1073,1073,1073),(1074,1074,1074),(1075,1075,1075), -(1076,1076,1076),(1077,1077,1077),(1078,1078,1078),(1079,1079,1079),(1080,1080,1080), -(1081,1081,1081),(1082,1082,1082),(1083,1083,1083),(1084,1084,1084),(1085,1085,1085), -(1086,1086,1086),(1087,1087,1087),(1088,1088,1088),(1089,1089,1089),(1090,1090,1090), -(1091,1091,1091),(1092,1092,1092),(1093,1093,1093),(1094,1094,1094),(1095,1095,1095), -(1096,1096,1096),(1097,1097,1097),(1098,1098,1098),(1099,1099,1099),(1100,1100,1100), -(1101,1101,1101),(1102,1102,1102),(1103,1103,1103),(1104,1104,1104),(1105,1105,1105), -(1106,1106,1106),(1107,1107,1107),(1108,1108,1108),(1109,1109,1109),(1110,1110,1110), -(1111,1111,1111),(1112,1112,1112),(1113,1113,1113),(1114,1114,1114),(1115,1115,1115), -(1116,1116,1116),(1117,1117,1117),(1118,1118,1118),(1119,1119,1119),(1120,1120,1120), -(1121,1121,1121),(1122,1122,1122),(1123,1123,1123),(1124,1124,1124),(1125,1125,1125), -(1126,1126,1126),(1127,1127,1127),(1128,1128,1128),(1129,1129,1129),(1130,1130,1130), -(1131,1131,1131),(1132,1132,1132),(1133,1133,1133),(1134,1134,1134),(1135,1135,1135), -(1136,1136,1136),(1137,1137,1137),(1138,1138,1138),(1139,1139,1139),(1140,1140,1140), -(1141,1141,1141),(1142,1142,1142),(1143,1143,1143),(1144,1144,1144),(1145,1145,1145), -(1146,1146,1146),(1147,1147,1147),(1148,1148,1148),(1149,1149,1149),(1150,1150,1150), -(1151,1151,1151),(1152,1152,1152),(1153,1153,1153),(1154,1154,1154),(1155,1155,1155), -(1156,1156,1156),(1157,1157,1157),(1158,1158,1158),(1159,1159,1159),(1160,1160,1160), -(1161,1161,1161),(1162,1162,1162),(1163,1163,1163),(1164,1164,1164),(1165,1165,1165), -(1166,1166,1166),(1167,1167,1167),(1168,1168,1168),(1169,1169,1169),(1170,1170,1170), -(1171,1171,1171),(1172,1172,1172),(1173,1173,1173),(1174,1174,1174),(1175,1175,1175), -(1176,1176,1176),(1177,1177,1177),(1178,1178,1178),(1179,1179,1179),(1180,1180,1180), -(1181,1181,1181),(1182,1182,1182),(1183,1183,1183),(1184,1184,1184),(1185,1185,1185), -(1186,1186,1186),(1187,1187,1187),(1188,1188,1188),(1189,1189,1189),(1190,1190,1190), -(1191,1191,1191),(1192,1192,1192),(1193,1193,1193),(1194,1194,1194),(1195,1195,1195), -(1196,1196,1196),(1197,1197,1197),(1198,1198,1198),(1199,1199,1199),(1200,1200,1200), -(1201,1201,1201),(1202,1202,1202),(1203,1203,1203),(1204,1204,1204),(1205,1205,1205), -(1206,1206,1206),(1207,1207,1207),(1208,1208,1208),(1209,1209,1209),(1210,1210,1210), -(1211,1211,1211),(1212,1212,1212),(1213,1213,1213),(1214,1214,1214),(1215,1215,1215), -(1216,1216,1216),(1217,1217,1217),(1218,1218,1218),(1219,1219,1219),(1220,1220,1220), -(1221,1221,1221),(1222,1222,1222),(1223,1223,1223),(1224,1224,1224),(1225,1225,1225), -(1226,1226,1226),(1227,1227,1227),(1228,1228,1228),(1229,1229,1229),(1230,1230,1230), -(1231,1231,1231),(1232,1232,1232),(1233,1233,1233),(1234,1234,1234),(1235,1235,1235), -(1236,1236,1236),(1237,1237,1237),(1238,1238,1238),(1239,1239,1239),(1240,1240,1240), -(1241,1241,1241),(1242,1242,1242),(1243,1243,1243),(1244,1244,1244),(1245,1245,1245), -(1246,1246,1246),(1247,1247,1247),(1248,1248,1248),(1249,1249,1249),(1250,1250,1250), -(1251,1251,1251),(1252,1252,1252),(1253,1253,1253),(1254,1254,1254),(1255,1255,1255), -(1256,1256,1256),(1257,1257,1257),(1258,1258,1258),(1259,1259,1259),(1260,1260,1260), -(1261,1261,1261),(1262,1262,1262),(1263,1263,1263),(1264,1264,1264),(1265,1265,1265), -(1266,1266,1266),(1267,1267,1267),(1268,1268,1268),(1269,1269,1269),(1270,1270,1270), -(1271,1271,1271),(1272,1272,1272),(1273,1273,1273),(1274,1274,1274),(1275,1275,1275), -(1276,1276,1276),(1277,1277,1277),(1278,1278,1278),(1279,1279,1279),(1280,1280,1280), -(1281,1281,1281),(1282,1282,1282),(1283,1283,1283),(1284,1284,1284),(1285,1285,1285), -(1286,1286,1286),(1287,1287,1287),(1288,1288,1288),(1289,1289,1289),(1290,1290,1290), -(1291,1291,1291),(1292,1292,1292),(1293,1293,1293),(1294,1294,1294),(1295,1295,1295), -(1296,1296,1296),(1297,1297,1297),(1298,1298,1298),(1299,1299,1299),(1300,1300,1300), -(1301,1301,1301),(1302,1302,1302),(1303,1303,1303),(1304,1304,1304),(1305,1305,1305), -(1306,1306,1306),(1307,1307,1307),(1308,1308,1308),(1309,1309,1309),(1310,1310,1310), -(1311,1311,1311),(1312,1312,1312),(1313,1313,1313),(1314,1314,1314),(1315,1315,1315), -(1316,1316,1316),(1317,1317,1317),(1318,1318,1318),(1319,1319,1319),(1320,1320,1320), -(1321,1321,1321),(1322,1322,1322),(1323,1323,1323),(1324,1324,1324),(1325,1325,1325), -(1326,1326,1326),(1327,1327,1327),(1328,1328,1328),(1329,1329,1329),(1330,1330,1330), -(1331,1331,1331),(1332,1332,1332),(1333,1333,1333),(1334,1334,1334),(1335,1335,1335), -(1336,1336,1336),(1337,1337,1337),(1338,1338,1338),(1339,1339,1339),(1340,1340,1340), -(1341,1341,1341),(1342,1342,1342),(1343,1343,1343),(1344,1344,1344),(1345,1345,1345), -(1346,1346,1346),(1347,1347,1347),(1348,1348,1348),(1349,1349,1349),(1350,1350,1350), -(1351,1351,1351),(1352,1352,1352),(1353,1353,1353),(1354,1354,1354),(1355,1355,1355), -(1356,1356,1356),(1357,1357,1357),(1358,1358,1358),(1359,1359,1359),(1360,1360,1360), -(1361,1361,1361),(1362,1362,1362),(1363,1363,1363),(1364,1364,1364),(1365,1365,1365), -(1366,1366,1366),(1367,1367,1367),(1368,1368,1368),(1369,1369,1369),(1370,1370,1370), -(1371,1371,1371),(1372,1372,1372),(1373,1373,1373),(1374,1374,1374),(1375,1375,1375), -(1376,1376,1376),(1377,1377,1377),(1378,1378,1378),(1379,1379,1379),(1380,1380,1380), -(1381,1381,1381),(1382,1382,1382),(1383,1383,1383),(1384,1384,1384),(1385,1385,1385), -(1386,1386,1386),(1387,1387,1387),(1388,1388,1388),(1389,1389,1389),(1390,1390,1390), -(1391,1391,1391),(1392,1392,1392),(1393,1393,1393),(1394,1394,1394),(1395,1395,1395), -(1396,1396,1396),(1397,1397,1397),(1398,1398,1398),(1399,1399,1399),(1400,1400,1400), -(1401,1401,1401),(1402,1402,1402),(1403,1403,1403),(1404,1404,1404),(1405,1405,1405), -(1406,1406,1406),(1407,1407,1407),(1408,1408,1408),(1409,1409,1409),(1410,1410,1410), -(1411,1411,1411),(1412,1412,1412),(1413,1413,1413),(1414,1414,1414),(1415,1415,1415), -(1416,1416,1416),(1417,1417,1417),(1418,1418,1418),(1419,1419,1419),(1420,1420,1420), -(1421,1421,1421),(1422,1422,1422),(1423,1423,1423),(1424,1424,1424),(1425,1425,1425), -(1426,1426,1426),(1427,1427,1427),(1428,1428,1428),(1429,1429,1429),(1430,1430,1430), -(1431,1431,1431),(1432,1432,1432),(1433,1433,1433),(1434,1434,1434),(1435,1435,1435), -(1436,1436,1436),(1437,1437,1437),(1438,1438,1438),(1439,1439,1439),(1440,1440,1440), -(1441,1441,1441),(1442,1442,1442),(1443,1443,1443),(1444,1444,1444),(1445,1445,1445), -(1446,1446,1446),(1447,1447,1447),(1448,1448,1448),(1449,1449,1449),(1450,1450,1450), -(1451,1451,1451),(1452,1452,1452),(1453,1453,1453),(1454,1454,1454),(1455,1455,1455), -(1456,1456,1456),(1457,1457,1457),(1458,1458,1458),(1459,1459,1459),(1460,1460,1460), -(1461,1461,1461),(1462,1462,1462),(1463,1463,1463),(1464,1464,1464),(1465,1465,1465), -(1466,1466,1466),(1467,1467,1467),(1468,1468,1468),(1469,1469,1469),(1470,1470,1470), -(1471,1471,1471),(1472,1472,1472),(1473,1473,1473),(1474,1474,1474),(1475,1475,1475), -(1476,1476,1476),(1477,1477,1477),(1478,1478,1478),(1479,1479,1479),(1480,1480,1480), -(1481,1481,1481),(1482,1482,1482),(1483,1483,1483),(1484,1484,1484),(1485,1485,1485), -(1486,1486,1486),(1487,1487,1487),(1488,1488,1488),(1489,1489,1489),(1490,1490,1490), -(1491,1491,1491),(1492,1492,1492),(1493,1493,1493),(1494,1494,1494),(1495,1495,1495), -(1496,1496,1496),(1497,1497,1497),(1498,1498,1498),(1499,1499,1499),(1500,1500,1500), -(1501,1501,1501),(1502,1502,1502),(1503,1503,1503),(1504,1504,1504),(1505,1505,1505), -(1506,1506,1506),(1507,1507,1507),(1508,1508,1508),(1509,1509,1509),(1510,1510,1510), -(1511,1511,1511),(1512,1512,1512),(1513,1513,1513),(1514,1514,1514),(1515,1515,1515), -(1516,1516,1516),(1517,1517,1517),(1518,1518,1518),(1519,1519,1519),(1520,1520,1520), -(1521,1521,1521),(1522,1522,1522),(1523,1523,1523),(1524,1524,1524),(1525,1525,1525), -(1526,1526,1526),(1527,1527,1527),(1528,1528,1528),(1529,1529,1529),(1530,1530,1530), -(1531,1531,1531),(1532,1532,1532),(1533,1533,1533),(1534,1534,1534),(1535,1535,1535), -(1536,1536,1536),(1537,1537,1537),(1538,1538,1538),(1539,1539,1539),(1540,1540,1540), -(1541,1541,1541),(1542,1542,1542),(1543,1543,1543),(1544,1544,1544),(1545,1545,1545), -(1546,1546,1546),(1547,1547,1547),(1548,1548,1548),(1549,1549,1549),(1550,1550,1550), -(1551,1551,1551),(1552,1552,1552),(1553,1553,1553),(1554,1554,1554),(1555,1555,1555), -(1556,1556,1556),(1557,1557,1557),(1558,1558,1558),(1559,1559,1559),(1560,1560,1560), -(1561,1561,1561),(1562,1562,1562),(1563,1563,1563),(1564,1564,1564),(1565,1565,1565), -(1566,1566,1566),(1567,1567,1567),(1568,1568,1568),(1569,1569,1569),(1570,1570,1570), -(1571,1571,1571),(1572,1572,1572),(1573,1573,1573),(1574,1574,1574),(1575,1575,1575), -(1576,1576,1576),(1577,1577,1577),(1578,1578,1578),(1579,1579,1579),(1580,1580,1580), -(1581,1581,1581),(1582,1582,1582),(1583,1583,1583),(1584,1584,1584),(1585,1585,1585), -(1586,1586,1586),(1587,1587,1587),(1588,1588,1588),(1589,1589,1589),(1590,1590,1590), -(1591,1591,1591),(1592,1592,1592),(1593,1593,1593),(1594,1594,1594),(1595,1595,1595), -(1596,1596,1596),(1597,1597,1597),(1598,1598,1598),(1599,1599,1599),(1600,1600,1600), -(1601,1601,1601),(1602,1602,1602),(1603,1603,1603),(1604,1604,1604),(1605,1605,1605), -(1606,1606,1606),(1607,1607,1607),(1608,1608,1608),(1609,1609,1609),(1610,1610,1610), -(1611,1611,1611),(1612,1612,1612),(1613,1613,1613),(1614,1614,1614),(1615,1615,1615), -(1616,1616,1616),(1617,1617,1617),(1618,1618,1618),(1619,1619,1619),(1620,1620,1620), -(1621,1621,1621),(1622,1622,1622),(1623,1623,1623),(1624,1624,1624),(1625,1625,1625), -(1626,1626,1626),(1627,1627,1627),(1628,1628,1628),(1629,1629,1629),(1630,1630,1630), -(1631,1631,1631),(1632,1632,1632),(1633,1633,1633),(1634,1634,1634),(1635,1635,1635), -(1636,1636,1636),(1637,1637,1637),(1638,1638,1638),(1639,1639,1639),(1640,1640,1640), -(1641,1641,1641),(1642,1642,1642),(1643,1643,1643),(1644,1644,1644),(1645,1645,1645), -(1646,1646,1646),(1647,1647,1647),(1648,1648,1648),(1649,1649,1649),(1650,1650,1650), -(1651,1651,1651),(1652,1652,1652),(1653,1653,1653),(1654,1654,1654),(1655,1655,1655), -(1656,1656,1656),(1657,1657,1657),(1658,1658,1658),(1659,1659,1659),(1660,1660,1660), -(1661,1661,1661),(1662,1662,1662),(1663,1663,1663),(1664,1664,1664),(1665,1665,1665), -(1666,1666,1666),(1667,1667,1667),(1668,1668,1668),(1669,1669,1669),(1670,1670,1670), -(1671,1671,1671),(1672,1672,1672),(1673,1673,1673),(1674,1674,1674),(1675,1675,1675), -(1676,1676,1676),(1677,1677,1677),(1678,1678,1678),(1679,1679,1679),(1680,1680,1680), -(1681,1681,1681),(1682,1682,1682),(1683,1683,1683),(1684,1684,1684),(1685,1685,1685), -(1686,1686,1686),(1687,1687,1687),(1688,1688,1688),(1689,1689,1689),(1690,1690,1690), -(1691,1691,1691),(1692,1692,1692),(1693,1693,1693),(1694,1694,1694),(1695,1695,1695), -(1696,1696,1696),(1697,1697,1697),(1698,1698,1698),(1699,1699,1699),(1700,1700,1700), -(1701,1701,1701),(1702,1702,1702),(1703,1703,1703),(1704,1704,1704),(1705,1705,1705), -(1706,1706,1706),(1707,1707,1707),(1708,1708,1708),(1709,1709,1709),(1710,1710,1710), -(1711,1711,1711),(1712,1712,1712),(1713,1713,1713),(1714,1714,1714),(1715,1715,1715), -(1716,1716,1716),(1717,1717,1717),(1718,1718,1718),(1719,1719,1719),(1720,1720,1720), -(1721,1721,1721),(1722,1722,1722),(1723,1723,1723),(1724,1724,1724),(1725,1725,1725), -(1726,1726,1726),(1727,1727,1727),(1728,1728,1728),(1729,1729,1729),(1730,1730,1730), -(1731,1731,1731),(1732,1732,1732),(1733,1733,1733),(1734,1734,1734),(1735,1735,1735), -(1736,1736,1736),(1737,1737,1737),(1738,1738,1738),(1739,1739,1739),(1740,1740,1740), -(1741,1741,1741),(1742,1742,1742),(1743,1743,1743),(1744,1744,1744),(1745,1745,1745), -(1746,1746,1746),(1747,1747,1747),(1748,1748,1748),(1749,1749,1749),(1750,1750,1750), -(1751,1751,1751),(1752,1752,1752),(1753,1753,1753),(1754,1754,1754),(1755,1755,1755), -(1756,1756,1756),(1757,1757,1757),(1758,1758,1758),(1759,1759,1759),(1760,1760,1760), -(1761,1761,1761),(1762,1762,1762),(1763,1763,1763),(1764,1764,1764),(1765,1765,1765), -(1766,1766,1766),(1767,1767,1767),(1768,1768,1768),(1769,1769,1769),(1770,1770,1770), -(1771,1771,1771),(1772,1772,1772),(1773,1773,1773),(1774,1774,1774),(1775,1775,1775), -(1776,1776,1776),(1777,1777,1777),(1778,1778,1778),(1779,1779,1779),(1780,1780,1780), -(1781,1781,1781),(1782,1782,1782),(1783,1783,1783),(1784,1784,1784),(1785,1785,1785), -(1786,1786,1786),(1787,1787,1787),(1788,1788,1788),(1789,1789,1789),(1790,1790,1790), -(1791,1791,1791),(1792,1792,1792),(1793,1793,1793),(1794,1794,1794),(1795,1795,1795), -(1796,1796,1796),(1797,1797,1797),(1798,1798,1798),(1799,1799,1799),(1800,1800,1800), -(1801,1801,1801),(1802,1802,1802),(1803,1803,1803),(1804,1804,1804),(1805,1805,1805), -(1806,1806,1806),(1807,1807,1807),(1808,1808,1808),(1809,1809,1809),(1810,1810,1810), -(1811,1811,1811),(1812,1812,1812),(1813,1813,1813),(1814,1814,1814),(1815,1815,1815), -(1816,1816,1816),(1817,1817,1817),(1818,1818,1818),(1819,1819,1819),(1820,1820,1820), -(1821,1821,1821),(1822,1822,1822),(1823,1823,1823),(1824,1824,1824),(1825,1825,1825), -(1826,1826,1826),(1827,1827,1827),(1828,1828,1828),(1829,1829,1829),(1830,1830,1830), -(1831,1831,1831),(1832,1832,1832),(1833,1833,1833),(1834,1834,1834),(1835,1835,1835), -(1836,1836,1836),(1837,1837,1837),(1838,1838,1838),(1839,1839,1839),(1840,1840,1840), -(1841,1841,1841),(1842,1842,1842),(1843,1843,1843),(1844,1844,1844),(1845,1845,1845), -(1846,1846,1846),(1847,1847,1847),(1848,1848,1848),(1849,1849,1849),(1850,1850,1850), -(1851,1851,1851),(1852,1852,1852),(1853,1853,1853),(1854,1854,1854),(1855,1855,1855), -(1856,1856,1856),(1857,1857,1857),(1858,1858,1858),(1859,1859,1859),(1860,1860,1860), -(1861,1861,1861),(1862,1862,1862),(1863,1863,1863),(1864,1864,1864),(1865,1865,1865), -(1866,1866,1866),(1867,1867,1867),(1868,1868,1868),(1869,1869,1869),(1870,1870,1870), -(1871,1871,1871),(1872,1872,1872),(1873,1873,1873),(1874,1874,1874),(1875,1875,1875), -(1876,1876,1876),(1877,1877,1877),(1878,1878,1878),(1879,1879,1879),(1880,1880,1880), -(1881,1881,1881),(1882,1882,1882),(1883,1883,1883),(1884,1884,1884),(1885,1885,1885), -(1886,1886,1886),(1887,1887,1887),(1888,1888,1888),(1889,1889,1889),(1890,1890,1890), -(1891,1891,1891),(1892,1892,1892),(1893,1893,1893),(1894,1894,1894),(1895,1895,1895), -(1896,1896,1896),(1897,1897,1897),(1898,1898,1898),(1899,1899,1899),(1900,1900,1900), -(1901,1901,1901),(1902,1902,1902),(1903,1903,1903),(1904,1904,1904),(1905,1905,1905), -(1906,1906,1906),(1907,1907,1907),(1908,1908,1908),(1909,1909,1909),(1910,1910,1910), -(1911,1911,1911),(1912,1912,1912),(1913,1913,1913),(1914,1914,1914),(1915,1915,1915), -(1916,1916,1916),(1917,1917,1917),(1918,1918,1918),(1919,1919,1919),(1920,1920,1920), -(1921,1921,1921),(1922,1922,1922),(1923,1923,1923),(1924,1924,1924),(1925,1925,1925), -(1926,1926,1926),(1927,1927,1927),(1928,1928,1928),(1929,1929,1929),(1930,1930,1930), -(1931,1931,1931),(1932,1932,1932),(1933,1933,1933),(1934,1934,1934),(1935,1935,1935), -(1936,1936,1936),(1937,1937,1937),(1938,1938,1938),(1939,1939,1939),(1940,1940,1940), -(1941,1941,1941),(1942,1942,1942),(1943,1943,1943),(1944,1944,1944),(1945,1945,1945), -(1946,1946,1946),(1947,1947,1947),(1948,1948,1948),(1949,1949,1949),(1950,1950,1950), -(1951,1951,1951),(1952,1952,1952),(1953,1953,1953),(1954,1954,1954),(1955,1955,1955), -(1956,1956,1956),(1957,1957,1957),(1958,1958,1958),(1959,1959,1959),(1960,1960,1960), -(1961,1961,1961),(1962,1962,1962),(1963,1963,1963),(1964,1964,1964),(1965,1965,1965), -(1966,1966,1966),(1967,1967,1967),(1968,1968,1968),(1969,1969,1969),(1970,1970,1970), -(1971,1971,1971),(1972,1972,1972),(1973,1973,1973),(1974,1974,1974),(1975,1975,1975), -(1976,1976,1976),(1977,1977,1977),(1978,1978,1978),(1979,1979,1979),(1980,1980,1980), -(1981,1981,1981),(1982,1982,1982),(1983,1983,1983),(1984,1984,1984),(1985,1985,1985), -(1986,1986,1986),(1987,1987,1987),(1988,1988,1988),(1989,1989,1989),(1990,1990,1990), -(1991,1991,1991),(1992,1992,1992),(1993,1993,1993),(1994,1994,1994),(1995,1995,1995), -(1996,1996,1996),(1997,1997,1997),(1998,1998,1998),(1999,1999,1999); - -SELECT COUNT(*) FROM t1; - - -# -# Insert duplicate rows -# ---error 1062 -INSERT INTO t1 VALUES (1,1,1); - ---error 1022 -INSERT INTO t1 VALUES -(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), -(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); - -select count(*) from t1; - - -# -# Test that select count(*) can see inserts made in the same transaction -# -begin; -SELECT COUNT(*) FROM t1; -INSERT INTO t1 VALUES -(2001,2001,2001),(2002,2002,2002),(2003,2003,2003),(2004,2004,2004),(2005,2005,2005); -SELECT COUNT(*) FROM t1; -rollback; - -# -# Insert duplicate rows, inside transaction -# try to commit -# -begin; - ---error 1022 -INSERT INTO t1 VALUES -(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), -(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); - ---error 1296 -commit; - -select * from t1 where pk1=1; -select * from t1 where pk1=10; -select count(*) from t1 where pk1 <= 10 order by pk1; -select count(*) from t1; - - -# -# Insert duplicate rows, inside transaction -# rollback -# -begin; - ---error 1022 -INSERT INTO t1 VALUES -(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), -(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); - -rollback; - -select * from t1 where pk1=1; -select * from t1 where pk1=10; -select count(*) from t1 where pk1 <= 10 order by pk1; -select count(*) from t1; - - -# -# Insert duplicate rows, inside transaction -# then try to select, finally rollback -# -begin; - ---error 1022 -INSERT INTO t1 VALUES -(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), -(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); ---error 1296 -SELECT * FROM t1 WHERE pk1=10; - -rollback; - -select * from t1 where pk1=1; -select * from t1 where pk1=10; -select count(*) from t1 where pk1 <= 10 order by pk1; -select count(*) from t1; - - -# -# Insert duplicate rows, inside transaction -# then try to select, finally commit -# -begin; - ---error 1022 -INSERT INTO t1 VALUES -(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), -(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); - ---error 1296 -SELECT * FROM t1 WHERE pk1=10; - ---error 1296 -SELECT * FROM t1 WHERE pk1=10; - ---error 1296 -commit; - -select * from t1 where pk1=1; -select * from t1 where pk1=10; -select count(*) from t1 where pk1 <= 10 order by pk1; -select count(*) from t1; - - -# -# Insert duplicate rows, inside transaction -# then try to do another insert -# -begin; - ---error 1022 -INSERT INTO t1 VALUES -(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), -(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); - ---error 1296 -INSERT INTO t1 values (4000, 40, 44); - -rollback; - -select * from t1 where pk1=1; -select * from t1 where pk1=10; -select count(*) from t1 where pk1 <= 10 order by pk1; -select count(*) from t1; - -# -# Insert duplicate rows using "insert .. select" - -# ---error 1022 -insert into t1 select * from t1 where b < 10 order by pk1; - -DELETE FROM t1 WHERE pk1=2; - -begin; -INSERT IGNORE INTO t1 VALUES(1,2,3),(2,3,4); -select * from t1 where pk1 < 3 order by pk1; -rollback; - -INSERT IGNORE INTO t1 VALUES(1,2,3),(2,3,4); -select * from t1 where pk1 < 3 order by pk1; - -REPLACE INTO t1 values(1, 78, 3); -select * from t1 where pk1=1; - -INSERT INTO t1 VALUES(1,1,1),(3,4,5) ON DUPLICATE KEY UPDATE b=79; -select * from t1 where pk1 < 4 order by pk1; - -INSERT INTO t1 VALUES(1,1,1),(3,4,5) ON DUPLICATE KEY UPDATE b=pk1+c; -select * from t1 where pk1 < 4 order by pk1; - -DELETE FROM t1 WHERE pk1 = 2 OR pk1 = 4 OR pk1 = 6; -INSERT INTO t1 VALUES(1,1,1),(2,2,17),(3,4,5) ON DUPLICATE KEY UPDATE pk1=b; -select * from t1 where pk1 = b and b != c order by pk1; - -# Test handling of duplicate unique -DELETE FROM t1; -CREATE UNIQUE INDEX bi ON t1(b); -INSERT INTO t1 VALUES -(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), -(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); -INSERT INTO t1 VALUES(0,1,0),(21,21,21) ON DUPLICATE KEY UPDATE pk1=b+10,b=b+10; -select * from t1 order by pk1; - -DROP TABLE t1; - -# -# Bug #6331: problem with 'insert ignore' -# - -CREATE TABLE t1(a INT) ENGINE=ndb; -INSERT IGNORE INTO t1 VALUES (1); -INSERT IGNORE INTO t1 VALUES (1); -INSERT IGNORE INTO t1 SELECT a FROM t1; -INSERT IGNORE INTO t1 SELECT a FROM t1; -INSERT IGNORE INTO t1 SELECT a FROM t1; -INSERT IGNORE INTO t1 VALUES (1); -INSERT IGNORE INTO t1 VALUES (1); -SELECT * FROM t1 ORDER BY a; -DELETE FROM t1; -CREATE UNIQUE INDEX ai ON t1(a); -INSERT IGNORE INTO t1 VALUES (1); -INSERT IGNORE INTO t1 VALUES (1); -INSERT IGNORE INTO t1 VALUES (NULL),(2); -SELECT * FROM t1 ORDER BY a; -DROP TABLE t1; - -# Ignore and NULL values -CREATE TABLE t1(pk INT NOT NULL PRIMARY KEY, a INT, UNIQUE (a)) ENGINE=ndb; -INSERT IGNORE INTO t1 VALUES (1,1),(2,2),(3,3); -INSERT IGNORE INTO t1 VALUES (4,NULL),(5,NULL),(6,NULL),(7,4); -SELECT * FROM t1 ORDER BY pk; -DROP TABLE t1; - -# -# Bug #27980 INSERT IGNORE wrongly ignores NULLs in unique index -# - -create table t1(a int primary key, b int, unique key(b)) engine=ndb; -insert ignore into t1 values (1,0), (2,0), (2,null), (3,null); -select * from t1 order by a; -drop table t1; -# End of 4.1 tests diff --git a/mysql-test/t/ndb_limit.test b/mysql-test/t/ndb_limit.test deleted file mode 100644 index 01613606d66..00000000000 --- a/mysql-test/t/ndb_limit.test +++ /dev/null @@ -1,85 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t2; ---enable_warnings - - -CREATE TABLE t2 ( - a bigint unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned -) engine=ndbcluster; - - -# -# insert records into table -# -let $1=1000; -disable_query_log; -while ($1) -{ - eval insert into t2 values($1*10, $1+9, 5*$1), ($1*10+1, $1+10, 7),($1*10+2, $1+10, 7*$1), ($1*10+3, $1+10, 10+$1), ($1*10+4, $1+10, 70*$1), ($1*10+5, $1+10, 7), ($1*10+6, $1+10, 9), ($1*10+7, $1+299, 899), ($1*10+8, $1+10, 12), ($1*10+9, $1+10, 14*$1); - dec $1; -} -enable_query_log; - -select count(*) from t2; - -delete from t2 limit 1; -select count(*) from t2; - -delete from t2 limit 100; -select count(*) from t2; - -delete from t2 limit 1000; -select count(*) from t2; - -update t2 set c=12345678 limit 100; -select count(*) from t2 where c=12345678; -select count(*) from t2 where c=12345678 limit 1000; - -select * from t2 limit 0; - -drop table t2; - -CREATE TABLE `t2` ( - `views` int(11) NOT NULL default '0', - `clicks` int(11) NOT NULL default '0', - `day` date NOT NULL default '0000-00-00', - `hour` tinyint(4) NOT NULL default '0', - `bannerid` smallint(6) NOT NULL default '0', - `zoneid` smallint(6) NOT NULL default '0', - `source` varchar(50) NOT NULL default '', - PRIMARY KEY (`day`,`hour`,`bannerid`,`zoneid`,`source`), - KEY `bannerid_day` (`bannerid`,`day`), - KEY `zoneid` (`zoneid`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; - -INSERT INTO `t2` VALUES -( 1,0,'2004-09-17', 5,100,100,''), -( 1,0,'2004-09-18', 7,100,100,''), -( 17,0,'2004-09-27',20,132,100,''), -( 4,0,'2004-09-16',23,132,100,''), -( 86,0,'2004-09-18', 7,196,196,''), -( 11,0,'2004-09-16',16,132,100,''), -(140,0,'2004-09-18', 0,100,164,''), -( 2,0,'2004-09-17', 7,132,100,''), -(846,0,'2004-09-27',11,132,164,''), -( 1,0,'2004-09-18', 8,132,100,''), -( 22,0,'2004-09-27', 9,164,132,''), -(711,0,'2004-09-27', 9,100,164,''), -( 11,0,'2004-09-18', 0,196,132,''), -( 41,0,'2004-09-27',15,196,132,''), -( 57,0,'2004-09-18', 2,164,196,''); - -SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y') -as date_formatted FROM t2 GROUP BY day ORDER BY day DESC; - -SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y') -as date_formatted FROM t2 GROUP BY day ORDER BY day DESC LIMIT 2; - -drop table t2; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_load.test b/mysql-test/t/ndb_load.test deleted file mode 100644 index af2df70b74e..00000000000 --- a/mysql-test/t/ndb_load.test +++ /dev/null @@ -1,24 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - -# -# Basic test for different types of loading data -# - -# should give duplicate key -CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=NDB; ---error 1022 -LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1 ; -DROP TABLE t1; - -# now without a primary key we should be ok -CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=NDB; -LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1 ; -SELECT * FROM t1 ORDER BY word; -DROP TABLE t1; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_loaddatalocal.test b/mysql-test/t/ndb_loaddatalocal.test deleted file mode 100644 index f8930255a2a..00000000000 --- a/mysql-test/t/ndb_loaddatalocal.test +++ /dev/null @@ -1,70 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - -create table t1(a int) engine=myisam; -let $1=10000; -disable_query_log; -set SQL_LOG_BIN=0; -while ($1) -{ - insert into t1 values(1); - dec $1; -} -set SQL_LOG_BIN=1; -enable_query_log; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; -#This will generate a 20KB file, now test LOAD DATA LOCAL -drop table t1; - -create table t1(a int) engine=ndb; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; -select count(*) from t1; -remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile ; -drop table t1; - -create table t1(a int) engine=myisam; -insert into t1 values (1), (2), (2), (3); ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; -drop table t1; - -create table t1(a int primary key) engine=ndb; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; -remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile; -select * from t1 order by a; -drop table t1; - -create table t1(a int) engine=myisam; -insert into t1 values (1), (1), (2), (3); ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; -drop table t1; - -create table t1(a int primary key) engine=ndb; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; -remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile; -select * from t1 order by a; -drop table t1; - -create table t1(a int) engine=myisam; -insert into t1 values (1), (2), (3), (3); ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; -drop table t1; - -create table t1(a int primary key) engine=ndb; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; -remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile; -select * from t1 order by a; -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_lock.test b/mysql-test/t/ndb_lock.test deleted file mode 100644 index bd35a7d28c3..00000000000 --- a/mysql-test/t/ndb_lock.test +++ /dev/null @@ -1,233 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - -connect (con1,localhost,root,,); -connect (con2,localhost,root,,); - ---disable_warnings -DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; ---enable_warnings - -# -# Transaction lock test to show that the NDB -# table handler is working properly with -# transaction locks -# - -# -# Testing of scan isolation -# -connection con1; -create table t1 (x integer not null primary key, y varchar(32)) engine = ndb; -insert into t1 values (1,'one'), (2,'two'); -select * from t1 order by x; - -connection con2; -select * from t1 order by x; - -connection con1; -start transaction; -insert into t1 values (3,'three'); -select * from t1 order by x; - -connection con2; -start transaction; -select * from t1 order by x; - -connection con1; -commit; - -connection con2; -select * from t1 order by x; -commit; - -drop table t1; - -### -# Bug#6020 -create table t1 (pk integer not null primary key, u int not null, o int not null, - unique(u), key(o)) engine = ndb; -insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5); - -lock tables t1 write; -delete from t1 where pk = 1; -unlock tables; -select * from t1 order by pk; -insert into t1 values (1,1,1); - -lock tables t1 write; -delete from t1 where u = 1; -unlock tables; -select * from t1 order by pk; -insert into t1 values (1,1,1); - -lock tables t1 write; -delete from t1 where o = 1; -unlock tables; -select * from t1 order by pk; -insert into t1 values (1,1,1); - -drop table t1; - -# Lock for update - -create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb; - -insert into t1 values (1,'one',1); - -# PK access -connection con1; -begin; -select * from t1 where x = 1 for update; - -connection con2; -begin; ---error 1205 -select * from t1 where x = 1 for update; -rollback; - -connection con1; -rollback; -insert into t1 values (2,'two',2),(3,"three",3); -begin; -select * from t1 where x = 1 for update; - -connection con2; ---error 1205 -select * from t1 where x = 1 for update; -select * from t1 where x = 2 for update; -rollback; - -connection con1; -commit; - -# table scan -# -# Note that there are two distinct execution paths in which we unlock -# non-matching rows inspected during table scan - one that is used in -# case of filesort and one that used in rest of cases. Below we cover -# the latter (Bug #20390 "SELECT FOR UPDATE does not release locks of -# untouched rows in full table scans"). -connection con1; -begin; -# We can't use "order by x" here as it will cause filesort ---replace_column 1 # 2 # 3 # -select * from t1 where y = 'one' or y = 'three' for update; - -connection con2; -begin; -# Have to check with pk access here since scans take locks on -# all rows and then release them in chunks -select * from t1 where x = 2 for update; ---error 1205 -select * from t1 where x = 1 for update; -rollback; - -connection con1; -commit; - -# And now the test for case with filesort -begin; -select * from t1 where y = 'one' or y = 'three' order by x for update; -connection con2; -begin; -select * from t1 where x = 2 for update; ---error 1205 -select * from t1 where x = 1 for update; -rollback; - -connection con1; -commit; - -# index scan -connection con1; -begin; -select * from t1 where z > 1 and z < 3 for update; - -connection con2; -begin; -# Have to check with pk access here since scans take locks on -# all rows and then release them in chunks -select * from t1 where x = 1 for update; ---error 1105,1205 -select * from t1 where x = 2 for update; -rollback; - -connection con1; -commit; - -# share locking - -# PK access -connection con1; -begin; -select * from t1 where x = 1 lock in share mode; - -connection con2; -begin; -select * from t1 where x = 1 lock in share mode; -select * from t1 where x = 2 for update; ---error 1205 -select * from t1 where x = 1 for update; -rollback; - -connection con1; -commit; - -# table scan -connection con1; -begin; -# We can't use "order by x" here as it will cause filesort ---replace_column 1 # 2 # 3 # -select * from t1 where y = 'one' or y = 'three' lock in share mode; - -connection con2; -begin; -select * from t1 where y = 'one' lock in share mode; -# Have to check with pk access here since scans take locks on -# all rows and then release them in chunks -select * from t1 where x = 2 for update; ---error 1205 -select * from t1 where x = 1 for update; -rollback; - -connection con1; -commit; - -# And the same test for case with filesort -connection con1; -begin; -select * from t1 where y = 'one' or y = 'three' order by x lock in share mode; - -connection con2; -begin; -select * from t1 where y = 'one' lock in share mode; -select * from t1 where x = 2 for update; ---error 1205 -select * from t1 where x = 1 for update; -rollback; - -connection con1; -commit; - -# index scan -connection con1; -begin; -select * from t1 where z > 1 and z < 3 lock in share mode; - -connection con2; -begin; -select * from t1 where z = 1 lock in share mode; -# Have to check with pk access here since scans take locks on -# all rows and then release them in chunks -select * from t1 where x = 1 for update; ---error 1205 -select * from t1 where x = 2 for update; -rollback; - -connection con1; -commit; - -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_minmax.test b/mysql-test/t/ndb_minmax.test deleted file mode 100644 index a3ac677cd2a..00000000000 --- a/mysql-test/t/ndb_minmax.test +++ /dev/null @@ -1,65 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1, t2; ---enable_warnings - -CREATE TABLE t1 ( - a int PRIMARY KEY -) engine = ndb; - -INSERT INTO t1 VALUES (1); -INSERT INTO t1 VALUES (2); -INSERT INTO t1 VALUES (3); -INSERT INTO t1 VALUES (4); -INSERT INTO t1 VALUES (5); -INSERT INTO t1 VALUES (6); - -select MAX(a) from t1; -select MAX(a) from t1; -select MAX(a) from t1; -select MAX(a) from t1; -select MIN(a) from t1; -select MIN(a) from t1; -select MIN(a) from t1; -select * from t1 order by a; -select MIN(a) from t1; -select MAX(a) from t1; -select MAX(a) from t1; -select * from t1 order by a; -drop table t1; - - -CREATE TABLE t2 ( - a int PRIMARY KEY, - b int not null, - c int not null, - KEY(b), - UNIQUE(c) -) engine = ndb; - -INSERT INTO t2 VALUES (1, 5, 1); -INSERT INTO t2 VALUES (2, 2, 7); -INSERT INTO t2 VALUES (3, 3, 3); -INSERT INTO t2 VALUES (4, 4, 4); -INSERT INTO t2 VALUES (5, 5, 5); -INSERT INTO t2 VALUES (6, 6, 6); -INSERT INTO t2 VALUES (7, 2, 10); -INSERT INTO t2 VALUES (8, 10, 2); - - -select MAX(a) from t2; -select MAX(b) from t2; -select MAX(c) from t2; -select MIN(a) from t2; -select MIN(b) from t2; -select MIN(c) from t2; -select * from t2 order by a; -select MIN(b) from t2; -select MAX(a) from t2; -select MAX(c) from t2; -select * from t2 order by a; -drop table t2; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_multi.test b/mysql-test/t/ndb_multi.test deleted file mode 100644 index 97cce08fce0..00000000000 --- a/mysql-test/t/ndb_multi.test +++ /dev/null @@ -1,91 +0,0 @@ --- source include/have_ndb.inc --- source include/have_multi_ndb.inc --- source include/not_embedded.inc - - ---disable_warnings -drop table if exists t1, t2, t3, t4; ---enable_warnings - -flush status; - -# Create test tables on server1 -create table t1 (a int) engine=ndbcluster; -create table t2 (a int) engine=ndbcluster; -insert into t1 value (2); -insert into t2 value (3); -select * from t1; -select * from t2; -show status like 'handler_discover%'; - -# Check dropping and recreating table on same server -connect (con1,localhost,root,,test); -connect (con2,localhost,root,,test); -connection con1; -select * from t1; -connection con2; -drop table t1; -create table t1 (a int) engine=ndbcluster; -insert into t1 value (2); -connection con1; -select * from t1; - -# Check dropping and recreating table on different server -connection server2; -show status like 'handler_discover%'; -drop table t1; -create table t1 (a int) engine=ndbcluster; -insert into t1 value (2); -connection server1; -flush table t1; -select * from t1; - -# Connect to server2 and use the tables from there -connection server2; -flush status; -select * from t1; -update t1 set a=3 where a=2; -show status like 'handler_discover%'; - -# Create a new table on server2 -create table t3 (a int not null primary key, b varchar(22), -c int, last_col text) engine=ndb; -insert into t3 values(1, 'Hi!', 89, 'Longtext column'); -create table t4 (pk int primary key, b int) engine=ndb; - -# Check that the tables are accessible from server1 -connection server1; -select * from t1; -select * from t3; -show status like 'handler_discover%'; -show tables like 't4'; -show status like 'handler_discover%'; -show tables; - -drop table t1, t2, t3, t4; -connection server2; -drop table t1, t3, t4; - -# bug#21378 -connection server1; -create table t1(c1 int key)ENGINE=MyISAM; -insert into t1 values(1),(3),(5); -select * from t1 order by c1; - -connection server2; -create table t1(c1 int key)ENGINE=MyISAM; -insert into t1 values(100),(344),(533); -select * from t1 order by c1; - -connection server1; -alter table t1 engine=ndb; - -connection server2; -show tables; -select * from t1 order by c1; -drop table t1; - -connection server1; -select * from t1 order by c1; -drop table t1; -# End of 4.1 tests diff --git a/mysql-test/t/ndb_read_multi_range.test b/mysql-test/t/ndb_read_multi_range.test deleted file mode 100644 index 1d1d5f26552..00000000000 --- a/mysql-test/t/ndb_read_multi_range.test +++ /dev/null @@ -1,315 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1, t2, r1; ---enable_warnings - -# -# Basic test to see that batching is working -# - -create table t1 ( - a int primary key, - b int not null, - c int not null, - index(b), unique index using hash(c) -) engine = ndb; -insert into t1 values - (1,2,1),(2,3,2),(3,4,3),(4,5,4), - (5,2,12),(6,3,11),(7,4,10),(8,5,9), - (9,2,8),(10,3,7),(11,4,6),(12,5,5); - -# batch on primary key -create table r1 as select * from t1 where a in (2,8,12); -select * from r1 order by a; -drop table r1; - -# batch on ordered index -create table r1 as select * from t1 where b in (1,2,5); -select * from r1 order by a; -drop table r1; - -# batch on unique hash index -create table r1 as select * from t1 where c in (2,8,12); -select * from r1 order by a; -drop table r1; - -# batch mixed -create table r1 as select * from t1 where a in (2,8) or (a > 11) or (a <= 1); -select * from r1 order by a; -drop table r1; - -# batch on primary key, missing values -create table r1 as select * from t1 where a in (33,8,12); -select * from r1 order by a; -drop table r1; -create table r1 as select * from t1 where a in (2,33,8,12,34); -select * from r1 order by a; -drop table r1; - -# batch on ordered index, missing values -create table r1 as select * from t1 where b in (1,33,5); -select * from r1 order by a; -drop table r1; -select * from t1 where b in (1,33,5) order by a; -create table r1 as select * from t1 where b in (45,1,33,5,44); -select * from r1 order by a; -drop table r1; -select * from t1 where b in (45,22) order by a; - -# batch on unique hash index, missing values -create table r1 as select * from t1 where c in (2,8,33); -select * from r1 order by a; -drop table r1; -create table r1 as select * from t1 where c in (13,2,8,33,12); -select * from r1 order by a; -drop table r1; - -select * from t1 where a in (33,8,12) order by a; -select * from t1 where a in (33,34,35) order by a; -select * from t1 where a in (2,8) or (a > 11) or (a <= 1) order by a; -select * from t1 where b in (6,7) or (b <= 5) or (b >= 10) order by b,a; -select * from t1 where c in (13,2,8,33,12) order by c,a; -drop table t1; - -# -# Somewhat more complicated -# - -create table t1 ( - a int not null, - b int not null, - c int not null, - d int not null, - e int not null, - primary key (a,b,c,d), index (d) -) engine = ndb; - -insert into t1 values - (1,2,1,1,1),(2,3,2,3,1),(3,4,3,1,1),(4,5,4,7,1), - (5,2,12,12,1),(6,3,11,1,1),(7,4,10,3,1),(8,5,9,5,1), - (9,2,8,6,1),(10,3,7,5,1),(11,4,6,3,1),(12,5,5,2,1), - (1,2,1,2,1), - (1,2,1,3,1), - (1,2,1,4,1), - (1,2,1,5,1); - -# batch on primary key -create table r1 as select * from t1 - where a=1 and b=2 and c=1 and d in (1,4,3,2); -select * from r1 order by a,b,c,d; -drop table r1; - -# batched update ordered index, one value for all -update t1 set e = 100 - where d in (12,6,7); -select * from t1 where d in (12,6,7) order by a,b,c,d; -select * from t1 where d not in (12,6,7) and e = 100; - -# batched update primary key, one value for all -update t1 - set e = 101 - where a=1 and - b=2 and - c=1 and - d in (1,4,3,2); -select * - from t1 - where a=1 and b=2 and c=1 and d in (1,4,3,2) - order by a,b,c,d; -select * - from t1 - where not (a=1 and b=2 and c=1 and d in (1,4,3,2)) - and e=101; - - -# batched update ordered index, different values -update t1 - set e = - (case d - when 12 then 112 - when 6 then 106 - when 7 then 107 - end) - where d in (12,6,7); -select * from t1 where d in (12,6,7) order by a,b,c,d; - -# batched update primary key, different values -update t1 - set e = - (case d - when 1 then 111 - when 4 then 444 - when 3 then 333 - when 2 then 222 - end) - where a=1 and - b=2 and - c=1 and - d in (1,4,3,2); -select * - from t1 - where a=1 and b=2 and c=1 and d in (1,4,3,2) - order by a,b,c,d; - -# batched delete -delete from t1 where d in (12,6,7); -select * from t1 where d in (12,6,7); - -drop table t1; - -# null handling -create table t1 ( - a int not null primary key, - b int, - c int, - d int, - unique index (b), - index(c) -) engine = ndb; - -insert into t1 values - (1,null,1,1), - (2,2,2,2), - (3,null,null,3), - (4,4,null,4), - (5,null,5,null), - (6,6,6,null), - (7,null,null,null), - (8,8,null,null), - (9,null,9,9), - (10,10,10,10), - (11,null,null,11), - (12,12,null,12), - (13,null,13,null), - (14,14,14,null), - (15,null,null,null), - (16,16,null,null); - -create table t2 as select * from t1 where a in (5,6,7,8,9,10); -select * from t2 order by a; -drop table t2; - -create table t2 as select * from t1 where b in (5,6,7,8,9,10); -select * from t2 order by a; -drop table t2; - -create table t2 as select * from t1 where c in (5,6,7,8,9,10); -select * from t2 order by a; -drop table t2; - -drop table t1; - -# bug17729 - -CREATE TABLE t1 ( - a int(11) NOT NULL, - b int(11) NOT NULL, - c datetime default NULL, - PRIMARY KEY (a), - KEY idx_bc (b,c) -) ENGINE=ndbcluster; - -INSERT INTO t1 VALUES -(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), -(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), -(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), -(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), -(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), -(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), -(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), -(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), -(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), -(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), -(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), -(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), -(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), -(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), -(154503,67,'2005-10-28 11:52:38'); - -create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; -create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; -create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; -create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; - -select * from t11 order by 1,2,3; -select * from t12 order by 1,2,3; -select * from t21 order by 1,2,3; -select * from t22 order by 1,2,3; -DROP TABLE t1, t11, t12, t21, t22; - -# bug#19956 -CREATE TABLE t1 (id varchar(255) NOT NULL, - tag int(11) NOT NULL, - doc text NOT NULL, - type varchar(150) NOT NULL, - modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (id) - ) ENGINE=ndbcluster; - -INSERT INTO t1 VALUES ('sakila',1,'Some text goes here','text',CURRENT_TIMESTAMP); -SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','orka'); -SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','sakila'); - -DROP TABLE t1; - -#bug#25522 -CREATE TABLE t1 ( - var1 int(2) NOT NULL, - var2 int(2) NOT NULL, - PRIMARY KEY (var1) - ) ENGINE=ndbcluster DEFAULT CHARSET=ascii CHECKSUM=1; - - -CREATE TABLE t2 ( - var1 int(2) NOT NULL, - var2 int(2) NOT NULL, - PRIMARY KEY (var1) - ) ENGINE=MyISAM DEFAULT CHARSET=ascii CHECKSUM=1; - - -DELIMITER |; -CREATE TRIGGER testtrigger - AFTER UPDATE ON t1 FOR EACH ROW BEGIN - REPLACE INTO t2 SELECT * FROM t1 WHERE t1.var1 = NEW.var1;END| -DELIMITER ;| - -INSERT INTO t1 VALUES (1,1),(2,2),(3,3); - -UPDATE t1 SET var2 = 9 WHERE var1 IN(1,2,3); - -DROP TRIGGER testtrigger; - -DROP TABLE t1, t2; - -#bug#25821 -create table t2 (a int, b int, primary key (a), key ab (a,b)) engine=ndbcluster; - -insert into t2 values (1,1), (10,10); - -select * from t2 use index (ab) where a in(1,10) order by a; - -drop table t2; - -#bug#30337 - -create table t1 (id int primary key) engine ndb; -insert into t1 values (1), (2), (3); - -create table t2 (id int primary key) engine ndb; -insert into t2 select id from t1; - -delimiter |; -create trigger kaboom after delete on t1 -for each row begin - delete from t2 where id=old.id; -end| -delimiter ;| - -select * from t1 order by id; -delete from t1 where id in (1,2); -select * from t2 order by id; - -drop trigger kaboom; -drop table t1; diff --git a/mysql-test/t/ndb_rename.test b/mysql-test/t/ndb_rename.test deleted file mode 100644 index 99c344bc29e..00000000000 --- a/mysql-test/t/ndb_rename.test +++ /dev/null @@ -1,32 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1,t2; -drop database if exists mysqltest; ---enable_warnings - -# -# Table rename tests -# - -# -# Create a normal table with primary key -# -CREATE TABLE t1 ( - pk1 INT NOT NULL PRIMARY KEY, - attr1 INT NOT NULL, - attr2 INT, - attr3 VARCHAR(10), - INDEX i1(attr1) -) ENGINE=ndbcluster; - -alter table t1 rename t2; - -create database ndbtest; -alter table t2 rename ndbtest.t2; - -drop table ndbtest.t2; -drop database ndbtest; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_replace.test b/mysql-test/t/ndb_replace.test deleted file mode 100644 index 476a607ed44..00000000000 --- a/mysql-test/t/ndb_replace.test +++ /dev/null @@ -1,104 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - -# -# Test of REPLACE with NDB -# - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - -CREATE TABLE t1 ( - gesuchnr int(11) DEFAULT '0' NOT NULL, - benutzer_id int(11) DEFAULT '0' NOT NULL, - PRIMARY KEY (gesuchnr,benutzer_id) -) engine=ndbcluster; - -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); -insert into t1 (gesuchnr, benutzer_id) value (3,2); -replace into t1 (gesuchnr,benutzer_id) values (1,1); -replace into t1 (gesuchnr,benutzer_id) values (1,1); ---error 1062 -insert into t1 (gesuchnr,benutzer_id) values (1,1); -replace into t1 (gesuchnr,benutzer_id) values (1,1); -select * from t1 order by gesuchnr; -drop table t1; - -# End of 4.1 tests - -# bug#17431 -CREATE TABLE t1(i INT PRIMARY KEY AUTO_INCREMENT, - j INT, - k INT, - UNIQUE INDEX(j) - ) ENGINE = ndb; -INSERT INTO t1 VALUES (1,1,23),(2,2,24); -REPLACE INTO t1 (j,k) VALUES (1,42); -REPLACE INTO t1 (i,j) VALUES (17,2); -SELECT * from t1 ORDER BY i; -DROP TABLE t1; - -# bug#19906 -CREATE TABLE t2 (a INT(11) NOT NULL, - b INT(11) NOT NULL, - c INT(11) NOT NULL, - x TEXT, - y TEXT, - z TEXT, - id INT(10) unsigned NOT NULL AUTO_INCREMENT, - i INT(11) DEFAULT NULL, - PRIMARY KEY (id), - UNIQUE KEY a (a,b,c) -) ENGINE=ndbcluster; - -REPLACE INTO t2 (a,b,c,x,y,z,i) VALUES (1,1,1,'a','a','a',1),(1,1,1,'b','b','b',2), (1,1,1,'c','c','c',3); - -SELECT * FROM t2 ORDER BY id; - -REPLACE INTO t2(a,b,c,x,y,z,i) values (1,1,1,'a','a','a',1); -REPLACE INTO t2(a,b,c,x,y,z,i) values (1,1,1,'b','b','b',2); - -SELECT * FROM t2 ORDER BY id; - -DROP TABLE t2; - -# -# Bug #20728 "REPLACE does not work correctly for NDB table with PK and -# unique index" -# ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1 (pk int primary key, apk int unique, data int) engine=ndbcluster; -# Test for plain replace which updates pk -insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); -replace into t1 (pk, apk) values (4, 1), (5, 2); -select * from t1 order by pk; -delete from t1; -# Another test for plain replace which doesn't touch pk -insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); -replace into t1 (pk, apk) values (1, 4), (2, 5); -select * from t1 order by pk; -delete from t1; -# Test for load data replace which updates pk -insert into t1 values (1, 1, 1), (4, 4, 4), (6, 6, 6); -load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk); -select * from t1 order by pk; -delete from t1; -# Now test for load data replace which doesn't touch pk -insert into t1 values (1, 1, 1), (3, 3, 3), (5, 5, 5); -load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk); -select * from t1 order by pk; -delete from t1; -# Finally test for both types of replace ... select -insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); -replace into t1 (pk, apk) select 4, 1; -replace into t1 (pk, apk) select 2, 4; -select * from t1 order by pk; -# Clean-up -drop table t1; - ---echo End of 5.0 tests. diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test deleted file mode 100644 index 940b53adbe1..00000000000 --- a/mysql-test/t/ndb_restore.test +++ /dev/null @@ -1,261 +0,0 @@ --- source include/have_ndb.inc --- source include/ndb_default_cluster.inc --- source include/not_embedded.inc - ---disable_warnings -use test; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; -drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; ---enable_warnings - -# Bug #27775 - mediumint auto inc not restored correctly -# - check mediumint -CREATE TABLE `t1_c` ( - `capgoaledatta` mediumint(5) unsigned NOT NULL auto_increment, - `goaledatta` char(2) NOT NULL default '', - `maturegarbagefa` varchar(32) NOT NULL default '', - PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; -INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(400,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3000,'20','threetrees.qt'); -# -# Bug #27758 Restoring NDB backups makes table usable in SQL nodes -# - space in key made table unusable after restore -# -# Bug #27775 - mediumint auto inc not restored correctly -# - check smallint -CREATE TABLE `t2_c` ( - `capgotod` smallint(5) unsigned NOT NULL auto_increment, - `gotod` smallint(5) unsigned NOT NULL default '0', - `goaledatta` char(2) default NULL, - `maturegarbagefa` varchar(32) default NULL, - `descrpooppo` varchar(64) default NULL, - `svcutonsa` varchar(64) NOT NULL default '', - PRIMARY KEY (`capgotod`), - KEY `i quadaddsvr` (`gotod`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; -INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); - -CREATE TABLE `t3_c` ( - `CapGoaledatta` smallint(5) unsigned NOT NULL default '0', - `capgotod` smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (`capgotod`,`CapGoaledatta`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; -INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3); - -# Bug #27775 - mediumint auto inc not restored correctly -# - check bigint -CREATE TABLE `t4_c` ( - `capfa` bigint(20) unsigned NOT NULL auto_increment, - `realm` varchar(32) NOT NULL default '', - `authpwchap` varchar(32) default NULL, - `fa` varchar(32) NOT NULL default '', - `payyingatta` tinyint(4) NOT NULL default '0', - `status` char(1) default NULL, - PRIMARY KEY (`fa`,`realm`), - KEY `capfa` (`capfa`), - KEY `i_quadentity` (`fa`,`realm`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; -INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(2200,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32000,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(290000000,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); - -CREATE TABLE `t5_c` ( - `capfa` bigint(20) unsigned NOT NULL default '0', - `gotod` smallint(5) unsigned NOT NULL default '0', - `orderutonsa` varchar(64) NOT NULL default '', - PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; -INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,''); - -CREATE TABLE `t6_c` ( - `capfa_parent` bigint(20) unsigned NOT NULL default '0', - `capfa_child` bigint(20) unsigned NOT NULL default '0', - `relatta` smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; -INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); - -# Bug #27775 - mediumint auto inc not restored correctly -# - check tinyint -CREATE TABLE `t7_c` ( - `dardpo` char(15) NOT NULL default '', - `dardtestard` tinyint(3) unsigned NOT NULL auto_increment, - `FastFA` char(5) NOT NULL default '', - `FastCode` char(6) NOT NULL default '', - `Fastca` char(1) NOT NULL default '', - `Fastmag` char(1) NOT NULL default '', - `Beareratta` char(2) NOT NULL default '', - PRIMARY KEY (`dardpo`,`dardtestard`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; -INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); - -CREATE TABLE `t8_c` ( - `kattjame` varchar(32) NOT NULL default '', - `realm` varchar(32) NOT NULL default '', - `realm_entered` varchar(32) NOT NULL default '', - `maturegarbagefa` varchar(32) NOT NULL default '', - `hunderaaarbagefa_parent` varchar(32) NOT NULL default '', - `kattjame_entered` varchar(32) NOT NULL default '', - `hunderaaarbagefa` varchar(32) NOT NULL default '', - `gest` varchar(16) default NULL, - `hassetino` varchar(16) NOT NULL default '', - `aaaproxysessfa` varchar(255) default NULL, - `autologonallowed` char(1) default NULL, - `squardporoot` varchar(15) NOT NULL default '', - `naspo` varchar(15) default NULL, - `beareratta` char(2) default NULL, - `fastCode` varchar(6) default NULL, - `fastFA` varchar(5) default NULL, - `fastca` char(1) default NULL, - `fastmag` char(1) default NULL, - `lastupdate` datetime default NULL, - `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', - `accthassetitime` int(10) unsigned default NULL, - `acctoutputoctets` bigint(20) unsigned default NULL, - `acctinputoctets` bigint(20) unsigned default NULL, - PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), - KEY `squardporoot` (`squardporoot`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; -INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); - -CREATE TABLE `t9_c` ( - `kattjame` varchar(32) NOT NULL default '', - `kattjame_entered` varchar(32) NOT NULL default '', - `realm` varchar(32) NOT NULL default '', - `realm_entered` varchar(32) NOT NULL default '', - `maturegarbagefa` varchar(32) NOT NULL default '', - `hunderaaarbagefa` varchar(32) NOT NULL default '', - `hunderaaarbagefa_parent` varchar(32) NOT NULL default '', - `gest` varchar(16) default NULL, - `hassetino` varchar(16) NOT NULL default '', - `squardporoot` varchar(15) NOT NULL default '', - `naspo` varchar(15) default NULL, - `beareratta` char(2) default NULL, - `fastCode` varchar(6) default NULL, - `fastFA` varchar(5) default NULL, - `fastca` char(1) default NULL, - `fastmag` char(1) default NULL, - `lastupdate` datetime default NULL, - `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', - `accthassetitime` int(10) unsigned default NULL, - `actcoutpuocttets` bigint(20) unsigned default NULL, - `actinputocctets` bigint(20) unsigned default NULL, - `terminateraste` tinyint(3) unsigned default NULL, - PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1; -INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); - -# Bug #20820 -# auto inc table not handled correctly when restored from cluster backup -# - before fix ndb_restore would not set auto inc value correct, -# seen by select below -create table t10_c (a int auto_increment key) ENGINE=ndbcluster; -insert into t10_c values (1),(2),(3); -# Bug #27775 - mediumint auto inc not restored correctly -# - check int -insert into t10_c values (10000),(2000),(3000); - -create table t1 engine=myisam as select * from t1_c; -create table t2 engine=myisam as select * from t2_c; -create table t3 engine=myisam as select * from t3_c; -create table t4 engine=myisam as select * from t4_c; -create table t5 engine=myisam as select * from t5_c; -create table t6 engine=myisam as select * from t6_c; -create table t7 engine=myisam as select * from t7_c; -create table t8 engine=myisam as select * from t8_c; -create table t9 engine=myisam as select * from t9_c; -create table t10 engine=myisam as select * from t10_c; - - ---source include/ndb_backup.inc -drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c, t10_c; ---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT - -show tables; - - -select count(*) from t1; -select count(*) from t1_c; -select count(*) - from (select * from t1 union - select * from t1_c) a; - -select count(*) from t2; -select count(*) from t2_c; -select count(*) - from (select * from t2 union - select * from t2_c) a; - -select count(*) from t3; -select count(*) from t3_c; -select count(*) - from (select * from t3 union - select * from t3_c) a; - -select count(*) from t4; -select count(*) from t4_c; -select count(*) - from (select * from t4 union - select * from t4_c) a; - -select count(*) from t5; -select count(*) from t5_c; -select count(*) - from (select * from t5 union - select * from t5_c) a; - -select count(*) from t6; -select count(*) from t6_c; -select count(*) - from (select * from t6 union - select * from t6_c) a; - -select count(*) from t7; -select count(*) from t7_c; -select count(*) - from (select * from t7 union - select * from t7_c) a; - -select count(*) from t8; -select count(*) from t8_c; -select count(*) - from (select * from t8 union - select * from t8_c) a; - -select count(*) from t9; -select count(*) from t9_c; -select count(*) - from (select * from t9 union - select * from t9_c) a; - -# Bug #20820 cont'd -select * from t10_c order by a; -# Bug #27775 cont'd -# - auto inc info should be correct -select max(capgoaledatta) from t1_c; -select auto_increment from information_schema.tables -where table_name = 't1_c'; -select max(capgotod) from t2_c; -select auto_increment from information_schema.tables -where table_name = 't2_c'; -select max(capfa) from t4_c; -select auto_increment from information_schema.tables -where table_name = 't4_c'; -select max(dardtestard) from t7_c; -select auto_increment from information_schema.tables -where table_name = 't7_c'; -select max(a) from t10_c; -select auto_increment from information_schema.tables -where table_name = 't10_c'; - ---disable_warnings -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9, t10; -drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c, t10_c; ---enable_warnings - -# -# Test BUG#10287 -# - ---exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696, | sed "s/,$the_backup_id/,<the_backup_id>/" - -# End of 5.0 tests (4.1 test intermixed to save test time) diff --git a/mysql-test/t/ndb_restore_different_endian_data.test b/mysql-test/t/ndb_restore_different_endian_data.test deleted file mode 100644 index 208ab8b459d..00000000000 --- a/mysql-test/t/ndb_restore_different_endian_data.test +++ /dev/null @@ -1,185 +0,0 @@ --- source include/have_ndb.inc --- source include/ndb_default_cluster.inc --- source include/not_embedded.inc - -# -# Bug #27543 restore of backup from different endian does not work for blob column -# Bug #30024 restore of backup from different endian does not work for datetime column -# Bug #28674 backup will run forever if disk full and later write succes will kill ndb node -# -# The table structure and data list below -# -# CREATE TABLE t_num ( -# t_pk INT PRIMARY KEY, -# t_bit BIT(64), -# t_tinyint TINYINT, -# t_bool BOOL, -# t_smallint SMALLINT, -# t_mediumint MEDIUMINT, -# t_int INT, -# t_bigint BIGINT, -# t_float FLOAT, -# t_double DOUBLE, -# t_decimal DECIMAL (37, 16) -# ) ENGINE=NDBCLUSTER; -# -# INSERT INTO t_num VALUE ( -# 1, -# b'1010101010101010101010101010101010101010101010101010101010101010', -# 125, -# 1, -# 32765, -# 8388606, -# 2147483647, -# 9223372036854775807, -# 1e+20, -# 1e+150, -# '331.0000000000' -# ); -# -# CREATE TABLE t_datetime ( -# t_pk INT PRIMARY KEY, -# t_date DATE, -# t_datetime DATETIME, -# t_timestamp TIMESTAMP, -# t_time TIME, -# t_year YEAR -# ) ENGINE=NDBCLUSTER; -# -# INSERT INTO t_datetime VALUE ( -# 1, -# '1998-01-01', -# '2006-08-10 10:11:12', -# 20021029165106, -# '19:38:34', -# 2155 -# ); -# -# CREATE TABLE t_string_1 ( -# t_pk INT PRIMARY KEY, -# t_char CHAR(255), -# t_varchar VARCHAR(655), -# t_binary BINARY(255), -# t_varbinary VARBINARY(6553) -# ) ENGINE=NDBCLUSTER; -# -# CREATE TABLE t_string_2 ( -# t_pk INT PRIMARY KEY, -# t_tinyblob TINYBLOB, -# t_tinytext TINYTEXT, -# t_blob BLOB, -# t_text TEXT, -# t_mediumblob MEDIUMBLOB, -# t_mediumtext MEDIUMTEXT, -# t_longblob LONGBLOB, -# t_longtext LONGTEXT, -# t_enum ENUM('001001','001004','001010','001018','001019','001020','001021','001027','001028','001029','001030','001031','001100','002003','002004','002005','002007')DEFAULT '001001' NOT NULL, -# t_set SET('a','B') -# ) ENGINE=NDBCLUSTER; -# -# INSERT INTO t_string_1 VALUE ( -# 1, -# 'abcdefghijklmn', -# 'abcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmn', -# 0x612020, -# 0x4100 -# ); -# -# INSERT INTO t_string_2 VALUE ( -# 1, -# 'abcdefghijklmnabcdefghijklmn', -# 'abcdefghijklmnabcdefghijklmn', -# 'a123456789b123456789c123456789d123456789e123456789f123456789g123456789', -# 'a123456789b123456789c123456789d123456789e123456789f123456789g123456789', -# 'a123456789b123456789c123456789d123456789e123456789f123456789g123456789', -# 'a123456789b123456789c123456789d123456789e123456789f123456789g123456789', -# 'a123456789b123456789c123456789d123456789e123456789f123456789g123456789', -# 'a123456789b123456789c123456789d123456789e123456789f123456789g123456789', -# '001001', -# 'a' -# ); -# -# CREATE TABLE t_gis ( -# t_pk INT PRIMARY KEY, -# t_point POINT, -# t_linestring LINESTRING, -# t_polygon POLYGON, -# t_multipoint MULTIPOINT, -# t_multilinestring MULTILINESTRING, -# t_multipolygon MULTIPOLYGON, -# t_geometrycollection GEOMETRYCOLLECTION, -# t_geometry GEOMETRY -# ) ENGINE=NDBCLUSTER; -# -# INSERT INTO t_gis VALUE ( -# 1, -# PointFromText('POINT(10 10)'), -# LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)'), -# PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'), -# MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)'), -# MLineFromText('MULTILINESTRING((10 48,10 21,10 0))'), -# 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)))'), -# GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))'), -# 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)))') -# ); -# -# INSERT INTO t_gis VALUE ( -# 2, -# PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))), -# LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))), -# PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))), -# MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))), -# MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))), -# MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))), -# GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))), -# GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))) -# ); - - - -# -# Restore backup files (from little endian) -# - ---disable_warnings -USE test; -DROP TABLE IF EXISTS t_num,t_datetime,t_string_1,t_string_2,t_gis; ---enable_warnings ---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -m -r $MYSQL_TEST_DIR/std_data/ndb_backup50_data_le >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 2 -r $MYSQL_TEST_DIR/std_data/ndb_backup50_data_le >> $NDB_TOOLS_OUTPUT -SHOW TABLES; -SHOW CREATE TABLE t_num; -SHOW CREATE TABLE t_datetime; -SHOW CREATE TABLE t_string_1; -SHOW CREATE TABLE t_string_2; -SHOW CREATE TABLE t_gis; -SELECT * FROM t_datetime; -SELECT t_pk,hex(t_bit),t_tinyint,t_bool,t_smallint,t_mediumint,t_int,t_bigint,t_float,t_double,t_decimal FROM t_num; -SELECT t_pk,t_char,t_varchar,hex(t_binary),hex(t_varbinary) FROM t_string_1; -SELECT * FROM t_string_2; -SELECT AsText(t_point), AsText(t_linestring),AsText(t_polygon) FROM t_gis ORDER by t_pk; -SELECT AsText(t_multipoint), AsText(t_multilinestring),AsText(t_multipolygon) FROM t_gis ORDER by t_pk; -SELECT AsText(t_geometrycollection), AsText(t_geometry) FROM t_gis ORDER by t_pk; - -# -# Restore backup files (from big endian) -# - -DROP TABLE t_num,t_datetime,t_string_1,t_string_2,t_gis; ---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -m -r $MYSQL_TEST_DIR/std_data/ndb_backup50_data_be >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 2 -r $MYSQL_TEST_DIR/std_data/ndb_backup50_data_be >> $NDB_TOOLS_OUTPUT -SHOW TABLES; -SHOW CREATE TABLE t_num; -SHOW CREATE TABLE t_datetime; -SHOW CREATE TABLE t_string_1; -SHOW CREATE TABLE t_string_2; -SHOW CREATE TABLE t_gis; -SELECT * FROM t_datetime; -SELECT t_pk,hex(t_bit),t_tinyint,t_bool,t_smallint,t_mediumint,t_int,t_bigint,t_float,t_double,t_decimal FROM t_num; -SELECT t_pk,t_char,t_varchar,hex(t_binary),hex(t_varbinary) FROM t_string_1; -SELECT * FROM t_string_2; -SELECT AsText(t_point), AsText(t_linestring),AsText(t_polygon) FROM t_gis ORDER by t_pk; -SELECT AsText(t_multipoint), AsText(t_multilinestring),AsText(t_multipolygon) FROM t_gis ORDER by t_pk; -SELECT AsText(t_geometrycollection), AsText(t_geometry) FROM t_gis ORDER by t_pk; - -DROP TABLE t_num,t_datetime,t_string_1,t_string_2,t_gis; diff --git a/mysql-test/t/ndb_restore_print.test b/mysql-test/t/ndb_restore_print.test deleted file mode 100644 index 9a880f8968c..00000000000 --- a/mysql-test/t/ndb_restore_print.test +++ /dev/null @@ -1,193 +0,0 @@ --- source include/have_ndb.inc --- source include/ndb_default_cluster.inc --- source include/not_embedded.inc - ---disable_warnings -use test; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; ---enable_warnings - -# basic datatypes -create table t1 - (pk int key - ,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64) - ,b1 TINYINT, b2 TINYINT UNSIGNED - ,c1 SMALLINT, c2 SMALLINT UNSIGNED - ,d1 INT, d2 INT UNSIGNED - ,e1 BIGINT, e2 BIGINT UNSIGNED - ,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY - ,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY - ,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255) - ,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) - ) engine myisam; - -# max values -insert into t1 values - (1 - ,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001 - ,127, 255 - ,32767, 65535 - ,2147483647, 4294967295 - ,9223372036854775807, 18446744073709551615 - ,'1','12345678901234567890123456789012','123456789' - ,'1','12345678901234567890123456789012','123456789' - ,0x12,0x123456789abcdef0, 0x012345 - ,0x12,0x123456789abcdef0, 0x00123450 - ); - -# min values -insert into t1 values - (2 - ,0, 0, 0, 0, 0 - ,-128, 0 - ,-32768, 0 - ,-2147483648, 0 - ,-9223372036854775808, 0 - ,'','','' - ,'','','' - ,0x0,0x0,0x0 - ,0x0,0x0,0x0 - ); - -# null values -insert into t1 values - (3 - ,NULL,NULL,NULL,NULL,NULL - ,NULL,NULL - ,NULL,NULL - ,NULL,NULL - ,NULL,NULL - ,NULL,NULL,NULL - ,NULL,NULL,NULL - ,NULL,NULL,NULL - ,NULL,NULL,NULL - ); - ---vertical_results -select pk - ,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5) - ,b1, b2 - ,c1 , c2 - ,d1 , d2 - ,e1 , e2 - ,f1 , f2, f3 - ,g1 , g2, g3 - ,hex(h1), hex(h2), hex(h3) - ,hex(i1), hex(i2), hex(i3) - from t1 order by pk; - -alter table t1 engine ndb; - -select pk - ,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5) - ,b1, b2 - ,c1 , c2 - ,d1 , d2 - ,e1 , e2 - ,f1 , f2, f3 - ,g1 , g2, g3 - ,hex(h1), hex(h2), hex(h3) - ,hex(i1), hex(i2), hex(i3) - from t1 order by pk; ---horizontal_results - ---source include/ndb_backup.inc - ---let ndb_restore_filter=test t1 ---let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by=";" ---source include/ndb_backup_print.inc - ---let ndb_restore_filter=test t1 ---let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by="," --fields-optionally-enclosed-by="'" ---source include/ndb_backup_print.inc - - -drop table t1; - -# some binary char tests with trailing spaces -create table t1 - (pk int key - ,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY - ,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY - ,h1 BINARY(1), h2 BINARY(9), h3 BINARY(255) - ,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) - ) engine ndb; - -insert into t1 values - (1 - ,'1','12345678901234567890123456789012','123456789 ' - ,'1 ','12345678901234567890123456789012 ','123456789 ' - ,0x20,0x123456789abcdef020, 0x012345000020 - ,0x1200000020,0x123456789abcdef000000020, 0x00123450000020 - ); - -create table t2 (pk int key, a int) engine ndb; -create table t3 (pk int key, a int) engine ndb; -create table t4 (pk int key, a int) engine ndb; - -insert into t2 values (1,11),(2,12),(3,13),(4,14),(5,15); -insert into t3 values (1,21),(2,22),(3,23),(4,24),(5,25); -insert into t4 values (1,31),(2,32),(3,33),(4,34),(5,35); - ---source include/ndb_backup.inc ---let ndb_restore_opts=--verbose=0 --print_data --hex --fields-enclosed-by="'" --fields-optionally-enclosed-by="X" ---let ndb_restore_filter=test t1 ---source include/ndb_backup_print.inc - ---error 0,1 ---remove_file $MYSQLTEST_VARDIR/tmp/t1.txt ---error 0,1 ---remove_file $MYSQLTEST_VARDIR/tmp/t2.txt ---error 0,1 ---remove_file $MYSQLTEST_VARDIR/tmp/t3.txt ---error 0,1 ---remove_file $MYSQLTEST_VARDIR/tmp/t4.txt - ---let ndb_restore_opts=--verbose=0 --print_data --hex --tab $MYSQLTEST_VARDIR/tmp --append ---let ndb_restore_filter=test ---source include/ndb_backup_print.inc - ---let $message= t1 ---source include/show_msg.inc ---exec sort $MYSQLTEST_VARDIR/tmp/t1.txt ---let $message= t2 ---source include/show_msg.inc ---exec sort $MYSQLTEST_VARDIR/tmp/t2.txt ---let $message= t3 ---source include/show_msg.inc ---exec sort $MYSQLTEST_VARDIR/tmp/t3.txt ---let $message= t4 ---source include/show_msg.inc ---exec sort $MYSQLTEST_VARDIR/tmp/t4.txt - ---remove_file $MYSQLTEST_VARDIR/tmp/t1.txt ---remove_file $MYSQLTEST_VARDIR/tmp/t2.txt ---remove_file $MYSQLTEST_VARDIR/tmp/t3.txt ---remove_file $MYSQLTEST_VARDIR/tmp/t4.txt - -# now test some other datatypes -drop table t1; -create table t1 - (pk int key - ,a1 MEDIUMINT, a2 MEDIUMINT UNSIGNED - ) engine ndb; - -# max values -insert into t1 values(1, 8388607, 16777215); -# min values -insert into t1 values(2, -8388608, 0); -# small values -insert into t1 values(3, -1, 1); - -# backup and print ---source include/ndb_backup.inc - ---let ndb_restore_filter=test t1 ---let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by=";" ---source include/ndb_backup_print.inc - -# clean up -drop table t1; -drop table t2; -drop table t3; -drop table t4; diff --git a/mysql-test/t/ndb_single_user.test b/mysql-test/t/ndb_single_user.test deleted file mode 100644 index 631d3800499..00000000000 --- a/mysql-test/t/ndb_single_user.test +++ /dev/null @@ -1,120 +0,0 @@ --- source include/have_ndb.inc --- source include/have_multi_ndb.inc --- source include/ndb_default_cluster.inc --- source include/not_embedded.inc - ---disable_warnings -use test; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; ---enable_warnings - -# operations allowed while cluster is in single user mode - ---connection server1 ---let $node_id= `SHOW STATUS LIKE 'Ndb_cluster_node_id'` ---disable_query_log ---eval set @node_id= SUBSTRING('$node_id', 20)+0 ---enable_query_log ---let $node_id= `SELECT @node_id` ---exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "enter single user mode $node_id" >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" --single-user >> $NDB_TOOLS_OUTPUT - -# verify that we are indeed in single user mode ---connection server2 ---error 1005 -create table t1 (a int key, b int unique, c int) engine ndb; - -# test some sql on first mysqld ---connection server1 -create table t1 (a int key, b int unique, c int) engine ndb; -insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(10,10,0); -create table t2 as select * from t1; -# read with pk -select * from t1 where a = 1; -# read with unique index -select * from t1 where b = 4; -# read with ordered index -select * from t1 where a > 4 order by a; -# update with pk -update t1 set b=102 where a = 2; -# update with unique index -update t1 set b=103 where b = 3; -# update with full table scan -update t1 set b=b+100; -# update with ordered insex scan -update t1 set b=b+100 where a > 7; -# delete with full table scan -delete from t1; -insert into t1 select * from t2; -# Bug #27710 Creating unique index fails during single user mode -# - prior to bugfix this would fail -create unique index new_index on t1 (b,c); - -# test some sql on other mysqld ---connection server2 ---error 1051 -drop table t1; ---error 1296 -create index new_index_fail on t1 (c); ---error 1296 -insert into t1 values (21,21,0),(22,22,0),(23,23,0),(24,24,0),(25,25,0),(26,26,0),(27,27,0),(28,28,0),(29,29,0),(210,210,0); ---error 1296 -select * from t1 where a = 1; ---error 1296 -select * from t1 where b = 4; ---error 1296 -update t1 set b=102 where a = 2; ---error 1296 -update t1 set b=103 where b = 3; ---error 1296 -update t1 set b=b+100; ---error 1296 -update t1 set b=b+100 where a > 7; - ---exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "exit single user mode" >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT - -# -# we should be able to run transaction while in single user mode -# ---connection server1 -BEGIN; -update t1 set b=b+100 where a=1; - ---connection server2 -BEGIN; -update t1 set b=b+100 where a=2; - -# enter single user mode ---exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "enter single user mode $node_id" >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" --single-user >> $NDB_TOOLS_OUTPUT - ---connection server1 -update t1 set b=b+100 where a=3; -COMMIT; - -# while on other mysqld it should be aborted ---connection server2 ---error 1296 -update t1 set b=b+100 where a=4; ---error 1296 -COMMIT; - -# Bug #25275 SINGLE USER MODE prevents ALTER on non-ndb -# tables for other mysqld nodes ---connection server2 -create table t2 (a int) engine myisam; -alter table t2 add column (b int); - -# exit single user mode ---exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "exit single user mode" >> $NDB_TOOLS_OUTPUT ---exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT - -# cleanup ---connection server2 -drop table t2; ---connection server1 -drop table t1; - -# End of 5.0 tests - diff --git a/mysql-test/t/ndb_subquery.test b/mysql-test/t/ndb_subquery.test deleted file mode 100644 index 93c45c521a0..00000000000 --- a/mysql-test/t/ndb_subquery.test +++ /dev/null @@ -1,65 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1; -drop table if exists t2; ---enable_warnings - -########## -# bug#5367 -create table t1 (p int not null primary key, u int not null, o int not null, -unique (u), key(o)) engine=ndb; - -create table t2 (p int not null primary key, u int not null, o int not null, -unique (u), key(o)) engine=ndb; - -insert into t1 values (1,1,1),(2,2,2),(3,3,3); -insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5); - -# Use pk -explain select * from t2 where p NOT IN (select p from t1); -select * from t2 where p NOT IN (select p from t1) order by p; - -# Use unique index -explain select * from t2 where p NOT IN (select u from t1); -select * from t2 where p NOT IN (select u from t1) order by p; - -# Use ordered index -explain select * from t2 where p NOT IN (select o from t1); -select * from t2 where p NOT IN (select o from t1) order by p; - -# Use scan -explain select * from t2 where p NOT IN (select p+0 from t1); -select * from t2 where p NOT IN (select p+0 from t1) order by p; - -drop table t1; -drop table t2; -# bug#5367 -########## - -# End of 4.1 tests - -# -# bug#11205 -# -create table t1 (p int not null primary key, u int not null) engine=ndb; -insert into t1 values (1,1),(2,2),(3,3); - -create table t2 as -select t1.* -from t1 as t1, t1 as t2, t1 as t3, t1 as t4, t1 as t5, t1 as t6, t1 as t7, t1 as t8 -where t1.u = t2.u - and t2.u = t3.u - and t3.u = t4.u - and t4.u = t5.u - and t5.u = t6.u - and t6.u = t7.u - and t7.u = t8.u; - -select * from t2 order by 1; - -drop table t1; -drop table t2; - - diff --git a/mysql-test/t/ndb_transaction.test b/mysql-test/t/ndb_transaction.test deleted file mode 100644 index d3ebadb1a78..00000000000 --- a/mysql-test/t/ndb_transaction.test +++ /dev/null @@ -1,298 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; -drop database if exists mysqltest; ---enable_warnings - -# -# Transactionc test to show that the NDB -# table handler is working properly with -# transactions -# - -# -# Create a normal table with primary key -# -CREATE TABLE t1 ( - pk1 INT NOT NULL PRIMARY KEY, - attr1 INT NOT NULL -) ENGINE=ndbcluster; - -# insert -begin; -insert into t1 values(1,1); -insert into t1 values(2,2); -select count(*) from t1; -select * from t1 where pk1 = 1; -select t1.attr1 from t1, t1 as t1x where t1.pk1 = t1x.pk1 + 1; -rollback; - -select count(*) from t1; -select * from t1 where pk1 = 1; -select t1.attr1 from t1, t1 as t1x where t1.pk1 = t1x.pk1 + 1; - -begin; -insert into t1 values(1,1); -insert into t1 values(2,2); -commit; - -select count(*) from t1; -select * from t1 where pk1 = 1; -select t1.attr1 from t1, t1 as t1x where t1.pk1 = t1x.pk1 + 1; - -# update -begin; -update t1 set attr1 = attr1 * 2; -select count(*) from t1; -select * from t1 where pk1 = 1; -select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; -rollback; - -select count(*) from t1; -select * from t1 where pk1 = 1; -select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; - -begin; -update t1 set attr1 = attr1 * 2; -commit; - -select count(*) from t1; -select * from t1 where pk1 = 1; -select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; - -# delete -begin; -delete from t1 where attr1 = 2; -select count(*) from t1; -select * from t1 where pk1 = 1; -select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; -rollback; - -select count(*) from t1; -select * from t1 where pk1 = 1; -select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; - -begin; -delete from t1 where attr1 = 2; -commit; - -select count(*) from t1; -select * from t1 where pk1 = 1; -select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; - -DROP TABLE t1; - -# -# Create table without primary key -# a hidden primary key column is created by handler -# -CREATE TABLE t1 (id INT, id2 int) engine=ndbcluster; - -# insert -begin; -insert into t1 values(1,1); -insert into t1 values(2,2); -select sum(id) from t1; -select * from t1 where id = 1; -select t1.id from t1, t1 as t1x where t1.id2 = t1x.id2 + 1; -rollback; - -select sum(id) from t1; -select * from t1 where id = 1; -select t1.id from t1, t1 as t1x where t1.id2 = t1x.id2 + 1; - -begin; -insert into t1 values(1,1); -insert into t1 values(2,2); -commit; - -select sum(id) from t1; -select * from t1 where id = 1; -select t1.id from t1, t1 as t1x where t1.id2 = t1x.id2 + 1; - -# update -begin; -update t1 set id = id * 2; -select sum(id) from t1; -select * from t1 where id = 2; -select * from t1, t1 as t1x where t1x.id = t1.id - 2; -rollback; - -select sum(id) from t1; -select * from t1 where id = 2; -select * from t1, t1 as t1x where t1x.id = t1.id - 2; - -begin; -update t1 set id = id * 2; -commit; - -select sum(id) from t1; -select * from t1 where id = 2; -select * from t1, t1 as t1x where t1x.id = t1.id - 2; - -# delete - -DROP TABLE t1; - -# -# A more extensive test with a lot more records -# - -CREATE TABLE t2 ( - a bigint unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned -) engine=ndbcluster; - -CREATE TABLE t3 ( - a bigint unsigned NOT NULL, - b bigint unsigned not null, - c bigint unsigned, - PRIMARY KEY(a) -) engine=ndbcluster; - -CREATE TABLE t4 ( - a bigint unsigned NOT NULL, - b bigint unsigned not null, - c bigint unsigned NOT NULL, - d int unsigned, - PRIMARY KEY(a, b, c) -) engine=ndbcluster; - - -# -# insert records into tables and rollback -# -let $1=100; -disable_query_log; -begin; -while ($1) -{ - eval insert into t2 values($1, $1+9, 5); - eval insert into t3 values($1, $1+9, 5); - eval insert into t4 values($1, $1+9, 5, $1+26000); - dec $1; -} -rollback; -enable_query_log; - -select count(*) from t2; -select count(*) from t3; -select count(*) from t4; - -# -# insert records into tables and commit; -# -let $1=100; -disable_query_log; -begin; -while ($1) -{ - eval insert into t2 values($1, $1+9, 5); - eval insert into t3 values($1, $1+9, 5); - eval insert into t4 values($1, $1+9, 5, $1+26000); - dec $1; -} -commit; -enable_query_log; - -select count(*) from t2; -select count(*) from t3; -select count(*) from t4; - -# -# delete every other record in the tables -# -let $1=100; -disable_query_log; -while ($1) -{ - eval delete from t2 where a=$1; - eval delete from t3 where a=$1; - eval delete from t4 where a=$1 and b=$1+9 and c=5; - dec $1; - dec $1; -} -enable_query_log; - -# -# update records and rollback -# -begin; -let $1=100; -disable_query_log; -while ($1) -{ - eval update t2 set c=$1 where a=$1; - eval update t3 set c=7 where a=$1 and b=$1+9 and c=5; - eval update t4 set d=$1+21987 where a=$1 and b=$1+9 and c=5; - dec $1; - dec $1; -} -rollback; -enable_query_log; - -# -# update records and commit -# -begin; -let $1=100; -disable_query_log; -while ($1) -{ - eval update t2 set c=$1 where a=$1; - eval update t3 set c=7 where a=$1 and b=$1+9 and c=5; - eval update t4 set d=$1+21987 where a=$1 and b=$1+9 and c=5; - dec $1; - dec $1; -} -rollback; -enable_query_log; - -drop table t2; -drop table t3; -drop table t4; - -# -# Test multiple databases in one transaction -# - -CREATE TABLE t1 ( - pk1 INT NOT NULL PRIMARY KEY, - attr1 INT NOT NULL -) ENGINE=ndbcluster; - -create database mysqltest; -use mysqltest; - -CREATE TABLE t2 ( - a bigint unsigned NOT NULL PRIMARY KEY, - b int unsigned not null, - c int unsigned -) engine=ndbcluster; - -begin; -insert into test.t1 values(1,1); -insert into t2 values(1,1,1); -insert into test.t1 values(2,2); -insert into t2 values(2,2,2); -select count(*) from test.t1; -select count(*) from t2; -select * from test.t1 where pk1 = 1; -select * from t2 where a = 1; -select test.t1.attr1 -from test.t1, test.t1 as t1x where test.t1.pk1 = t1x.pk1 + 1; -select t2.a -from t2, t2 as t2x where t2.a = t2x.a + 1; -select test.t1.pk1, a from test.t1,t2 where b > test.t1.attr1; -rollback; - -select count(*) from test.t1; -select count(*) from t2; - -drop table test.t1, t2; -drop database mysqltest; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_trigger.test b/mysql-test/t/ndb_trigger.test deleted file mode 100644 index 25b079cfe7c..00000000000 --- a/mysql-test/t/ndb_trigger.test +++ /dev/null @@ -1,200 +0,0 @@ -# Tests which involve triggers and NDB storage engine ---source include/have_ndb.inc ---source include/not_embedded.inc - -# -# Test for bug#18437 "Wrong values inserted with a before update -# trigger on NDB table". SQL-layer didn't properly inform handler -# about fields which were read and set in triggers. In some cases -# this resulted in incorrect (garbage) values of OLD variables and -# lost changes to NEW variables. -# You can find similar tests for ON INSERT triggers in federated.test -# since this engine so far is the only engine in MySQL which cares -# about field mark-up during handler::write_row() operation. -# - ---disable_warnings -drop table if exists t1, t2, t3; ---enable_warnings - -create table t1 (id int primary key, a int not null, b decimal (63,30) default 0) engine=ndb; -create table t2 (op char(1), a int not null, b decimal (63,30)); -create table t3 select 1 as i; - -delimiter //; -create trigger t1_bu before update on t1 for each row -begin - insert into t2 values ("u", old.a, old.b); - set new.b = old.b + 10; -end;// -create trigger t1_bd before delete on t1 for each row -begin - insert into t2 values ("d", old.a, old.b); -end;// -delimiter ;// -insert into t1 values (1, 1, 1.05), (2, 2, 2.05), (3, 3, 3.05), (4, 4, 4.05); - -# Check that usual update works as it should -update t1 set a=5 where a != 3; -select * from t1 order by id; -select * from t2 order by op, a, b; -delete from t2; -# Check that everything works for multi-update -update t1, t3 set a=6 where a = 5; -select * from t1 order by id; -select * from t2 order by op, a, b; -delete from t2; -# Check for delete -delete from t1 where a != 3; -select * from t1 order by id; -select * from t2 order by op, a, b; -delete from t2; -# Check for multi-delete -insert into t1 values (1, 1, 1.05), (2, 2, 2.05), (4, 4, 4.05); -delete t1 from t1, t3 where a != 3; -select * from t1 order by id; -select * from t2 order by op, a, b; -delete from t2; -# Check for insert ... on duplicate key update -insert into t1 values (4, 4, 4.05); -insert into t1 (id, a) values (4, 1), (3, 1) on duplicate key update a= a + 1; -select * from t1 order by id; -select * from t2 order by op, a, b; -delete from t2; -# Check for insert ... select ... on duplicate key update -delete from t3; -insert into t3 values (4), (3); -insert into t1 (id, a) (select i, 1 from t3) on duplicate key update a= a + 1; -select * from t1 order by id; -select * from t2 order by op, a, b; -delete from t2; -# Check for replace -replace into t1 (id, a) values (4, 1), (3, 1); -select * from t1 order by id; -select * from t2 order by op, a, b; -delete from t1; -delete from t2; -# Check for replace ... select ... -insert into t1 values (3, 1, 1.05), (4, 1, 2.05); -replace into t1 (id, a) (select i, 2 from t3); -select * from t1 order by id; -select * from t2 order by op, a, b; -delete from t1; -delete from t2; -# Check for load data replace -insert into t1 values (3, 1, 1.05), (5, 2, 2.05); -load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (id, a); -select * from t1 order by id; -select * from t2 order by op, a, b; - -drop tables t1, t2, t3; - -# Test for bug#26242 -# Verify that AFTER UPDATE/DELETE triggers are executed -# after the change has actually taken place - -CREATE TABLE t1 ( - id INT NOT NULL PRIMARY KEY, - xy INT -) ENGINE=ndbcluster; - -INSERT INTO t1 VALUES (1, 0); - -DELIMITER //; -CREATE TRIGGER t1_update AFTER UPDATE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id = NEW.id; END // -DELIMITER ;// - -CREATE TABLE t2 ( - id INT NOT NULL PRIMARY KEY, - xy INT -) ENGINE=ndbcluster; - -INSERT INTO t2 VALUES (2, 0); - -CREATE TABLE t3 (id INT NOT NULL PRIMARY KEY) ENGINE=ndbcluster; - -INSERT INTO t3 VALUES (1); - -CREATE TABLE t4 LIKE t1; - -DELIMITER //; -CREATE TRIGGER t4_update AFTER UPDATE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id = NEW.id; END // -DELIMITER ;// - -CREATE TABLE t5 LIKE t2; - -UPDATE t1 SET xy = 3 WHERE id = 1; -SELECT xy FROM t1 where id = 1; -SELECT xy FROM t2 where id = 1; - -UPDATE t1 SET xy = 4 WHERE id IN (SELECT id FROM t3 WHERE id = 1); -SELECT xy FROM t1 where id = 1; -SELECT xy FROM t2 where id = 1; - -INSERT INTO t4 SELECT * FROM t1; -INSERT INTO t5 SELECT * FROM t2; -UPDATE t1,t4 SET t1.xy = 3, t4.xy = 3 WHERE t1.id = 1 AND t4.id = 1; -SELECT xy FROM t1 where id = 1; -SELECT xy FROM t2 where id = 1; -SELECT xy FROM t4 where id = 1; -SELECT xy FROM t5 where id = 1; - -UPDATE t1,t4 SET t1.xy = 4, t4.xy = 4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 1) AND t4.id IN (SELECT id FROM t3 WHERE id = 1); -SELECT xy FROM t1 where id = 1; -SELECT xy FROM t2 where id = 1; -SELECT xy FROM t4 where id = 1; -SELECT xy FROM t5 where id = 1; - -INSERT INTO t1 VALUES (1,0) ON DUPLICATE KEY UPDATE xy = 5; -SELECT xy FROM t1 where id = 1; -SELECT xy FROM t2 where id = 1; - -DROP TRIGGER t1_update; -DROP TRIGGER t4_update; - -DELIMITER //; -CREATE TRIGGER t1_delete AFTER DELETE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id > 4; END // -DELIMITER ;// - -DELIMITER //; -CREATE TRIGGER t4_delete AFTER DELETE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id > 4; END // -DELIMITER ;// - -INSERT INTO t1 VALUES (5, 0),(6,0); -INSERT INTO t2 VALUES (5, 1),(6,1); -INSERT INTO t3 VALUES (5); -SELECT * FROM t1 order by id; -SELECT * FROM t2 order by id; -DELETE FROM t1 WHERE id IN (SELECT id FROM t3 WHERE id = 5); -SELECT * FROM t1 order by id; -SELECT * FROM t2 order by id; - -INSERT INTO t1 VALUES (5,0); -UPDATE t2 SET xy = 1 WHERE id = 6; -TRUNCATE t4; -INSERT INTO t4 SELECT * FROM t1; -TRUNCATE t5; -INSERT INTO t5 SELECT * FROM t2; -SELECT * FROM t1 order by id; -SELECT * FROM t2 order by id; -SELECT * FROM t4 order by id; -SELECT * FROM t5 order by id; -DELETE FROM t1,t4 USING t1,t3,t4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 5) AND t4.id IN (SELECT id FROM t3 WHERE id = 5); -SELECT * FROM t1 order by id; -SELECT * FROM t2 order by id; -SELECT * FROM t4 order by id; -SELECT * FROM t5 order by id; - -INSERT INTO t1 VALUES (5, 0); -REPLACE INTO t2 VALUES (6,1); -SELECT * FROM t1 order by id; -SELECT * FROM t2 order by id; -REPLACE INTO t1 VALUES (5, 1); -SELECT * FROM t1 order by id; -SELECT * FROM t2 order by id; - -DROP TRIGGER t1_delete; -DROP TRIGGER t4_delete; -DROP TABLE t1, t2, t3, t4, t5; - ---echo End of 5.0 tests diff --git a/mysql-test/t/ndb_truncate.test b/mysql-test/t/ndb_truncate.test deleted file mode 100644 index a1ef4be0d48..00000000000 --- a/mysql-test/t/ndb_truncate.test +++ /dev/null @@ -1,41 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1, t2; ---enable_warnings - -CREATE TABLE t1 ( - a bigint unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, - b int unsigned not null, - c int unsigned -) engine=ndbcluster; - - -# -# insert records into table -# -let $1=500; -disable_query_log; -while ($1) -{ - eval insert into t1 values(NULL, $1+9, 5*$1), (NULL, $1+10, 7),(NULL, $1+10, 7*$1), (NULL, $1+10, 10+$1), (NULL, $1+10, 70*$1), (NULL, $1+10, 7), (NULL, $1+10, 9), (NULL, $1+299, 899), (NULL, $1+10, 12), (NULL, $1+10, 14*$1); - dec $1; -} -enable_query_log; - -select count(*) from t1; - -select * from t1 order by a limit 2; - -truncate table t1; - -select count(*) from t1; - -insert into t1 values(NULL,1,1),(NULL,2,2); - -select * from t1 order by a; - -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/ndb_types.test b/mysql-test/t/ndb_types.test deleted file mode 100644 index ab18817132e..00000000000 --- a/mysql-test/t/ndb_types.test +++ /dev/null @@ -1,85 +0,0 @@ ---source include/have_ndb.inc ---source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - -# -# Test creation of different column types in NDB -# -CREATE TABLE t1 ( - auto int(5) unsigned NOT NULL auto_increment, - string char(10) default "hello", - vstring varchar(10) default "hello", - bin binary(2), - vbin varbinary(7), - tiny tinyint(4) DEFAULT '0' NOT NULL , - short smallint(6) DEFAULT '1' NOT NULL , - medium mediumint(8) DEFAULT '0' NOT NULL, - long_int int(11) DEFAULT '0' NOT NULL, - longlong bigint(13) DEFAULT '0' NOT NULL, - real_float float(13,1) DEFAULT 0.0 NOT NULL, - real_double double(16,4), - real_decimal decimal(16,4), - utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, - ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, - umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, - ulong int(11) unsigned DEFAULT '0' NOT NULL, - ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, - bits bit(3), - options enum('one','two','tree') not null, - flags set('one','two','tree') not null, - date_field date, - year_field year, - time_field time, - date_time datetime, - time_stamp timestamp not null default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - PRIMARY KEY (auto), - KEY (utiny), - KEY (tiny), - KEY (short), - KEY any_name (medium), - KEY (longlong), - KEY (real_float), - KEY (ushort), - KEY (umedium), - KEY (ulong), - KEY (ulonglong,ulong), - KEY (options,flags) -); - -set @now = now(); ---sleep 1.5 -insert into t1 -(string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, - real_float,real_double, real_decimal,utiny, ushort, umedium,ulong,ulonglong, - bits,options,flags,date_field,year_field,time_field,date_time) -values -("aaaa","aaaa",0xAAAA,0xAAAA,-1,-1,-1,-1,-1,1.1,1.1,1.1,1,1,1,1,1, - b'001','one','one', '1901-01-01','1901','01:01:01','1901-01-01 01:01:01'); - -select auto,string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, - real_float,real_double,real_decimal,utiny,ushort,umedium,ulong,ulonglong, - bits,options,flags,date_field,year_field,time_field,date_time -from t1; -select time_stamp>@now from t1; - -set @now = now(); ---sleep 1.5 -update t1 set string="bbbb",vstring="bbbb",bin=0xBBBB,vbin=0xBBBB, -tiny=-2,short=-2,medium=-2,long_int=-2,longlong=-2,real_float=2.2, -real_double=2.2,real_decimal=2.2,utiny=2,ushort=2,umedium=2,ulong=2, -ulonglong=2, bits=b'010', -options='one',flags='one', date_field='1902-02-02',year_field='1902', -time_field='02:02:02',date_time='1902-02-02 02:02:02' where auto=1; - -select auto,string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, - real_float,real_double,real_decimal,utiny,ushort,umedium,ulong,ulonglong, - bits,options,flags,date_field,year_field,time_field,date_time -from t1; -select time_stamp>@now from t1; - -drop table t1; - ---echo End of 4.1 tests diff --git a/mysql-test/t/ndb_update.test b/mysql-test/t/ndb_update.test deleted file mode 100644 index 0f8793300e0..00000000000 --- a/mysql-test/t/ndb_update.test +++ /dev/null @@ -1,46 +0,0 @@ --- source include/have_ndb.inc --- source include/not_embedded.inc - ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - -# -# Basic test of INSERT in NDB -# - -# -# Create a normal table with primary key -# -CREATE TABLE t1 ( - pk1 INT NOT NULL PRIMARY KEY, - b INT NOT NULL, - c INT NOT NULL UNIQUE -) ENGINE=ndbcluster; - -INSERT INTO t1 VALUES (0, 1, 0),(1,2,1),(2,3,2); -UPDATE t1 set b = c; -select * from t1 order by pk1; -UPDATE t1 set pk1 = 4 where pk1 = 1; -select * from t1 order by pk1; ---error 1062 -UPDATE t1 set pk1 = 4 where pk1 = 2; -UPDATE IGNORE t1 set pk1 = 4 where pk1 = 2; -select * from t1 order by pk1; --- error 1062 -UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4; -UPDATE IGNORE t1 set pk1 = 1, c = 2 where pk1 = 4; -select * from t1 order by pk1; -UPDATE t1 set pk1 = pk1 + 10; -select * from t1 order by pk1; -# bug#25817 -create unique index ib on t1(b); -update t1 set c = 4 where pk1 = 12; -update ignore t1 set b = 55 where pk1 = 14; -select * from t1 order by pk1; - ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - -# End of 4.1 tests diff --git a/mysql-test/t/no-threads-master.opt b/mysql-test/t/no-threads-master.opt new file mode 100644 index 00000000000..e263cad427c --- /dev/null +++ b/mysql-test/t/no-threads-master.opt @@ -0,0 +1 @@ +--one-thread --thread-handling=no-threads diff --git a/mysql-test/t/no-threads.test b/mysql-test/t/no-threads.test new file mode 100644 index 00000000000..fd8365e5678 --- /dev/null +++ b/mysql-test/t/no-threads.test @@ -0,0 +1,16 @@ +# +# Test the --thread-handler=no-threads option +# +select 1+1; +select 1+2; +SHOW GLOBAL VARIABLES LIKE 'thread_handling'; + +# +# Bug #30651 Problems with thread_handling system variable +# + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +select @@session.thread_handling; + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +set GLOBAL thread_handling='one-thread'; diff --git a/mysql-test/t/not_embedded_server.test b/mysql-test/t/not_embedded_server.test index fcbcc389b15..fa2b659ec57 100644 --- a/mysql-test/t/not_embedded_server.test +++ b/mysql-test/t/not_embedded_server.test @@ -5,48 +5,41 @@ -- source include/not_embedded.inc # -# Show full process list with prepare -# To not show other connections, this must be the first test and we must -# have a server restart before this one +# Produce output # -prepare stmt1 from ' show full processlist '; ---replace_column 1 number 6 time 3 localhost -execute stmt1; -deallocate prepare stmt1; - -# End of 4.1 tests - +select 1; + +# The following fails sporadically because 'check-testcase' runs +# queries before this test and there is no way to guarantee that any +# previous process finishes. The purpose of the test is not clearly +# stated, there is no reference to any bug report, and "select from +# I_S from prepared statement" doesn't look like something that's +# really imporant to test. I'm commenting out this for now. If +# anyone wants to keep this, please fix the race and motivate why we +# need to test this. If you see this comment and it is after mid-2009 +# or so, feel free to remove this test from the file. /Sven # -# Bug#31222: com_% global status counters behave randomly with -# mysql_change_user. # +## Show full process list with prepare +## To not show other connections, this must be the first test and we must +## have a server restart before this one +## +## We don't have any 4.1 tests as we use I_S to query the PROCESSLIST to +## exclude system threads that may/may not be active in the server +## (namely the ndb injector thread) +## +## End of 4.1 tests +# +#prepare stmt1 from ' SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND!=\'Daemon\' '; +#--replace_column 1 number 6 time 3 localhost +#execute stmt1; +#deallocate prepare stmt1; -FLUSH STATUS; - ---disable_result_log ---disable_query_log - -let $i = 100; - -while ($i) -{ - dec $i; - - SELECT 1; -} - ---enable_query_log ---enable_result_log - -let $before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_select',Value,1); - ---change_user +# +# Bug#43835: SHOW VARIABLES does not include 0 for slave_skip_errors +# -let $after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_select',Value,1); +SHOW VARIABLES like 'slave_skip_errors'; -if (`select $after != $before`){ - SHOW GLOBAL STATUS LIKE 'com_select'; - die The value of com_select changed during change_user; -} -echo Value of com_select did not change; +# End of 5.1 tests diff --git a/mysql-test/t/not_partition.test b/mysql-test/t/not_partition.test new file mode 100644 index 00000000000..78ca44acf18 --- /dev/null +++ b/mysql-test/t/not_partition.test @@ -0,0 +1,85 @@ +--disable_abort_on_error +# Run this test only when mysqld don't has partitioning (not compiled with) +# the statements are not expected to work, just check that we +# can't crash the server +-- require r/not_partition.require +disable_query_log; +show variables like "have_partitioning"; +enable_query_log; +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +let $MYSQLD_DATADIR= `SELECT @@datadir`; + +# +# Bug#39893: Crash if select on a partitioned table, +# when partitioning is disabled +FLUSH TABLES; +--copy_file $MYSQLTEST_VARDIR/std_data/parts/t1.frm $MYSQLD_DATADIR/test/t1.frm +SELECT * FROM t1; +TRUNCATE TABLE t1; +ANALYZE TABLE t1; +CHECK TABLE t1; +OPTIMIZE TABLE t1; +REPAIR TABLE t1; +ALTER TABLE t1 REPAIR PARTITION ALL; +ALTER TABLE t1 CHECK PARTITION ALL; +ALTER TABLE t1 OPTIMIZE PARTITION ALL; +ALTER TABLE t1 ANALYZE PARTITION ALL; +ALTER TABLE t1 REBUILD PARTITION ALL; +ALTER TABLE t1 ENGINE Memory; +ALTER TABLE t1 ADD (new INT); +DROP TABLE t1; + +--error ER_FEATURE_DISABLED +CREATE TABLE t1 ( + firstname VARCHAR(25) NOT NULL, + lastname VARCHAR(25) NOT NULL, + username VARCHAR(16) NOT NULL, + email VARCHAR(35), + joined DATE NOT NULL +) +PARTITION BY KEY(joined) +PARTITIONS 6; + +--error ER_FEATURE_DISABLED +ALTER TABLE t1 PARTITION BY KEY(joined) PARTITIONS 2; + +--error ER_BAD_TABLE_ERROR +drop table t1; + +--error ER_FEATURE_DISABLED +CREATE TABLE t1 ( + firstname VARCHAR(25) NOT NULL, + lastname VARCHAR(25) NOT NULL, + username VARCHAR(16) NOT NULL, + email VARCHAR(35), + joined DATE NOT NULL +) +PARTITION BY RANGE( YEAR(joined) ) ( + PARTITION p0 VALUES LESS THAN (1960), + PARTITION p1 VALUES LESS THAN (1970), + PARTITION p2 VALUES LESS THAN (1980), + PARTITION p3 VALUES LESS THAN (1990), + PARTITION p4 VALUES LESS THAN MAXVALUE +); +--error ER_BAD_TABLE_ERROR +drop table t1; + +--error ER_FEATURE_DISABLED +CREATE TABLE t1 (id INT, purchased DATE) + PARTITION BY RANGE( YEAR(purchased) ) + SUBPARTITION BY HASH( TO_DAYS(purchased) ) + SUBPARTITIONS 2 ( + PARTITION p0 VALUES LESS THAN (1990), + PARTITION p1 VALUES LESS THAN (2000), + PARTITION p2 VALUES LESS THAN MAXVALUE + ); +--error ER_BAD_TABLE_ERROR +drop table t1; + +# Create a table without partitions to test "EXPLAIN PARTITIONS" +create table t1 (a varchar(10) charset latin1 collate latin1_bin); +insert into t1 values (''),(' '),('a'),('a '),('a '); +explain partitions select * from t1 where a='a ' OR a='a'; +drop table t1; diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test index ad051503fd6..baa1603faab 100644 --- a/mysql-test/t/openssl_1.test +++ b/mysql-test/t/openssl_1.test @@ -1,7 +1,7 @@ # Tests for SSL connections, only run if mysqld is compiled # with support for SSL. --- source include/have_ssl.inc +--source include/have_ssl.inc # Save the initial number of concurrent sessions --source include/count_sessions.inc @@ -109,7 +109,7 @@ drop table t1; # - Apparently selecting a cipher doesn't work at all # - Usa a cipher that both yaSSL and OpenSSL supports # ---exec echo "SHOW STATUS LIKE 'Ssl_cipher';" > $MYSQLTEST_VARDIR/tmp/test.sql +--exec echo "SHOW STATUS LIKE 'Ssl_cipher'; exit;" > $MYSQLTEST_VARDIR/tmp/test.sql --exec $MYSQL_TEST --ssl-cipher=DHE-RSA-AES256-SHA < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 # @@ -120,23 +120,61 @@ drop table t1; # and ca path to NULL # --exec $MYSQL --ssl --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem -e "SHOW STATUS LIKE 'ssl_Cipher'" 2>&1 +--echo End of 5.0 tests +# +# Bug#26174 Server Crash: INSERT ... SELECT ... FROM I_S.GLOBAL_STATUS in +# Event (see also information_schema.test for the other part of test for +# this bug). +# +--disable_warnings +DROP TABLE IF EXISTS thread_status; +DROP EVENT IF EXISTS event_status; +--enable_warnings + +SET GLOBAL event_scheduler=1; + +DELIMITER $$; + +CREATE EVENT event_status + ON SCHEDULE AT NOW() + ON COMPLETION NOT PRESERVE + DO +BEGIN + CREATE TABLE thread_status + SELECT variable_name, variable_value + FROM information_schema.session_status + WHERE variable_name LIKE 'SSL_ACCEPTS' OR + variable_name LIKE 'SSL_CALLBACK_CACHE_HITS'; +END$$ + +DELIMITER ;$$ + +let $wait_condition=select count(*) = 0 from information_schema.events where event_name='event_status'; +--source include/wait_condition.inc + +# The actual value doesn't matter and can vary based on test ordering and on ssl library. +--replace_column 2 # +SELECT variable_name, variable_value FROM thread_status; + +DROP TABLE thread_status; +SET GLOBAL event_scheduler=0; # # Test to connect using a list of ciphers # ---exec echo "SHOW STATUS LIKE 'Ssl_cipher';" > $MYSQLTEST_VARDIR/tmp/test.sql +--exec echo "SHOW STATUS LIKE 'Ssl_cipher'; exit;" > $MYSQLTEST_VARDIR/tmp/test.sql --exec $MYSQL_TEST --ssl-cipher=UNKNOWN-CIPHER:AES128-SHA < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 # Test to connect using a specifi cipher # ---exec echo "SHOW STATUS LIKE 'Ssl_cipher';" > $MYSQLTEST_VARDIR/tmp/test.sql +--exec echo "SHOW STATUS LIKE 'Ssl_cipher'; exit;" > $MYSQLTEST_VARDIR/tmp/test.sql --exec $MYSQL_TEST --ssl-cipher=AES128-SHA < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 # Test to connect using an unknown cipher # ---exec echo "SHOW STATUS LIKE 'Ssl_cipher';" > $MYSQLTEST_VARDIR/tmp/test.sql +--exec echo "SHOW STATUS LIKE 'Ssl_cipher'; exit" > $MYSQLTEST_VARDIR/tmp/test.sql --error 1 --exec $MYSQL_TEST --ssl-cipher=UNKNOWN-CIPHER < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 @@ -162,5 +200,57 @@ INSERT INTO t1 VALUES (1), (2); DROP TABLE t1; --remove_file $MYSQLTEST_VARDIR/tmp/test.sql +# +# Bug#39172 Asking for DH+non-RSA key with server set to use other key caused +# YaSSL to crash the server. +# + +# Common ciphers to openssl and yassl +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=DHE-RSA-AES256-SHA +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=EDH-RSA-DES-CBC3-SHA +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=EDH-RSA-DES-CBC-SHA +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl_cipher';" --ssl-cipher=RC4-SHA +--disable_query_log +--disable_result_log + +# Below here caused crashes. ################ +--error 1,0 +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl-cipher';" --ssl-cipher=NOT----EXIST +# These probably exist but the server's keys can't be used to accept these kinds of connections. +--error 1,0 +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl-cipher';" --ssl-cipher=DHE-DSS-AES128-RMD +--error 1,0 +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl-cipher';" --ssl-cipher=DHE-DSS-AES128-SHA +--error 1,0 +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl-cipher';" --ssl-cipher=DHE-DSS-AES256-RMD +--error 1,0 +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl-cipher';" --ssl-cipher=DHE-DSS-AES256-SHA +--error 1,0 +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl-cipher';" --ssl-cipher=DHE-DSS-DES-CBC3-RMD +--error 1,0 +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl-cipher';" --ssl-cipher=EDH-DSS-DES-CBC3-SHA +--error 1,0 +--exec $MYSQL --host=localhost -e "SHOW STATUS LIKE 'Ssl-cipher';" --ssl-cipher=EDH-DSS-DES-CBC-SHA +# End of crashers. ########################## + +# If this gives a result, then the bug is fixed. +--enable_result_log +--enable_query_log +select 'is still running; no cipher request crashed the server' as result from dual; + +# +# Bug#42158: leak: SSL_get_peer_certificate() doesn't have matching X509_free() +# + +GRANT SELECT ON test.* TO bug42158@localhost REQUIRE X509; +FLUSH PRIVILEGES; +connect(con1,localhost,bug42158,,,,,SSL); +SHOW STATUS LIKE 'Ssl_cipher'; +disconnect con1; +connection default; +DROP USER bug42158@localhost; + +--echo End of 5.1 tests + # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 6d7ee1c1ca7..ac2bbaaeeac 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -727,6 +727,115 @@ SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC; DROP TABLE t1; +# +# BUG#16590: Optimized does not do right "const" table pre-read +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE KEY b (b)); +INSERT INTO t1 VALUES (1,1),(2,2); + +CREATE TABLE t2 (a INT, b INT, KEY a (a,b)); +INSERT INTO t2 VALUES (1,1),(1,2),(2,1),(2,2); + +EXPLAIN SELECT 1 FROM t1,t2 WHERE t1.b=2 AND t1.a=t2.a ORDER BY t2.b; + +DROP TABLE t1,t2; + +# End of 5.0 + +# +# Bug #28404: query with ORDER BY and ref access +# + +CREATE TABLE t1( + id int auto_increment PRIMARY KEY, c2 int, c3 int, INDEX k2(c2), INDEX k3(c3)); + +INSERT INTO t1 (c2,c3) VALUES + (31,34),(35,38),(34,31),(32,35),(31,39), + (11,14),(15,18),(14,11),(12,15),(11,19); + +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1; +UPDATE t1 SET c2=20 WHERE id%100 = 0; +SELECT COUNT(*) FROM t1; + +CREATE TABLE t2 LIKE t1; +INSERT INTO t2 SELECT * FROM t1 ORDER BY id; + +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; +EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 4000; +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20; +EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; + +SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; + +DROP TABLE t1,t2; + +# +# Bug #30665: Inconsistent optimization of IGNORE INDEX FOR {ORDER BY|GROUP BY} +# +CREATE TABLE t1 ( + a INT, + b INT, + PRIMARY KEY (a), + KEY ab(a, b) +); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4); +INSERT INTO t1 SELECT a + 4, b + 4 FROM t1; +INSERT INTO t1 SELECT a + 8, b + 8 FROM t1; +INSERT INTO t1 SELECT a +16, b +16 FROM t1; +INSERT INTO t1 SELECT a +32, b +32 FROM t1; +INSERT INTO t1 SELECT a +64, b +64 FROM t1; + +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_before = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; + +# this query creates one temporary table in itself, which we are not +# interested in. + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_after = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT @tmp_tables_after = @tmp_tables_before ; + +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a; + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_before = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a; + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_after = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT @tmp_tables_after = @tmp_tables_before; + +DROP TABLE t1; --echo # --echo # Bug#31590: Wrong error message on sort buffer being too small. --echo # @@ -756,3 +865,572 @@ SELECT FROM t3; DROP TABLE t1, t2, t3; + + +# +# Bug #35206: select query result different if the key is indexed or not +# + +CREATE TABLE t2 (a varchar(32), b int(11), c float, d double, + UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c)); + +CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b)); +CREATE TABLE t3 (a varchar(32), b char(3), UNIQUE KEY a (a,b)); + +--disable_query_log +INSERT INTO t1 (a, b) VALUES +('domestic', 'CH'), ('domestic', 'LI'), ('plfcz1', 'FR'), ('all', 'AD'), +('all', 'AE'), ('all', 'AF'), ('all', 'AG'), ('all', 'AI'), ('all', 'AL'), +('all', 'AM'), ('all', 'AN'), ('all', 'AO'), ('all', 'AP'), ('all', 'AQ'), +('all', 'AR'), ('all', 'AS'), ('all', 'AT'), ('all', 'AU'), ('all', 'AW'), +('all', 'AZ'), ('all', 'BA'), ('all', 'BB'), ('all', 'BD'), ('all', 'BE'), +('all', 'BF'), ('all', 'BG'), ('all', 'BH'), ('all', 'BI'), ('all', 'BJ'), +('all', 'BM'), ('all', 'BN'), ('all', 'BO'), ('all', 'BR'), ('all', 'BS'), +('all', 'BT'), ('all', 'BV'), ('all', 'BW'), ('all', 'BY'), ('all', 'BZ'), +('all', 'CA'), ('all', 'CC'), ('all', 'CD'), ('all', 'CF'), ('all', 'CG'), +('all', 'CH'), ('all', 'CI'), ('all', 'CK'), ('all', 'CL'), ('all', 'CM'), +('all', 'CN'), ('all', 'CO'), ('all', 'CR'), ('all', 'CU'), ('all', 'CV'), +('all', 'CX'), ('all', 'CY'), ('all', 'CZ'), ('all', 'DE'), ('all', 'DJ'), +('all', 'DK'), ('all', 'DM'), ('all', 'DO'), ('all', 'DZ'), ('all', 'EC'), +('all', 'EE'), ('all', 'EG'), ('all', 'EH'), ('all', 'EI'), ('all', 'ER'), +('all', 'ES'), ('all', 'ET'), ('all', 'FI'), ('all', 'FJ'), ('all', 'FK'), +('all', 'FM'), ('all', 'FO'), ('all', 'FR'), ('all', 'FX'), ('all', 'GA'), +('all', 'GB'), ('all', 'GD'), ('all', 'GE'), ('all', 'GF'), ('all', 'GH'), +('all', 'GI'), ('all', 'GL'), ('all', 'GM'), ('all', 'GN'), ('all', 'GP'), +('all', 'GQ'), ('all', 'GR'), ('all', 'GS'), ('all', 'GT'), ('all', 'GU'), +('all', 'GW'), ('all', 'GY'), ('all', 'HK'), ('all', 'HM'), ('all', 'HN'), +( 'all', 'HR'), ( 'all', 'HT'), ( 'all', 'HU'), ( 'all', 'ID'), ( 'all', 'IE'), +( 'all', 'IL'), ( 'all', 'IN'), ( 'all', 'IO'), ( 'all', 'IQ'), ( 'all', 'IR'), +( 'all', 'IS'), ( 'all', 'IT'), ( 'all', 'JM'), ( 'all', 'JO'), ( 'all', 'JP'), +( 'all', 'KE'), ( 'all', 'KG'), ( 'all', 'KH'), ( 'all', 'KI'), ( 'all', 'KM'), +( 'all', 'KN'), ( 'all', 'KP'), ( 'all', 'KR'), ( 'all', 'KW'), ( 'all', 'KY'), +( 'all', 'KZ'), ( 'all', 'LA'), ( 'all', 'LB'), ( 'all', 'LC'), ( 'all', 'LI'), +( 'all', 'LK'), ( 'all', 'LR'), ( 'all', 'LS'), ( 'all', 'LT'), ( 'all', 'LU'), +( 'all', 'LV'), ( 'all', 'LY'), ( 'all', 'MA'), ( 'all', 'MC'), ( 'all', 'MD'), +( 'all', 'ME'), ( 'all', 'MG'), ( 'all', 'MH'), ( 'all', 'MK'), ( 'all', 'ML'), +( 'all', 'MM'), ( 'all', 'MN'), ( 'all', 'MO'), ( 'all', 'MP'), ( 'all', 'MQ'), +( 'all', 'MR'), ( 'all', 'MS'), ( 'all', 'MT'), ( 'all', 'MU'), ( 'all', 'MV'), +( 'all', 'MW'), ( 'all', 'MX'), ( 'all', 'MY'), ( 'all', 'MZ'), ( 'all', 'NA'), +( 'all', 'NC'), ( 'all', 'NE'), ( 'all', 'NF'), ( 'all', 'NG'), ( 'all', 'NI'), +( 'all', 'NL'), ( 'all', 'NO'), ( 'all', 'NP'), ( 'all', 'NR'), ( 'all', 'NU'), +( 'all', 'NV'), ( 'all', 'NZ'), ( 'all', 'OM'), ( 'all', 'PA'), ( 'all', 'PE'), +( 'all', 'PF'), ( 'all', 'PG'), ( 'all', 'PH'), ( 'all', 'PK'), ( 'all', 'PL'), +( 'all', 'PM'), ( 'all', 'PN'), ( 'all', 'PR'), ( 'all', 'PS'), ( 'all', 'PT'), +( 'all', 'PW'), ( 'all', 'PY'), ( 'all', 'QA'), ( 'all', 'RE'), ( 'all', 'RO'), +( 'all', 'RU'), ( 'all', 'RW'), ( 'all', 'SA'), ( 'all', 'SB'), ( 'all', 'SC'), +( 'all', 'SD'), ( 'all', 'SE'), ( 'all', 'SG'), ( 'all', 'SH'), ( 'all', 'SI'), +( 'all', 'SJ'), ( 'all', 'SK'), ( 'all', 'SL'), ( 'all', 'SM'), ( 'all', 'SN'), +( 'all', 'SO'), ( 'all', 'SR'), ( 'all', 'ST'), ( 'all', 'SV'), ( 'all', 'SY'), +( 'all', 'SZ'), ( 'all', 'TA'), ( 'all', 'TC'), ( 'all', 'TD'), ( 'all', 'TF'), +( 'all', 'TG'), ( 'all', 'TH'), ( 'all', 'TJ'), ( 'all', 'TK'), ( 'all', 'TM'), +( 'all', 'TN'), ( 'all', 'TO'), ( 'all', 'TP'), ( 'all', 'TR'), ( 'all', 'TT'), +( 'all', 'TV'), ( 'all', 'TW'), ( 'all', 'TZ'), ( 'all', 'UA'), ( 'all', 'UG'), +( 'all', 'UM'), ( 'all', 'US'), ( 'all', 'UY'), ( 'all', 'UZ'), ( 'all', 'VA'), +( 'all', 'VC'), ( 'all', 'VE'), ( 'all', 'VG'), ( 'all', 'VI'), ( 'all', 'VN'), +( 'all', 'VU'), ( 'all', 'WF'), ( 'all', 'WS'), ( 'plfcz1', 'FI'), +( 'all', 'XE'), ( 'all', 'XS'), ( 'all', 'XU'), ( 'plfcz1', 'XE'), +( 'all', 'YE'), ( 'all', 'YT'), ( 'all', 'YU'), ( 'all', 'ZA'), ( 'all', 'ZM'), +( 'all', 'ZR'), ( 'all', 'ZW'), ( 'foreign', 'AD'), ( 'foreign', 'AE'), +( 'foreign', 'AF'), ( 'foreign', 'AG'), ( 'foreign', 'AI'), +( 'foreign', 'AL'), ( 'foreign', 'AM'), ( 'foreign', 'AN'), ( 'foreign', 'AO'), +( 'foreign', 'AP'), ( 'foreign', 'AQ'), ( 'foreign', 'AR'), ( 'foreign', 'AS'), +( 'foreign', 'AT'), ( 'foreign', 'AU'), ( 'foreign', 'AW'), ( 'foreign', 'AZ'), +( 'foreign', 'BA'), ( 'foreign', 'BB'), ( 'foreign', 'BD'), ( 'foreign', 'BE'), +( 'foreign', 'BF'), ( 'foreign', 'BG'), ( 'foreign', 'BH'), ( 'foreign', 'BI'), +( 'foreign', 'BJ'), ( 'foreign', 'BM'), ( 'foreign', 'BN'), ( 'foreign', 'BO'), +( 'foreign', 'BR'), ( 'foreign', 'BS'), ( 'foreign', 'BT'), ( 'foreign', 'BV'), +( 'foreign', 'BW'), ( 'foreign', 'BY'), ( 'foreign', 'BZ'), ( 'foreign', 'CA'), +( 'foreign', 'CC'), ( 'foreign', 'CD'), ( 'foreign', 'CF'), ( 'foreign', 'CG'), +( 'foreign', 'CI'), ( 'foreign', 'CK'), ( 'foreign', 'CL'), ( 'foreign', 'CM'), +( 'foreign', 'CN'), ( 'foreign', 'CO'), ( 'foreign', 'CR'), ( 'foreign', 'CU'), +( 'foreign', 'CV'), ( 'foreign', 'CX'), ( 'foreign', 'CY'), ( 'foreign', 'CZ'), +( 'foreign', 'DE'), ( 'foreign', 'DJ'), ( 'foreign', 'DK'), ( 'foreign', 'DM'), +( 'foreign', 'DO'), ( 'foreign', 'DZ'), ( 'foreign', 'EC'), ( 'foreign', 'EE'), +( 'foreign', 'EG'), ( 'foreign', 'EH'), ( 'foreign', 'EI'), ( 'foreign', 'ER'), +( 'foreign', 'ES'), ( 'foreign', 'ET'), ( 'foreign', 'FI'), ( 'foreign', 'FJ'), +( 'foreign', 'FK'), ( 'foreign', 'FM'), ( 'foreign', 'FO'), ( 'foreign', 'FR'), +( 'foreign', 'FX'), ( 'foreign', 'GA'), ( 'foreign', 'GB'), ( 'foreign', 'GD'), +( 'foreign', 'GE'), ( 'foreign', 'GF'), ( 'foreign', 'GH'), ( 'foreign', 'GI'), +( 'foreign', 'GL'), ( 'foreign', 'GM'), ( 'foreign', 'GN'), ( 'foreign', 'GP'), +( 'foreign', 'GQ'), ( 'foreign', 'GR'), ( 'foreign', 'GS'), ( 'foreign', 'GT'), +( 'foreign', 'GU'), ( 'foreign', 'GW'), ( 'foreign', 'GY'), ( 'foreign', 'HK'), +( 'foreign', 'HM'), ( 'foreign', 'HN'), ( 'foreign', 'HR'), ( 'foreign', 'HT'), +( 'foreign', 'HU'), ( 'foreign', 'ID'), ( 'foreign', 'IE'), ( 'foreign', 'IL'), +( 'foreign', 'IN'), ( 'foreign', 'IO'), ( 'foreign', 'IQ'), ( 'foreign', 'IR'), +( 'foreign', 'IS'), ( 'foreign', 'IT'), ( 'foreign', 'JM'), ( 'foreign', 'JO'), +( 'foreign', 'JP'), ( 'foreign', 'KE'), ( 'foreign', 'KG'), ( 'foreign', 'KH'), +( 'foreign', 'KI'), ( 'foreign', 'KM'), ( 'foreign', 'KN'), ( 'foreign', 'KP'), +( 'foreign', 'KR'), ( 'foreign', 'KW'), ( 'foreign', 'KY'), ( 'foreign', 'KZ'), +( 'foreign', 'LA'), ( 'foreign', 'LB'), ( 'foreign', 'LC'), ( 'foreign', 'LK'), +( 'foreign', 'LR'), ( 'foreign', 'LS'), ( 'foreign', 'LT'), ( 'foreign', 'LU'), +( 'foreign', 'LV'), ( 'foreign', 'LY'), ( 'foreign', 'MA'), ( 'foreign', 'MC'), +( 'foreign', 'MD'), ( 'foreign', 'ME'), ( 'foreign', 'MG'), ( 'foreign', 'MH'), +( 'foreign', 'MK'), ( 'foreign', 'ML'), ( 'foreign', 'MM'), ( 'foreign', 'MN'), +( 'foreign', 'MO'), ( 'foreign', 'MP'), ( 'foreign', 'MQ'), ( 'foreign', 'MR'), +( 'foreign', 'MS'), ( 'foreign', 'MT'), ( 'foreign', 'MU'), ( 'foreign', 'MV'), +( 'foreign', 'MW'), ( 'foreign', 'MX'), ( 'foreign', 'MY'), ( 'foreign', 'MZ'), +( 'foreign', 'NA'), ( 'foreign', 'NC'), ( 'foreign', 'NE'), ( 'foreign', 'NF'), +( 'foreign', 'NG'), ( 'foreign', 'NI'), ( 'foreign', 'NL'), ( 'foreign', 'NO'), +( 'foreign', 'NP'), ( 'foreign', 'NR'), ( 'foreign', 'NU'), ( 'foreign', 'NV'), +( 'foreign', 'NZ'), ( 'foreign', 'OM'), ( 'foreign', 'PA'), ( 'foreign', 'PE'), +( 'foreign', 'PF'), ( 'foreign', 'PG'), ( 'foreign', 'PH'), ( 'foreign', 'PK'), +( 'foreign', 'PL'), ( 'foreign', 'PM'), ( 'foreign', 'PN'), ( 'foreign', 'PR'), +( 'foreign', 'PS'), ( 'foreign', 'PT'), ( 'foreign', 'PW'), ( 'foreign', 'PY'), +( 'foreign', 'QA'), ( 'foreign', 'RE'), ( 'foreign', 'RO'), ( 'foreign', 'RU'), +( 'foreign', 'RW'), ( 'foreign', 'SA'), ( 'foreign', 'SB'), ( 'foreign', 'SC'), +( 'foreign', 'SD'), ( 'foreign', 'SE'), ( 'foreign', 'SG'), ( 'foreign', 'SH'), +( 'foreign', 'SI'), ( 'foreign', 'SJ'), ( 'foreign', 'SK'), ( 'foreign', 'SL'), +( 'foreign', 'SM'), ( 'foreign', 'SN'), ( 'foreign', 'SO'), ( 'foreign', 'SR'), +( 'foreign', 'ST'), ( 'foreign', 'SV'), ( 'foreign', 'SY'), ( 'foreign', 'SZ'), +( 'foreign', 'TA'), ( 'foreign', 'TC'), ( 'foreign', 'TD'), ( 'foreign', 'TF'), +( 'foreign', 'TG'), ( 'foreign', 'TH'), ( 'foreign', 'TJ'), ( 'foreign', 'TK'), +( 'foreign', 'TM'), ( 'foreign', 'TN'), ( 'foreign', 'TO'), ( 'foreign', 'TP'), +( 'foreign', 'TR'), ( 'foreign', 'TT'), ( 'foreign', 'TV'), ( 'foreign', 'TW'), +( 'foreign', 'TZ'), ( 'foreign', 'UA'), ( 'foreign', 'UG'), ( 'foreign', 'UM'), +( 'foreign', 'US'), ( 'foreign', 'UY'), ( 'foreign', 'UZ'), ( 'foreign', 'VA'), +( 'foreign', 'VC'), ( 'foreign', 'VE'), ( 'foreign', 'VG'), ( 'foreign', 'VI'), +( 'foreign', 'VN'), ( 'foreign', 'VU'), ( 'foreign', 'WF'), ( 'foreign', 'WS'), +( 'plfcz1', 'DK'), ( 'foreign', 'XE'), ( 'foreign', 'XS'), ( 'foreign', 'XU'), +( 'plfcz1', 'BE'), ( 'foreign', 'YE'), ( 'foreign', 'YT'), ( 'foreign', 'YU'), +( 'foreign', 'ZA'), ( 'foreign', 'ZM'), ( 'foreign', 'ZR'), ( 'foreign', 'ZW'), +( 'plfcz1', 'DE'), ( 'plfcz1', 'GI'), ( 'plfcz1', 'GR'), ( 'plfcz1', 'IS'), +( 'plfcz1', 'EI'), ( 'plfcz1', 'IT'), ( 'plfcz1', 'LU'), ( 'plfcz1', 'NL'), +( 'plfcz1', 'NO'), ( 'plfcz1', 'ES'), ( 'plfcz1', 'SE'), ( 'plfcz1', 'AL'), +( 'plfcz1', 'AD'), ( 'plfcz1', 'BY'), ( 'plfcz1', 'BA'), ( 'plfcz1', 'BG'), +( 'plfcz1', 'EE'), ( 'plfcz1', 'FO'), ( 'plfcz1', 'GL'), ( 'plfcz1', 'GB'), +( 'plfcz1', 'HR'), ( 'plfcz1', 'LV'), ( 'plfcz1', 'LT'), ( 'plfcz1', 'MT'), +( 'plfcz1', 'MK'), ( 'plfcz1', 'MD'), ( 'plfcz1', 'MC'), ( 'plfcz1', 'AT'), +( 'plfcz1', 'PL'), ( 'plfcz1', 'PT'), ( 'plfcz1', 'RO'), ( 'plfcz1', 'RU'), +( 'plfcz1', 'SM'), ( 'plfcz1', 'XS'), ( 'plfcz1', 'SK'), ( 'plfcz1', 'SI'), +( 'plfcz1', 'CZ'), ( 'plfcz1', 'TR'), ( 'plfcz1', 'UA'), ( 'plfcz1', 'HU'), +( 'plfcz1', 'VA'), ( 'plfcz1', 'CY'), ( 'plfcz2', 'AF'), ( 'plfcz2', 'DZ'), +( 'plfcz2', 'AS'), ( 'plfcz2', 'AO'), ( 'plfcz2', 'AI'), ( 'plfcz2', 'AQ'), +( 'plfcz2', 'AG'), ( 'plfcz2', 'AR'), ( 'plfcz2', 'AM'), ( 'plfcz2', 'AW'), +( 'plfcz2', 'AU'), ( 'plfcz2', 'AZ'), ( 'plfcz2', 'AP'), ( 'plfcz2', 'BS'), +( 'plfcz2', 'BH'), ( 'plfcz2', 'BD'), ( 'plfcz2', 'BB'), ( 'plfcz2', 'BZ'), +( 'plfcz2', 'BJ'), ( 'plfcz2', 'BM'), ( 'plfcz2', 'BT'), ( 'plfcz2', 'BO'), +( 'plfcz2', 'BW'), ( 'plfcz2', 'BV'), ( 'plfcz2', 'BR'), ( 'plfcz2', 'IO'), +( 'plfcz2', 'VG'), ( 'plfcz2', 'BN'), ( 'plfcz2', 'BF'), ( 'plfcz2', 'BI'), +( 'plfcz2', 'KH'), ( 'plfcz2', 'CM'), ( 'plfcz2', 'CA'), ( 'plfcz2', 'CV'), +( 'plfcz2', 'KY'), ( 'plfcz2', 'CF'), ( 'plfcz2', 'TD'), ( 'plfcz2', 'CL'), +( 'plfcz2', 'CN'), ( 'plfcz2', 'CX'), ( 'plfcz2', 'CC'), ( 'plfcz2', 'CO'), +( 'plfcz2', 'KM'), ( 'plfcz2', 'CG'), ( 'plfcz2', 'CD'), ( 'plfcz2', 'CK'), +( 'plfcz2', 'CR'), ( 'plfcz2', 'CI'), ( 'plfcz2', 'CU'), ( 'plfcz2', 'DJ'), +( 'plfcz2', 'DM'), ( 'plfcz2', 'DO'), ( 'plfcz2', 'TP'), ( 'plfcz2', 'EC'), +( 'plfcz2', 'EG'), ( 'plfcz2', 'SV'), ( 'plfcz2', 'GQ'), ( 'plfcz2', 'ER'), +( 'plfcz2', 'ET'), ( 'plfcz2', 'FK'), ( 'plfcz2', 'FJ'), ( 'plfcz2', 'FX'), +( 'plfcz2', 'GF'), ( 'plfcz2', 'PF'), ( 'plfcz2', 'TA'), ( 'plfcz2', 'TF'), +( 'plfcz2', 'GA'), ( 'plfcz2', 'GM'), ( 'plfcz2', 'GE'), ( 'plfcz2', 'GH'), +( 'plfcz2', 'GD'), ( 'plfcz2', 'GP'), ( 'plfcz2', 'GU'), ( 'plfcz2', 'GT'), +( 'plfcz2', 'GN'), ( 'plfcz2', 'GW'), ( 'plfcz2', 'GY'), ( 'plfcz2', 'HT'), +( 'plfcz2', 'HM'), ( 'plfcz2', 'HN'), ( 'plfcz2', 'HK'), ( 'plfcz2', 'IN'), +( 'plfcz2', 'ID'), ( 'plfcz2', 'IR'), ( 'plfcz2', 'IQ'), ( 'plfcz2', 'IE'), +( 'plfcz2', 'IL'), ( 'plfcz2', 'JM'), ( 'plfcz2', 'JP'), ( 'plfcz2', 'JO'), +( 'plfcz2', 'KZ'), ( 'plfcz2', 'KE'), ( 'plfcz2', 'KI'), ( 'plfcz2', 'KP'), +( 'plfcz2', 'KW'), ( 'plfcz2', 'KG'), ( 'plfcz2', 'LA'), ( 'plfcz2', 'LB'), +( 'plfcz2', 'LS'), ( 'plfcz2', 'LR'), ( 'plfcz2', 'LY'), ( 'plfcz2', 'MO'), +( 'plfcz2', 'MG'), ( 'plfcz2', 'ME'), ( 'plfcz2', 'MW'), ( 'plfcz2', 'MY'), +( 'plfcz2', 'MV'), ( 'plfcz2', 'ML'), ( 'plfcz2', 'MH'), ( 'plfcz2', 'MQ'), +( 'plfcz2', 'MR'), ( 'plfcz2', 'MU'), ( 'plfcz2', 'YT'), ( 'plfcz2', 'MX'), +( 'plfcz2', 'FM'), ( 'plfcz2', 'MN'), ( 'plfcz2', 'MS'), ( 'plfcz2', 'MA'), +( 'plfcz2', 'MZ'), ( 'plfcz2', 'MM'), ( 'plfcz2', 'NA'), ( 'plfcz2', 'NR'), +( 'plfcz2', 'NP'), ( 'plfcz2', 'AN'), ( 'plfcz2', 'NC'), ( 'plfcz2', 'NZ'), +( 'plfcz2', 'NI'), ( 'plfcz2', 'NE'), ( 'plfcz2', 'NG'), ( 'plfcz2', 'NU'), +( 'plfcz2', 'NF'), ( 'plfcz2', 'MP'), ( 'plfcz2', 'OM'), ( 'plfcz2', 'PK'), +( 'plfcz2', 'PW'), ( 'plfcz2', 'PS'), ( 'plfcz2', 'PA'), ( 'plfcz2', 'PG'), +( 'plfcz2', 'PY'), ( 'plfcz2', 'PE'), ( 'plfcz2', 'PH'), ( 'plfcz2', 'PN'), +( 'plfcz2', 'PR'), ( 'plfcz2', 'QA'), ( 'plfcz2', 'RE'), ( 'plfcz2', 'RW'), +( 'plfcz2', 'KN'), ( 'plfcz2', 'ST'), ( 'plfcz2', 'SA'), ( 'plfcz2', 'SN'), +( 'plfcz2', 'SC'), ( 'plfcz2', 'SL'), ( 'plfcz2', 'SG'), ( 'plfcz2', 'SB'), +( 'plfcz2', 'SO'), ( 'plfcz2', 'ZA'), ( 'plfcz2', 'GS'), ( 'plfcz2', 'KR'), +( 'plfcz2', 'LK'), ( 'plfcz2', 'NV'), ( 'plfcz2', 'SH'), ( 'plfcz2', 'LC'), +( 'plfcz2', 'PM'), ( 'plfcz2', 'VC'), ( 'plfcz2', 'SD'), ( 'plfcz2', 'SR'), +( 'plfcz2', 'SJ'), ( 'plfcz2', 'SZ'), ( 'plfcz2', 'SY'), ( 'plfcz2', 'TW'), +( 'plfcz2', 'TJ'), ( 'plfcz2', 'TZ'), ( 'plfcz2', 'TH'), ( 'plfcz2', 'TG'), +( 'plfcz2', 'TK'), ( 'plfcz2', 'TO'), ( 'plfcz2', 'TT'), ( 'plfcz2', 'XU'), +( 'plfcz2', 'TN'), ( 'plfcz2', 'TM'), ( 'plfcz2', 'TC'), ( 'plfcz2', 'TV'), +( 'plfcz2', 'UG'), ( 'plfcz2', 'AE'), ( 'plfcz2', 'US'), ( 'plfcz2', 'UM'), +( 'plfcz2', 'UY'), ( 'plfcz2', 'UZ'), ( 'plfcz2', 'VU'), ( 'plfcz2', 'VE'), +( 'plfcz2', 'VN'), ( 'plfcz2', 'VI'), ( 'plfcz2', 'WF'), ( 'plfcz2', 'EH'), +( 'plfcz2', 'WS'), ( 'plfcz2', 'YE'), ( 'plfcz2', 'YU'), ( 'plfcz2', 'ZR'), +( 'plfcz2', 'ZM'), ( 'plfcz2', 'ZW'), ( 'ppfcz1', 'AT'), ( 'ppfcz1', 'BE'), +( 'ppfcz1', 'DE'), ( 'ppfcz1', 'FR'), ( 'ppfcz1', 'FX'), ( 'ppfcz1', 'IT'), +( 'ppfcz1', 'LU'), ( 'ppfcz1', 'MC'), ( 'ppfcz1', 'NL'), ( 'ppfcz1', 'SM'), +( 'ppfcz1', 'VA'), ( 'ppfcz1', 'XE'), ( 'ppfcz2', 'AD'), ( 'ppfcz2', 'AL'), +( 'ppfcz2', 'BA'), ( 'ppfcz2', 'BG'), ( 'ppfcz2', 'BY'), ( 'ppfcz2', 'CY'), +( 'ppfcz2', 'CZ'), ( 'ppfcz2', 'DK'), ( 'ppfcz2', 'EE'), ( 'ppfcz2', 'EI'), +( 'ppfcz2', 'ES'), ( 'ppfcz2', 'FI'), ( 'ppfcz2', 'FO'), ( 'ppfcz2', 'GB'), +( 'ppfcz2', 'GI'), ( 'ppfcz2', 'GL'), ( 'ppfcz2', 'GR'), ( 'ppfcz2', 'HR'), +( 'ppfcz2', 'HU'), ( 'ppfcz2', 'IE'), ( 'ppfcz2', 'IS'), ( 'ppfcz2', 'LT'), +( 'ppfcz2', 'LV'), ( 'ppfcz2', 'MD'), ( 'ppfcz2', 'MK'), ( 'ppfcz2', 'MT'), +( 'ppfcz2', 'NO'), ( 'ppfcz2', 'PL'), ( 'ppfcz2', 'PT'), ( 'ppfcz2', 'RO'), +( 'ppfcz2', 'RU'), ( 'ppfcz2', 'SE'), ( 'ppfcz2', 'SI'), ( 'ppfcz2', 'SK'), +( 'ppfcz2', 'TR'), ( 'ppfcz2', 'UA'), ( 'ppfcz2', 'XS'), ( 'ppfcz2', 'YU'), +( 'ppfcz3', 'CA'), ( 'ppfcz3', 'DZ'), ( 'ppfcz3', 'EG'), ( 'ppfcz3', 'IL'), +( 'ppfcz3', 'JO'), ( 'ppfcz3', 'LB'), ( 'ppfcz3', 'LY'), ( 'ppfcz3', 'MA'), +( 'ppfcz3', 'MX'), ( 'ppfcz3', 'PM'), ( 'ppfcz3', 'SY'), ( 'ppfcz3', 'TN'), +( 'ppfcz3', 'US'), ( 'ppfcz4', 'AE'), ( 'ppfcz4', 'AF'), ( 'ppfcz4', 'AM'), +( 'ppfcz4', 'AO'), ( 'ppfcz4', 'AZ'), ( 'ppfcz4', 'BD'), ( 'ppfcz4', 'BF'), +( 'ppfcz4', 'BH'), ( 'ppfcz4', 'BI'), ( 'ppfcz4', 'BJ'), ( 'ppfcz4', 'BT'), +( 'ppfcz4', 'BV'), ( 'ppfcz4', 'BW'), ( 'ppfcz4', 'CF'), ( 'ppfcz4', 'CG'), +( 'ppfcz4', 'CI'), ( 'ppfcz4', 'CM'), ( 'ppfcz4', 'CN'), ( 'ppfcz4', 'DJ'), +( 'ppfcz4', 'DO'), ( 'ppfcz4', 'ER'), ( 'ppfcz4', 'ET'), ( 'ppfcz4', 'GA'), +( 'ppfcz4', 'GE'), ( 'ppfcz4', 'GH'), ( 'ppfcz4', 'GM'), ( 'ppfcz4', 'GN'), +( 'ppfcz4', 'GQ'), ( 'ppfcz4', 'GW'), ( 'ppfcz4', 'HK'), ( 'ppfcz4', 'IN'), +( 'ppfcz4', 'IQ'), ( 'ppfcz4', 'IR'), ( 'ppfcz4', 'JP'), ( 'ppfcz4', 'KE'), +( 'ppfcz4', 'KG'), ( 'ppfcz4', 'KH'), ( 'ppfcz4', 'KP'), ( 'ppfcz4', 'KW'), +( 'ppfcz4', 'KZ'), ( 'ppfcz4', 'LA'), ( 'ppfcz4', 'LK'), ( 'ppfcz4', 'LR'), +( 'ppfcz4', 'LS'), ( 'ppfcz4', 'MG'), ( 'ppfcz4', 'ML'), ( 'ppfcz4', 'MM'), +( 'ppfcz4', 'MN'), ( 'ppfcz4', 'MO'), ( 'ppfcz4', 'MR'), ( 'ppfcz4', 'MU'), +( 'ppfcz4', 'MV'), ( 'ppfcz4', 'MW'), ( 'ppfcz4', 'MY'), ( 'ppfcz4', 'MZ'), +( 'ppfcz4', 'NA'), ( 'ppfcz4', 'NE'), ( 'ppfcz4', 'NG'), ( 'ppfcz4', 'NP'), +( 'ppfcz4', 'OM'), ( 'ppfcz4', 'PK'), ( 'ppfcz4', 'QA'), ( 'ppfcz4', 'RE'), +( 'ppfcz4', 'RW'), ( 'ppfcz4', 'SA'), ( 'ppfcz4', 'SC'), ( 'ppfcz4', 'SD'), +( 'ppfcz4', 'SG'), ( 'ppfcz4', 'SH'), ( 'ppfcz4', 'SL'), ( 'ppfcz4', 'SN'), +( 'ppfcz4', 'SO'), ( 'ppfcz4', 'SZ'), ( 'ppfcz4', 'TD'), ( 'ppfcz4', 'TG'), +( 'ppfcz4', 'TH'), ( 'ppfcz4', 'TJ'), ( 'ppfcz4', 'TM'), ( 'ppfcz4', 'TW'), +( 'ppfcz4', 'TZ'), ( 'ppfcz4', 'UG'), ( 'ppfcz4', 'UZ'), ( 'ppfcz4', 'VN'), +( 'ppfcz4', 'XU'), ( 'ppfcz4', 'YT'), ( 'ppfcz4', 'ZA'), ( 'ppfcz4', 'ZW'), +( 'ppfcz5', 'AG'), ( 'ppfcz5', 'AI'), ( 'ppfcz5', 'AN'), ( 'ppfcz5', 'AP'), +( 'ppfcz5', 'AQ'), ( 'ppfcz5', 'AR'), ( 'ppfcz5', 'AS'), ( 'ppfcz5', 'AU'), +( 'ppfcz5', 'AW'), ( 'ppfcz5', 'BB'), ( 'ppfcz5', 'BM'), ( 'ppfcz5', 'BN'), +( 'ppfcz5', 'BO'), ( 'ppfcz5', 'BR'), ( 'ppfcz5', 'BS'), ( 'ppfcz5', 'BZ'), +( 'ppfcz5', 'CC'), ( 'ppfcz5', 'CD'), ( 'ppfcz5', 'CK'), ( 'ppfcz5', 'CL'), +( 'ppfcz5', 'CO'), ( 'ppfcz5', 'CR'), ( 'ppfcz5', 'CU'), ( 'ppfcz5', 'CV'), +( 'ppfcz5', 'CX'), ( 'ppfcz5', 'DM'), ( 'ppfcz5', 'EC'), ( 'ppfcz5', 'EH'), +( 'ppfcz5', 'FJ'), ( 'ppfcz5', 'FK'), ( 'ppfcz5', 'FM'), ( 'ppfcz5', 'GD'), +( 'ppfcz5', 'GF'), ( 'ppfcz5', 'GP'), ( 'ppfcz5', 'GS'), ( 'ppfcz5', 'GT'), +( 'ppfcz5', 'GU'), ( 'ppfcz5', 'GY'), ( 'ppfcz5', 'HM'), ( 'ppfcz5', 'HN'), +( 'ppfcz5', 'HT'), ( 'ppfcz5', 'ID'), ( 'ppfcz5', 'IO'), ( 'ppfcz5', 'JM'), +( 'ppfcz5', 'KI'), ( 'ppfcz5', 'KM'), ( 'ppfcz5', 'KN'), ( 'ppfcz5', 'KR'), +( 'ppfcz5', 'KY'), ( 'ppfcz5', 'LC'), ( 'ppfcz5', 'ME'), ( 'ppfcz5', 'MH'), +( 'ppfcz5', 'MP'), ( 'ppfcz5', 'MQ'), ( 'ppfcz5', 'MS'), ( 'ppfcz5', 'NC'), +( 'ppfcz5', 'NF'), ( 'ppfcz5', 'NI'), ( 'ppfcz5', 'NR'), ( 'ppfcz5', 'NU'), +( 'ppfcz5', 'NZ'), ( 'ppfcz5', 'PA'), ( 'ppfcz5', 'PE'), ( 'ppfcz5', 'PF'), +( 'ppfcz5', 'PG'), ( 'ppfcz5', 'PH'), ( 'ppfcz5', 'PN'), ( 'ppfcz5', 'PR'), +( 'ppfcz5', 'PS'), ( 'ppfcz5', 'PW'), ( 'ppfcz5', 'PY'), ( 'ppfcz5', 'SB'), +( 'ppfcz5', 'SJ'), ( 'ppfcz5', 'SR'), ( 'ppfcz5', 'ST'), ( 'ppfcz5', 'SV'), +( 'ppfcz5', 'TA'), ( 'ppfcz5', 'TC'), ( 'ppfcz5', 'TF'), ( 'ppfcz5', 'TK'), +( 'ppfcz5', 'TO'), ( 'ppfcz5', 'TP'), ( 'ppfcz5', 'TT'), ( 'ppfcz5', 'TV'), +( 'ppfcz5', 'UM'), ( 'ppfcz5', 'UY'), ( 'ppfcz5', 'VC'), ( 'ppfcz5', 'VE'), +( 'ppfcz5', 'VG'), ( 'ppfcz5', 'VI'), ( 'ppfcz5', 'VU'), ( 'ppfcz5', 'WF'), +( 'ppfcz5', 'WS'), ( 'ppfcz5', 'YE'), ( 'ppfcz5', 'ZM'), ( 'ppfcz5', 'ZR'); + +INSERT INTO t2 (a, b, c, d) VALUES +('domestic', 26, 0.25, 4.7), ('domestic', 27, 0.25, 6), +('domestic', 19, 2, 6.3), ('domestic', 19, 5, 7.77), +('domestic', 19, 10, 10.3), ('domestic', 19, 20, 14.83), +('domestic', 19, 30, 20.88), ('domestic', 20, 2, 7.3), +('domestic', 20, 5, 8.77), ('domestic', 20, 10, 11.3), +('domestic', 20, 20, 15.83), ('domestic', 20, 30, 21.88), +('domestic', 23, 2, 18.8), ('domestic', 23, 5, 20.8), +('domestic', 23, 10, 24.8), ('domestic', 23, 20, 27.8), +('domestic', 23, 30, 30.8), ('domestic', 24, 2, 21.1405), +('domestic', 24, 5, 22.3705), ('domestic', 24, 10, 25.0905), +('domestic', 24, 20, 29.7705), ('domestic', 24, 30, 35.9605), +('domestic', 17, 2, 7.2), ('domestic', 17, 5, 8.43), +('domestic', 17, 10, 11.15), ('domestic', 17, 20, 15.83), +('domestic', 17, 30, 22.02), ('domestic', 18, 2, 8.2), +('domestic', 18, 5, 9.43), ('domestic', 18, 10, 12.15), +('domestic', 18, 20, 16.83), ('domestic', 18, 30, 23.02), +('domestic', 28, 2, 17), ('domestic', 28, 5, 19), +('domestic', 28, 10, 22), ('domestic', 28, 20, 28), +('domestic', 28, 30, 35), ('domestic', 29, 30, 29.5), +('foreign', 25, 200, 0), ('domestic', 3, 100, 59), +('foreign', 10, 30, 0), ('foreign', 22, 0, 0), +('foreign', 11, 30, 0), ('foreign', 12, 30, 0), +('all', 1, 10000, 0), ('all', 2, 10000, 0), +('domestic', 9, 10000, 0), ('domestic', 4, 500, 0), +('domestic', 5, 500, 0), ('domestic', 6, 500, 0), +('domestic', 7, 500, 0), ('domestic', 8, 500, 0), +('domestic', 21, 3.9, 10.8), ('domestic', 21, 4.9, 12.2), +('domestic', 21, 9.9, 15.3), ('domestic', 21, 19.9, 20.6), +('domestic', 21, 30, 28.1), ('plfcz1', 16, 0.5, 19), +('plfcz2', 16, 0.5, 25), ( 'ppfcz2', 15, 16, 76.5), +( 'ppfcz2', 15, 15, 75.5), ( 'ppfcz2', 15, 14, 73.5), +( 'ppfcz2', 15, 13, 71.5), ( 'ppfcz2', 15, 12, 69.5), +( 'ppfcz2', 15, 11, 67.5), ( 'ppfcz2', 15, 10, 65.5), +( 'ppfcz2', 15, 9, 62.5), ( 'ppfcz2', 15, 8, 59.5), +( 'ppfcz2', 15, 7, 56.5), ( 'ppfcz2', 15, 6, 53.5), +( 'ppfcz2', 15, 5, 50.5), ( 'ppfcz2', 15, 4, 46.5), +( 'ppfcz2', 15, 3, 42.5), ( 'ppfcz2', 15, 2, 38.5), +('ppfcz1', 15, 2, 33.5), ('ppfcz1', 15, 3, 36.5), +('ppfcz1', 15, 4, 39.5), ('ppfcz1', 15, 5, 41.5), +('ppfcz1', 15, 6, 42.5), ('ppfcz1', 15, 7, 43.5), +('ppfcz1', 15, 8, 44.5), ('ppfcz1', 15, 9, 45.5), +('ppfcz1', 15, 10, 46.5), ('ppfcz1', 15, 11, 47.5), +( 'ppfcz1', 15, 12, 48.5), ( 'ppfcz1', 15, 13, 49.5), ( 'ppfcz1', 15, 14, 50.5), +( 'ppfcz1', 15, 15, 51.5), ( 'ppfcz1', 15, 16, 52.5), ( 'ppfcz1', 15, 17, 53.5), +( 'ppfcz1', 15, 18, 54.5), ( 'ppfcz1', 15, 19, 55.5), ( 'ppfcz1', 15, 20, 56.5), +( 'ppfcz1', 15, 21, 57.5), ( 'ppfcz1', 15, 22, 58.5), ( 'ppfcz1', 15, 23, 59.5), +( 'ppfcz1', 15, 24, 60.5), ( 'ppfcz1', 15, 25, 61.5), ( 'ppfcz1', 15, 26, 62.5), +( 'ppfcz1', 15, 27, 63.5), ( 'ppfcz1', 15, 28, 64.5), ( 'ppfcz1', 15, 29, 65.5), +( 'ppfcz1', 15, 30, 66.5), ( 'ppfcz2', 15, 17, 77.5), ( 'ppfcz2', 15, 18, 78.5), +( 'ppfcz2', 15, 19, 79.5), ( 'ppfcz2', 15, 20, 80.5), ( 'ppfcz2', 15, 21, 81.5), +( 'ppfcz2', 15, 22, 82.5), ( 'ppfcz2', 15, 23, 83.5), ( 'ppfcz2', 15, 24, 84.5), +( 'ppfcz2', 15, 25, 85.5), ( 'ppfcz2', 15, 26, 86.5), ( 'ppfcz2', 15, 27, 87.5), +( 'ppfcz2', 15, 28, 88.5), ( 'ppfcz2', 15, 29, 89.5), ( 'ppfcz2', 15, 30, 90.5), +( 'ppfcz3', 15, 2, 39.5), ( 'ppfcz3', 15, 3, 45.5), ( 'ppfcz3', 15, 4, 51.5), +( 'ppfcz3', 15, 5, 57.5), ( 'ppfcz3', 15, 6, 63.5), ( 'ppfcz3', 15, 7, 69.5), +( 'ppfcz3', 15, 8, 75.5), ( 'ppfcz3', 15, 9, 81.5), ( 'ppfcz3', 15, 10, 87.5), +( 'ppfcz3', 15, 11, 93.5), ( 'ppfcz3', 15, 12, 99.5), ( 'ppfcz3', 15, 13, 105.5), +( 'ppfcz3', 15, 14, 111.5), ( 'ppfcz3', 15, 15, 117.5), ( 'ppfcz3', 15, 16, 122.5), +( 'ppfcz3', 15, 17, 127.5), ( 'ppfcz3', 15, 18, 132.5), ( 'ppfcz3', 15, 19, 137.5), +( 'ppfcz3', 15, 20, 142.5), ( 'ppfcz3', 15, 21, 146.5), ( 'ppfcz3', 15, 22, 150.5), +( 'ppfcz3', 15, 23, 154.5), ( 'ppfcz3', 15, 24, 158.5), ( 'ppfcz3', 15, 25, 162.5), +( 'ppfcz3', 15, 26, 166.5), ( 'ppfcz3', 15, 27, 170.5), ( 'ppfcz3', 15, 28, 174.5), +( 'ppfcz3', 15, 29, 178.5), ( 'ppfcz3', 15, 30, 182.5), ( 'ppfcz4', 15, 2, 44.5), +( 'ppfcz4', 15, 3, 51.5), ( 'ppfcz4', 15, 4, 58.5), ( 'ppfcz4', 15, 5, 65.5), +( 'ppfcz4', 15, 6, 72.5), ( 'ppfcz4', 15, 7, 79.5), ( 'ppfcz4', 15, 8, 86.5), +( 'ppfcz4', 15, 9, 93.5), ( 'ppfcz4', 15, 10, 100.5), ( 'ppfcz4', 15, 11, 105.5), +( 'ppfcz4', 15, 12, 110.5), ( 'ppfcz4', 15, 13, 115.5), ( 'ppfcz4', 15, 14, 120.5), +( 'ppfcz4', 15, 15, 125.5), ( 'ppfcz4', 15, 16, 130.5), ( 'ppfcz4', 15, 17, 135.5), +( 'ppfcz4', 15, 18, 140.5), ( 'ppfcz4', 15, 19, 145.5), ( 'ppfcz4', 15, 20, 150.5), +( 'ppfcz4', 15, 21, 154.5), ( 'ppfcz4', 15, 22, 158.5), ( 'ppfcz4', 15, 23, 162.5), +( 'ppfcz4', 15, 24, 166.5), ( 'ppfcz4', 15, 25, 170.5), ( 'ppfcz4', 15, 26, 174.5), +( 'ppfcz4', 15, 27, 178.5), ( 'ppfcz4', 15, 28, 182.5), ( 'ppfcz4', 15, 29, 186.5), +( 'ppfcz4', 15, 30, 190.5), ( 'ppfcz5', 15, 2, 48.5), ( 'ppfcz5', 15, 3, 56.5), +( 'ppfcz5', 15, 4, 64.5), ( 'ppfcz5', 15, 5, 72.5), ( 'ppfcz5', 15, 6, 80.5), +( 'ppfcz5', 15, 7, 88.5), ( 'ppfcz5', 15, 8, 96.5), ( 'ppfcz5', 15, 9, 104.5), +( 'ppfcz5', 15, 10, 112.5), ( 'ppfcz5', 15, 11, 119.5), ( 'ppfcz5', 15, 12, 126.5), +( 'ppfcz5', 15, 13, 133.5), ( 'ppfcz5', 15, 14, 140.5), ( 'ppfcz5', 15, 15, 147.5), +( 'ppfcz5', 15, 16, 153.5), ( 'ppfcz5', 15, 17, 161.5), ( 'ppfcz5', 15, 18, 167.5), +( 'ppfcz5', 15, 19, 173.5), ( 'ppfcz5', 15, 20, 179.5), ( 'ppfcz5', 15, 21, 185.5), +( 'ppfcz5', 15, 22, 191.5), ( 'ppfcz5', 15, 23, 197.5), ( 'ppfcz5', 15, 24, 203.5), +( 'ppfcz5', 15, 25, 207.5), ( 'ppfcz5', 15, 26, 212.5), ( 'ppfcz5', 15, 27, 217.5), +( 'ppfcz5', 15, 28, 222.5), ( 'ppfcz5', 15, 29, 227.5), ( 'ppfcz5', 15, 30, 232.5), +( 'ppfcz1', 14, 2, 37.5), ( 'ppfcz1', 14, 3, 41.5), ( 'ppfcz1', 14, 4, 45.5), +( 'ppfcz1', 14, 5, 48.5), ( 'ppfcz1', 14, 6, 52.5), ( 'ppfcz1', 14, 7, 55.5), +( 'ppfcz1', 14, 8, 57.5), ( 'ppfcz1', 14, 9, 59.5), ( 'ppfcz1', 14, 10, 61.5), +( 'ppfcz1', 14, 11, 62.5), ( 'ppfcz1', 14, 12, 63.5), ( 'ppfcz1', 14, 13, 64.5), +( 'ppfcz1', 14, 14, 65.5), ( 'ppfcz1', 14, 15, 66.5), ( 'ppfcz1', 14, 16, 67.5), +( 'ppfcz1', 14, 17, 68.5), ( 'ppfcz1', 14, 18, 69.5), ( 'ppfcz1', 14, 19, 70.5), +( 'ppfcz1', 14, 20, 71.5), ( 'ppfcz1', 14, 21, 72.5), ( 'ppfcz1', 14, 22, 73.5), +( 'ppfcz1', 14, 23, 74.5), ( 'ppfcz1', 14, 24, 75.5), ( 'ppfcz1', 14, 25, 76.5), +( 'ppfcz1', 14, 26, 77.5), ( 'ppfcz1', 14, 27, 78.5), ( 'ppfcz1', 14, 28, 79.5), +( 'ppfcz1', 14, 29, 80.5), ( 'ppfcz1', 14, 30, 81.5), ( 'ppfcz2', 14, 2, 43.5), +( 'ppfcz2', 14, 3, 48.5), ( 'ppfcz2', 14, 4, 53.5), ( 'ppfcz2', 14, 5, 57.5), +( 'ppfcz2', 14, 6, 61.5), ( 'ppfcz2', 14, 7, 65.5), ( 'ppfcz2', 14, 8, 69.5), +( 'ppfcz2', 14, 9, 73.5), ( 'ppfcz2', 14, 10, 77.5), ( 'ppfcz2', 14, 11, 80.5), +( 'ppfcz2', 14, 12, 83.5), ( 'ppfcz2', 14, 13, 86.5), ( 'ppfcz2', 14, 14, 89.5), +( 'ppfcz2', 14, 15, 92.5), ( 'ppfcz2', 14, 16, 94.5), ( 'ppfcz2', 14, 17, 96.5), +( 'ppfcz2', 14, 18, 98.5), ( 'ppfcz2', 14, 19, 99.5), ( 'ppfcz2', 14, 20, 100.5), +( 'ppfcz2', 14, 21, 101.5), ( 'ppfcz2', 14, 22, 102.5), ( 'ppfcz2', 14, 23, 103.5), +( 'ppfcz2', 14, 24, 104.5), ( 'ppfcz2', 14, 25, 105.5), ( 'ppfcz2', 14, 26, 106.5), +( 'ppfcz2', 14, 27, 107.5), ( 'ppfcz2', 14, 28, 108.5), ( 'ppfcz2', 14, 29, 109.5), +( 'ppfcz2', 14, 30, 110.5), ( 'ppfcz3', 14, 2, 47.5), ( 'ppfcz3', 14, 3, 56.5), +( 'ppfcz3', 14, 4, 67.5), ( 'ppfcz3', 14, 5, 78.5), ( 'ppfcz3', 14, 6, 87.5), +( 'ppfcz3', 14, 7, 96.5), ( 'ppfcz3', 14, 8, 105.5), ( 'ppfcz3', 14, 9, 114.5), +( 'ppfcz3', 14, 10, 123.5), ( 'ppfcz3', 14, 11, 131.5), ( 'ppfcz3', 14, 12, 139.5), +( 'ppfcz3', 14, 13, 147.5), ( 'ppfcz3', 14, 14, 155.5), ( 'ppfcz3', 14, 15, 163.5), +( 'ppfcz3', 14, 16, 171.5), ( 'ppfcz3', 14, 17, 179.5), ( 'ppfcz3', 14, 18, 187.5), +( 'ppfcz3', 14, 19, 195.5), ( 'ppfcz3', 14, 20, 203.5), ( 'ppfcz3', 14, 21, 210.5), +( 'ppfcz3', 14, 22, 217.5), ( 'ppfcz3', 14, 23, 224.5), ( 'ppfcz3', 14, 24, 231.5), +( 'ppfcz3', 14, 25, 238.5), ( 'ppfcz3', 14, 26, 245.5), ( 'ppfcz3', 14, 27, 252.5), +( 'ppfcz3', 14, 28, 259.5), ( 'ppfcz3', 14, 29, 266.5), ( 'ppfcz3', 14, 30, 273.5), +( 'ppfcz4', 14, 2, 54.5), ( 'ppfcz4', 14, 3, 68.5), ( 'ppfcz4', 14, 4, 81.5), +( 'ppfcz4', 14, 5, 95.5), ( 'ppfcz4', 14, 6, 108.5), ( 'ppfcz4', 14, 7, 121.5), +( 'ppfcz4', 14, 8, 134.5), ( 'ppfcz4', 14, 9, 147.5), ( 'ppfcz4', 14, 10, 160.5), +( 'ppfcz4', 14, 11, 168.5), ( 'ppfcz4', 14, 12, 178.5), ( 'ppfcz4', 14, 13, 188.5), +( 'ppfcz4', 14, 14, 198.5), ( 'ppfcz4', 14, 15, 208.5), ( 'ppfcz4', 14, 16, 216.5), +( 'ppfcz4', 14, 17, 224.5), ( 'ppfcz4', 14, 18, 232.5), ( 'ppfcz4', 14, 19, 240.5), +( 'ppfcz4', 14, 20, 248.5), ( 'ppfcz4', 14, 21, 256.5), ( 'ppfcz4', 14, 22, 264.5), +( 'ppfcz4', 14, 23, 272.5), ( 'ppfcz4', 14, 24, 280.5), ( 'ppfcz4', 14, 25, 288.5), +( 'ppfcz4', 14, 26, 296.5), ( 'ppfcz4', 14, 27, 304.5), ( 'ppfcz4', 14, 28, 312.5), +( 'ppfcz4', 14, 29, 320.5), ( 'ppfcz4', 14, 30, 328.5), ( 'ppfcz5', 14, 2, 66.5), +( 'ppfcz5', 14, 3, 84.5), ( 'ppfcz5', 14, 4, 102.5), ( 'ppfcz5', 14, 5, 120.5), +( 'ppfcz5', 14, 6, 137.5), ( 'ppfcz5', 14, 7, 154.5), ( 'ppfcz5', 14, 8, 171.5), +( 'ppfcz5', 14, 9, 188.5), ( 'ppfcz5', 14, 10, 205.5), ( 'ppfcz5', 14, 11, 220.5), +( 'ppfcz5', 14, 12, 235.5), ( 'ppfcz5', 14, 13, 250.5), ( 'ppfcz5', 14, 14, 265.5), +( 'ppfcz5', 14, 15, 280.5), ( 'ppfcz5', 14, 16, 295.5), ( 'ppfcz5', 14, 17, 310.5), +( 'ppfcz5', 14, 18, 325.5), ( 'ppfcz5', 14, 19, 340.5), ( 'ppfcz5', 14, 20, 355.5), +( 'ppfcz5', 14, 21, 368.5), ( 'ppfcz5', 14, 22, 381.5), ( 'ppfcz5', 14, 23, 394.5), +( 'ppfcz5', 14, 24, 407.5), ( 'ppfcz5', 14, 25, 420.5), ( 'ppfcz5', 14, 26, 433.5), +( 'ppfcz5', 14, 27, 446.5), ( 'ppfcz5', 14, 28, 459.5), ( 'ppfcz5', 14, 29, 472.5), +( 'ppfcz5', 14, 30, 485.5), ( 'ppfcz1', 30, 0.5, 56.5), ( 'ppfcz1', 30, 1, 63.5), +( 'ppfcz1', 30, 1.5, 69.5), ( 'ppfcz1', 30, 2, 75.5), ( 'ppfcz1', 30, 2.5, 80.5), +( 'ppfcz1', 30, 3, 86.5), ( 'ppfcz1', 30, 3.5, 92.5), ( 'ppfcz1', 30, 4, 99.5), +( 'ppfcz1', 30, 4.5, 105.5), ( 'ppfcz1', 30, 5, 111.5), ( 'ppfcz1', 30, 6, 118.5), +( 'ppfcz1', 30, 7, 126.5), ( 'ppfcz1', 30, 8, 133.5), ( 'ppfcz1', 30, 9, 141.5), +( 'ppfcz1', 30, 10, 148.5), ( 'ppfcz1', 30, 11, 156.5), ( 'ppfcz1', 30, 12, 163.5), +( 'ppfcz1', 30, 13, 171.5), ( 'ppfcz1', 30, 14, 178.5), ( 'ppfcz1', 30, 15, 186.5), +( 'ppfcz1', 30, 16, 193.5), ( 'ppfcz1', 30, 17, 201.5), ( 'ppfcz1', 30, 18, 209.5), +( 'ppfcz1', 30, 19, 216.5), ( 'ppfcz1', 30, 20, 224.5), ( 'ppfcz1', 30, 21, 231.5), +( 'ppfcz1', 30, 22, 239.5), ( 'ppfcz1', 30, 23, 246.5), ( 'ppfcz1', 30, 24, 254.5), +( 'ppfcz1', 30, 25, 261.5), ( 'ppfcz1', 30, 26, 269.5), ( 'ppfcz1', 30, 27, 276.5), +( 'ppfcz1', 30, 28, 284.5), ( 'ppfcz1', 30, 29, 291.5), ( 'ppfcz1', 30, 30, 299.5), +( 'ppfcz2', 30, 0.5, 61.5), ( 'ppfcz2', 30, 1, 65.5), ( 'ppfcz2', 30, 1.5, 75.5), +( 'ppfcz2', 30, 2, 80.5), ( 'ppfcz2', 30, 2.5, 86.5), ( 'ppfcz2', 30, 3, 99.5), +( 'ppfcz2', 30, 3.5, 109.5), ( 'ppfcz2', 30, 4, 113.5), ( 'ppfcz2', 30, 4.5, 121.5), +( 'ppfcz2', 30, 5, 129.5), ( 'ppfcz2', 30, 6, 139.5), ( 'ppfcz2', 30, 7, 149.5), +( 'ppfcz2', 30, 8, 159.5), ( 'ppfcz2', 30, 9, 169.5), ( 'ppfcz2', 30, 10, 180.5), +( 'ppfcz2', 30, 11, 189.5), ( 'ppfcz2', 30, 12, 199.5), ( 'ppfcz2', 30, 13, 210.5), +( 'ppfcz2', 30, 14, 219.5), ( 'ppfcz2', 30, 15, 229.5), ( 'ppfcz2', 30, 16, 240.5), +( 'ppfcz2', 30, 17, 249.5), ( 'ppfcz2', 30, 18, 259.5), ( 'ppfcz2', 30, 19, 270.5), +( 'ppfcz2', 30, 20, 280.5), ( 'ppfcz2', 30, 21, 289.5), ( 'ppfcz2', 30, 22, 300.5), +( 'ppfcz2', 30, 23, 310.5), ( 'ppfcz2', 30, 24, 320.5), ( 'ppfcz2', 30, 25, 330.5), +( 'ppfcz2', 30, 26, 340.5), ( 'ppfcz2', 30, 27, 350.5), ( 'ppfcz2', 30, 28, 360.5), +( 'ppfcz2', 30, 29, 370.5), ( 'ppfcz2', 30, 30, 381.5), ( 'ppfcz3', 30, 0.5, 74.5), +( 'ppfcz3', 30, 1, 83.5), ( 'ppfcz3', 30, 1.5, 90.5), ( 'ppfcz3', 30, 2, 99.5), +( 'ppfcz3', 30, 2.5, 107.5), ( 'ppfcz3', 30, 3, 114.5), ( 'ppfcz3', 30, 3.5, 122.5), +( 'ppfcz3', 30, 4, 130.5), ( 'ppfcz3', 30, 4.5, 140.5), ( 'ppfcz3', 30, 5, 147.5), +( 'ppfcz3', 30, 6, 162.5), ( 'ppfcz3', 30, 7, 174.5), ( 'ppfcz3', 30, 8, 188.5), +( 'ppfcz3', 30, 9, 201.5), ( 'ppfcz3', 30, 10, 213.5), ( 'ppfcz3', 30, 11, 227.5), +( 'ppfcz3', 30, 12, 240.5), ( 'ppfcz3', 30, 13, 252.5), ( 'ppfcz3', 30, 14, 266.5), +( 'ppfcz3', 30, 15, 278.5), ( 'ppfcz3', 30, 16, 290.5), ( 'ppfcz3', 30, 17, 304.5), +( 'ppfcz3', 30, 18, 317.5), ( 'ppfcz3', 30, 19, 330.5), ( 'ppfcz3', 30, 20, 343.5), +( 'ppfcz3', 30, 21, 354.5), ( 'ppfcz3', 30, 22, 363.5), ( 'ppfcz3', 30, 23, 375.5), +( 'ppfcz3', 30, 24, 385.5), ( 'ppfcz3', 30, 25, 396.5), ( 'ppfcz3', 30, 26, 405.5), +( 'ppfcz3', 30, 27, 417.5), ( 'ppfcz3', 30, 28, 428.5), ( 'ppfcz3', 30, 29, 438.5), +( 'ppfcz3', 30, 30, 448.5), ( 'ppfcz4', 30, 0.5, 90.5), ( 'ppfcz4', 30, 1, 104.5), +( 'ppfcz4', 30, 1.5, 118.5), ( 'ppfcz4', 30, 2, 134.5), ( 'ppfcz4', 30, 2.5, 146.5), +( 'ppfcz4', 30, 3, 163.5), ( 'ppfcz4', 30, 3.5, 179.5), ( 'ppfcz4', 30, 4, 195.5), +( 'ppfcz4', 30, 4.5, 211.5), ( 'ppfcz4', 30, 5, 232.5), ( 'ppfcz4', 30, 6, 257.5), +( 'ppfcz4', 30, 7, 278.5), ( 'ppfcz4', 30, 8, 300.5), ( 'ppfcz4', 30, 9, 321.5), +( 'ppfcz4', 30, 10, 343.5), ( 'ppfcz4', 30, 11, 364.5), ( 'ppfcz4', 30, 12, 386.5), +( 'ppfcz4', 30, 13, 407.5), ( 'ppfcz4', 30, 14, 429.5), ( 'ppfcz4', 30, 15, 450.5), +( 'ppfcz4', 30, 16, 472.5), ( 'ppfcz4', 30, 17, 493.5), ( 'ppfcz4', 30, 18, 515.5), +( 'ppfcz4', 30, 19, 536.5), ( 'ppfcz4', 30, 20, 558.5), ( 'ppfcz4', 30, 21, 579.5), +( 'ppfcz4', 30, 22, 601.5), ( 'ppfcz4', 30, 23, 622.5), ( 'ppfcz4', 30, 24, 644.5), +( 'ppfcz4', 30, 25, 665.5), ( 'ppfcz4', 30, 26, 687.5), ( 'ppfcz4', 30, 27, 708.5), +( 'ppfcz4', 30, 28, 730.5), ( 'ppfcz4', 30, 29, 751.5), ( 'ppfcz4', 30, 30, 773.5), +( 'ppfcz5', 30, 0.5, 97.5), ( 'ppfcz5', 30, 1, 114.5), ( 'ppfcz5', 30, 1.5, 131.5), +( 'ppfcz5', 30, 2, 148.5), ( 'ppfcz5', 30, 2.5, 165.5), ( 'ppfcz5', 30, 3, 183.5), +( 'ppfcz5', 30, 3.5, 200.5), ( 'ppfcz5', 30, 4, 221.5), ( 'ppfcz5', 30, 4.5, 243.5), +( 'ppfcz5', 30, 5, 264.5), ( 'ppfcz5', 30, 6, 289.5), ( 'ppfcz5', 30, 7, 313.5), +( 'ppfcz5', 30, 8, 336.5), ( 'ppfcz5', 30, 9, 360.5), ( 'ppfcz5', 30, 10, 384.5), +( 'ppfcz5', 30, 11, 407.5), ( 'ppfcz5', 30, 12, 431.5), ( 'ppfcz5', 30, 13, 455.5), +( 'ppfcz5', 30, 14, 478.5), ( 'ppfcz5', 30, 15, 502.5), ( 'ppfcz5', 30, 16, 526.5), +( 'ppfcz5', 30, 17, 549.5), ( 'ppfcz5', 30, 18, 573.5), ( 'ppfcz5', 30, 19, 597.5), +( 'ppfcz5', 30, 20, 620.5), ( 'ppfcz5', 30, 21, 644.5), ( 'ppfcz5', 30, 22, 668.5), +( 'ppfcz5', 30, 23, 691.5), ( 'ppfcz5', 30, 24, 715.5), ( 'ppfcz5', 30, 25, 738.5), +( 'ppfcz5', 30, 26, 762.5), ( 'ppfcz5', 30, 27, 786.5), ( 'ppfcz5', 30, 28, 809.5), +( 'ppfcz5', 30, 29, 833.5), ( 'ppfcz5', 30, 30, 857.5), ( 'foreign', 13, 30, 0), +( 'all', 32, 10000, 23.2342007434944); + +--enable_query_log + +INSERT INTO t3 SELECT * FROM t1; + +EXPLAIN +SELECT d FROM t1, t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE' +ORDER BY t2.c LIMIT 1; +SELECT d FROM t1, t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE' +ORDER BY t2.c LIMIT 1; + +EXPLAIN +SELECT d FROM t3 AS t1, t2 AS t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE' +ORDER BY t2.c LIMIT 1; +SELECT d FROM t3 AS t1, t2 AS t2 +WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE' +ORDER BY t2.c LIMIT 1; + +DROP TABLE t1,t2,t3; + + +# +# Bug#35844: Covering index for ref access not compatible with ORDER BY list +# + +CREATE TABLE t1 ( + id1 INT NULL, + id2 INT NOT NULL, + junk INT NOT NULL, + PRIMARY KEY (id1, id2, junk), + INDEX id2_j_id1 (id2, junk, id1) +); + +INSERT INTO t1 VALUES (1, 1, 1), (2, 1, 2), (3, 1, 3), (4, 1, 4); +INSERT INTO t1 VALUES (5, 2, 1), (6, 2, 2), (7, 2, 3), (8, 2, 4); +INSERT INTO t1 VALUES (9, 3, 1), (10, 3, 2), (11, 3, 3), (12, 3, 4); +INSERT INTO t1 VALUES (13, 4, 1), (14, 4, 2), (15, 4, 3), (16, 4, 4); +INSERT INTO t1 VALUES (17, 5, 1), (18, 5, 2), (19, 5, 3), (20, 5, 4); +INSERT INTO t1 VALUES (21, 6, 1), (22, 6, 2), (23, 6, 3), (24, 6, 4); +INSERT INTO t1 VALUES (25, 7, 1), (26, 7, 2), (27, 7, 3), (28, 7, 4); +INSERT INTO t1 VALUES (29, 8, 1), (30, 8, 2), (31, 8, 3), (32, 8, 4); +INSERT INTO t1 VALUES (33, 9, 1), (34, 9, 2), (35, 9, 3), (36, 9, 4); + +EXPLAIN SELECT id1 FROM t1 WHERE id2 = 4 ORDER BY id1; + +SELECT id1 FROM t1 WHERE id2 = 4 ORDER BY id1; + +DROP TABLE t1; + + + +# +# Bug#46454: MySQL wrong index optimisation leads to incorrect result & crashes +# +CREATE TABLE t1 ( + a INT, + b INT NOT NULL, + c char(100), + KEY (b, c), + KEY (b, a, c) +) +DEFAULT CHARSET = utf8; + +INSERT INTO t1 VALUES +(1, 1, 1), +(2, 2, 2), +(3, 3, 3), +(4, 4, 4), +(5, 5, 5), +(6, 6, 6), +(7, 7, 7), +(8, 8, 8), +(9, 9, 9); + +INSERT INTO t1 SELECT a + 10, b, c FROM t1; +INSERT INTO t1 SELECT a + 20, b, c FROM t1; +INSERT INTO t1 SELECT a + 40, b, c FROM t1; +INSERT INTO t1 SELECT a + 80, b, c FROM t1; +INSERT INTO t1 SELECT a + 160, b, c FROM t1; +INSERT INTO t1 SELECT a + 320, b, c FROM t1; +INSERT INTO t1 SELECT a + 640, b, c FROM t1; +INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80; + +EXPLAIN +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; + +EXPLAIN +SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9; +SELECT DISTINCT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 0, 9; + +DROP TABLE t1; + +--echo # +--echo # Bug #43029: FORCE INDEX FOR ORDER BY is ignored when join buffering +--echo # is used +--echo # + +CREATE TABLE t1 (a INT, b INT, KEY (a)); + +INSERT INTO t1 VALUES (0, NULL), (1, NULL), (2, NULL), (3, NULL); +INSERT INTO t1 SELECT a+4, b FROM t1; +INSERT INTO t1 SELECT a+8, b FROM t1; + +CREATE TABLE t2 (a INT, b INT); + +INSERT INTO t2 VALUES (0,NULL), (1,NULL), (2,NULL), (3,NULL), (4,NULL); +INSERT INTO t2 SELECT a+4, b FROM t2; + +--echo # shouldn't have "using filesort" +EXPLAIN +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (a), t2 WHERE t1.a < 2 ORDER BY t1.a; + +--echo # should have "using filesort" +EXPLAIN +SELECT * FROM t1 USE INDEX FOR ORDER BY (a), t2 WHERE t1.a < 2 ORDER BY t1.a; + +--echo # should have "using filesort" +EXPLAIN +SELECT * FROM t1 FORCE INDEX FOR JOIN (a), t2 WHERE t1.a < 2 ORDER BY t1.a; + +DROP TABLE t1, t2; + +--echo End of 5.1 tests diff --git a/mysql-test/t/order_fill_sortbuf-master.opt b/mysql-test/t/order_fill_sortbuf-master.opt index 116494d4588..9aa3cc76221 100644 --- a/mysql-test/t/order_fill_sortbuf-master.opt +++ b/mysql-test/t/order_fill_sortbuf-master.opt @@ -1 +1 @@ ---set-variable=sort_buffer=0 +--set-variable=sort_buffer=32804 diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test index 4398f9fa741..45b13f141f7 100644 --- a/mysql-test/t/outfile.test +++ b/mysql-test/t/outfile.test @@ -1,7 +1,7 @@ disable_query_log; -- source include/test_outfile.inc -# Server are started in "var/master-data", so "../tmp" will be "var/tmp" -eval set @tmpdir="../tmp"; +# Server are started in "var/master-data", so "../../tmp" will be "var/tmp" +eval set @tmpdir="../../tmp"; enable_query_log; -- source include/have_outfile.inc @@ -20,15 +20,15 @@ drop table if exists t1; create table t1 (`a` blob); insert into t1 values("hello world"),("Hello mars"),(NULL); disable_query_log; -eval select * into outfile "../tmp/outfile-test.1" from t1; +eval select * into outfile "../../tmp/outfile-test.1" from t1; enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.1")); disable_query_log; -eval select * into dumpfile "../tmp/outfile-test.2" from t1 limit 1; +eval select * into dumpfile "../../tmp/outfile-test.2" from t1 limit 1; enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.2")); disable_query_log; -eval select * into dumpfile "../tmp/outfile-test.3" from t1 where a is null; +eval select * into dumpfile "../../tmp/outfile-test.3" from t1 where a is null; enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.3")); @@ -36,13 +36,13 @@ select load_file(concat(@tmpdir,"/outfile-test.3")); disable_query_log; --error ER_FILE_EXISTS_ERROR -eval select * into outfile "../tmp/outfile-test.1" from t1; +eval select * into outfile "../../tmp/outfile-test.1" from t1; --error ER_FILE_EXISTS_ERROR -eval select * into dumpfile "../tmp/outfile-test.2" from t1; +eval select * into dumpfile "../../tmp/outfile-test.2" from t1; --error ER_FILE_EXISTS_ERROR -eval select * into dumpfile "../tmp/outfile-test.3" from t1; +eval select * into dumpfile "../../tmp/outfile-test.3" from t1; enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.not-exist")); --remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.1 @@ -52,7 +52,7 @@ drop table t1; # Bug#8191 SELECT INTO OUTFILE insists on FROM clause disable_query_log; -eval select 1 into outfile "../tmp/outfile-test.4"; +eval select 1 into outfile "../../tmp/outfile-test.4"; enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.4")); --remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4 @@ -75,7 +75,7 @@ DROP TABLE t1; # Bug#13202 SELECT * INTO OUTFILE ... FROM information_schema.schemata now fails # disable_query_log; -eval SELECT * INTO OUTFILE "../tmp/outfile-test.4" +eval SELECT * INTO OUTFILE "../../tmp/outfile-test.4" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM information_schema.schemata LIMIT 0, 5; # enable_query_log; @@ -83,7 +83,7 @@ FROM information_schema.schemata LIMIT 0, 5; use information_schema; # disable_query_log; -eval SELECT * INTO OUTFILE "../tmp/outfile-test.4" +eval SELECT * INTO OUTFILE "../../tmp/outfile-test.4" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM schemata LIMIT 0, 5; enable_query_log; @@ -111,7 +111,7 @@ connect (con28181_1,localhost,user_1,,mysqltest); --error ER_DBACCESS_DENIED_ERROR eval select schema_name -into outfile "../tmp/outfile-test.4" +into outfile "../../tmp/outfile-test.4" fields terminated by ',' optionally enclosed by '"' lines terminated by '\n' from information_schema.schemata @@ -123,7 +123,7 @@ grant file on *.* to user_1@localhost; connect (con28181_2,localhost,user_1,,mysqltest); eval select schema_name -into outfile "../tmp/outfile-test.4" +into outfile "../../tmp/outfile-test.4" fields terminated by ',' optionally enclosed by '"' lines terminated by '\n' from information_schema.schemata diff --git a/mysql-test/t/outfile_loaddata.test b/mysql-test/t/outfile_loaddata.test index 2a120871e7d..3f62acbd214 100644 --- a/mysql-test/t/outfile_loaddata.test +++ b/mysql-test/t/outfile_loaddata.test @@ -111,3 +111,146 @@ SELECT HEX(c1) FROM t1; DROP TABLE t1; --echo # End of 5.0 tests. + +########################################################################### + +--echo # +--echo # Bug #30946: mysqldump silently ignores --default-character-set +--echo # when used with --tab +--echo # +--echo # Also see mysqldump.test +--echo # + +SET NAMES utf8; +CREATE TABLE t1 (a INT, b CHAR(10) CHARSET koi8r, c CHAR(10) CHARSET latin1); +CREATE TABLE t2 LIKE t1; +INSERT INTO t1 VALUES (1, 'ABC-АБВ', 'DEF-ÂÃÄ'), (2, NULL, NULL); + +--let $file=$MYSQLTEST_VARDIR/tmp/t1.txt + + +--echo # Error on multi-character ENCLOSED/ESCAPED BY + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--error 1083 +--eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ENCLOSED BY '12345' +--remove_file $file + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--error 1083 +--eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ESCAPED BY '12345' +--remove_file $file + + +--echo # "Not implemented" warning on multibyte ENCLOSED/ESCAPED BY character, +--echo # LOAD DATA rises error or has unpredictable result -- to be fixed later + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ENCLOSED BY 'ъ' +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--error 1083 # backward compatibility +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary FIELDS ENCLOSED BY 'ъ' +--remove_file $file + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ESCAPED BY 'ъ' +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--error 1083 # backward compatibility +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary FIELDS ESCAPED BY 'ъ' +--remove_file $file + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS TERMINATED BY 'ъ' +--echo ################################################## +--cat_file $file +--echo ################################################## +TRUNCATE t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary FIELDS TERMINATED BY 'ъ' +--remove_file $file +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT * FROM t1 INTO OUTFILE '$file' LINES STARTING BY 'ъ' +--echo ################################################## +--cat_file $file +--echo ################################################## +TRUNCATE t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary LINES STARTING BY 'ъ' +--remove_file $file +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT * FROM t1 INTO OUTFILE '$file' LINES TERMINATED BY 'ъ' +--echo ################################################## +--cat_file $file +--echo ################################################## +TRUNCATE t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary LINES TERMINATED BY 'ъ' +--remove_file $file +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; + +--echo # Default (binary) charset: + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT * INTO OUTFILE '$file' FROM t1 +--echo ################################################## +--cat_file $file +--echo ################################################## +TRUNCATE t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary +--remove_file $file +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; + + +--echo # latin1 charset (INTO OUTFILE warning is expected): + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT * INTO OUTFILE '$file' CHARACTER SET latin1 FROM t1 +--echo ################################################## +--cat_file $file +--echo ################################################## +TRUNCATE t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET latin1 +--remove_file $file +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; + + +--echo # KOI8-R charset (INTO OUTFILE warning is expected): + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT * INTO OUTFILE '$file' CHARACTER SET koi8r FROM t1 +--echo ################################################## +--cat_file $file +--echo ################################################## +TRUNCATE t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET koi8r +--remove_file $file +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; + + +--echo # UTF-8 charset: + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT * INTO OUTFILE '$file' CHARACTER SET utf8 FROM t1 +--echo ################################################## +--cat_file $file +--echo ################################################## +TRUNCATE t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET utf8 +--remove_file $file +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; + + +SET NAMES default; + +DROP TABLE t1, t2; + +########################################################################### +--echo # End of 5.1 tests. diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test index 02fe98dc7b2..e579e371184 100644 --- a/mysql-test/t/parser.test +++ b/mysql-test/t/parser.test @@ -11,6 +11,387 @@ # even whitespace or comments, is significant here. # +SET @save_sql_mode=@@sql_mode; + +# +# Documenting the current behavior, to detect incompatible changes. +# In each cases: +# - no error is the correct result +# - an error is the expected result with the current implementation, +# and is a limitation. + +set SQL_MODE=''; + +create table ADDDATE(a int); +drop table ADDDATE; +create table ADDDATE (a int); +drop table ADDDATE; + +--error ER_PARSE_ERROR +create table BIT_AND(a int); +create table BIT_AND (a int); +drop table BIT_AND; + +--error ER_PARSE_ERROR +create table BIT_OR(a int); +create table BIT_OR (a int); +drop table BIT_OR; + +--error ER_PARSE_ERROR +create table BIT_XOR(a int); +create table BIT_XOR (a int); +drop table BIT_XOR; + +--error ER_PARSE_ERROR +create table CAST(a int); +create table CAST (a int); +drop table CAST; + +--error ER_PARSE_ERROR +create table COUNT(a int); +create table COUNT (a int); +drop table COUNT; + +--error ER_PARSE_ERROR +create table CURDATE(a int); +create table CURDATE (a int); +drop table CURDATE; + +--error ER_PARSE_ERROR +create table CURTIME(a int); +create table CURTIME (a int); +drop table CURTIME; + +--error ER_PARSE_ERROR +create table DATE_ADD(a int); +create table DATE_ADD (a int); +drop table DATE_ADD; + +--error ER_PARSE_ERROR +create table DATE_SUB(a int); +create table DATE_SUB (a int); +drop table DATE_SUB; + +--error ER_PARSE_ERROR +create table EXTRACT(a int); +create table EXTRACT (a int); +drop table EXTRACT; + +--error ER_PARSE_ERROR +create table GROUP_CONCAT(a int); +create table GROUP_CONCAT (a int); +drop table GROUP_CONCAT; + +# Limitation removed in 5.1 +create table GROUP_UNIQUE_USERS(a int); +drop table GROUP_UNIQUE_USERS; +create table GROUP_UNIQUE_USERS (a int); +drop table GROUP_UNIQUE_USERS; + +--error ER_PARSE_ERROR +create table MAX(a int); +create table MAX (a int); +drop table MAX; + +--error ER_PARSE_ERROR +create table MID(a int); +create table MID (a int); +drop table MID; + +--error ER_PARSE_ERROR +create table MIN(a int); +create table MIN (a int); +drop table MIN; + +--error ER_PARSE_ERROR +create table NOW(a int); +create table NOW (a int); +drop table NOW; + +--error ER_PARSE_ERROR +create table POSITION(a int); +create table POSITION (a int); +drop table POSITION; + +create table SESSION_USER(a int); +drop table SESSION_USER; +create table SESSION_USER (a int); +drop table SESSION_USER; + +--error ER_PARSE_ERROR +create table STD(a int); +create table STD (a int); +drop table STD; + +--error ER_PARSE_ERROR +create table STDDEV(a int); +create table STDDEV (a int); +drop table STDDEV; + +--error ER_PARSE_ERROR +create table STDDEV_POP(a int); +create table STDDEV_POP (a int); +drop table STDDEV_POP; + +--error ER_PARSE_ERROR +create table STDDEV_SAMP(a int); +create table STDDEV_SAMP (a int); +drop table STDDEV_SAMP; + +create table SUBDATE(a int); +drop table SUBDATE; +create table SUBDATE (a int); +drop table SUBDATE; + +--error ER_PARSE_ERROR +create table SUBSTR(a int); +create table SUBSTR (a int); +drop table SUBSTR; + +--error ER_PARSE_ERROR +create table SUBSTRING(a int); +create table SUBSTRING (a int); +drop table SUBSTRING; + +--error ER_PARSE_ERROR +create table SUM(a int); +create table SUM (a int); +drop table SUM; + +--error ER_PARSE_ERROR +create table SYSDATE(a int); +create table SYSDATE (a int); +drop table SYSDATE; + +create table SYSTEM_USER(a int); +drop table SYSTEM_USER; +create table SYSTEM_USER (a int); +drop table SYSTEM_USER; + +--error ER_PARSE_ERROR +create table TRIM(a int); +create table TRIM (a int); +drop table TRIM; + +# Limitation removed in 5.1 +create table UNIQUE_USERS(a int); +drop table UNIQUE_USERS; +create table UNIQUE_USERS (a int); +drop table UNIQUE_USERS; + +--error ER_PARSE_ERROR +create table VARIANCE(a int); +create table VARIANCE (a int); +drop table VARIANCE; + +--error ER_PARSE_ERROR +create table VAR_POP(a int); +create table VAR_POP (a int); +drop table VAR_POP; + +--error ER_PARSE_ERROR +create table VAR_SAMP(a int); +create table VAR_SAMP (a int); +drop table VAR_SAMP; + +set SQL_MODE='IGNORE_SPACE'; + +create table ADDDATE(a int); +drop table ADDDATE; +create table ADDDATE (a int); +drop table ADDDATE; + +--error ER_PARSE_ERROR +create table BIT_AND(a int); +--error ER_PARSE_ERROR +create table BIT_AND (a int); + +--error ER_PARSE_ERROR +create table BIT_OR(a int); +--error ER_PARSE_ERROR +create table BIT_OR (a int); + +--error ER_PARSE_ERROR +create table BIT_XOR(a int); +--error ER_PARSE_ERROR +create table BIT_XOR (a int); + +--error ER_PARSE_ERROR +create table CAST(a int); +--error ER_PARSE_ERROR +create table CAST (a int); + +--error ER_PARSE_ERROR +create table COUNT(a int); +--error ER_PARSE_ERROR +create table COUNT (a int); + +--error ER_PARSE_ERROR +create table CURDATE(a int); +--error ER_PARSE_ERROR +create table CURDATE (a int); + +--error ER_PARSE_ERROR +create table CURTIME(a int); +--error ER_PARSE_ERROR +create table CURTIME (a int); + +--error ER_PARSE_ERROR +create table DATE_ADD(a int); +--error ER_PARSE_ERROR +create table DATE_ADD (a int); + +--error ER_PARSE_ERROR +create table DATE_SUB(a int); +--error ER_PARSE_ERROR +create table DATE_SUB (a int); + +--error ER_PARSE_ERROR +create table EXTRACT(a int); +--error ER_PARSE_ERROR +create table EXTRACT (a int); + +--error ER_PARSE_ERROR +create table GROUP_CONCAT(a int); +--error ER_PARSE_ERROR +create table GROUP_CONCAT (a int); + +# Limitation removed in 5.1 +create table GROUP_UNIQUE_USERS(a int); +drop table GROUP_UNIQUE_USERS; +create table GROUP_UNIQUE_USERS (a int); +drop table GROUP_UNIQUE_USERS; + +--error ER_PARSE_ERROR +create table MAX(a int); +--error ER_PARSE_ERROR +create table MAX (a int); + +--error ER_PARSE_ERROR +create table MID(a int); +--error ER_PARSE_ERROR +create table MID (a int); + +--error ER_PARSE_ERROR +create table MIN(a int); +--error ER_PARSE_ERROR +create table MIN (a int); + +--error ER_PARSE_ERROR +create table NOW(a int); +--error ER_PARSE_ERROR +create table NOW (a int); + +--error ER_PARSE_ERROR +create table POSITION(a int); +--error ER_PARSE_ERROR +create table POSITION (a int); + +create table SESSION_USER(a int); +drop table SESSION_USER; +create table SESSION_USER (a int); +drop table SESSION_USER; + +--error ER_PARSE_ERROR +create table STD(a int); +--error ER_PARSE_ERROR +create table STD (a int); + +--error ER_PARSE_ERROR +create table STDDEV(a int); +--error ER_PARSE_ERROR +create table STDDEV (a int); + +--error ER_PARSE_ERROR +create table STDDEV_POP(a int); +--error ER_PARSE_ERROR +create table STDDEV_POP (a int); + +--error ER_PARSE_ERROR +create table STDDEV_SAMP(a int); +--error ER_PARSE_ERROR +create table STDDEV_SAMP (a int); + +create table SUBDATE(a int); +drop table SUBDATE; +create table SUBDATE (a int); +drop table SUBDATE; + +--error ER_PARSE_ERROR +create table SUBSTR(a int); +--error ER_PARSE_ERROR +create table SUBSTR (a int); + +--error ER_PARSE_ERROR +create table SUBSTRING(a int); +--error ER_PARSE_ERROR +create table SUBSTRING (a int); + +--error ER_PARSE_ERROR +create table SUM(a int); +--error ER_PARSE_ERROR +create table SUM (a int); + +--error ER_PARSE_ERROR +create table SYSDATE(a int); +--error ER_PARSE_ERROR +create table SYSDATE (a int); + +create table SYSTEM_USER(a int); +drop table SYSTEM_USER; +create table SYSTEM_USER (a int); +drop table SYSTEM_USER; + +--error ER_PARSE_ERROR +create table TRIM(a int); +--error ER_PARSE_ERROR +create table TRIM (a int); + +# Limitation removed in 5.1 +create table UNIQUE_USERS(a int); +drop table UNIQUE_USERS; +create table UNIQUE_USERS (a int); +drop table UNIQUE_USERS; + +--error ER_PARSE_ERROR +create table VARIANCE(a int); +--error ER_PARSE_ERROR +create table VARIANCE (a int); + +--error ER_PARSE_ERROR +create table VAR_POP(a int); +--error ER_PARSE_ERROR +create table VAR_POP (a int); + +--error ER_PARSE_ERROR +create table VAR_SAMP(a int); +--error ER_PARSE_ERROR +create table VAR_SAMP (a int); + +# +# Bug#25930 (CREATE TABLE x SELECT ... parses columns wrong when ran with +# ANSI_QUOTES mode) +# + +--disable_warnings +DROP TABLE IF EXISTS table_25930_a; +DROP TABLE IF EXISTS table_25930_b; +--enable_warnings + +SET SQL_MODE = 'ANSI_QUOTES'; +CREATE TABLE table_25930_a ( "blah" INT ); +CREATE TABLE table_25930_b SELECT "blah" - 1 FROM table_25930_a; + +# The lexer used to chop the first <">, +# not marking the start of the token "blah" correctly. +desc table_25930_b; + +DROP TABLE table_25930_a; +DROP TABLE table_25930_b; + + +SET @@sql_mode=@save_sql_mode; + # # Bug#26030 (Parsing fails for stored routine w/multi-statement execution # enabled) @@ -53,7 +434,297 @@ $$ delimiter ;$$ DROP PROCEDURE p26030; -#============================================================================r +#============================================================================= # SYNTACTIC PARSER (bison) #============================================================================= +# +# +# Bug#21114 (Foreign key creation fails to table with name format) +# + +# Test coverage with edge conditions + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select pi(3.14); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select tan(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select tan(1, 2); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select makedate(1); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select makedate(1, 2, 3); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select maketime(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select maketime(1); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select maketime(1, 2); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select maketime(1, 2, 3, 4); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select atan(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select atan2(1, 2, 3); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select concat(); +select concat("foo"); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select concat_ws(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select concat_ws("foo"); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select encrypt(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select encrypt(1, 2, 3); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select des_encrypt("p1", "p2", "not expected"); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select des_decrypt("p1", "p2", "not expected"); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select elt(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select elt(1); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select export_set(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select export_set("p1"); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select export_set("p1", "p2"); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select export_set("p1", "p2", "p3", "p4", "p5", "p6"); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select field(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select field("p1"); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select from_unixtime(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select from_unixtime(1, 2, 3); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select unix_timestamp(1, 2); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select greatest(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select greatest(12); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select last_insert_id(1, 2); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select least(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select least(12); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select locate(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select locate(1); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select locate(1, 2, 3, 4); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select log(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select log(1, 2, 3); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select make_set(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select make_set(1); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select master_pos_wait(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select master_pos_wait(1); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select master_pos_wait(1, 2, 3, 4); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select rand(1, 2, 3); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select round(1, 2, 3); + +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select yearweek(); +-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select yearweek(1, 2, 3); + +# +# Bug#24736: UDF functions parsed as Stored Functions +# + +# Verify that the syntax for calling UDF : foo(expr AS param, ...) +# can not be used when calling native functions + +# Native function with 1 argument + +select abs(3); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select abs(3 AS three); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select abs(3 three); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select abs(3 AS "three"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select abs(3 "three"); + +# Native function with 2 arguments + +set @bar="bar"; +set @foobar="foobar"; + +select instr("foobar", "bar"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar" AS p1, "bar"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar" p1, "bar"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar" AS "p1", "bar"); +## String concatenation, valid syntax +select instr("foobar" "p1", "bar"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr(@foobar "p1", "bar"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar", "bar" AS p2); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar", "bar" p2); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar", "bar" AS "p2"); +## String concatenation, valid syntax +select instr("foobar", "bar" "p2"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar", @bar "p2"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar" AS p1, "bar" AS p2); + +# Native function with 3 arguments + +select conv(255, 10, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255 AS p1, 10, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255 p1, 10, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255 AS "p1", 10, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255 "p1", 10, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10 AS p2, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10 p2, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10 AS "p2", 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10 "p2", 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10, 16 AS p3); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10, 16 p3); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10, 16 AS "p3"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10, 16 "p3"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255 AS p1, 10 AS p2, 16 AS p3); + +# Native function with a variable number of arguments + +select atan(10); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 AS p1); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 p1); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 AS "p1"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 "p1"); + +select atan(10, 20); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 AS p1, 20); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 p1, 20); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 AS "p1", 20); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 "p1", 20); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10, 20 AS p2); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10, 20 p2); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10, 20 AS "p2"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10, 20 "p2"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 AS p1, 20 AS p2); + +# +# Bug#22312 Syntax error in expression with INTERVAL() +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE; +SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE; +SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND; +SELECT 1 + INTERVAL(1,0,1,2) + 1; +SELECT INTERVAL(1^1,0,1,2) + 1; +SELECT INTERVAL(1,0+1,2,3) * 5.5; +SELECT INTERVAL(3,3,1+3,4+4) / 0.5; +SELECT (INTERVAL(1,0,1,2) + 5) * 7 + INTERVAL(1,0,1,2) / 2; +SELECT INTERVAL(1,0,1,2) + 1, 5 * INTERVAL(1,0,1,2); +SELECT INTERVAL(0,(1*5)/2) + INTERVAL(5,4,3); + +--disable_warnings +SELECT 1^1 + INTERVAL 1+1 SECOND & 1 + INTERVAL 1+1 SECOND; +SELECT 1%2 - INTERVAL 1^1 SECOND | 1%2 - INTERVAL 1^1 SECOND; +--enable_warnings + +CREATE TABLE t1 (a INT, b DATETIME); +INSERT INTO t1 VALUES (INTERVAL(3,2,1) + 1, "1997-12-31 23:59:59" + INTERVAL 1 SECOND); +SELECT * FROM t1 WHERE a = INTERVAL(3,2,1) + 1; +DROP TABLE t1; + +# +# Bug#28317 Left Outer Join with {oj outer-join} +# + +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3; +--enable_warnings +CREATE TABLE t1 (a1 INT, a2 INT, a3 INT, a4 DATETIME); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 LIKE t1; +SELECT t1.* FROM t1 AS t0, { OJ t2 INNER JOIN t1 ON (t1.a1=t2.a1) } WHERE t0.a3=2; +SELECT t1.*,t2.* FROM { OJ ((t1 INNER JOIN t2 ON (t1.a1=t2.a2)) LEFT OUTER JOIN t3 ON t3.a3=t2.a1)}; +SELECT t1.*,t2.* FROM { OJ ((t1 LEFT OUTER JOIN t2 ON t1.a3=t2.a2) INNER JOIN t3 ON (t3.a1=t2.a2))}; +SELECT t1.*,t2.* FROM { OJ (t1 LEFT OUTER JOIN t2 ON t1.a1=t2.a2) CROSS JOIN t3 ON (t3.a2=t2.a3)}; +SELECT * FROM {oj t1 LEFT OUTER JOIN t2 ON t1.a1=t2.a3} WHERE t1.a2 > 10; +SELECT {fn CONCAT(a1,a2)} FROM t1; +UPDATE t3 SET a4={d '1789-07-14'} WHERE a1=0; +SELECT a1, a4 FROM t2 WHERE a4 LIKE {fn UCASE('1789-07-14')}; +DROP TABLE t1, t2, t3; + +--echo # +--echo # End of 5.1 tests +--echo # diff --git a/mysql-test/t/parser_bug21114_innodb.test b/mysql-test/t/parser_bug21114_innodb.test new file mode 100644 index 00000000000..969eea2da40 --- /dev/null +++ b/mysql-test/t/parser_bug21114_innodb.test @@ -0,0 +1,422 @@ +-- source include/have_innodb.inc + +let $engine_type=InnoDb; + +# +# Bug#21114 (Foreign key creation fails to table with name format) +# + +# Testing with the full log for only a few functions, +# including FORMAT for witch the bug was reported. + +let $verbose=1; + +let $FCT=abs; +-- source include/parser_bug21114.inc +let $FCT=field; +-- source include/parser_bug21114.inc +let $FCT=format; +-- source include/parser_bug21114.inc + +# Ignoring the result of SHOW CREATE (this generates too much noise) +# Tests will fail if the create table statement can not be parsed + +let verbose=0; + +let $FCT=acos; +-- source include/parser_bug21114.inc +let $FCT=adddate; +-- source include/parser_bug21114.inc +let $FCT=addtime; +-- source include/parser_bug21114.inc +let $FCT=aes_decrypt; +-- source include/parser_bug21114.inc +let $FCT=aes_encrypt; +-- source include/parser_bug21114.inc +let $FCT=area; +-- source include/parser_bug21114.inc +let $FCT=asbinary; +-- source include/parser_bug21114.inc +let $FCT=asin; +-- source include/parser_bug21114.inc +let $FCT=astext; +-- source include/parser_bug21114.inc +let $FCT=aswkb; +-- source include/parser_bug21114.inc +let $FCT=aswkt; +-- source include/parser_bug21114.inc +let $FCT=atan; +-- source include/parser_bug21114.inc +let $FCT=atan2; +-- source include/parser_bug21114.inc +let $FCT=benchmark; +-- source include/parser_bug21114.inc +let $FCT=bin; +-- source include/parser_bug21114.inc +let $FCT=bit_count; +-- source include/parser_bug21114.inc +let $FCT=bit_length; +-- source include/parser_bug21114.inc +let $FCT=ceil; +-- source include/parser_bug21114.inc +let $FCT=ceiling; +-- source include/parser_bug21114.inc +let $FCT=centroid; +-- source include/parser_bug21114.inc +let $FCT=character_length; +-- source include/parser_bug21114.inc +let $FCT=char_length; +-- source include/parser_bug21114.inc +let $FCT=coercibility; +-- source include/parser_bug21114.inc +let $FCT=compress; +-- source include/parser_bug21114.inc +let $FCT=concat; +-- source include/parser_bug21114.inc +let $FCT=concat_ws; +-- source include/parser_bug21114.inc +let $FCT=connection_id; +-- source include/parser_bug21114.inc +let $FCT=conv; +-- source include/parser_bug21114.inc +let $FCT=convert_tz; +-- source include/parser_bug21114.inc +let $FCT=cos; +-- source include/parser_bug21114.inc +let $FCT=cot; +-- source include/parser_bug21114.inc +let $FCT=crc32; +-- source include/parser_bug21114.inc +let $FCT=crosses; +-- source include/parser_bug21114.inc +let $FCT=datediff; +-- source include/parser_bug21114.inc +let $FCT=date_format; +-- source include/parser_bug21114.inc +let $FCT=dayname; +-- source include/parser_bug21114.inc +let $FCT=dayofmonth; +-- source include/parser_bug21114.inc +let $FCT=dayofweek; +-- source include/parser_bug21114.inc +let $FCT=dayofyear; +-- source include/parser_bug21114.inc +let $FCT=decode; +-- source include/parser_bug21114.inc +let $FCT=degrees; +-- source include/parser_bug21114.inc +let $FCT=des_decrypt; +-- source include/parser_bug21114.inc +let $FCT=des_encrypt; +-- source include/parser_bug21114.inc +let $FCT=dimension; +-- source include/parser_bug21114.inc +let $FCT=disjoint; +-- source include/parser_bug21114.inc +let $FCT=elt; +-- source include/parser_bug21114.inc +let $FCT=encode; +-- source include/parser_bug21114.inc +let $FCT=encrypt; +-- source include/parser_bug21114.inc +let $FCT=endpoint; +-- source include/parser_bug21114.inc +let $FCT=envelope; +-- source include/parser_bug21114.inc +let $FCT=equals; +-- source include/parser_bug21114.inc +let $FCT=exp; +-- source include/parser_bug21114.inc +let $FCT=export_set; +-- source include/parser_bug21114.inc +let $FCT=exteriorring; +-- source include/parser_bug21114.inc +let $FCT=extractvalue; +-- source include/parser_bug21114.inc +let $FCT=find_in_set; +-- source include/parser_bug21114.inc +let $FCT=floor; +-- source include/parser_bug21114.inc +let $FCT=found_rows; +-- source include/parser_bug21114.inc +let $FCT=from_days; +-- source include/parser_bug21114.inc +let $FCT=from_unixtime; +-- source include/parser_bug21114.inc +let $FCT=geomcollfromtext; +-- source include/parser_bug21114.inc +let $FCT=geomcollfromwkb; +-- source include/parser_bug21114.inc +let $FCT=geometrycollectionfromtext; +-- source include/parser_bug21114.inc +let $FCT=geometrycollectionfromwkb; +-- source include/parser_bug21114.inc +let $FCT=geometryfromtext; +-- source include/parser_bug21114.inc +let $FCT=geometryfromwkb; +-- source include/parser_bug21114.inc +let $FCT=geometryn; +-- source include/parser_bug21114.inc +let $FCT=geometrytype; +-- source include/parser_bug21114.inc +let $FCT=geomfromtext; +-- source include/parser_bug21114.inc +let $FCT=geomfromwkb; +-- source include/parser_bug21114.inc +let $FCT=get_lock; +-- source include/parser_bug21114.inc +let $FCT=glength; +-- source include/parser_bug21114.inc +let $FCT=greatest; +-- source include/parser_bug21114.inc +let $FCT=hex; +-- source include/parser_bug21114.inc +let $FCT=ifnull; +-- source include/parser_bug21114.inc +let $FCT=inet_aton; +-- source include/parser_bug21114.inc +let $FCT=inet_ntoa; +-- source include/parser_bug21114.inc +let $FCT=instr; +-- source include/parser_bug21114.inc +let $FCT=interiorringn; +-- source include/parser_bug21114.inc +let $FCT=intersects; +-- source include/parser_bug21114.inc +let $FCT=isclosed; +-- source include/parser_bug21114.inc +let $FCT=isempty; +-- source include/parser_bug21114.inc +let $FCT=isnull; +-- source include/parser_bug21114.inc +let $FCT=issimple; +-- source include/parser_bug21114.inc +let $FCT=is_free_lock; +-- source include/parser_bug21114.inc +let $FCT=is_used_lock; +-- source include/parser_bug21114.inc +let $FCT=last_day; +-- source include/parser_bug21114.inc +let $FCT=last_insert_id; +-- source include/parser_bug21114.inc +let $FCT=lcase; +-- source include/parser_bug21114.inc +let $FCT=least; +-- source include/parser_bug21114.inc +let $FCT=length; +-- source include/parser_bug21114.inc +let $FCT=linefromtext; +-- source include/parser_bug21114.inc +let $FCT=linefromwkb; +-- source include/parser_bug21114.inc +let $FCT=linestringfromtext; +-- source include/parser_bug21114.inc +let $FCT=linestringfromwkb; +-- source include/parser_bug21114.inc +let $FCT=ln; +-- source include/parser_bug21114.inc +let $FCT=load_file; +-- source include/parser_bug21114.inc +let $FCT=locate; +-- source include/parser_bug21114.inc +let $FCT=log; +-- source include/parser_bug21114.inc +let $FCT=log10; +-- source include/parser_bug21114.inc +let $FCT=log2; +-- source include/parser_bug21114.inc +let $FCT=lower; +-- source include/parser_bug21114.inc +let $FCT=lpad; +-- source include/parser_bug21114.inc +let $FCT=ltrim; +-- source include/parser_bug21114.inc +let $FCT=makedate; +-- source include/parser_bug21114.inc +let $FCT=maketime; +-- source include/parser_bug21114.inc +let $FCT=make_set; +-- source include/parser_bug21114.inc +let $FCT=master_pos_wait; +-- source include/parser_bug21114.inc +let $FCT=mbrcontains; +-- source include/parser_bug21114.inc +let $FCT=mbrdisjoint; +-- source include/parser_bug21114.inc +let $FCT=mbrequal; +-- source include/parser_bug21114.inc +let $FCT=mbrintersects; +-- source include/parser_bug21114.inc +let $FCT=mbroverlaps; +-- source include/parser_bug21114.inc +let $FCT=mbrtouches; +-- source include/parser_bug21114.inc +let $FCT=mbrwithin; +-- source include/parser_bug21114.inc +let $FCT=md5; +-- source include/parser_bug21114.inc +let $FCT=mlinefromtext; +-- source include/parser_bug21114.inc +let $FCT=mlinefromwkb; +-- source include/parser_bug21114.inc +let $FCT=monthname; +-- source include/parser_bug21114.inc +let $FCT=mpointfromtext; +-- source include/parser_bug21114.inc +let $FCT=mpointfromwkb; +-- source include/parser_bug21114.inc +let $FCT=mpolyfromtext; +-- source include/parser_bug21114.inc +let $FCT=mpolyfromwkb; +-- source include/parser_bug21114.inc +let $FCT=multilinestringfromtext; +-- source include/parser_bug21114.inc +let $FCT=multilinestringfromwkb; +-- source include/parser_bug21114.inc +let $FCT=multipointfromtext; +-- source include/parser_bug21114.inc +let $FCT=multipointfromwkb; +-- source include/parser_bug21114.inc +let $FCT=multipolygonfromtext; +-- source include/parser_bug21114.inc +let $FCT=multipolygonfromwkb; +-- source include/parser_bug21114.inc +let $FCT=name_const; +-- source include/parser_bug21114.inc +let $FCT=nullif; +-- source include/parser_bug21114.inc +let $FCT=numgeometries; +-- source include/parser_bug21114.inc +let $FCT=numinteriorrings; +-- source include/parser_bug21114.inc +let $FCT=numpoints; +-- source include/parser_bug21114.inc +let $FCT=oct; +-- source include/parser_bug21114.inc +let $FCT=octet_length; +-- source include/parser_bug21114.inc +let $FCT=ord; +-- source include/parser_bug21114.inc +let $FCT=overlaps; +-- source include/parser_bug21114.inc +let $FCT=period_add; +-- source include/parser_bug21114.inc +let $FCT=period_diff; +-- source include/parser_bug21114.inc +let $FCT=pi; +-- source include/parser_bug21114.inc +let $FCT=pointfromtext; +-- source include/parser_bug21114.inc +let $FCT=pointfromwkb; +-- source include/parser_bug21114.inc +let $FCT=pointn; +-- source include/parser_bug21114.inc +let $FCT=polyfromtext; +-- source include/parser_bug21114.inc +let $FCT=polyfromwkb; +-- source include/parser_bug21114.inc +let $FCT=polygonfromtext; +-- source include/parser_bug21114.inc +let $FCT=polygonfromwkb; +-- source include/parser_bug21114.inc +let $FCT=pow; +-- source include/parser_bug21114.inc +let $FCT=power; +-- source include/parser_bug21114.inc +let $FCT=quote; +-- source include/parser_bug21114.inc +let $FCT=radians; +-- source include/parser_bug21114.inc +let $FCT=rand; +-- source include/parser_bug21114.inc +let $FCT=release_lock; +-- source include/parser_bug21114.inc +let $FCT=reverse; +-- source include/parser_bug21114.inc +let $FCT=round; +-- source include/parser_bug21114.inc +let $FCT=row_count; +-- source include/parser_bug21114.inc +let $FCT=rpad; +-- source include/parser_bug21114.inc +let $FCT=rtrim; +-- source include/parser_bug21114.inc +let $FCT=sec_to_time; +-- source include/parser_bug21114.inc +let $FCT=session_user; +-- source include/parser_bug21114.inc +let $FCT=sha; +-- source include/parser_bug21114.inc +let $FCT=sha1; +-- source include/parser_bug21114.inc +let $FCT=sign; +-- source include/parser_bug21114.inc +let $FCT=sin; +-- source include/parser_bug21114.inc +let $FCT=sleep; +-- source include/parser_bug21114.inc +let $FCT=soundex; +-- source include/parser_bug21114.inc +let $FCT=space; +-- source include/parser_bug21114.inc +let $FCT=sqrt; +-- source include/parser_bug21114.inc +let $FCT=srid; +-- source include/parser_bug21114.inc +let $FCT=startpoint; +-- source include/parser_bug21114.inc +let $FCT=strcmp; +-- source include/parser_bug21114.inc +let $FCT=str_to_date; +-- source include/parser_bug21114.inc +let $FCT=subdate; +-- source include/parser_bug21114.inc +let $FCT=substring_index; +-- source include/parser_bug21114.inc +let $FCT=subtime; +-- source include/parser_bug21114.inc +let $FCT=system_user; +-- source include/parser_bug21114.inc +let $FCT=tan; +-- source include/parser_bug21114.inc +let $FCT=timediff; +-- source include/parser_bug21114.inc +let $FCT=time_format; +-- source include/parser_bug21114.inc +let $FCT=time_to_sec; +-- source include/parser_bug21114.inc +let $FCT=touches; +-- source include/parser_bug21114.inc +let $FCT=to_days; +-- source include/parser_bug21114.inc +let $FCT=ucase; +-- source include/parser_bug21114.inc +let $FCT=uncompress; +-- source include/parser_bug21114.inc +let $FCT=uncompressed_length; +-- source include/parser_bug21114.inc +let $FCT=unhex; +-- source include/parser_bug21114.inc +let $FCT=unix_timestamp; +-- source include/parser_bug21114.inc +let $FCT=updatexml; +-- source include/parser_bug21114.inc +let $FCT=upper; +-- source include/parser_bug21114.inc +let $FCT=uuid; +-- source include/parser_bug21114.inc +let $FCT=version; +-- source include/parser_bug21114.inc +let $FCT=weekday; +-- source include/parser_bug21114.inc +let $FCT=weekofyear; +-- source include/parser_bug21114.inc +let $FCT=within; +-- source include/parser_bug21114.inc +let $FCT=x; +-- source include/parser_bug21114.inc +let $FCT=y; +-- source include/parser_bug21114.inc +let $FCT=yearweek; +-- source include/parser_bug21114.inc + diff --git a/mysql-test/t/parser_not_embedded.test b/mysql-test/t/parser_not_embedded.test new file mode 100644 index 00000000000..8ebeb9a8301 --- /dev/null +++ b/mysql-test/t/parser_not_embedded.test @@ -0,0 +1,26 @@ +--source include/not_embedded.inc + +########################################################################### +--echo # +--echo # Bug#39559: dump of stored procedures / functions with C-style +--echo # comment can't be read back +--echo # + +--write_file $MYSQLTEST_VARDIR/tmp/bug39559.sql +select 2 as expected, /*!01000/**/*/ 2 as result; +select 1 as expected, /*!99998/**/*/ 1 as result; +select 3 as expected, /*!01000 1 + */ 2 as result; +select 2 as expected, /*!99990 1 + */ 2 as result; +select 7 as expected, /*!01000 1 + /* 8 + */ 2 + */ 4 as result; +select 8 as expected, /*!99998 1 + /* 2 + */ 4 + */ 8 as result; +select 7 as expected, /*!01000 1 + /*!01000 8 + */ 2 + */ 4 as result; +select 7 as expected, /*!01000 1 + /*!99998 8 + */ 2 + */ 4 as result; +select 4 as expected, /*!99998 1 + /*!99998 8 + */ 2 + */ 4 as result; +select 4 as expected, /*!99998 1 + /*!01000 8 + */ 2 + */ 4 as result; +select 7 as expected, /*!01000 1 + /*!01000 8 + /*!01000 error */ 16 + */ 2 + */ 4 as result; +select 4 as expected, /* 1 + /*!01000 8 + */ 2 + */ 4; +EOF + +--exec $MYSQL --comment --force --table test <$MYSQLTEST_VARDIR/tmp/bug39559.sql +--remove_file $MYSQLTEST_VARDIR/tmp/bug39559.sql + diff --git a/mysql-test/t/partition-master.opt b/mysql-test/t/partition-master.opt new file mode 100644 index 00000000000..b1392bfd485 --- /dev/null +++ b/mysql-test/t/partition-master.opt @@ -0,0 +1 @@ +--symbolic-links=1 diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test new file mode 100644 index 00000000000..1dfc53c6232 --- /dev/null +++ b/mysql-test/t/partition.test @@ -0,0 +1,2061 @@ +#--disable_abort_on_error +# +# Simple test for the partition storage engine +# taken from the select test. +# +# Last update: +# 2007-10-22 mleich - Move ARCHIVE, BLACKHOLE and CSV related sub tests to +# new tests. Reason: All these might be not available. +# - Minor cleanup +# +--source include/have_partition.inc + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +# +# Bug#46639: 1030 (HY000): Got error 124 from storage engine on +# INSERT ... SELECT ... +CREATE TABLE t1 ( + a int NOT NULL, + b int NOT NULL); + +CREATE TABLE t2 ( + a int NOT NULL, + b int NOT NULL, + INDEX(b) +) +PARTITION BY HASH(a) PARTITIONS 2; + +INSERT INTO t1 VALUES (399, 22); +INSERT INTO t2 VALUES (1, 22), (1, 42); + +INSERT INTO t2 SELECT 1, 399 FROM t2, t1 +WHERE t1.b = t2.b; + +DROP TABLE t1, t2; + +# +# Bug#46478: timestamp field incorrectly defaulted when partition is reorganized +# +CREATE TABLE t1 ( + a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + b varchar(10), + PRIMARY KEY (a) +) +PARTITION BY RANGE (to_days(a)) ( + PARTITION p1 VALUES LESS THAN (733407), + PARTITION pmax VALUES LESS THAN MAXVALUE +); + +INSERT INTO t1 VALUES ('2007-07-30 17:35:48', 'p1'); +INSERT INTO t1 VALUES ('2009-07-14 17:35:55', 'pmax'); +INSERT INTO t1 VALUES ('2009-09-21 17:31:42', 'pmax'); + +SELECT * FROM t1; +ALTER TABLE t1 REORGANIZE PARTITION pmax INTO ( + PARTITION p3 VALUES LESS THAN (733969), + PARTITION pmax VALUES LESS THAN MAXVALUE); +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# +# Bug#44059: rec_per_key on empty partition gives weird optimiser results +# +create table t1 (a int, b int, key(a)) +partition by list (a) +( partition p0 values in (1), + partition p1 values in (2)); +insert into t1 values (1,1),(2,1),(2,2),(2,3); +show indexes from t1; +analyze table t1; +show indexes from t1; +drop table t1; + +# +# Bug#36001: Partitions: spelling and using some error messages +# +--error ER_FOREIGN_KEY_ON_PARTITIONED +CREATE TABLE t1 (a INT, FOREIGN KEY (a) REFERENCES t0 (a)) +ENGINE=MyISAM +PARTITION BY HASH (a); + +# +# Bug#40954: Crash if range search and order by. +# +CREATE TABLE t1 ( + pk INT NOT NULL AUTO_INCREMENT, + PRIMARY KEY (pk) +) +/*!50100 PARTITION BY HASH (pk) +PARTITIONS 2 */; +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM t1 WHERE pk < 0 ORDER BY pk; +DROP TABLE t1; + +# +# Bug#40494: Crash MYSQL server crashes on range access with partitioning +# and order by +# +CREATE TABLE t1 (a INT NOT NULL, KEY(a)) +PARTITION BY RANGE(a) +(PARTITION p1 VALUES LESS THAN (200), PARTITION pmax VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (2), (40), (40), (70), (60), (90), (199); +SELECT a FROM t1 WHERE a BETWEEN 60 AND 95 ORDER BY a ASC; +--sorted_result +SELECT a FROM t1 WHERE a BETWEEN 60 AND 95; +INSERT INTO t1 VALUES (200), (250), (210); +SELECT a FROM t1 WHERE a BETWEEN 60 AND 220 ORDER BY a ASC; +SELECT a FROM t1 WHERE a BETWEEN 200 AND 220 ORDER BY a ASC; +SELECT a FROM t1 WHERE a BETWEEN 60 AND 95 ORDER BY a DESC; +SELECT a FROM t1 WHERE a BETWEEN 60 AND 220 ORDER BY a DESC; +SELECT a FROM t1 WHERE a BETWEEN 200 AND 220 ORDER BY a DESC; +--sorted_result +SELECT a FROM t1 WHERE a BETWEEN 60 AND 220; +--sorted_result +SELECT a FROM t1 WHERE a BETWEEN 200 AND 220; +--sorted_result +SELECT a FROM t1 WHERE a BETWEEN 60 AND 95; +--sorted_result +SELECT a FROM t1 WHERE a BETWEEN 60 AND 220; +--sorted_result +SELECT a FROM t1 WHERE a BETWEEN 200 AND 220; +DROP TABLE t1; + +# +# Bug35931: Index search may return duplicates +# +CREATE TABLE t1 ( + a INT NOT NULL, + b MEDIUMINT NOT NULL, + c INT NOT NULL, + KEY b (b) +) ENGINE=MyISAM +PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (1) +); +INSERT INTO t1 VALUES (1,1,0), (1,1,1), (1,1,2), (1,1,53), (1,1,4), (1,1,5), +(1,1,6), (1,1,7), (1,1,8), (1,1,9), (1,1,10), (1,1,11), (1,1,12), (1,1,13), +(1,1,14), (1,1,15), (1,1,16), (1,1,67), (1,1,18), (1,1,19), (1,1,20), (1,1,21), +(1,1,22), (1,1,23), (1,1,24), (1,1,75), (1,1,26), (1,1,27), (1,1,128), +(1,1,79), (1,1,30), (1,1,31), (1,1,32), (1,1,33), (1,1,34), (1,1,85), (1,1,36), +(1,1,37), (1,1,38), (1,1,39), (1,1,40), (1,1,241), (1,1,42), (1,1,43), +(1,1,44), (1,1,45), (1,1,46), (1,1,147), (1,1,48), (1,1,49), (1,2,0), (1,2,1), +(1,2,2), (1,2,3), (1,2,4), (1,2,5), (1,2,6), (1,2,7), (1,2,8), (1,2,9), +(1,2,10), (1,2,11), (1,2,12), (1,2,13), (1,2,14), (1,2,15), (1,2,16), (1,2,17), +(1,2,18), (1,2,19), (1,2,20), (1,2,21), (1,2,22), (1,2,23), (1,2,24), (1,2,25), +(1,2,26), (1,2,27), (1,2,28), (1,2,29), (1,2,30), (1,2,31), (1,2,32), (1,2,33), +(1,2,34), (1,2,35), (1,2,36), (1,2,37), (1,2,38), (1,2,39), (1,2,40), (1,2,41), +(1,2,42), (1,2,43), (1,2,44), (1,2,45), (1,2,46), (1,2,47), (1,2,48), (1,2,49), +(1,6,0), (1,6,1), (1,6,2), (1,6,3), (1,6,4), (1,6,5), (1,6,6), (1,6,7), +(1,6,8), (1,6,9), (1,6,10), (1,6,11), (1,6,12), (1,6,13), (1,6,14), (1,6,15), +(1,6,16), (1,6,17), (1,6,18), (1,6,19), (1,6,20), (1,6,21), (1,6,22), (1,6,23), +(1,6,24), (1,6,25), (1,6,26), (1,6,27), (1,6,28), (1,6,29), (1,6,30), (1,6,31), +(1,6,32), (1,6,33), (1,6,34), (1,6,35), (1,6,36), (1,6,37), (1,6,38), (1,6,39), +(1,6,40), (1,6,41), (1,6,42), (1,6,43), (1,6,44), (1,6,45), (1,6,46), (1,6,47), +(1,6,48), (1,6,49), (1,7,0), (1,7,1), (1,7,2), (1,7,3), (1,7,4), (1,7,5), +(1,7,6), (1,7,7), (1,7,8), (1,7,9), (1,7,10), (1,7,11), (1,7,12), (1,7,13), +(1,7,14), (1,7,15), (1,7,16), (1,7,17), (1,7,18), (1,7,19), (1,7,20), (1,7,21), +(1,7,22), (1,7,23), (1,7,24), (1,7,25), (1,7,26), (1,7,27), (1,7,28), (1,7,29), + (1,7,30), (1,7,31), (1,7,32), (1,7,33), (1,7,34), (1,7,35), (1,7,38), (1,7,39), +(1,7,90), (1,7,41), (1,7,43), (1,7,48), (1,7,49), (1,9,0), (1,9,1), (1,9,2), +(1,9,3), (1,9,4), (1,9,5), (1,9,6), (1,9,7), (1,9,8), (1,9,9), (1,9,10), +(1,9,11), (1,9,12), (1,9,13), (1,9,14), (1,9,15), (1,9,16), (1,9,17), (1,9,18), +(1,9,19), (1,9,20), (1,9,21), (1,9,22), (1,9,23), (1,9,24), (1,9,25), (1,9,26), +(1,9,29), (1,9,32), (1,9,35), (1,9,38), (1,10,0), (1,10,1), (1,10,2), (1,10,3), +(1,10,4), (1,10,5), (1,10,6), (1,10,7), (1,10,8), (1,10,9), (1,10,10), +(1,10,11), (1,10,13), (1,10,14), (1,10,15), (1,10,16), (1,10,17), (1,10,18), +(1,10,22), (1,10,24), (1,10,25), (1,10,26), (1,10,28), (1,10,131), (1,10,33), +(1,10,84), (1,10,35), (1,10,40), (1,10,42), (1,10,49), (1,11,0), (1,11,1), +(1,11,2), (1,11,3), (1,11,4), (1,11,5), (1,11,6), (1,11,7), (1,11,8), (1,11,9), +(1,11,10), (1,11,11), (1,11,12), (1,11,13), (1,11,14), (1,11,15), (1,11,16), +(1,11,17), (1,11,18), (1,11,19), (1,11,20), (1,11,21), (1,11,22), (1,11,23), +(1,11,24), (1,11,25), (1,11,26), (1,11,27), (1,11,28), (1,11,30), (1,11,31), +(1,11,32), (1,11,33), (1,11,34), (1,11,35), (1,11,37), (1,11,39), (1,11,40), +(1,11,42), (1,11,44), (1,11,45), (1,11,47), (1,11,48), (1,14,104), (1,14,58), +(1,14,12), (1,14,13), (1,14,15), (1,14,16), (1,14,17), (1,14,34), (1,15,0), +(1,15,1), (1,15,2), (1,15,3), (1,15,4), (1,15,5), (1,15,7), (1,15,9), +(1,15,15), (1,15,27), (1,15,49), (1,16,0), (1,16,1), (1,16,3), (1,17,4), +(1,19,1); +SELECT COUNT(*) FROM t1 WHERE b NOT IN ( 1,2,6,7,9,10,11 ); +SELECT SUM(c) FROM t1 WHERE b NOT IN ( 1,2,6,7,9,10,11 ); +ALTER TABLE t1 DROP INDEX b; +SELECT COUNT(*) FROM t1 WHERE b NOT IN ( 1,2,6,7,9,10,11 ); +SELECT SUM(c) FROM t1 WHERE b NOT IN ( 1,2,6,7,9,10,11 ); +ALTER TABLE t1 ENGINE = Memory; +SELECT COUNT(*) FROM t1 WHERE b NOT IN ( 1,2,6,7,9,10,11 ); +SELECT SUM(c) FROM t1 WHERE b NOT IN ( 1,2,6,7,9,10,11 ); +ALTER TABLE t1 ADD INDEX b USING HASH (b); +SELECT COUNT(*) FROM t1 WHERE b NOT IN ( 1,2,6,7,9,10,11 ); +SELECT SUM(c) FROM t1 WHERE b NOT IN ( 1,2,6,7,9,10,11 ); +DROP TABLE t1; + +# Bug#37327 Range scan on partitioned table returns duplicate rows +# (Duplicate of Bug#35931) +CREATE TABLE `t1` ( + `c1` int(11) DEFAULT NULL, + KEY `c1` (`c1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +CREATE TABLE `t2` ( + `c1` int(11) DEFAULT NULL, + KEY `c1` (`c1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (c1) (PARTITION a VALUES LESS THAN (100) ENGINE = MyISAM, PARTITION b VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */; + +INSERT INTO `t1` VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); +INSERT INTO `t2` VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); + +EXPLAIN PARTITIONS SELECT c1 FROM t1 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20); + +FLUSH STATUS; +SELECT c1 FROM t1 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20); +SHOW STATUS LIKE 'Handler_read_%'; + +EXPLAIN PARTITIONS SELECT c1 FROM t2 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20); + +FLUSH STATUS; +SELECT c1 FROM t2 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20); +SHOW STATUS LIKE 'Handler_read_%'; +DROP TABLE t1,t2; + +# Bug#37329 Range scan on partitioned tables shows higher Handler_read_next +# (marked as duplicate of Bug#35931) +CREATE TABLE `t1` ( + `c1` int(11) DEFAULT NULL, + KEY `c1` (`c1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +CREATE TABLE `t2` ( + `c1` int(11) DEFAULT NULL, + KEY `c1` (`c1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (c1) +(PARTITION a VALUES LESS THAN (100) ENGINE = MyISAM, + PARTITION b VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */; + +INSERT INTO `t1` VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); +INSERT INTO `t2` VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); + +EXPLAIN PARTITIONS SELECT c1 FROM t1 WHERE (c1 > 2 AND c1 < 5); + +FLUSH STATUS; +SELECT c1 FROM t1 WHERE (c1 > 2 AND c1 < 5); +SHOW STATUS LIKE 'Handler_read_%'; + +EXPLAIN PARTITIONS SELECT c1 FROM t2 WHERE (c1 > 2 AND c1 < 5); + +FLUSH STATUS; +SELECT c1 FROM t2 WHERE (c1 > 2 AND c1 < 5); +SHOW STATUS LIKE 'Handler_read_%'; + +EXPLAIN PARTITIONS SELECT c1 FROM t1 WHERE (c1 > 12 AND c1 < 15); + +FLUSH STATUS; +SELECT c1 FROM t1 WHERE (c1 > 12 AND c1 < 15); +SHOW STATUS LIKE 'Handler_read_%'; + +EXPLAIN PARTITIONS SELECT c1 FROM t2 WHERE (c1 > 12 AND c1 < 15); + +FLUSH STATUS; +SELECT c1 FROM t2 WHERE (c1 > 12 AND c1 < 15); +SHOW STATUS LIKE 'Handler_read_%'; +DROP TABLE t1,t2; + +--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int) partition by list ((a/3)*10 div 1) +(partition p0 values in (0), partition p1 values in (1)); + +# +# Bug #30695: An apostrophe ' in the comment of the ADD PARTITION causes the Server to crash. +# +# To verify the fix for crashing (on unix-type OS) +# uncomment the exec and error rows! + +CREATE TABLE t1 ( + d DATE NOT NULL +) +PARTITION BY RANGE( YEAR(d) ) ( + PARTITION p0 VALUES LESS THAN (1960), + PARTITION p1 VALUES LESS THAN (1970), + PARTITION p2 VALUES LESS THAN (1980), + PARTITION p3 VALUES LESS THAN (1990) +); + +ALTER TABLE t1 ADD PARTITION ( +PARTITION `p5` VALUES LESS THAN (2010) +COMMENT 'APSTART \' APEND' +); +#--exec sed 's/APSTART \\/APSTART /' var/master-data/test/t1.frm > tmpt1.frm && mv tmpt1.frm var/master-data/test/t1.frm +#--error ER_PARSE_ERROR +SELECT * FROM t1 LIMIT 1; + +DROP TABLE t1; + +# +# Bug 30878: crashing when alter an auto_increment non partitioned +# table to partitioned + +create table t1 (id int auto_increment, s1 int, primary key (id)); + +insert into t1 values (null,1); +insert into t1 values (null,6); + +-- sorted_result +select * from t1; + +alter table t1 partition by range (id) ( + partition p0 values less than (3), + partition p1 values less than maxvalue +); + +drop table t1; + +# +# Bug 15890: Strange number of partitions accepted +# +-- error ER_PARSE_ERROR +create table t1 (a int) +partition by key(a) +partitions 0.2+e1; +-- error ER_PARSE_ERROR +create table t1 (a int) +partition by key(a) +partitions -1; +-- error ER_PARSE_ERROR +create table t1 (a int) +partition by key(a) +partitions 1.5; +-- error ER_PARSE_ERROR +create table t1 (a int) +partition by key(a) +partitions 1e+300; + +# +# Bug 19309 Partitions: Crash if double procedural alter +# +create table t1 (a int) +partition by list (a) +(partition p0 values in (1)); + +create procedure pz() +alter table t1 engine = myisam; + +call pz(); +call pz(); +drop procedure pz; +drop table t1; + +# +# BUG 16002: Handle unsigned integer functions properly +# +--error ER_PARSE_ERROR +create table t1 (a bigint) +partition by range (a) +(partition p0 values less than (0xFFFFFFFFFFFFFFFF), + partition p1 values less than (10)); +--error ER_PARSE_ERROR +create table t1 (a bigint) +partition by list (a) +(partition p0 values in (0xFFFFFFFFFFFFFFFF), + partition p1 values in (10)); + +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (100), + partition p1 values less than MAXVALUE); +insert into t1 values (1); +drop table t1; + +create table t1 (a bigint unsigned) +partition by hash (a); +insert into t1 values (0xFFFFFFFFFFFFFFFD); +insert into t1 values (0xFFFFFFFFFFFFFFFE); +select * from t1 where (a + 1) < 10; +select * from t1 where (a + 1) > 10; +drop table t1; + +# +# Added test case +# +create table t1 (a int) +partition by key(a) +(partition p0 engine = MEMORY); +drop table t1; + +# +# BUG 19067 ALTER TABLE .. ADD PARTITION for subpartitioned table crashes +# +create table t1 (a int) +partition by range (a) +subpartition by key (a) +(partition p0 values less than (1)); +alter table t1 add partition (partition p1 values less than (2)); +show create table t1; +alter table t1 reorganize partition p1 into (partition p1 values less than (3)); +show create table t1; +drop table t1; + +# +# Partition by key no partition defined => OK +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by key (a); + +# +# Bug 13323: Select count(*) on empty table returns 2 +# +select count(*) from t1; + +# +# Test SHOW CREATE TABLE +# +show create table t1; + +drop table t1; +# +# Partition by key no partition, list of fields +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by key (a, b); + +drop table t1; +# +# Partition by key specified 3 partitions and defined 3 => ok +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by key (a) +partitions 3 +(partition x1, partition x2, partition x3); + +drop table t1; +# +# Partition by key specifying nodegroup +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by key (a) +partitions 3 +(partition x1 nodegroup 0, + partition x2 nodegroup 1, + partition x3 nodegroup 2); + +drop table t1; +# +# Partition by key specifying engine +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by key (a) +partitions 3 +(partition x1 engine myisam, + partition x2 engine myisam, + partition x3 engine myisam); + +drop table t1; +# +# Partition by key specifying tablespace +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by key (a) +partitions 3 +(partition x1 tablespace ts1, + partition x2 tablespace ts2, + partition x3 tablespace ts3); + +CREATE TABLE t2 LIKE t1; + +drop table t2; +drop table t1; + +# +# Partition by key list, basic +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a) +partitions 3 +(partition x1 values in (1,2,9,4) tablespace ts1, + partition x2 values in (3, 11, 5, 7) tablespace ts2, + partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3); + +drop table t1; +# +# Partition by key list, list function +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (b*a) +partitions 3 +(partition x1 values in (1,2,9,4) tablespace ts1, + partition x2 values in (3, 11, 5, 7) tablespace ts2, + partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3); + +drop table t1; + +# +# Partition by key list, list function, no spec of #partitions +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (b*a) +(partition x1 values in (1) tablespace ts1, + partition x2 values in (3, 11, 5, 7) tablespace ts2, + partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3); + +drop table t1; + +# +# Bug 13154: Insert crashes due to bad calculation of partition id +# for PARTITION BY KEY and SUBPARTITION BY KEY +# +CREATE TABLE t1 ( +a int not null) +partition by key(a); + +LOCK TABLES t1 WRITE; +insert into t1 values (1); +insert into t1 values (2); +insert into t1 values (3); +insert into t1 values (4); +UNLOCK TABLES; + +drop table t1; + +# +# Bug #13644 DROP PARTITION NULL's DATE column +# +CREATE TABLE t1 (a int, name VARCHAR(50), purchased DATE) +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (3), + PARTITION p1 VALUES LESS THAN (7), + PARTITION p2 VALUES LESS THAN (9), + PARTITION p3 VALUES LESS THAN (11)); +INSERT INTO t1 VALUES +(1, 'desk organiser', '2003-10-15'), +(2, 'CD player', '1993-11-05'), +(3, 'TV set', '1996-03-10'), +(4, 'bookcase', '1982-01-10'), +(5, 'exercise bike', '2004-05-09'), +(6, 'sofa', '1987-06-05'), +(7, 'popcorn maker', '2001-11-22'), +(8, 'acquarium', '1992-08-04'), +(9, 'study desk', '1984-09-16'), +(10, 'lava lamp', '1998-12-25'); + +SELECT * from t1 ORDER BY a; +ALTER TABLE t1 DROP PARTITION p0; +SELECT * from t1 ORDER BY a; + +drop table t1; + +# +# Bug #13442; Truncate Partitioned table doesn't work +# + +CREATE TABLE t1 (a int) +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (1,2,3), PARTITION p1 VALUES IN (4,5,6)); + +insert into t1 values (1),(2),(3),(4),(5),(6); +select * from t1; +truncate t1; +select * from t1; +truncate t1; +select * from t1; +drop table t1; + +# +# Bug #13445 Partition by KEY method crashes server +# +CREATE TABLE t1 (a int, b int, primary key(a,b)) +PARTITION BY KEY(b,a) PARTITIONS 4; + +insert into t1 values (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6); +select * from t1 where a = 4; + +drop table t1; + +# +# Bug#22351 - handler::index_next_same() call to key_cmp_if_same() +# uses the wrong buffer +# +CREATE TABLE t1 (c1 INT, c2 INT, PRIMARY KEY USING BTREE (c1,c2)) ENGINE=MEMORY + PARTITION BY KEY(c2,c1) PARTITIONS 4; +INSERT INTO t1 VALUES (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6); +SELECT * FROM t1 WHERE c1 = 4; +DROP TABLE t1; + +# +# Bug #13438: Engine clause in PARTITION clause causes crash +# +CREATE TABLE t1 (a int) +PARTITION BY LIST (a) +PARTITIONS 1 +(PARTITION x1 VALUES IN (1) ENGINE=MEMORY); + +show create table t1; +drop table t1; + +# +# Bug #13440: REPLACE causes crash in partitioned table +# +CREATE TABLE t1 (a int, unique(a)) +PARTITION BY LIST (a) +(PARTITION x1 VALUES IN (10), PARTITION x2 VALUES IN (20)); + +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +REPLACE t1 SET a = 4; +drop table t1; + +# +# Bug #14365: Crash if value too small in list partitioned table +# +CREATE TABLE t1 (a int) +PARTITION BY LIST (a) +(PARTITION x1 VALUES IN (2), PARTITION x2 VALUES IN (3)); + +insert into t1 values (2), (3); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +insert into t1 values (4); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +insert into t1 values (1); +drop table t1; + +# +# Bug 14327: PARTITIONS clause gets lost in SHOW CREATE TABLE +# +CREATE TABLE t1 (a int) +PARTITION BY HASH(a) +PARTITIONS 5; + +SHOW CREATE TABLE t1; + +drop table t1; + +# +# Bug #13446: Update to value outside of list values doesn't give error +# +CREATE TABLE t1 (a int) +PARTITION BY RANGE (a) +(PARTITION x1 VALUES LESS THAN (2)); + +insert into t1 values (1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +update t1 set a = 5; + +drop table t1; + +# +# Bug #13441: Analyze on partitioned table didn't work +# +CREATE TABLE t1 (a int) +PARTITION BY LIST (a) +(PARTITION x1 VALUES IN (10), PARTITION x2 VALUES IN (20)); + +analyze table t1; + +drop table t1; + +# +# BUG 15221 (Cannot reorganize with the same name) +# +create table t1 +(a int) +partition by range (a) + ( partition p0 values less than(10), + partition p1 values less than (20), + partition p2 values less than (25)); + +alter table t1 reorganize partition p2 into (partition p2 values less than (30)); +show create table t1; +drop table t1; + +CREATE TABLE t1 (a int, b int) +PARTITION BY RANGE (a) +(PARTITION x0 VALUES LESS THAN (2), + PARTITION x1 VALUES LESS THAN (4), + PARTITION x2 VALUES LESS THAN (6), + PARTITION x3 VALUES LESS THAN (8), + PARTITION x4 VALUES LESS THAN (10), + PARTITION x5 VALUES LESS THAN (12), + PARTITION x6 VALUES LESS THAN (14), + PARTITION x7 VALUES LESS THAN (16), + PARTITION x8 VALUES LESS THAN (18), + PARTITION x9 VALUES LESS THAN (20)); + +ALTER TABLE t1 REORGANIZE PARTITION x0,x1,x2 INTO +(PARTITION x1 VALUES LESS THAN (6)); +show create table t1; +drop table t1; + +# Testcase for BUG#15819 +create table t1 (a int not null, b int not null) partition by LIST (a+b) ( + partition p0 values in (12), + partition p1 values in (14) +); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +insert into t1 values (10,1); + +drop table t1; + +# +# Bug#16901 Partitions: crash, SELECT, column of part. +# function=first column of primary key +# +create table t1 (f1 integer,f2 integer, f3 varchar(10), primary key(f1,f2)) +partition by range(f1) subpartition by hash(f2) subpartitions 2 +(partition p1 values less than (0), + partition p2 values less than (2), + partition p3 values less than (2147483647)); + +insert into t1 values(10,10,'10'); +insert into t1 values(2,2,'2'); +select * from t1 where f1 = 2; +drop table t1; + +# +# Bug #16907 Partitions: crash, SELECT goes into last partition, UNIQUE INDEX +# +create table t1 (f1 integer,f2 integer, unique index(f1)) +partition by range(f1 div 2) +subpartition by hash(f1) subpartitions 2 +(partition partb values less than (2), +partition parte values less than (4), +partition partf values less than (10000)); +insert into t1 values(10,1); +select * from t1 where f1 = 10; +drop table t1; + +# +# Bug #16775: Wrong engine type stored for subpartition +# +set session storage_engine= 'memory'; +create table t1 (f_int1 int(11) default null) engine = memory + partition by range (f_int1) subpartition by hash (f_int1) + (partition part1 values less than (1000) + (subpartition subpart11 engine = memory)); +drop table t1; +set session storage_engine='myisam'; + +# +# Bug #16782: Crash using REPLACE on table with primary key +# +create table t1 (f_int1 integer, f_int2 integer, primary key (f_int1)) + partition by hash(f_int1) partitions 2; +insert into t1 values (1,1),(2,2); +replace into t1 values (1,1),(2,2); +drop table t1; + +# +# Bug #17169: Partitions: out of memory if add partition and unique +# +create table t1 (s1 int, unique (s1)) partition by list (s1) (partition x1 VALUES in (10), partition x2 values in (20)); +alter table t1 add partition (partition x3 values in (30)); +drop table t1; + +# +# Bug #17754 Change to explicit removal of partitioning scheme +# Also added a number of tests to ensure that proper engine is +# choosen in all kinds of scenarios. +# + +create table t1 (a int) +partition by key(a) +partitions 2 +(partition p0 engine=myisam, partition p1 engine=myisam); +show create table t1; + +alter table t1; +show create table t1; + +alter table t1 engine=myisam; +show create table t1; + +alter table t1 engine=heap; +show create table t1; + +alter table t1 remove partitioning; +show create table t1; + +drop table t1; + +create table t1 (a int) +engine=myisam +partition by key(a) +partitions 2 +(partition p0 engine=myisam, partition p1 engine=myisam); +show create table t1; + +alter table t1 add column b int remove partitioning; +show create table t1; + +alter table t1 +engine=myisam +partition by key(a) +(partition p0 engine=myisam, partition p1); +show create table t1; + +alter table t1 +engine=heap +partition by key(a) +(partition p0, partition p1 engine=heap); +show create table t1; + +alter table t1 engine=myisam, add column c int remove partitioning; +show create table t1; + +alter table t1 +engine=heap +partition by key (a) +(partition p0, partition p1); +show create table t1; + +alter table t1 +partition by key (a) +(partition p0, partition p1); +show create table t1; + +alter table t1 +engine=heap +partition by key (a) +(partition p0, partition p1); +show create table t1; + +# Since alter, it already have ENGINE=HEAP from before on table level +# -> OK +alter table t1 +partition by key(a) +(partition p0, partition p1 engine=heap); + +# Since alter, it already have ENGINE=HEAP from before on table level +# -> OK +alter table t1 +partition by key(a) +(partition p0 engine=heap, partition p1); + +--error ER_MIX_HANDLER_ERROR +alter table t1 +engine=heap +partition by key (a) +(partition p0 engine=heap, partition p1 engine=myisam); + +--error ER_MIX_HANDLER_ERROR +alter table t1 +partition by key (a) +(partition p0 engine=heap, partition p1 engine=myisam); + +drop table t1; + +# Bug #17432: Partition functions containing NULL values should return +# LONGLONG_MIN +# +CREATE TABLE t1 ( + f_int1 INTEGER, f_int2 INTEGER, + f_char1 CHAR(10), f_char2 CHAR(10), f_charbig VARCHAR(1000) + ) + PARTITION BY RANGE(f_int1 DIV 2) + SUBPARTITION BY HASH(f_int1) + SUBPARTITIONS 2 + (PARTITION parta VALUES LESS THAN (0), + PARTITION partb VALUES LESS THAN (5), + PARTITION parte VALUES LESS THAN (10), + PARTITION partf VALUES LESS THAN (2147483647)); +INSERT INTO t1 SET f_int1 = NULL , f_int2 = -20, f_char1 = CAST(-20 AS CHAR), + f_char2 = CAST(-20 AS CHAR), f_charbig = '#NULL#'; +SELECT * FROM t1 WHERE f_int1 IS NULL; +SELECT * FROM t1; +drop table t1; + +# +# Bug 17430: Crash when SELECT * from t1 where field IS NULL +# + +CREATE TABLE t1 ( + f_int1 INTEGER, f_int2 INTEGER, + f_char1 CHAR(10), f_char2 CHAR(10), f_charbig VARCHAR(1000) ) + PARTITION BY LIST(MOD(f_int1,2)) + SUBPARTITION BY KEY(f_int1) + (PARTITION part1 VALUES IN (-1) (SUBPARTITION sp1, SUBPARTITION sp2), + PARTITION part2 VALUES IN (0) (SUBPARTITION sp3, SUBPARTITION sp5), + PARTITION part3 VALUES IN (1) (SUBPARTITION sp4, SUBPARTITION sp6)); + +INSERT INTO t1 SET f_int1 = 2, f_int2 = 2, f_char1 = '2', f_char2 = '2', f_charbig = '===2==='; +INSERT INTO t1 SET f_int1 = 2, f_int2 = 2, f_char1 = '2', f_char2 = '2', f_charbig = '===2==='; + +SELECT * FROM t1 WHERE f_int1 IS NULL; +drop table t1; + +# +# Bug#14363 Partitions: failure if create in stored procedure +# +delimiter //; + +create procedure p () +begin +create table t1 (s1 mediumint,s2 mediumint) +partition by list (s2) +(partition p1 values in (0), + partition p2 values in (1)); +end// + +call p()// +drop procedure p// +drop table t1; + +create procedure p () +begin +create table t1 (a int not null,b int not null,c int not null,primary key (a,b)) +partition by range (a) +subpartition by hash (a+b) +(partition x1 values less than (1) + (subpartition x11, + subpartition x12), + partition x2 values less than (5) + (subpartition x21, + subpartition x22)); +end// + +call p()// +drop procedure p// +drop table t1// +delimiter ;// + +# +# Bug #15447 Partitions: NULL is treated as zero +# + +# NULL for RANGE partition +create table t1 (a int,b int,c int,key(a,b)) +partition by range (a) +partitions 3 +(partition x1 values less than (0) tablespace ts1, + partition x2 values less than (10) tablespace ts2, + partition x3 values less than maxvalue tablespace ts3); + +insert into t1 values (NULL, 1, 1); +insert into t1 values (0, 1, 1); +insert into t1 values (12, 1, 1); + +select partition_name, partition_description, table_rows +from information_schema.partitions where table_schema ='test'; +drop table t1; + +# NULL for LIST partition +--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR +create table t1 (a int,b int, c int) +partition by list(a) +partitions 2 +(partition x123 values in (11,12), + partition x234 values in (1 ,NULL, NULL)); + +--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR +create table t1 (a int,b int, c int) +partition by list(a) +partitions 2 +(partition x123 values in (11, NULL), + partition x234 values in (1 ,NULL)); + +create table t1 (a int,b int, c int) +partition by list(a) +partitions 2 +(partition x123 values in (11, 12), + partition x234 values in (5, 1)); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +insert into t1 values (NULL,1,1); +drop table t1; + +create table t1 (a int,b int, c int) +partition by list(a) +partitions 2 +(partition x123 values in (11, 12), + partition x234 values in (NULL, 1)); + +insert into t1 values (11,1,6); +insert into t1 values (NULL,1,1); + +select partition_name, partition_description, table_rows +from information_schema.partitions where table_schema ='test'; +drop table t1; + +# +# BUG 17947 Crash with REBUILD PARTITION +# +create table t1 (a int) +partition by list (a) +(partition p0 values in (1)); + +--error ER_PARSE_ERROR +alter table t1 rebuild partition; + +drop table t1; + +# +# BUG 15253 Insert that should fail doesn't +# +create table t1 (a int) +partition by list (a) +(partition p0 values in (5)); + +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +insert into t1 values (0); + +drop table t1; + +# +# BUG #16370 Subpartitions names not shown in SHOW CREATE TABLE output +# +create table t1 (a int) +partition by range (a) subpartition by hash (a) +(partition p0 values less than (100)); + +show create table t1; +alter table t1 add partition (partition p1 values less than (200) +(subpartition subpart21)); + +show create table t1; + +drop table t1; + +create table t1 (a int) +partition by key (a); + +show create table t1; +alter table t1 add partition (partition p1); +show create table t1; + +drop table t1; + +# +# BUG 15407 Crash with subpartition +# +--error ER_PARSE_ERROR +create table t1 (a int, b int) +partition by range (a) +subpartition by hash(a) +(partition p0 values less than (0) (subpartition sp0), + partition p1 values less than (1)); + +--error ER_PARSE_ERROR +create table t1 (a int, b int) +partition by range (a) +subpartition by hash(a) +(partition p0 values less than (0), + partition p1 values less than (1) (subpartition sp0)); + +# +# Bug 46354 Crash with subpartition +# +--error ER_PARSE_ERROR +create table t1 (a int, b int) +partition by list (a) +subpartition by hash(a) +(partition p0 values in (0), + partition p1 values in (1) (subpartition sp0)); + + +# +# BUG 15961 No error when subpartition defined without subpartition by clause +# +--error ER_SUBPARTITION_ERROR +create table t1 (a int) +partition by hash (a) +(partition p0 (subpartition sp0)); + +# +# Bug 17127 +# +create table t1 (a int) +partition by range (a) +(partition p0 values less than (1)); + +--error ER_PARTITION_WRONG_VALUES_ERROR +alter table t1 add partition (partition p1 values in (2)); +--error ER_PARTITION_REQUIRES_VALUES_ERROR +alter table t1 add partition (partition p1); + +drop table t1; + +create table t1 (a int) +partition by list (a) +(partition p0 values in (1)); + +--error ER_PARTITION_WRONG_VALUES_ERROR +alter table t1 add partition (partition p1 values less than (2)); +--error ER_PARTITION_REQUIRES_VALUES_ERROR +alter table t1 add partition (partition p1); + +drop table t1; + +create table t1 (a int) +partition by hash (a) +(partition p0); + +--error ER_PARTITION_WRONG_VALUES_ERROR +alter table t1 add partition (partition p1 values less than (2)); +--error ER_PARTITION_WRONG_VALUES_ERROR +alter table t1 add partition (partition p1 values in (2)); + +drop table t1; + +# +# BUG 17947 Crash with REBUILD PARTITION +# +create table t1 (a int) +partition by list (a) +(partition p0 values in (1)); + +--error ER_PARSE_ERROR +alter table t1 rebuild partition; + +drop table t1; + +# +# Bug #14526: Partitions: indexed searches fail +# +create table t2 (s1 int not null auto_increment, primary key (s1)) partition by list (s1) (partition p1 values in (1),partition p2 values in (2),partition p3 values in (3),partition p4 values in (4)); +insert into t2 values (null),(null),(null); +select * from t2; +select * from t2 where s1 < 2; +update t2 set s1 = s1 + 1 order by s1 desc; +select * from t2 where s1 < 3; +select * from t2 where s1 = 2; +drop table t2; + +# +# Bug #17497: Partitions: crash if add partition on temporary table +# +--error ER_PARTITION_NO_TEMPORARY +create temporary table t1 (a int) partition by hash(a); + +# +# Bug #17097: Partitions: failing ADD PRIMARY KEY leads to temporary rotten +# metadata,crash +# +create table t1 (a int, b int) partition by list (a) + (partition p1 values in (1), partition p2 values in (2)); +--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF +alter table t1 add primary key (b); +show create table t1; +drop table t1; + +############################################ +# +# Author: Mikael Ronstrom +# Date: 2006-03-01 +# Purpose +# Bug 17772: Crash at ALTER TABLE with rename +# and add column + comment on +# partitioned table +# +############################################ +create table t1 (a int unsigned not null auto_increment primary key) +partition by key(a); +alter table t1 rename t2, add c char(10), comment "no comment"; +show create table t2; + +drop table t2; + +# +# Bug#15336 Partitions: crash if create table as select +# +create table t1 (f1 int) partition by hash (f1) as select 1; +drop table t1; + +# +# bug #14350 Partitions: crash if prepared statement +# +prepare stmt1 from 'create table t1 (s1 int) partition by hash (s1)'; +execute stmt1; +--error ER_TABLE_EXISTS_ERROR +execute stmt1; +drop table t1; + +# +# bug 17290 SP with delete, create and rollback to save point causes MySQLD core +# +delimiter |; +eval CREATE PROCEDURE test.p1(IN i INT) +BEGIN + DECLARE CONTINUE HANDLER FOR sqlexception BEGIN END; + DROP TABLE IF EXISTS t1; + CREATE TABLE t1 (num INT,PRIMARY KEY(num)); + START TRANSACTION; + INSERT INTO t1 VALUES(i); + savepoint t1_save; + INSERT INTO t1 VALUES (14); + ROLLBACK to savepoint t1_save; + COMMIT; +END| +delimiter ;| +CALL test.p1(12); +CALL test.p1(13); +drop table t1; +drop procedure test.p1; + +# +# Bug 13520: Problem with delimiters in COMMENT DATA DIRECTORY .. +# +CREATE TABLE t1 (a int not null) +partition by key(a) +(partition p0 COMMENT='first partition'); +drop table t1; + +# +# Bug 13433: Problem with delimited identifiers +# +CREATE TABLE t1 (`a b` int not null) +partition by key(`a b`); +drop table t1; + +CREATE TABLE t1 (`a b` int not null) +partition by hash(`a b`); +drop table t1; + +# +# Bug#18053 Partitions: crash if null +# Bug#18070 Partitions: wrong result on WHERE ... IS NULL +# +create table t1 (f1 integer) partition by range(f1) +(partition p1 values less than (0), partition p2 values less than (10)); +insert into t1 set f1 = null; +select * from t1 where f1 is null; +explain partitions select * from t1 where f1 is null; +drop table t1; + +create table t1 (f1 integer) partition by list(f1) +(partition p1 values in (1), partition p2 values in (null)); +insert into t1 set f1 = null; +insert into t1 set f1 = 1; +select * from t1 where f1 is null or f1 = 1; +drop table t1; + +create table t1 (f1 smallint) +partition by list (f1) (partition p0 values in (null)); +insert into t1 values (null); +select * from t1 where f1 is null; +select * from t1 where f1 < 1; +select * from t1 where f1 <= NULL; +select * from t1 where f1 < NULL; +select * from t1 where f1 >= NULL; +select * from t1 where f1 > NULL; +select * from t1 where f1 > 1; +drop table t1; + +create table t1 (f1 smallint) +partition by range (f1) (partition p0 values less than (0)); +insert into t1 values (null); +select * from t1 where f1 is null; +drop table t1; + +create table t1 (f1 integer) partition by list(f1) +( + partition p1 values in (1), + partition p2 values in (NULL), + partition p3 values in (2), + partition p4 values in (3), + partition p5 values in (4) +); + +insert into t1 values (1),(2),(3),(4),(null); +select * from t1 where f1 < 3; +explain partitions select * from t1 where f1 < 3; +select * from t1 where f1 is null; +explain partitions select * from t1 where f1 is null; +drop table t1; + +create table t1 (f1 int) partition by list(f1 div 2) +( + partition p1 values in (1), + partition p2 values in (NULL), + partition p3 values in (2), + partition p4 values in (3), + partition p5 values in (4) +); + +insert into t1 values (2),(4),(6),(8),(null); +select * from t1 where f1 < 3; +explain partitions select * from t1 where f1 < 3; +select * from t1 where f1 is null; +explain partitions select * from t1 where f1 is null; +drop table t1; + +create table t1 (a int) partition by LIST(a) ( + partition pn values in (NULL), + partition p0 values in (0), + partition p1 values in (1), + partition p2 values in (2) +); +insert into t1 values (NULL),(0),(1),(2); +select * from t1 where a is null or a < 2; +explain partitions select * from t1 where a is null or a < 2; +select * from t1 where a is null or a < 0 or a > 1; +explain partitions select * from t1 where a is null or a < 0 or a > 1; +drop table t1; + +# +#Bug# 17631 SHOW TABLE STATUS reports wrong engine +# +CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, name VARCHAR(20)) +ENGINE=MyISAM DEFAULT CHARSET=latin1 +PARTITION BY RANGE(id) +(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM, +PARTITION p1 VALUES LESS THAN (20) ENGINE = MyISAM, +PARTITION p2 VALUES LESS THAN (30) ENGINE = MyISAM); +--replace_column 6 0 7 0 8 0 9 0 12 NULL 13 NULL 14 NULL +SHOW TABLE STATUS; +DROP TABLE t1; + +# +#BUG 16002 Erroneus handling of unsigned partition functions +# +--error ER_PARTITION_CONST_DOMAIN_ERROR +create table t1 (a bigint unsigned) +partition by list (a) +(partition p0 values in (0-1)); + +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (10)); + +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +insert into t1 values (0xFFFFFFFFFFFFFFFF); + +drop table t1; + +# +#BUG 18750 Problems with partition names +# +create table t1 (a int) +partition by list (a) +(partition `s1 s2` values in (0)); +drop table t1; + +create table t1 (a int) +partition by list (a) +(partition `7` values in (0)); +drop table t1; + +--error ER_WRONG_PARTITION_NAME +create table t1 (a int) +partition by list (a) +(partition `s1 s2 ` values in (0)); + +--error ER_WRONG_PARTITION_NAME +create table t1 (a int) +partition by list (a) +subpartition by hash (a) +(partition p1 values in (0) (subpartition `p1 p2 `)); + +# +# BUG 18752 SHOW CREATE TABLE doesn't show NULL value in SHOW CREATE TABLE +# +CREATE TABLE t1 (a int) +PARTITION BY LIST (a) +(PARTITION p0 VALUES IN (NULL)); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--error ER_PARSE_ERROR +CREATE TABLE t1 (a int) +PARTITION BY RANGE(a) +(PARTITION p0 VALUES LESS THAN (NULL)); + +# +# Bug#18753 Partitions: auto_increment fails +# +create table t1 (s1 int auto_increment primary key) +partition by list (s1) +(partition p1 values in (1), + partition p2 values in (2), + partition p3 values in (3)); +insert into t1 values (null); +insert into t1 values (null); +insert into t1 values (null); +select auto_increment from information_schema.tables where table_name='t1'; +select * from t1; +drop table t1; + +# +# BUG 19140 Partitions: Create index for partitioned table crashes +# +create table t1 (a int) engine=memory +partition by key(a); +insert into t1 values (1); +create index inx1 on t1(a); +drop table t1; + +# +# Bug 19695 Partitions: SHOW CREATE TABLE shows table options even when it +# shouldn't +# +create table t1 (a int) +PARTITION BY KEY (a) +(PARTITION p0); +set session sql_mode='no_table_options'; +show create table t1; +set session sql_mode=''; +drop table t1; + +# +# BUG 19304 Partitions: MERGE handler not allowed in partitioned tables +# +--error ER_PARTITION_MERGE_ERROR +create table t1 (a int) +partition by key (a) +(partition p0 engine = MERGE); + +# +# BUG 19062 Partition clause ignored if CREATE TABLE ... AS SELECT ...; +# +create table t1 (a varchar(1)) +partition by key (a) +as select 'a'; + +show create table t1; +drop table t1; + +# +# BUG 19501 Partitions: SHOW TABLE STATUS shows wrong Data_free +# +CREATE TABLE t1 (a int) ENGINE = MYISAM PARTITION BY KEY(a); +INSERT into t1 values (1), (2); +--replace_column 9 0 12 NULL 13 NULL 14 NULL +SHOW TABLE STATUS; +DELETE from t1 where a = 1; +--replace_column 9 0 12 NULL 13 NULL 14 NULL +SHOW TABLE STATUS; +ALTER TABLE t1 OPTIMIZE PARTITION p0; +--replace_column 12 NULL 13 NULL 14 NULL +SHOW TABLE STATUS; +DROP TABLE t1; + +# +# BUG 19502: ENABLE/DISABLE Keys don't work for partitioned tables +# +CREATE TABLE t1 (a int, index(a)) PARTITION BY KEY(a); +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t1 ENABLE KEYS; +DROP TABLE t1; + +# +# Bug 17455 Partitions: Wrong message and error when using Repair/Optimize +# table on partitioned table +# (added check/analyze for gcov of Bug#20129) +create table t1 (a int) +engine=MEMORY +partition by key (a); + +REPAIR TABLE t1; +OPTIMIZE TABLE t1; +CHECK TABLE t1; +ANALYZE TABLE t1; + +drop table t1; + +# +#BUG 17138 Problem with stored procedure and analyze partition +# +--disable_warnings +drop procedure if exists mysqltest_1; +--enable_warnings + +create table t1 (a int) +partition by list (a) +(partition p0 values in (0)); + +insert into t1 values (0); +delimiter //; + +create procedure mysqltest_1 () +begin + begin + declare continue handler for sqlexception begin end; + update ignore t1 set a = 1 where a = 0; + end; + prepare stmt1 from 'alter table t1'; + execute stmt1; +end// + +call mysqltest_1()// +delimiter ;// +drop table t1; +drop procedure mysqltest_1; + +# +# Bug 20583 Partitions: Crash using index_last +# +create table t1 (a int, index(a)) +partition by hash(a); +insert into t1 values (1),(2); +select * from t1 ORDER BY a DESC; +drop table t1; + +# +# Bug 21388: Bigint fails to find record +# +create table t1 (a bigint unsigned not null, primary key(a)) +engine = myisam +partition by key (a) +partitions 10; + +show create table t1; +insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), +(18446744073709551613), (18446744073709551612); +select * from t1; +select * from t1 where a = 18446744073709551615; +delete from t1 where a = 18446744073709551615; +select * from t1; +drop table t1; + +# +# Bug 24502 reorganize partition closes connection +# +CREATE TABLE t1 ( + num int(11) NOT NULL, cs int(11) NOT NULL) +PARTITION BY RANGE (num) SUBPARTITION BY HASH ( +cs) SUBPARTITIONS 2 (PARTITION p_X VALUES LESS THAN MAXVALUE); + +ALTER TABLE t1 +REORGANIZE PARTITION p_X INTO ( + PARTITION p_100 VALUES LESS THAN (100), + PARTITION p_X VALUES LESS THAN MAXVALUE + ); + +drop table t1; + +# +# Bug #24186 (nested query across partitions returns fewer records) +# + +CREATE TABLE t2 ( + taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + id int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (id,taken), + KEY taken (taken) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +INSERT INTO t2 VALUES +('2006-09-27 21:50:01',16421), +('2006-10-02 21:50:01',16421), +('2006-09-27 21:50:01',19092), +('2006-09-28 21:50:01',19092), +('2006-09-29 21:50:01',19092), +('2006-09-30 21:50:01',19092), +('2006-10-01 21:50:01',19092), +('2006-10-02 21:50:01',19092), +('2006-09-27 21:50:01',22589), +('2006-09-29 21:50:01',22589); + +CREATE TABLE t1 ( + id int(8) NOT NULL, + PRIMARY KEY (id) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +INSERT INTO t1 VALUES +(16421), +(19092), +(22589); + +CREATE TABLE t4 ( + taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + id int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (id,taken), + KEY taken (taken) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +PARTITION BY RANGE (to_days(taken)) +( +PARTITION p01 VALUES LESS THAN (732920) , +PARTITION p02 VALUES LESS THAN (732950) , +PARTITION p03 VALUES LESS THAN MAXVALUE ) ; + +INSERT INTO t4 select * from t2; + +set @f_date='2006-09-28'; +set @t_date='2006-10-02'; + +SELECT t1.id AS MyISAM_part +FROM t1 +WHERE t1.id IN ( + SELECT distinct id + FROM t4 + WHERE taken BETWEEN @f_date AND date_add(@t_date, INTERVAL 1 DAY)) +ORDER BY t1.id +; + +drop table t1, t2, t4; + +CREATE TABLE t1 ( + taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + id int(11) NOT NULL DEFAULT '0', + status varchar(20) NOT NULL DEFAULT '', + PRIMARY KEY (id,taken) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +PARTITION BY RANGE (to_days(taken)) +( +PARTITION p15 VALUES LESS THAN (732950) , +PARTITION p16 VALUES LESS THAN MAXVALUE ) ; + + +INSERT INTO t1 VALUES +('2006-09-27 21:50:01',22589,'Open'), +('2006-09-29 21:50:01',22589,'Verified'); + +DROP TABLE IF EXISTS t2; +CREATE TABLE t2 ( + id int(8) NOT NULL, + severity tinyint(4) NOT NULL DEFAULT '0', + priority tinyint(4) NOT NULL DEFAULT '0', + status varchar(20) DEFAULT NULL, + alien tinyint(4) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +INSERT INTO t2 VALUES +(22589,1,1,'Need Feedback',0); + +SELECT t2.id FROM t2 WHERE t2.id IN (SELECT id FROM t1 WHERE status = 'Verified'); + +drop table t1, t2; + +# +# Bug #27123 partition + on duplicate key update + varchar = Can't find record in <table> +# +create table t1 (c1 varchar(255),c2 tinyint,primary key(c1)) + partition by key (c1) partitions 10 ; +insert into t1 values ('aaa','1') on duplicate key update c2 = c2 + 1; +insert into t1 values ('aaa','1') on duplicate key update c2 = c2 + 1; +select * from t1; +drop table t1; + +# +# Bug #28005 Partitions: can't use -9223372036854775808 +# + +create table t1 (s1 bigint) partition by list (s1) (partition p1 values in (-9223372036854775808)); +drop table t1; + +# +# Bug #28806: Running SHOW TABLE STATUS during high INSERT load crashes server +# +create table t1(a int auto_increment, b int, primary key (b, a)) + partition by hash(b) partitions 2; +insert into t1 values (null, 1); +--replace_column 9 0 12 NULL 13 NULL 14 NULL +show table status; +drop table t1; + +create table t1(a int auto_increment primary key) + partition by key(a) partitions 2; +insert into t1 values (null), (null), (null); +--replace_column 9 0 12 NULL 13 NULL 14 NULL +show table status; +drop table t1; +# Bug #28488: Incorrect information in file: './test/t1_test#.frm' +# + +CREATE TABLE t1(a INT NOT NULL, b TINYBLOB, KEY(a)) + PARTITION BY RANGE(a) ( PARTITION p0 VALUES LESS THAN (32)); +INSERT INTO t1 VALUES (1, REPEAT('a', 10)); +INSERT INTO t1 SELECT a + 1, b FROM t1; +INSERT INTO t1 SELECT a + 2, b FROM t1; +INSERT INTO t1 SELECT a + 4, b FROM t1; +INSERT INTO t1 SELECT a + 8, b FROM t1; + +ALTER TABLE t1 ADD PARTITION (PARTITION p1 VALUES LESS THAN (64)); +ALTER TABLE t1 DROP PARTITION p1; + +DROP TABLE t1; + +# +# Bug #30484: Partitions: crash with self-referencing trigger +# + +create table t (s1 int) engine=myisam partition by key (s1); +create trigger t_ad after delete on t for each row insert into t values (old.s1); +insert into t values (1); +drop table t; + +# +# Bug #27084 partitioning by list seems failing when using case +# BUG #18198: Case no longer supported, test case removed +# + +create table t2 (b int); +--error ER_BAD_FIELD_ERROR +create table t1 (b int) +PARTITION BY RANGE (t2.b) ( + PARTITION p1 VALUES LESS THAN (10), + PARTITION p2 VALUES LESS THAN (20) +) select * from t2; +create table t1 (a int) +PARTITION BY RANGE (b) ( + PARTITION p1 VALUES LESS THAN (10), + PARTITION p2 VALUES LESS THAN (20) +) select * from t2; +show create table t1; +drop table t1, t2; + +# +# Bug #32067 Partitions: crash with timestamp column +# this bug occurs randomly on some UPDATE statement +# with the '1032: Can't find record in 't1'' error + +create table t1 + (s1 timestamp on update current_timestamp, s2 int) + partition by key(s1) partitions 3; + +insert into t1 values (null,null); +--disable_query_log +let $cnt= 1000; +while ($cnt) +{ + update t1 set s2 = 1; + update t1 set s2 = 2; + dec $cnt; +} +--enable_query_log + +drop table t1; + +# +# BUG#32272: partition crash 1: enum column +# +create table t1 ( + c0 int, + c1 bigint, + c2 set('sweet'), + key (c2,c1,c0), + key(c0) +) engine=myisam partition by hash (month(c0)) partitions 5; + +--disable_warnings +insert ignore into t1 set c0 = -6502262, c1 = 3992917, c2 = 35019; +insert ignore into t1 set c0 = 241221, c1 = -6862346, c2 = 56644; +--enable_warnings +# This must not fail assert: +select c1 from t1 group by (select c0 from t1 limit 1); +drop table t1; + +# Bug #30495: optimize table t1,t2,t3 extended errors +# (added more maintenace commands for Bug#20129 +CREATE TABLE t1(a int) +PARTITION BY RANGE (a) ( + PARTITION p1 VALUES LESS THAN (10), + PARTITION p2 VALUES LESS THAN (20) +); +--error ER_PARSE_ERROR +ALTER TABLE t1 OPTIMIZE PARTITION p1 EXTENDED; +--error ER_PARSE_ERROR +ALTER TABLE t1 ANALYZE PARTITION p1 EXTENDED; +ALTER TABLE t1 ANALYZE PARTITION p1; +ALTER TABLE t1 CHECK PARTITION p1; +ALTER TABLE t1 REPAIR PARTITION p1; +ALTER TABLE t1 OPTIMIZE PARTITION p1; +DROP TABLE t1; + +# +# Bug #29258: Partitions: search fails for maximum unsigned bigint +# +CREATE TABLE t1 (s1 BIGINT UNSIGNED) + PARTITION BY RANGE (s1) ( + PARTITION p0 VALUES LESS THAN (0), + PARTITION p1 VALUES LESS THAN (1), + PARTITION p2 VALUES LESS THAN (18446744073709551615) +); +INSERT INTO t1 VALUES (0), (18446744073709551614); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT INTO t1 VALUES (18446744073709551615); +DROP TABLE t1; + +CREATE TABLE t1 (s1 BIGINT UNSIGNED) + PARTITION BY RANGE (s1) ( + PARTITION p0 VALUES LESS THAN (0), + PARTITION p1 VALUES LESS THAN (1), + PARTITION p2 VALUES LESS THAN (18446744073709551614), + PARTITION p3 VALUES LESS THAN MAXVALUE +); +INSERT INTO t1 VALUES (-1), (0), (18446744073709551613), + (18446744073709551614), (18446744073709551615); +SELECT * FROM t1; +SELECT * FROM t1 WHERE s1 = 0; +SELECT * FROM t1 WHERE s1 = 18446744073709551614; +SELECT * FROM t1 WHERE s1 = 18446744073709551615; +DROP TABLE t1; + +CREATE TABLE t1 (s1 BIGINT UNSIGNED) + PARTITION BY RANGE (s1) ( + PARTITION p0 VALUES LESS THAN (0), + PARTITION p1 VALUES LESS THAN (1), + PARTITION p2 VALUES LESS THAN (18446744073709551615), + PARTITION p3 VALUES LESS THAN MAXVALUE +); +DROP TABLE t1; + +# +# Bug #31890 Partitions: ORDER BY DESC in InnoDB not working +# + +CREATE TABLE t1 +(int_column INT, char_column CHAR(5), +PRIMARY KEY(char_column,int_column)) +PARTITION BY KEY(char_column,int_column) +PARTITIONS 101; +INSERT INTO t1 (int_column, char_column) VALUES +( 39868 ,'zZZRW'), +( 545592 ,'zZzSD'), +( 4936 ,'zzzsT'), +( 9274 ,'ZzZSX'), +( 970185 ,'ZZzTN'), +( 786036 ,'zZzTO'), +( 37240 ,'zZzTv'), +( 313801 ,'zzzUM'), +( 782427 ,'ZZZva'), +( 907955 ,'zZZvP'), +( 453491 ,'zzZWV'), +( 756594 ,'ZZZXU'), +( 718061 ,'ZZzZH'); +SELECT * FROM t1 ORDER BY char_column DESC; +DROP TABLE t1; + +# +# Bug #32247 Test reports wrong value of "AUTO_INCREMENT" (on a partitioned InnoDB table) +# + +CREATE TABLE t1(id MEDIUMINT NOT NULL AUTO_INCREMENT, + user CHAR(25), PRIMARY KEY(id)) + PARTITION BY RANGE(id) + SUBPARTITION BY hash(id) subpartitions 2 + (PARTITION pa1 values less than (10), + PARTITION pa2 values less than (20), + PARTITION pa11 values less than MAXVALUE); +--disable_query_log +let $n= 15; +while ($n) +{ + insert into t1 (user) values ('mysql'); + dec $n; +} +--enable_query_log +show create table t1; +drop table t1; + +# +# Bug #38272 timestamps fields incorrectly defaulted on update accross partitions. +# + +CREATE TABLE t1 ( + `ID` bigint(20) NOT NULL AUTO_INCREMENT, + `createdDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + `number` int, + PRIMARY KEY (`ID`, number) +) +PARTITION BY RANGE (number) ( + PARTITION p0 VALUES LESS THAN (6), + PARTITION p1 VALUES LESS THAN (11) +); + +create table t2 ( + `ID` bigint(20), + `createdDate` TIMESTAMP, + `number` int +); + +INSERT INTO t1 SET number=1; +insert into t2 select * from t1; +SELECT SLEEP(1); +UPDATE t1 SET number=6; +select count(*) from t1, t2 where t1.createdDate = t2.createdDate; + +drop table t1, t2; + +# +# Bug #38083 Error-causing row inserted into partitioned table despite error +# +SET @orig_sql_mode = @@SQL_MODE; +SET SQL_MODE='STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO'; +CREATE TABLE t1 (c1 INT) + PARTITION BY LIST(1 DIV c1) ( + PARTITION p0 VALUES IN (NULL), + PARTITION p1 VALUES IN (1) + ); + +-- error ER_DIVISION_BY_ZERO +INSERT INTO t1 VALUES (0); +SELECT * FROM t1; +TRUNCATE t1; +-- error ER_DIVISION_BY_ZERO +INSERT INTO t1 VALUES (NULL), (0), (1), (2); +SELECT * FROM t1; +DROP TABLE t1; +SET SQL_MODE= @orig_sql_mode; + + + +# +# Bug #38005 Partitions: error with insert select +# + +create table t1 (s1 int) partition by hash(s1) partitions 2; +create index i on t1 (s1); +insert into t1 values (1); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +select * from t1; +drop table t1; + +create table t1 (s1 int) partition by range(s1) + (partition pa1 values less than (10), + partition pa2 values less than MAXVALUE); +create index i on t1 (s1); +insert into t1 values (1); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +select * from t1; +drop table t1; + +create table t1 (s1 int) partition by range(s1) + (partition pa1 values less than (10), + partition pa2 values less than MAXVALUE); +create index i on t1 (s1); +insert into t1 values (20); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +select * from t1; +drop table t1; + +create table t1 (s1 int) partition by range(s1) + (partition pa1 values less than (10), + partition pa2 values less than MAXVALUE); +create index i on t1 (s1); +insert into t1 values (1), (2), (3), (4), (5), (6), (7), (8); +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1; +insert into t1 select s1 from t1 order by s1 desc; +insert into t1 select s1 from t1 where s1=3; +select count(*) from t1; +drop table t1; + + +--echo # +--echo # Bug#42944: partition not pruned correctly +--echo # +CREATE TABLE t1 (a int) PARTITION BY RANGE (a) + (PARTITION p0 VALUES LESS THAN (100), + PARTITION p1 VALUES LESS THAN (200), + PARTITION p2 VALUES LESS THAN (300), + PARTITION p3 VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (10), (100), (200), (300), (400); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a>=200; +DROP TABLE t1; + +# +# Bug#44821: select distinct on partitioned table returns wrong results +# +CREATE TABLE t1 ( a INT, b INT, c INT, KEY bc(b, c) ) +PARTITION BY KEY (a, b) PARTITIONS 3 +; + +INSERT INTO t1 VALUES +(17, 1, -8), +(3, 1, -7), +(23, 1, -6), +(22, 1, -5), +(11, 1, -4), +(21, 1, -3), +(19, 1, -2), +(30, 1, -1), + +(20, 1, 1), +(16, 1, 2), +(18, 1, 3), +(9, 1, 4), +(15, 1, 5), +(28, 1, 6), +(29, 1, 7), +(25, 1, 8), +(10, 1, 9), +(13, 1, 10), +(27, 1, 11), +(24, 1, 12), +(12, 1, 13), +(26, 1, 14), +(14, 1, 15) +; + +SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c; + +EXPLAIN +SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c; + +DROP TABLE t1; + +--echo # +--echo # Bug #45807: crash accessing partitioned table and sql_mode +--echo # contains ONLY_FULL_GROUP_BY +--echo # + +SET SESSION SQL_MODE='ONLY_FULL_GROUP_BY'; +CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM + PARTITION BY HASH(id) PARTITIONS 2; +DROP TABLE t1; +SET SESSION SQL_MODE=DEFAULT; + + +--echo # +--echo # BUG#45816 - assertion failure with index containing double +--echo # column on partitioned table +--echo # + +CREATE TABLE t1 ( + a INT DEFAULT NULL, + b DOUBLE DEFAULT NULL, + c INT DEFAULT NULL, + KEY idx2(b,a) +) PARTITION BY HASH(c) PARTITIONS 3; + +INSERT INTO t1 VALUES (6,8,9); +INSERT INTO t1 VALUES (6,8,10); + +SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE; + +DROP TABLE t1; +--echo End of 5.1 tests diff --git a/mysql-test/t/partition_archive.test b/mysql-test/t/partition_archive.test new file mode 100644 index 00000000000..fad57107b7d --- /dev/null +++ b/mysql-test/t/partition_archive.test @@ -0,0 +1,107 @@ +# Tests for the partition storage engine in connection with the +# storage engine ARCHIVE. +# +# Creation: +# 2007-10-18 mleich - Move ARCHIVE related sub tests of partition.test to +# this test. Reason: ARCHIVE is not everytime available. +# - Minor cleanup +# + +--source include/have_partition.inc +--source include/have_archive.inc + + +# +# Bug 17310 Partitions: Bugs with archived partitioned tables +# +--disable_warnings +drop database if exists db99; +drop table if exists t1; +--enable_warnings + +create database db99; +use db99; +create table t1 (a int not null) +engine=archive +partition by list (a) +(partition p0 values in (1), partition p1 values in (2)); +insert into t1 values (1), (2); +--error 0, ER_CANT_CREATE_TABLE +create index inx on t1 (a); +alter table t1 add partition (partition p2 values in (3)); +alter table t1 drop partition p2; +use test; +drop database db99; + +create table t1 (f1 integer) engine= ARCHIVE partition by list(f1) +( + partition p1 values in (1), + partition p2 values in (NULL), + partition p3 values in (2), + partition p4 values in (3), + partition p5 values in (4) +); + +insert into t1 values (1),(2),(3),(4),(null); +select * from t1; +select * from t1 where f1 < 3; +drop table t1; + +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null) engine=ARCHIVE +partition by hash (a + 2) +partitions 3 +(partition x1 tablespace ts1, + partition x2 tablespace ts2, + partition x3 tablespace ts3); + +insert into t1 values (1,1,1); +insert into t1 values (2,1,1); +insert into t1 values (3,1,1); +insert into t1 values (4,1,1); +insert into t1 values (5,1,1); + +select * from t1; + +drop table t1; + +# +# Bug #32247 Test reports wrong value of "AUTO_INCREMENT" (on a partitioned InnoDB table) +# (though reported as InnoDB bug, requires some ARCHIVE tests + +create table t1 (a int) engine=archive partition by hash(a); +show create table t1; +drop table t1; + +CREATE TABLE t1(id MEDIUMINT NOT NULL AUTO_INCREMENT, + f1 VARCHAR(25), + PRIMARY KEY(id)) ENGINE=ARCHIVE + PARTITION BY RANGE(id) + SUBPARTITION BY hash(id) subpartitions 2 + (PARTITION pa1 values less than (10), + PARTITION pa2 values less than (20), + PARTITION pa3 values less than (30), + PARTITION pa4 values less than (40), + PARTITION pa5 values less than (50), + PARTITION pa6 values less than (60), + PARTITION pa7 values less than (70), + PARTITION pa8 values less than (80), + PARTITION pa9 values less than (90), + PARTITION pa10 values less than (100), + PARTITION pa11 values less than MAXVALUE); + +--disable_query_log +let $n= 100; +while ($n) +{ + insert into t1 (f1) values (repeat('a',25)); + dec $n; +} +--enable_query_log + +show create table t1; +select count(*) from t1; +drop table t1; + diff --git a/mysql-test/t/partition_blackhole.test b/mysql-test/t/partition_blackhole.test new file mode 100644 index 00000000000..9344ecb3b62 --- /dev/null +++ b/mysql-test/t/partition_blackhole.test @@ -0,0 +1,24 @@ +# Tests for the partition storage engine in connection with the +# storage engine BLACKHOLE. +# +# Creation: +# 2007-10-18 mleich - Move BLACKHOLE related sub tests of partition.test to +# this test. Reason: BLACKHOLE is not everytime available. +# - Minor cleanup +# + +--source include/have_partition.inc +--source include/have_blackhole.inc + +# +# Bug#14524 Partitions: crash if blackhole +# +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE `t1` ( + `id` int(11) default NULL +) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1 PARTITION BY HASH (id) ; +SELECT * FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/t/partition_bug18198.test b/mysql-test/t/partition_bug18198.test new file mode 100644 index 00000000000..7f071c6ec9e --- /dev/null +++ b/mysql-test/t/partition_bug18198.test @@ -0,0 +1,219 @@ +-- source include/have_partition.inc +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (col1 datetime) +partition by range(datediff(col1,col1)) +(partition p0 values less than (10), partition p1 values less than (30)); +drop table t1; + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(greatest(col1,10)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(isnull(col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(least(col1,12)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(case when col1>0 then 10 else 20 end) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(ifnull(col1,5)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(nullif(col1,5)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(bit_length(col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 char(5)) +partition by range(bit_length(col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(char_length(col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 char(5)) +partition by range(char_length(col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 char(5)) +partition by range(character_length(col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(find_in_set(col1,1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 char(5)) +partition by range(find_in_set(col1,'1')) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(instr(col1,3)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 char(5)) +partition by range(instr(col1,'3')) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 char(5)) +partition by range(length(col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 char(5)) +partition by range(locate(1,col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(locate(1,col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 char(5)) +partition by range(octet_length(col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 char(5)) +partition by range(position(1 in col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(position(1 in col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 char(5)) +partition by range(strcmp(col1,2)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(strcmp(col1,2)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(crc32(col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(round(col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(sign(col1)) +(partition p0 values less than (2), partition p1 values less than (6)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 datetime) +partition by range(period_add(col1,5)) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 datetime, col2 datetime) +partition by range(period_diff(col1,col2)) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int, col2 int) +partition by range(period_diff(col1,col2)) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 datetime) +partition by range(timestampdiff(day,5,col1)) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 date) +partition by range(unix_timestamp(col1)) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 datetime) +partition by range(week(col1)) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 varchar(25)) +partition by range(cast(col1 as signed)) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 varchar(25)) +partition by range(convert(col1,unsigned)) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(col1 | 20) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(col1 & 20) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(col1 ^ 20) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(col1 << 20) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(col1 >> 20) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(~col1) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(bit_count(col1)) +(partition p0 values less than (10), partition p1 values less than (30)); + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (col1 int) +partition by range(inet_aton(col1)) +(partition p0 values less than (10), partition p1 values less than (30)); diff --git a/mysql-test/t/partition_charset.test b/mysql-test/t/partition_charset.test new file mode 100644 index 00000000000..6842e5268fa --- /dev/null +++ b/mysql-test/t/partition_charset.test @@ -0,0 +1,29 @@ +# +# Test for character set related things in combination +# with the partition storage engine +# +-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +set names utf8; +create table t1 (s1 int) + partition by list (s1) + (partition c values in (1), + partition Ç values in (3)); +insert into t1 values (1),(3); +select * from t1; +flush tables; +set names latin1; +select * from t1; +drop table t1; + +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (a varchar(1), primary key (a)) +partition by list (ascii(a)) +(partition p1 values in (65)); +#insert into t1 values ('A'); +#replace into t1 values ('A'); +#drop table t1; diff --git a/mysql-test/t/partition_csv.test b/mysql-test/t/partition_csv.test new file mode 100644 index 00000000000..44013dd4b0a --- /dev/null +++ b/mysql-test/t/partition_csv.test @@ -0,0 +1,93 @@ +# Tests for the partition storage engine in connection with the +# storage engine CSV. +# +# Creation: +# 2007-10-18 mleich - Move CSV related sub tests of partition.test to +# this test. Reason: CSV is not everytime available. +# - Minor cleanup +# + +--source include/have_partition.inc +--source include/have_csv.inc + +call mtr.add_suppression("Failed to write to mysql.general_log"); + +# +# Bug#19307: Partitions: csv delete failure +# = CSV engine crashes +# +--disable_warnings +drop table if exists t1; +--enable_warnings +--error ER_PARTITION_MERGE_ERROR +create table t1 (a int) +engine = csv +partition by list (a) +(partition p0 values in (null)); + +# +# Bug #27816: Log tables ran with partitions crashes the server when logging +# is enabled. +# + +USE mysql; +TRUNCATE TABLE general_log; +SET @old_general_log_state = @@global.general_log; +SET GLOBAL general_log = 0; +ALTER TABLE general_log ENGINE = MyISAM; +--error ER_WRONG_USAGE +ALTER TABLE general_log PARTITION BY RANGE (TO_DAYS(event_time)) + (PARTITION p0 VALUES LESS THAN (733144), PARTITION p1 VALUES LESS THAN (3000000)); +ALTER TABLE general_log ENGINE = CSV; +SET GLOBAL general_log = @old_general_log_state; +use test; + +--echo # +--echo # Bug#40281: partitioning the general log table crashes the server +--echo # + +--echo # set up partitioned log, and switch to it + +USE mysql; +SET @old_general_log_state = @@global.general_log; +SET GLOBAL general_log = 0; +CREATE TABLE gl_partitioned LIKE general_log; +ALTER TABLE gl_partitioned ENGINE=myisam; +ALTER TABLE gl_partitioned PARTITION BY HASH (thread_id) PARTITIONS 10; +ALTER TABLE general_log RENAME TO gl_nonpartitioned; +ALTER TABLE gl_partitioned RENAME TO general_log; + +SELECT @@global.log_output INTO @old_glo; +SET GLOBAL log_output='table'; +SET GLOBAL general_log =1; + +--echo # do some things to be logged to partitioned log, should fail +USE /* 1 */ test; + +CREATE TABLE t1 (i INT); + +connect (con1,localhost,root,,); +INSERT INTO t1 VALUES (1); +SELECT * FROM t1; +disconnect con1; + +connection default; +USE mysql; +SET GLOBAL general_log =0; +ALTER TABLE general_log RENAME TO gl_partitioned; +ALTER TABLE gl_nonpartitioned RENAME TO general_log; + +--echo # show whether we actually logged anything (no) to general_log +SELECT COUNT(argument) FROM gl_partitioned; + +DROP TABLE gl_partitioned; + +SET GLOBAL log_output = @old_glo; +SET GLOBAL general_log = 1; + +USE /* 2 */ test; +DROP TABLE t1; + +SET GLOBAL general_log = @old_general_log_state; + +--echo End of 5.1 tests diff --git a/mysql-test/t/partition_datatype.test b/mysql-test/t/partition_datatype.test new file mode 100644 index 00000000000..7440a9bf3a3 --- /dev/null +++ b/mysql-test/t/partition_datatype.test @@ -0,0 +1,232 @@ +# +# Simple test for the partition storage engine +# with most datatypes and null / not null +# as partition by key +# Created to verify the fix for Bug#31705 +# Partitions: crash if varchar length > 65530 +# +-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +-- echo # test with not null +create table t1 (a bit not null) partition by key (a); +insert into t1 values (b'1'); +select hex(a) from t1 where a = b'1'; +drop table t1; +create table t1 (a tinyint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a smallint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a mediumint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a int not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a bigint not null) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a float not null) partition by key (a); +insert into t1 values (0.5); +select * from t1 where a = 0.5; +drop table t1; +create table t1 (a double not null) partition by key (a); +insert into t1 values (0.5); +select * from t1 where a = 0.5; +drop table t1; +create table t1 (a decimal(4,2) not null) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +drop table t1; +create table t1 (a date not null) partition by key (a); +insert into t1 values ('2001-01-01'); +select * from t1 where a = '2001-01-01'; +drop table t1; +create table t1 (a datetime not null) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +drop table t1; +create table t1 (a timestamp not null) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +drop table t1; +create table t1 (a time not null) partition by key (a); +insert into t1 values ('01:02:03'); +select * from t1 where a = '01:02:03'; +drop table t1; +create table t1 (a year not null) partition by key (a); +insert into t1 values ('2001'); +select * from t1 where a = '2001'; +drop table t1; +create table t1 (a varchar(10) character set utf8 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(300) character set utf8 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(10) character set latin1 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(300) character set latin1 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a char(10) character set utf8 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a char(10) character set latin1 not null) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a enum('y','n') not null) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +drop table t1; +create table t1 (a set('y','n') not null) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +drop table t1; +-- echo # test with null allowed +create table t1 (a bit) partition by key (a); +insert into t1 values (b'1'); +insert into t1 values (NULL); +select hex(a) from t1 where a = b'1'; +select hex(a) from t1 where a is NULL; +select hex(a) from t1 order by a; +drop table t1; +create table t1 (a tinyint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a smallint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a mediumint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a int) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a bigint) partition by key (a); +insert into t1 values (2); +select * from t1 where a = 2; +drop table t1; +create table t1 (a float) partition by key (a); +insert into t1 values (0.5); +select * from t1 where a = 0.5; +drop table t1; +create table t1 (a double) partition by key (a); +insert into t1 values (0.5); +select * from t1 where a = 0.5; +drop table t1; +create table t1 (a decimal(4,2)) partition by key (a); +insert into t1 values (2.1); +select * from t1 where a = 2.1; +drop table t1; +create table t1 (a date) partition by key (a); +insert into t1 values ('2001-01-01'); +select * from t1 where a = '2001-01-01'; +drop table t1; +create table t1 (a datetime) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +drop table t1; +create table t1 (a timestamp null) partition by key (a); +insert into t1 values ('2001-01-01 01:02:03'); +select * from t1 where a = '2001-01-01 01:02:03'; +drop table t1; +create table t1 (a time) partition by key (a); +insert into t1 values ('01:02:03'); +select * from t1 where a = '01:02:03'; +drop table t1; +create table t1 (a year) partition by key (a); +insert into t1 values ('2001'); +select * from t1 where a = '2001'; +drop table t1; +create table t1 (a varchar(10) character set utf8) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(300) character set utf8) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(10) character set latin1) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a varchar(300) character set latin1) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a char(10) character set utf8) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a char(10) character set latin1) partition by key (a); +insert into t1 values ('abc'); +select * from t1 where a = 'abc'; +drop table t1; +create table t1 (a enum('y','n')) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +drop table t1; +create table t1 (a set('y','n')) partition by key (a); +insert into t1 values ('y'); +select * from t1 where a = 'y'; +drop table t1; +create table t1 (a varchar(65531)) partition by key (a); +insert into t1 values ('bbbb'); +insert into t1 values ('aaaa'); +select * from t1 where a = 'aaaa'; +select * from t1 where a like 'aaa%'; +select * from t1 where a = 'bbbb'; +drop table t1; +create table t1 (a varchar(65532)) partition by key (a); +insert into t1 values ('bbbb'); +insert into t1 values ('aaaa'); +select * from t1 where a = 'aaaa'; +select * from t1 where a like 'aaa%'; +select * from t1 where a = 'bbbb'; +drop table t1; +create table t1 (a varchar(65533) not null) partition by key (a); +insert into t1 values ('bbbb'); +insert into t1 values ('aaaa'); +select * from t1 where a = 'aaaa'; +select * from t1 where a like 'aaa%'; +select * from t1 where a = 'bbbb'; +drop table t1; +-- error ER_TOO_BIG_ROWSIZE +create table t1 (a varchar(65533)) partition by key (a); +-- error ER_TOO_BIG_ROWSIZE +create table t1 (a varchar(65534) not null) partition by key (a); +-- error ER_TOO_BIG_ROWSIZE +create table t1 (a varchar(65535)) partition by key (a); + +# +# Bug#34358: error in key_restore for bitfields with uneven bits +# +create table t1 (a bit(27), primary key (a)) engine=myisam +partition by hash (a) +(partition p0, partition p1, partition p2); +show create table t1; +insert into t1 values (1),(4),(7),(10),(13),(16),(19),(22),(25),(28),(31),(34); +select hex(a) from t1 where a = 7; +drop table t1; diff --git a/mysql-test/t/partition_disabled-master.opt b/mysql-test/t/partition_disabled-master.opt new file mode 100644 index 00000000000..2703cb02f07 --- /dev/null +++ b/mysql-test/t/partition_disabled-master.opt @@ -0,0 +1 @@ +--loose-skip-partition diff --git a/mysql-test/t/partition_disabled.test b/mysql-test/t/partition_disabled.test new file mode 100644 index 00000000000..320d6238502 --- /dev/null +++ b/mysql-test/t/partition_disabled.test @@ -0,0 +1,85 @@ +--disable_abort_on_error +# Run this test only when mysqld has partitioning, but it is disabled. +# The statements are not expected to work, just check that we +# can't crash the server. +--require r/disabled_partition.require +--disable_query_log +show variables like "have_partitioning"; +--enable_query_log +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +let $MYSQLD_DATADIR= `SELECT @@datadir`; + +# +# Bug#39893: Crash if select on a partitioned table, +# when partitioning is disabled +FLUSH TABLES; +--copy_file $MYSQLTEST_VARDIR/std_data/parts/t1.frm $MYSQLD_DATADIR/test/t1.frm +SELECT * FROM t1; +TRUNCATE TABLE t1; +ANALYZE TABLE t1; +CHECK TABLE t1; +OPTIMIZE TABLE t1; +REPAIR TABLE t1; +ALTER TABLE t1 REPAIR PARTITION ALL; +ALTER TABLE t1 CHECK PARTITION ALL; +ALTER TABLE t1 OPTIMIZE PARTITION ALL; +ALTER TABLE t1 ANALYZE PARTITION ALL; +ALTER TABLE t1 REBUILD PARTITION ALL; +ALTER TABLE t1 ENGINE Memory; +ALTER TABLE t1 ADD (new INT); +DROP TABLE t1; + +--error ER_OPTION_PREVENTS_STATEMENT +CREATE TABLE t1 ( + firstname VARCHAR(25) NOT NULL, + lastname VARCHAR(25) NOT NULL, + username VARCHAR(16) NOT NULL, + email VARCHAR(35), + joined DATE NOT NULL +) +PARTITION BY KEY(joined) +PARTITIONS 6; + +--error ER_OPTION_PREVENTS_STATEMENT +ALTER TABLE t1 PARTITION BY KEY(joined) PARTITIONS 2; + +--error ER_BAD_TABLE_ERROR +drop table t1; + +--error ER_OPTION_PREVENTS_STATEMENT +CREATE TABLE t1 ( + firstname VARCHAR(25) NOT NULL, + lastname VARCHAR(25) NOT NULL, + username VARCHAR(16) NOT NULL, + email VARCHAR(35), + joined DATE NOT NULL +) +PARTITION BY RANGE( YEAR(joined) ) ( + PARTITION p0 VALUES LESS THAN (1960), + PARTITION p1 VALUES LESS THAN (1970), + PARTITION p2 VALUES LESS THAN (1980), + PARTITION p3 VALUES LESS THAN (1990), + PARTITION p4 VALUES LESS THAN MAXVALUE +); +--error ER_BAD_TABLE_ERROR +drop table t1; + +--error ER_OPTION_PREVENTS_STATEMENT +CREATE TABLE t1 (id INT, purchased DATE) + PARTITION BY RANGE( YEAR(purchased) ) + SUBPARTITION BY HASH( TO_DAYS(purchased) ) + SUBPARTITIONS 2 ( + PARTITION p0 VALUES LESS THAN (1990), + PARTITION p1 VALUES LESS THAN (2000), + PARTITION p2 VALUES LESS THAN MAXVALUE + ); +--error ER_BAD_TABLE_ERROR +drop table t1; + +# Create a table without partitions to test "EXPLAIN PARTITIONS" +create table t1 (a varchar(10) charset latin1 collate latin1_bin); +insert into t1 values (''),(' '),('a'),('a '),('a '); +explain partitions select * from t1 where a='a ' OR a='a'; +drop table t1; diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test new file mode 100644 index 00000000000..49632f95dfb --- /dev/null +++ b/mysql-test/t/partition_error.test @@ -0,0 +1,843 @@ +# +# Simple test for the erroneos statements using the +# partition storage engine +# +-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Bug#38719: Partitioning returns a different error code for a +# duplicate key error +CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a)); +-- error ER_DUP_ENTRY +INSERT INTO t1 VALUES (1),(1); +DROP TABLE t1; +CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a)) +PARTITION BY KEY (a) PARTITIONS 2; +-- error ER_DUP_ENTRY +INSERT INTO t1 VALUES (1),(1); +DROP TABLE t1; + +# +# Bug#31931: Mix of handlers error message +# +--error ER_MIX_HANDLER_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (a) +( PARTITION p0 ENGINE=MyISAM, + PARTITION p1); +--error ER_MIX_HANDLER_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY LIST (a) +SUBPARTITION BY HASH (a) +( PARTITION p0 VALUES IN (0) +( SUBPARTITION s0, SUBPARTITION s1 ENGINE=MyISAM, SUBPARTITION s2), + PARTITION p1 VALUES IN (1) +( SUBPARTITION s3 ENGINE=MyISAM, SUBPARTITION s4, SUBPARTITION s5 ENGINE=MyISAM)); + + +# +# Bug 29368: +# Incorrect error, 1467, for syntax error when creating partition +--error ER_PARTITION_REQUIRES_VALUES_ERROR +CREATE TABLE t1 ( + a int +) +PARTITION BY RANGE (a) +( + PARTITION p0 VALUES LESS THAN (1), + PARTITION p1 VALU ES LESS THAN (2) +); + +# +# Partition by key stand-alone error +# +--error 1064 +partition by list (a) +partitions 3 +(partition x1 values in (1,2,9,4) tablespace ts1, + partition x2 values in (3, 11, 5, 7) tablespace ts2, + partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3); + +# +# Partition by key list, number of partitions defined, no partition defined +# +--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a) +partitions 2; + +# +# Partition by key list, wrong result type +# +--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (sin(a)) +partitions 3 +(partition x1 values in (1,2,9,4) tablespace ts1, + partition x2 values in (3, 11, 5, 7) tablespace ts2, + partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3); + +# +# Partition by key, partition function not allowed +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by key (a+2) +partitions 3 +(partition x1 tablespace ts1, + partition x2 tablespace ts2, + partition x3 tablespace ts3); + +# +# Partition by key, no partition name +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by key (a) +partitions 3 +(partition tablespace ts1, + partition x2 tablespace ts2, + partition x3 tablespace ts3); + +# +# Partition by key, invalid field in field list +# +--error ER_FIELD_NOT_FOUND_PART_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by key (a,d) +partitions 3 +(partition x1 tablespace ts1, + partition x2 tablespace ts2, + partition x3 tablespace ts3); + +let $MYSQLD_DATADIR= `select @@datadir`; +select load_file('$MYSQLD_DATADIR/test/t1.par'); +# +# Partition by hash, invalid field in function +# +--error 1054 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by hash (a + d) +partitions 3 +(partition x1 tablespace ts1, + partition x2 tablespace ts2, + partition x3 tablespace ts3); + +# +# Partition by hash, invalid result type +# +--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by hash (sin(a)) +partitions 3 +(partition x1 tablespace ts1, + partition x2 tablespace ts2, + partition x3 tablespace ts3); + +# +# Partition by key specified 3 partitions but only defined 2 => error +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by key (a) +partitions 3 +(partition x1, partition x2); + +# +# Partition by key specified 3 partitions but only defined 2 => error +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by hash (rand(a)) +partitions 2 +(partition x1, partition x2); + +# +# Partition by key specified 3 partitions but only defined 2 => error +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (rand(a)) +partitions 2 +(partition x1 values less than (0), partition x2 values less than (2)); + +# +# Partition by key specified 3 partitions but only defined 2 => error +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (rand(a)) +partitions 2 +(partition x1 values in (1), partition x2 values in (2)); + +# +# Partition by hash, values less than error +# +--error ER_PARTITION_WRONG_VALUES_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by hash (a) +partitions 2 +(partition x1 values less than (4), + partition x2 values less than (5)); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Partition by hash, values in error +# +--error ER_PARTITION_WRONG_VALUES_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by hash (a) +partitions 2 +(partition x1 values in (4), + partition x2 values in (5)); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Partition by hash, values in error +# +--error ER_PARTITION_WRONG_VALUES_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by hash (a) +partitions 2 +(partition x1 values in (4,6), + partition x2 values in (5,7)); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Subpartition by key, no partitions defined, single field +# +--error ER_SUBPARTITION_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by key (a) +subpartition by key (b); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Subpartition by key, no partitions defined, list of fields +# +--error ER_SUBPARTITION_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by key (a) +subpartition by key (a, b); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Subpartition by hash, no partitions defined +# +--error ER_SUBPARTITION_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by key (a) +subpartition by hash (a+b); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Subpartition by key, no partitions defined, single field +# +--error ER_SUBPARTITION_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by key (a) +subpartition by key (b); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Subpartition by key, no partitions defined, list of fields +# +--error ER_SUBPARTITION_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by key (a) +subpartition by key (a, b); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Subpartition by hash, no partitions defined +# +--error ER_SUBPARTITION_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by key (a) +subpartition by hash (a+b); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Subpartition by hash, no partitions defined, wrong subpartition function +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by key (a) +subpartition by hash (rand(a+b)); + +# +# Subpartition by hash, wrong subpartition function +# +--error ER_SUBPARTITION_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by key (a) +subpartition by hash (sin(a+b)) +(partition x1 (subpartition x11, subpartition x12), + partition x2 (subpartition x21, subpartition x22)); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Subpartition by hash, no partitions defined, wrong subpartition function +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by range (a) +subpartition by key (a+b) +(partition x1 values less than (1) (subpartition x11, subpartition x12), + partition x2 values less than (2) (subpartition x21, subpartition x22)); + +# +# Subpartition by hash, no partitions defined, wrong subpartition function +# +--error ER_FIELD_NOT_FOUND_PART_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by range (a) +subpartition by key (a,d) +(partition x1 values less than (1) (subpartition x11, subpartition x12), + partition x2 values less than (2) (subpartition x21, subpartition x22)); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Subpartition by hash, no partitions defined, wrong subpartition function +# +--error ER_SUBPARTITION_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by key (a) +subpartition by hash (3+4); + +# +# Subpartition by hash, no partitions defined, wrong subpartition function +# +--error 1054 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by range (a) +subpartition by hash (a+d) +(partition x1 values less than (1) (subpartition x11, subpartition x12), + partition x2 values less than (2) (subpartition x21, subpartition x22)); + +# +# Partition by range, no partition => error +# +--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a); +select load_file('$MYSQLD_DATADIR/test/t1.par'); + +# +# Partition by range, invalid field in function +# +--error 1054 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a+d) +partitions 2 +(partition x1 values less than (4) tablespace ts1, + partition x2 values less than (8) tablespace ts2); + +# +# Partition by range, inconsistent partition function and constants +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a) +partitions 2 +(partition x1 values less than (4.0) tablespace ts1, + partition x2 values less than (8) tablespace ts2); + +# +# Partition by range, constant partition function not allowed +# +--error ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (3+4) +partitions 2 +(partition x1 values less than (4) tablespace ts1, + partition x2 values less than (8) tablespace ts2); + +# +# Partition by range, no values less than definition +# +--error ER_PARTITION_REQUIRES_VALUES_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a) +partitions 2 +(partition x1 values less than (4), + partition x2); + +# +# Partition by range, no values in definition allowed +# +--error ER_PARTITION_WRONG_VALUES_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a) +partitions 2 +(partition x1 values in (4), + partition x2); + +# +# Partition by range, values in error +# +--error ER_PARTITION_WRONG_VALUES_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a) +partitions 2 +(partition x1 values in (4), + partition x2 values less than (5)); + +# +# Partition by range, missing parenthesis +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a) +partitions 2 +(partition x1 values less than 4, + partition x2 values less than (5)); + +# +# Partition by range, maxvalue in wrong place +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a) +partitions 2 +(partition x1 values less than maxvalue, + partition x2 values less than (5)); + +# +# Partition by range, maxvalue in several places +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a) +partitions 2 +(partition x1 values less than maxvalue, + partition x2 values less than maxvalue); + +# +# Partition by range, not increasing ranges +# +--error ER_RANGE_NOT_INCREASING_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a) +partitions 2 +(partition x1 values less than (4), + partition x2 values less than (3)); + +# +# Partition by range, wrong result type of partition function +# +--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (sin(a)) +partitions 2 +(partition x1 values less than (4), + partition x2 values less than (5)); + +# +# Subpartition by hash, wrong number of subpartitions +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by list (a) +subpartition by hash (a+b) +subpartitions 3 +( partition x1 values in (1,2,4) + ( subpartition x11 nodegroup 0, + subpartition x12 nodegroup 1), + partition x2 values in (3,5,6) + ( subpartition x21 nodegroup 0, + subpartition x22 nodegroup 1) +); + +# +# Subpartition by hash, wrong number of subpartitions +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by list (a) +subpartition by hash (a+b) +( partition x1 values in (1) + ( subpartition x11 nodegroup 0, + subpartition xextra, + subpartition x12 nodegroup 1), + partition x2 values in (2) + ( subpartition x21 nodegroup 0, + subpartition x22 nodegroup 1) +); + +# +# Subpartition by list => error +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by key (a) +subpartition by list (a+b) +( partition x1 + ( subpartition x11 engine myisam, + subpartition x12 engine myisam), + partition x2 + ( subpartition x21 engine myisam, + subpartition x22 engine myisam) +); + +# +# Subpartition by list => error +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by key (a) +subpartition by list (a+b) +( partition x1 + ( subpartition x11 engine myisam values in (0), + subpartition x12 engine myisam values in (1)), + partition x2 + ( subpartition x21 engine myisam values in (0), + subpartition x22 engine myisam values in (1)) +); + +# +# Partition by list, no partition => error +# +--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a); + +# +# Partition by list, constant partition function not allowed +# +--error ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (3+4) +partitions 2 +(partition x1 values in (4) tablespace ts1, + partition x2 values in (8) tablespace ts2); + +# +# Partition by list, invalid field in function +# +--error 1054 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a+d) +partitions 2 +(partition x1 values in (4) tablespace ts1, + partition x2 values in (8) tablespace ts2); + +# +# Partition by list, no values in definition +# +--error ER_PARTITION_REQUIRES_VALUES_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a) +partitions 2 +(partition x1 values in (4), + partition x2); + +# +# Partition by list, values less than error +# +--error ER_PARTITION_WRONG_VALUES_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a) +partitions 2 +(partition x1 values in (4), + partition x2 values less than (5)); + +# +# Partition by list, no values in definition +# +--error ER_PARTITION_REQUIRES_VALUES_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a) +partitions 2 +(partition x1 values in (4,6), + partition x2); + +# +# Partition by list, duplicate values +# +--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a) +partitions 2 +(partition x1 values in (4, 12+9), + partition x2 values in (3, 21)); + +# +# Partition by list, wrong constant result type (not INT) +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a) +partitions 2 +(partition x1 values in (4.0, 12+8), + partition x2 values in (3, 21)); + +# +# Partition by list, missing parenthesis +# +--error 1064 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a) +partitions 2 +(partition x1 values in 4, + partition x2 values in (5)); + +# +# Bug #13439: Crash when LESS THAN (non-literal) +# +--error 1054 +CREATE TABLE t1 (a int) +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (x1)); + +# +# No partition for the given value +# +CREATE TABLE t1(a int) + PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN(5)); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +insert into t1 values (10); +drop table t1; + +--error ER_PARTITION_CONST_DOMAIN_ERROR +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (-1)); +# +# Bug 18198 Partitions: Verify that erroneus partition functions doesn't work +# +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (v varchar(12)) +partition by range (ascii(v)) +(partition p0 values less than (10)); +#drop table t1; + +-- error 1064 +create table t1 (a int) +partition by hash (rand(a)); +-- error 1064 +create table t1 (a int) +partition by hash(CURTIME() + a); +-- error 1064 +create table t1 (a int) +partition by hash (NOW()+a); +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int) +partition by hash (extract(hour from convert_tz(a, '+00:00', '+00:00'))); +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (a int) +partition by range (a + (select count(*) from t1)) +(partition p1 values less than (1)); +-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (a char(10)) +partition by hash (extractvalue(a,'a')); + + diff --git a/mysql-test/t/partition_federated.test b/mysql-test/t/partition_federated.test new file mode 100644 index 00000000000..0fe692ecd01 --- /dev/null +++ b/mysql-test/t/partition_federated.test @@ -0,0 +1,21 @@ +# +# Tests for partitioned FEDERATED +# +-- source include/have_partition.inc +-- source include/not_embedded.inc +-- source suite/federated/have_federated_db.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Bug #22451 Partitions: duplicate results with engine=federated +# + +--error ER_PARTITION_MERGE_ERROR +create table t1 (s1 int) engine=federated +connection='mysql://root@localhost/federated/t1' partition by list (s1) +(partition p1 values in (1), partition p2 values in (2)); + +--echo End of 5.1 tests diff --git a/mysql-test/t/partition_grant.test b/mysql-test/t/partition_grant.test new file mode 100644 index 00000000000..cf944e507fd --- /dev/null +++ b/mysql-test/t/partition_grant.test @@ -0,0 +1,81 @@ +-- source include/have_partition.inc +# Grant tests not performed with embedded server +-- source include/not_embedded.inc + +--disable_warnings +drop schema if exists mysqltest_1; +--enable_warnings + + +# +# Bug #17139: ALTER TABLE ... DROP PARTITION should require DROP privilege +# + +create schema mysqltest_1; +use mysqltest_1; + +create table t1 (a int) partition by list (a) (partition p1 values in (1), partition p2 values in (2), partition p3 values in (3)); +insert into t1 values (1),(2); + +# We don't have DROP USER IF EXISTS. Use this workaround to +# cleanup possible grants for mysqltest_1 left by previous tests +# and ensure consistent results of SHOW GRANTS command below. +--disable_warnings +grant usage on *.* to mysqltest_1@localhost; +revoke all privileges on *.* from mysqltest_1@localhost; +--enable_warnings + +grant select,alter on mysqltest_1.* to mysqltest_1@localhost; + +connect (conn1,localhost,mysqltest_1,,mysqltest_1); +show grants for current_user; +alter table t1 add b int; +--error ER_TABLEACCESS_DENIED_ERROR +alter table t1 drop partition p2; +disconnect conn1; + +connection default; +grant drop on mysqltest_1.* to mysqltest_1@localhost; + +connect (conn2,localhost,mysqltest_1,,mysqltest_1); +alter table t1 drop partition p2; +disconnect conn2; + +connection default; +revoke alter on mysqltest_1.* from mysqltest_1@localhost; + +connect (conn3,localhost,mysqltest_1,,mysqltest_1); +--error ER_TABLEACCESS_DENIED_ERROR +alter table t1 drop partition p3; +disconnect conn3; + +connection default; + +revoke select,alter,drop on mysqltest_1.* from mysqltest_1@localhost; +drop table t1; + +# +# Bug #23675 Partitions: possible security breach via alter +# + +create table t1 (s1 int); +insert into t1 values (1); +grant alter on mysqltest_1.* to mysqltest_1@localhost; +connect (conn4,localhost,mysqltest_1,,mysqltest_1); +connection conn4; +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +alter table t1 partition by list (s1) (partition p1 values in (2)); +connection default; +grant select, alter on mysqltest_1.* to mysqltest_1@localhost; +disconnect conn4; +connect (conn5,localhost,mysqltest_1,,mysqltest_1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +alter table t1 partition by list (s1) (partition p1 values in (2)); +disconnect conn5; +connection default; +drop table t1; + +drop user mysqltest_1@localhost; +drop schema mysqltest_1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/partition_hash.test b/mysql-test/t/partition_hash.test new file mode 100644 index 00000000000..5b9aa5707b9 --- /dev/null +++ b/mysql-test/t/partition_hash.test @@ -0,0 +1,173 @@ +#--disable_abort_on_error +# +# Simple test for the partition storage engine +# Taken fromm the select test +# +-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Bug#30822: crash when COALESCE +# +CREATE TABLE t1 (c1 INT) + PARTITION BY HASH (c1) + PARTITIONS 15; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +ALTER TABLE t1 COALESCE PARTITION 13; +DROP TABLE t1; +CREATE TABLE t1 (c1 INT) + PARTITION BY LINEAR HASH (c1) + PARTITIONS 5; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +ALTER TABLE t1 COALESCE PARTITION 3; +DROP TABLE t1; + +# +# More partition pruning tests, especially on interval walking +# +create table t1 (a int unsigned) +partition by hash(a div 2) +partitions 4; +insert into t1 values (null),(0),(1),(2),(3),(4),(5),(6),(7); +select * from t1 where a < 0; +select * from t1 where a is null or (a >= 5 and a <= 7); +select * from t1 where a is null; +select * from t1 where a is not null; +select * from t1 where a >= 1 and a < 3; +select * from t1 where a >= 3 and a <= 5; +select * from t1 where a > 2 and a < 4; +select * from t1 where a > 3 and a <= 6; +select * from t1 where a > 5; +select * from t1 where a >= 1 and a <= 5; +explain partitions select * from t1 where a < 0; +explain partitions select * from t1 where a is null or (a >= 5 and a <= 7); +explain partitions select * from t1 where a is null; +explain partitions select * from t1 where a is not null; +explain partitions select * from t1 where a >= 1 and a < 3; +explain partitions select * from t1 where a >= 3 and a <= 5; +explain partitions select * from t1 where a > 2 and a < 4; +explain partitions select * from t1 where a > 3 and a <= 6; +explain partitions select * from t1 where a > 5; +explain partitions select * from t1 where a >= 1 and a <= 5; + +drop table t1; + +# +# Partition by hash, basic +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by hash (a + 2) +partitions 3 +(partition x1 tablespace ts1, + partition x2 tablespace ts2, + partition x3 tablespace ts3); + +insert into t1 values (1,1,1); +insert into t1 values (2,1,1); +insert into t1 values (3,1,1); +insert into t1 values (4,1,1); +insert into t1 values (5,1,1); + +select * from t1; + +update t1 set c=3 where b=1; +select * from t1; + +select b from t1 where a=3; +select b,c from t1 where a=1 AND b=1; + +delete from t1 where a=1; +delete from t1 where c=3; + +select * from t1; + +ALTER TABLE t1 +partition by hash (a + 3) +partitions 3 +(partition x1 tablespace ts1, + partition x2 tablespace ts2, + partition x3 tablespace ts3); +select * from t1; +drop table t1; + +# +# Partition by hash, only one partition +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by hash (a) +(partition x1); + +drop table t1; +# +# Partition by key, only one partition +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by key (a) +(partition x1); + +drop table t1; + +# +# Bug# 15968 - crash when INSERT with f1 = -1 into partition by hash(f1) +# +CREATE TABLE t1 (f1 INTEGER, f2 char(20)) ENGINE = 'MYISAM' PARTITION BY HASH(f1) PARTITIONS 2; +INSERT INTO t1 SET f1 = 0 - 1, f2 = '#######'; +select * from t1; +drop table t1; + +# +# BUG# 14524 Partitions: crash if blackhole +# +# Disable warnings to allow this test case to run without +# the Blackhole storage engine. +--disable_warnings +CREATE TABLE t1 (s1 int) ENGINE=BLACKHOLE PARTITION BY HASH (s1); +--enable_warnings +--error 0,ER_BINLOG_LOGGING_IMPOSSIBLE +INSERT INTO t1 VALUES (0); +DROP TABLE t1; + +# +# BUG 18423 Hash partitioning can lose rows in some queries +# +create table t1 (c1 int DEFAULT NULL, + c2 varchar (30) DEFAULT NULL, + c3 date DEFAULT NULL) +engine = myisam +partition by hash (to_days(c3)) +partitions 12; + +insert into t1 values +(136,'abc','2002-01-05'),(142,'abc','2002-02-14'),(162,'abc','2002-06-28'), +(182,'abc','2002-11-09'),(158,'abc','2002-06-01'),(184,'abc','2002-11-22'); +select * from t1; +select * from t1 where c3 between '2002-01-01' and '2002-12-31'; + +drop table t1; + +# +# Bug#31210 - INSERT DELAYED crashes server when used on partitioned table +# +CREATE TABLE t1 (c1 INT) ENGINE=MyISAM PARTITION BY HASH(c1) PARTITIONS 1; +# The test succeeds in an embedded server because normal insert is done. +# The test fails in a normal server with +# "DELAYED option not supported by table". +--error 0, ER_DELAYED_NOT_SUPPORTED +INSERT DELAYED INTO t1 VALUES (1); +DROP TABLE t1; + diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test new file mode 100644 index 00000000000..aba28b76f01 --- /dev/null +++ b/mysql-test/t/partition_innodb.test @@ -0,0 +1,301 @@ +--source include/have_partition.inc +--source include/have_innodb.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Bug#47029: Crash when reorganize partition with subpartition +# +create table t1 (a int not null, + b datetime not null, + primary key (a,b)) +engine=innodb +partition by range (to_days(b)) +subpartition by hash (a) +subpartitions 2 +( partition p0 values less than (to_days('2009-01-01')), + partition p1 values less than (to_days('2009-02-01')), + partition p2 values less than (to_days('2009-03-01')), + partition p3 values less than maxvalue); +alter table t1 reorganize partition p1,p2 into +( partition p2 values less than (to_days('2009-03-01'))); +drop table t1; +# +# Bug#40595: Non-matching rows not released with READ-COMMITTED on tables +# with partitions +CREATE TABLE t1 (id INT PRIMARY KEY, data INT) ENGINE = InnoDB +PARTITION BY RANGE(id) ( + PARTITION p0 VALUES LESS THAN (5), + PARTITION p1 VALUES LESS THAN (10), + PARTITION p2 VALUES LESS THAN MAXVALUE +); + +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), + (9,9), (10,10), (11,11); + +SET @old_tx_isolation := @@session.tx_isolation; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; + +SET autocommit = 0; + +UPDATE t1 SET DATA = data*2 WHERE id = 3; + +# grouping/referencing in replace_regex is very slow on long strings, +# removing all before/after the interesting row before grouping/referencing +--replace_regex /.*---TRANSACTION [0-9]+ [0-9]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/ +SHOW ENGINE InnoDB STATUS; + +UPDATE t1 SET data = data*2 WHERE data = 2; + +# grouping/referencing in replace_regex is very slow on long strings, +# removing all before/after the interesting row before grouping/referencing +--replace_regex /.*---TRANSACTION [0-9]+ [0-9]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/ +SHOW ENGINE InnoDB STATUS; + +SET @@session.tx_isolation = @old_tx_isolation; + +DROP TABLE t1; + +# +# Bug37721: ORDER BY when WHERE contains non-partitioned index column +# wrong order since it did not use pk as second compare +--echo # Bug#37721, test of ORDER BY on PK and WHERE on INDEX +CREATE TABLE t1 ( + a INT, + b INT, + PRIMARY KEY (a), + INDEX (b)) +ENGINE InnoDB +PARTITION BY HASH(a) +PARTITIONS 3; +# This will give the middle partition the highest value +INSERT INTO t1 VALUES (0,0),(4,0),(2,0); +SELECT a FROM t1 WHERE b = 0 ORDER BY a ASC; +SELECT a FROM t1 WHERE b = 0 ORDER BY a DESC; +ALTER TABLE t1 DROP INDEX b; +SELECT a FROM t1 WHERE b = 0 ORDER BY a ASC; +SELECT a FROM t1 WHERE b = 0 ORDER BY a DESC; +DROP TABLE t1; +CREATE TABLE t1 ( + a VARCHAR(600), + b VARCHAR(600), + PRIMARY KEY (a), + INDEX (b)) +ENGINE InnoDB +PARTITION BY KEY(a) +PARTITIONS 3; +# This will give the middle partition the highest value +INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'1'),repeat('0',257)); +INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'3'),repeat('0',257)); +INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'2'),repeat('0',257)); +SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a ASC; +SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a DESC; +ALTER TABLE t1 DROP INDEX b; +SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a ASC; +SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a DESC; +DROP TABLE t1; + +# +# Bug#32948 - FKs allowed to reference partitioned table +# +-- echo # Bug#32948 +CREATE TABLE t1 (c1 INT, PRIMARY KEY (c1)) ENGINE=INNODB; +CREATE TABLE t2 (c1 INT, PRIMARY KEY (c1), + FOREIGN KEY (c1) REFERENCES t1 (c1) + ON DELETE CASCADE) +ENGINE=INNODB; +--error ER_ROW_IS_REFERENCED +ALTER TABLE t1 PARTITION BY HASH(c1) PARTITIONS 5; +--error ER_ROW_IS_REFERENCED +ALTER TABLE t1 ENGINE=MyISAM; +DROP TABLE t2; +DROP TABLE t1; + +# +# Bug #14673: Wrong InnoDB default row format +# +create table t1 (a int) engine=innodb partition by hash(a) ; +# Data_free for InnoDB tablespace varies depending on which +# tests have been run before this one +--replace_column 10 # +show table status like 't1'; +drop table t1; + +# +# Bug 21173: SHOW TABLE STATUS crashes server in InnoDB +# +create table t1 (a int) +engine = innodb +partition by key (a); +# Data_free for InnoDB tablespace varies depending on which +# tests have been run before this one +--replace_column 10 # +show table status; +insert into t1 values (0), (1), (2), (3); +# Data_free for InnoDB tablespace varies depending on which +# tests have been run before this one +--replace_column 10 # +show table status; +drop table t1; + +create table t1 (a int auto_increment primary key) +engine = innodb +partition by key (a); +# Data_free for InnoDB tablespace varies depending on which +# tests have been run before this one +--replace_column 10 # +show table status; +insert into t1 values (NULL), (NULL), (NULL), (NULL); +# Data_free for InnoDB tablespace varies depending on which +# tests have been run before this one +--replace_column 10 # +show table status; +insert into t1 values (NULL), (NULL), (NULL), (NULL); +# Data_free for InnoDB tablespace varies depending on which +# tests have been run before this one +--replace_column 10 # +show table status; +drop table t1; + +# +# BUG 19122 Crash after ALTER TABLE t1 REBUILD PARTITION p1 +# +create table t1 (a int) +partition by key (a) +(partition p1 engine = innodb); + +alter table t1 rebuild partition p1; +alter table t1 rebuild partition p1; +alter table t1 rebuild partition p1; +alter table t1 rebuild partition p1; +alter table t1 rebuild partition p1; +alter table t1 rebuild partition p1; +alter table t1 rebuild partition p1; +drop table t1; + +# +# Bug 21339: Crash in Explain Partitions +# +create table t1 (a date) +engine = innodb +partition by range (year(a)) +(partition p0 values less than (2006), + partition p1 values less than (2007)); +explain partitions select * from t1 +where a between '2006-01-01' and '2007-06-01'; +drop table t1; + +# +# Bug 20397: Partitions: Crash when using non-existing engine +# +create table t1 (a int) +engine = x +partition by key (a); +show create table t1; +drop table t1; + +create table t1 (a int) +engine = innodb +partition by list (a) +(partition p0 values in (0)); + +-- error ER_MIX_HANDLER_ERROR +alter table t1 engine = x; +show create table t1; +drop table t1; + +# BUG#26117: index_merge sort-union over partitioned table crashes + +create table t1 +( + id int unsigned auto_increment, + time datetime not null, + first_name varchar(40), + last_name varchar(50), + primary key (id, time), + index first_index (first_name), + index last_index (last_name) +) engine=Innodb partition by range (to_days(time)) ( + partition p1 values less than (to_days('2007-02-07')), + partition p2 values less than (to_days('2007-02-08')), + partition p3 values less than MAXVALUE +); + +insert into t1 (time, first_name, last_name) values ('2007-02-07', 'Q', 'Robert'), +('2007-02-07', 'Mark', 'Nate'), ('2007-02-07', 'Nate', 'Oscar'), +('2007-02-07', 'Zack', 'Alice'), ('2007-02-07', 'Jack', 'Kathy'), +('2007-02-06', 'Alice', 'Alice'), ('2007-02-06', 'Brian', 'Charles'), +('2007-02-06', 'Charles', 'David'), ('2007-02-06', 'David', 'Eric'), +('2007-02-07', 'Hector', 'Isaac'), ('2007-02-07', 'Oscar', 'Patricia'), +('2007-02-07', 'Patricia', 'Q'), ('2007-02-07', 'X', 'Yuri'), +('2007-02-07', 'Robert', 'Shawn'), ('2007-02-07', 'Kathy', 'Lois'), +('2007-02-07', 'Eric', 'Francis'), ('2007-02-06', 'Shawn', 'Theron'), +('2007-02-06', 'U', 'Vincent'), ('2007-02-06', 'Francis', 'George'), +('2007-02-06', 'George', 'Hector'), ('2007-02-06', 'Vincent', 'Walter'), +('2007-02-06', 'Walter', 'X'), ('2007-02-07', 'Lois', 'Mark'), +('2007-02-07', 'Yuri', 'Zack'), ('2007-02-07', 'Isaac', 'Jack'), +('2007-02-07', 'Sharon', 'Mark'), ('2007-02-07', 'Michael', 'Michelle'), +('2007-02-07', 'Derick', 'Nathan'), ('2007-02-07', 'Peter', 'Xavier'), +('2007-02-07', 'Fred', 'Harold'), ('2007-02-07', 'Katherine', 'Lisa'), +('2007-02-07', 'Tom', 'Rina'), ('2007-02-07', 'Jerry', 'Victor'), +('2007-02-07', 'Alexander', 'Terry'), ('2007-02-07', 'Justin', 'John'), +('2007-02-07', 'Greg', 'Ernest'), ('2007-02-07', 'Robert', 'Q'), +('2007-02-07', 'Nate', 'Mark'), ('2007-02-07', 'Oscar', 'Nate'), +('2007-02-07', 'Alice', 'Zack'), ('2007-02-07', 'Kathy', 'Jack'), +('2007-02-06', 'Alice', 'Alice'), ('2007-02-06', 'Charles', 'Brian'), +('2007-02-06', 'David', 'Charles'), ('2007-02-06', 'Eric', 'David'), +('2007-02-07', 'Isaac', 'Hector'), ('2007-02-07', 'Patricia', 'Oscar'), +('2007-02-07', 'Q', 'Patricia'), ('2007-02-07', 'Yuri', 'X'), +('2007-02-07', 'Shawn', 'Robert'), ('2007-02-07', 'Lois', 'Kathy'), +('2007-02-07', 'Francis', 'Eric'), ('2007-02-06', 'Theron', 'Shawn'), +('2007-02-06', 'Vincent', 'U'), ('2007-02-06', 'George', 'Francis'), +('2007-02-06', 'Hector', 'George'), ('2007-02-06', 'Walter', 'Vincent'), +('2007-02-06', 'X', 'Walter'), ('2007-02-07', 'Mark', 'Lois'), +('2007-02-07', 'Zack', 'Yuri'), ('2007-02-07', 'Jack', 'Isaac'), +('2007-02-07', 'Mark', 'Sharon'), ('2007-02-07', 'Michelle', 'Michael'), +('2007-02-07', 'Nathan', 'Derick'), ('2007-02-07', 'Xavier', 'Peter'), +('2007-02-07', 'Harold', 'Fred'), ('2007-02-07', 'Lisa', 'Katherine'), +('2007-02-07', 'Rina', 'Tom'), ('2007-02-07', 'Victor', 'Jerry'), +('2007-02-07', 'Terry', 'Alexander'), ('2007-02-07', 'John', 'Justin'), +('2007-02-07', 'Ernest', 'Greg'); + +SELECT * FROM t1 WHERE first_name='Andy' OR last_name='Jake'; + +drop table t1; + +# +# BUG#30583 - Partition on DOUBLE key + INNODB + count(*) == crash +# +CREATE TABLE t1 (a DOUBLE NOT NULL, KEY(a)) ENGINE=InnoDB +PARTITION BY KEY(a) PARTITIONS 10; +INSERT INTO t1 VALUES(1),(2); +SELECT COUNT(*) FROM t1; +DROP TABLE t1; + +# +# Bug #31893 Partitions: crash if subpartitions and engine change +# +create table t1 (int_column int, char_column char(5)) + PARTITION BY RANGE (int_column) subpartition by key (char_column) subpartitions 2 + (PARTITION p1 VALUES LESS THAN (5) ENGINE = InnoDB); +alter table t1 +ENGINE = MyISAM +PARTITION BY RANGE (int_column) + subpartition by key (char_column) subpartitions 2 + (PARTITION p1 VALUES LESS THAN (5)); +show create table t1; +drop table t1; + +# +# BUG#46483 - drop table of partitioned table may leave extraneous file +# Note: was only repeatable with InnoDB plugin +# +CREATE TABLE t1 (a INT) ENGINE=InnoDB + PARTITION BY list(a) (PARTITION p1 VALUES IN (1)); +CREATE INDEX i1 ON t1 (a); +DROP TABLE t1; +let $MYSQLD_DATADIR= `SELECT @@datadir`; +# Before the fix it should show extra file like #sql-2405_2.par +--list_files $MYSQLD_DATADIR/test/ * diff --git a/mysql-test/t/partition_innodb_builtin.test b/mysql-test/t/partition_innodb_builtin.test new file mode 100644 index 00000000000..a9be41c7455 --- /dev/null +++ b/mysql-test/t/partition_innodb_builtin.test @@ -0,0 +1,67 @@ +--source include/have_partition.inc +--source include/have_innodb.inc +--source include/have_not_innodb_plugin.inc + +# +# Bug#32430 - show engine innodb status causes errors +# +SET NAMES utf8; +CREATE TABLE `t``\""e` (a INT, PRIMARY KEY (a)) +ENGINE=InnoDB +PARTITION BY RANGE (a) +SUBPARTITION BY HASH (a) +(PARTITION `p0``\""e` VALUES LESS THAN (100) + (SUBPARTITION `sp0``\""e`, + SUBPARTITION `sp1``\""e`), + PARTITION `p1``\""e` VALUES LESS THAN (MAXVALUE) + (SUBPARTITION `sp2``\""e`, + SUBPARTITION `sp3``\""e`)); +INSERT INTO `t``\""e` VALUES (0), (2), (6), (10), (14), (18), (22); +START TRANSACTION; +--echo # con1 +connect(con1,localhost,root,,); +SET NAMES utf8; +START TRANSACTION; +--echo # default connection +connection default; +UPDATE `t``\""e` SET a = 16 WHERE a = 0; +--echo # con1 +connection con1; +UPDATE `t``\""e` SET a = 8 WHERE a = 22; +let $id_1= `SELECT CONNECTION_ID()`; +SEND; +UPDATE `t``\""e` SET a = 12 WHERE a = 0; +--echo # default connection +connection default; +let $wait_timeout= 2; +let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST +WHERE ID = $id_1 AND STATE = 'Searching rows for update'; +--source include/wait_condition.inc +#--echo # tested wait condition $wait_condition_reps times +--error ER_LOCK_DEADLOCK +UPDATE `t``\""e` SET a = 4 WHERE a = 22; +--echo # First table reported in 'SHOW ENGINE InnoDB STATUS' +# RECORD LOCKS space id 0 page no 50 n bits 80 index `PRIMARY` in \ +# Database `test`, Table `t1`, Partition `p0`, Subpartition `sp0` \ +# trx id 0 775 +# NOTE: replace_regex is very slow on match copy/past '(.*)' regex's +# on big texts, removing a lot of text before + after makes it much faster. +#/.*in (.*) trx.*/\1/ +--replace_regex /.*RECORD LOCKS space id [0-9]* page no [0-9]* n bits [0-9]* // / trx id .*// /.*index .* in // +SHOW ENGINE InnoDB STATUS; +set @old_sql_mode = @@sql_mode; +set sql_mode = 'ANSI_QUOTES'; +# INNODB_LOCKS only exists in innodb_plugin +#SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS; +--replace_regex /.*RECORD LOCKS space id [0-9]* page no [0-9]* n bits [0-9]* // / trx id .*// /.*index .* in // +SHOW ENGINE InnoDB STATUS; +set @@sql_mode = @old_sql_mode; +--echo # con1 +connection con1; +REAP; +ROLLBACK; +disconnect con1; +--echo # default connection +connection default; +DROP TABLE `t``\""e`; +SET NAMES DEFAULT; diff --git a/mysql-test/t/partition_innodb_plugin.test b/mysql-test/t/partition_innodb_plugin.test new file mode 100644 index 00000000000..fed8c96424a --- /dev/null +++ b/mysql-test/t/partition_innodb_plugin.test @@ -0,0 +1,75 @@ +--source include/have_partition.inc +--source include/have_innodb.inc +--source suite/innodb/include/have_innodb_plugin.inc + +# +# Bug#32430 - show engine innodb status causes errors +# +SET NAMES utf8; +CREATE TABLE `t``\""e` (a INT, PRIMARY KEY (a)) +ENGINE=InnoDB +PARTITION BY RANGE (a) +SUBPARTITION BY HASH (a) +(PARTITION `p0``\""e` VALUES LESS THAN (100) + (SUBPARTITION `sp0``\""e`, + SUBPARTITION `sp1``\""e`), + PARTITION `p1``\""e` VALUES LESS THAN (MAXVALUE) + (SUBPARTITION `sp2``\""e`, + SUBPARTITION `sp3``\""e`)); +INSERT INTO `t``\""e` VALUES (0), (2), (6), (10), (14), (18), (22); +START TRANSACTION; +--echo # con1 +connect(con1,localhost,root,,); +SET NAMES utf8; +START TRANSACTION; +--echo # default connection +connection default; +UPDATE `t``\""e` SET a = 16 WHERE a = 0; +--echo # con1 +connection con1; +UPDATE `t``\""e` SET a = 8 WHERE a = 22; +let $id_1= `SELECT CONNECTION_ID()`; +SEND; +UPDATE `t``\""e` SET a = 12 WHERE a = 0; +--echo # default connection +connection default; +let $wait_timeout= 2; +let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST +WHERE ID = $id_1 AND STATE = 'Searching rows for update'; +--source include/wait_condition.inc +#--echo # tested wait condition $wait_condition_reps times +# INNODB_LOCKS only exists in innodb_plugin +--sorted_result +SELECT lock_table, COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS +GROUP BY lock_table; +set @old_sql_mode = @@sql_mode; +set sql_mode = 'ANSI_QUOTES'; +--sorted_result +SELECT lock_table, COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS +GROUP BY lock_table; +set @@sql_mode = @old_sql_mode; +--error ER_LOCK_DEADLOCK +UPDATE `t``\""e` SET a = 4 WHERE a = 22; +--echo # First table reported in 'SHOW ENGINE InnoDB STATUS' +# RECORD LOCKS space id 0 page no 50 n bits 80 index `PRIMARY` in \ +# Database `test`, Table `t1`, Partition `p0`, Subpartition `sp0` \ +# trx id 0 775 +# NOTE: replace_regex is very slow on match copy/past '(.*)' regex's +# on big texts, removing a lot of text before + after makes it much faster. +#/.*in (.*) trx.*/\1/ +--replace_regex /.*RECORD LOCKS space id [0-9]* page no [0-9]* n bits [0-9]* // / trx id .*// /.*index .* in // +SHOW ENGINE InnoDB STATUS; +set @old_sql_mode = @@sql_mode; +set sql_mode = 'ANSI_QUOTES'; +--replace_regex /.*RECORD LOCKS space id [0-9]* page no [0-9]* n bits [0-9]* // / trx id .*// /.*index .* in // +SHOW ENGINE InnoDB STATUS; +set @@sql_mode = @old_sql_mode; +--echo # con1 +connection con1; +REAP; +ROLLBACK; +disconnect con1; +--echo # default connection +connection default; +DROP TABLE `t``\""e`; +SET NAMES DEFAULT; diff --git a/mysql-test/t/partition_innodb_semi_consistent-master.opt b/mysql-test/t/partition_innodb_semi_consistent-master.opt new file mode 100644 index 00000000000..e76299453d3 --- /dev/null +++ b/mysql-test/t/partition_innodb_semi_consistent-master.opt @@ -0,0 +1 @@ +--innodb_lock_wait_timeout=2 diff --git a/mysql-test/t/partition_innodb_semi_consistent.test b/mysql-test/t/partition_innodb_semi_consistent.test new file mode 100644 index 00000000000..6a6a7cf958e --- /dev/null +++ b/mysql-test/t/partition_innodb_semi_consistent.test @@ -0,0 +1,197 @@ +-- source include/have_partition.inc +-- source include/not_embedded.inc +-- source include/have_innodb.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# basic tests of semi-consistent reads +# for verifying Bug#40595: Non-matching rows not released with READ-COMMITTED +# on tables with partitions + +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +set binlog_format=mixed; +set session transaction isolation level repeatable read; +create table t1(a int not null) +engine=innodb +DEFAULT CHARSET=latin1 +PARTITION BY RANGE(a) +(PARTITION p0 VALUES LESS THAN (20), + PARTITION p1 VALUES LESS THAN MAXVALUE); +insert into t1 values (1),(2),(3),(4),(5),(6),(7); +set autocommit=0; +# this should lock the entire table +select * from t1 where a=3 lock in share mode; +connection b; +set binlog_format=mixed; +set session transaction isolation level repeatable read; +set autocommit=0; +-- error ER_LOCK_WAIT_TIMEOUT +update t1 set a=10 where a=5; +connection a; +#DELETE FROM t1 WHERE a=5; +commit; +connection b; +# perform a semi-consisent read (and unlock non-matching rows) +set session transaction isolation level read committed; +update t1 set a=10 where a=5; +connection a; +-- error ER_LOCK_WAIT_TIMEOUT +select * from t1 where a=2 for update; +# this should lock the records (1),(2) +select * from t1 where a=2 limit 1 for update; +connection b; +# semi-consistent read will skip non-matching locked rows a=1, a=2 +update t1 set a=11 where a=6; +-- error ER_LOCK_WAIT_TIMEOUT +update t1 set a=12 where a=2; +-- error ER_LOCK_WAIT_TIMEOUT +update t1 set a=13 where a=1; +connection a; +commit; +connection b; +update t1 set a=14 where a=1; +commit; +connection a; +--sorted_result +select * from t1; +drop table t1; + +connection default; +disconnect a; +disconnect b; + +# +# Bug #31310: Locked rows silently skipped in read-committed isolation level. +# (This also tests the '*_semi_consistent*' functions in partitioning) +# Copied from include/mix1.inc + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +SET SESSION AUTOCOMMIT = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +set binlog_format=mixed; +--echo # Switch to connection con1 +connection con1; + +eval +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) +ENGINE = InnoDB +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (300), + PARTITION p1 VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (1,2); + +--echo # 1. test for locking: + +BEGIN; +--enable_info +UPDATE t1 SET b = 12 WHERE a = 1; +--disable_info +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; + +--enable_info +--disable_abort_on_error +--error ER_LOCK_WAIT_TIMEOUT +UPDATE t1 SET b = 21 WHERE a = 1; +--disable_info + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; +ROLLBACK; + +--echo # 2. test for serialized update: + +CREATE TABLE t2 (a INT); + +TRUNCATE t1; +INSERT INTO t1 VALUES (1,'init'); + +DELIMITER |; +CREATE PROCEDURE p1() +BEGIN + UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1; + INSERT INTO t2 VALUES (); +END| +DELIMITER ;| + +BEGIN; +--enable_info +UPDATE t1 SET b = CONCAT(b, '+con1') WHERE a = 1; +--disable_info +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; + +--send CALL p1; + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; +COMMIT; + +let $bug31310 = 1; +while ($bug31310) +{ + let $bug31310= `SELECT 1 - COUNT(*) FROM t2`; +} + +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; +--reap +SELECT * FROM t1; + +--echo # Switch to connection con1 +connection con1; + +--echo # 3. test for updated key column: + +TRUNCATE t1; +TRUNCATE t2; + +INSERT INTO t1 VALUES (1,'init'); + +BEGIN; +--enable_info +UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1; +--disable_info +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; + +--send CALL p1; + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; +COMMIT; + +let $bug31310 = 1; +while ($bug31310) +{ + let $bug31310= `SELECT 1 - COUNT(*) FROM t2`; +} + +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; +SELECT * FROM t1; + +connection default; +disconnect con1; +disconnect con2; +DROP PROCEDURE p1; +DROP TABLE t1, t2; + diff --git a/mysql-test/t/partition_innodb_stmt.test b/mysql-test/t/partition_innodb_stmt.test new file mode 100644 index 00000000000..d6181ce068e --- /dev/null +++ b/mysql-test/t/partition_innodb_stmt.test @@ -0,0 +1,60 @@ +--source include/have_partition.inc +--source include/have_binlog_format_statement.inc +--source include/have_innodb.inc + +--echo # connection default +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; + +CREATE TABLE t1 +( + id SMALLINT NOT NULL, + PRIMARY KEY (id) +) ENGINE=innodb +PARTITION BY RANGE (id) +( + PARTITION p1 VALUES LESS THAN (2), + PARTITION p2 VALUES LESS THAN (4), + PARTITION p3 VALUES LESS THAN (10) +); + +INSERT INTO t1 VALUES (1),(2),(3); + +--echo # Test READ COMMITTED -> REPEATABLE READ +FLUSH TABLES; +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +SELECT * FROM t1; + +connect (con1, localhost, root,,); +connection con1; + +--echo #connection con1 +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +INSERT INTO t1 VALUES(7); +COMMIT; + +connection default; +--echo # connection default +COMMIT; + +FLUSH TABLES; + +--echo # Test REPEATABLE READ -> READ COMMITTED +SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +SELECT * FROM t1; + +connection con1; + +--echo # connection con1 +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +--error ER_BINLOG_LOGGING_IMPOSSIBLE +INSERT INTO t1 VALUES(9); +COMMIT; + +disconnect con1; +connection default; +COMMIT; +DROP TABLE t1; diff --git a/mysql-test/t/partition_list.test b/mysql-test/t/partition_list.test new file mode 100644 index 00000000000..1c76de9d55a --- /dev/null +++ b/mysql-test/t/partition_list.test @@ -0,0 +1,186 @@ +#--disable_abort_on_error +# +# Simple test for the partition storage engine +# testing list partitioning +# +-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Bug 20733: Zerofill columns gives wrong result with partitioned tables +# +create table t1 (a int unsigned) +partition by list (a) +(partition p0 values in (0), + partition p1 values in (1), + partition pnull values in (null), + partition p2 values in (2)); + +insert into t1 values (null),(0),(1),(2); +select * from t1 where a < 2; +select * from t1 where a <= 0; +select * from t1 where a < 1; +select * from t1 where a > 0; +select * from t1 where a > 1; +select * from t1 where a >= 0; +select * from t1 where a >= 1; +select * from t1 where a is null; +select * from t1 where a is not null; +select * from t1 where a is null or a > 0; +drop table t1; + +create table t1 (a int unsigned, b int) +partition by list (a) +subpartition by hash (b) +subpartitions 2 +(partition p0 values in (0), + partition p1 values in (1), + partition pnull values in (null, 2), + partition p3 values in (3)); +insert into t1 values (0,0),(0,1),(1,0),(1,1),(null,0),(null,1); +insert into t1 values (2,0),(2,1),(3,0),(3,1); + +explain partitions select * from t1 where a is null; +select * from t1 where a is null; +explain partitions select * from t1 where a = 2; +select * from t1 where a = 2; +select * from t1 where a <= 0; +select * from t1 where a < 3; +select * from t1 where a >= 1 or a is null; +drop table t1; + +# +# Test ordinary list partitioning that it works ok +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null) +partition by list(a) +partitions 2 +(partition x123 values in (1,5,6), + partition x234 values in (4,7,8)); + +INSERT into t1 VALUES (1,1,1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT into t1 VALUES (2,1,1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT into t1 VALUES (3,1,1); +INSERT into t1 VALUES (4,1,1); +INSERT into t1 VALUES (5,1,1); +INSERT into t1 VALUES (6,1,1); +INSERT into t1 VALUES (7,1,1); +INSERT into t1 VALUES (8,1,1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT into t1 VALUES (9,1,1); +INSERT into t1 VALUES (1,2,1); +INSERT into t1 VALUES (1,3,1); +INSERT into t1 VALUES (1,4,1); +INSERT into t1 VALUES (7,2,1); +INSERT into t1 VALUES (7,3,1); +INSERT into t1 VALUES (7,4,1); + +SELECT * from t1; +SELECT * from t1 WHERE a=1; +SELECT * from t1 WHERE a=7; +SELECT * from t1 WHERE b=2; + +UPDATE t1 SET a=8 WHERE a=7 AND b=3; +SELECT * from t1; +UPDATE t1 SET a=8 WHERE a=5 AND b=1; +SELECT * from t1; + +DELETE from t1 WHERE a=8; +SELECT * from t1; +DELETE from t1 WHERE a=2; +SELECT * from t1; +DELETE from t1 WHERE a=5 OR a=6; +SELECT * from t1; + +ALTER TABLE t1 +partition by list(a) +partitions 2 +(partition x123 values in (1,5,6), + partition x234 values in (4,7,8)); +SELECT * from t1; +INSERT into t1 VALUES (6,2,1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT into t1 VALUES (2,2,1); + +drop table t1; +# +# Subpartition by hash, two partitions and two subpartitions +# Defined node group +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by list (a) +subpartition by hash (a+b) +( partition x1 values in (1,2,3) + ( subpartition x11 nodegroup 0, + subpartition x12 nodegroup 1), + partition x2 values in (4,5,6) + ( subpartition x21 nodegroup 0, + subpartition x22 nodegroup 1) +); + +INSERT into t1 VALUES (1,1,1); +INSERT into t1 VALUES (4,1,1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT into t1 VALUES (7,1,1); +UPDATE t1 SET a=5 WHERE a=1; +SELECT * from t1; +UPDATE t1 SET a=6 WHERE a=4; +SELECT * from t1; +DELETE from t1 WHERE a=6; +SELECT * from t1; + +drop table t1; + +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by list (a) +(partition x1 values in (1,2,9,4) tablespace ts1); + +drop table t1; + +# +#Bug #17173 Partitions: less-than search fails +# +CREATE TABLE t1 (s1 int) PARTITION BY LIST (s1) +(PARTITION p1 VALUES IN (1), +PARTITION p2 VALUES IN (2), +PARTITION p3 VALUES IN (3), +PARTITION p4 VALUES IN (4), +PARTITION p5 VALUES IN (5)); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +SELECT COUNT(*) FROM t1 WHERE s1 < 3; +DROP TABLE t1; + +# +# Bug 19281 Partitions: Auto-increment value lost +# +create table t1 (a int auto_increment primary key) +auto_increment=100 +partition by list (a) +(partition p0 values in (1, 100)); +create index inx on t1 (a); +insert into t1 values (null); +select * from t1; +drop table t1; + +--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +create table t1 (a char(1)) +partition by list (ascii(ucase(a))) +(partition p1 values in (2)); + diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test new file mode 100644 index 00000000000..bf9b5ed174e --- /dev/null +++ b/mysql-test/t/partition_mgm.test @@ -0,0 +1,91 @@ +-- source include/have_partition.inc +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# +# Bug 40389: REORGANIZE PARTITION crashes when only using one partition +# +CREATE TABLE t1 (a INT PRIMARY KEY) +ENGINE MYISAM +PARTITION BY HASH (a) +PARTITIONS 1; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +ALTER TABLE t1 REORGANIZE PARTITION; +DROP TABLE t1; + +# +# Bug 21143: mysqld hang when error in number of subparts in +# REORGANIZE command +# +create table t1 (a int) +partition by range (a) +subpartition by key (a) +(partition p0 values less than (10) (subpartition sp00, subpartition sp01), + partition p1 values less than (20) (subpartition sp10, subpartition sp11)); + +-- error ER_PARTITION_WRONG_NO_SUBPART_ERROR +alter table t1 reorganize partition p0 into +(partition p0 values less than (10) (subpartition sp00, +subpartition sp01, subpartition sp02)); +drop table t1; + +CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30)) +PARTITION BY HASH(YEAR(f_date)) PARTITIONS 2; +SHOW CREATE TABLE t1; +let $MYSQLD_DATADIR= `select @@datadir`; +-- file_exists $MYSQLD_DATADIR/test/t1#P#p0.MYD +-- file_exists $MYSQLD_DATADIR/test/t1#P#p0.MYI +-- file_exists $MYSQLD_DATADIR/test/t1#P#p1.MYD +-- file_exists $MYSQLD_DATADIR/test/t1#P#p1.MYI +-- file_exists $MYSQLD_DATADIR/test/t1.frm +-- file_exists $MYSQLD_DATADIR/test/t1.par +ALTER TABLE t1 COALESCE PARTITION 1; +SHOW CREATE TABLE t1; +-- file_exists $MYSQLD_DATADIR/test/t1#P#p0.MYD +-- file_exists $MYSQLD_DATADIR/test/t1#P#p0.MYI +-- file_exists $MYSQLD_DATADIR/test/t1.frm +-- file_exists $MYSQLD_DATADIR/test/t1.par +drop table t1; +# +# Bug 20767: REORGANIZE partition crashes +# +create table t1 (a int) +partition by list (a) +subpartition by hash (a) +(partition p11 values in (1,2), + partition p12 values in (3,4)); + +alter table t1 REORGANIZE partition p11, p12 INTO +(partition p1 values in (1,2,3,4)); + +alter table t1 REORGANIZE partition p1 INTO +(partition p11 values in (1,2), + partition p12 values in (3,4)); + +drop table t1; +# +# Verification tests for bug#14326 +# +CREATE TABLE t1 (a INT) +/*!50100 PARTITION BY HASH (a) +/* Test + of multi-line + comment */ +PARTITIONS 5 */; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (a INT) +/*!50100 PARTITION BY HASH (a) +-- with a single line comment embedded +PARTITIONS 5 */; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (a INT) +/*!50100 PARTITION BY HASH (a) +PARTITIONS 5 */; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (a INT) /*!50100 PARTITION BY HASH (a) PARTITIONS 5 */; +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/t/partition_mgm_err.test b/mysql-test/t/partition_mgm_err.test new file mode 100644 index 00000000000..0f8b8d3cd90 --- /dev/null +++ b/mysql-test/t/partition_mgm_err.test @@ -0,0 +1,225 @@ +# +# Simple test for the erroneos create statements using the +# partition storage engine +# +-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Try faulty DROP PARTITION and COALESCE PARTITION +# +CREATE TABLE t1 (a int, b int) +PARTITION BY RANGE (a) +(PARTITION x0 VALUES LESS THAN (2), + PARTITION x1 VALUES LESS THAN (4), + PARTITION x2 VALUES LESS THAN (6), + PARTITION x3 VALUES LESS THAN (8), + PARTITION x4 VALUES LESS THAN (10), + PARTITION x5 VALUES LESS THAN (12), + PARTITION x6 VALUES LESS THAN (14), + PARTITION x7 VALUES LESS THAN (16), + PARTITION x8 VALUES LESS THAN (18), + PARTITION x9 VALUES LESS THAN (20)); + +--error ER_REORG_OUTSIDE_RANGE +ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO +(PARTITION x01 VALUES LESS THAN (2), + PARTITION x11 VALUES LESS THAN (5)); + +--error ER_DROP_PARTITION_NON_EXISTENT +ALTER TABLE t1 DROP PARTITION x0, x1, x2, x3, x3; + +--error ER_DROP_PARTITION_NON_EXISTENT +ALTER TABLE t1 DROP PARTITION x0, x1, x2, x10; + +--error ER_DROP_PARTITION_NON_EXISTENT +ALTER TABLE t1 DROP PARTITION x10, x1, x2, x1; + +--error ER_DROP_PARTITION_NON_EXISTENT +ALTER TABLE t1 DROP PARTITION x10, x1, x2, x3; + +--error ER_REORG_PARTITION_NOT_EXIST +ALTER TABLE t1 REORGANIZE PARTITION x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10 INTO +(PARTITION x11 VALUES LESS THAN (22)); + +--error ER_SAME_NAME_PARTITION +ALTER TABLE t1 REORGANIZE PARTITION x0,x1,x2 INTO +(PARTITION x3 VALUES LESS THAN (6)); + +--error ER_CONSECUTIVE_REORG_PARTITIONS +ALTER TABLE t1 REORGANIZE PARTITION x0, x2 INTO +(PARTITION x11 VALUES LESS THAN (2)); + +--error ER_DROP_PARTITION_NON_EXISTENT +ALTER TABLE t1 REORGANIZE PARTITION x0, x1, x1 INTO +(PARTITION x11 VALUES LESS THAN (4)); + +--error ER_REORG_OUTSIDE_RANGE +ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO +(PARTITION x01 VALUES LESS THAN (5)); + +--error ER_REORG_OUTSIDE_RANGE +ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO +(PARTITION x01 VALUES LESS THAN (4), + PARTITION x11 VALUES LESS THAN (2)); + +--error ER_RANGE_NOT_INCREASING_ERROR +ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO +(PARTITION x01 VALUES LESS THAN (6), + PARTITION x11 VALUES LESS THAN (4)); + +DROP TABLE t1; + +CREATE TABLE t1 (a int) +PARTITION BY KEY (a) +PARTITIONS 2; + +--error ER_SAME_NAME_PARTITION +ALTER TABLE t1 ADD PARTITION (PARTITION p1); + +DROP TABLE t1; + +--error ER_SAME_NAME_PARTITION +CREATE TABLE t1 (a int) +PARTITION BY KEY (a) +(PARTITION x0, PARTITION x1, PARTITION x2, PARTITION x3, PARTITION x3); + +CREATE TABLE t1 (a int) +PARTITION BY RANGE (a) +SUBPARTITION BY KEY (a) +SUBPARTITIONS 2 +(PARTITION x0 VALUES LESS THAN (4), + PARTITION x1 VALUES LESS THAN (8)); + +--error ER_RANGE_NOT_INCREASING_ERROR +ALTER TABLE t1 ADD PARTITION (PARTITION x2 VALUES LESS THAN (5) +(SUBPARTITION sp0, SUBPARTITION sp1)); + +--error ER_ADD_PARTITION_SUBPART_ERROR +ALTER TABLE t1 ADD PARTITION (PARTITION x2 VALUES LESS THAN (12) +(SUBPARTITION sp0, SUBPARTITION sp1, SUBPARTITION sp2)); + +DROP TABLE t1; + +CREATE TABLE t1 (a int) +PARTITION BY LIST (a) +(PARTITION x0 VALUES IN (1,2,3), + PARTITION x1 VALUES IN (4,5,6)); + +--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR +ALTER TABLE t1 ADD PARTITION (PARTITION x2 VALUES IN (3,4)); + +DROP TABLE t1; + +CREATE TABLE t1 (a int); + +--error ER_PARTITION_MGMT_ON_NONPARTITIONED +ALTER TABLE t1 ADD PARTITION PARTITIONS 1; + +--error ER_PARTITION_MGMT_ON_NONPARTITIONED +ALTER TABLE t1 DROP PARTITION x1; + +--error ER_PARTITION_MGMT_ON_NONPARTITIONED +ALTER TABLE t1 COALESCE PARTITION 1; + +--error ER_PARTITION_MGMT_ON_NONPARTITIONED +ALTER TABLE t1 ANALYZE PARTITION p1; + +--error ER_PARTITION_MGMT_ON_NONPARTITIONED +ALTER TABLE t1 CHECK PARTITION p1; + +--error ER_PARTITION_MGMT_ON_NONPARTITIONED +ALTER TABLE t1 OPTIMIZE PARTITION p1; + +--error ER_PARTITION_MGMT_ON_NONPARTITIONED +ALTER TABLE t1 REPAIR PARTITION p1; + +DROP TABLE t1; + +CREATE TABLE t1 (a int) +PARTITION BY KEY (a) +(PARTITION x0, PARTITION x1); + +--error ER_ADD_PARTITION_NO_NEW_PARTITION +ALTER TABLE t1 ADD PARTITION PARTITIONS 0; + +--error ER_TOO_MANY_PARTITIONS_ERROR +ALTER TABLE t1 ADD PARTITION PARTITIONS 1024; + +--error ER_ONLY_ON_RANGE_LIST_PARTITION +ALTER TABLE t1 DROP PARTITION x0; + +ALTER TABLE t1 COALESCE PARTITION 1; + +--error ER_DROP_LAST_PARTITION +ALTER TABLE t1 COALESCE PARTITION 1; + +DROP TABLE t1; + +CREATE TABLE t1 (a int) +PARTITION BY RANGE (a) +(PARTITION x0 VALUES LESS THAN (4), + PARTITION x1 VALUES LESS THAN (8)); + +--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR +ALTER TABLE t1 ADD PARTITION PARTITIONS 1; + +--error ER_DROP_PARTITION_NON_EXISTENT +ALTER TABLE t1 DROP PARTITION x2; + +--error ER_COALESCE_ONLY_ON_HASH_PARTITION +ALTER TABLE t1 COALESCE PARTITION 1; + +ALTER TABLE t1 DROP PARTITION x1; + +--error ER_DROP_LAST_PARTITION +ALTER TABLE t1 DROP PARTITION x0; + +DROP TABLE t1; + +# +# Bug# 16534 - Trying to add multiple partitions crashes server +# +CREATE TABLE t1 ( id INT NOT NULL, + fname VARCHAR(50) NOT NULL, + lname VARCHAR(50) NOT NULL, + hired DATE NOT NULL ) +PARTITION BY RANGE(YEAR(hired)) ( + PARTITION p1 VALUES LESS THAN (1991), + PARTITION p2 VALUES LESS THAN (1996), + PARTITION p3 VALUES LESS THAN (2001), + PARTITION p4 VALUES LESS THAN (2005)); +ALTER TABLE t1 ADD PARTITION ( + PARTITION p5 VALUES LESS THAN (2010), + PARTITION p6 VALUES LESS THAN MAXVALUE); +DROP TABLE t1; + +# +#BUG 15523 ALTER TABLE ... PARTITION BY does not work +# +CREATE TABLE t1 (a INT); +SHOW CREATE TABLE t1; +ALTER TABLE t1 PARTITION BY KEY(a) PARTITIONS 2; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# +#BUG 15820 create table with 1 partition, doing ALTER TABLE ADD PARTITION fails +# +CREATE TABLE t1 (a INT) PARTITION BY HASH(a); +ALTER TABLE t1 ADD PARTITION PARTITIONS 4; +DROP TABLE t1; + +# +#BUG 15408: Partitions: subpartition names are not unique +# +--error ER_SAME_NAME_PARTITION +CREATE TABLE t1 (s1 int, s2 int) +PARTITION BY LIST (s1) +SUBPARTITION BY KEY (s2) ( +PARTITION p1 VALUES IN (0) (SUBPARTITION p1b), +PARTITION p2 VALUES IN (2) (SUBPARTITION p1b) +); diff --git a/mysql-test/t/partition_mgm_err2.test b/mysql-test/t/partition_mgm_err2.test new file mode 100644 index 00000000000..f683ec6277e --- /dev/null +++ b/mysql-test/t/partition_mgm_err2.test @@ -0,0 +1,26 @@ +# +# Test of partitions that require symlinks +# +--source include/have_partition.inc +--source include/have_symlink.inc + +# +# This test is disabled on windows due to BUG#19107 +# +--source include/not_windows.inc +# +# BUG: 14354 Partitions: data directory clause fails +# +--system rm -rf $MYSQLTEST_VARDIR/tmp/bug14354 +--system mkdir $MYSQLTEST_VARDIR/tmp/bug14354 +disable_query_log; +eval CREATE TABLE t1 (id int) PARTITION BY RANGE(id) ( +PARTITION p1 VALUES LESS THAN (20) ENGINE=myisam +DATA DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354" +INDEX DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354"); +enable_query_log; +INSERT INTO t1 VALUES (15); +--system test -f $MYSQLTEST_VARDIR/tmp/bug14354/t1#P#p1.MYD +--system test -f $MYSQLTEST_VARDIR/tmp/bug14354/t1#P#p1.MYI +DROP TABLE t1; +--system rm -rf $MYSQLTEST_VARDIR/tmp/bug14354 diff --git a/mysql-test/t/partition_not_embedded.test b/mysql-test/t/partition_not_embedded.test new file mode 100644 index 00000000000..5c512085a9e --- /dev/null +++ b/mysql-test/t/partition_not_embedded.test @@ -0,0 +1,53 @@ +-- source include/have_partition.inc +-- source include/not_embedded.inc +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings +let $MYSQLD_DATADIR= `SELECT @@datadir`; + +# +# Bug#30102: rename table does corrupt tables with partition files on failure +# +--echo # Bug#30102 test +CREATE TABLE t1 (a INT) +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (6), + PARTITION `p1....................` VALUES LESS THAN (9), + PARTITION p2 VALUES LESS THAN MAXVALUE); +# partition p1 is 't1#P#p1' + @002e * 20 = 107 characters + file ending +# total path lenght of './test/t1#P#p1@002e@002e<...>@002e.MY[ID]' is 118 chars +--echo # List of files in database `test`, all original t1-files here +--list_files $MYSQLD_DATADIR/test t1* +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +--echo # Renaming to a file name where the first partition is 250 chars +--echo # and the second partition is 350 chars +# 7,7 avoids the error message, which is not deterministic. +--error 7,7 +RENAME TABLE t1 TO `t2_new..............................................end`; +# 1234567890123456789012345678901234567890123456 +--echo # List of files in database `test`, should not be any t2-files here +--list_files $MYSQLD_DATADIR/test t2* +--echo # List of files in database `test`, should be all t1-files here +--list_files $MYSQLD_DATADIR/test t1* +--sorted_result +SELECT * FROM t1; +--echo # List of files in database `test`, should be all t1-files here +--list_files $MYSQLD_DATADIR/test t1* +--echo # Renaming to a file name where the first partition is 156 chars +--echo # and the second partition is 256 chars +# 7,7 avoids the error message, which is not deterministic. +--error 7,7 +RENAME TABLE t1 TO `t2_............................_end`; +# 1234567890123456789012345678 +# 7 + 4 + 5 + 28 * 5 = 16 + 140 = 156 +--echo # List of files in database `test`, should not be any t2-files here +--list_files $MYSQLD_DATADIR/test t2* +--echo # List of files in database `test`, should be all t1-files here +--list_files $MYSQLD_DATADIR/test t1* +--sorted_result +SELECT * FROM t1; +DROP TABLE t1; +--echo # Should not be any files left here +--list_files $MYSQLD_DATADIR/test t1* +--list_files $MYSQLD_DATADIR/test t2* +--echo # End of bug#30102 test. diff --git a/mysql-test/t/partition_not_windows-master.opt b/mysql-test/t/partition_not_windows-master.opt new file mode 100644 index 00000000000..b1392bfd485 --- /dev/null +++ b/mysql-test/t/partition_not_windows-master.opt @@ -0,0 +1 @@ +--symbolic-links=1 diff --git a/mysql-test/t/partition_not_windows.test b/mysql-test/t/partition_not_windows.test new file mode 100644 index 00000000000..333e12e2b16 --- /dev/null +++ b/mysql-test/t/partition_not_windows.test @@ -0,0 +1,214 @@ +# Non-windows specific partition tests. +--source include/not_windows.inc +--source include/have_partition.inc +# DATA DIRECTORY/INDEX DIRECTORY require symbolic link support +--source include/have_symlink.inc + +# The test for Bug 20770 is disabled on Windows due to BUG#19107; it +# should be moved into partition.test once the bug has been resolved. + +# +# Bug 20770 Partitions: DATA DIRECTORY clause change in reorganize +# doesn't remove old directory + +let $MYSQLD_DATADIR= `select @@datadir`; +let $data_directory = DATA DIRECTORY = '$MYSQLTEST_VARDIR/tmp'; +let $inx_directory = INDEX DIRECTORY = '$MYSQLTEST_VARDIR/tmp'; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval create table t1 (a int) engine myisam +partition by range (a) +subpartition by hash (a) +(partition p0 VALUES LESS THAN (1) $data_directory $inx_directory + (SUBPARTITION subpart00, SUBPARTITION subpart01)); + +--echo # Checking if file exists before alter +--file_exists $MYSQLD_DATADIR/test/t1.frm +--file_exists $MYSQLD_DATADIR/test/t1.par +--file_exists $MYSQLD_DATADIR/test/t1#P#p0#SP#subpart00.MYD +--file_exists $MYSQLD_DATADIR/test/t1#P#p0#SP#subpart00.MYI +--file_exists $MYSQLD_DATADIR/test/t1#P#p0#SP#subpart01.MYD +--file_exists $MYSQLD_DATADIR/test/t1#P#p0#SP#subpart01.MYI +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p0#SP#subpart00.MYD +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p0#SP#subpart01.MYD +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p0#SP#subpart00.MYI +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p0#SP#subpart01.MYI + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval ALTER TABLE t1 REORGANIZE PARTITION p0 INTO +(partition p1 VALUES LESS THAN (1) $data_directory $inx_directory + (SUBPARTITION subpart10, SUBPARTITION subpart11), + partition p2 VALUES LESS THAN (2) $data_directory $inx_directory + (SUBPARTITION subpart20, SUBPARTITION subpart21)); + +--echo # Checking if file exists after alter +--file_exists $MYSQLD_DATADIR/test/t1.frm +--file_exists $MYSQLD_DATADIR/test/t1.par +--file_exists $MYSQLD_DATADIR/test/t1#P#p1#SP#subpart10.MYD +--file_exists $MYSQLD_DATADIR/test/t1#P#p1#SP#subpart10.MYI +--file_exists $MYSQLD_DATADIR/test/t1#P#p1#SP#subpart11.MYD +--file_exists $MYSQLD_DATADIR/test/t1#P#p1#SP#subpart11.MYI +--file_exists $MYSQLD_DATADIR/test/t1#P#p2#SP#subpart20.MYD +--file_exists $MYSQLD_DATADIR/test/t1#P#p2#SP#subpart20.MYI +--file_exists $MYSQLD_DATADIR/test/t1#P#p2#SP#subpart21.MYD +--file_exists $MYSQLD_DATADIR/test/t1#P#p2#SP#subpart21.MYI +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p1#SP#subpart10.MYD +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p1#SP#subpart11.MYD +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p2#SP#subpart20.MYD +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p2#SP#subpart21.MYD +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p1#SP#subpart10.MYI +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p1#SP#subpart11.MYI +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p2#SP#subpart20.MYI +--file_exists $MYSQLTEST_VARDIR/tmp/t1#P#p2#SP#subpart21.MYI + +drop table t1; + +# +# Bug #24633 SQL MODE "NO_DIR_IN_CREATE" does not work with partitioned tables +# +disable_query_log; +eval create table t2 (i int ) +partition by range (i) +( + partition p01 values less than (1000) + data directory="$MYSQLTEST_VARDIR/tmp/" + index directory="$MYSQLTEST_VARDIR/tmp/" +); +enable_query_log; + +set @org_mode=@@sql_mode; +set @@sql_mode='NO_DIR_IN_CREATE'; +select @@sql_mode; +create table t1 (i int ) +partition by range (i) +( + partition p01 values less than (1000) + data directory='/not/existing' + index directory='/not/existing' +); +show create table t2; +DROP TABLE t1, t2; +set @@sql_mode=@org_mode; + +# +# Bug#32167: another privilege bypass with DATA/INDEX DIRECTORY +# + +let $MYSQLD_DATADIR= `select @@datadir`; + +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--error ER_WRONG_ARGUMENTS +eval CREATE TABLE t1(a INT) +PARTITION BY KEY (a) +(PARTITION p0 DATA DIRECTORY '$MYSQLD_DATADIR/test'); + +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--error ER_WRONG_ARGUMENTS +eval CREATE TABLE t1(a INT) +PARTITION BY KEY (a) +(PARTITION p0 INDEX DIRECTORY '$MYSQLD_DATADIR/test'); + +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--error ER_WRONG_ARGUMENTS +eval CREATE TABLE ts (id INT, purchased DATE) +PARTITION BY RANGE(YEAR(purchased)) +SUBPARTITION BY HASH(TO_DAYS(purchased)) ( +PARTITION p0 VALUES LESS THAN (1990) ( +SUBPARTITION s0a + DATA DIRECTORY = '$MYSQLD_DATADIR/test', +SUBPARTITION s0b + DATA DIRECTORY = '$MYSQLD_DATADIR/test' +)); + +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--error ER_WRONG_ARGUMENTS +eval CREATE TABLE ts (id INT, purchased DATE) +PARTITION BY RANGE(YEAR(purchased)) +SUBPARTITION BY HASH(TO_DAYS(purchased)) ( +PARTITION p0 VALUES LESS THAN (1990) ( +SUBPARTITION s0a + INDEX DIRECTORY = '$MYSQLD_DATADIR/test', +SUBPARTITION s0b + INDEX DIRECTORY = '$MYSQLD_DATADIR/test' +)); + +# End Windows specific test failures. + +# These tests contain non-Windows specific directory/file format. + +# +# Bug 25141: Crash Server on Partitioning command +# + +--disable_warnings +DROP TABLE IF EXISTS `example`; +--enable_warnings + +--mkdir $MYSQLTEST_VARDIR/p0Data +--mkdir $MYSQLTEST_VARDIR/p1Data +--mkdir $MYSQLTEST_VARDIR/p2Data +--mkdir $MYSQLTEST_VARDIR/p3Data +--mkdir $MYSQLTEST_VARDIR/p0Index +--mkdir $MYSQLTEST_VARDIR/p1Index +--mkdir $MYSQLTEST_VARDIR/p2Index +--mkdir $MYSQLTEST_VARDIR/p3Index +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE `example` ( + `ID_EXAMPLE` int(10) unsigned NOT NULL AUTO_INCREMENT, + `DESCRIPTION` varchar(30) NOT NULL, + `LEVEL` smallint(5) unsigned DEFAULT NULL, + PRIMARY KEY (`ID_EXAMPLE`) +) ENGINE = MYISAM +PARTITION BY HASH(ID_EXAMPLE)( +PARTITION p0 DATA DIRECTORY = '$MYSQLTEST_VARDIR/p0Data' +INDEX DIRECTORY = '$MYSQLTEST_VARDIR/p0Index', +PARTITION p1 DATA DIRECTORY = '$MYSQLTEST_VARDIR/p1Data' +INDEX DIRECTORY = '$MYSQLTEST_VARDIR/p1Index', +PARTITION p2 DATA DIRECTORY = '$MYSQLTEST_VARDIR/p2Data' +INDEX DIRECTORY = '$MYSQLTEST_VARDIR/p2Index', +PARTITION p3 DATA DIRECTORY = '$MYSQLTEST_VARDIR/p3Data' +INDEX DIRECTORY = '$MYSQLTEST_VARDIR/p3Index' +); + +let $MYSQLD_DATADIR= `select @@datadir`; + +--echo # Checking that MyISAM .MYD and .MYI are in test db and data/idx dir +--file_exists $MYSQLD_DATADIR/test/example#P#p0.MYI +--file_exists $MYSQLD_DATADIR/test/example#P#p0.MYD +--file_exists $MYSQLTEST_VARDIR/p0Data/example#P#p0.MYD +--file_exists $MYSQLTEST_VARDIR/p0Index/example#P#p0.MYI +--file_exists $MYSQLD_DATADIR/test/example#P#p1.MYI +--file_exists $MYSQLD_DATADIR/test/example#P#p1.MYD +--file_exists $MYSQLTEST_VARDIR/p1Data/example#P#p1.MYD +--file_exists $MYSQLTEST_VARDIR/p1Index/example#P#p1.MYI +--file_exists $MYSQLD_DATADIR/test/example#P#p2.MYI +--file_exists $MYSQLD_DATADIR/test/example#P#p2.MYD +--file_exists $MYSQLTEST_VARDIR/p2Data/example#P#p2.MYD +--file_exists $MYSQLTEST_VARDIR/p2Index/example#P#p2.MYI +--file_exists $MYSQLD_DATADIR/test/example#P#p3.MYI +--file_exists $MYSQLD_DATADIR/test/example#P#p3.MYD +--file_exists $MYSQLTEST_VARDIR/p3Data/example#P#p3.MYD +--file_exists $MYSQLTEST_VARDIR/p3Index/example#P#p3.MYI +DROP TABLE example; +--rmdir $MYSQLTEST_VARDIR/p0Data +--rmdir $MYSQLTEST_VARDIR/p1Data +--rmdir $MYSQLTEST_VARDIR/p2Data +--rmdir $MYSQLTEST_VARDIR/p3Data +--rmdir $MYSQLTEST_VARDIR/p0Index +--rmdir $MYSQLTEST_VARDIR/p1Index +--rmdir $MYSQLTEST_VARDIR/p2Index +--rmdir $MYSQLTEST_VARDIR/p3Index + +--error ER_CANT_CREATE_TABLE,1 +CREATE TABLE `example` ( + `ID_EXAMPLE` int(10) unsigned NOT NULL AUTO_INCREMENT, + `DESCRIPTION` varchar(30) NOT NULL, + `LEVEL` smallint(5) unsigned DEFAULT NULL, + PRIMARY KEY (`ID_EXAMPLE`) +) ENGINE = MYISAM +PARTITION BY HASH(ID_EXAMPLE)( +PARTITION p0 DATA DIRECTORY = '/not/existent/p0Data', +PARTITION p1 DATA DIRECTORY = '/not/existent/p1Data', +PARTITION p2 DATA DIRECTORY = '/not/existent/p2Data', +PARTITION p3 DATA DIRECTORY = '/not/existent/p3Data' +); diff --git a/mysql-test/t/partition_open_files_limit-master.opt b/mysql-test/t/partition_open_files_limit-master.opt new file mode 100644 index 00000000000..4c1ed0c3da3 --- /dev/null +++ b/mysql-test/t/partition_open_files_limit-master.opt @@ -0,0 +1 @@ +--open-files-limit=5 --max_connections=2 --table_open_cache=1 diff --git a/mysql-test/t/partition_open_files_limit.test b/mysql-test/t/partition_open_files_limit.test new file mode 100644 index 00000000000..e62ebd0ade7 --- /dev/null +++ b/mysql-test/t/partition_open_files_limit.test @@ -0,0 +1,26 @@ +--source include/have_partition.inc + +--disable_warnings +DROP TABLE IF EXISTS `t1`; +--enable_warnings + +# On some platforms the lowest possible open_files_limit is too high... +let $max_open_files_limit= `SELECT @@open_files_limit > 511`; +if ($max_open_files_limit) +{ + skip Need open_files_limit to be lower than 512; +} + +# +--echo # Bug#46922: crash when adding partitions and open_files_limit is reached +# +CREATE TABLE t1 (a INT PRIMARY KEY) +ENGINE=MyISAM PARTITION BY KEY () PARTITIONS 1; +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11); +--echo # if the bug exists, then crash will happen here +--replace_regex /file '.*'/file '<partition file>'/ +--error 23 +ALTER TABLE t1 ADD PARTITION PARTITIONS 511; +--sorted_result +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/t/partition_order.test b/mysql-test/t/partition_order.test new file mode 100644 index 00000000000..ad956361d00 --- /dev/null +++ b/mysql-test/t/partition_order.test @@ -0,0 +1,844 @@ +#--disable_abort_on_error +# +# Simple test for the partition storage engine +# Focuses on tests of ordered index read +# +-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Ordered index read, int type +# +CREATE TABLE t1 ( +a int not null, +b int not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 order by b; + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, unsigned int type +# +CREATE TABLE t1 ( +a int not null, +b int unsigned not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, tiny int type +# +CREATE TABLE t1 ( +a int not null, +b tinyint not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, unsigned tinyint type +# +CREATE TABLE t1 ( +a int not null, +b tinyint unsigned not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, smallint type +# +CREATE TABLE t1 ( +a int not null, +b smallint not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, unsigned smallint type +# +CREATE TABLE t1 ( +a int not null, +b smallint unsigned not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; +# +# Ordered index read, mediumint type +# +CREATE TABLE t1 ( +a int not null, +b mediumint not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, unsigned int type +# +CREATE TABLE t1 ( +a int not null, +b mediumint unsigned not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, unsigned bigint type +# +CREATE TABLE t1 ( +a int not null, +b bigint unsigned not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, bigint type +# +CREATE TABLE t1 ( +a int not null, +b bigint not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; +# +# Ordered index read, bigint type +# +CREATE TABLE t1 ( +a int not null, +b bigint not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, float type +# +CREATE TABLE t1 ( +a int not null, +b float not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, double type +# +CREATE TABLE t1 ( +a int not null, +b double not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, unsigned double type +# +CREATE TABLE t1 ( +a int not null, +b double unsigned not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, unsigned float type +# +CREATE TABLE t1 ( +a int not null, +b float unsigned not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, double precision type +# +CREATE TABLE t1 ( +a int not null, +b double precision not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; +# +# Ordered index read, unsigned double precision type +# +CREATE TABLE t1 ( +a int not null, +b double precision unsigned not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, decimal type +# +CREATE TABLE t1 ( +a int not null, +b decimal not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (2, 5); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; +# +# Ordered index read, char type +# +CREATE TABLE t1 ( +a int not null, +b char(10) not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '1'); +INSERT into t1 values (2, '5'); +INSERT into t1 values (30, '4'); +INSERT into t1 values (35, '2'); + +select * from t1 force index (b) where b > 0 order by b; + +drop table t1; + +# +# Ordered index read, varchar type +# +CREATE TABLE t1 ( +a int not null, +b varchar(10) not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '1'); +INSERT into t1 values (2, '5'); +INSERT into t1 values (30, '4'); +INSERT into t1 values (35, '2'); + +select * from t1 force index (b) where b > '0' order by b; + +drop table t1; +# +# Ordered index read, varchar type limited index size +# +CREATE TABLE t1 ( +a int not null, +b varchar(10) not null, +primary key(a), +index (b(5))) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '1'); +INSERT into t1 values (2, '5'); +INSERT into t1 values (30, '4'); +INSERT into t1 values (35, '2'); + +select * from t1 force index (b) where b > '0' order by b; + +drop table t1; + +# +# Ordered index read, varchar binary type +# +CREATE TABLE t1 ( +a int not null, +b varchar(10) binary not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '1'); +INSERT into t1 values (2, '5'); +INSERT into t1 values (30, '4'); +INSERT into t1 values (35, '2'); + +select * from t1 force index (b) where b > '0' order by b; + +drop table t1; + +# +# Ordered index read, tinytext type +# +CREATE TABLE t1 ( +a int not null, +b tinytext not null, +primary key(a), +index (b(10))) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '1'); +INSERT into t1 values (2, '5'); +INSERT into t1 values (30, '4'); +INSERT into t1 values (35, '2'); + +select * from t1 force index (b) where b > '0' order by b; + +drop table t1; +# +# Ordered index read, text type +# +CREATE TABLE t1 ( +a int not null, +b text not null, +primary key(a), +index (b(10))) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '1'); +INSERT into t1 values (2, '5'); +INSERT into t1 values (30, '4'); +INSERT into t1 values (35, '2'); + +select * from t1 force index (b) where b > '0' order by b; + +drop table t1; + +# +# Ordered index read, mediumtext type +# +CREATE TABLE t1 ( +a int not null, +b mediumtext not null, +primary key(a), +index (b(10))) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '1'); +INSERT into t1 values (2, '5'); +INSERT into t1 values (30, '4'); +INSERT into t1 values (35, '2'); + +select * from t1 force index (b) where b > '0' order by b; + +drop table t1; +# +# Ordered index read, longtext type +# +CREATE TABLE t1 ( +a int not null, +b longtext not null, +primary key(a), +index (b(10))) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '1'); +INSERT into t1 values (2, '5'); +INSERT into t1 values (30, '4'); +INSERT into t1 values (35, '2'); + +select * from t1 force index (b) where b > '0' order by b; + +drop table t1; +# +# Ordered index read, enum type +# +CREATE TABLE t1 ( +a int not null, +b enum('1','2', '4', '5') not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '1'); +INSERT into t1 values (2, '5'); +INSERT into t1 values (30, '4'); +INSERT into t1 values (35, '2'); + +select * from t1 force index (b) where b >= '1' order by b; + +drop table t1; +# +# Ordered index read, set type +# +CREATE TABLE t1 ( +a int not null, +b set('1','2', '4', '5') not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '1'); +INSERT into t1 values (2, '5'); +INSERT into t1 values (30, '4'); +INSERT into t1 values (35, '2'); + +select * from t1 force index (b) where b >= '1' order by b; + +drop table t1; +# +# Ordered index read, date type +# +CREATE TABLE t1 ( +a int not null, +b date not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '2001-01-01'); +INSERT into t1 values (2, '2005-01-01'); +INSERT into t1 values (30, '2004-01-01'); +INSERT into t1 values (35, '2002-01-01'); + +select * from t1 force index (b) where b > '2000-01-01' order by b; + +drop table t1; +# +# Ordered index read, datetime type +# +CREATE TABLE t1 ( +a int not null, +b datetime not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '2001-01-01 00:00:00'); +INSERT into t1 values (2, '2005-01-01 00:00:00'); +INSERT into t1 values (30, '2004-01-01 00:00:00'); +INSERT into t1 values (35, '2002-01-01 00:00:00'); + +select * from t1 force index (b) where b > '2000-01-01 00:00:00' order by b; + +drop table t1; +# +# Ordered index read, timestamp type +# +CREATE TABLE t1 ( +a int not null, +b timestamp not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '2001-01-01 00:00:00'); +INSERT into t1 values (2, '2005-01-01 00:00:00'); +INSERT into t1 values (30, '2004-01-01 00:00:00'); +INSERT into t1 values (35, '2002-01-01 00:00:00'); + +select * from t1 force index (b) where b > '2000-01-01 00:00:00' order by b; + +drop table t1; +# +# Ordered index read, time type +# +CREATE TABLE t1 ( +a int not null, +b time not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, '01:00:00'); +INSERT into t1 values (2, '05:00:00'); +INSERT into t1 values (30, '04:00:00'); +INSERT into t1 values (35, '02:00:00'); + +select * from t1 force index (b) where b > '00:00:00' order by b; + +drop table t1; +# +# Ordered index read, year type +# +CREATE TABLE t1 ( +a int not null, +b year not null, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 2001); +INSERT into t1 values (2, 2005); +INSERT into t1 values (30, 2004); +INSERT into t1 values (35, 2002); + +select * from t1 force index (b) where b > 2000 order by b; + +drop table t1; +# +# Ordered index read, bit(5) type +# +CREATE TABLE t1 ( +a int not null, +b bit(5) not null, +c int, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, b'00001', NULL); +INSERT into t1 values (2, b'00101', 2); +INSERT into t1 values (30, b'00100', 2); +INSERT into t1 values (35, b'00010', NULL); + +select a from t1 force index (b) where b > b'00000' order by b; + +drop table t1; +# +# Ordered index read, bit(15) type +# +CREATE TABLE t1 ( +a int not null, +b bit(15) not null, +c int, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, b'000000000000001', NULL); +INSERT into t1 values (2, b'001010000000101', 2); +INSERT into t1 values (30, b'001000000000100', 2); +INSERT into t1 values (35, b'000100000000010', NULL); + +select a from t1 force index (b) where b > b'000000000000000' order by b; + +drop table t1; + +# +# Ordered index read, NULL values +# +CREATE TABLE t1 ( +a int not null, +b int, +primary key(a), +index (b)) +partition by range (a) +partitions 2 +(partition x1 values less than (25), + partition x2 values less than (100)); + +# Insert a couple of tuples +INSERT into t1 values (1, 1); +INSERT into t1 values (5, NULL); +INSERT into t1 values (2, 4); +INSERT into t1 values (3, 3); +INSERT into t1 values (4, 5); +INSERT into t1 values (7, 1); +INSERT into t1 values (6, 6); +INSERT into t1 values (30, 4); +INSERT into t1 values (35, 2); +INSERT into t1 values (40, NULL); + +select * from t1 force index (b) where b < 10 OR b IS NULL order by b; +select * from t1 force index (b) where b < 10 ORDER BY b; +select * from t1 force index (b) where b < 10 ORDER BY b DESC; +drop table t1; + +create table t1 (a int not null, b int, c varchar(20), key (a,b,c)) +partition by range (b) +(partition p0 values less than (5), + partition p1 values less than (10)); +INSERT into t1 values (1,1,'1'),(2,2,'2'),(1,3,'3'),(2,4,'4'),(1,5,'5'); +INSERT into t1 values (2,6,'6'),(1,7,'7'),(2,8,'8'),(1,9,'9'); +INSERT into t1 values (1, NULL, NULL), (2, NULL, '10'); +select * from t1 where a = 1 order by a desc, b desc; +select * from t1 where a = 1 order by b desc; +drop table t1; diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test new file mode 100644 index 00000000000..11e65be45fc --- /dev/null +++ b/mysql-test/t/partition_pruning.test @@ -0,0 +1,1161 @@ +# +# Partition pruning tests. Currently we only detect which partitions to +# prune, so the test is EXPLAINs. +# +-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +--enable_warnings + +# +# Bug#20577: Partitions: use of to_days() function leads to selection failures +# +--let $explain_partitions= 1; +--let $verify_without_partitions= 0; +--echo # test of RANGE and index +CREATE TABLE t1 (a DATE, KEY(a)) +PARTITION BY RANGE (TO_DAYS(a)) +(PARTITION `pNULL` VALUES LESS THAN (0), + PARTITION `p0001-01-01` VALUES LESS THAN (366 + 1), + PARTITION `p1001-01-01` VALUES LESS THAN (TO_DAYS('1001-01-01') + 1), + PARTITION `p2001-01-01` VALUES LESS THAN (TO_DAYS('2001-01-01') + 1)); +if ($verify_without_partitions) +{ +ALTER TABLE t1 REMOVE PARTITIONING; +} +INSERT INTO t1 VALUES ('0000-00-00'), ('0000-01-02'), ('0001-01-01'), + ('1001-00-00'), ('1001-01-01'), ('1002-00-00'), ('2001-01-01'); +--source include/partition_date_range.inc +--echo # test without index +ALTER TABLE t1 DROP KEY a; +--source include/partition_date_range.inc +DROP TABLE t1; + +--echo # test of LIST and index +CREATE TABLE t1 (a DATE, KEY(a)) +PARTITION BY LIST (TO_DAYS(a)) +(PARTITION `p0001-01-01` VALUES IN (TO_DAYS('0001-01-01')), + PARTITION `p2001-01-01` VALUES IN (TO_DAYS('2001-01-01')), + PARTITION `pNULL` VALUES IN (NULL), + PARTITION `p0000-01-02` VALUES IN (TO_DAYS('0000-01-02')), + PARTITION `p1001-01-01` VALUES IN (TO_DAYS('1001-01-01'))); +if ($verify_without_partitions) +{ +ALTER TABLE t1 REMOVE PARTITIONING; +} +INSERT INTO t1 VALUES ('0000-00-00'), ('0000-01-02'), ('0001-01-01'), + ('1001-00-00'), ('1001-01-01'), ('1002-00-00'), ('2001-01-01'); +--source include/partition_date_range.inc +--echo # test without index +ALTER TABLE t1 DROP KEY a; +--source include/partition_date_range.inc +DROP TABLE t1; + +# +# Bug#46362: Endpoint should be set to false for TO_DAYS(DATE) +# There is a problem when comparing DATE with DATETIME. +# In pruning it is converted into the field type +# and in row evaluation it is converted to longlong +# (like a DATETIME). +--echo # Test with DATETIME column NOT NULL +CREATE TABLE t1 ( + a int(10) unsigned NOT NULL, + b DATETIME NOT NULL, + PRIMARY KEY (a, b) +) PARTITION BY RANGE (TO_DAYS(b)) +(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), + PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), + PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), + PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), + PARTITION p20090405 VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), + (1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-02 23:59:59'), + (1, '2009-04-03'), (2, '2009-04-03'), (1, '2009-04-04'), (2, '2009-04-04'), + (1, '2009-04-05'), (1, '2009-04-06'), (1, '2009-04-07'); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); +DROP TABLE t1; + +--echo # Test with DATE column NOT NULL +CREATE TABLE t1 ( + a int(10) unsigned NOT NULL, + b DATE NOT NULL, + PRIMARY KEY (a, b) +) PARTITION BY RANGE (TO_DAYS(b)) +(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), + PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), + PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), + PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), + PARTITION p20090405 VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), + (1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-03'), (2, '2009-04-03'), + (1, '2009-04-04'), (2, '2009-04-04'), (1, '2009-04-05'), (1, '2009-04-06'), + (1, '2009-04-07'); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); +DROP TABLE t1; + +--echo # Test with DATETIME column NULL +CREATE TABLE t1 ( + a int(10) unsigned NOT NULL, + b DATETIME NULL +) PARTITION BY RANGE (TO_DAYS(b)) +(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), + PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), + PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), + PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), + PARTITION p20090405 VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), + (1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-02 23:59:59'), + (1, '2009-04-03'), (2, '2009-04-03'), (1, '2009-04-04'), (2, '2009-04-04'), + (1, '2009-04-05'), (1, '2009-04-06'), (1, '2009-04-07'); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); +DROP TABLE t1; + +--echo # Test with DATE column NULL +CREATE TABLE t1 ( + a int(10) unsigned NOT NULL, + b DATE NULL +) PARTITION BY RANGE (TO_DAYS(b)) +(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), + PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), + PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), + PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), + PARTITION p20090405 VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (1, '2009-01-01'), (1, '2009-04-01'), (2, '2009-04-01'), + (1, '2009-04-02'), (2, '2009-04-02'), (1, '2009-04-03'), (2, '2009-04-03'), + (1, '2009-04-04'), (2, '2009-04-04'), (1, '2009-04-05'), (1, '2009-04-06'), + (1, '2009-04-07'); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-02 23:59:59' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > CAST('2009-04-03' AS DATE); +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03 00:00:00'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-02 23:59:59'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b <= '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b = '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b >= '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b > '2009-04-03'; +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-03 00:00:01' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b < CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b <= CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b = CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b >= CAST('2009-04-02 23:59:58' AS DATETIME); +EXPLAIN PARTITIONS SELECT * FROM t1 + WHERE b > CAST('2009-04-02 23:59:58' AS DATETIME); +DROP TABLE t1; + +--echo # For better code coverage of the patch +CREATE TABLE t1 ( + a int(10) unsigned NOT NULL, + b DATE +) PARTITION BY RANGE ( TO_DAYS(b) ) +(PARTITION p20090401 VALUES LESS THAN (TO_DAYS('2009-04-02')), + PARTITION p20090402 VALUES LESS THAN (TO_DAYS('2009-04-03')), + PARTITION p20090403 VALUES LESS THAN (TO_DAYS('2009-04-04')), + PARTITION p20090404 VALUES LESS THAN (TO_DAYS('2009-04-05')), + PARTITION p20090405 VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (1, '2009-01-01'), (2, NULL); +--echo # test with an invalid date, which lead to item->null_value is set. +EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-99' AS DATETIME); +DROP TABLE t1; + +# +# Bug#40972: some sql execution lead the whole database crashing +# +# Setup so the start is at partition pX and end is at p1 +# Pruning does handle 'bad' dates differently. +CREATE TABLE t1 +(a INT NOT NULL AUTO_INCREMENT, + b DATETIME, + PRIMARY KEY (a,b), + KEY (b)) +PARTITION BY RANGE (to_days(b)) +(PARTITION p0 VALUES LESS THAN (733681) COMMENT = 'LESS THAN 2008-10-01', + PARTITION p1 VALUES LESS THAN (733712) COMMENT = 'LESS THAN 2008-11-01', + PARTITION pX VALUES LESS THAN MAXVALUE); +SELECT a,b FROM t1 WHERE b >= '2008-12-01' AND b < '2009-12-00'; +DROP TABLE t1; + +# Check if we can infer from condition on partition fields that +# no records will match. +create table t1 ( a int not null) partition by hash(a) partitions 2; +insert into t1 values (1),(2),(3); +explain select * from t1 where a=5 and a=6; +drop table t1; + +# Simple HASH partitioning +create table t1 ( + a int(11) not null +) partition by hash (a) partitions 2; +insert into t1 values (1),(2),(3); + +explain partitions select * from t1 where a=1; +explain partitions select * from t1 where a=2; +explain partitions select * from t1 where a=1 or a=2; + +# Partitioning over several fields +create table t2 ( + a int not null, + b int not null +) partition by key(a,b) partitions 2; +insert into t2 values (1,1),(2,2),(3,3); + +explain partitions select * from t2 where a=1; +explain partitions select * from t2 where b=1; + +explain partitions select * from t2 where a=1 and b=1; + +# RANGE(expr) partitioning +create table t3 ( + a int +) +partition by range (a*1) ( + partition p0 values less than (10), + partition p1 values less than (20) +); +insert into t3 values (5),(15); + +explain partitions select * from t3 where a=11; +explain partitions select * from t3 where a=10; +explain partitions select * from t3 where a=20; + +explain partitions select * from t3 where a=30; + +# LIST(expr) partitioning +create table t4 (a int not null, b int not null) partition by LIST (a+b) ( + partition p0 values in (12), + partition p1 values in (14) +); +insert into t4 values (10,2), (10,4); + +# empty OR one +explain partitions select * from t4 where (a=10 and b=1) or (a=10 and b=2); + +# empty OR one OR empty +explain partitions select * from t4 + where (a=10 and b=1) or (a=10 and b=2) or (a=10 and b = 3); + +# one OR empty OR one +explain partitions select * from t4 where (a=10 and b=2) or (a=10 and b=3) + or (a=10 and b = 4); + +# empty OR full +explain partitions select * from t4 where (a=10 and b=1) or a=11; + +# one OR full +explain partitions select * from t4 where (a=10 and b=2) or a=11; + +drop table t1, t2, t3, t4; + +# LIST(expr)/HASH subpartitioning. +create table t5 (a int not null, b int not null, + c int not null, d int not null) +partition by LIST(a+b) subpartition by HASH (c+d) subpartitions 2 +( + partition p0 values in (12), + partition p1 values in (14) +); + +insert into t5 values (10,2,0,0), (10,4,0,0), (10,2,0,1), (10,4,0,1); +explain partitions select * from t5; + +# empty OR one OR empty +explain partitions select * from t5 + where (a=10 and b=1) or (a=10 and b=2) or (a=10 and b = 3); + +# one OR empty OR one +explain partitions select * from t5 where (a=10 and b=2) or (a=10 and b=3) + or (a=10 and b = 4); + +# conditions on subpartitions only +explain partitions select * from t5 where (c=1 and d=1); +explain partitions select * from t5 where (c=2 and d=1); + +# mixed partition/subpartitions. +explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or +(c=2 and d=1); + +# same as above +explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or +(b=2 and c=2 and d=1); + +# LIST(field) partitioning, interval analysis. +create table t6 (a int not null) partition by LIST(a) ( + partition p1 values in (1), + partition p3 values in (3), + partition p5 values in (5), + partition p7 values in (7), + partition p9 values in (9) +); +insert into t6 values (1),(3),(5); + +explain partitions select * from t6 where a < 1; +explain partitions select * from t6 where a <= 1; +explain partitions select * from t6 where a > 9; +explain partitions select * from t6 where a >= 9; + +explain partitions select * from t6 where a > 0 and a < 5; +explain partitions select * from t6 where a > 5 and a < 12; +explain partitions select * from t6 where a > 3 and a < 8 ; + +explain partitions select * from t6 where a >= 0 and a <= 5; +explain partitions select * from t6 where a >= 5 and a <= 12; +explain partitions select * from t6 where a >= 3 and a <= 8; + +explain partitions select * from t6 where a > 3 and a < 5; + +drop table t6; + +create table t6 (a int unsigned not null) partition by LIST(a) ( + partition p1 values in (1), + partition p3 values in (3), + partition p5 values in (5), + partition p7 values in (7), + partition p9 values in (9) +); +insert into t6 values (1),(3),(5); + +explain partitions select * from t6 where a < 1; +explain partitions select * from t6 where a <= 1; +explain partitions select * from t6 where a > 9; +explain partitions select * from t6 where a >= 9; + +explain partitions select * from t6 where a > 0 and a < 5; +explain partitions select * from t6 where a > 5 and a < 12; +explain partitions select * from t6 where a > 3 and a < 8 ; + +explain partitions select * from t6 where a >= 0 and a <= 5; +explain partitions select * from t6 where a >= 5 and a <= 12; +explain partitions select * from t6 where a >= 3 and a <= 8; + +explain partitions select * from t6 where a > 3 and a < 5; + +# RANGE(field) partitioning, interval analysis. +create table t7 (a int not null) partition by RANGE(a) ( + partition p10 values less than (10), + partition p30 values less than (30), + partition p50 values less than (50), + partition p70 values less than (70), + partition p90 values less than (90) +); +insert into t7 values (10),(30),(50); + +# leftmost intervals +explain partitions select * from t7 where a < 5; +explain partitions select * from t7 where a < 10; +explain partitions select * from t7 where a <= 10; +explain partitions select * from t7 where a = 10; + +#rightmost intervals +explain partitions select * from t7 where a < 90; +explain partitions select * from t7 where a = 90; +explain partitions select * from t7 where a > 90; +explain partitions select * from t7 where a >= 90; + +# misc intervals +explain partitions select * from t7 where a > 11 and a < 29; + +drop table t7; + +create table t7 (a int unsigned not null) partition by RANGE(a) ( + partition p10 values less than (10), + partition p30 values less than (30), + partition p50 values less than (50), + partition p70 values less than (70), + partition p90 values less than (90) +); +insert into t7 values (10),(30),(50); + +# leftmost intervals +explain partitions select * from t7 where a < 5; +explain partitions select * from t7 where a < 10; +explain partitions select * from t7 where a <= 10; +explain partitions select * from t7 where a = 10; + +#rightmost intervals +explain partitions select * from t7 where a < 90; +explain partitions select * from t7 where a = 90; +explain partitions select * from t7 where a > 90; +explain partitions select * from t7 where a >= 90; + +# misc intervals +explain partitions select * from t7 where a > 11 and a < 29; + +# LIST(monontonic_func) partitioning +create table t8 (a date not null) partition by RANGE(YEAR(a)) ( + partition p0 values less than (1980), + partition p1 values less than (1990), + partition p2 values less than (2000) +); +insert into t8 values ('1985-05-05'),('1995-05-05'); + +explain partitions select * from t8 where a < '1980-02-02'; + +# LIST(strict_monotonic_func) partitioning +create table t9 (a date not null) partition by RANGE(TO_DAYS(a)) ( + partition p0 values less than (732299), -- 2004-12-19 + partition p1 values less than (732468), -- 2005-06-06 + partition p2 values less than (732664) -- 2005-12-19 +); +insert into t9 values ('2005-05-05'), ('2005-04-04'); + +explain partitions select * from t9 where a < '2004-12-19'; +explain partitions select * from t9 where a <= '2004-12-19'; + +drop table t5,t6,t7,t8,t9; + +# Test the case where we can't create partitioning 'index' +# +# Not supported after bug#18198 is fixed +# +#create table t1 (a enum('a','b','c','d') default 'a') +# partition by hash (ascii(a)) partitions 2; +#insert into t1 values ('a'),('b'),('c'); +#explain partitions select * from t1 where a='b'; +#drop table t1; + +# +# Test cases for bugs found in code review: +# +create table t1 ( + a1 int not null +) +partition by range (a1) ( + partition p0 values less than (3), + partition p1 values less than (6), + partition p2 values less than (9) +); +insert into t1 values (1),(2),(3); +explain partitions select * from t1 where a1 > 3; +explain partitions select * from t1 where a1 >= 3; + +explain partitions select * from t1 where a1 < 3 and a1 > 3; +drop table t1; + +# +create table t3 (a int, b int) + partition by list(a) subpartition by hash(b) subpartitions 4 ( + partition p0 values in (1), + partition p1 values in (2), + partition p2 values in (3), + partition p3 values in (4) + ); +insert into t3 values (1,1),(2,2),(3,3); + +explain partitions select * from t3 where a=2 or b=1; +explain partitions select * from t3 where a=4 or b=2; +explain partitions select * from t3 where (a=2 or b=1) and (a=4 or b=2) ; +drop table t3; + +# Test for NULLs +create table t1 (a int) partition by hash(a) partitions 2; +insert into t1 values (1),(2); +explain partitions select * from t1 where a is null; + +# this uses both partitions +explain partitions select * from t1 where a is not null; +drop table t1; + +# Join tests +create table t1 (a int not null, b int not null, key(a), key(b)) + partition by hash(a) partitions 4; +insert into t1 values (1,1),(2,2),(3,3),(4,4); + +explain partitions +select * from t1 X, t1 Y +where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3); + +explain partitions +select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2); + +drop table t1; + +# Tests for "short ranges" +create table t1 (a int) partition by hash(a) partitions 20; +insert into t1 values (1),(2),(3); +explain partitions select * from t1 where a > 1 and a < 3; +explain partitions select * from t1 where a >= 1 and a < 3; +explain partitions select * from t1 where a > 1 and a <= 3; +explain partitions select * from t1 where a >= 1 and a <= 3; +drop table t1; + +create table t1 (a int, b int) + partition by list(a) subpartition by hash(b) subpartitions 20 +( + partition p0 values in (0), + partition p1 values in (1), + partition p2 values in (2), + partition p3 values in (3) +); +insert into t1 values (1,1),(2,2),(3,3); + +explain partitions select * from t1 where b > 1 and b < 3; +explain partitions select * from t1 where b > 1 and b < 3 and (a =1 or a =2); +drop table t1; + +# Test partition pruning for single-table UPDATE/DELETE. +# TODO: Currently we test only "all partitions pruned away" case. Add more +# tests when the patch that makes use of partition pruning results at +# execution phase is pushed. + +create table t1 (a int) partition by list(a) ( + partition p0 values in (1,2), + partition p1 values in (3,4) +); +insert into t1 values (1),(1),(2),(2),(3),(4),(3),(4); + +# This won't do any table access +flush status; +update t1 set a=100 where a=5; +show status like 'Handler_read_rnd_next'; + +# ... as compared to this, which will scan both partitions +flush status; +update t1 set a=100 where a+1=5+1; +show status like 'Handler_read_rnd_next'; + +# Same as above for DELETE: +flush status; +delete from t1 where a=5; +show status like 'Handler_read_rnd_next'; + +flush status; +delete from t1 where a+1=5+1; +show status like 'Handler_read_rnd_next'; + +# Same as above multi-table UPDATE/DELETE +create table t2 like t1; +insert into t2 select * from t2; + +flush status; +update t1,t2 set t1.a=1000, t2.a=1000 where t1.a=5 and t2.a=5; +show status like 'Handler_read_rnd_next'; +# ^ This shows 3 accesses, these are caused by const table reads. +# They should vanish when partition pruning results are used. + +flush status; +delete t1,t2 from t1, t2 where t1.a=5 and t2.a=5; +show status like 'Handler_read_rnd_next'; +drop table t1,t2; + +# +# WL#2986 Tests (Checking if partition pruning results are used at query +# execution phase) +# +CREATE TABLE `t1` ( + `a` int(11) default NULL +); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +CREATE TABLE `t2` ( + `a` int(11) default NULL, + KEY `a` (`a`) +) ; + +insert into t2 select A.a + 10*(B.a + 10* C.a) from t1 A, t1 B, t1 C ; +insert into t1 select a from t2; + +drop table t2; +CREATE TABLE `t2` ( + `a` int(11) default NULL, + `b` int(11) default NULL +) +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (200), +PARTITION p1 VALUES LESS THAN (400), +PARTITION p2 VALUES LESS THAN (600), +PARTITION p3 VALUES LESS THAN (800), +PARTITION p4 VALUES LESS THAN (1001)); + +insert into t2 select a,1 from t1 where a < 200; +insert into t2 select a,2 from t1 where a >= 200 and a < 400; +insert into t2 select a,3 from t1 where a >= 400 and a < 600; +insert into t2 select a,4 from t1 where a >= 600 and a < 800; +insert into t2 select a,5 from t1 where a >= 800 and a < 1001; + +explain partitions select * from t2; +explain partitions select * from t2 where a < 801 and a > 200; +explain partitions select * from t2 where a < 801 and a > 800; +explain partitions select * from t2 where a > 600; +explain partitions select * from t2 where a > 600 and b = 1; +explain partitions select * from t2 where a > 600 and b = 4; +explain partitions select * from t2 where a > 600 and b = 5; +explain partitions select * from t2 where b = 5; + +flush status; +update t2 set b = 100 where b = 6; +show status like 'Handler_read_rnd_next'; +flush status; +update t2 set a = 1002 where a = 1001; +show status like 'Handler_read_rnd_next'; +flush status; +update t2 set b = 6 where a = 600; +show status like 'Handler_read_rnd_next'; +flush status; +update t2 set b = 6 where a > 600 and a < 800; +show status like 'Handler_read_rnd_next'; +flush status; +delete from t2 where a > 600; +show status like 'Handler_read_rnd_next'; + +drop table t2; +CREATE TABLE `t2` ( + `a` int(11) default NULL, + `b` int(11) default NULL, + index (b) +) +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (200), +PARTITION p1 VALUES LESS THAN (400), +PARTITION p2 VALUES LESS THAN (600), +PARTITION p3 VALUES LESS THAN (800), +PARTITION p4 VALUES LESS THAN (1001)); + +insert into t2 select a,1 from t1 where a < 100; +insert into t2 select a,2 from t1 where a >= 200 and a < 300; +insert into t2 select a,3 from t1 where a >= 300 and a < 400; +insert into t2 select a,4 from t1 where a >= 400 and a < 500; +insert into t2 select a,5 from t1 where a >= 500 and a < 600; +insert into t2 select a,6 from t1 where a >= 600 and a < 700; +insert into t2 select a,7 from t1 where a >= 700 and a < 800; +insert into t2 select a,8 from t1 where a >= 800 and a < 900; +insert into t2 select a,9 from t1 where a >= 900 and a < 1001; + +explain partitions select * from t2; +# not using indexes +explain partitions select * from t2 where a = 101; +explain partitions select * from t2 where a = 550; +explain partitions select * from t2 where a = 833; +explain partitions select * from t2 where (a = 100 OR a = 900); +explain partitions select * from t2 where (a > 100 AND a < 600); +explain partitions select * from t2 where b = 4; + +explain extended select * from t2 where b = 6; +explain partitions select * from t2 where b = 6; + +explain extended select * from t2 where b in (1,3,5); +explain partitions select * from t2 where b in (1,3,5); + +explain extended select * from t2 where b in (2,4,6); +explain partitions select * from t2 where b in (2,4,6); + +explain extended select * from t2 where b in (7,8,9); +explain partitions select * from t2 where b in (7,8,9); + +explain extended select * from t2 where b > 5; +explain partitions select * from t2 where b > 5; + +explain extended select * from t2 where b > 5 and b < 8; +explain partitions select * from t2 where b > 5 and b < 8; + +explain extended select * from t2 where b > 5 and b < 7; +explain partitions select * from t2 where b > 5 and b < 7; + +explain extended select * from t2 where b > 0 and b < 5; +explain partitions select * from t2 where b > 0 and b < 5; + +flush status; +update t2 set a = 111 where b = 10; +show status like 'Handler_read_rnd_next'; +show status like 'Handler_read_key'; +flush status; +update t2 set a = 111 where b in (5,6); +show status like 'Handler_read_rnd_next'; +show status like 'Handler_read_key'; +flush status; +update t2 set a = 222 where b = 7; +show status like 'Handler_read_rnd_next'; +show status like 'Handler_read_key'; +flush status; +delete from t2 where b = 7; +show status like 'Handler_read_rnd_next'; +show status like 'Handler_read_key'; +flush status; +delete from t2 where b > 5; +show status like 'Handler_read_rnd_next'; +show status like 'Handler_read_key'; +show status like 'Handler_read_prev'; +show status like 'Handler_read_next'; +flush status; +delete from t2 where b < 5 or b > 3; +show status like 'Handler_read_rnd_next'; +show status like 'Handler_read_key'; +show status like 'Handler_read_prev'; +show status like 'Handler_read_next'; + +drop table t1, t2; + +# BUG#18025 +# part1: mediumint columns +create table t1 ( f_int1 mediumint, f_int2 integer) +partition by list(mod(f_int1,4)) ( + partition p_3 values in (-3), + partition p_2 values in (-2), + partition p_1 values in (-1), + partition p0 values in (0), + partition p1 values in (1), + partition p2 values in (2), + partition p3 values in (3) +); + +insert into t1 values (9, 9), (8, 8), (7, 7), (6, 6), (5, 5), + (4, 4), (3, 3), (2, 2), (1, 1); +select * from t1 where f_int1 between 5 and 15 order by f_int1; + +drop table t1; + +# part2: bug in pruning code +#create table t1 (a char(10) binary) +#partition by list(ascii(a)) +# (partition p1 values in (ascii('a')), +# partition p2 values in (ascii('b')), +# partition p3 values in (ascii('c')), +# partition p4 values in (ascii('d')), +# partition p5 values in (ascii('e'))); +#insert into t1 values ('a'),('bb'),('ccc'),('dddd'),('eeEee'); +#select * from t1 where a>='a' and a <= 'dddd'; +#explain partitions select * from t1 where a>='a' and a <= 'dddd'; +#drop table t1; + +# BUG#18659: Assertion failure when subpartitioning is used and partition is +# "IS NULL" +create table t1 (f_int1 integer) partition by list(abs(mod(f_int1,2))) + subpartition by hash(f_int1) subpartitions 2 +( + partition part1 values in (0), + partition part2 values in (1), + partition part4 values in (null) +); +insert into t1 set f_int1 = null; + +select * from t1 where f_int1 is null; +explain partitions select * from t1 where f_int1 is null; +drop table t1; + +# +# BUG#18558 +# +create table t1 (a int not null, b int not null) +partition by list(a) + subpartition by hash(b) subpartitions 4 +( + partition p0 values in (1), + partition p1 values in (2), + partition p2 values in (3) +); +insert into t1 values (1,1),(1,2),(1,3),(1,4), + (2,1),(2,2),(2,3),(2,4); +explain partitions select * from t1 where a=1 AND (b=1 OR b=2); +drop table t1; + +create table t1 (a int, b int not null) +partition by list(a) + subpartition by hash(b) subpartitions 2 +( + partition p0 values in (1), + partition p1 values in (2), + partition p2 values in (3), + partition pn values in (NULL) +); +insert into t1 values (1,1),(1,2),(1,3),(1,4), + (2,1),(2,2),(2,3),(2,4), (NULL,1); + +explain partitions select * from t1 where a IS NULL AND (b=1 OR b=2); + +explain partitions select * from t1 where (a IS NULL or a < 1) AND (b=1 OR b=2); +explain partitions select * from t1 where (a IS NULL or a < 2) AND (b=1 OR b=2); +explain partitions select * from t1 where (a IS NULL or a <= 1) AND (b=1 OR b=2); + +drop table t1; + +create table t1 ( a int) partition by list (MOD(a, 10)) +( partition p0 values in (0), partition p1 values in (1), + partition p2 values in (2), partition p3 values in (3), + partition p4 values in (4), partition p5 values in (5), + partition p6 values in (6), partition pn values in (NULL) +); +insert into t1 values (NULL), (0),(1),(2),(3),(4),(5),(6); +explain partitions select * from t1 where a is null or a < 2; +drop table t1; + +# Testcase from BUG#18751 +create table t1 (s1 int) partition by list (s1) + (partition p1 values in (0), + partition p2 values in (1), + partition p3 values in (null)); + +insert into t1 values (0),(1),(null); + +select count(*) from t1 where s1 < 0 or s1 is null; +explain partitions select count(*) from t1 where s1 < 0 or s1 is null; +drop table t1; + +# No tests for NULLs in RANGE(monotonic_expr()) - they depend on BUG#15447 +# being fixed. + +# +# BUG#17946 Like searches fail with partitioning +# +create table t1 (a char(32) primary key) +partition by key() +partitions 100; +insert into t1 values ('na'); +select * from t1; +select * from t1 where a like 'n%'; +drop table t1; + + +# BUG#19055 Crashes for varchar_col=NUMBER or varchar_col IS NULL +create table t1 (s1 varchar(15)) partition by key (s1); +select * from t1 where s1 = 0 or s1 is null; +insert into t1 values ('aa'),('bb'),('0'); +explain partitions select * from t1 where s1 = 0 or s1 is null; +drop table t1; + +# +# BUG#19684: EXPLAIN PARTITIONS produces garbage in 'partitions' column when +# the length of string to be displayed exceeds some limit. +create table t2 (a int, b int) + partition by LIST(a) + subpartition by HASH(b) subpartitions 40 +( partition p_0_long_partition_name values in(1), + partition p_1_long_partition_name values in(2)); + +insert into t2 values (1,1),(2,2); + +--vertical_results +explain partitions select * from t2; +--horizontal_results +drop table t2; + + +# BUG#20484 "Partitions: crash with explain and union" +create table t1 (s1 int); +explain partitions select 1 from t1 union all select 2; +drop table t1; + + +# BUG#20257: partition pruning test coverage for BIGINT UNSIGNED +create table t1 (a bigint unsigned not null) partition by range(a) ( + partition p0 values less than (10), + partition p1 values less than (100), + partition p2 values less than (1000), + partition p3 values less than (18446744073709551000), + partition p4 values less than (18446744073709551614) +); +insert into t1 values (5),(15),(105),(1005); +insert into t1 values (18446744073709551000+1); +insert into t1 values (18446744073709551614-1); + +explain partitions select * from t1 where a < 10; +explain partitions select * from t1 + where a >= 18446744073709551000-1 and a <= 18446744073709551000+1; + +explain partitions select * from t1 + where a between 18446744073709551001 and 18446744073709551002; + +explain partitions select * from t1 where a = 18446744073709551000; +explain partitions select * from t1 where a = 18446744073709551613; +explain partitions select * from t1 where a = 18446744073709551614; +drop table t1; +# +# Test all variants of usage for interval_via_mapping +# and interval_via_walking +# +# t1 will use interval_via_mapping since it uses a +# monotonic function, whereas t2 will use +# interval_via_walking since the intervals are short +# and the function isn't monotonic (it is, but it isn't +# discovered in this version). +# + create table t1 (a int) + partition by range(a) ( + partition p0 values less than (64), + partition p1 values less than (128), + partition p2 values less than (255) +); + +create table t2 (a int) + partition by range(a+0) ( + partition p0 values less than (64), + partition p1 values less than (128), + partition p2 values less than (255) +); + +insert into t1 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE); +insert into t2 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE); +explain partitions select * from t1 where a=0; +explain partitions select * from t2 where a=0; +explain partitions select * from t1 where a=0xFE; +explain partitions select * from t2 where a=0xFE; +explain partitions select * from t1 where a > 0xFE AND a <= 0xFF; +explain partitions select * from t2 where a > 0xFE AND a <= 0xFF; +explain partitions select * from t1 where a >= 0xFE AND a <= 0xFF; +explain partitions select * from t2 where a >= 0xFE AND a <= 0xFF; +explain partitions select * from t1 where a < 64 AND a >= 63; +explain partitions select * from t2 where a < 64 AND a >= 63; +explain partitions select * from t1 where a <= 64 AND a >= 63; +explain partitions select * from t2 where a <= 64 AND a >= 63; +drop table t1; +drop table t2; + +create table t1(a bigint unsigned not null) partition by range(a+0) ( + partition p1 values less than (10), + partition p2 values less than (20), + partition p3 values less than (2305561538531885056), + partition p4 values less than (2305561538531950591) +); + +insert into t1 values (9),(19),(0xFFFF0000FFFF000-1), (0xFFFF0000FFFFFFF-1); +insert into t1 values (9),(19),(0xFFFF0000FFFF000-1), (0xFFFF0000FFFFFFF-1); + +explain partitions select * from t1 where + a >= 2305561538531885056-10 and a <= 2305561538531885056-8; + +explain partitions select * from t1 where + a > 0xFFFFFFFFFFFFFFEC and a < 0xFFFFFFFFFFFFFFEE; + +explain partitions select * from t1 where a>=0 and a <= 0xFFFFFFFFFFFFFFFF; +drop table t1; + +create table t1 (a bigint) partition by range(a+0) ( + partition p1 values less than (-1000), + partition p2 values less than (-10), + partition p3 values less than (10), + partition p4 values less than (1000) +); +insert into t1 values (-15),(-5),(5),(15),(-15),(-5),(5),(15); +explain partitions select * from t1 where a>-2 and a <=0; +drop table t1; + + +# +# BUG#27927 Partition pruning not optimal with TO_DAYS function +# + +CREATE TABLE t1 ( recdate DATETIME NOT NULL ) +PARTITION BY RANGE( TO_DAYS(recdate) ) ( + PARTITION p0 VALUES LESS THAN ( TO_DAYS('2007-03-08') ), + PARTITION p1 VALUES LESS THAN ( TO_DAYS('2007-04-01') ) +); +INSERT INTO t1 VALUES ('2007-03-01 12:00:00'); +INSERT INTO t1 VALUES ('2007-03-07 12:00:00'); +INSERT INTO t1 VALUES ('2007-03-08 12:00:00'); +INSERT INTO t1 VALUES ('2007-03-15 12:00:00'); +-- echo must use p0 only: +explain partitions select * from t1 where recdate < '2007-03-08 00:00:00'; + +drop table t1; +CREATE TABLE t1 ( recdate DATETIME NOT NULL ) +PARTITION BY RANGE( YEAR(recdate) ) ( + PARTITION p0 VALUES LESS THAN (2006), + PARTITION p1 VALUES LESS THAN (2007) +); +INSERT INTO t1 VALUES ('2005-03-01 12:00:00'); +INSERT INTO t1 VALUES ('2005-03-01 12:00:00'); +INSERT INTO t1 VALUES ('2006-03-01 12:00:00'); +INSERT INTO t1 VALUES ('2006-03-01 12:00:00'); + +-- echo must use p0 only: +explain partitions select * from t1 where recdate < '2006-01-01 00:00:00'; +drop table t1; diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test new file mode 100644 index 00000000000..c02d9049f2e --- /dev/null +++ b/mysql-test/t/partition_range.test @@ -0,0 +1,830 @@ +#--disable_abort_on_error +# +# Simple test for the partition storage engine +# Focuses on range partitioning tests +# +-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +# +# BUG 33429: Succeeds in adding partition when maxvalue on last partition +# +create table t1 (a int) +partition by range (a) +( partition p0 values less than (maxvalue)); +--error ER_PARTITION_MAXVALUE_ERROR +alter table t1 add partition (partition p1 values less than (100000)); +show create table t1; +drop table t1; + +# BUG 32943: +# Locking problems in relation to partitioning and triggers +# Also fixes and test cases of generic lock issues with +# partition change code. +# +create table t1 (a integer) +partition by range (a) +( partition p0 values less than (4), + partition p1 values less than (100)); + +delimiter |; +create trigger tr1 before insert on t1 +for each row begin + set @a = 1; +end| + +delimiter ;| +alter table t1 drop partition p0; + +drop table t1; + +create table t1 (a integer) +partition by range (a) +( partition p0 values less than (4), + partition p1 values less than (100)); +LOCK TABLES t1 WRITE; +alter table t1 drop partition p0; +alter table t1 reorganize partition p1 into +( partition p0 values less than (4), + partition p1 values less than (100)); +alter table t1 add partition ( partition p2 values less than (200)); +UNLOCK TABLES; +drop table t1; + +# +# BUG 18198: Various tests for partition functions +# +#create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int) +#partition by range (ascii(a) * b) +#(partition p0 values less than (2), partition p1 values less than (4000)); +#insert into t1 values ('a ', 2),('a',3); +#drop table t1; + +#create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int) +#partition by range (b* ascii(a) * b) +#(partition p0 values less than (2), partition p1 values less than (4000)); +#insert into t1 values ('a ', 2),('a',3); +#drop table t1; + +#create table t1 (a varchar(10) charset latin1 collate latin1_bin, +# b varchar(10) charset latin1 collate latin1_bin) +#partition by range (ascii(b) * ascii(a)) +#(partition p0 values less than (2), partition p1 values less than (40000)); +#insert into t1 values ('a ', 'b '),('a','b'); +#drop table t1; + +#create table t1 (a varchar(10) charset latin1 collate latin1_bin, +# b varchar(10) charset latin1 collate latin1_bin) +#partition by range (ascii(a) * ascii(b)) +#(partition p0 values less than (2), partition p1 values less than (40000)); +#insert into t1 values ('a ', 'b '),('a','b'); +#drop table t1; + +#create table t1 (a varchar(10) charset latin1 collate latin1_bin, +# b varchar(10) charset latin1 collate latin1_bin, c int) +#partition by range (ascii(a) * c) +#(partition p0 values less than (2), partition p1 values less than (4000)); +#insert into t1 values ('a ', 'b ', 2),('a','b', 3); +#drop table t1; + +#create table t1 (a varchar(10) charset latin1 collate latin1_bin, +# b varchar(10) charset latin1 collate latin1_bin, c int) +#partition by range (c * ascii(a)) +#(partition p0 values less than (2), partition p1 values less than (4000)); +#insert into t1 values ('a ', 'b ', 2),('a','b', 3); +#drop table t1; + +# +# More checks for partition pruning +# +create table t1 (a int unsigned) +partition by range (a) +(partition pnull values less than (0), + partition p0 values less than (1), + partition p1 values less than(2)); +insert into t1 values (null),(0),(1); + +select * from t1 where a is null; +select * from t1 where a >= 0; +select * from t1 where a < 0; +select * from t1 where a <= 0; +select * from t1 where a > 1; +explain partitions select * from t1 where a is null; +explain partitions select * from t1 where a >= 0; +explain partitions select * from t1 where a < 0; +explain partitions select * from t1 where a <= 0; +explain partitions select * from t1 where a > 1; +drop table t1; + +create table t1 (a int unsigned, b int unsigned) +partition by range (a) +subpartition by hash (b) +subpartitions 2 +(partition pnull values less than (0), + partition p0 values less than (1), + partition p1 values less than(2)); +insert into t1 values (null,0),(null,1),(0,0),(0,1),(1,0),(1,1); + +select * from t1 where a is null; +select * from t1 where a >= 0; +select * from t1 where a < 0; +select * from t1 where a <= 0; +select * from t1 where a > 1; +explain partitions select * from t1 where a is null; +explain partitions select * from t1 where a >= 0; +explain partitions select * from t1 where a < 0; +explain partitions select * from t1 where a <= 0; +explain partitions select * from t1 where a > 1; + +drop table t1; + +# +# Partition by range, basic +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a) +partitions 3 +(partition x1 values less than (5) tablespace ts1, + partition x2 values less than (10) tablespace ts2, + partition x3 values less than maxvalue tablespace ts3); + +# Simple insert and verify test +INSERT into t1 values (1, 1, 1); +INSERT into t1 values (6, 1, 1); +INSERT into t1 values (10, 1, 1); +INSERT into t1 values (15, 1, 1); + +select * from t1; +show create table t1; + +ALTER TABLE t1 +partition by range (a) +partitions 3 +(partition x1 values less than (5) tablespace ts1, + partition x2 values less than (10) tablespace ts2, + partition x3 values less than maxvalue tablespace ts3); + +select * from t1; +show create table t1; + +drop table if exists t1; + +# +# Partition by range, basic +# No primary key +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null) +partition by range (a) +partitions 3 +(partition x1 values less than (5) tablespace ts1, + partition x2 values less than (10) tablespace ts2, + partition x3 values less than maxvalue tablespace ts3); + +# Simple insert and verify test +INSERT into t1 values (1, 1, 1); +INSERT into t1 values (6, 1, 1); +INSERT into t1 values (10, 1, 1); +INSERT into t1 values (15, 1, 1); + +select * from t1; + +ALTER TABLE t1 +partition by range (a) +partitions 3 +(partition x1 values less than (5) tablespace ts1, + partition x2 values less than (10) tablespace ts2, + partition x3 values less than maxvalue tablespace ts3); + +select * from t1; + +drop table if exists t1; + +# +# Partition by range, basic +# No max value used +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a) +partitions 3 +(partition x1 values less than (5) tablespace ts1, + partition x2 values less than (10) tablespace ts2, + partition x3 values less than (15) tablespace ts3); + + +# Simple insert and verify test +INSERT into t1 values (1, 1, 1); +INSERT into t1 values (6, 1, 1); +INSERT into t1 values (10, 1, 1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT into t1 values (15, 1, 1); + +select * from t1; + +ALTER TABLE t1 +partition by range (a) +partitions 3 +(partition x1 values less than (5) tablespace ts1, + partition x2 values less than (10) tablespace ts2, + partition x3 values less than (15) tablespace ts3); + +select * from t1; + +drop table t1; + +# +# Partition by range, only one partition +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b)) +partition by range (a) +(partition x1 values less than (1)); + +drop table t1; + +# +# Subpartition by hash, two partitions and two subpartitions +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11, + subpartition x12), + partition x2 values less than (5) + ( subpartition x21, + subpartition x22) +); + +SELECT * from t1; +show create table t1; + +ALTER TABLE t1 ADD COLUMN d int; +show create table t1; + +drop table t1; + +# +# Subpartition by hash, two partitions and two subpartitions +# Defined tablespace, engine and node group +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 tablespace t1 engine myisam nodegroup 0, + subpartition x12 tablespace t2 engine myisam nodegroup 1), + partition x2 values less than (5) + ( subpartition x21 tablespace t1 engine myisam nodegroup 0, + subpartition x22 tablespace t2 engine myisam nodegroup 1) +); + +SELECT * from t1; + +drop table t1; + +# +# Subpartition by hash, two partitions and two subpartitions +# Defined tablespace, node group +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 tablespace t1 nodegroup 0, + subpartition x12 tablespace t2 nodegroup 1), + partition x2 values less than (5) + ( subpartition x21 tablespace t1 nodegroup 0, + subpartition x22 tablespace t2 nodegroup 1) +); + +SELECT * from t1; + +drop table t1; + +# +# Subpartition by hash, two partitions and two subpartitions +# Defined engine and node group +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 engine myisam nodegroup 0, + subpartition x12 engine myisam nodegroup 1), + partition x2 values less than (5) + ( subpartition x21 engine myisam nodegroup 0, + subpartition x22 engine myisam nodegroup 1) +); + +INSERT into t1 VALUES (1,1,1); +INSERT into t1 VALUES (4,1,1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT into t1 VALUES (5,1,1); + +SELECT * from t1; + +ALTER TABLE t1 +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 engine myisam nodegroup 0, + subpartition x12 engine myisam nodegroup 1), + partition x2 values less than (5) + ( subpartition x21 engine myisam nodegroup 0, + subpartition x22 engine myisam nodegroup 1) +); + +SELECT * from t1; + +drop table t1; + +# +# Subpartition by hash, two partitions and two subpartitions +# Defined tablespace, engine +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 tablespace t1 engine myisam, + subpartition x12 tablespace t2 engine myisam), + partition x2 values less than (5) + ( subpartition x21 tablespace t1 engine myisam, + subpartition x22 tablespace t2 engine myisam) +); + +INSERT into t1 VALUES (1,1,1); +INSERT into t1 VALUES (4,1,1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT into t1 VALUES (5,1,1); + +SELECT * from t1; + +ALTER TABLE t1 +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 tablespace t1 engine myisam, + subpartition x12 tablespace t2 engine myisam), + partition x2 values less than (5) + ( subpartition x21 tablespace t1 engine myisam, + subpartition x22 tablespace t2 engine myisam) +); + +SELECT * from t1; + +drop table t1; + +# +# Subpartition by hash, two partitions and two subpartitions +# Defined tablespace +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 tablespace t1, + subpartition x12 tablespace t2), + partition x2 values less than (5) + ( subpartition x21 tablespace t1, + subpartition x22 tablespace t2) +); + +INSERT into t1 VALUES (1,1,1); +INSERT into t1 VALUES (4,1,1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT into t1 VALUES (5,1,1); + +SELECT * from t1; + +ALTER TABLE t1 +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 tablespace t1 engine myisam, + subpartition x12 tablespace t2 engine myisam), + partition x2 values less than (5) + ( subpartition x21 tablespace t1 engine myisam, + subpartition x22 tablespace t2 engine myisam) +); + +SELECT * from t1; + +drop table t1; + +# +# Subpartition by hash, two partitions and two subpartitions +# Defined engine +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key (a,b)) +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 engine myisam, + subpartition x12 engine myisam), + partition x2 values less than (5) + ( subpartition x21 engine myisam, + subpartition x22 engine myisam) +); + +INSERT into t1 VALUES (1,1,1); +INSERT into t1 VALUES (4,1,1); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT into t1 VALUES (5,1,1); + +SELECT * from t1; + +ALTER TABLE t1 +partition by range (a) +subpartition by hash (a+b) +( partition x1 values less than (1) + ( subpartition x11 engine myisam, + subpartition x12 engine myisam), + partition x2 values less than (5) + ( subpartition x21 engine myisam, + subpartition x22 engine myisam) +); + +SELECT * from t1; + +drop table t1; + +# +# Bug #17894 Comparison with "less than" operator fails with Range partition +# +CREATE TABLE t1 (c1 int default NULL, c2 varchar(30) default NULL, +c3 date default NULL) engine=myisam +PARTITION BY RANGE (year(c3)) (PARTITION p0 VALUES LESS THAN (1995), +PARTITION p1 VALUES LESS THAN (1996) , PARTITION p2 VALUES LESS THAN (1997) , +PARTITION p3 VALUES LESS THAN (1998) , PARTITION p4 VALUES LESS THAN (1999) , +PARTITION p5 VALUES LESS THAN (2000) , PARTITION p6 VALUES LESS THAN (2001) , +PARTITION p7 VALUES LESS THAN (2002) , PARTITION p8 VALUES LESS THAN (2003) , +PARTITION p9 VALUES LESS THAN (2004) , PARTITION p10 VALUES LESS THAN (2010), +PARTITION p11 VALUES LESS THAN MAXVALUE ); +INSERT INTO t1 VALUES (1, 'testing partitions', '1995-07-17'), +(3, 'testing partitions','1995-07-31'), +(5, 'testing partitions','1995-08-13'), +(7, 'testing partitions','1995-08-26'), +(9, 'testing partitions','1995-09-09'), +(0, 'testing partitions','2000-07-10'), +(2, 'testing partitions','2000-07-23'), +(4, 'testing partitions','2000-08-05'), +(6, 'testing partitions','2000-08-19'), +(8, 'testing partitions','2000-09-01'); +SELECT COUNT(*) FROM t1 WHERE c3 BETWEEN '1996-12-31' AND '2000-12-31'; +SELECT COUNT(*) FROM t1 WHERE c3 < '2000-12-31'; +DROP TABLE t1; + +# +# BUG 16002: Unsigned partition functions not handled correctly +# +--error ER_RANGE_NOT_INCREASING_ERROR +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (10), + partition p1 values less than (0)); + +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (0), + partition p1 values less than (10)); +show create table t1; +drop table t1; + +create table t1 (a bigint unsigned) +partition by range (a) +(partition p0 values less than (2), + partition p1 values less than (10)); +show create table t1; +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +insert into t1 values (0xFFFFFFFFFFFFFFFF); +drop table t1; + +# +# BUG 18962 Errors in DROP PARTITION +# +create table t1 (a int) +partition by range (MOD(a,3)) +subpartition by hash(a) +subpartitions 2 +(partition p0 values less than (1), + partition p1 values less than (2), + partition p2 values less than (3), + partition p3 values less than (4)); +ALTER TABLE t1 DROP PARTITION p3; +ALTER TABLE t1 DROP PARTITION p1; +ALTER TABLE t1 DROP PARTITION p2; +drop table t1; + +create table t1 (a int) +partition by range (MOD(a,3)) +subpartition by hash(a) +subpartitions 2 +(partition p0 values less than (1), + partition p1 values less than (2), + partition p2 values less than (3), + partition p3 values less than (4)); +ALTER TABLE t1 DROP PARTITION p0; +ALTER TABLE t1 DROP PARTITION p1; +ALTER TABLE t1 DROP PARTITION p2; +drop table t1; + +# +# Bug 19830: ALTER TABLE t1 REORGANIZE PARTITION crashes +# +create table t1 (a int DEFAULT NULL, + b varchar(30) DEFAULT NULL, + c date DEFAULT NULL) +ENGINE=MYISAM DEFAULT CHARSET=latin1; + +insert into t1 values (1, 'abc', '1995-01-01'); +insert into t1 values (1, 'abc', '1995-01-02'); +insert into t1 values (1, 'abc', '1995-01-03'); +insert into t1 values (1, 'abc', '1995-01-04'); +insert into t1 values (1, 'abc', '1995-01-05'); +insert into t1 values (1, 'abc', '1995-01-06'); +insert into t1 values (1, 'abc', '1995-01-07'); +insert into t1 values (1, 'abc', '1995-01-08'); +insert into t1 values (1, 'abc', '1995-01-09'); +insert into t1 values (1, 'abc', '1995-01-10'); +insert into t1 values (1, 'abc', '1995-01-11'); +insert into t1 values (1, 'abc', '1995-01-12'); +insert into t1 values (1, 'abc', '1995-01-13'); +insert into t1 values (1, 'abc', '1995-01-14'); +insert into t1 values (1, 'abc', '1995-01-15'); +insert into t1 values (1, 'abc', '1997-01-01'); +insert into t1 values (1, 'abc', '1997-01-02'); +insert into t1 values (1, 'abc', '1997-01-03'); +insert into t1 values (1, 'abc', '1997-01-04'); +insert into t1 values (1, 'abc', '1997-01-05'); +insert into t1 values (1, 'abc', '1997-01-06'); +insert into t1 values (1, 'abc', '1997-01-07'); +insert into t1 values (1, 'abc', '1997-01-08'); +insert into t1 values (1, 'abc', '1997-01-09'); +insert into t1 values (1, 'abc', '1997-01-10'); +insert into t1 values (1, 'abc', '1997-01-11'); +insert into t1 values (1, 'abc', '1997-01-12'); +insert into t1 values (1, 'abc', '1997-01-13'); +insert into t1 values (1, 'abc', '1997-01-14'); +insert into t1 values (1, 'abc', '1997-01-15'); +insert into t1 values (1, 'abc', '1998-01-01'); +insert into t1 values (1, 'abc', '1998-01-02'); +insert into t1 values (1, 'abc', '1998-01-03'); +insert into t1 values (1, 'abc', '1998-01-04'); +insert into t1 values (1, 'abc', '1998-01-05'); +insert into t1 values (1, 'abc', '1998-01-06'); +insert into t1 values (1, 'abc', '1998-01-07'); +insert into t1 values (1, 'abc', '1998-01-08'); +insert into t1 values (1, 'abc', '1998-01-09'); +insert into t1 values (1, 'abc', '1998-01-10'); +insert into t1 values (1, 'abc', '1998-01-11'); +insert into t1 values (1, 'abc', '1998-01-12'); +insert into t1 values (1, 'abc', '1998-01-13'); +insert into t1 values (1, 'abc', '1998-01-14'); +insert into t1 values (1, 'abc', '1998-01-15'); +insert into t1 values (1, 'abc', '1999-01-01'); +insert into t1 values (1, 'abc', '1999-01-02'); +insert into t1 values (1, 'abc', '1999-01-03'); +insert into t1 values (1, 'abc', '1999-01-04'); +insert into t1 values (1, 'abc', '1999-01-05'); +insert into t1 values (1, 'abc', '1999-01-06'); +insert into t1 values (1, 'abc', '1999-01-07'); +insert into t1 values (1, 'abc', '1999-01-08'); +insert into t1 values (1, 'abc', '1999-01-09'); +insert into t1 values (1, 'abc', '1999-01-10'); +insert into t1 values (1, 'abc', '1999-01-11'); +insert into t1 values (1, 'abc', '1999-01-12'); +insert into t1 values (1, 'abc', '1999-01-13'); +insert into t1 values (1, 'abc', '1999-01-14'); +insert into t1 values (1, 'abc', '1999-01-15'); +insert into t1 values (1, 'abc', '2000-01-01'); +insert into t1 values (1, 'abc', '2000-01-02'); +insert into t1 values (1, 'abc', '2000-01-03'); +insert into t1 values (1, 'abc', '2000-01-04'); +insert into t1 values (1, 'abc', '2000-01-05'); +insert into t1 values (1, 'abc', '2000-01-06'); +insert into t1 values (1, 'abc', '2000-01-07'); +insert into t1 values (1, 'abc', '2000-01-08'); +insert into t1 values (1, 'abc', '2000-01-09'); +insert into t1 values (1, 'abc', '2000-01-15'); +insert into t1 values (1, 'abc', '2000-01-11'); +insert into t1 values (1, 'abc', '2000-01-12'); +insert into t1 values (1, 'abc', '2000-01-13'); +insert into t1 values (1, 'abc', '2000-01-14'); +insert into t1 values (1, 'abc', '2000-01-15'); +insert into t1 values (1, 'abc', '2001-01-01'); +insert into t1 values (1, 'abc', '2001-01-02'); +insert into t1 values (1, 'abc', '2001-01-03'); +insert into t1 values (1, 'abc', '2001-01-04'); +insert into t1 values (1, 'abc', '2001-01-05'); +insert into t1 values (1, 'abc', '2001-01-06'); +insert into t1 values (1, 'abc', '2001-01-07'); +insert into t1 values (1, 'abc', '2001-01-08'); +insert into t1 values (1, 'abc', '2001-01-09'); +insert into t1 values (1, 'abc', '2001-01-15'); +insert into t1 values (1, 'abc', '2001-01-11'); +insert into t1 values (1, 'abc', '2001-01-12'); +insert into t1 values (1, 'abc', '2001-01-13'); +insert into t1 values (1, 'abc', '2001-01-14'); +insert into t1 values (1, 'abc', '2001-01-15'); + +alter table t1 +partition by range (year(c)) +(partition p5 values less than (2000), partition p10 values less than (2010)); + +alter table t1 +reorganize partition p5 into +(partition p1 values less than (1996), + partition p2 values less than (1997), + partition p3 values less than (1998), + partition p4 values less than (1999), + partition p5 values less than (2000)); + +drop table t1; + +# +# New test cases for date based partitioning +# +CREATE TABLE t1 (a date) +PARTITION BY RANGE (TO_DAYS(a)) +(PARTITION p3xx VALUES LESS THAN (TO_DAYS('2004-01-01')), + PARTITION p401 VALUES LESS THAN (TO_DAYS('2004-02-01')), + PARTITION p402 VALUES LESS THAN (TO_DAYS('2004-03-01')), + PARTITION p403 VALUES LESS THAN (TO_DAYS('2004-04-01')), + PARTITION p404 VALUES LESS THAN (TO_DAYS('2004-05-01')), + PARTITION p405 VALUES LESS THAN (TO_DAYS('2004-06-01')), + PARTITION p406 VALUES LESS THAN (TO_DAYS('2004-07-01')), + PARTITION p407 VALUES LESS THAN (TO_DAYS('2004-08-01')), + PARTITION p408 VALUES LESS THAN (TO_DAYS('2004-09-01')), + PARTITION p409 VALUES LESS THAN (TO_DAYS('2004-10-01')), + PARTITION p410 VALUES LESS THAN (TO_DAYS('2004-11-01')), + PARTITION p411 VALUES LESS THAN (TO_DAYS('2004-12-01')), + PARTITION p412 VALUES LESS THAN (TO_DAYS('2005-01-01')), + PARTITION p501 VALUES LESS THAN (TO_DAYS('2005-02-01')), + PARTITION p502 VALUES LESS THAN (TO_DAYS('2005-03-01')), + PARTITION p503 VALUES LESS THAN (TO_DAYS('2005-04-01')), + PARTITION p504 VALUES LESS THAN (TO_DAYS('2005-05-01')), + PARTITION p505 VALUES LESS THAN (TO_DAYS('2005-06-01')), + PARTITION p506 VALUES LESS THAN (TO_DAYS('2005-07-01')), + PARTITION p507 VALUES LESS THAN (TO_DAYS('2005-08-01')), + PARTITION p508 VALUES LESS THAN (TO_DAYS('2005-09-01')), + PARTITION p509 VALUES LESS THAN (TO_DAYS('2005-10-01')), + PARTITION p510 VALUES LESS THAN (TO_DAYS('2005-11-01')), + PARTITION p511 VALUES LESS THAN (TO_DAYS('2005-12-01')), + PARTITION p512 VALUES LESS THAN (TO_DAYS('2006-01-01')), + PARTITION p601 VALUES LESS THAN (TO_DAYS('2006-02-01')), + PARTITION p602 VALUES LESS THAN (TO_DAYS('2006-03-01')), + PARTITION p603 VALUES LESS THAN (TO_DAYS('2006-04-01')), + PARTITION p604 VALUES LESS THAN (TO_DAYS('2006-05-01')), + PARTITION p605 VALUES LESS THAN (TO_DAYS('2006-06-01')), + PARTITION p606 VALUES LESS THAN (TO_DAYS('2006-07-01')), + PARTITION p607 VALUES LESS THAN (TO_DAYS('2006-08-01'))); + +INSERT INTO t1 VALUES ('2003-01-13'),('2003-06-20'),('2003-08-30'); +INSERT INTO t1 VALUES ('2003-04-13'),('2003-07-20'),('2003-10-30'); +INSERT INTO t1 VALUES ('2003-05-13'),('2003-11-20'),('2003-12-30'); + +INSERT INTO t1 VALUES ('2004-01-13'),('2004-01-20'),('2004-01-30'); +INSERT INTO t1 VALUES ('2004-02-13'),('2004-02-20'),('2004-02-28'); +INSERT INTO t1 VALUES ('2004-03-13'),('2004-03-20'),('2004-03-30'); +INSERT INTO t1 VALUES ('2004-04-13'),('2004-04-20'),('2004-04-30'); +INSERT INTO t1 VALUES ('2004-05-13'),('2004-05-20'),('2004-05-30'); +INSERT INTO t1 VALUES ('2004-06-13'),('2004-06-20'),('2004-06-30'); +INSERT INTO t1 VALUES ('2004-07-13'),('2004-07-20'),('2004-07-30'); +INSERT INTO t1 VALUES ('2004-08-13'),('2004-08-20'),('2004-08-30'); +INSERT INTO t1 VALUES ('2004-09-13'),('2004-09-20'),('2004-09-30'); +INSERT INTO t1 VALUES ('2004-10-13'),('2004-10-20'),('2004-10-30'); +INSERT INTO t1 VALUES ('2004-11-13'),('2004-11-20'),('2004-11-30'); +INSERT INTO t1 VALUES ('2004-12-13'),('2004-12-20'),('2004-12-30'); + +INSERT INTO t1 VALUES ('2005-01-13'),('2005-01-20'),('2005-01-30'); +INSERT INTO t1 VALUES ('2005-02-13'),('2005-02-20'),('2005-02-28'); +INSERT INTO t1 VALUES ('2005-03-13'),('2005-03-20'),('2005-03-30'); +INSERT INTO t1 VALUES ('2005-04-13'),('2005-04-20'),('2005-04-30'); +INSERT INTO t1 VALUES ('2005-05-13'),('2005-05-20'),('2005-05-30'); +INSERT INTO t1 VALUES ('2005-06-13'),('2005-06-20'),('2005-06-30'); +INSERT INTO t1 VALUES ('2005-07-13'),('2005-07-20'),('2005-07-30'); +INSERT INTO t1 VALUES ('2005-08-13'),('2005-08-20'),('2005-08-30'); +INSERT INTO t1 VALUES ('2005-09-13'),('2005-09-20'),('2005-09-30'); +INSERT INTO t1 VALUES ('2005-10-13'),('2005-10-20'),('2005-10-30'); +INSERT INTO t1 VALUES ('2005-11-13'),('2005-11-20'),('2005-11-30'); +INSERT INTO t1 VALUES ('2005-12-13'),('2005-12-20'),('2005-12-30'); + +INSERT INTO t1 VALUES ('2006-01-13'),('2006-01-20'),('2006-01-30'); +INSERT INTO t1 VALUES ('2006-02-13'),('2006-02-20'),('2006-02-28'); +INSERT INTO t1 VALUES ('2006-03-13'),('2006-03-20'),('2006-03-30'); +INSERT INTO t1 VALUES ('2006-04-13'),('2006-04-20'),('2006-04-30'); +INSERT INTO t1 VALUES ('2006-05-13'),('2006-05-20'),('2006-05-30'); +INSERT INTO t1 VALUES ('2006-06-13'),('2006-06-20'),('2006-06-30'); +INSERT INTO t1 VALUES ('2006-07-13'),('2006-07-20'),('2006-07-30'); + +SELECT * FROM t1 +WHERE a >= '2004-07-01' AND a <= '2004-09-30'; +EXPLAIN PARTITIONS SELECT * FROM t1 +WHERE a >= '2004-07-01' AND a <= '2004-09-30'; +SELECT * from t1 +WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR + (a >= '2005-07-01' AND a <= '2005-09-30'); +EXPLAIN PARTITIONS SELECT * from t1 +WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR + (a >= '2005-07-01' AND a <= '2005-09-30'); +DROP TABLE t1; + +# +# Bug 18198: Try with a couple of cases using VARCHAR fields in +# partition function. +#create table t1 (a varchar(20)) +#partition by range (ascii(a)) +#(partition p0 values less than (100), +# partition p1 values less than maxvalue); + +#insert into t1 values ("12345678901234567890"); +#insert into t1 values ("A2345678901234567890"); +#insert into t1 values ("B2345678901234567890"); +#insert into t1 values ("1234567890123456789"); +#insert into t1 values ("1234567890123456"); +#select * from t1; +#explain partitions select * from t1 where a = "12345678901234567890"; +#explain partitions select * from t1 where a = "12345678901234567890" OR +# a = "A2345678901234567890" OR +# a = "B2345678901234567890" OR +# a = "C2345678901234567890"; +#explain partitions select * from t1 where a = "01234567890123456"; +#select * from t1 where a = "01234567890123456"; +#select * from t1 where a = "12345678901234567890" OR +# a = "A2345678901234567890" OR +# a = "B2345678901234567890" OR +# a = "C2345678901234567890"; +#select * from t1 where a = "12345678901234567890"; +#drop table t1; + + +# +# BUG#30573: get wrong result with "group by" on PARTITIONed table +# +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 ( + defid int(10) unsigned NOT NULL, + day int(10) unsigned NOT NULL, + count int(10) unsigned NOT NULL, + filler char(200), + KEY (defid,day) +) +PARTITION BY RANGE (day) ( + PARTITION p7 VALUES LESS THAN (20070401) , + PARTITION p8 VALUES LESS THAN (20070501)); + +insert into t2 select 20, 20070311, 1, 'filler' from t1 A, t1 B; +insert into t2 select 20, 20070411, 1, 'filler' from t1 A, t1 B; +insert into t2 values(52, 20070321, 123, 'filler') ; +insert into t2 values(52, 20070322, 456, 'filler') ; + +select sum(count) from t2 ch where ch.defid in (50,52) and ch.day between 20070320 and 20070401 group by defid; +drop table t1, t2; + diff --git a/mysql-test/t/partition_rename_longfilename.test b/mysql-test/t/partition_rename_longfilename.test new file mode 100644 index 00000000000..5e454f01da7 --- /dev/null +++ b/mysql-test/t/partition_rename_longfilename.test @@ -0,0 +1,50 @@ +-- source include/not_windows.inc +-- source include/have_partition.inc +-- source include/not_embedded.inc +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings +let $MYSQLD_DATADIR= `SELECT @@datadir`; + +# +# Bug#30102: rename table does corrupt tables with partition files on failure +# This test case renames the table such that the partition file name +# is 255 chars long. Due the restriction of 260 char path name (including drive label) +# this will fail in windows. +# Other tests related to this bug can be found in partition_not_embedded.test +# +CREATE TABLE t1 (a INT) +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (6), + PARTITION `p1....................` VALUES LESS THAN (9), + PARTITION p2 VALUES LESS THAN MAXVALUE); +# partition p1 is 't1#P#p1' + @002e * 20 = 107 characters + file ending +# total path lenght of './test/t1#P#p1@002e@002e<...>@002e.MY[ID]' is 118 chars +--echo # List of files in database `test`, all original t1-files here +--list_files $MYSQLD_DATADIR/test t1* +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +--echo # Renaming to a file name where the first partition is 155 chars +--echo # and the second partition is 255 chars +RENAME TABLE t1 TO `t2_............................end`; +# 1234567890123456789012345678 +# t2_ + end +# .MY[ID] or .frm +# #P#p[012] +# 28 * @002e +# 6 + 4 + 5 + 28 * 5 = 155 +--echo # List of files in database `test`, should not be any t1-files here +--list_files $MYSQLD_DATADIR/test t1* +--echo # List of files in database `test`, should be all t2-files here +--list_files $MYSQLD_DATADIR/test t2* +--sorted_result +SELECT * FROM `t2_............................end`; +RENAME TABLE `t2_............................end` to t1; +--echo # List of files in database `test`, should be all t1-files here +--list_files $MYSQLD_DATADIR/test t1* +--sorted_result +SELECT * FROM t1; +DROP TABLE t1; +--echo # Should not be any files left here +--list_files $MYSQLD_DATADIR/test t1* +--list_files $MYSQLD_DATADIR/test t2* +--echo # End of bug#30102 test. diff --git a/mysql-test/t/partition_symlink.test b/mysql-test/t/partition_symlink.test new file mode 100644 index 00000000000..4147d2c6e89 --- /dev/null +++ b/mysql-test/t/partition_symlink.test @@ -0,0 +1,172 @@ +# Test that must have symlink. eg. using DATA/INDEX DIR +# (DATA/INDEX DIR requires symlinks) +-- source include/have_partition.inc +-- source include/have_symlink.inc +# remove the not_windows line after fixing bug#33687 +# symlinks must also work for files, not only directories +# as in --skip-symbolic-links +-- source include/not_windows.inc +-- disable_warnings +DROP TABLE IF EXISTS t1; +DROP DATABASE IF EXISTS mysqltest2; +-- enable_warnings + +# +# Bug 32091: Security breach via directory changes +# +# The below test shows that a pre-existing table mysqltest2.t1 cannot be +# replaced by a user with no rights in 'mysqltest2'. The altered table +# test.t1 will be altered (remove partitioning) into the test directory +# and having its partitions removed from the mysqltest2 directory. +# (the partitions data files are named <tablename>#P#<partname>.MYD +# and will not collide with a non partitioned table's data files.) +# NOTE: the privileges on files and directories are the same for all +# database users in mysqld, though mysqld enforces privileges on +# the database and table levels which in turn maps to directories and +# files, but not the other way around (any db-user can use any +# directory or file that the mysqld-process can use, via DATA/INDEX DIR) +# this is the security flaw that was used in bug#32091 and bug#32111 + +-- echo # Creating two non colliding tables mysqltest2.t1 and test.t1 +-- echo # test.t1 have partitions in mysqltest2-directory! +-- echo # user root: + CREATE USER mysqltest_1@localhost; + CREATE DATABASE mysqltest2; + USE mysqltest2; + CREATE TABLE t1 (a INT); + INSERT INTO t1 VALUES (0); +connect(con1,localhost,mysqltest_1,,); +-- echo # user mysqltest_1: + USE test; + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/tmp', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/tmp', + PARTITION p2 VALUES IN (2) + ); + -- echo # without the patch for bug#32091 this would create + -- echo # files mysqltest2/t1.MYD + .MYI and possible overwrite + -- echo # the mysqltest2.t1 table (depending on bug#32111) + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + ALTER TABLE t1 REMOVE PARTITIONING; + INSERT INTO t1 VALUES (1); + SELECT * FROM t1; +connection default; +-- echo # user root: + USE mysqltest2; + FLUSH TABLES; + -- echo # if the patch works, this should be different + -- echo # and before the patch they were the same! + SELECT * FROM t1; + USE test; + SELECT * FROM t1; + DROP TABLE t1; + DROP DATABASE mysqltest2; +# The below test shows that a pre-existing partition can not be +# destroyed by a new partition from another table. +# (Remember that a table or partition that uses the DATA/INDEX DIR +# is symlinked and thus has +# 1. the real file in the DATA/INDEX DIR and +# 2. a symlink in its default database directory pointing to +# the real file. +# So it is using/blocking 2 files in (in 2 different directories +-- echo # test that symlinks can not overwrite files when CREATE TABLE +-- echo # user root: + + CREATE DATABASE mysqltest2; + USE mysqltest2; + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/tmp', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/tmp' + ); +connection con1; +-- echo # user mysqltest_1: + USE test; + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + -- error 1,1 + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/tmp', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/tmp' + ); + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + -- error 1,1 + eval CREATE TABLE t1 (a INT) + PARTITION BY LIST (a) ( + PARTITION p0 VALUES IN (0) + DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/tmp', + PARTITION p1 VALUES IN (1) + DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp' + INDEX DIRECTORY '$MYSQLTEST_VARDIR/tmp' + ); +connection default; +-- echo # user root (cleanup): + DROP DATABASE mysqltest2; + USE test; + DROP USER mysqltest_1@localhost; + disconnect con1; + +# +# Bug #24633 SQL MODE "NO_DIR_IN_CREATE" does not work with partitioned tables +# + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval create table t2 (i int ) +partition by range (i) +( + partition p01 values less than (1000) + data directory="$MYSQLTEST_VARDIR/tmp" + index directory="$MYSQLTEST_VARDIR/tmp" +); + +set @org_mode=@@sql_mode; +set @@sql_mode='NO_DIR_IN_CREATE'; +select @@sql_mode; +create table t1 (i int ) +partition by range (i) +( + partition p01 values less than (1000) + data directory='/not/existing' + index directory='/not/existing' +); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +show create table t2; +DROP TABLE t1, t2; +set @@sql_mode=@org_mode; + +# +# Bug 21350: Data Directory problems +# +# Added ER_WRONG_TABLE_NAME and reported bug#39045 +-- error ER_WRONG_ARGUMENTS, ER_WRONG_TABLE_NAME +create table t1 (a int) +partition by key (a) +(partition p0 DATA DIRECTORY 'part-data' INDEX DIRECTORY 'part-data'); + +# +# Insert a test that manages to create the first partition and fails with +# the second, ensure that we clean up afterwards in a proper manner. +# +# Added ER_WRONG_TABLE_NAME and reported bug#39045 +--error ER_WRONG_ARGUMENTS, ER_WRONG_TABLE_NAME +create table t1 (a int) +partition by key (a) +(partition p0, + partition p1 DATA DIRECTORY 'part-data' INDEX DIRECTORY 'part-data'); diff --git a/mysql-test/t/partition_windows.test b/mysql-test/t/partition_windows.test new file mode 100644 index 00000000000..d42a7383c99 --- /dev/null +++ b/mysql-test/t/partition_windows.test @@ -0,0 +1,40 @@ +# Windows-specific partition tests +--source include/windows.inc +--source include/have_partition.inc + +# These tests contain Windows specific directory/file format. + +# +# Bug 25141: Crash Server on Partitioning command +# +# Bug#30459: Partitioning across disks failing on Windows +# updated this test, since symlinked files are not supported on Windows +# (not the same as symlinked directories that have a special hack +# on windows). This test is not dependent on have_symlink. + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 ( + c1 int(10) unsigned NOT NULL AUTO_INCREMENT, + c2 varchar(30) NOT NULL, + c3 smallint(5) unsigned DEFAULT NULL, + PRIMARY KEY (c1) +) ENGINE = MYISAM +PARTITION BY HASH(c1)( + PARTITION p0 + DATA DIRECTORY = 'C:/mysqltest/p0Data' + INDEX DIRECTORY = 'D:/mysqltest/p0Index', + PARTITION p1, + PARTITION p2 + DATA DIRECTORY = 'E:/mysqltest/p2Data' + INDEX DIRECTORY = 'F:/mysqltest/p2Index' +); +INSERT INTO t1 VALUES (NULL, "first", 1); +INSERT INTO t1 VALUES (NULL, "second", 2); +INSERT INTO t1 VALUES (NULL, "third", 3); +ALTER TABLE t1 ADD PARTITION (PARTITION p3 DATA DIRECTORY = 'G:/mysqltest/p3Data' INDEX DIRECTORY = 'H:/mysqltest/p3Index'); +INSERT INTO t1 VALUES (NULL, "last", 4); +DROP TABLE t1; + diff --git a/mysql-test/t/plugin-master.opt b/mysql-test/t/plugin-master.opt new file mode 100644 index 00000000000..367d5233e0e --- /dev/null +++ b/mysql-test/t/plugin-master.opt @@ -0,0 +1 @@ +$EXAMPLE_PLUGIN_OPT diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test new file mode 100644 index 00000000000..788a7b336ef --- /dev/null +++ b/mysql-test/t/plugin.test @@ -0,0 +1,81 @@ +--source include/not_windows_embedded.inc +--source include/have_example_plugin.inc + +CREATE TABLE t1(a int) ENGINE=EXAMPLE; +DROP TABLE t1; + +--replace_regex /\.dll/.so/ +eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +--replace_regex /\.dll/.so/ +--error 1125 +eval INSTALL PLUGIN EXAMPLE SONAME $HA_EXAMPLE_SO; + +UNINSTALL PLUGIN example; + +--replace_regex /\.dll/.so/ +eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; + +CREATE TABLE t1(a int) ENGINE=EXAMPLE; + +# Let's do some advanced ops with the example engine :) +SELECT * FROM t1; + +DROP TABLE t1; + +UNINSTALL PLUGIN example; +--error 1305 +UNINSTALL PLUGIN EXAMPLE; + +--error 1305 +UNINSTALL PLUGIN non_exist; + + +--echo # +--echo # Bug#32034: check_func_enum() does not check correct values but set it +--echo # to impossible int val +--echo # +--replace_regex /\.dll/.so/ +eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; + +SET GLOBAL example_enum_var= e1; +SET GLOBAL example_enum_var= e2; +--error 1231 +SET GLOBAL example_enum_var= impossible; + +UNINSTALL PLUGIN example; + + + +# +# Bug #32757 hang with sql_mode set when setting some global variables +# +--replace_regex /\.dll/.so/ +eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; + +select @@session.sql_mode into @old_sql_mode; + +# first, try normal sql_mode (no error, send OK) +set session sql_mode=''; +set global example_ulong_var=500; +select @@global.example_ulong_var; +# overflow -- correct value, but throw warning +set global example_ulong_var=1111; +select @@global.example_ulong_var; + +# now, try STRICT (error occurrs, no message is sent, so send default) +set session sql_mode='STRICT_ALL_TABLES'; +set global example_ulong_var=500; +select @@global.example_ulong_var; +# overflow -- throw warning, do NOT change value +--error ER_WRONG_VALUE_FOR_VAR +set global example_ulong_var=1111; +select @@global.example_ulong_var; + +set session sql_mode=@old_sql_mode; + +# finally, show that conditions that already raised an error are not +# adversely affected (error was already sent, do nothing) +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +set session old=bla; + +UNINSTALL PLUGIN example; diff --git a/mysql-test/t/plugin_load-master.opt b/mysql-test/t/plugin_load-master.opt new file mode 100644 index 00000000000..bb7831c5769 --- /dev/null +++ b/mysql-test/t/plugin_load-master.opt @@ -0,0 +1,3 @@ +$EXAMPLE_PLUGIN_OPT +$EXAMPLE_PLUGIN_LOAD +--loose-plugin-example-enum-var=e2 diff --git a/mysql-test/t/plugin_load.test b/mysql-test/t/plugin_load.test new file mode 100644 index 00000000000..97b2afbe219 --- /dev/null +++ b/mysql-test/t/plugin_load.test @@ -0,0 +1,4 @@ +--source include/not_windows_embedded.inc +--source include/have_example_plugin.inc + +SELECT @@global.example_enum_var = 'e2'; diff --git a/mysql-test/t/profiling.test b/mysql-test/t/profiling.test index 29b694fa0bd..275c2d77c4a 100644 --- a/mysql-test/t/profiling.test +++ b/mysql-test/t/profiling.test @@ -1,4 +1,4 @@ ---source include/have_profiling.inc +--source include/have_community_features.inc # Verify that the protocol isn't violated if we ask for profiling info # before profiling has recorded anything. @@ -14,6 +14,7 @@ select @@profiling; set global profiling = ON; # But size is okay +set @start_value= @@global.profiling_history_size; set global profiling_history_size=100; show global variables like 'profil%'; @@ -261,6 +262,6 @@ drop function if exists f1; ## last thing in the file set session profiling = OFF; - +set global profiling_history_size= @start_value; ## --echo End of 5.0 tests diff --git a/mysql-test/t/ps-master.opt b/mysql-test/t/ps-master.opt index 3eb98fc3d6b..31c287d2bb5 100644 --- a/mysql-test/t/ps-master.opt +++ b/mysql-test/t/ps-master.opt @@ -1 +1 @@ ---log-slow-queries --log-long-format --log-queries-not-using-indexes +--log-output=table,file --log-slow-queries --log-long-format --log-queries-not-using-indexes diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index d9e593fd76f..db5994d434b 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1,8 +1,10 @@ +-- source include/not_embedded.inc +-- source include/have_log_bin.inc # # SQL Syntax for Prepared Statements test # --disable_warnings -drop table if exists t1,t2; +drop table if exists t1,t2,t3,t4; # Avoid wrong warnings if mysql_client_test fails drop database if exists client_test_db; @@ -530,8 +532,9 @@ deallocate prepare stmt; # create table t1 (a varchar(20)); insert into t1 values ('foo'); ---error 1305 prepare stmt FROM 'SELECT char_length (a) FROM t1'; +-- error ER_SP_DOES_NOT_EXIST +prepare stmt2 FROM 'SELECT not_a_function (a) FROM t1'; drop table t1; # @@ -943,8 +946,13 @@ set global max_prepared_stmt_count=3; select @@max_prepared_stmt_count; show status like 'prepared_stmt_count'; prepare stmt from "select 1"; + connect (con1,localhost,root,,); + +# Switch to connection con1 connection con1; +let $con1_id=`SELECT CONNECTION_ID()`; + prepare stmt from "select 2"; prepare stmt1 from "select 3"; --error ER_MAX_PREPARED_STMT_COUNT_REACHED @@ -954,9 +962,19 @@ connection default; prepare stmt2 from "select 4"; select @@max_prepared_stmt_count; show status like 'prepared_stmt_count'; + +# Disconnect connection con1 and switch to default connection disconnect con1; connection default; + +# Wait for the connection con1 to die +let $wait_condition=SELECT COUNT(*)=0 FROM information_schema.processlist WHERE id=$con1_id; +--source include/wait_condition.inc + deallocate prepare stmt; + +select @@max_prepared_stmt_count; +show status like 'prepared_stmt_count'; # # Restore the old value. # @@ -1042,7 +1060,6 @@ EXECUTE STMT USING @id,@id; DEALLOCATE PREPARE STMT; DROP TABLE t1; - # # BUG#21354: (COUNT(*) = 1) not working in SELECT inside prepared # statement @@ -1239,8 +1256,9 @@ drop table t1; # create table t1 (a varchar(20)); insert into t1 values ('foo'); ---error 1305 prepare stmt FROM 'SELECT char_length (a) FROM t1'; +-- error ER_SP_DOES_NOT_EXIST +prepare stmt2 FROM 'SELECT not_a_function (a) FROM t1'; drop table t1; # @@ -1658,7 +1676,7 @@ DROP PROCEDURE IF EXISTS p1; let $iterations= 100; --disable_query_log --disable_result_log -while ($iterations > 0) +while ($iterations) { --error ER_PARSE_ERROR PREPARE stmt FROM "CREATE PROCEDURE p1()"; @@ -1763,18 +1781,18 @@ deallocate prepare stmt; drop table t1, t2; # 5.1 part of the test. # CREATE DATABASE -#set @old_character_set_server= @@character_set_server; -#set @@character_set_server= latin1; -#prepare stmt from "create database mysqltest"; -#execute stmt; -#show create database mysqltest; -#drop database mysqltest; -#set @@character_set_server= utf8; -#execute stmt; -#show create database mysqltest; -#drop database mysqltest; -#deallocate prepare stmt; -#set @@character_set_server= @old_character_set_server; +set @old_character_set_server= @@character_set_server; +set @@character_set_server= latin1; +prepare stmt from "create database mysqltest_1"; +execute stmt; +show create database mysqltest_1; +drop database mysqltest_1; +set @@character_set_server= utf8; +execute stmt; +show create database mysqltest_1; +drop database mysqltest_1; +deallocate prepare stmt; +set @@character_set_server= @old_character_set_server; # @@ -1974,3 +1992,1022 @@ execute stmt using @arg; deallocate prepare stmt; --echo End of 5.0 tests. + +# +# Bug #20665: All commands supported in Stored Procedures should work in +# Prepared Statements +# +create procedure proc_1() reset query cache; +call proc_1(); +call proc_1(); +call proc_1(); +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int deterministic begin reset query cache; return 1; end| +create function func_1() returns int deterministic begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "reset query cache"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() reset master; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin reset master; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "reset master"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() reset slave; +call proc_1(); +call proc_1(); +call proc_1(); +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin reset slave; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "reset slave"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1(a integer) kill a; +--error ER_NO_SUCH_THREAD +call proc_1(0); +--error ER_NO_SUCH_THREAD +call proc_1(0); +--error ER_NO_SUCH_THREAD +call proc_1(0); +drop procedure proc_1; +delimiter |; +create function func_1() returns int begin kill 0; return 1; end| +delimiter ;| +--error ER_NO_SUCH_THREAD +select func_1() from dual; +--error ER_NO_SUCH_THREAD +select func_1() from dual; +--error ER_NO_SUCH_THREAD +select func_1() from dual; +drop function func_1; +prepare abc from "kill 0"; +--error ER_NO_SUCH_THREAD +execute abc; +--error ER_NO_SUCH_THREAD +execute abc; +--error ER_NO_SUCH_THREAD +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush hosts; +call proc_1(); +call proc_1(); +call proc_1(); +call proc_1(); +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush hosts; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "flush hosts"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush privileges; +call proc_1(); +call proc_1(); +call proc_1(); +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush privileges; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "flush privileges"; +deallocate prepare abc; + + +create procedure proc_1() flush tables with read lock; +call proc_1(); +unlock tables; +call proc_1(); +unlock tables; +call proc_1(); +unlock tables; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush tables with read lock; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "flush tables with read lock"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +unlock tables; + + +create procedure proc_1() flush tables; +call proc_1(); +call proc_1(); +call proc_1(); +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush tables; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "flush tables"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush tables; +flush tables; +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +call proc_1(); +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +call proc_1(); +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +call proc_1(); +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +flush tables; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush tables; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; + +# make the output deterministic: +# the order used in SHOW OPEN TABLES +# is too much implementation dependent +--disable_ps_protocol +flush tables; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +--enable_ps_protocol + +prepare abc from "flush tables"; +execute abc; +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +execute abc; +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +execute abc; +show open tables from mysql; +select Host, User from mysql.user limit 0; +select Host, Db from mysql.host limit 0; +show open tables from mysql; +flush tables; +deallocate prepare abc; + + +create procedure proc_1() flush logs; +call proc_1(); +call proc_1(); +call proc_1(); +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush logs; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "flush logs"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush status; +call proc_1(); +call proc_1(); +call proc_1(); +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush status; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "flush status"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush slave; +call proc_1(); +call proc_1(); +call proc_1(); +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush slave; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "flush slave"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush master; +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush master; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "flush master"; +deallocate prepare abc; + + +create procedure proc_1() flush des_key_file; +call proc_1(); +call proc_1(); +call proc_1(); +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush des_key_file; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "flush des_key_file"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() flush user_resources; +call proc_1(); +call proc_1(); +call proc_1(); +delimiter |; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin flush user_resources; return 1; end| +create function func_1() returns int begin call proc_1(); return 1; end| +delimiter ;| +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +select func_1(), func_1(), func_1() from dual; +drop function func_1; +drop procedure proc_1; +prepare abc from "flush user_resources"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() start slave; +drop procedure proc_1; +delimiter |; +create function func_1() returns int begin start slave; return 1; end| +delimiter ;| +drop function func_1; +prepare abc from "start slave"; +deallocate prepare abc; + + +create procedure proc_1() stop slave; +drop procedure proc_1; +delimiter |; +create function func_1() returns int begin stop slave; return 1; end| +delimiter ;| +drop function func_1; +prepare abc from "stop slave"; +deallocate prepare abc; + + +create procedure proc_1() show binlog events; +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show binlog events; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show binlog events"; +deallocate prepare abc; + + +create procedure proc_1() show slave status; +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show slave status; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show slave status"; +deallocate prepare abc; + + +create procedure proc_1() show master status; +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show master status; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show master status"; +deallocate prepare abc; + + +create procedure proc_1() show master logs; +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show master logs; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show master logs"; +deallocate prepare abc; + + +create procedure proc_1() show events; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show events; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show events"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +--disable_warnings +drop procedure if exists a; +--enable_warnings +create procedure a() select 42; +create procedure proc_1(a char(2)) show create procedure a; +call proc_1("bb"); +call proc_1("bb"); +call proc_1("bb"); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show create procedure a; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show create procedure a"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop procedure a; + + +--disable_warnings +drop function if exists a; +--enable_warnings +create function a() returns int return 42+13; +create procedure proc_1(a char(2)) show create function a; +call proc_1("bb"); +call proc_1("bb"); +call proc_1("bb"); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show create function a; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show create function a"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop function a; + + +--disable_warnings +drop table if exists tab1; +--enable_warnings +create table tab1(a int, b char(1), primary key(a,b)); +create procedure proc_1() show create table tab1; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show create table tab1; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show create table tab1"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop table tab1; + + +--disable_warnings +drop view if exists v1; +drop table if exists t1; +--enable_warnings +create table t1(a int, b char(5)); +insert into t1 values (1, "one"), (1, "edno"), (2, "two"), (2, "dve"); +create view v1 as + (select a, count(*) from t1 group by a) + union all + (select b, count(*) from t1 group by b); +create procedure proc_1() show create view v1; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show create view v1; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "show create view v1"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop view v1; +drop table t1; + + +create procedure proc_1() install plugin my_plug soname 'some_plugin.so'; +--replace_regex /(Can\'t open shared library).*$/\1/ +--error ER_CANT_OPEN_LIBRARY,ER_FEATURE_DISABLED +call proc_1(); +--replace_regex /(Can\'t open shared library).*$/\1/ +--error ER_CANT_OPEN_LIBRARY,ER_FEATURE_DISABLED +call proc_1(); +--replace_regex /(Can\'t open shared library).*$/\1/ +--error ER_CANT_OPEN_LIBRARY,ER_FEATURE_DISABLED +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin install plugin my_plug soname '/tmp/plugin'; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "install plugin my_plug soname 'some_plugin.so'"; +deallocate prepare abc; + + +create procedure proc_1() uninstall plugin my_plug; +--error ER_SP_DOES_NOT_EXIST +call proc_1(); +--error ER_SP_DOES_NOT_EXIST +call proc_1(); +--error ER_SP_DOES_NOT_EXIST +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin uninstall plugin my_plug; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "uninstall plugin my_plug"; +--error ER_SP_DOES_NOT_EXIST +execute abc; +--error ER_SP_DOES_NOT_EXIST +execute abc; +--error ER_SP_DOES_NOT_EXIST +execute abc; +deallocate prepare abc; + + +--disable_warnings +drop database if exists mysqltest_xyz; +--enable_warnings +create procedure proc_1() create database mysqltest_xyz; +call proc_1(); +drop database if exists mysqltest_xyz; +call proc_1(); +--error ER_DB_CREATE_EXISTS +call proc_1(); +drop database if exists mysqltest_xyz; +call proc_1(); +drop database if exists mysqltest_xyz; +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin create database mysqltest_xyz; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "create database mysqltest_xyz"; +execute abc; +drop database if exists mysqltest_xyz; +execute abc; +--error ER_DB_CREATE_EXISTS +execute abc; +drop database if exists mysqltest_xyz; +execute abc; +drop database if exists mysqltest_xyz; +deallocate prepare abc; + + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int, b char(5)); +insert into t1 values (1, "one"), (2, "two"), (3, "three"); +create procedure proc_1() checksum table xyz; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin checksum table t1; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "checksum table t1"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; + + +create procedure proc_1() create user pstest_xyz@localhost; +call proc_1(); +drop user pstest_xyz@localhost; +call proc_1(); +--error ER_CANNOT_USER +call proc_1(); +drop user pstest_xyz@localhost; +call proc_1(); +drop user pstest_xyz@localhost; +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin create user pstest_xyz@localhost; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +prepare abc from "create user pstest_xyz@localhost"; +execute abc; +drop user pstest_xyz@localhost; +execute abc; +--error ER_CANNOT_USER +execute abc; +drop user pstest_xyz@localhost; +execute abc; +drop user pstest_xyz@localhost; +deallocate prepare abc; + + +--disable_warnings +drop event if exists xyz; +--enable_warnings +#create procedure proc_1() create event xyz on schedule every 5 minute disable do select 123; +#call proc_1(); +#drop event xyz; +#call proc_1(); +#--error ER_EVENT_ALREADY_EXISTS +#call proc_1(); +#drop event xyz; +#call proc_1(); +#drop event xyz; +#drop procedure proc_1; +delimiter |; +--error ER_EVENT_RECURSION_FORBIDDEN +create function func_1() returns int begin create event xyz on schedule at now() do select 123; return 1; end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +select func_1(), func_1(), func_1() from dual; +--error ER_SP_DOES_NOT_EXIST +drop function func_1; +--error ER_UNSUPPORTED_PS +prepare abc from "create event xyz on schedule at now() do select 123"; +--error ER_UNKNOWN_STMT_HANDLER +deallocate prepare abc; + + +--disable_warnings +drop event if exists xyz; +create event xyz on schedule every 5 minute disable do select 123; +--enable_warnings +create procedure proc_1() alter event xyz comment 'xyz'; +call proc_1(); +drop event xyz; +create event xyz on schedule every 5 minute disable do select 123; +call proc_1(); +drop event xyz; +create event xyz on schedule every 5 minute disable do select 123; +call proc_1(); +drop event xyz; +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin alter event xyz comment 'xyz'; return 1; end| +delimiter ;| +--error ER_UNSUPPORTED_PS +prepare abc from "alter event xyz comment 'xyz'"; +--error ER_UNKNOWN_STMT_HANDLER +deallocate prepare abc; + + +--disable_warnings +drop event if exists xyz; +create event xyz on schedule every 5 minute disable do select 123; +--enable_warnings +create procedure proc_1() drop event xyz; +call proc_1(); +create event xyz on schedule every 5 minute disable do select 123; +call proc_1(); +--error ER_EVENT_DOES_NOT_EXIST +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +create function func_1() returns int begin drop event xyz; return 1; end| +delimiter ;| +--error ER_UNSUPPORTED_PS +prepare abc from "drop event xyz"; +--error ER_UNKNOWN_STMT_HANDLER +deallocate prepare abc; + + +--disable_warnings +drop table if exists t1; +create table t1 (a int, b char(5)) engine=myisam; +insert into t1 values (1, "one"), (2, "two"), (3, "three"); +--enable_warnings +SET GLOBAL new_cache.key_buffer_size=128*1024; +create procedure proc_1() cache index t1 in new_cache; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +SET GLOBAL second_cache.key_buffer_size=128*1024; +prepare abc from "cache index t1 in second_cache"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop table t1; + +--disable_warnings +drop table if exists t1; +drop table if exists t2; +create table t1 (a int, b char(5)) engine=myisam; +insert into t1 values (1, "one"), (2, "two"), (3, "three"); +create table t2 (a int, b char(5)) engine=myisam; +insert into t2 values (1, "one"), (2, "two"), (3, "three"); +--enable_warnings +create procedure proc_1() load index into cache t1 ignore leaves; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin load index into cache t1 ignore leaves; return 1; end| +delimiter ;| +prepare abc from "load index into cache t2 ignore leaves"; +execute abc; +execute abc; +execute abc; +deallocate prepare abc; +drop table t1, t2; + +# +# Bug #21422: GRANT/REVOKE possible inside stored function, probably in a trigger +# This is disabled for now till it is resolved in 5.0 +# + +#create procedure proc_1() grant all on *.* to abc@host; +#drop procedure proc_1; +#delimiter |; +#--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +#create function func_1() returns int begin grant all on *.* to abc@host; return 1; end| +#delimiter ;| +#prepare abc from "grant all on *.* to abc@host"; +# +#create procedure proc_1() revoke all on *.* from abc@host; +#drop procedure proc_1; +#delimiter |;#--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +#create function func_1() returns int begin revoke all on *.* from abc@host; return 1; end| +#delimiter ;| +#prepare abc from "revoke all on *.* from abc@host"; + +create procedure proc_1() show errors; +call proc_1(); +call proc_1(); +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show errors; return 1; end| +delimiter ;| +prepare abc from "show errors"; +deallocate prepare abc; + +--disable_warnings +drop table if exists t1; +drop table if exists t2; +--enable_warnings +create procedure proc_1() show warnings; +drop table if exists t1; +call proc_1(); +drop table if exists t2; +call proc_1(); +drop table if exists t1, t2; +call proc_1(); +drop procedure proc_1; +delimiter |; +--error ER_SP_NO_RETSET +create function func_1() returns int begin show warnings; return 1; end| +delimiter ;| +prepare abc from "show warnings"; +drop table if exists t1; +execute abc; +drop table if exists t2; +execute abc; +drop table if exists t1, t2; +execute abc; +deallocate prepare abc; + +# +# Bug#22684: The Functions ENCODE, DECODE and FORMAT are not real functions +# + +set @my_password="password"; +set @my_data="clear text to encode"; + +prepare stmt1 from 'select decode(encode(?, ?), ?)'; +execute stmt1 using @my_data, @my_password, @my_password; +set @my_data="more text to encode"; +execute stmt1 using @my_data, @my_password, @my_password; +set @my_password="new password"; +execute stmt1 using @my_data, @my_password, @my_password; +deallocate prepare stmt1; + +set @to_format="123456789.123456789"; +set @dec=0; + +prepare stmt2 from 'select format(?, ?)'; +execute stmt2 using @to_format, @dec; +set @dec=4; +execute stmt2 using @to_format, @dec; +set @dec=6; +execute stmt2 using @to_format, @dec; +set @dec=2; +execute stmt2 using @to_format, @dec; +set @to_format="100"; +execute stmt2 using @to_format, @dec; +set @to_format="1000000"; +execute stmt2 using @to_format, @dec; +set @to_format="10000"; +execute stmt2 using @to_format, @dec; +deallocate prepare stmt2; + + +# +# BUG#18326: Do not lock table for writing during prepare of statement +# +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (i INT); +INSERT INTO t2 VALUES (2); + +LOCK TABLE t1 READ, t2 WRITE; + +connect (conn1, localhost, root, , ); + +# Prepare never acquires the lock, and thus should not block. +PREPARE stmt1 FROM "SELECT i FROM t1"; +PREPARE stmt2 FROM "INSERT INTO t2 (i) VALUES (3)"; + +# This should not block because READ lock on t1 is shared. +EXECUTE stmt1; + +# This should block because WRITE lock on t2 is exclusive. +send EXECUTE stmt2; + +connection default; + +SELECT * FROM t2; +UNLOCK TABLES; +let $wait_condition= SELECT COUNT(*) = 2 FROM t2; +--source include/wait_condition.inc +SELECT * FROM t2; + +# DDL and DML works even if some client have a prepared statement +# referencing the table. +ALTER TABLE t1 ADD COLUMN j INT; +ALTER TABLE t2 ADD COLUMN j INT; +INSERT INTO t1 VALUES (4, 5); +INSERT INTO t2 VALUES (4, 5); + +connection conn1; + +reap; +EXECUTE stmt1; +EXECUTE stmt2; +SELECT * FROM t2; + +disconnect conn1; + +connection default; + +DROP TABLE t1, t2; + +# +# Bug #24879 Prepared Statements: CREATE TABLE (UTF8 KEY) produces a growing +# key length +# +# Test that parse information is not altered by subsequent executions of a +# prepared statement +# +drop table if exists t1; +prepare stmt +from "create table t1 (c char(100) character set utf8, key (c(10)))"; +execute stmt; +show create table t1; +drop table t1; +execute stmt; +show create table t1; +drop table t1; + +# +# Bug #32030 DELETE does not return an error and deletes rows if error +# evaluating WHERE +# +# Test that there is an error for prepared delete just like for the normal +# one. +# +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +create table t1 (a int, b int); +create table t2 like t1; + +insert into t1 (a, b) values (1,1), (1,2), (1,3), (1,4), (1,5), + (2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6); + +insert into t2 select a, max(b) from t1 group by a; + +prepare stmt from "delete from t2 where (select (select max(b) from t1 group +by a having a < 2) x from t1) > 10000"; + +--error ER_SUBQUERY_NO_1_ROW +delete from t2 where (select (select max(b) from t1 group +by a having a < 2) x from t1) > 10000; +--error ER_SUBQUERY_NO_1_ROW +execute stmt; +--error ER_SUBQUERY_NO_1_ROW +execute stmt; + +deallocate prepare stmt; +drop table t1, t2; + +--echo # +--echo # Bug#27430 Crash in subquery code when in PS and table DDL changed +--echo # after PREPARE +--echo # +--echo # This part of the test doesn't work in embedded server, this is +--echo # why it's here. For the main test see ps_ddl*.test +--echo +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show events where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + + +--echo End of 5.1 tests. diff --git a/mysql-test/t/ps_11bugs.test b/mysql-test/t/ps_11bugs.test index 515bcc03c1a..ccab833e878 100644 --- a/mysql-test/t/ps_11bugs.test +++ b/mysql-test/t/ps_11bugs.test @@ -177,4 +177,41 @@ select * from t2; drop table t1; drop table t2; +# +# Bug #32124: crash if prepared statements refer to variables in the where +# clause +# + +CREATE TABLE t1 (a INT); +PREPARE stmt FROM 'select 1 from `t1` where `a` = any (select (@@tmpdir))'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + +CREATE TABLE t2 (a INT PRIMARY KEY); +INSERT INTO t2 VALUES (400000), (400001); + +SET @@sort_buffer_size=400000; + +DELIMITER |; + +CREATE FUNCTION p1(i INT) RETURNS INT +BEGIN + SET @@sort_buffer_size= i; + RETURN i + 1; +END| + +DELIMITER ;| + +SELECT * FROM t2 WHERE a = @@sort_buffer_size AND p1(@@sort_buffer_size + 1) > a - 1; + +DROP TABLE t2; +DROP FUNCTION p1; + + +SELECT CONCAT(@@sort_buffer_size); +SELECT LEFT("12345", @@ft_boolean_syntax); + +SET @@sort_buffer_size=DEFAULT; + --echo End of 5.0 tests. diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test index 65e7f6a8682..387b3ebdd05 100644 --- a/mysql-test/t/ps_1general.test +++ b/mysql-test/t/ps_1general.test @@ -181,7 +181,7 @@ create table t5 a int primary key, b char(30), c int, - d timestamp default current_timestamp + d timestamp default '2008-02-23 09:23:45' ); insert into t5( a, b, c) values( 9, 'recreated table', 9); execute stmt2 ; @@ -191,7 +191,7 @@ drop table t5 ; create table t5 ( a int primary key, - d timestamp default current_timestamp, + d timestamp default '2008-02-23 09:23:45', b char(30), c int ); @@ -218,7 +218,6 @@ create table t5 f3 int ); insert into t5( f1, f2, f3) values( 9, 'recreated table', 9); ---error ER_BAD_FIELD_ERROR execute stmt2 ; drop table t5 ; @@ -321,30 +320,21 @@ prepare stmt4 from ' show status like ''Threads_running'' '; execute stmt4; prepare stmt4 from ' show variables like ''sql_mode'' '; execute stmt4; -prepare stmt4 from ' show engine bdb logs '; -# The output depends on the history (actions of the bdb engine). -# That is the reason why, we switch the output here off. -# (The real output will be tested in ps_6bdb.test) -# --replace_result $MYSQL_TEST_DIR TEST_DIR ---disable_result_log +prepare stmt4 from ' show engine myisam logs '; execute stmt4; ---enable_result_log prepare stmt4 from ' show grants for user '; ---error ER_UNSUPPORTED_PS prepare stmt4 from ' show create table t2 '; ---error ER_UNSUPPORTED_PS prepare stmt4 from ' show master status '; ---error ER_UNSUPPORTED_PS prepare stmt4 from ' show master logs '; ---error ER_UNSUPPORTED_PS prepare stmt4 from ' show slave status '; ---error ER_UNSUPPORTED_PS prepare stmt4 from ' show warnings limit 20 '; ---error ER_UNSUPPORTED_PS prepare stmt4 from ' show errors limit 20 '; prepare stmt4 from ' show storage engines '; ---replace_column 2 YES/NO +# The output depends upon the precise order in which +# storage engines are registered, so we switch off the output. +--disable_result_log execute stmt4; +--enable_result_log ################ MISC STUFF ################ ## get a warning and an error @@ -432,10 +422,8 @@ prepare stmt1 from 'alter view v1 as select 2'; prepare stmt4 from ' use test ' ; ## create/drop database ---error ER_UNSUPPORTED_PS prepare stmt3 from ' create database mysqltest '; create database mysqltest ; ---error ER_UNSUPPORTED_PS prepare stmt3 from ' drop database mysqltest '; drop database mysqltest ; @@ -467,15 +455,14 @@ eval prepare stmt1 from ' select * into outfile ''$datafile'' from t1 '; ## prepare stmt1 from ' optimize table t1 ' ; prepare stmt1 from ' analyze table t1 ' ; ---error ER_UNSUPPORTED_PS prepare stmt1 from ' checksum table t1 ' ; prepare stmt1 from ' repair table t1 ' ; + --replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> --error ER_UNSUPPORTED_PS eval prepare stmt1 from ' restore table t1 from ''$datafile'' ' ; --remove_file $datafile - ## handler --error ER_UNSUPPORTED_PS prepare stmt1 from ' handler t1 open '; @@ -503,11 +490,8 @@ SET sql_mode=ansi; execute stmt5; SET sql_mode=""; ---error ER_UNSUPPORTED_PS prepare stmt1 from ' flush local privileges ' ; ---error ER_UNSUPPORTED_PS prepare stmt1 from ' reset query cache ' ; ---error ER_UNSUPPORTED_PS prepare stmt1 from ' KILL 0 '; ## simple explain @@ -603,7 +587,7 @@ prepare stmt1 from ' rename table t5 to t6, t7 to t8 ' ; create table t5 (a int) ; # rename must fail, t7 does not exist # Clean up the filename here because embedded server reports whole path ---replace_result \\ / $MYSQLTEST_VARDIR . /master-data/ / t7.frm t7 +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' t7.frm t7 --error ER_FILE_NOT_FOUND execute stmt1 ; create table t7 (a int) ; diff --git a/mysql-test/t/ps_6bdb.test b/mysql-test/t/ps_6bdb.test deleted file mode 100644 index 49dd7aa924b..00000000000 --- a/mysql-test/t/ps_6bdb.test +++ /dev/null @@ -1,25 +0,0 @@ -############################################### -# # -# 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 diff --git a/mysql-test/t/ps_7ndb.test b/mysql-test/t/ps_7ndb.test deleted file mode 100644 index e3f65ec2c4e..00000000000 --- a/mysql-test/t/ps_7ndb.test +++ /dev/null @@ -1,25 +0,0 @@ -############################################### -# # -# Prepared Statements test on NDB tables # -# # -############################################### - -# -# NOTE: PLEASE SEE ps_1general.test (bottom) -# BEFORE ADDING NEW TEST CASES HERE !!! - -use test; - --- source include/have_ndb.inc -let $type= 'NDB' ; --- 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 diff --git a/mysql-test/t/ps_ddl.test b/mysql-test/t/ps_ddl.test new file mode 100644 index 00000000000..fee235cd36c --- /dev/null +++ b/mysql-test/t/ps_ddl.test @@ -0,0 +1,2048 @@ +# +# Testing the behavior of 'PREPARE', 'DDL', 'EXECUTE' scenarios +# +# Background: +# In a statement like "select * from t1", t1 can be: +# - nothing (the table does not exist) +# - a real table +# - a temporary table +# - a view +# +# Changing the nature of "t1" between a PREPARE and an EXECUTE +# can invalidate the internal state of a prepared statement, so that, +# during the execute, the server should: +# - detect state changes and fail to execute a statement, +# instead of crashing the server or returning wrong results +# - "RE-PREPARE" the statement to restore a valid internal state. +# +# Also, changing the physical structure of "t1", by: +# - changing the definition of t1 itself (DDL on tables, views) +# - changing TRIGGERs associated with a table +# - changing PROCEDURE, FUNCTION referenced by a TRIGGER body, +# - changing PROCEDURE, FUNCTION referenced by a VIEW body, +# impacts the internal structure of a prepared statement, and should +# cause the same verifications at execute time to be performed. +# +# This test provided in this file cover the different state transitions +# between a PREPARE and an EXECUTE, and are organized as follows: +# - Part 1: NOTHING -> TABLE +# - Part 2: NOTHING -> TEMPORARY TABLE +# - Part 3: NOTHING -> VIEW +# - Part 4: TABLE -> NOTHING +# - Part 5: TABLE -> TABLE (DDL) +# - Part 6: TABLE -> TABLE (TRIGGER) +# - Part 7: TABLE -> TABLE (TRIGGER dependencies) +# - Part 8: TABLE -> TEMPORARY TABLE +# - Part 9: TABLE -> VIEW +# - Part 10: TEMPORARY TABLE -> NOTHING +# - Part 11: TEMPORARY TABLE -> TABLE +# - Part 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL) +# - Part 13: TEMPORARY TABLE -> VIEW +# - Part 14: VIEW -> NOTHING +# - Part 15: VIEW -> TABLE +# - Part 16: VIEW -> TEMPORARY TABLE +# - Part 17: VIEW -> VIEW (DDL) +# - Part 18: VIEW -> VIEW (VIEW dependencies) +# - Part 19: Special tables (INFORMATION_SCHEMA) +# - Part 20: Special tables (log tables) +# - Part 21: Special tables (system tables) +# - Part 22: Special tables (views temp tables) +# - Part 23: Special statements +# - Part 24: Testing the strength of TABLE_SHARE version +--disable_warnings +drop temporary table if exists t1, t2, t3; +drop table if exists t1, t2, t3; +drop procedure if exists p_verify_reprepare_count; +drop procedure if exists p1; +drop function if exists f1; +drop view if exists v1, v2; +--enable_warnings + +delimiter |; +create procedure p_verify_reprepare_count(expected int) +begin + declare old_reprepare_count int default @reprepare_count; + + select variable_value from + information_schema.session_status where + variable_name='com_stmt_reprepare' + into @reprepare_count; + + if old_reprepare_count + expected <> @reprepare_count then + select concat("Expected: ", expected, + ", actual: ", @reprepare_count - old_reprepare_count) + as "ERROR"; + else + select '' as "SUCCESS"; + end if; +end| +delimiter ;| +set @reprepare_count= 0; +flush status; + +--echo ===================================================================== +--echo Part 1: NOTHING -> TABLE transitions +--echo ===================================================================== + +# can not be tested since prepare failed +--error ER_NO_SUCH_TABLE +prepare stmt from "select * from t1"; + +--echo ===================================================================== +--echo Part 2: NOTHING -> TEMPORARY TABLE transitions +--echo ===================================================================== + +# can not be tested + +--echo ===================================================================== +--echo Part 3: NOTHING -> VIEW transitions +--echo ===================================================================== + +# can not be tested + +--echo ===================================================================== +--echo Part 4: TABLE -> NOTHING transitions +--echo ===================================================================== + +--echo # Test 4-a: select ... from <table> +create table t1 (a int); + +prepare stmt from "select * from t1"; +execute stmt; +call p_verify_reprepare_count(0); +execute stmt; +call p_verify_reprepare_count(0); + +drop table t1; +--error ER_NO_SUCH_TABLE +execute stmt; +call p_verify_reprepare_count(0); +--error ER_NO_SUCH_TABLE +execute stmt; +call p_verify_reprepare_count(0); +deallocate prepare stmt; + +--echo # Test 4-b: TABLE -> NOTHING by renaming the table +create table t1 (a int); +prepare stmt from "select * from t1"; +execute stmt; +call p_verify_reprepare_count(0); +execute stmt; +call p_verify_reprepare_count(0); + +rename table t1 to t2; +--error ER_NO_SUCH_TABLE +execute stmt; +call p_verify_reprepare_count(0); +--error ER_NO_SUCH_TABLE +execute stmt; +call p_verify_reprepare_count(0); + +deallocate prepare stmt; +drop table t2; + +--echo ===================================================================== +--echo Part 5: TABLE -> TABLE (DDL) transitions +--echo ===================================================================== + +create table t1 (a int); + +prepare stmt from "select a from t1"; +execute stmt; +call p_verify_reprepare_count(0); +execute stmt; +call p_verify_reprepare_count(0); + +alter table t1 add column (b int); + +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +drop table t1; +deallocate prepare stmt; + + +--echo ===================================================================== +--echo Part 6: TABLE -> TABLE (TRIGGER) transitions +--echo ===================================================================== + +--echo # Test 6-a: adding a relevant trigger + +create table t1 (a int); + +prepare stmt from "insert into t1 (a) value (?)"; +set @val=1; +execute stmt using @val; +call p_verify_reprepare_count(0); + +# Relevant trigger: execute should reprepare +create trigger t1_bi before insert on t1 for each row + set @message= new.a; + +set @val=2; +execute stmt using @val; +call p_verify_reprepare_count(1); +select @message; +set @val=3; +execute stmt using @val; +call p_verify_reprepare_count(0); +select @message; + +prepare stmt from "insert into t1 (a) value (?)"; +set @val=4; +execute stmt using @val; +call p_verify_reprepare_count(0); +select @message; + +--echo # Test 6-b: adding an irrelevant trigger + +# Unrelated trigger: reprepare may or may not happen, implementation dependent +create trigger t1_bd before delete on t1 for each row + set @message= old.a; + +set @val=5; +execute stmt using @val; +call p_verify_reprepare_count(1); +select @message; +set @val=6; +execute stmt using @val; +call p_verify_reprepare_count(0); +select @message; + +prepare stmt from "insert into t1 (a) value (?)"; +set @val=7; +execute stmt using @val; +call p_verify_reprepare_count(0); +select @message; + +--echo # Test 6-c: changing a relevant trigger + +# Relevant trigger: execute should reprepare +drop trigger t1_bi; +create trigger t1_bi before insert on t1 for each row + set @message= concat("new trigger: ", new.a); + +set @val=8; +execute stmt using @val; +call p_verify_reprepare_count(1); +select @message; +set @val=9; +execute stmt using @val; +call p_verify_reprepare_count(0); +select @message; + +prepare stmt from "insert into t1 (a) value (?)"; +set @val=10; +execute stmt using @val; +call p_verify_reprepare_count(0); +select @message; + +--echo # Test 6-d: changing an irrelevant trigger + +# Unrelated trigger: reprepare may or may not happen, implementation dependent +drop trigger t1_bd; + +set @val=11; +execute stmt using @val; +call p_verify_reprepare_count(1); +select @message; + +--echo Test 6-e: removing a relevant trigger + +drop trigger t1_bi; + +set @val=12; +execute stmt using @val; +call p_verify_reprepare_count(1); +select @message; +set @val=13; +execute stmt using @val; +call p_verify_reprepare_count(0); +select @message; + +prepare stmt from "insert into t1 (a) value (?)"; +set @val=14; +execute stmt using @val; +call p_verify_reprepare_count(0); +select @message; + +select * from t1 order by a; +drop table t1; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 7: TABLE -> TABLE (TRIGGER dependencies) transitions +--echo ===================================================================== + +--echo # Test 7-a: dependent PROCEDURE has changed +--echo # +--echo # Note, this scenario is not supported, subject of Bug#12093 +--echo # + +create table t1 (a int); +create trigger t1_ai after insert on t1 for each row + call p1(new.a); +create procedure p1(a int) begin end; +prepare stmt from "insert into t1 (a) values (?)"; +set @var= 1; +execute stmt using @var; +drop procedure p1; +create procedure p1 (a int) begin end; +set @var= 2; +--error ER_SP_DOES_NOT_EXIST +execute stmt using @var; +--echo # Cleanup +drop procedure p1; +call p_verify_reprepare_count(0); + +--echo # Test 7-b: dependent FUNCTION has changed +--echo # +--echo # Note, this scenario is supported, subject of Bug#12093 +--echo # +drop trigger t1_ai; +create trigger t1_ai after insert on t1 for each row + select f1(new.a+1) into @var; +create function f1 (a int) returns int return a; +prepare stmt from "insert into t1(a) values (?)"; +set @var=3; +execute stmt using @var; +select @var; +drop function f1; +create function f1 (a int) returns int return 0; +execute stmt using @var; +call p_verify_reprepare_count(1); +drop function f1; +deallocate prepare stmt; + +--echo # Test 7-c: dependent VIEW has changed +--echo # +--echo # Note, this scenario is not functioning correctly, see +--echo # Bug#33255 Trigger using views and view ddl : corrupted triggers +--echo # and Bug #33000 Triggers do not detect changes in meta-data. +--echo # +drop trigger t1_ai; +create table t2 (a int unique); +create table t3 (a int unique); +create view v1 as select a from t2; +create trigger t1_ai after insert on t1 for each row + insert into v1 (a) values (new.a); + +--echo # Demonstrate that the same bug is present +--echo # without prepared statements +insert into t1 (a) values (5); +select * from t2; +select * from t3; +drop view v1; +create view v1 as select a from t3; +--error ER_NO_SUCH_TABLE +insert into t1 (a) values (6); +flush table t1; +insert into t1 (a) values (6); +select * from t2; +select * from t3; + +prepare stmt from "insert into t1 (a) values (?)"; +set @var=7; +execute stmt using @var; +call p_verify_reprepare_count(0); +select * from t3; +select * from t2; +drop view v1; +create view v1 as select a from t2; +set @var=8; +--echo # XXX: bug, the SQL statement in the trigger is still +--echo # pointing at table 't3', since the view was expanded +--echo # at first statement execution. +--echo # Repreparation of the main statement doesn't cause repreparation +--echo # of trigger statements. +--error ER_NO_SUCH_TABLE +execute stmt using @var; +call p_verify_reprepare_count(1); +--echo # +--echo # Sic: the insert went into t3, even though the view now +--echo # points at t2. This is because neither the merged view +--echo # nor its prelocking list are affected by view DDL +--echo # The binary log is of course wrong, since it is not +--echo # using prepared statements +--echo # +select * from t2; +select * from t3; +flush table t1; +set @var=9; +execute stmt using @var; +call p_verify_reprepare_count(1); +select * from t2; +select * from t3; +drop view v1; +drop table t1,t2,t3; + +--echo # Test 7-d: dependent TABLE has changed +create table t1 (a int); +create trigger t1_ai after insert on t1 for each row + insert into t2 (a) values (new.a); +create table t2 (a int); + +prepare stmt from "insert into t1 (a) values (?)"; +set @var=1; +execute stmt using @var; +alter table t2 add column comment varchar(255); +set @var=2; +--echo # Since the dependent table is tracked in the prelocked +--echo # list of the prepared statement, invalidation happens +--echo # and the statement is re-prepared. This is an unnecessary +--echo # side effect, since the statement that *is* dependent +--echo # on t2 definition is inside the trigger, and it is currently +--echo # not reprepared (see the previous test case). +execute stmt using @var; +call p_verify_reprepare_count(1); +select * from t1; +select * from t2; +drop table t1,t2; + +--echo # Test 7-e: dependent TABLE TRIGGER has changed +create table t1 (a int); +create trigger t1_ai after insert on t1 for each row + insert into t2 (a) values (new.a); +create table t2 (a int unique); +create trigger t2_ai after insert on t2 for each row + insert into t3 (a) values (new.a); +create table t3 (a int unique); +create table t4 (a int unique); + +insert into t1 (a) values (1); +select * from t1 join t2 on (t1.a=t2.a) join t3 on (t2.a=t3.a); +drop trigger t2_ai; +create trigger t2_ai after insert on t2 for each row + insert into t4 (a) values (new.a); +insert into t1 (a) values (2); +select * from t1 join t2 on (t1.a=t2.a) join t4 on (t2.a=t4.a); + +prepare stmt from "insert into t1 (a) values (?)"; +set @var=3; +execute stmt using @var; +select * from t1 join t2 on (t1.a=t2.a) join t4 on (t2.a=t4.a); +drop trigger t2_ai; +create trigger t2_ai after insert on t2 for each row + insert into t3 (a) values (new.a); +set @var=4; +execute stmt using @var; +call p_verify_reprepare_count(1); +select * from t1 join t2 on (t1.a=t2.a) join t3 on (t2.a=t3.a); +select * from t1 join t2 on (t1.a=t2.a) join t4 on (t2.a=t4.a); + +drop table t1, t2, t3, t4; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 8: TABLE -> TEMPORARY TABLE transitions +--echo ===================================================================== + +--echo # Test 8-a: base table used recreated as temporary table +create table t1 (a int); + +prepare stmt from "select * from t1"; +execute stmt; + +drop table t1; +create temporary table t1 (a int); + +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +drop table t1; +deallocate prepare stmt; + +--echo # Test 8-b: temporary table has precedence over base table with same name +create table t1 (a int); +prepare stmt from 'select count(*) from t1'; +execute stmt; +call p_verify_reprepare_count(0); +execute stmt; +call p_verify_reprepare_count(0); + +create temporary table t1 AS SELECT 1; +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +deallocate prepare stmt; +drop temporary table t1; +drop table t1; + + +--echo ===================================================================== +--echo Part 9: TABLE -> VIEW transitions +--echo ===================================================================== + +create table t1 (a int); + +prepare stmt from "select * from t1"; +execute stmt; +call p_verify_reprepare_count(0); + +drop table t1; +create table t2 (a int); +create view t1 as select * from t2; + +execute stmt; +call p_verify_reprepare_count(1); + +drop view t1; +drop table t2; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 10: TEMPORARY TABLE -> NOTHING transitions +--echo ===================================================================== + +create temporary table t1 (a int); + +prepare stmt from "select * from t1"; +execute stmt; +call p_verify_reprepare_count(0); + +drop temporary table t1; +--error ER_NO_SUCH_TABLE +execute stmt; +call p_verify_reprepare_count(0); +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 11: TEMPORARY TABLE -> TABLE transitions +--echo ===================================================================== + +--echo # Test 11-a: temporary table replaced by base table +create table t1 (a int); +insert into t1 (a) value (1); +create temporary table t1 (a int); + +prepare stmt from "select * from t1"; +execute stmt; +call p_verify_reprepare_count(0); + +drop temporary table t1; + +execute stmt; +call p_verify_reprepare_count(1); + +select * from t1; +drop table t1; +deallocate prepare stmt; + + +--echo # Test 11-b: temporary table has precedence over base table with same name +--echo # temporary table disappears +create table t1 (a int); +create temporary table t1 as select 1 as a; +prepare stmt from "select count(*) from t1"; +execute stmt; +call p_verify_reprepare_count(0); +execute stmt; +call p_verify_reprepare_count(0); + +drop temporary table t1; +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +deallocate prepare stmt; +drop table t1; + + +--echo ===================================================================== +--echo Part 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL) transitions +--echo ===================================================================== + +create temporary table t1 (a int); + +prepare stmt from "select a from t1"; +execute stmt; +call p_verify_reprepare_count(0); + +drop temporary table t1; +create temporary table t1 (a int, b int); + +execute stmt; +call p_verify_reprepare_count(1); + +select * from t1; +drop temporary table t1; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 13: TEMPORARY TABLE -> VIEW transitions +--echo ===================================================================== + +create temporary table t1 (a int); +create table t2 (a int); + +prepare stmt from "select * from t1"; +execute stmt; +call p_verify_reprepare_count(0); + +drop temporary table t1; +create view t1 as select * from t2; + +execute stmt; +call p_verify_reprepare_count(1); + +drop view t1; +drop table t2; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 14: VIEW -> NOTHING transitions +--echo ===================================================================== + +create table t2 (a int); +create view t1 as select * from t2; + +prepare stmt from "select * from t1"; +execute stmt; +drop view t1; + +--error ER_NO_SUCH_TABLE +execute stmt; +call p_verify_reprepare_count(0); +--error ER_NO_SUCH_TABLE +execute stmt; +call p_verify_reprepare_count(0); + +drop table t2; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 15: VIEW -> TABLE transitions +--echo ===================================================================== + +create table t2 (a int); +create view t1 as select * from t2; + +prepare stmt from "select * from t1"; +execute stmt; +call p_verify_reprepare_count(0); + +drop view t1; +create table t1 (a int); + +execute stmt; +call p_verify_reprepare_count(1); + +drop table t2; +drop table t1; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 16: VIEW -> TEMPORARY TABLE transitions +--echo ===================================================================== + +create table t2 (a int); +insert into t2 (a) values (1); +create view t1 as select * from t2; + +prepare stmt from "select * from t1"; +execute stmt; +call p_verify_reprepare_count(0); + +create temporary table t1 (a int); +execute stmt; +call p_verify_reprepare_count(1); +drop view t1; +execute stmt; +call p_verify_reprepare_count(0); + +drop table t2; +drop temporary table t1; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 17: VIEW -> VIEW (DDL) transitions +--echo ===================================================================== + +create table t2 (a int); +insert into t2 values (10), (20), (30); + +create view t1 as select a, 2*a as b, 3*a as c from t2; +select * from t1; + +prepare stmt from "select * from t1"; +execute stmt; + +drop view t1; +create view t1 as select a, 2*a as b, 5*a as c from t2; +select * from t1; + +--echo # Currently a different result from conventional statements. +--echo # A view is inlined once at prepare, later on view DDL +--echo # does not affect prepared statement and it is not re-prepared. +--echo # This is reported in Bug#36002 Prepared statements: if a view +--echo # used in a statement is replaced, bad data +execute stmt; +call p_verify_reprepare_count(0); +flush table t2; +execute stmt; +call p_verify_reprepare_count(1); + +drop table t2; +drop view t1; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 18: VIEW -> VIEW (VIEW dependencies) transitions +--echo ===================================================================== + +--echo # Part 18a: dependent function has changed +create table t1 (a int); +insert into t1 (a) values (1), (2), (3); +create function f1() returns int return (select max(a) from t1); +create view v1 as select f1(); +prepare stmt from "select * from v1"; +execute stmt; +execute stmt; +call p_verify_reprepare_count(0); +drop function f1; +create function f1() returns int return 2; +--echo # XXX: Used to be another manifestation of Bug#12093. +--echo # We only used to get a different error +--echo # message because the non-existing procedure error is masked +--echo # by the view. +execute stmt; +execute stmt; +call p_verify_reprepare_count(1); + +--echo # Part 18b: dependent procedure has changed (referred to via a function) + +create table t2 (a int); +insert into t2 (a) values (4), (5), (6); + +drop function f1; +delimiter |; +create function f1() returns int +begin + declare x int; + call p1(x); + return x; +end| +delimiter ;| +create procedure p1(out x int) select max(a) from t1 into x; + +prepare stmt from "select * from v1"; +execute stmt; +execute stmt; +call p_verify_reprepare_count(0); +drop procedure p1; +create procedure p1(out x int) select max(a) from t2 into x; +--echo # XXX: used to be a bug. The prelocked list was not invalidated +--echo # and we kept opening table t1, whereas the procedure +--echo # is now referring to table t2 +execute stmt; +call p_verify_reprepare_count(1); +flush table t1; +execute stmt; +call p_verify_reprepare_count(0); +execute stmt; + +--echo # Test 18-c: dependent VIEW has changed + +drop view v1; +create view v2 as select a from t1; +create view v1 as select * from v2; +prepare stmt from "select * from v1"; +execute stmt; +execute stmt; +call p_verify_reprepare_count(0); +drop view v2; +create view v2 as select a from t2; +execute stmt; +execute stmt; +call p_verify_reprepare_count(0); +flush table t1; +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +--echo # Test 18-d: dependent TABLE has changed +drop view v2; +create table v2 as select * from t1; +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); +drop table v2; +create table v2 (a int unique) as select * from t2; +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +--echo # Test 18-e: dependent TABLE trigger has changed + +prepare stmt from "insert into v1 (a) values (?)"; +set @var= 7; +execute stmt using @var; +call p_verify_reprepare_count(0); +create trigger v2_bi before insert on v2 for each row set @message="v2_bi"; +set @var=8; +execute stmt using @var; +call p_verify_reprepare_count(1); +select @message; +drop trigger v2_bi; +set @message=null; +set @var=9; +execute stmt using @var; +call p_verify_reprepare_count(1); +select @message; +create trigger v2_bi after insert on v2 for each row set @message="v2_ai"; +set @var= 10; +execute stmt using @var; +call p_verify_reprepare_count(1); +select @message; +select * from v1; + +--echo # Cleanup + +--disable_warnings +drop table if exists t1, t2, v1, v2; +drop view if exists v1, v2; +drop function f1; +drop procedure p1; +--enable_warnings +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 19: Special tables (INFORMATION_SCHEMA) +--echo ===================================================================== + +# Using a temporary table internally should not confuse the prepared +# statement code, and should not raise ER_PS_INVALIDATED errors +prepare stmt from + "select ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE + from INFORMATION_SCHEMA.ROUTINES where + routine_name='p1'"; + +create procedure p1() select "hi there"; + +execute stmt; +execute stmt; + +drop procedure p1; +create procedure p1() select "hi there, again"; + +execute stmt; +execute stmt; +call p_verify_reprepare_count(0); + +drop procedure p1; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 20: Special tables (log tables) +--echo ===================================================================== + +prepare stmt from + "select * from mysql.general_log where argument='IMPOSSIBLE QUERY STRING'"; + +--disable_result_log +execute stmt; +execute stmt; +execute stmt; +execute stmt; +--enable_result_log +call p_verify_reprepare_count(0); +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 21: Special tables (system tables) +--echo ===================================================================== + +prepare stmt from + "select type, db, name from mysql.proc where name='p1'"; + +create procedure p1() select "hi there"; + +execute stmt; +execute stmt; + +drop procedure p1; +create procedure p1() select "hi there, again"; + +execute stmt; +execute stmt; +call p_verify_reprepare_count(0); + +drop procedure p1; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 22: Special tables (views temp tables) +--echo ===================================================================== + +create table t1 (a int); + +create algorithm=temptable view v1 as select a*a as a2 from t1; + +--echo # Using a temporary table internally should not confuse the prepared +--echo # statement code, and should not raise ER_PS_INVALIDATED errors +show create view v1; + +prepare stmt from "select * from v1"; + +insert into t1 values (1), (2), (3); +execute stmt; +execute stmt; + +insert into t1 values (4), (5), (6); +execute stmt; +execute stmt; +call p_verify_reprepare_count(0); + +drop table t1; +drop view v1; + +--echo ===================================================================== +--echo Part 23: Special statements +--echo ===================================================================== + +--echo # SQLCOM_ALTER_TABLE: + + +create table t1 (a int); + +prepare stmt from "alter table t1 add column b int"; +execute stmt; + +drop table t1; +create table t1 (a1 int, a2 int); + +--echo # t1 has changed, and it's does not lead to reprepare +execute stmt; + +alter table t1 drop column b; +execute stmt; + +alter table t1 drop column b; +execute stmt; +call p_verify_reprepare_count(0); + +drop table t1; + +--echo # SQLCOM_REPAIR: + +create table t1 (a int); + +insert into t1 values (1), (2), (3); + +prepare stmt from "repair table t1"; + +execute stmt; +execute stmt; + +drop table t1; +create table t1 (a1 int, a2 int); +insert into t1 values (1, 10), (2, 20), (3, 30); + +--echo # t1 has changed, and it's does not lead to reprepare +execute stmt; + +alter table t1 add column b varchar(50) default NULL; +execute stmt; +call p_verify_reprepare_count(0); + +alter table t1 drop column b; +execute stmt; +call p_verify_reprepare_count(0); + +--echo # SQLCOM_ANALYZE: + +prepare stmt from "analyze table t1"; +execute stmt; + +drop table t1; +create table t1 (a1 int, a2 int); +insert into t1 values (1, 10), (2, 20), (3, 30); +--echo # t1 has changed, and it's not a problem +execute stmt; + +alter table t1 add column b varchar(50) default NULL; +execute stmt; + +alter table t1 drop column b; +execute stmt; + +call p_verify_reprepare_count(0); + +--echo # SQLCOM_OPTIMIZE: + +prepare stmt from "optimize table t1"; +execute stmt; + +drop table t1; +create table t1 (a1 int, a2 int); +insert into t1 values (1, 10), (2, 20), (3, 30); + +--echo # t1 has changed, and it's not a problem +execute stmt; + +alter table t1 add column b varchar(50) default NULL; +execute stmt; + +alter table t1 drop column b; +execute stmt; +call p_verify_reprepare_count(0); + +drop table t1; + +--echo # SQLCOM_SHOW_CREATE_PROC: + +prepare stmt from "show create procedure p1"; +--error ER_SP_DOES_NOT_EXIST +execute stmt; +--error ER_SP_DOES_NOT_EXIST +execute stmt; + +create procedure p1() begin end; + +--disable_result_log +execute stmt; +execute stmt; +--enable_result_log + +drop procedure p1; +create procedure p1(x int, y int) begin end; + +--disable_result_log +execute stmt; +execute stmt; +--enable_result_log + +drop procedure p1; + +--error ER_SP_DOES_NOT_EXIST +execute stmt; +--error ER_SP_DOES_NOT_EXIST +execute stmt; +call p_verify_reprepare_count(0); + +--echo # SQLCOM_SHOW_CREATE_FUNC: + +prepare stmt from "show create function f1"; +--error ER_SP_DOES_NOT_EXIST +execute stmt; +--error ER_SP_DOES_NOT_EXIST +execute stmt; + +create function f1() returns int return 0; + +--disable_result_log +execute stmt; +execute stmt; +--enable_result_log + +drop function f1; +create function f1(x int, y int) returns int return x+y; + +--disable_result_log +execute stmt; +execute stmt; +--enable_result_log + +drop function f1; + +--error ER_SP_DOES_NOT_EXIST +execute stmt; +--error ER_SP_DOES_NOT_EXIST +execute stmt; +call p_verify_reprepare_count(0); + +--echo # SQLCOM_SHOW_CREATE_TRIGGER: + +create table t1 (a int); + +prepare stmt from "show create trigger t1_bi"; +--error ER_TRG_DOES_NOT_EXIST +execute stmt; +--error ER_TRG_DOES_NOT_EXIST +execute stmt; + +create trigger t1_bi before insert on t1 for each row set @message= "t1_bi"; + +--disable_result_log +execute stmt; +execute stmt; +--enable_result_log + +drop trigger t1_bi; + +create trigger t1_bi before insert on t1 for each row set @message= "t1_bi (2)"; + +--disable_result_log +execute stmt; +execute stmt; +--enable_result_log + +drop trigger t1_bi; + +--error ER_TRG_DOES_NOT_EXIST +execute stmt; +--error ER_TRG_DOES_NOT_EXIST +execute stmt; +call p_verify_reprepare_count(0); + +drop table t1; +deallocate prepare stmt; + +--echo ===================================================================== +--echo Part 24: Testing the strength of TABLE_SHARE version +--echo ===================================================================== + +--echo # Test 24-a: number of columns + +create table t1 (a int); + +prepare stmt from "select a from t1"; +execute stmt; +call p_verify_reprepare_count(0); + +alter table t1 add column b varchar(50) default NULL; + +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +--echo # Test 24-b: column name + +alter table t1 change b c int; +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +--echo # Test 24-c: column type + +alter table t1 change a a varchar(10); + +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +--echo # Test 24-d: column type length + +alter table t1 change a a varchar(20); + +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +--echo # Test 24-e: column NULL property + +alter table t1 change a a varchar(20) NOT NULL; + +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +--echo # Test 24-f: column DEFAULT + +alter table t1 change c c int DEFAULT 20; + +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +--echo # Test 24-g: number of keys +create unique index t1_a_idx on t1 (a); + +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +--echo # Test 24-h: changing index uniqueness + +drop index t1_a_idx on t1; +create index t1_a_idx on t1 (a); + +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +--echo # Cleanup +drop table t1; + +deallocate prepare stmt; + +--echo ===================================================================== +--echo Testing reported bugs +--echo ===================================================================== + +--echo # +--echo # Bug#27420 A combination of PS and view operations cause +--echo # error + assertion on shutdown +--echo # + +--disable_warnings +drop table if exists t_27420_100; +drop table if exists t_27420_101; +drop view if exists v_27420; +--enable_warnings + +create table t_27420_100(a int); +insert into t_27420_100 values (1), (2); + +create table t_27420_101(a int); +insert into t_27420_101 values (1), (2); + +create view v_27420 as select t_27420_100.a X, t_27420_101.a Y + from t_27420_100, t_27420_101 + where t_27420_100.a=t_27420_101.a; + +prepare stmt from "select * from v_27420"; + +execute stmt; +call p_verify_reprepare_count(0); + +drop view v_27420; +create table v_27420(X int, Y int); + +execute stmt; +call p_verify_reprepare_count(1); + +drop table v_27420; +# passes in 5.0, fails in 5.1, should pass +create table v_27420 (a int, b int, filler char(200)); + +execute stmt; +call p_verify_reprepare_count(1); + +drop table t_27420_100; +drop table t_27420_101; +drop table v_27420; +deallocate prepare stmt; + +--echo # +--echo # Bug#27430 Crash in subquery code when in PS and table DDL changed +--echo # after PREPARE +--echo # + +--disable_warnings +drop table if exists t_27430_1; +drop table if exists t_27430_2; +--enable_warnings + +create table t_27430_1 (a int not null, oref int not null, key(a)); +insert into t_27430_1 values + (1, 1), + (1, 1234), + (2, 3), + (2, 1234), + (3, 1234); + +create table t_27430_2 (a int not null, oref int not null); +insert into t_27430_2 values + (1, 1), + (2, 2), + (1234, 3), + (1234, 4); + +prepare stmt from + "select oref, a, a in (select a from t_27430_1 where oref=t_27430_2.oref) Z from t_27430_2"; + +execute stmt; +call p_verify_reprepare_count(0); + +drop table t_27430_1, t_27430_2; + +create table t_27430_1 (a int, oref int, key(a)); +insert into t_27430_1 values + (1, 1), + (1, NULL), + (2, 3), + (2, NULL), + (3, NULL); + +create table t_27430_2 (a int, oref int); +insert into t_27430_2 values + (1, 1), + (2,2), + (NULL, 3), + (NULL, 4); + +execute stmt; +call p_verify_reprepare_count(1); + +drop table t_27430_1; +drop table t_27430_2; +deallocate prepare stmt; + +--echo # +--echo # Bug#27690 Re-execution of prepared statement after table +--echo # was replaced with a view crashes +--echo # + +--disable_warnings +drop table if exists t_27690_1; +drop view if exists v_27690_1; +drop table if exists v_27690_2; +--enable_warnings + +create table t_27690_1 (a int, b int); +insert into t_27690_1 values (1,1),(2,2); + +create table v_27690_1 as select * from t_27690_1; +create table v_27690_2 as select * from t_27690_1; + +prepare stmt from "select * from v_27690_1, v_27690_2"; + +execute stmt; +execute stmt; + +drop table v_27690_1; + +--error ER_NO_SUCH_TABLE +execute stmt; + +--error ER_NO_SUCH_TABLE +execute stmt; +call p_verify_reprepare_count(0); + +create view v_27690_1 as select A.a, A.b from t_27690_1 A, t_27690_1 B; + +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +drop table t_27690_1; +drop view v_27690_1; +drop table v_27690_2; +deallocate prepare stmt; + +--echo #===================================================================== +--echo # +--echo # Bug#21294 Executing a prepared statement that executes +--echo # a stored function which was recreat +--echo # + +create function f1() returns int return 10; + +prepare stmt from "select f1()"; +execute stmt; + +drop function f1; +create function f1() returns int return 10; + +# might pass or fail, implementation dependent +execute stmt; + +drop function f1; +create function f1() returns int return 20; + +execute stmt; +call p_verify_reprepare_count(2); + +drop function f1; +deallocate prepare stmt; + +--echo # +--echo # Bug#12093 SP not found on second PS execution if another thread drops +--echo # other SP in between +--echo # +--disable_warnings +drop table if exists t_12093; +drop function if exists f_12093; +drop function if exists f_12093_unrelated; +drop procedure if exists p_12093; +drop view if exists v_12093_unrelated; +--enable_warnings + +create table t_12093 (a int); +create function f_12093() returns int return (select count(*) from t_12093); +create procedure p_12093(a int) select * from t_12093; + +create function f_12093_unrelated() returns int return 2; +create procedure p_12093_unrelated() begin end; +create view v_12093_unrelated as select * from t_12093; + +connect (con1,localhost,root,,); +connection default; + +let $my_drop = drop function f_12093_unrelated; +--source include/ps_ddl_1.inc +# +let $my_drop = drop procedure p_12093_unrelated; +--source include/ps_ddl_1.inc +# +# A reprepare of stmt_sf and stmt_sp is necessary because there is no +# information about views within the table definition cache. +let $my_drop = drop view v_12093_unrelated; +--source include/ps_ddl_1.inc + +call p_verify_reprepare_count(6); + +disconnect con1; +drop table t_12093; +drop function f_12093; +drop procedure p_12093; +deallocate prepare stmt_sf; +deallocate prepare stmt_sp; + + +--echo ===================================================================== +--echo Ensure that metadata validation is performed for every type of +--echo SQL statement where it is needed. +--echo ===================================================================== + +--echo # +--echo # SQLCOM_SELECT +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "select 1 as res from dual where (1) in (select * from t1)"; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; +call p_verify_reprepare_count(1); + +--echo # +--echo # SQLCOM_CREATE_TABLE +--echo # + +--disable_warnings +drop table if exists t1; +drop table if exists t2; +--enable_warnings +create table t1 (a int); +prepare stmt from 'create table t2 as select * from t1'; +execute stmt; +drop table t2; +execute stmt; +drop table t2; +execute stmt; +call p_verify_reprepare_count(0); +# Base table with name of table to be created exists +--error ER_TABLE_EXISTS_ERROR +execute stmt; +call p_verify_reprepare_count(1); +--error ER_TABLE_EXISTS_ERROR +execute stmt; +call p_verify_reprepare_count(0); +drop table t2; +# Temporary table with name of table to be created exists +create temporary table t2 (a int); +--error ER_TABLE_EXISTS_ERROR +execute stmt; +call p_verify_reprepare_count(1); +--error ER_TABLE_EXISTS_ERROR +execute stmt; +call p_verify_reprepare_count(0); +drop temporary table t2; +execute stmt; +call p_verify_reprepare_count(1); +drop table t2; +execute stmt; +call p_verify_reprepare_count(0); +drop table t2; +# View with name of table to be created exists +# Attention: +# We cannot print the error message because it contains a random filename. +# Example: 1050: Table '<some_path>/var/tmp/#sql_6979_0' already exists +# Therefore we mangle it via +# "--error ER_TABLE_EXISTS_ERROR,9999" (9999 is currently not used) +# to "Got one of the listed errors". +create view t2 as select 1; +--error ER_TABLE_EXISTS_ERROR,9999 +execute stmt; +call p_verify_reprepare_count(1); +--error ER_TABLE_EXISTS_ERROR,9999 +execute stmt; +call p_verify_reprepare_count(0); +drop view t2; +drop table t1; +# Table to be used recreated (drop,create) with different layout +create table t1 (x varchar(20)); +execute stmt; +call p_verify_reprepare_count(1); +select * from t2; +drop table t2; +execute stmt; +call p_verify_reprepare_count(0); +drop table t2; +# Table to be used has a modified (alter table) layout +alter table t1 add column y decimal(10,3); +execute stmt; +call p_verify_reprepare_count(1); +select * from t2; +drop table t2; +execute stmt; +call p_verify_reprepare_count(0); +drop table t1; +deallocate prepare stmt; +--echo # XXX: no validation of the first table in case of +--echo # CREATE TEMPORARY TABLE. This is a shortcoming of the current code, +--echo # but since validation is not strictly necessary, nothing is done +--echo # about it. +--echo # Will be fixed as part of work on Bug#21431 "Incomplete support of +--echo # temporary tables" +create table t1 (a int); +insert into t1 (a) values (1); +prepare stmt from "create temporary table if not exists t2 as select * from t1"; +execute stmt; +drop table t2; +execute stmt; +execute stmt; +select * from t2; +execute stmt; +select * from t2; +drop table t2; +create temporary table t2 (a varchar(10)); +execute stmt; +select * from t2; +call p_verify_reprepare_count(0); +drop table t1; +create table t1 (x int); +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); +drop table t1; +drop temporary table t2; +drop table t2; +deallocate prepare stmt; + +create table t1 (a int); +prepare stmt from "create table t2 like t1"; +execute stmt; +call p_verify_reprepare_count(0); +drop table t2; +execute stmt; +call p_verify_reprepare_count(0); +drop table t2; +# Table to be used does not exist +drop table t1; +--error ER_NO_SUCH_TABLE +execute stmt; +call p_verify_reprepare_count(0); +--error ER_NO_SUCH_TABLE +execute stmt; +call p_verify_reprepare_count(0); +# Table to be used recreated (drop,create) with different layout +create table t1 (x char(17)); +execute stmt; +call p_verify_reprepare_count(1); +drop table t2; +execute stmt; +call p_verify_reprepare_count(0); +drop table t2; +# Table to be used has a modified (alter table) layout +alter table t1 add column y time; +execute stmt; +call p_verify_reprepare_count(1); +select * from t2; +drop table t2; +execute stmt; +call p_verify_reprepare_count(0); +drop table t1; +drop table t2; +deallocate prepare stmt; + + +--echo # +--echo # SQLCOM_UPDATE +--echo # + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +create table t1 (a int); +create table t2 (a int); +prepare stmt from "update t2 set a=a+1 where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1, t2; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_INSERT +--echo # + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +create table t1 (a int); +create table t2 (a int); +prepare stmt from "insert into t2 set a=((1) in (select * from t1))"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; + +drop table t1, t2; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_INSERT_SELECT +--echo # + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +create table t1 (a int); +create table t2 (a int); +prepare stmt from "insert into t2 select * from t1"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1, t2; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_REPLACE +--echo # + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +create table t1 (a int); +create table t2 (a int); +prepare stmt from "replace t2 set a=((1) in (select * from t1))"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1, t2; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_REPLACE_SELECT +--echo # + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +create table t1 (a int); +create table t2 (a int); +prepare stmt from "replace t2 select * from t1"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1, t2; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_DELETE +--echo # + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +create table t1 (a int); +create table t2 (a int); +prepare stmt from "delete from t2 where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1, t2; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_DELETE_MULTI +--echo # + +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +prepare stmt from "delete t2, t3 from t2, t3 where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1, t2, t3; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_UPDATE_MULTI +--echo # + +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +prepare stmt from "update t2, t3 set t3.a=t2.a, t2.a=null where (1) in (select * from t1)"; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1, t2, t3; +deallocate prepare stmt; +--echo # Intermediate results: 8 SQLCOMs tested, 8 automatic reprepares +call p_verify_reprepare_count(8); + +--echo # +--echo # SQLCOM_LOAD +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a varchar(20)); +--error ER_UNSUPPORTED_PS +prepare stmt from "load data infile '../std_data_ln/words.dat' into table t1"; +drop table t1; + +--echo # +--echo # SQLCOM_SHOW_DATABASES +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show databases where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_TABLES +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show tables where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_FIELDS +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show fields from t1 where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_KEYS +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show keys from t1 where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_VARIABLES +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show variables where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_STATUS +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show status where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_ENGINE_STATUS, SQLCOM_SHOW_ENGINE_LOGS, +--echo # SQLCOM_SHOW_ENGINE_MUTEX, SQLCOM_SHOW_PROCESSLIST +--echo # + +--echo # Currently can not have a where clause, need to be covered +--echo # with tests + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +--error ER_PARSE_ERROR +prepare stmt from "show engine all status where (1) in (select * from t1)"; +--error ER_PARSE_ERROR +prepare stmt from "show engine all logs where (1) in (select * from t1)"; +--error ER_PARSE_ERROR +prepare stmt from "show engine all mutex where (1) in (select * from t1)"; +--error ER_PARSE_ERROR +prepare stmt from "show processlist where (1) in (select * from t1)"; +drop table t1; + +--echo # +--echo # SQLCOM_SHOW_CHARSETS +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show charset where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_COLLATIONS +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show collation where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_TABLE_STATUS +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show table status where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_TRIGGERS +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show triggers where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_OPEN_TABLES +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show open tables where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_STATUS_PROC +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show procedure status where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_STATUS_FUNC +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "show function status where (1) in (select * from t1)"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_SHOW_EVENTS +--echo # +--echo # +--echo # Please see this test in ps.test, it requires not_embedded.inc +--echo # + +--echo # +--echo # SQLCOM_SET_OPTION +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "set @a=((1) in (select * from t1))"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_DO +--echo # + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt from "do ((1) in (select * from t1))"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_CALL +--echo # + +--disable_warnings +drop table if exists t1; +drop procedure if exists p1; +--enable_warnings +create procedure p1(a int) begin end; +create table t1 (a int); +prepare stmt from "call p1((1) in (select * from t1))"; +execute stmt; +drop table t1; +create table t1 (x int); +execute stmt; +drop table t1; +drop procedure p1; +deallocate prepare stmt; + +--echo # +--echo # SQLCOM_CREATE_VIEW +--echo # + +--disable_warnings +drop table if exists t1; +drop view if exists v1; +--enable_warnings +create table t1 (a int); +prepare stmt from "create view v1 as select * from t1"; +execute stmt; +drop view v1; +drop table t1; +create table t1 (x int); +execute stmt; +drop view v1; +drop table t1; +deallocate prepare stmt; +--echo # Intermediate result: number of reprepares matches the number +--echo # of tests +call p_verify_reprepare_count(17); + +--echo # +--echo # SQLCOM_ALTER_VIEW +--echo # + +--disable_warnings +drop view if exists v1; +--enable_warnings +create view v1 as select 1; +--error ER_UNSUPPORTED_PS +prepare stmt from "alter view v1 as select 2"; +drop view v1; + +--echo # Cleanup +--echo # +--disable_warnings +drop temporary table if exists t1, t2, t3; +drop table if exists t1, t2, t3, v1, v2; +drop procedure if exists p_verify_reprepare_count; +drop procedure if exists p1; +drop function if exists f1; +drop view if exists v1, v2; +--enable_warnings diff --git a/mysql-test/t/ps_ddl1.test b/mysql-test/t/ps_ddl1.test new file mode 100644 index 00000000000..379ed576b5f --- /dev/null +++ b/mysql-test/t/ps_ddl1.test @@ -0,0 +1,398 @@ +# +# Testing the behavior of 'PREPARE', 'DDL', 'EXECUTE' scenarios +# +# There are several subtests which are probably "superfluous" because a DDL +# statement before the EXECUTE <prepared stmt handle> contained a keyword +# or action (Example: Alter) which causes that all prepared statements using +# the modified object are reprepared before execution. +# Please do not delete these subtests if they disturb. Just disable them by +# if (0) +# { +# <tests to disable> +# }. +# There might be future optimisations of the server which decrease the amount +# of unneeded reprepares or skip unneeded prepare steps and than these subtests +# might become valuable. +# Example: +# Every preceding ALTER TABLE seems to cause a reprepare. +# But if the ALTER only changed the table comment ... +# +# Created: 2008-04-18 mleich +# + +--disable_warnings +drop temporary table if exists t1; +drop table if exists t1, t2; +drop procedure if exists p_verify_reprepare_count; +drop procedure if exists p1; +drop function if exists f1; +drop view if exists t1; +drop schema if exists mysqltest; +--enable_warnings + +delimiter |; +create procedure p_verify_reprepare_count(expected int) +begin + declare old_reprepare_count int default @reprepare_count; + + select variable_value from + information_schema.session_status where + variable_name='com_stmt_reprepare' + into @reprepare_count; + + if old_reprepare_count + expected <> @reprepare_count then + select concat("Expected: ", expected, + ", actual: ", @reprepare_count - old_reprepare_count) + as "ERROR"; + else + select '' as "SUCCESS"; + end if; +end| +delimiter ;| +set @reprepare_count= 0; +flush status; + +--disable_warnings +drop table if exists t1; +--disable_warnings + +--echo # Column added or dropped is not within the list of selected columns +--echo # or table comment has changed. +--echo # A reprepare is probably not needed. +create table t1 (a int, b int); +prepare stmt from "select a from t1"; +execute stmt; +call p_verify_reprepare_count(0); +alter table t1 add column c int; +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); +alter table t1 drop column b; +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); +alter table t1 comment "My best table"; +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); +drop table t1; +deallocate prepare stmt; + +--echo # Selects using the table at various positions, inser,update ... +--echo # + the table disappears +create table t1 (a int); +# Attention: +# "truncate" must have the first position (= executed as last prepared +# statement), because it recreates the table which has leads to reprepare +# (is this really needed) of all statements. +prepare stmt1 from "truncate t1"; +prepare stmt2 from "select 1 as my_column from t1"; +prepare stmt3 from "select 1 as my_column from (select * from t1) as t2"; +prepare stmt4 from +"select 1 as my_column from (select 1) as t2 where exists (select 1 from t1)"; +prepare stmt5 from "select * from (select 1 as b) as t2, t1"; +prepare stmt6 from "select * from t1 union all select 1.5"; +prepare stmt7 from "select 1 as my_column union all select 1 from t1"; +prepare stmt8 from "insert into t1 values(1),(2)"; +prepare stmt9 from "update t1 set a = 3 where a = 2"; +prepare stmt10 from "delete from t1 where a = 1"; +let ps_stmt_count= 10; +--echo # Attention: Result logging is disabled. +# Checks of correct results of statements are not the goal of this test. +let $num= $ps_stmt_count; +while ($num) +{ + --disable_result_log + eval execute stmt$num; + --enable_result_log + dec $num; +} +# There was no reprepare needed, because none of the objects has changed. +call p_verify_reprepare_count(0); +drop table t1; +let $num= $ps_stmt_count; +while ($num) +{ + --error ER_NO_SUCH_TABLE + eval execute stmt$num; + dec $num; +} +# There was no reprepare needed, because the statement is no more applicable. +call p_verify_reprepare_count(0); +let $num= $ps_stmt_count; +while ($num) +{ + eval deallocate prepare stmt$num; + dec $num; +} + +--echo # Selects using the table at various positions, inser,update ... +--echo # + layout change (drop column) which must cause a reprepare +create table t1 (a int, b int); +insert into t1 values(1,1),(2,2),(3,3); +create table t2 like t1; +insert into t1 values(2,2); +prepare stmt1 from "select a,b from t1"; +prepare stmt2 from "select a,b from (select * from t1) as t1"; +prepare stmt3 from "select * from t1 where a = 2 and b = 2"; +prepare stmt4 from "select * from t2 where (a,b) in (select * from t1)"; +prepare stmt5 from "select * from t1 union select * from t2"; +prepare stmt6 from "select * from t1 union all select * from t2"; +prepare stmt7 from "insert into t1 set a = 4, b = 4"; +prepare stmt8 from "insert into t1 select * from t2"; +let ps_stmt_count= 8; +--echo # Attention: Result logging is disabled. +# Checks of correct results of statements are not the goal of this test. +let $num= $ps_stmt_count; +while ($num) +{ + --disable_result_log + eval execute stmt$num; + --enable_result_log + dec $num; +} +call p_verify_reprepare_count(0); +alter table t1 drop column b; +--disable_abort_on_error +let $num= $ps_stmt_count; +while ($num) +{ + eval execute stmt$num; + # A reprepare is needed, because layout change of t1 affects statement. + call p_verify_reprepare_count(1); + dec $num; +} +let $num= $ps_stmt_count; +while ($num) +{ + eval execute stmt$num; + call p_verify_reprepare_count(1); + dec $num; +} +--echo # Why does the INSERT ... SELECT does not get a reprepare or is +--echo # only the counter not incremented? +eval execute stmt8; +call p_verify_reprepare_count(1); +--enable_abort_on_error +alter table t2 add column c int; +--error ER_WRONG_VALUE_COUNT_ON_ROW +eval execute stmt8; +call p_verify_reprepare_count(1); +let $num= $ps_stmt_count; +while ($num) +{ + eval deallocate prepare stmt$num; + dec $num; +} +drop table t1; +drop table t2; + + +--echo # select AVG(<col>) + optimizer uses index meets loss of the index +create table t1 (a int, b int, primary key(b),unique index t1_unq_idx(a)); +# We need an index which is not converted to PRIMARY KEY (becomes in +# case of InnoDB the key used for table clustering). +insert into t1 set a = 0, b = 0; +insert into t1 select a + 1, b + 1 from t1; +insert into t1 select a + 2, b + 2 from t1; +insert into t1 select a + 4, b + 4 from t1; +insert into t1 select a + 8, b + 8 from t1; +# "using index" optimizer strategy is intended +let $possible_keys= + query_get_value(explain select avg(a) from t1, possible_keys, 1); +let $extra= + query_get_value(explain select avg(a) from t1, Extra, 1); +--echo # Optimizer strategy: Possible keys = $possible_keys , Extra = $extra +prepare stmt from "select avg(a) from t1"; +execute stmt; +call p_verify_reprepare_count(0); +execute stmt; +call p_verify_reprepare_count(0); + +alter table t1 drop index t1_unq_idx; +let $possible_keys= + query_get_value(explain select avg(a) from t1, possible_keys, 1); +let $extra= + query_get_value(explain select avg(a) from t1, Extra, 1); +--echo # Optimizer strategy: Possible keys = $possible_keys , Extra = $extra +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + + +--echo # select AVG(<col>) + optimizer uses table scan meets a new index +alter table t1 add unique index t1_unq_idx(a); +let $possible_keys= + query_get_value(explain select avg(a) from t1, possible_keys, 1); +let $extra= + query_get_value(explain select avg(a) from t1, Extra, 1); +--echo # Optimizer strategy: Possible keys = $possible_keys , Extra = $extra +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); + +deallocate prepare stmt; +drop table t1; + + +--echo # table replaced by not updatable view - Insert +create table t1 (a int); +prepare stmt from "insert into t1 values(1)"; +execute stmt; +call p_verify_reprepare_count(0); + +drop table t1; +create view t1 as select 1; +--error ER_NON_INSERTABLE_TABLE +execute stmt; +call p_verify_reprepare_count(1); + +drop view t1; +create table t2 (a int); +create view t1 as select * from t2 with check option; +execute stmt; +call p_verify_reprepare_count(1); +execute stmt; +call p_verify_reprepare_count(0); +select * from t1; + +deallocate prepare stmt; +drop view t1; +drop table t2; + + +--echo ===================================================================== +--echo Some freestyle tests +--echo ===================================================================== + +create temporary table t1 as select 1 as a; +delimiter |; +create procedure p1() +begin + drop temporary table t1; +end| +create function f1() returns int +begin + call p1(); + return 1; +end| +delimiter ;| + +prepare stmt from "select f1() as my_column, a from t1"; +--error ER_CANT_REOPEN_TABLE +execute stmt; +call p_verify_reprepare_count(0); +select * from t1; + +prepare stmt from "select a, f1() as my_column from t1"; +--error ER_CANT_REOPEN_TABLE +execute stmt; +call p_verify_reprepare_count(0); +select * from t1; + +prepare stmt from "select f1() as my_column, count(*) from t1"; +--error ER_CANT_REOPEN_TABLE +execute stmt; +call p_verify_reprepare_count(0); +select * from t1; + +prepare stmt from "select count(*), f1() as my_column from t1"; +--error ER_CANT_REOPEN_TABLE +execute stmt; +call p_verify_reprepare_count(0); +select * from t1; + + +--echo # Execute fails, no drop of temporary table +prepare stmt from "select 1 as my_column from (select 1) as t2 + where exists (select f1() from t1)"; +execute stmt; +call p_verify_reprepare_count(0); +execute stmt; +call p_verify_reprepare_count(0); +select * from t1; + +--echo # Execute drops temporary table +prepare stmt from "select f1()"; +execute stmt; +call p_verify_reprepare_count(0); +--error ER_BAD_TABLE_ERROR +execute stmt; +call p_verify_reprepare_count(0); + +drop function f1; +drop procedure p1; +deallocate prepare stmt; + +--echo # Execute fails, temporary table is not replaced by another +create temporary table t1 as select 1 as a; +delimiter |; +create procedure p1() +begin + drop temporary table t1; + create temporary table t1 as select 'abc' as a; +end| +create function f1() returns int +begin + call p1(); + return 1; +end| +delimiter ;| +prepare stmt from "select count(*), f1() as my_column from t1"; +--error ER_CANT_REOPEN_TABLE +execute stmt; +call p_verify_reprepare_count(0); +select * from t1; +deallocate prepare stmt; + +prepare stmt from "call p1"; +execute stmt; +drop procedure p1; +create schema mysqltest; +delimiter |; +create procedure mysqltest.p1() +begin + drop schema mysqltest; + create schema mysqltest; +end| +delimiter ;| +--error ER_SP_DOES_NOT_EXIST +execute stmt; +call p_verify_reprepare_count(1); +--error ER_SP_DOES_NOT_EXIST +execute stmt; +call p_verify_reprepare_count(0); +deallocate prepare stmt; +drop schema mysqltest; +drop temporary table t1; + + +# Bug#36089 drop temp table in SP called by function, crash +# Note: A non prepared "select 1 from t1 having count(*) = f1();" is sufficient. +if (0) +{ +create temporary table t1 as select 1 as a; +prepare stmt from "select 1 from t1 having count(*) = f1()"; +execute stmt; +call p_verify_reprepare_count(0); +deallocate prepare stmt; +drop temporary table t1; +} + + +--echo # Cleanup +--echo # +--disable_warnings +drop temporary table if exists t1; +drop table if exists t1, t2; +drop procedure if exists p_verify_reprepare_count; +drop procedure if exists p1; +drop function if exists f1; +drop view if exists t1; +drop schema if exists mysqltest; +--enable_warnings diff --git a/mysql-test/t/ps_grant.test b/mysql-test/t/ps_grant.test index 22ac8675328..b25facdb418 100644 --- a/mysql-test/t/ps_grant.test +++ b/mysql-test/t/ps_grant.test @@ -117,15 +117,12 @@ drop database mysqltest; # # grant/revoke + drop user # ---error 1295 prepare stmt3 from ' grant all on test.t1 to drop_user@localhost identified by ''looser'' '; grant all on test.t1 to drop_user@localhost identified by 'looser' ; ---error 1295 prepare stmt3 from ' revoke all privileges on test.t1 from drop_user@localhost '; revoke all privileges on test.t1 from drop_user@localhost ; ---error 1295 prepare stmt3 from ' drop user drop_user@localhost '; drop user drop_user@localhost; diff --git a/mysql-test/t/ps_not_windows.test b/mysql-test/t/ps_not_windows.test new file mode 100644 index 00000000000..0ab08b59f1e --- /dev/null +++ b/mysql-test/t/ps_not_windows.test @@ -0,0 +1,27 @@ +# doesn't work with embedded server +--source include/not_embedded.inc +# Non-windows specific ps tests. +--source include/not_windows.inc +# requires dynamic loading +--source include/have_dynamic_loading.inc + +# +# Bug #20665: All commands supported in Stored Procedures should work in +# Prepared Statements +# + +create procedure proc_1() install plugin my_plug soname '/root/some_plugin.so'; +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +drop procedure proc_1; + +prepare abc from "install plugin my_plug soname '/root/some_plugin.so'"; +--error ER_UDF_NO_PATHS +execute abc; +--error ER_UDF_NO_PATHS +execute abc; +deallocate prepare abc; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index 2dd70f415a1..7841e7274dd 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -12,8 +12,12 @@ flush query cache; # This crashed in some versions reset query cache; flush status; --disable_warnings -drop table if exists t1,t2,t3,t4,t11,t21; +drop table if exists t1,t2,t3,t4,t11,t21,t1_1,t1_2,t9,t9_1,t9_2; drop database if exists mysqltest; + +# Fix possible left overs from other tests +drop table if exists ```a`; +drop view if exists v1; --enable_warnings # @@ -216,7 +220,7 @@ show status like "Qcache_queries_in_cache"; drop table t1; # -# Charset convertion (cp1251_koi8 always present) +# Charset conversion (cp1251_koi8 always present) # create table t1 (a char(1) not null collate koi8r_general_ci); insert into t1 values(_koi8r""); @@ -296,7 +300,7 @@ select * from t1; select * from t1; show status like "Qcache_queries_in_cache"; insert delayed into t1 values (4); ---sleep 5 # Wait for insert delayed to be executed. +--sleep 5 # Wait for insert delayed to be executed. select a from t1; show status like "Qcache_queries_in_cache"; drop table t1; @@ -406,10 +410,10 @@ create table t1(id int auto_increment primary key); insert into t1 values (NULL), (NULL), (NULL); select * from t1 where id=2; alter table t1 rename to t2; --- error 1146 +--error ER_NO_SUCH_TABLE select * from t1 where id=2; drop table t2; --- error 1146 +--error ER_NO_SUCH_TABLE select * from t1 where id=2; # @@ -419,7 +423,7 @@ create table t1 (word char(20) not null); select * from t1; show status like "Qcache_queries_in_cache"; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval load data infile '$MYSQLTEST_VARDIR/std_data_ln/words.dat' into table t1; +eval load data infile '$MYSQLTEST_VARDIR/std_data/words.dat' into table t1; show status like "Qcache_queries_in_cache"; select count(*) from t1; drop table t1; @@ -431,11 +435,14 @@ create table t1 (a int); insert into t1 values (1),(2),(3); show status like "Qcache_queries_in_cache"; select * from t1 into outfile "query_cache.out.file"; ---error 1086 +--error ER_FILE_EXISTS_ERROR select * from t1 into outfile "query_cache.out.file"; select * from t1 limit 1 into dumpfile "query_cache.dump.file"; show status like "Qcache_queries_in_cache"; drop table t1; +let $datadir=`select @@datadir`; +--remove_file $datadir/test/query_cache.dump.file +--remove_file $datadir/test/query_cache.out.file # # test of SQL_SELECT_LIMIT @@ -533,7 +540,7 @@ drop table t1; # If at least one of the above variables has changed, # the cached query can't be reused. In the below test # absolutely the same query is used several times, -# SELECT should fetch different results for every instance. +# SELECT should fetch different results for every instance. # No hits should be produced. # New cache entry should appear for every SELECT. # @@ -550,21 +557,21 @@ show status like "Qcache_queries_in_cache"; # Change collation_connection and run the same query again # set collation_connection=koi8r_bin; -SELECT a,'',''='' FROM t1; +SELECT a,'',''='' FROM t1; show status like "Qcache_hits"; show status like "Qcache_queries_in_cache"; # # Now change character_set_client and run the same query again # set character_set_client=cp1251; -SELECT a,'',''='' FROM t1; +SELECT a,'',''='' FROM t1; show status like "Qcache_hits"; show status like "Qcache_queries_in_cache"; # # And finally change character_set_results and run the same query again # set character_set_results=cp1251; -SELECT a,'',''='' FROM t1; +SELECT a,'',''='' FROM t1; show status like "Qcache_hits"; show status like "Qcache_queries_in_cache"; SET NAMES default; @@ -598,12 +605,12 @@ insert into t1 set c = repeat('x',24); insert into t1 set c = concat(repeat('x',24),'x'); insert into t1 set c = concat(repeat('x',24),'w'); insert into t1 set c = concat(repeat('x',24),'y'); -set max_sort_length=200; +set max_sort_length=200; select c from t1 order by c, id; reset query cache; set max_sort_length=20; select c from t1 order by c, id; -set max_sort_length=200; +set max_sort_length=200; select c from t1 order by c, id; set max_sort_length=default; # sql_mode @@ -774,6 +781,9 @@ drop table t1; create table t1 (a int); insert into t1 values (1),(2); +--disable_warnings +drop procedure if exists p1; +--enable_warnings delimiter //; CREATE PROCEDURE `p1`() begin @@ -794,7 +804,10 @@ create procedure `p1`() begin select a, f1() from t1; end// +SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; +SET GLOBAL log_bin_trust_function_creators = 1; call p1()// +SET GLOBAL log_bin_trust_function_creators = @old_log_bin_trust_function_creators; drop procedure p1// drop function f1// @@ -869,7 +882,7 @@ drop procedure f4; drop table t1; set GLOBAL query_cache_size=0; -# End of 4.1 tests +--echo End of 4.1 tests # # Bug #10303: problem with last_query_cost @@ -911,6 +924,26 @@ start transaction; insert into t1(c1) select c1 from v1; drop table t1, t2, t3; drop view v1; + + +# +# If running with --ps-protocol: +# see if a query from the text protocol is served with results cached +# from a query which used the binary (which would be wrong, results +# are in different formats); if that happens, the results will +# be incorrect and the test will fail. +# + +create table t1(c1 int); +insert into t1 values(1),(10),(100); +select * from t1; +-- disable_ps_protocol +select * from t1; +select * from t1; +-- enable_ps_protocol +select * from t1; +drop table t1; + set global query_cache_size=0; # @@ -969,7 +1002,7 @@ select *, MATCH(a,b) AGAINST("+called +collections" IN BOOLEAN MODE) as x from t # be sure not to cause dead lock if the query cache is flushed # while inserting a query in the query cache. delimiter |; -create function change_global() returns integer +create function change_global() returns integer deterministic begin set global ft_boolean_syntax='+ -><()~*:""&|'; return 1; @@ -987,7 +1020,7 @@ set GLOBAL query_cache_size= default; # -# Bug #28897 UUID() returns non-unique values when query cache is enabled +# Bug#28897 UUID() returns non-unique values when query cache is enabled # set GLOBAL query_cache_size=1000000; @@ -996,7 +1029,7 @@ create table t1 (a char); insert into t1 values ('c'); let $q1= `select UUID(), a from t1`; -let $q2= `select UUID(), a from t1`; +let $q2= `select UUID(), a from t1`; # disabling the logging of the query because the UUIDs are different each run. --disable_query_log @@ -1017,7 +1050,7 @@ create table t1 (a char); insert into t1 values ('c'); let $q1= `select RAND() from t1 union select sql_cache 1 from t1;`; -let $q2= `select RAND() from t1 union select sql_cache 1 from t1;`; +let $q2= `select RAND() from t1 union select sql_cache 1 from t1;`; # disabling the logging of the query because the times are different each run. --disable_query_log @@ -1153,109 +1186,61 @@ DROP TABLE t1; SET GLOBAL query_cache_size= default; # -# Bug #28249 Query Cache returns wrong result with concurrent insert / certain lock -# ---echo Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock -connect (user1,localhost,root,,test,,); -connect (user2,localhost,root,,test,,); -connect (user3,localhost,root,,test,,); - -connection user1; - -set GLOBAL query_cache_type=1; -set GLOBAL query_cache_limit=10000; -set GLOBAL query_cache_min_res_unit=0; -set GLOBAL query_cache_size= 100000; - -flush tables; ---disable_warnings -drop table if exists t1, t2; ---enable_warnings -create table t1 (a int); -create table t2 (a int); -insert into t1 values (1),(2),(3); -connection user2; ---echo Locking table T2 with a write lock. -lock table t2 write; - -connection user1; ---echo Select blocked by write lock. ---send select *, (select count(*) from t2) from t1; ---echo Sleeing is ok, because selecting should be done very fast. -sleep 5; - -connection user3; ---echo Inserting into table T1. -insert into t1 values (4); - -connection user2; ---echo Unlocking the tables. -unlock tables; - -connection user1; ---echo Collecting result from previously blocked select. -# -# Since the lock ordering rule in thr_multi_lock depends on -# pointer values, from execution to execution we might have -# different lock order, and therefore, sometimes lock t1 and block -# on t2, and sometimes block on t2 right away. In the second case, -# the following insert succeeds, and only then this select can -# proceed, and we actually test nothing, as the very first select -# returns 4 rows right away. -# It's fine to have a test case that covers the problematic area -# at least once in a while. -# We, however, need to disable the result log here to make the -# test repeatable. ---disable_result_log ---reap ---enable_result_log ---echo Next select should contain 4 rows, as the insert is long finished. -select *, (select count(*) from t2) from t1; -reset query cache; -select *, (select count(*) from t2) from t1; - -drop table t1,t2; - -connection default; -disconnect user1; -disconnect user2; -disconnect user3; - -# -# Bug #30269 Query cache eats memory -# ---disable_warnings -DROP DATABASE IF EXISTS bug30269; ---enable_warnings -FLUSH STATUS; -CREATE DATABASE bug30269; -USE bug30269; -CREATE TABLE test1 (id int, name varchar(23)); -CREATE VIEW view1 AS SELECT * FROM test1; -INSERT INTO test1 VALUES (5, 'testit'); -GRANT SELECT (id) ON TABLE bug30269.test1 TO 'bug30269'@'localhost'; -GRANT SELECT ON TABLE bug30269.view1 TO 'bug30269'@'localhost'; -set global query_cache_size= 81920; -connect (bug30269, localhost, bug30269,,); -connection bug30269; -USE bug30269; -show status like 'Qcache_queries_in_cache'; ---echo # Select statement not stored in query cache because of column privileges. -SELECT id FROM test1 WHERE id>2; -show status like 'Qcache_queries_in_cache'; -SELECT id FROM view1 WHERE id>2; -show status like 'Qcache_queries_in_cache'; - -connection default; -DROP DATABASE bug30269; -disconnect bug30269; -DROP USER 'bug30269'@'localhost'; +--echo # +--echo # Bug#25132 disabled query cache: Qcache_free_blocks = 1 +--echo # +set global query_cache_size=100000; +set global query_cache_size=0; +set global query_cache_type=0; +show status like 'Qcache_free_blocks'; + +--echo Restore default values. +# Bug#28211 RENAME DATABASE and query cache don't play nicely together +# +# TODO: enable these tests when RENAME DATABASE is implemented. +# --disable_warnings +# drop database if exists db1; +# drop database if exists db2; +# --enable_warnings +# set GLOBAL query_cache_size=15*1024*1024; +# create database db1; +# use db1; +# create table t1(c1 int)engine=myisam; +# insert into t1(c1) values (1); +# select * from db1.t1 f; +# show status like 'Qcache_queries_in_cache'; +# rename schema db1 to db2; +# show status like 'Qcache_queries_in_cache'; +# drop database db2; +# set global query_cache_size=default; +# +# --disable_warnings +# drop database if exists db1; +# drop database if exists db3; +# --enable_warnings +# set GLOBAL query_cache_size=15*1024*1024; +# create database db1; +# create database db3; +# use db1; +# create table t1(c1 int) engine=myisam; +# use db3; +# create table t1(c1 int) engine=myisam; +# use db1; +# insert into t1(c1) values (1); +# use mysql; +# select * from db1.t1; +# select c1+1 from db1.t1; +# select * from db3.t1; +# show status like 'Qcache_queries_in_cache'; +# rename schema db1 to db2; +# show status like 'Qcache_queries_in_cache'; +# drop database db2; +# drop database db3; set GLOBAL query_cache_type=default; set GLOBAL query_cache_limit=default; set GLOBAL query_cache_min_res_unit=default; set GLOBAL query_cache_size=default; -use test; # # Bug#33756 - query cache with concurrent_insert=0 appears broken @@ -1303,4 +1288,23 @@ SHOW STATUS LIKE "Qcache_hits"; DROP TABLE t1; SET GLOBAL query_cache_size= default; -# End of 5.0 tests +--echo End of 5.0 tests + +# +# Bug #31157: Crash when select+order by the avg of some field within the +# group by +# + +CREATE TABLE t1 (a ENUM('rainbow')); +INSERT INTO t1 VALUES (),(),(),(),(); +SELECT 1 FROM t1 GROUP BY (SELECT 1 FROM t1 ORDER BY AVG(LAST_INSERT_ID())); +DROP TABLE t1; +CREATE TABLE t1 (a LONGBLOB); +INSERT INTO t1 SET a = 'aaaa'; +INSERT INTO t1 SET a = 'aaaa'; +SELECT 1 FROM t1 GROUP BY + (SELECT LAST_INSERT_ID() FROM t1 ORDER BY MIN(a) ASC LIMIT 1); +DROP TABLE t1; + +--echo End of 5.1 tests + diff --git a/mysql-test/t/query_cache_28249.test b/mysql-test/t/query_cache_28249.test new file mode 100644 index 00000000000..390a1ce6e3d --- /dev/null +++ b/mysql-test/t/query_cache_28249.test @@ -0,0 +1,124 @@ +### t/query_cache_28249.test ### +# +# Test for +# Bug#28249 Query Cache returns wrong result with concurrent insert / certain lock +# +# Last modification: +# 2008-11-27 mleich - Move this test out of query_cache.test +# - Fix Bug#40179 Test main.query_cache failing randomly on Pushbuild, +# test weakness +# - Minor improvements (comments,formatting etc.) +# + +--source include/have_query_cache.inc +--source include/not_embedded.inc + +SET @query_cache_type= @@global.query_cache_type; +SET @query_cache_limit= @@global.query_cache_limit; +SET @query_cache_min_res_unit= @@global.query_cache_min_res_unit; +SET @query_cache_size= @@global.query_cache_size; + +--echo # Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock +--echo # Establish connections user1,user2,user3 (user=root) +connect (user1,localhost,root,,test,,); +connect (user2,localhost,root,,test,,); +connect (user3,localhost,root,,test,,); + +--echo # Switch to connection user1 +connection user1; + +SET GLOBAL query_cache_type=1; +SET GLOBAL query_cache_limit=10000; +SET GLOBAL query_cache_min_res_unit=0; +SET GLOBAL query_cache_size= 100000; + +FLUSH TABLES; +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); + +--echo # Switch to connection user2 +connection user2; +LOCK TABLE t2 WRITE; + +--echo # Switch to connection user1 +connection user1; +--echo # "send" the next select, "reap" the result later. +--echo # The select will be blocked by the write lock on the t1. +let $select_for_qc = +SELECT *, (SELECT COUNT(*) FROM t2) FROM t1; +send; +eval $select_for_qc; + +--echo # Switch to connection user3 +connection user3; +# Typical information_schema.processlist content after sufficient sleep time +# ID USER COMMAND TIME STATE INFO +# .... +# 2 root Query 5 Locked SELECT *, (SELECT COUNT(*) FROM t2) FROM t1 +# .... +# XXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +# The values marked with 'X' must be reached. +--echo # Poll till the select of connection user1 is blocked by the write lock on t1. +let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist +WHERE state = 'Locked' + AND info = '$select_for_qc'; +--source include/wait_condition.inc +eval +SELECT user,command,state,info FROM information_schema.processlist +WHERE state = 'Locked' + AND info = '$select_for_qc'; +INSERT INTO t1 VALUES (4); + +--echo # Switch to connection user2 +connection user2; +UNLOCK TABLES; + +--echo # Switch to connection user1 +connection user1; +# +# Since the lock ordering rule in thr_multi_lock depends on +# pointer values, from execution to execution we might have +# different lock order, and therefore, sometimes lock t1 and block +# on t2, and sometimes block on t2 right away. In the second case, +# the following insert succeeds, and only then this select can +# proceed, and we actually test nothing, as the very first select +# returns 4 rows right away. +# It's fine to have a test case that covers the problematic area +# at least once in a while. +--echo # Collecting ("reap") the result from the previously blocked select. +--echo # The printing of the result (varies between 3 and 4 rows) set has to be suppressed. +--disable_result_log +--reap +--enable_result_log + +--echo # Switch to connection user3 +connection user3; +--echo # The next select enforces that effects of "concurrent_inserts" like the +--echo # record with a = 4 is missing in result sets can no more happen. +SELECT 1 FROM t1 WHERE a = 4; + +--echo # Switch to connection user1 +connection user1; +--echo # The next result set must contain 4 rows. +# If not, we have a regression of Bug#28249 +eval $select_for_qc; +RESET QUERY CACHE; +eval $select_for_qc; + +DROP TABLE t1,t2; + +--echo # Switch to connection default + close connections user1,user2,user3 +connection default; +disconnect user1; +disconnect user2; +disconnect user3; + +SET GLOBAL query_cache_type= @query_cache_type; +SET GLOBAL query_cache_limit= @query_cache_limit; +SET GLOBAL query_cache_min_res_unit= @query_cache_min_res_unit; +SET GLOBAL query_cache_size= @query_cache_size; + diff --git a/mysql-test/t/query_cache_debug.test b/mysql-test/t/query_cache_debug.test new file mode 100644 index 00000000000..d30cd458e99 --- /dev/null +++ b/mysql-test/t/query_cache_debug.test @@ -0,0 +1,259 @@ +--source include/not_embedded.inc +--source include/have_query_cache.inc +--source include/have_debug.inc + +# +# Bug #30887 Server crashes on SET GLOBAL query_cache_size=0 +# +flush status; +set query_cache_type=DEMAND; +set global query_cache_size= 1024*768; +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a varchar(100)); +insert into t1 values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +connect (bug30887con1, localhost, root, ,test); +connect (bug30887con2, localhost, root, ,test); + +connection bug30887con1; +--echo Activate debug hook and attempt to retrieve the statement from the cache. +set session debug='+d,wait_in_query_cache_insert'; +--send select SQL_CACHE * from t1; + +connection default; +let $wait_condition= select count(*)= 1 from information_schema.processlist where state= 'wait_in_query_cache_insert'; +--source include/wait_condition.inc + +connection bug30887con2; +--echo On a second connection; clear the query cache. +show status like 'Qcache_queries_in_cache'; +set global query_cache_size= 0; + +connection default; +--echo Signal the debug hook to release the lock. +select id from information_schema.processlist where state='wait_in_query_cache_insert' into @thread_id; +kill query @thread_id; + +--echo Show query cache status. +show status like 'Qcache_queries_in_cache'; + +disconnect bug30887con1; +disconnect bug30887con2; +set global query_cache_size= 0; +use test; +drop table t1; + +# +# Bug#41098: Query Cache returns wrong result with concurrent insert +# + +SET @old_concurrent_insert= @@GLOBAL.concurrent_insert; +SET @old_query_cache_size= @@GLOBAL.query_cache_size; + +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); + +SET GLOBAL concurrent_insert= 1; +SET GLOBAL query_cache_size= 1024*512; +SET GLOBAL query_cache_type= ON; + +connect(con1,localhost,root,,test,,); +connect(con2,localhost,root,,test,,); + +connection con1; +--echo # Switch to connection con1 +SET SESSION debug='+d,wait_after_query_cache_invalidate'; +--echo # Send concurrent insert, will wait in the query cache table invalidate +--send INSERT INTO t1 VALUES (4) + +connection default; +--echo # Switch to connection default +--echo # Wait for concurrent insert to reach the debug point +let $wait_condition= + SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST + WHERE STATE = "wait_after_query_cache_invalidate" AND + INFO = "INSERT INTO t1 VALUES (4)"; +--source include/wait_condition.inc + +connection con2; +--echo # Switch to connection con2 +--echo # Send SELECT that shouldn't be cached +SELECT * FROM t1; + +connection default; +--echo # Switch to connection default +--echo # Notify the concurrent insert to proceed +SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST + WHERE STATE = 'wait_after_query_cache_invalidate' INTO @thread_id; +KILL QUERY @thread_id; + +connection con1; +--echo # Switch to connection con1 +--echo # Gather insert result +--reap +SHOW STATUS LIKE "Qcache_queries_in_cache"; +--echo # Test that it's cacheable +SELECT * FROM t1; +SHOW STATUS LIKE "Qcache_queries_in_cache"; + +--echo # Disconnect +disconnect con1; +disconnect con2; + +connection default; +--echo # Restore defaults +RESET QUERY CACHE; +DROP TABLE t1,t2; +SET GLOBAL concurrent_insert= DEFAULT; +SET GLOBAL query_cache_size= DEFAULT; +SET GLOBAL query_cache_type= DEFAULT; + + +--echo # +--echo # Bug43758 Query cache can lock up threads in 'freeing items' state +--echo # +FLUSH STATUS; +SET GLOBAL query_cache_type=DEMAND; +SET GLOBAL query_cache_size= 1024*768; +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3,t4,t5; +--enable_warnings +CREATE TABLE t1 (a VARCHAR(100)); +CREATE TABLE t2 (a VARCHAR(100)); +CREATE TABLE t3 (a VARCHAR(100)); +CREATE TABLE t4 (a VARCHAR(100)); +CREATE TABLE t5 (a VARCHAR(100)); + +INSERT INTO t1 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t2 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t3 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t4 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t5 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); + +connect (thd2, localhost, root, ,test); +connect (thd3, localhost, root, ,test); +connect (thd1, localhost, root, ,test); + +connection thd1; +--echo =================================== Connection thd1 +--echo ** +--echo ** Load Query Cache with a result set and one table. +--echo ** +SELECT SQL_CACHE * FROM t1; +--echo ************************************************************************* +--echo ** We want to accomplish the following state: +--echo ** - Query cache status: TABLE_FLUSH_IN_PROGRESS +--echo ** - THD1: invalidate_table_internal (iterating query blocks) +--echo ** - THD2: query_cache_insert (cond_wait) +--echo ** - THD3: query_cache_insert (cond_wait) +--echo ** - No thread should be holding the structure_guard_mutex. +--echo ** +--echo ** First step is to place a DELETE-statement on the debug hook just +--echo ** before the mutex lock in invalidate_table_internal. +--echo ** This will allow new result sets to be written into the QC. +--echo ** +SET SESSION debug='+d,wait_in_query_cache_invalidate1'; +SET SESSION debug='+d,wait_in_query_cache_invalidate2'; +--send DELETE FROM t1 WHERE a like '%a%'; + +connection default; +--echo =================================== Connection default +--echo ** Assert that the expect process status is obtained. +LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 1 FROM information_schema.processlist WHERE state= 'wait_in_query_cache_invalidate1'; +--source include/wait_condition.inc +-- echo ** + +connection thd2; +--echo =================================== Connection thd2 +--echo ** On THD2: Insert a result into the cache. This attempt will be blocked +--echo ** because of a debug hook placed just before the mutex lock after which +--echo ** the first part of the result set is written. +SET SESSION debug='+d,wait_in_query_cache_insert'; +--send SELECT SQL_CACHE * FROM t2 UNION SELECT * FROM t3 + +connection thd3; +--echo =================================== Connection thd3 +--echo ** On THD3: Insert another result into the cache and block on the same +--echo ** debug hook. +SET SESSION debug='+d,wait_in_query_cache_insert'; +--send SELECT SQL_CACHE * FROM t4 UNION SELECT * FROM t5; + +connection default; +--echo =================================== Connection default +--echo ** Assert that the two SELECT-stmt threads to reach the hook. +LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 2 FROM information_schema.processlist WHERE state='wait_in_query_cache_insert'; +--source include/wait_condition.inc +--echo ** +--echo ** + +--echo ** Signal the DELETE thread, THD1, to continue. It will enter the mutex +--echo ** lock and set query cache status to TABLE_FLUSH_IN_PROGRESS and then +--echo ** unlock the mutex before stopping on the next debug hook. +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate1' LIMIT 1 INTO @flush_thread_id; +KILL QUERY @flush_thread_id; +--echo ** Assert that we reach the next debug hook. +LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 1 FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate2'; +--source include/wait_condition.inc + +--echo ** +--echo ** Signal the remaining debug hooks blocking THD2 and THD3. +--echo ** The threads will grab the guard mutex enter the wait condition and +--echo ** and finally release the mutex. The threads will continue to wait +--echo ** until a broadcast signal reaches them causing both threads to +--echo ** come alive and check the condition. +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id ASC LIMIT 1 INTO @thread_id; +KILL QUERY @thread_id; +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id DESC LIMIT 1 INTO @thread_id; +KILL QUERY @thread_id; + +--echo ** +--echo ** Finally signal the DELETE statement on THD1 one last time. +--echo ** The stmt will complete the query cache invalidation and return +--echo ** cache status to NO_FLUSH_IN_PROGRESS. On the status change +--echo ** One signal will be sent to the thread group waiting for executing +--echo ** invalidations and a broadcast signal will be sent to the thread +--echo ** group holding result set writers. +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate2' LIMIT 1 INTO @flush_thread_id; +KILL QUERY @flush_thread_id; + +--echo ** +--echo ************************************************************************* +--echo ** No tables should be locked +connection thd2; +--echo =================================== Connection thd2 +reap; +DELETE FROM t1; +DELETE FROM t2; +DELETE FROM t3; + +connection thd3; +--echo =================================== Connection thd3 +reap; +DELETE FROM t4; +DELETE FROM t5; + +connection thd1; +--echo =================================== Connection thd1 +reap; + +--echo ** Done. + +connection default; +disconnect thd1; +disconnect thd2; +disconnect thd3; +SET GLOBAL query_cache_size= 0; + +connection default; +--echo # Restore defaults +RESET QUERY CACHE; +FLUSH STATUS; +DROP TABLE t1,t2,t3,t4,t5; +SET GLOBAL query_cache_size= DEFAULT; +SET GLOBAL query_cache_type= DEFAULT; +exit; diff --git a/mysql-test/t/query_cache_merge.test b/mysql-test/t/query_cache_merge.test index b854bfb5d67..4e25bc3ed14 100644 --- a/mysql-test/t/query_cache_merge.test +++ b/mysql-test/t/query_cache_merge.test @@ -25,6 +25,15 @@ while ($1) } --enable_warnings +# +# In order for the test to pass in --ps-protocol, we must +# set table_definition_cache size to at least 258 elements. +# Otherwise table versions are bound to change between +# prepare and execute, and we will get a constant validation +# error. See WL#4165 for details. +# +set @save_table_definition_cache= @@global.table_definition_cache; +set @@global.table_definition_cache=512; create table t00 (a int) engine=MERGE UNION=(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257) INSERT_METHOD=FIRST; enable_query_log; select count(*) from t00; @@ -36,6 +45,7 @@ show status like "Qcache_queries_in_cache"; drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00; SET @@global.query_cache_size=0; +set @@global.table_definition_cache=@save_table_definition_cache; # End of 4.1 tests @@ -43,6 +53,9 @@ SET @@global.query_cache_size=0; # Bug#33362: Query cache invalidation (truncate) may hang if cached query uses many tables # +SET @save_table_definition_cache = @@global.table_definition_cache; +SET @@global.table_definition_cache = 512; + let $c= 255; while ($c) @@ -70,8 +83,6 @@ SHOW STATUS LIKE "Qcache_queries_in_cache"; let $c= 255; let $i= 1; -FLUSH TABLES; - while ($c) { eval TRUNCATE TABLE t$c; @@ -92,5 +103,6 @@ while ($c) } SET @@global.query_cache_size = 0; +SET @@global.table_definition_cache = @save_table_definition_cache; --echo End of 5.1 tests diff --git a/mysql-test/t/query_cache_notembedded.test b/mysql-test/t/query_cache_notembedded.test index 112856117ce..095d47f5bdf 100644 --- a/mysql-test/t/query_cache_notembedded.test +++ b/mysql-test/t/query_cache_notembedded.test @@ -190,6 +190,10 @@ drop table t1; # # Bug#14767 INSERT in SF + concurrent SELECT with query cache # +connection default; +SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; +SET GLOBAL log_bin_trust_function_creators = 1; + reset query cache; --disable_warnings drop function if exists f1; @@ -232,5 +236,43 @@ set GLOBAL query_cache_size=0; # End of 5.0 tests +SET @@global.log_bin_trust_function_creators = @old_log_bin_trust_function_creators; + +# +# Bug #30269 Query cache eats memory +# +--disable_warnings +DROP DATABASE IF EXISTS bug30269; +--enable_warnings +FLUSH STATUS; +CREATE DATABASE bug30269; +USE bug30269; +CREATE TABLE test1 (id int, name varchar(23)); +CREATE VIEW view1 AS SELECT * FROM test1; +INSERT INTO test1 VALUES (5, 'testit'); +GRANT SELECT (id) ON TABLE bug30269.test1 TO 'bug30269'@'localhost'; +GRANT SELECT ON TABLE bug30269.view1 TO 'bug30269'@'localhost'; +set global query_cache_size= 81920; +connect (bug30269, localhost, bug30269,,); +connection bug30269; +USE bug30269; +show status like 'Qcache_queries_in_cache'; +--echo # Select statement not stored in query cache because of column privileges. +SELECT id FROM test1 WHERE id>2; +show status like 'Qcache_queries_in_cache'; +SELECT id FROM view1 WHERE id>2; +show status like 'Qcache_queries_in_cache'; + +connection default; +USE test; +DROP DATABASE bug30269; +disconnect bug30269; +DROP USER 'bug30269'@'localhost'; + +set GLOBAL query_cache_type=default; +set GLOBAL query_cache_limit=default; +set GLOBAL query_cache_min_res_unit=default; +set GLOBAL query_cache_size=default; + # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/query_cache_ps_no_prot.test b/mysql-test/t/query_cache_ps_no_prot.test new file mode 100644 index 00000000000..6f4263eeef9 --- /dev/null +++ b/mysql-test/t/query_cache_ps_no_prot.test @@ -0,0 +1,26 @@ +#################### t/query_cache_ps_no_prot.test ##################### +# +# Test grants with query cache to be run when mysqltest was started +# without any "--<whatever>-protocol". +# +# Last update: +# 2007-05-03 ML - Move t/query_cache_sql_prepare.test to +# include/query_cache_sql_prepare.inc +# - Create this test as non "--<whatever>-protocol" variant. +# + +# We cannot run on embedded server because we use multiple sessions. +--source include/not_embedded.inc + +--source include/have_query_cache.inc + +# The file with expected results fits only to a run without +# ps-protocol/sp-protocol/cursor-protocol/view-protocol. +if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL + + $VIEW_PROTOCOL > 0`) +{ + --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled +} + +# The main testing script +--source include/query_cache_sql_prepare.inc diff --git a/mysql-test/t/query_cache_ps_ps_prot.test b/mysql-test/t/query_cache_ps_ps_prot.test new file mode 100644 index 00000000000..dc49624788a --- /dev/null +++ b/mysql-test/t/query_cache_ps_ps_prot.test @@ -0,0 +1,25 @@ +#################### t/query_cache_ps_ps_prot.test ##################### +# +# Test grants with query cache to be run when mysqltest was started +# without any "--<whatever>-protocol". +# +# Last update: +# 2007-05-03 ML - Move t/query_cache_sql_prepare.test to +# include/query_cache_sql_prepare.inc +# - Create this test as "--ps-protocol" only variant. +# + +# We cannot run on embedded server because we use multiple sessions. +--source include/not_embedded.inc + +--source include/have_query_cache.inc + +# The file with expected results fits only to a run with "--ps-protocol". +if (`SELECT $SP_PROTOCOL + $CURSOR_PROTOCOL + $VIEW_PROTOCOL > 0 + OR $PS_PROTOCOL = 0`) +{ + --skip Test requires: ps-protocol enabled, other protocols disabled +} + +# The main testing script +--source include/query_cache_sql_prepare.inc diff --git a/mysql-test/t/raid.test b/mysql-test/t/raid.test deleted file mode 100644 index 3ca5adaaaea..00000000000 --- a/mysql-test/t/raid.test +++ /dev/null @@ -1,224 +0,0 @@ --- require r/have_raid.require -disable_query_log; -show variables like "have_raid"; -enable_query_log; - -# -# Test of raided tables -# - ---disable_warnings -DROP TABLE IF EXISTS t1,t2; -DROP DATABASE IF EXISTS test_$1; ---enable_warnings - -# -# Test dropping database with raid tables -# - -create database test_$1; -create table test_$1.r1 (i int) raid_type=1; -create table test_$1.r2 (i int) raid_type=1 raid_chunks=32; -drop database test_$1; - -# -# Bug #3182: Test using more than 257 raid chunks -# -create database test_$1; -create table test_$1.r2 (i int) raid_type=1 raid_chunks=257; -show create table test_$1.r2; -drop database test_$1; - -# -# Test that data is spread over different raid directories -# - -CREATE TABLE t1 ( -id int unsigned not null auto_increment primary key, -c char(255) not null -) RAID_TYPE=STRIPED RAID_CHUNKS=2 RAID_CHUNKSIZE=123; -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -select count(*) from t1; -ALTER TABLE t1 ADD COLUMN x INT UNSIGNED NOT NULL; -ALTER TABLE t1 ADD KEY c (c); -ALTER TABLE t1 DROP KEY c; -ALTER TABLE t1 DROP COLUMN x; -ALTER TABLE t1 RENAME t2; -select count(*) from t2; -DROP TABLE t2; - -/* variable rows */ -CREATE TABLE t1 ( -id int unsigned not null auto_increment primary key, -c varchar(255) not null -) RAID_TYPE=STRIPED RAID_CHUNKS=5 RAID_CHUNKSIZE=121; -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -select count(*) from t1; -ALTER TABLE t1 ADD COLUMN x INT UNSIGNED NOT NULL; -ALTER TABLE t1 ADD KEY c (c); -ALTER TABLE t1 DROP KEY c; -ALTER TABLE t1 DROP COLUMN x; -ALTER TABLE t1 RENAME t2; -ALTER TABLE t2 CHANGE COLUMN c c VARCHAR(251) NOT NULL; -select count(*) from t2; -DROP TABLE t2; - -# End of 4.1 tests diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index cdbedb1f848..f0fa99f3d95 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -370,7 +370,7 @@ insert into t2(uid, name) values (25, CHAR(64+25)), (26, CHAR(64+26)); -insert into t1(uid, name) select uid, name from t2; +insert into t1(uid, name) select uid, name from t2 order by uid; delete from t2; insert into t2(id, uid, name) select id, uid, name from t1; @@ -1019,3 +1019,166 @@ SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -128; DROP TABLE t1; # End of 5.0 tests + +# BUG#22393 fix: Adjust 'ref' estimate if we have 'range' estimate for +# a smaller scan interval +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t2 (a int, b int, filler char(100)); +insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A, +t1 B, t1 C where A.a < 5; + +insert into t2 select 1000, b, 'filler' from t2; +alter table t2 add index (a,b); +# t2 values +# ( 1 , 10, 'filler') +# ( 2 , 10, 'filler') +# ( 3 , 10, 'filler') +# (... , 10, 'filler') +# ... +# (1000, 10, 'filler') - 500 times + +# 500 rows, 1 row + +select 'In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)' Z; +explain select * from t2 where a=1000 and b<11; + +drop table t1, t2; + +# +# Bug#42846: wrong result returned for range scan when using covering index +# +CREATE TABLE t1( a INT, b INT, KEY( a, b ) ); + +CREATE TABLE t2( a INT, b INT, KEY( a, b ) ); + +CREATE TABLE t3( a INT, b INT, KEY( a, b ) ); + +INSERT INTO t1( a, b ) +VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7); + +INSERT INTO t2( a, b ) +VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1), + ( 6, 1), ( 7, 1), ( 8, 1), ( 9, 1), (10, 1), + (11, 1), (12, 1), (13, 1), (14, 1), (15, 1), + (16, 1), (17, 1), (18, 1), (19, 1), (20, 1); + +INSERT INTO t2 SELECT a, 2 FROM t2 WHERE b = 1; +INSERT INTO t2 SELECT a, 3 FROM t2 WHERE b = 1; + +# To make range scan compelling to the optimizer +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; +INSERT INTO t2 SELECT -1, -1 FROM t2; + +INSERT INTO t3 +VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), + (6, 0), (7, 0), (8, 0), (9, 0), (10, 0); + +# To make range scan compelling to the optimizer +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; +INSERT INTO t3 SELECT * FROM t3 WHERE a = 10; + + +# +# Problem#1 Test queries. Will give missing results unless Problem#1 is fixed. +# With one exception, they are independent of Problem#2. +# +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; + +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 < a AND b = 3 OR +3 <= a; + +# Query below: Tests both Problem#1 and Problem#2 (EXPLAIN differs as well) +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; + +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a < 5 OR +5 <= a AND b = 3 OR +3 <= a; + +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; + +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +5 <= a AND b = 3 OR +3 <= a; + +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; + +EXPLAIN +SELECT * FROM t1 WHERE +3 <= a AND a <= 5 OR +3 <= a; + +# +# Problem#2 Test queries. +# These queries will give missing results if Problem#1 is fixed. +# But Problem#1 also hides this bug. +# +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; + +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 1 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; + +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; + +EXPLAIN +SELECT * FROM t2 WHERE +5 <= a AND a < 10 AND b = 2 OR +15 <= a AND a < 20 AND b = 3 +OR +1 <= a AND b = 1; + +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; + +EXPLAIN +SELECT * FROM t3 WHERE +5 <= a AND a < 10 AND b = 3 OR +a < 5 OR +a < 10; + +DROP TABLE t1, t2, t3; + +--echo # +--echo # Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN +--echo # + +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES (1), (NULL); +SELECT * FROM t1 WHERE a <> NULL and (a <> NULL or a <= NULL); +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/read_many_rows_innodb.test b/mysql-test/t/read_many_rows_innodb.test new file mode 100644 index 00000000000..ed86275447f --- /dev/null +++ b/mysql-test/t/read_many_rows_innodb.test @@ -0,0 +1,17 @@ +# t/read_many_rows_innodb.test +# +# Check how filesort and buffered-record-reads works with InnoDB. +# This test takes a long time. +# +# Last update: +# 2006-08-03 ML test refactored (MySQL 5.1) +# main code --> include/read_many_rows_innodb.inc +# + +--source include/big_test.inc + +--source include/have_innodb.inc +let $engine_type= InnoDB; +let $other_engine_type= MyISAM; + +--source include/read_many_rows.inc diff --git a/mysql-test/t/read_only.test b/mysql-test/t/read_only.test index fdb68b28fdf..abc016bafce 100644 --- a/mysql-test/t/read_only.test +++ b/mysql-test/t/read_only.test @@ -2,7 +2,9 @@ # check that it blocks updates unless they are only on temporary tables. # should work with embedded server after mysqltest is fixed --- source include/not_embedded.inc +--source include/not_embedded.inc + +set @start_read_only= @@global.read_only; # Save the initial number of concurrent sessions --source include/count_sessions.inc @@ -16,12 +18,15 @@ DROP TABLE IF EXISTS t1,t2,t3; grant CREATE, SELECT, DROP on *.* to test@localhost; +--echo connect (con1,localhost,test,,test); connect (con1,localhost,test,,test); +--echo connection default; connection default; set global read_only=0; +--echo connection con1; connection con1; create table t1 (a int); @@ -30,6 +35,7 @@ insert into t1 values(1); create table t2 select * from t1; +--echo connection default; connection default; set global read_only=1; @@ -39,6 +45,7 @@ set global read_only=1; create table t3 (a int); drop table t3; +--echo connection con1; connection con1; select @@global.read_only; @@ -105,6 +112,136 @@ drop table t1; insert into t1 values(1); # +# Bug#11733 COMMITs should not happen if read-only is set +# + +# LOCK TABLE ... WRITE / READ_ONLY +# - is an error in the same connection +# - is ok in a different connection + +--echo connection default; +connection default; +set global read_only=0; +lock table t1 write; + +--echo connection con1; +connection con1; +lock table t2 write; + +--echo connection default; +connection default; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +set global read_only=1; +unlock tables ; +# The following call blocks until con1 releases the write lock. +# Blocking is expected. +--echo send set global read_only=1; +send set global read_only=1; + +--echo connection con1; +connection con1; +select @@global.read_only; +unlock tables ; +let $wait_condition= SELECT @@global.read_only= 1; +--source include/wait_condition.inc +select @@global.read_only; + +--echo connection default; +connection default; +--echo reap; +reap; + +# LOCK TABLE ... READ / READ_ONLY +# - is an error in the same connection +# - is ok in a different connection + +--echo connection default; +connection default; +set global read_only=0; +lock table t1 read; + +--echo connection con1; +connection con1; +lock table t2 read; + +--echo connection default; +connection default; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +set global read_only=1; +unlock tables ; +# The following call blocks until con1 releases the read lock. +# Blocking is a limitation, and could be improved. +--echo send set global read_only=1; +send set global read_only=1; + +--echo connection con1; +connection con1; +select @@global.read_only; +unlock tables ; +let $wait_condition= SELECT @@global.read_only= 1; +--source include/wait_condition.inc +select @@global.read_only; + +--echo connection default; +connection default; +--echo reap; +reap; + +# pending transaction / READ_ONLY +# - is an error in the same connection +# - is ok in a different connection + +--echo connection default; +connection default; +set global read_only=0; +BEGIN; + +--echo connection con1; +connection con1; +BEGIN; + +--echo connection default; +connection default; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +set global read_only=1; +ROLLBACK; + +set global read_only=1; + +--echo connection con1; +connection con1; +select @@global.read_only; +ROLLBACK; + +# Verify that FLUSH TABLES WITH READ LOCK do not block READ_ONLY +# - in the same SUPER connection +# - in another SUPER connection + +--echo connection default; +connection default; +set global read_only=0; +flush tables with read lock; +set global read_only=1; +unlock tables; + +--echo connect (root2,localhost,root,,test); +connect (root2,localhost,root,,test); + +--echo connection default; +connection default; +set global read_only=0; +flush tables with read lock; + +--echo connection root2; +connection root2; +set global read_only=1; + +--echo connection default; +connection default; +select @@global.read_only; +unlock tables; +disconnect root2; + # Bug#22077 DROP TEMPORARY TABLE fails with wrong error if read_only is set # # check if DROP TEMPORARY on a non-existing temporary table returns the right @@ -116,7 +253,12 @@ drop temporary table ttt; # check if DROP TEMPORARY TABLE IF EXISTS produces a warning with read_only set drop temporary table if exists ttt; +# +# Cleanup +# +--echo connection default; connection default; +set global read_only=0; disconnect con1; drop table t1,t2; drop user test@localhost; @@ -124,6 +266,7 @@ drop user test@localhost; --echo # --echo # Bug#27440 read_only allows create and drop database --echo # +set global read_only= 1; --disable_warnings drop database if exists mysqltest_db1; drop database if exists mysqltest_db2; @@ -139,14 +282,18 @@ grant all on mysqltest_db2.* to `mysqltest_u1`@`%`; create database mysqltest_db1; grant all on mysqltest_db1.* to `mysqltest_u1`@`%`; flush privileges; +--echo connect (con_bug27440,127.0.0.1,mysqltest_u1,,test,MASTER_MYPORT,); connect (con_bug27440,127.0.0.1,mysqltest_u1,,test,$MASTER_MYPORT,); +--echo connection con_bug27440; connection con_bug27440; --error ER_OPTION_PREVENTS_STATEMENT create database mysqltest_db2; show databases like '%mysqltest_db2%'; --error ER_OPTION_PREVENTS_STATEMENT drop database mysqltest_db1; +--echo disconnect con_bug27440; disconnect con_bug27440; +--echo connection default; connection default; delete from mysql.user where User like 'mysqltest_%'; delete from mysql.db where User like 'mysqltest_%'; @@ -154,7 +301,7 @@ delete from mysql.tables_priv where User like 'mysqltest_%'; delete from mysql.columns_priv where User like 'mysqltest_%'; flush privileges; drop database mysqltest_db1; -set global read_only=0; +set global read_only= @start_read_only; # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/read_only_innodb.test b/mysql-test/t/read_only_innodb.test new file mode 100644 index 00000000000..f8c25fdee1d --- /dev/null +++ b/mysql-test/t/read_only_innodb.test @@ -0,0 +1,85 @@ +# should work with embedded server after mysqltest is fixed +-- source include/not_embedded.inc +-- source include/have_innodb.inc + +# +# BUG#11733: COMMITs should not happen if read-only is set +# + +--disable_warnings +DROP TABLE IF EXISTS table_11733 ; +--enable_warnings + +# READ_ONLY does nothing to SUPER users +# so we use a non-SUPER one: + +grant CREATE, SELECT, DROP on *.* to test@localhost; + +connect (con1,localhost,test,,test); + +connection default; +set global read_only=0; + +# Any transactional engine will do +create table table_11733 (a int) engine=InnoDb; + +connection con1; +BEGIN; +insert into table_11733 values(11733); + +connection default; +set global read_only=1; + +connection con1; +select @@global.read_only; +select * from table_11733 ; +-- error ER_OPTION_PREVENTS_STATEMENT +COMMIT; + +connection default; +set global read_only=0; +drop table table_11733 ; +drop user test@localhost; + +disconnect con1; + +# +# Bug #35732: read-only blocks SELECT statements in InnoDB +# +# Test 1: read only mode +GRANT CREATE, SELECT, DROP ON *.* TO test@localhost; +connect(con1, localhost, test, , test); + +connection default; +CREATE TABLE t1(a INT) ENGINE=INNODB; +INSERT INTO t1 VALUES (0), (1); +SET GLOBAL read_only=1; + +connection con1; +SELECT * FROM t1; +BEGIN; +SELECT * FROM t1; +COMMIT; + +connection default; +SET GLOBAL read_only=0; + +# +# Test 2: global read lock +# +FLUSH TABLES WITH READ LOCK; + +connection con1; +SELECT * FROM t1; +BEGIN; +SELECT * FROM t1; +COMMIT; + +connection default; +UNLOCK TABLES; +DROP TABLE t1; +DROP USER test@localhost; + +disconnect con1; + +--echo echo End of 5.1 tests diff --git a/mysql-test/t/rename.test b/mysql-test/t/rename.test index fce37d8466d..5aa1a51a90f 100644 --- a/mysql-test/t/rename.test +++ b/mysql-test/t/rename.test @@ -2,6 +2,8 @@ # Test of rename table # +--source include/count_sessions.inc + --disable_warnings drop table if exists t0,t1,t2,t3,t4; # Clear up from other tests (to ensure that SHOW TABLES below is right) @@ -19,16 +21,16 @@ rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1; select * from t1; # The following should give errors ---error 1050,1050 +--error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR rename table t1 to t2; ---error 1050,1050 +--error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR rename table t1 to t1; ---error 1050,1050 +--error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR rename table t3 to t4, t2 to t3, t1 to t2, t4 to t2; show tables like "t_"; ---error 1050,1050 +--error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR rename table t3 to t1, t2 to t3, t1 to t2, t4 to t1; ---error 1017,1017 +--error ER_FILE_NOT_FOUND,ER_FILE_NOT_FOUND rename table t3 to t4, t5 to t3, t1 to t2, t4 to t1; select * from t1; @@ -63,7 +65,7 @@ connection con2; # Wait for the the tables to be renamed # i.e the query below succeds let $query= select * from t2, t4; -source include/wait_for_query_to_suceed.inc; +source include/wait_for_query_to_succeed.inc; show tables; @@ -83,13 +85,15 @@ connection default; create table t1(f1 int); create view v1 as select * from t1; alter table v1 rename to v2; ---error 1146 +--error ER_NO_SUCH_TABLE alter table v1 rename to v2; rename table v2 to v1; ---error 1050 +--error ER_TABLE_EXISTS_ERROR rename table v2 to v1; drop view v1; drop table t1; - --echo End of 5.0 tests + +--source include/wait_until_count_sessions.inc + diff --git a/mysql-test/t/renamedb.test b/mysql-test/t/renamedb.test new file mode 100644 index 00000000000..84315090b7a --- /dev/null +++ b/mysql-test/t/renamedb.test @@ -0,0 +1,53 @@ + +# TODO: enable these tests when RENAME DATABASE is implemented. +# +# --disable_warnings +# drop database if exists testdb1; +# --enable_warnings +# +# create database testdb1 default character set latin2; +# use testdb1; +# create table t1 (a int); +# insert into t1 values (1),(2),(3); +# show create database testdb1; +# show tables; +# rename database testdb1 to testdb2; +# --error 1049 +# show create database testdb1; +# show create database testdb2; +# select database(); +# show tables; +# select a from t1 order by a; +# drop database testdb2; +# +# +# Bug#19392 Rename Database: Crash if case change +# +# create database testdb1; +# --error 1007 +# rename database testdb1 to testdb1; +# drop database testdb1; + +# +# WL#4030 (Deprecate RENAME DATABASE: replace with ALTER DATABASE <name> UPGRADE) +# + +--error ER_PARSE_ERROR +rename database testdb1 to testdb2; + +--error ER_WRONG_USAGE +ALTER DATABASE wrong UPGRADE DATA DIRECTORY NAME; + +--error ER_WRONG_USAGE +ALTER DATABASE `#mysql41#not-supported` UPGRADE DATA DIRECTORY NAME; + +--error ER_WRONG_USAGE +ALTER DATABASE `#mysql51#not-yet` UPGRADE DATA DIRECTORY NAME; + +--error ER_WRONG_USAGE +ALTER DATABASE `#mysql50#` UPGRADE DATA DIRECTORY NAME; + +--error ER_BAD_DB_ERROR +ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME; + + diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test index 4af0895827c..eb2ca7992a6 100644 --- a/mysql-test/t/repair.test +++ b/mysql-test/t/repair.test @@ -29,7 +29,8 @@ repair table t1 use_frm; create table t1 engine=myisam SELECT 1,"table 1"; flush tables; -system echo 1 > $MYSQLTEST_VARDIR/master-data/test/t1.MYI ; +let $MYSQLD_DATADIR= `select @@datadir`; +system echo 1 > $MYSQLD_DATADIR/test/t1.MYI ; repair table t1; repair table t1 use_frm; drop table t1; @@ -119,9 +120,10 @@ DROP TABLE t1; # --echo # Test with a saved table from 4.1 ---copy_file std_data/bug36055.frm $MYSQLTEST_VARDIR/master-data/test/t1.frm ---copy_file std_data/bug36055.MYD $MYSQLTEST_VARDIR/master-data/test/t1.MYD ---copy_file std_data/bug36055.MYI $MYSQLTEST_VARDIR/master-data/test/t1.MYI +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file std_data/bug36055.frm $MYSQLD_DATADIR/test/t1.frm +--copy_file std_data/bug36055.MYD $MYSQLD_DATADIR/test/t1.MYD +--copy_file std_data/bug36055.MYI $MYSQLD_DATADIR/test/t1.MYI --replace_column 12 # 13 # SHOW TABLE STATUS LIKE 't1'; @@ -143,3 +145,16 @@ REPAIR TABLE t1 USE_FRM; SELECT * FROM t1; DROP TABLE t1; +# End of 5.0 tests + +# +# Bug#18775 - Temporary table from alter table visible to other threads +# +# REPAIR TABLE ... USE_FRM on temporary table crashed the table or server. +--disable_warnings +DROP TABLE IF EXISTS tt1; +--enable_warnings +CREATE TEMPORARY TABLE tt1 (c1 INT); +REPAIR TABLE tt1 USE_FRM; +DROP TABLE tt1; + diff --git a/mysql-test/t/replace.test b/mysql-test/t/replace.test index 269854fb180..ff910bdf5cf 100644 --- a/mysql-test/t/replace.test +++ b/mysql-test/t/replace.test @@ -25,9 +25,9 @@ drop table t1; create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value"); insert into t1 values (126,"first"),(63, "middle"),(0,"last"); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values (0,"error"); ---error 1062 +--error ER_DUP_ENTRY replace into t1 values (0,"error"); replace into t1 values (126,"first updated"); replace into t1 values (63,default); diff --git a/mysql-test/t/rowid_order_bdb.test b/mysql-test/t/rowid_order_bdb.test deleted file mode 100644 index ef133054c35..00000000000 --- a/mysql-test/t/rowid_order_bdb.test +++ /dev/null @@ -1,108 +0,0 @@ -# -# 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; - diff --git a/mysql-test/t/rowid_order_innodb.test b/mysql-test/t/rowid_order_innodb.test index fb4959d78e6..152eb28d388 100644 --- a/mysql-test/t/rowid_order_innodb.test +++ b/mysql-test/t/rowid_order_innodb.test @@ -1,108 +1,14 @@ +# t/rowid_order_innodb.test # # 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_innodb.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=innodb; -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=innodb; -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=innodb 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=innodb; -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=innodb; -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; +# Last update: +# 2006-07-28 ML test refactored (MySQL 5.1) +# main code t/rowid_order_innodb.test -> include/rowid_order.inc +# -drop table t1; +--source include/have_innodb.inc +let $engine_type= InnoDB; +--source include/rowid_order.inc diff --git a/mysql-test/t/rpl000001-slave.opt b/mysql-test/t/rpl000001-slave.opt deleted file mode 100644 index 627becdbfb5..00000000000 --- a/mysql-test/t/rpl000001-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb diff --git a/mysql-test/t/rpl000001.test b/mysql-test/t/rpl000001.test deleted file mode 100644 index 0472fdf13a1..00000000000 --- a/mysql-test/t/rpl000001.test +++ /dev/null @@ -1,131 +0,0 @@ -source include/master-slave.inc; - -create table t1 (word char(20) not null); -load data infile '../std_data_ln/words.dat' into table t1; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1; -select * from t1 limit 10; - -# -# Test slave with wrong password -# -save_master_pos; -connection slave; -sync_with_master; -stop slave; -connection master; -set password for root@"localhost" = password('foo'); -connection slave; -start slave; -connection master; -# -# Give slave time to do at last one failed connect retry -# This one must be short so that the slave will not stop retrying -real_sleep 2; -set password for root@"localhost" = password(''); -# Give slave time to connect (will retry every second) -sleep 2; - -create table t3(n int); -insert into t3 values(1),(2); -save_master_pos; -connection slave; -sync_with_master; -select * from t3; -select sum(length(word)) from t1; -connection master; -drop table t1,t3; -save_master_pos; -connection slave; -sync_with_master; - -# Test if the slave SQL thread can be more than 16K behind the slave -# I/O thread (> IO_SIZE) - -connection master; -# we'll use table-level locking to delay slave SQL thread -create table t1 (n int) engine=myisam; -sync_slave_with_master; -connection master; -reset master; -connection slave; -stop slave; -reset slave; - -connection master; -let $1=5000; -# Generate 16K of relay log -disable_query_log; -while ($1) -{ - eval insert into t1 values($1); - dec $1; -} -enable_query_log; - -# Try to cause a large relay log lag on the slave by locking t1 -connection slave; -lock tables t1 read; -start slave; -#hope this is long enough for I/O thread to fetch over 16K relay log data -sleep 3; -unlock tables; - -#test handling of aborted connection in the middle of update - -connection master; -create table t2(id int); -insert into t2 values(connection_id()); -save_master_pos; - -connection master1; -# Avoid generating result -create temporary table t3(n int); -insert into t3 select get_lock('crash_lock%20C', 1) from t2; - -connection master; -send update t1 set n = n + get_lock('crash_lock%20C', 2); -connection master1; -sleep 3; -select (@id := id) - id from t2; -kill @id; -# We don't drop t3 as this is a temporary table -drop table t2; -connection master; ---error 1317,2013 -reap; -connection slave; -# The SQL slave thread should now have stopped because the query was killed on -# the master (so it has a non-zero error code in the binlog). -wait_for_slave_to_stop; - -# The following test can't be done because the result of Pos will differ -# on different computers -# --replace_result $MASTER_MYPORT MASTER_PORT -# show slave status; - -set global sql_slave_skip_counter=1; -start slave; -select count(*) from t1; -connection master1; -drop table t1; -create table t1 (n int); -insert into t1 values(3456); -insert into mysql.user (Host, User, Password) - VALUES ("10.10.10.%", "blafasel2", password("blafasel2")); -select select_priv,user from mysql.user where user = _binary'blafasel2'; -update mysql.user set Select_priv = "Y" where User= _binary"blafasel2"; -select select_priv,user from mysql.user where user = _binary'blafasel2'; -save_master_pos; -connection slave; -sync_with_master; -select n from t1; -select select_priv,user from mysql.user where user = _binary'blafasel2'; -connection master1; -drop table t1; -delete from mysql.user where user="blafasel2"; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000002.test b/mysql-test/t/rpl000002.test deleted file mode 100644 index bafd8a30159..00000000000 --- a/mysql-test/t/rpl000002.test +++ /dev/null @@ -1,41 +0,0 @@ -source include/master-slave.inc; - -# Test replication of auto_increment - -create table t1 (n int auto_increment primary key); -set insert_id = 2000; -insert into t1 values (NULL),(NULL),(NULL); -sync_slave_with_master; -select * from t1; -connection master; ---replace_result $SLAVE_MYPORT 9999 -show slave hosts; -drop table t1; -sync_slave_with_master; -stop slave; -connection master; - -# Test replication of timestamp - -create table t2(id int auto_increment primary key, created datetime); -set timestamp=12345; -insert into t2 set created=now(); -select * from t2; - -# Test replication of CREATE .. LIKE (Bug #2557) - -create table t3 like t2; -create temporary table t4 like t2; -create table t5 select * from t4; -save_master_pos; -connection slave; -start slave; -sync_with_master; -select * from t2; -show create table t3; -show create table t5; -connection master; -drop table t2,t3,t5; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000004.test b/mysql-test/t/rpl000004.test deleted file mode 100644 index 9c8c535c67d..00000000000 --- a/mysql-test/t/rpl000004.test +++ /dev/null @@ -1,25 +0,0 @@ -source include/master-slave.inc; - -set SQL_LOG_BIN=0; -create table t1 (word char(20) not null, index(word)); -load data infile '../std_data_ln/words.dat' into table t1; -create table t2 (word char(20) not null); -load data infile '../std_data_ln/words.dat' into table t2; -create table t3 (word char(20) not null primary key); -connection slave; -load table t1 from master; -load table t2 from master; -load table t3 from master; -check table t1; -select count(*) from t2; -select count(*) from t3; -connection master; -set SQL_LOG_BIN=1; -drop table if exists t1,t2,t3; -save_master_pos; -connection slave; -sync_with_master; -create table t1(n int); -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000005.test b/mysql-test/t/rpl000005.test deleted file mode 100644 index e81ad739402..00000000000 --- a/mysql-test/t/rpl000005.test +++ /dev/null @@ -1,24 +0,0 @@ -source include/master-slave.inc; - -# -# Bug#7100 relay_log_space_max missing from SHOW VARIABLES -# -SHOW VARIABLES LIKE 'relay_log_space_limit'; - -CREATE TABLE t1 (name varchar(64), age smallint(3)); -INSERT INTO t1 SET name='Andy', age=31; -INSERT t1 SET name='Jacob', age=2; -INSERT into t1 SET name='Caleb', age=1; -ALTER TABLE t1 ADD id int(8) ZEROFILL AUTO_INCREMENT PRIMARY KEY; -select * from t1; -save_master_pos; -connection slave; -sync_with_master; -select * from t1; -connection master; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000006.test b/mysql-test/t/rpl000006.test deleted file mode 100644 index 334ed575835..00000000000 --- a/mysql-test/t/rpl000006.test +++ /dev/null @@ -1,47 +0,0 @@ -# -# Test forced timestamp -# -source include/master-slave.inc; - -# Don't log table creating to the slave as we want to test LOAD TABLE -set SQL_LOG_BIN=0,timestamp=200006; -create table t1(t timestamp not null,a char(1)); -insert into t1 ( a) values ('F'); -select unix_timestamp(t) from t1; -connection slave; -load table t1 from master; -select unix_timestamp(t) from t1; - -# Delete the created table on master and slave -connection master; -set SQL_LOG_BIN=1,timestamp=default; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; -connection master; - -# -# Test copying table with checksum -# - -# Don't log table creating to the slave as we want to test LOAD TABLE -set SQL_LOG_BIN=0; - -CREATE TABLE t1 ( - a int not null -) ENGINE=MyISAM MAX_ROWS=4000 CHECKSUM=1; -INSERT INTO t1 VALUES (1); -save_master_pos; -connection slave; -sync_with_master; -load table t1 from master; -check table t1; -drop table t1; -connection master; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000008-slave.opt b/mysql-test/t/rpl000008-slave.opt deleted file mode 100644 index 177f89e0910..00000000000 --- a/mysql-test/t/rpl000008-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-ignore-table=test.mysqltest_foo diff --git a/mysql-test/t/rpl000008.test b/mysql-test/t/rpl000008.test deleted file mode 100644 index fe030f90411..00000000000 --- a/mysql-test/t/rpl000008.test +++ /dev/null @@ -1,38 +0,0 @@ -# This one assumes we are ignoring updates on table mysqltest_foo, but doing -# the ones on all other tables - -source include/master-slave.inc; -connection slave; - -# -# For this test we must be in the test database -# -use test; - ---disable_warnings -drop table if exists mysqltest_foo; -drop table if exists mysqltest_bar; ---enable_warnings - -create table mysqltest_foo (n int); -insert into mysqltest_foo values(4); -connection master; -use test; -create table mysqltest_foo (n int); -insert into mysqltest_foo values(5); -create table mysqltest_bar (m int); -insert into mysqltest_bar values(15); -create table t1 (k int); -insert into t1 values(55); -save_master_pos; -connection slave; -sync_with_master; -select mysqltest_foo.n,mysqltest_bar.m,t1.k from mysqltest_foo,mysqltest_bar,t1; -connection master; -drop table mysqltest_foo,mysqltest_bar,t1; -save_master_pos; -connection slave; -sync_with_master; -drop table mysqltest_foo,mysqltest_bar,t1; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000009-slave.opt b/mysql-test/t/rpl000009-slave.opt deleted file mode 100644 index c015c02ba78..00000000000 --- a/mysql-test/t/rpl000009-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-wild-do-table=mysqltest.% diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl000009.test deleted file mode 100644 index 161e01ad293..00000000000 --- a/mysql-test/t/rpl000009.test +++ /dev/null @@ -1,174 +0,0 @@ -# This one assumes we are ignoring updates on tables in database mysqltest2, -# but doing the ones in database mysqltest - -source include/master-slave.inc; ---disable_warnings -drop database if exists mysqltest; -drop database if exists mysqltest2; -drop database if exists mysqltest3; -connection slave; -drop database if exists mysqltest; -drop database if exists mysqltest2; -drop database if exists mysqltest3; -connection master; -create database mysqltest2; -create database mysqltest; ---enable_warnings - -save_master_pos; -connection slave; -sync_with_master; -create database mysqltest2; -create table mysqltest2.foo (n int); -insert into mysqltest2.foo values(4); -connection master; -create table mysqltest2.foo (n int); -insert into mysqltest2.foo values(5); -create table mysqltest.bar (m int); -insert into mysqltest.bar values(15); -save_master_pos; -connection slave; -sync_with_master; -select mysqltest2.foo.n,mysqltest.bar.m from mysqltest2.foo,mysqltest.bar; -connection master; -drop database mysqltest; -drop database if exists mysqltest2; -save_master_pos; -connection slave; -sync_with_master; ---error 1008 -drop database mysqltest; -drop database mysqltest2; - -# Now let's test load data from master - -# First create some databases and tables on the master - -connection master; -set sql_log_bin = 0; -create database mysqltest2; -create database mysqltest; -show databases; -create table mysqltest2.t1(n int, s char(20)); -create table mysqltest2.t2(n int, s text); -insert into mysqltest2.t1 values (1, 'one'), (2, 'two'), (3, 'three'); -insert into mysqltest2.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen'); - -create table mysqltest.t1(n int, s char(20)); -create table mysqltest.t2(n int, s text); -insert into mysqltest.t1 values (1, 'one test'), (2, 'two test'), (3, 'three test'); -insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'), - (13, 'thirteen test'); -set sql_log_bin = 1; -save_master_pos; -connection slave; -sync_with_master; - -# This should show that the slave is empty at this point -show databases; -# Create mysqltest2 and mysqltest3 on slave; we expect that LOAD DATA FROM -# MASTER will neither touch database mysqltest nor mysqltest3 -create database mysqltest2; -create table mysqltest2.t1(n int, s char(20)); -insert into mysqltest2.t1 values (1, 'original foo.t1'); -create table mysqltest2.t3(n int, s char(20)); -insert into mysqltest2.t3 values (1, 'original foo.t3'); -create database mysqltest3; -create table mysqltest3.t1(n int, s char(20)); -insert into mysqltest3.t1 values (1, 'original foo2.t1'); - -# Create mysqltest, and mysqltest.t1, to check that it gets replaced, -# and mysqltest.t3 to check that it is not touched (there is no -# mysqltest.t3 on master) -create database mysqltest; -create table mysqltest.t1(n int, s char(20)); -insert into mysqltest.t1 values (1, 'original bar.t1'); -create table mysqltest.t3(n int, s char(20)); -insert into mysqltest.t3 values (1, 'original bar.t3'); - -load data from master; - -# Now let's check if we have the right tables and the right data in them -show databases; -use mysqltest2; - -# LOAD DATA FROM MASTER uses only replicate_*_db rules to decide which -# databases have to be copied. So it thinks "mysqltest" has to be -# copied. Before 4.0.16 it would first drop "mysqltest", then create -# "mysqltest". This "drop" is a bug; in that case t3 would disappear. So -# here the effect of this bug (BUG#1248) would be to leave an empty -# "mysqltest" on the slave. - -show tables; # should be t1 & t3 -select * from t1; # should be slave's original -use mysqltest3; -show tables; # should be t1 -select * from t1; # should be slave's original -use mysqltest; -show tables; # should contain master's copied t1&t2, slave's original t3 -select * from mysqltest.t1; -select * from mysqltest.t2; -select * from mysqltest.t3; - -# Now let's see if replication works -connection master; -insert into mysqltest.t1 values (4, 'four test'); -save_master_pos; -connection slave; -sync_with_master; -select * from mysqltest.t1; - -# Check that LOAD DATA FROM MASTER is able to create master.info -# if needed (if RESET SLAVE was used before), before writing to it (BUG#2922). - -stop slave; -reset slave; -load data from master; -start slave; -# see if replication coordinates were restored fine -connection master; -insert into mysqltest.t1 values (5, 'five bar'); -save_master_pos; -connection slave; -sync_with_master; -select * from mysqltest.t1; - -# Check that LOAD DATA FROM MASTER reports the error if it can't drop a -# table to be overwritten. -# DISABLED FOR NOW AS chmod IS NOT PORTABLE ON NON-UNIX -# insert into mysqltest.t1 values(10, 'should be there'); -# flush tables; -# system chmod 500 $MYSQLTEST_VARDIR/slave-data/mysqltest/; -# --error 6 -# load data from master; # should fail (errno 13) -# system chmod 700 $MYSQLTEST_VARDIR/slave-data/mysqltest/; -# select * from mysqltest.t1; # should contain the row (10, ...) - - -# Check that LOAD TABLE FROM MASTER fails if the table exists on slave ---error 1050 -load table mysqltest.t1 from master; -drop table mysqltest.t1; -load table mysqltest.t1 from master; - -# Check what happens when requestion not existing table -# ---error 1188 -load table bar.t1 from master; - -# as LOAD DATA FROM MASTER failed it did not restart slave threads -# DISABLED FOR NOW -# start slave; - -# Now time for cleanup -connection master; -drop database mysqltest; -drop database mysqltest2; -save_master_pos; -connection slave; -sync_with_master; -# These have to be dropped on slave because they are not replicated -drop database mysqltest2; -drop database mysqltest3; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000010-slave.opt b/mysql-test/t/rpl000010-slave.opt deleted file mode 100644 index 0dbfb311e33..00000000000 --- a/mysql-test/t/rpl000010-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---disconnect-slave-event-count=2 diff --git a/mysql-test/t/rpl000010.test b/mysql-test/t/rpl000010.test deleted file mode 100644 index 261b9148774..00000000000 --- a/mysql-test/t/rpl000010.test +++ /dev/null @@ -1,19 +0,0 @@ -# This tests the offset off by 22 mystery bug -# Must run slave with --disconnect-slave-event-count=1 --master-connect-retry=1 - -source include/master-slave.inc; - -create table t1 (n int not null auto_increment primary key); -insert into t1 values(NULL); -insert into t1 values(2); -save_master_pos; -connection slave; -sync_with_master; -select n from t1; -connection master; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000011.test b/mysql-test/t/rpl000011.test deleted file mode 100644 index 32f6227f7c5..00000000000 --- a/mysql-test/t/rpl000011.test +++ /dev/null @@ -1,17 +0,0 @@ -source include/master-slave.inc; - -create table t1 (n int); -insert into t1 values(1); -sync_slave_with_master; -stop slave; -start slave; -connection master; -insert into t1 values(2); -#let slave catch up -sync_slave_with_master; -select * from t1; -connection master; -drop table t1; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000012.test b/mysql-test/t/rpl000012.test deleted file mode 100644 index 2c1c65e4202..00000000000 --- a/mysql-test/t/rpl000012.test +++ /dev/null @@ -1,45 +0,0 @@ -source include/master-slave.inc; -connection master; - -create table t2 (n int); -create temporary table t1 (n int); -insert into t1 values(1),(2),(3); -insert into t2 select * from t1; -create temporary table t3 (n int not null); -alter table t3 add primary key(n); -flush logs; -insert into t3 values (100); -insert into t2 select * from t3; -drop table if exists t3; -insert into t2 values (101); -connection master1; -create temporary table t1 (n int); -insert into t1 values (4),(5); -insert into t2 select * from t1; -save_master_pos; -disconnect master; -connection slave; - -#add 1 to the saved position, so we will catch drop table on disconnect -#for sure -sync_with_master 1; -connection master1; -insert into t2 values(6); -save_master_pos; -disconnect master1; -connection slave; -#same trick - make sure we catch drop of temporary table on disconnect -sync_with_master 1; -select * from t2; -show status like 'Slave_open_temp_tables'; -# -# Clean up -# -connect (master2,localhost,root,,); -connection master2; -drop table if exists t1,t2; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000013-slave.opt b/mysql-test/t/rpl000013-slave.opt deleted file mode 100644 index 2662c695b41..00000000000 --- a/mysql-test/t/rpl000013-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---abort-slave-event-count=1 diff --git a/mysql-test/t/rpl000013.test b/mysql-test/t/rpl000013.test deleted file mode 100644 index eca4803c6bc..00000000000 --- a/mysql-test/t/rpl000013.test +++ /dev/null @@ -1,43 +0,0 @@ -source include/master-slave.inc; -save_master_pos; -connection slave; -sync_with_master; -connection master; - -create table t2(n int); -create temporary table t1 (n int); -insert into t1 values(1),(2),(3); -insert into t2 select * from t1; -connection master1; -create temporary table t1 (n int); -insert into t1 values (4),(5); -insert into t2 select * from t1 as t10; -save_master_pos; -disconnect master; -connection slave; -#add 1 to catch drop table -sync_with_master 1; -connection master1; -insert into t2 values(6); -save_master_pos; -disconnect master1; -connection slave; -# same trick to go one more event -sync_with_master 1; -select * from t2; -show status like 'Slave_open_temp_tables'; -# -# Clean up -# -connect (master2,localhost,root,,); -connection master2; - -# We will get a warning for t1 as this is a temporary table that doesn't -# exist in this connection. - -drop table if exists t1,t2; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000015-slave.sh b/mysql-test/t/rpl000015-slave.sh deleted file mode 100755 index 7deeca3d2d6..00000000000 --- a/mysql-test/t/rpl000015-slave.sh +++ /dev/null @@ -1 +0,0 @@ -rm -f $MYSQLTEST_VARDIR/slave-data/master.info diff --git a/mysql-test/t/rpl000015.slave-mi b/mysql-test/t/rpl000015.slave-mi deleted file mode 100644 index 28bc753dd56..00000000000 --- a/mysql-test/t/rpl000015.slave-mi +++ /dev/null @@ -1 +0,0 @@ ---server-id=22 --master-connect-retry=7 diff --git a/mysql-test/t/rpl000015.test b/mysql-test/t/rpl000015.test deleted file mode 100644 index e103d40943f..00000000000 --- a/mysql-test/t/rpl000015.test +++ /dev/null @@ -1,43 +0,0 @@ --- source include/have_log_bin.inc - -connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); -connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK); -connection master; -reset master; -show master status; -save_master_pos; -connection slave; -reset slave; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -change master to master_host='127.0.0.1'; -# The following needs to be cleaned up when change master is fixed ---replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; ---replace_result $MASTER_MYPORT MASTER_PORT -eval change master to master_host='127.0.0.1',master_user='root', - master_password='',master_port=$MASTER_MYPORT; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; -start slave; -sync_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; -connection master; ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1 (n int); -insert into t1 values (10),(45),(90); -sync_slave_with_master; -select * from t1; -connection master; -drop table t1; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000017-slave.opt b/mysql-test/t/rpl000017-slave.opt deleted file mode 100644 index 58a964c90d0..00000000000 --- a/mysql-test/t/rpl000017-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---skip-slave-start diff --git a/mysql-test/t/rpl000017-slave.sh b/mysql-test/t/rpl000017-slave.sh deleted file mode 100755 index 17188aba0db..00000000000 --- a/mysql-test/t/rpl000017-slave.sh +++ /dev/null @@ -1,12 +0,0 @@ -rm -f $MYSQLTEST_VARDIR/log/*relay* -rm -f $MYSQLTEST_VARDIR/slave-data/relay-log.info -cat > $MYSQLTEST_VARDIR/slave-data/master.info <<EOF -master-bin.000001 -4 -127.0.0.1 -replicate -aaaaaaaaaaaaaaab -$MASTER_MYPORT -1 -0 -EOF diff --git a/mysql-test/t/rpl000017.test b/mysql-test/t/rpl000017.test deleted file mode 100644 index 4488cbad230..00000000000 --- a/mysql-test/t/rpl000017.test +++ /dev/null @@ -1,24 +0,0 @@ --- source include/have_log_bin.inc - -connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); -connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK); -connection master; -reset master; -grant replication slave on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab'; -grant replication slave on *.* to replicate@127.0.0.1 identified by 'aaaaaaaaaaaaaaab'; -connection slave; -start slave; -connection master; ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1(n int); -insert into t1 values(24); -sync_slave_with_master; -select * from t1; -connection master; -drop table t1; -delete from mysql.user where user="replicate"; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000018-master.opt b/mysql-test/t/rpl000018-master.opt deleted file mode 100644 index ad2c6a647b5..00000000000 --- a/mysql-test/t/rpl000018-master.opt +++ /dev/null @@ -1 +0,0 @@ --O max_binlog_size=4096 diff --git a/mysql-test/t/rpl000018-slave.opt b/mysql-test/t/rpl000018-slave.opt deleted file mode 100644 index e854f0d0bb2..00000000000 --- a/mysql-test/t/rpl000018-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---skip-slave-start --abort-slave-event-count=1 diff --git a/mysql-test/t/rpl_EE_error.test b/mysql-test/t/rpl_EE_error.test deleted file mode 100644 index bf42cf2304e..00000000000 --- a/mysql-test/t/rpl_EE_error.test +++ /dev/null @@ -1,34 +0,0 @@ -# See if an EE_ error in one event of the master's binlog stops replication -# (it should not: in this configuration the EE_ error is probably not -# critical). Example: you do a DROP TABLE on a table which has no MYI file -# check if START SLAVE, RESET SLAVE, CHANGE MASTER reset Last_slave_error and -# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986). - -source include/master-slave.inc; - - -create table t1 (a int) engine=myisam; -flush tables; ---remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYI - -drop table if exists t1; -save_master_pos; -connection slave; -sync_with_master; - -# Now a real error. - -connection master; -create table t1 (a int, unique(a)) engine=myisam; -set sql_log_bin=0; -insert into t1 values(2); -set sql_log_bin=1; -save_master_pos; ---error ER_DUP_ENTRY -insert into t1 values(1),(2); -drop table t1; -save_master_pos; -connection slave; -wait_for_slave_to_stop; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_alter.test b/mysql-test/t/rpl_alter.test deleted file mode 100644 index 576376a0264..00000000000 --- a/mysql-test/t/rpl_alter.test +++ /dev/null @@ -1,24 +0,0 @@ -source include/master-slave.inc; ---disable_warnings -drop database if exists mysqltest; ---enable_warnings -create database mysqltest; - -create table mysqltest.t1 ( n int); -alter table mysqltest.t1 add m int; -insert into mysqltest.t1 values (1,2); -create table mysqltest.t2 (n int); -insert into mysqltest.t2 values (45); -rename table mysqltest.t2 to mysqltest.t3, mysqltest.t1 to mysqltest.t2; -save_master_pos; -connection slave; -sync_with_master; -select * from mysqltest.t2; -select * from mysqltest.t3; -connection master; -drop database mysqltest; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_auto_increment-master.opt b/mysql-test/t/rpl_auto_increment-master.opt deleted file mode 100644 index a8a6af19da9..00000000000 --- a/mysql-test/t/rpl_auto_increment-master.opt +++ /dev/null @@ -1 +0,0 @@ ---auto-increment-increment=10 --auto-increment-offset=2 diff --git a/mysql-test/t/rpl_auto_increment.test b/mysql-test/t/rpl_auto_increment.test deleted file mode 100644 index caa2b79feb5..00000000000 --- a/mysql-test/t/rpl_auto_increment.test +++ /dev/null @@ -1,142 +0,0 @@ -# -# Test of auto_increment with offset -# -source include/have_innodb.inc; -source include/master-slave.inc; - -create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3; -insert into t1 values (NULL,1),(NULL,2),(NULL,3); -select * from t1; - -sync_slave_with_master; -select * from t1; -connection master; -drop table t1; - -create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam; -insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4); -delete from t1 where b=4; -insert into t1 values (NULL,5),(NULL,6); -select * from t1; - -sync_slave_with_master; -select * from t1; -connection master; - -drop table t1; - -set @@session.auto_increment_increment=100, @@session.auto_increment_offset=10; -show variables like "%auto_inc%"; - -create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; -# Insert with 2 insert statements to get better testing of logging -insert into t1 values (NULL),(5),(NULL); -insert into t1 values (250),(NULL); -select * from t1; -insert into t1 values (1000); -set @@insert_id=400; -insert into t1 values(NULL),(NULL); -select * from t1; - -sync_slave_with_master; -select * from t1; -connection master; -drop table t1; - -# -# Same test with innodb (as the innodb code is a bit different) -# -create table t1 (a int not null auto_increment, primary key (a)) engine=innodb; -# Insert with 2 insert statements to get better testing of logging -insert into t1 values (NULL),(5),(NULL); -insert into t1 values (250),(NULL); -select * from t1; -insert into t1 values (1000); -set @@insert_id=400; -insert into t1 values(NULL),(NULL); -select * from t1; - -sync_slave_with_master; -select * from t1; -connection master; -drop table t1; - -set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1; -create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; -# Insert with 2 insert statements to get better testing of logging -insert into t1 values (NULL),(5),(NULL),(NULL); -insert into t1 values (500),(NULL),(502),(NULL),(NULL); -select * from t1; -set @@insert_id=600; ---error 1062 -insert into t1 values(600),(NULL),(NULL); -set @@insert_id=600; -insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL); -select * from t1; - -sync_slave_with_master; -select * from t1; -connection master; -drop table t1; - -# -# Test that auto-increment works when slave has rows in the table -# -set @@session.auto_increment_increment=10, @@session.auto_increment_offset=1; - -create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; - -sync_slave_with_master; -insert into t1 values(2),(12),(22),(32),(42); -connection master; - -insert into t1 values (NULL),(NULL); -insert into t1 values (3),(NULL),(NULL); -select * from t1; - -sync_slave_with_master; -select * from t1; - -# Test for BUG#20524 "auto_increment_* not observed when inserting -# a too large value". When an autogenerated value was bigger than the -# maximum possible value of the field, it was truncated to that max -# possible value, without being "rounded down" to still honour -# auto_increment_* variables. - -connection master; -drop table t1; -create table t1 (a tinyint not null auto_increment primary key) engine=myisam; -insert into t1 values(103); -set auto_increment_increment=11; -set auto_increment_offset=4; -insert into t1 values(null); -insert into t1 values(null); ---error 1062 -insert into t1 values(null); -select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t1 order by a; - -# same but with a larger value -create table t2 (a tinyint unsigned not null auto_increment primary key) engine=myisam; -set auto_increment_increment=10; -set auto_increment_offset=1; -set insert_id=1000; -insert into t2 values(null); -select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t2 order by a; - -# An offset so big that even first value does not fit -create table t3 like t1; -set auto_increment_increment=1000; -set auto_increment_offset=700; -insert into t3 values(null); -select * from t3 order by a; -sync_slave_with_master; -select * from t1 order by a; -select * from t2 order by a; -select * from t3 order by a; - -connection master; - -drop table t1,t2,t3; - -# End cleanup -sync_slave_with_master; diff --git a/mysql-test/t/rpl_auto_increment_11932.test b/mysql-test/t/rpl_auto_increment_11932.test deleted file mode 100644 index d4b7872fb2b..00000000000 --- a/mysql-test/t/rpl_auto_increment_11932.test +++ /dev/null @@ -1,63 +0,0 @@ -# -# Test of auto_increment -# BUG#11932 -# -# Bug reported that master and slave get out of sync after TRUNCATE -# TABLE. -# -# Test supplied by Are Casilla - -source include/master-slave.inc; ---disable_warnings -connection master; -drop database if exists test1; ---enable_warnings -create database test1; -use test1; - -CREATE TABLE `t1` ( - `id` int(10) unsigned NOT NULL auto_increment, - `fname` varchar(100) default NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; - -INSERT INTO `t1` VALUES (1, 'blablabla'); - -CREATE TABLE `t2` ( - `id` int(10) NOT NULL auto_increment, - `comment` varchar(255) NOT NULL default '', - PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=3 ; - -INSERT INTO `t2` VALUES (1, 'testtest 1'); -INSERT INTO `t2` VALUES (2, 'test 2'); - -DELIMITER $; -CREATE PROCEDURE simpleproc3 () - NOT DETERMINISTIC - BEGIN - INSERT INTO t1 (fname) (SELECT t2.comment FROM t2 WHERE t2.id = '1'); - INSERT INTO t1 (fname) VALUES('test'); - END - $ -DELIMITER ;$ - -CALL simpleproc3(); - -select * from t2; - -TRUNCATE TABLE `t1`; -CALL simpleproc3(); - -select * from t1; - -save_master_pos; -connection slave; -sync_with_master; - -use test1; -select * from t1; - -drop database test1; -connection master; -drop database test1; diff --git a/mysql-test/t/rpl_auto_increment_bug33029.test b/mysql-test/t/rpl_auto_increment_bug33029.test deleted file mode 100644 index db548945c7f..00000000000 --- a/mysql-test/t/rpl_auto_increment_bug33029.test +++ /dev/null @@ -1,109 +0,0 @@ -# BUG#33029 5.0 to 5.1 replication fails on dup key when inserting -# using a trig in SP - -# For all 5.0 up to 5.0.58 exclusive, and 5.1 up to 5.1.12 exclusive, -# if one statement in a SP generated AUTO_INCREMENT value by the top -# statement, all statements after it would be considered generated -# AUTO_INCREMENT value by the top statement, and a erroneous INSERT_ID -# value might be associated with these statement, which could cause -# duplicate entry error and stop the slave. - -source include/master-slave.inc; - ---disable_warnings -DROP TABLE IF EXISTS t1, t2; -DROP PROCEDURE IF EXISTS p1; -DROP PROCEDURE IF EXISTS p2; -DROP TRIGGER IF EXISTS tr1; -DROP FUNCTION IF EXISTS f1; ---enable_warnings - -CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE t2 (id INT AUTO_INCREMENT PRIMARY KEY); - -delimiter //; - -CREATE PROCEDURE p1() -BEGIN - DECLARE ins_count INT DEFAULT 10; - - WHILE ins_count > 0 DO - INSERT INTO t1 VALUES (NULL); - SET ins_count = ins_count - 1; - END WHILE; - - DELETE FROM t1 WHERE id = 1; - DELETE FROM t1 WHERE id = 2; - DELETE FROM t2 WHERE id = 1; - DELETE FROM t2 WHERE id = 2; -END// - -CREATE PROCEDURE p2() -BEGIN - INSERT INTO t1 VALUES (NULL); - DELETE FROM t1 WHERE id = f1(3); - DELETE FROM t1 WHERE id = f1(4); - DELETE FROM t2 WHERE id = 3; - DELETE FROM t2 WHERE id = 4; -END// - -CREATE TRIGGER tr1 BEFORE DELETE - ON t1 FOR EACH ROW - BEGIN - INSERT INTO t2 VALUES (NULL); - END// - -CREATE FUNCTION f1 (i int) RETURNS int - BEGIN - INSERT INTO t2 VALUES (NULL); - RETURN i; - END// - -delimiter ;// - -# the $binlog_start will be used by the show_binlog_events.inc, so -# that we can skip binlog events we don't care -let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); -CALL p1(); -source include/show_binlog_events.inc; - -echo # Result on master; -SELECT * FROM t1; -SELECT * FROM t2; - -sync_slave_with_master; - -echo # Result on slave; -SELECT * FROM t1; -SELECT * FROM t2; - -connection master; - -DROP TRIGGER tr1; - -# the $binlog_start will be used by the show_binlog_events.inc, so -# that we can skip binlog events we don't care -let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); -CALL p2(); -source include/show_binlog_events.inc; - -echo # Result on master; -SELECT * FROM t1; -SELECT * FROM t2; - -sync_slave_with_master; - -echo # Result on slave; -SELECT * FROM t1; -SELECT * FROM t2; - -# clean up -connection master; -disable_warnings; -DROP TABLE IF EXISTS t1, t2; -DROP PROCEDURE IF EXISTS p1; -DROP PROCEDURE IF EXISTS p2; -DROP FUNCTION IF EXISTS f1; -DROP TRIGGER IF EXISTS tr1; -enable_warnings; -sync_slave_with_master; diff --git a/mysql-test/t/rpl_begin_commit_rollback-slave.opt b/mysql-test/t/rpl_begin_commit_rollback-slave.opt deleted file mode 100644 index b4abda5893f..00000000000 --- a/mysql-test/t/rpl_begin_commit_rollback-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb --replicate-do-db=db1 diff --git a/mysql-test/t/rpl_begin_commit_rollback.test b/mysql-test/t/rpl_begin_commit_rollback.test deleted file mode 100644 index 060cf3c21fc..00000000000 --- a/mysql-test/t/rpl_begin_commit_rollback.test +++ /dev/null @@ -1,124 +0,0 @@ -source include/master-slave.inc; -source include/have_innodb.inc; - -disable_warnings; -DROP DATABASE IF EXISTS db1; -enable_warnings; - -CREATE DATABASE db1; - -use db1; - -CREATE TABLE db1.t1 (a INT) ENGINE=InnoDB; -CREATE TABLE db1.t2 (s CHAR(255)) ENGINE=MyISAM; - -sync_slave_with_master; -source include/stop_slave.inc; -connection master; -echo [on master]; - -DELIMITER //; -CREATE PROCEDURE db1.p1 () -BEGIN - INSERT INTO t1 VALUES (1); - INSERT INTO t1 VALUES (2); - INSERT INTO t1 VALUES (3); - INSERT INTO t1 VALUES (4); - INSERT INTO t1 VALUES (5); -END// - -CREATE PROCEDURE db1.p2 () -BEGIN - INSERT INTO t1 VALUES (6); - INSERT INTO t1 VALUES (7); - INSERT INTO t1 VALUES (8); - INSERT INTO t1 VALUES (9); - INSERT INTO t1 VALUES (10); - INSERT INTO t2 VALUES ('executed db1.p2()'); -END// -DELIMITER ;// - -INSERT INTO db1.t2 VALUES ('before call db1.p1()'); - -# Note: the master_log_pos is set to be the position of the BEGIN + 1, -# so before fix of BUG#43263 if the BEGIN is ignored, then all the -# INSERTS in p1 will be replicated in AUTOCOMMIT=1 mode and the slave -# SQL thread will stop right before the first INSERT. After fix of -# BUG#43263, BEGIN will not be ignored by the replication db rules, -# and then the whole transaction will be executed before slave SQL -# stop. -let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1); -let $master_pos= `SELECT $master_pos + 1`; - -use test; -BEGIN; -CALL db1.p1(); -COMMIT; - -# The position where the following START SLAVE UNTIL will stop at -let $master_end_trans_pos= query_get_value(SHOW MASTER STATUS, Position, 1); - -INSERT INTO db1.t2 VALUES ('after call db1.p1()'); -SELECT * FROM db1.t1; -SELECT * FROM db1.t2; - -connection slave; -echo [on slave]; - -replace_result $master_pos MASTER_POS; -eval start slave until master_log_file='master-bin.000001', master_log_pos=$master_pos; -source include/wait_for_slave_sql_to_stop.inc; -let $slave_sql_stop_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1); -let $result= query_get_value(SELECT $slave_sql_stop_pos - $master_end_trans_pos as result, result, 1); - ---echo # ---echo # If we got non-zero here, then we're suffering BUG#43263 ---echo # -eval SELECT $result as 'Must be 0'; -SELECT * from db1.t1; -SELECT * from db1.t2; - -connection master; -echo [on master]; - -INSERT INTO db1.t2 VALUES ('before call db1.p2()'); - -# See comments above. -let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1); -let $master_pos= `SELECT $master_pos + 1`; - -BEGIN; -CALL db1.p2(); -disable_warnings; -ROLLBACK; -enable_warnings; -let $master_end_trans_pos= query_get_value(SHOW MASTER STATUS, Position, 1); - -INSERT INTO db1.t2 VALUES ('after call db1.p2()'); -SELECT * FROM db1.t1; -SELECT * FROM db1.t2; - -connection slave; -echo [on slave]; - -replace_result $master_pos MASTER_POS; -eval start slave until master_log_file='master-bin.000001', master_log_pos=$master_pos; -source include/wait_for_slave_sql_to_stop.inc; - -let $slave_sql_stop_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1); -let $result= query_get_value(SELECT $slave_sql_stop_pos - $master_end_trans_pos as result, result, 1); - ---echo # ---echo # If we got non-zero here, then we're suffering BUG#43263 ---echo # -eval SELECT $result as 'Must be 0'; -SELECT * from db1.t1; -SELECT * from db1.t2; - ---echo # ---echo # Clean up ---echo # -connection master; -DROP DATABASE db1; -connection slave; -DROP DATABASE db1; diff --git a/mysql-test/t/rpl_bug33931-slave.opt b/mysql-test/t/rpl_bug33931-slave.opt deleted file mode 100644 index 55fe328a41d..00000000000 --- a/mysql-test/t/rpl_bug33931-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-debug=d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init diff --git a/mysql-test/t/rpl_bug33931.test b/mysql-test/t/rpl_bug33931.test deleted file mode 100644 index 788f79d4c1c..00000000000 --- a/mysql-test/t/rpl_bug33931.test +++ /dev/null @@ -1,37 +0,0 @@ -# Test for -# Bug #33931 assertion at write_ignored_events_info_to_relay_log if init_slave_thread() fails -# Bug #33932 assertion at handle_slave_sql if init_slave_thread() fails - -source include/have_debug.inc; -source include/have_log_bin.inc; - -connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,); -connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,); - - -connection master; -reset master; - -connection slave; ---disable_warnings -stop slave; ---enable_warnings -reset slave; -start slave; - -connection master; -save_master_pos; -connection slave; - -# -# slave is going to stop because of emulated failures -# but there won't be any crashes nor asserts hit. -# -source include/wait_for_slave_to_stop.inc; - ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -query_vertical show slave status; - -# no clean-up is needed - diff --git a/mysql-test/t/rpl_bug38694-slave.opt b/mysql-test/t/rpl_bug38694-slave.opt deleted file mode 100644 index d96e981b198..00000000000 --- a/mysql-test/t/rpl_bug38694-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-debug=d,simulate_slave_delay_at_terminate_bug38694 diff --git a/mysql-test/t/rpl_bug38694.test b/mysql-test/t/rpl_bug38694.test deleted file mode 100644 index 41b11d271b9..00000000000 --- a/mysql-test/t/rpl_bug38694.test +++ /dev/null @@ -1,10 +0,0 @@ -# Testing replication threads stopping concurrency issue -# at the server shutdown -# Related bugs: bug#38694, bug#29968, bug#25306 -# The test checks if a delay at the termination phase of slave threads -# DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5);); -# could cause any issue. - -source include/master-slave.inc; - -# End of tests diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test deleted file mode 100644 index 9dd1505af90..00000000000 --- a/mysql-test/t/rpl_change_master.test +++ /dev/null @@ -1,37 +0,0 @@ -# Verify that after CHANGE MASTER, replication (I/O thread and SQL -# thread) restart from where SQL thread left, not from where -# I/O thread left (some old bug fixed in 4.0.17) - -source include/master-slave.inc; - -connection master; -# Make SQL slave thread advance a bit -create table t1(n int); -sync_slave_with_master; -select * from t1; -# Now stop it and make I/O slave thread be ahead -stop slave sql_thread; -connection master; -insert into t1 values(1); -insert into t1 values(2); -save_master_pos; -connection slave; ---real_sleep 3 # wait for I/O thread to have read updates -stop slave; ---replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 8 # 9 # 23 # 33 # -query_vertical show slave status; -change master to master_user='root'; ---replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 8 # 9 # 23 # 33 # -query_vertical show slave status; -start slave; -sync_with_master; -select * from t1; -connection master; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_charset.test b/mysql-test/t/rpl_charset.test deleted file mode 100644 index e916ae9ad6c..00000000000 --- a/mysql-test/t/rpl_charset.test +++ /dev/null @@ -1,173 +0,0 @@ -# Replication of character sets. -# This test will fail if the server/client does not support enough charsets. - -source include/master-slave.inc; ---disable_warnings -set timestamp=1000000000; -drop database if exists mysqltest2; -drop database if exists mysqltest3; ---enable_warnings - -create database mysqltest2 character set latin2; -set @@character_set_server=latin5; -create database mysqltest3; ---disable_query_log -select "--- --master--" as ""; ---enable_query_log -show create database mysqltest2; -show create database mysqltest3; -sync_slave_with_master; ---disable_query_log -select "--- --slave--" as ""; ---enable_query_log -show create database mysqltest2; -show create database mysqltest3; - -connection master; -set @@collation_server=armscii8_bin; -drop database mysqltest3; -create database mysqltest3; ---disable_query_log -select "--- --master--" as ""; ---enable_query_log -show create database mysqltest3; -sync_slave_with_master; ---disable_query_log -select "--- --slave--" as ""; ---enable_query_log -show create database mysqltest3; - -connection master; -use mysqltest2; -create table t1 (a int auto_increment primary key, b varchar(100)); -set character_set_client=cp850, collation_connection=latin2_croatian_ci; -insert into t1 (b) values(@@character_set_server); -insert into t1 (b) values(@@collation_server); -# character_set_database and collation_database are not tested as they -# needn't be replicated (Bar said in Jan 2005). -insert into t1 (b) values(@@character_set_client); -# collation_client does not exist -insert into t1 (b) values(@@character_set_connection); -insert into t1 (b) values(@@collation_connection); ---disable_query_log -select "--- --master--" as ""; ---enable_query_log -select * from t1 order by a; -sync_slave_with_master; ---disable_query_log -select "--- --slave--" as ""; ---enable_query_log -select * from mysqltest2.t1 order by a; - -connection master; -set character_set_client=latin1, collation_connection=latin1_german1_ci; -truncate table t1; -insert into t1 (b) values(@@collation_connection); -insert into t1 (b) values(LEAST("Mller","Muffler")); -set collation_connection=latin1_german2_ci; -insert into t1 (b) values(@@collation_connection); -insert into t1 (b) values(LEAST("Mller","Muffler")); ---disable_query_log -select "--- --master--" as ""; ---enable_query_log -select * from t1 order by a; -sync_slave_with_master; ---disable_query_log -select "--- --slave--" as ""; ---enable_query_log -select * from mysqltest2.t1 order by a; - -# Presently charset info is not logged with LOAD DATA but it will -# change in Jan 2005 when Dmitri pushes his new LOAD DATA, -# before 5.0.3 goes out. When done, LOAD DATA INFILE should be tested -# here. - -# See if user var is prefixed with collation in binlog and replicated well. -# Note: replication of user variables is broken as far as derivation is -# concerned. That's because when we store a user variable in the binlog, -# we lose its derivation. So later on the slave, it's impossible to -# know if the collation was explicit or not, so we use DERIVATION_NONE, -# which provokes error messages (like 'Illegal mix of collation') when -# we replay the master's INSERT/etc statements. -connection master; -set @a= _cp850 'Mller' collate cp850_general_ci; -truncate table t1; -insert into t1 (b) values(collation(@a)); ---disable_query_log -select "--- --master--" as ""; ---enable_query_log -select * from t1 order by a; -sync_slave_with_master; ---disable_query_log -select "--- --slave--" as ""; ---enable_query_log -select * from mysqltest2.t1 order by a; - -connection master; -drop database mysqltest2; -drop database mysqltest3; ---replace_column 2 # 5 # -show binlog events from 98; -sync_slave_with_master; - -# Check that we can change global.collation_server (since 5.0.3) - -set global character_set_server=latin2; -set global character_set_server=latin1; # back -connection master; -set global character_set_server=latin2; -set global character_set_server=latin1; # back - -# Check that SET ONE_SHOT is really one shot - -set one_shot @@character_set_server=latin5; -set @@max_join_size=1000; -select @@character_set_server; -select @@character_set_server; -set @@character_set_server=latin5; -select @@character_set_server; -select @@character_set_server; - -# ONE_SHOT on not charset/collation stuff is not allowed --- error 1382 -set one_shot max_join_size=10; - -# Test of wrong character set numbers; -error 1115; -set character_set_client=9999999; -error 1273; -set collation_server=9999998; - -# This one was contributed by Sergey Petrunia (BUG#3943) - -use test; -CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255)); -SET CHARACTER_SET_CLIENT=koi8r, - CHARACTER_SET_CONNECTION=cp1251, - CHARACTER_SET_RESULTS=koi8r; -INSERT INTO t1 (c1, c2) VALUES (', ',', '); -select hex(c1), hex(c2) from t1; -sync_slave_with_master; -select hex(c1), hex(c2) from t1; - -connection master; -# Let's have a look at generated SETs. ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 -drop table t1; -sync_slave_with_master; - -# -# BUG#6676: Derivation of variables must be correct on slave -# -connection master; -create table `t1` ( - `pk` varchar(10) not null default '', - primary key (`pk`) -) engine=myisam default charset=latin1; -set @p=_latin1 'test'; -update t1 set pk='test' where pk=@p; -drop table t1; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_charset_sjis.test b/mysql-test/t/rpl_charset_sjis.test deleted file mode 100644 index 2469b0db8a2..00000000000 --- a/mysql-test/t/rpl_charset_sjis.test +++ /dev/null @@ -1,25 +0,0 @@ -source include/have_sjis.inc; -source include/master-slave.inc; - ---disable_warnings -drop table if exists t1; -drop procedure if exists p1; ---enable_warnings -create table t1 (a varchar(255) character set sjis); -create procedure p1 (in a varchar(255) character set sjis) insert into t1 values (a); - -SET NAMES binary; -CALL p1 ('\\'); -select "--- on master ---"; -select hex(a) from t1 ; -sync_slave_with_master; -connection slave; -select "--- on slave ---"; -select hex(a) from t1; -connection master; -drop table t1; -drop procedure p1; -sync_slave_with_master; -connection master; - -# End of 5.0 tests diff --git a/mysql-test/t/rpl_commit_after_flush.test b/mysql-test/t/rpl_commit_after_flush.test deleted file mode 100644 index 6129e5485a6..00000000000 --- a/mysql-test/t/rpl_commit_after_flush.test +++ /dev/null @@ -1,19 +0,0 @@ -source include/master-slave.inc; -source include/have_innodb.inc; -create table t1 (a int) engine=innodb; -begin; -insert into t1 values(1); -flush tables with read lock; -commit; -save_master_pos; -connection slave; -sync_with_master; -# cleanup -connection master; -unlock tables; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_create_database-master.opt b/mysql-test/t/rpl_create_database-master.opt deleted file mode 100644 index 85660a17140..00000000000 --- a/mysql-test/t/rpl_create_database-master.opt +++ /dev/null @@ -1 +0,0 @@ ---binlog-do-db=mysqltest_sisyfos --binlog-do-db=mysqltest_prometheus diff --git a/mysql-test/t/rpl_create_database-slave.opt b/mysql-test/t/rpl_create_database-slave.opt deleted file mode 100644 index 96d630c9229..00000000000 --- a/mysql-test/t/rpl_create_database-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-do-db=mysqltest_sisyfos --replicate-do-db=mysqltest_prometheus diff --git a/mysql-test/t/rpl_create_database.test b/mysql-test/t/rpl_create_database.test deleted file mode 100644 index cfccc4567b5..00000000000 --- a/mysql-test/t/rpl_create_database.test +++ /dev/null @@ -1,73 +0,0 @@ -# -# Tests for replication of statements that manipulate databases. -# -# For this test file, we have a number of databases. All databases -# with "greek" names will be replicated on the slave, while other names -# (e.g., american) will not be replicated. -# - -source include/master-slave.inc; - -# Bug#6391 (binlog-do-db rules ignored) -# In this case, 'mysqltest_bob' should not be replicated to the slave. ---disable_warnings -DROP DATABASE IF EXISTS mysqltest_prometheus; -DROP DATABASE IF EXISTS mysqltest_sisyfos; -DROP DATABASE IF EXISTS mysqltest_bob; -sync_slave_with_master; -# This database is not replicated -DROP DATABASE IF EXISTS mysqltest_bob; ---enable_warnings - -connection master; -CREATE DATABASE mysqltest_prometheus; -CREATE DATABASE mysqltest_sisyfos; -CREATE DATABASE mysqltest_bob; - -USE mysqltest_sisyfos; -# These should be replicated -CREATE TABLE t1 (b int); -INSERT INTO t1 VALUES(1); - -USE mysqltest_bob; -# These should *not* be replicated -CREATE TABLE t2 (b int); -INSERT INTO t2 VALUES(2); - -# Current database is now 'mysqltest_bob' -# The following should be replicated -ALTER DATABASE mysqltest_sisyfos CHARACTER SET latin1; - -USE mysqltest_sisyfos; -# The following should *not* be replicated -ALTER DATABASE mysqltest_bob CHARACTER SET latin1; - -SHOW DATABASES; -sync_slave_with_master; -SHOW DATABASES; - -connection master; -DROP DATABASE IF EXISTS mysqltest_sisyfos; -USE mysqltest_prometheus; -CREATE TABLE t1 (a INT); -INSERT INTO t1 VALUES (1); -CREATE DATABASE mysqltest_sisyfos; -USE mysqltest_sisyfos; -CREATE TABLE t2 (a INT); -let $VERSION=`select version()`; ---replace_result $VERSION VERSION ---replace_column 2 # 5 # -SHOW BINLOG EVENTS; -SHOW DATABASES; -sync_slave_with_master; -SHOW DATABASES; -SHOW CREATE TABLE mysqltest_prometheus.t1; -SHOW CREATE TABLE mysqltest_sisyfos.t2; - -connection master; -DROP DATABASE IF EXISTS mysqltest_prometheus; -DROP DATABASE IF EXISTS mysqltest_sisyfos; -DROP DATABASE IF EXISTS mysqltest_bob; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_critical_errors.test b/mysql-test/t/rpl_critical_errors.test deleted file mode 100644 index ffe00050b01..00000000000 --- a/mysql-test/t/rpl_critical_errors.test +++ /dev/null @@ -1,66 +0,0 @@ -# Test for BUG#26551 -# - -# This test is unfortunately very fragile and very dependent on the -# load of the computer. The test is therefore disabled normally. It is -# entered here to demonstrate how to check that the bug is actually -# solved. - ---echo Turn on parsing to run this test - -disable_parsing; - -source include/master-slave.inc; - -connection master; -CREATE TABLE t1 (data LONGBLOB) ENGINE=MYISAM; -CREATE TABLE t2 (data LONGBLOB) ENGINE=MYISAM; - -INSERT INTO t1 (data) VALUES (repeat('a',1024*1024)); -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -sync_slave_with_master; - -connection master; -send INSERT INTO t2 SELECT * FROM t1; - -connection master1; - -# This sleep is picked so that the query above has started to insert -# some rows into t2. If it hasn't the slave will not stop below. -sleep 4; - -# SHOW PROCESSLIST; - -# Code for the 5.1 server to get the thread id of the thread executing -# the query above. -# -#SET @id = 0; -#SELECT id INTO @id -# FROM information_schema.processlist -# WHERE info LIKE 'INSERT INTO t2%'; - -# This is the connection that is executing the INSERT INTO t2... -KILL QUERY 2; - -connection slave; - -# Here the slave will only stop if the query above actually started -# inserting some rows into t2. Otherwise, it will hang forever. -wait_for_slave_to_stop; - -# The following should be 0 -SELECT COUNT(*) FROM t2; - -# ... and there the error code should be 1317 (ER_QUERY_INTERRUPTED) ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 7 # 8 # 9 # 20 # 22 # 23 # 33 # -query_vertical SHOW SLAVE STATUS; - -enable_parsing; diff --git a/mysql-test/t/rpl_ddl.test b/mysql-test/t/rpl_ddl.test deleted file mode 100644 index 23841ee3491..00000000000 --- a/mysql-test/t/rpl_ddl.test +++ /dev/null @@ -1,522 +0,0 @@ -######################## rpl_ddl.test ######################## -# # -# DDL statements (sometimes with implicit COMMIT) executed # -# by the master and it's propagation into the slave # -# # -############################################################## - -# -# NOTE, PLEASE BE CAREFUL, WHEN MODIFYING THE TESTS !! -# -# 1. !All! objects to be dropped, renamed, altered ... must be created -# in AUTOCOMMIT= 1 mode before AUTOCOMMIT is set to 0 and the test -# sequences start. -# -# 2. Never use a test object, which was direct or indirect affected by a -# preceeding test sequence again. -# Except table d1.t1 where ONLY DML is allowed. -# -# If one preceeding test sequence hits a (sometimes not good visible, -# because the sql error code of the statement might be 0) bug -# and these rules are ignored, a following test sequence might earn ugly -# effects like failing 'sync_slave_with_master', crashes of the slave or -# abort of the test case etc.. -# -# 3. The assignment of the DDL command to be tested to $my_stmt can -# be a bit difficult. "'" must be avoided, because the test -# routine "include/rpl_stmt_seq.inc" performs a -# eval SELECT CONCAT('######## ','$my_stmt',' ########') as ""; -# - ---source include/have_innodb.inc ---source include/master-slave.inc - -############################################################### -# Some preparations -############################################################### -# The sync_slave_with_master is needed to make the xids deterministic. -sync_slave_with_master; -connection master; - -SET AUTOCOMMIT = 1; -# -# 1. DROP all objects, which probably already exist, but must be created here -# ---disable_warnings -DROP DATABASE IF EXISTS mysqltest1; -DROP DATABASE IF EXISTS mysqltest2; -DROP DATABASE IF EXISTS mysqltest3; ---enable_warnings -# -# 2. CREATE all objects needed -# working database is mysqltest1 -# working (transactional!) is mysqltest1.t1 -# -CREATE DATABASE mysqltest1; -CREATE DATABASE mysqltest2; -CREATE TABLE mysqltest1.t1 (f1 BIGINT) ENGINE= "InnoDB"; -# Prevent Bug#26687 rpl_ddl test fails if run with --innodb option -# The current testscripts + the expected result need that the slave uses MyISAM -# for the table mysqltest.t1. -sync_slave_with_master; -connection slave; -if (`SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES - WHERE TABLE_SCHEMA = 'mysqltest1' AND TABLE_NAME = 't1' - AND ENGINE <> 'MyISAM'`) -{ - skip This test needs on slave side: InnoDB disabled, default engine: MyISAM; -} -connection master; -INSERT INTO mysqltest1.t1 SET f1= 0; -CREATE TABLE mysqltest1.t2 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t3 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t4 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t5 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t6 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE INDEX my_idx6 ON mysqltest1.t6(f1); -CREATE TABLE mysqltest1.t7 (f1 BIGINT) ENGINE= "InnoDB"; -INSERT INTO mysqltest1.t7 SET f1= 0; -CREATE TABLE mysqltest1.t8 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t9 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t10 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t11 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t12 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t13 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t14 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t15 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t16 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t17 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t18 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TABLE mysqltest1.t19 (f1 BIGINT) ENGINE= "InnoDB"; -CREATE TEMPORARY TABLE mysqltest1.t23 (f1 BIGINT); - -# -# 3. master sessions: never do AUTOCOMMIT -# slave sessions: never do AUTOCOMMIT -# -SET AUTOCOMMIT = 0; -use mysqltest1; -sync_slave_with_master; -connection slave; ---disable_query_log -SELECT '-------- switch to slave --------' as ""; ---enable_query_log -SET AUTOCOMMIT = 0; -use mysqltest1; -connection master; ---disable_query_log -SELECT '-------- switch to master -------' as ""; ---enable_query_log - - -# We don't want to abort the whole test if one statement sent -# to the server gets an error, because the following test -# sequences are nearly independend of the previous statements. ---disable_abort_on_error - -############################################################### -# Banal case: (explicit) COMMIT and ROLLBACK -# Just for checking if the test sequence is usable -############################################################### - -let $my_stmt= COMMIT; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc - -let $my_stmt= ROLLBACK; -let $my_master_commit= false; -let $my_slave_commit= false; ---source include/rpl_stmt_seq.inc - -############################################################### -# Cases with commands very similar to COMMIT -############################################################### - -let $my_stmt= SET AUTOCOMMIT=1; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SET AUTOCOMMIT=0; - -let $my_stmt= START TRANSACTION; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc - -let $my_stmt= BEGIN; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc - -############################################################### -# Cases with (BASE) TABLES and (UPDATABLE) VIEWs -############################################################### - -let $my_stmt= DROP TABLE mysqltest1.t2; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SHOW TABLES LIKE 't2'; -connection slave; ---disable_query_log -SELECT '-------- switch to slave --------' as ""; ---enable_query_log -SHOW TABLES LIKE 't2'; -connection master; ---disable_query_log -SELECT '-------- switch to master -------' as ""; ---enable_query_log - -# Note: Since this test is executed with a skip-innodb slave, the -# slave incorrectly commits the insert. One can *not* have InnoDB on -# master and MyISAM on slave and expect that a transactional rollback -# after a CREATE TEMPORARY TABLE should work correctly on the slave. -# For this to work properly the handler on the slave must be able to -# handle transactions (e.g. InnoDB or NDB). -let $my_stmt= DROP TEMPORARY TABLE mysqltest1.t23; -let $my_master_commit= false; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SHOW TABLES LIKE 't23'; -connection slave; ---disable_query_log -SELECT '-------- switch to slave --------' as ""; ---enable_query_log -SHOW TABLES LIKE 't23'; -connection master; ---disable_query_log -SELECT '-------- switch to master -------' as ""; ---enable_query_log - -let $my_stmt= RENAME TABLE mysqltest1.t3 to mysqltest1.t20; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SHOW TABLES LIKE 't20'; -connection slave; ---disable_query_log -SELECT '-------- switch to slave --------' as ""; ---enable_query_log -SHOW TABLES LIKE 't20'; -connection master; ---disable_query_log -SELECT '-------- switch to master -------' as ""; ---enable_query_log - -let $my_stmt= ALTER TABLE mysqltest1.t4 ADD column f2 BIGINT; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -describe mysqltest1.t4; -connection slave; ---disable_query_log -SELECT '-------- switch to slave --------' as ""; ---enable_query_log -describe mysqltest1.t4; -connection master; ---disable_query_log -SELECT '-------- switch to master -------' as ""; ---enable_query_log - -let $my_stmt= CREATE TABLE mysqltest1.t21 (f1 BIGINT) ENGINE= "InnoDB"; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc - -# Note: Since this test is executed with a skip-innodb slave, the -# slave incorrectly commits the insert. One can *not* have InnoDB on -# master and MyISAM on slave and expect that a transactional rollback -# after a CREATE TEMPORARY TABLE should work correctly on the slave. -# For this to work properly the handler on the slave must be able to -# handle transactions (e.g. InnoDB or NDB). -let $my_stmt= CREATE TEMPORARY TABLE mysqltest1.t22 (f1 BIGINT); -let $my_master_commit= false; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc - -let $my_stmt= TRUNCATE TABLE mysqltest1.t7; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SELECT * FROM mysqltest1.t7; -connection slave; ---disable_query_log -SELECT '-------- switch to slave --------' as ""; ---enable_query_log -SELECT * FROM mysqltest1.t7; -connection master; ---disable_query_log -SELECT '-------- switch to master -------' as ""; ---enable_query_log - -############################################################### -# Cases with LOCK/UNLOCK -############################################################### - -# MySQL insists in locking mysqltest1.t1, because rpl_stmt_seq performs an -# INSERT into this table. -let $my_stmt= LOCK TABLES mysqltest1.t1 WRITE, mysqltest1.t8 READ; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -UNLOCK TABLES; - -# No prior locking -let $my_stmt= UNLOCK TABLES; -let $my_master_commit= false; -let $my_slave_commit= false; ---source include/rpl_stmt_seq.inc - -# With prior read locking -# Note that this test generate an error since the rpl_stmt_seq.inc -# tries to insert into t1. -LOCK TABLES mysqltest1.t1 READ; -let $my_stmt= UNLOCK TABLES; -let $my_master_commit= false; -let $my_slave_commit= false; ---source include/rpl_stmt_seq.inc - -# With prior write locking -LOCK TABLES mysqltest1.t1 WRITE, mysqltest1.t8 READ; -let $my_stmt= UNLOCK TABLES; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc - -############################################################### -# Cases with INDEXES -############################################################### - -let $my_stmt= DROP INDEX my_idx6 ON mysqltest1.t6; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SHOW INDEX FROM mysqltest1.t6; -connection slave; ---disable_query_log -SELECT '-------- switch to slave --------' as ""; ---enable_query_log -SHOW INDEX FROM mysqltest1.t6; -connection master; ---disable_query_log -SELECT '-------- switch to master -------' as ""; ---enable_query_log - -let $my_stmt= CREATE INDEX my_idx5 ON mysqltest1.t5(f1); -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SHOW INDEX FROM mysqltest1.t5; -connection slave; ---disable_query_log -SELECT '-------- switch to slave --------' as ""; ---enable_query_log -SHOW INDEX FROM mysqltest1.t5; -connection master; ---disable_query_log -SELECT '-------- switch to master -------' as ""; ---enable_query_log - -############################################################### -# Cases with DATABASE -############################################################### - -let $my_stmt= DROP DATABASE mysqltest2; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SHOW DATABASES LIKE "mysqltest2"; -connection slave; ---disable_query_log -SELECT '-------- switch to slave --------' as ""; ---enable_query_log -SHOW DATABASES LIKE "mysqltest2"; -connection master; ---disable_query_log -SELECT '-------- switch to master -------' as ""; ---enable_query_log - -let $my_stmt= CREATE DATABASE mysqltest3; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SHOW DATABASES LIKE "mysqltest3"; -connection slave; ---disable_query_log -SELECT '-------- switch to slave --------' as ""; ---enable_query_log -SHOW DATABASES LIKE "mysqltest3"; -connection master; ---disable_query_log -SELECT '-------- switch to master -------' as ""; ---enable_query_log - -# End of 4.1 tests - -############################################################### -# Cases with stored procedures -############################################################### -let $my_stmt= CREATE PROCEDURE p1() READS SQL DATA SELECT "this is p1"; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc ---vertical_results ---replace_column 5 # 6 # -SHOW PROCEDURE STATUS LIKE 'p1'; ---disable_query_log -SELECT '-------- switch to slave -------' as ""; ---enable_query_log -connection slave; ---replace_column 5 # 6 # -SHOW PROCEDURE STATUS LIKE 'p1'; -connection master; ---horizontal_results - -let $my_stmt= ALTER PROCEDURE p1 COMMENT "I have been altered"; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc ---vertical_results ---replace_column 5 # 6 # -SHOW PROCEDURE STATUS LIKE 'p1'; ---disable_query_log -SELECT '-------- switch to slave -------' as ""; ---enable_query_log -connection slave; ---replace_column 5 # 6 # -SHOW PROCEDURE STATUS LIKE 'p1'; -connection master; ---horizontal_results - -let $my_stmt= DROP PROCEDURE p1; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc ---vertical_results -SHOW PROCEDURE STATUS LIKE 'p1'; ---disable_query_log -SELECT '-------- switch to slave -------' as ""; ---enable_query_log -connection slave; -SHOW PROCEDURE STATUS LIKE 'p1'; -connection master; ---horizontal_results - -############################################################### -# Cases with VIEWs -############################################################### -let $my_stmt= CREATE OR REPLACE VIEW v1 as select * from t1; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SHOW CREATE VIEW v1; ---disable_query_log -SELECT '-------- switch to slave -------' as ""; ---enable_query_log -connection slave; -SHOW CREATE VIEW v1; -connection master; - -let $my_stmt= ALTER VIEW v1 AS select f1 from t1; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SHOW CREATE VIEW v1; ---disable_query_log -SELECT '-------- switch to slave -------' as ""; ---enable_query_log -connection slave; -SHOW CREATE VIEW v1; -connection master; - -let $my_stmt= DROP VIEW IF EXISTS v1; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc ---error 1146 -SHOW CREATE VIEW v1; ---disable_query_log -SELECT '-------- switch to slave -------' as ""; ---enable_query_log -connection slave; ---error 1146 -SHOW CREATE VIEW v1; -connection master; - -############################################################### -# Cases with TRIGGERs -############################################################### -let $my_stmt= CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @a:=1; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SHOW TRIGGERS; ---disable_query_log -SELECT '-------- switch to slave -------' as ""; ---enable_query_log -connection slave; -SHOW TRIGGERS; -connection master; - -let $my_stmt= DROP TRIGGER trg1; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SHOW TRIGGERS; ---disable_query_log -SELECT '-------- switch to slave -------' as ""; ---enable_query_log -connection slave; -SHOW TRIGGERS; -connection master; - -############################################################### -# Cases with USERs -############################################################### -let $my_stmt= CREATE USER user1@localhost; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SELECT user FROM mysql.user WHERE user = 'user1'; ---disable_query_log -SELECT '-------- switch to slave -------' as ""; ---enable_query_log -connection slave; -SELECT user FROM mysql.user WHERE user = 'user1'; -connection master; - -let $my_stmt= RENAME USER user1@localhost TO rename1@localhost; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SELECT user FROM mysql.user WHERE user = 'rename1'; ---disable_query_log -SELECT '-------- switch to slave -------' as ""; ---enable_query_log -connection slave; -SELECT user FROM mysql.user WHERE user = 'rename1'; -connection master; - -let $my_stmt= DROP USER rename1@localhost; -let $my_master_commit= true; -let $my_slave_commit= true; ---source include/rpl_stmt_seq.inc -SELECT user FROM mysql.user WHERE user = 'rename1'; ---disable_query_log -SELECT '-------- switch to slave -------' as ""; ---enable_query_log -connection slave; -SELECT user FROM mysql.user WHERE user = 'rename1'; -connection master; - -############################################################### -# Cleanup -############################################################### ---disable_warnings -DROP DATABASE IF EXISTS mysqltest1; -DROP DATABASE IF EXISTS mysqltest2; -DROP DATABASE IF EXISTS mysqltest3; ---enable_warnings - - diff --git a/mysql-test/t/rpl_deadlock-slave.opt b/mysql-test/t/rpl_deadlock-slave.opt deleted file mode 100644 index f4a8c640458..00000000000 --- a/mysql-test/t/rpl_deadlock-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb --loose-innodb_lock_wait_timeout=4 --slave-transaction-retries=2 --max-relay-log-size=4096 diff --git a/mysql-test/t/rpl_deadlock.test b/mysql-test/t/rpl_deadlock.test deleted file mode 100644 index db2a7ec3a8d..00000000000 --- a/mysql-test/t/rpl_deadlock.test +++ /dev/null @@ -1,124 +0,0 @@ -# See if slave restarts the transaction after failing on an InnoDB deadlock error. - -# Note: testing what happens when too many retries is possible, but -# needs large waits when running with --debug, so we don't do it. -# The same way, this test may not test what is expected when run -# under Valgrind, timings are too short then (with --valgrind I -# (Guilhem) have seen the test manage to provoke lock wait timeout -# error but not deadlock error; that is ok as code deals with the two -# errors in exactly the same way. -# We don't 'show status like 'slave_retried_transactions'' because this -# is not repeatable (depends on sleeps). - -source include/have_innodb.inc; -source include/master-slave.inc; - -connection master; -create table t1 (a int not null, key(a)) engine=innodb; -create table t2 (a int not null, key(a)) engine=innodb; -# requiring 'unique' for the timeout part of the test -create table t3 (a int unique) engine=innodb; -create table t4 (a int) engine=innodb; -show variables like 'slave_transaction_retries'; -sync_slave_with_master; - -show create table t1; -show create table t2; -show variables like 'slave_transaction_retries'; -stop slave; - -# 1) Test deadlock - -connection master; -begin; -# Let's keep BEGIN and the locked statement in two different relay logs. -let $1=200;disable_query_log; -while ($1) -{ - eval insert into t3 values( $1 ); - dec $1; -} -enable_query_log; -insert into t3 select * from t2 for update; -insert into t1 values(1); -commit; -save_master_pos; - -connection slave; -begin; -# Let's make our transaction large so that it's slave who is chosen as -# victim -let $1=1000; -disable_query_log; -while ($1) -{ - eval insert into t4 values( $1 ); - dec $1; -} -enable_query_log; -select * from t1 for update; -start slave; ---real_sleep 3 # hope that slave is blocked now -insert into t2 values(201); # provoke deadlock, slave should be victim -commit; -sync_with_master; -select * from t1; # check that slave succeeded finally -select * from t2; -# check that no error is reported ---replace_column 1 # 8 # 9 # 23 # 33 # ---replace_result $MASTER_MYPORT MASTER_MYPORT ---vertical_results -show slave status; ---horizontal_results - -# 2) Test lock wait timeout - -stop slave; -delete from t3; -change master to master_log_pos=539; # the BEGIN log event -begin; -select * from t2 for update; # hold lock -start slave; ---real_sleep 10 # slave should have blocked, and be retrying -select count(*) from t3 /* must be zero */; # replaying begins after rollback -commit; -sync_with_master; -select * from t1; # check that slave succeeded finally -select * from t2; -# check that no error is reported ---replace_column 1 # 8 # 9 # 11 # 23 # 33 # ---replace_result $MASTER_MYPORT MASTER_MYPORT ---vertical_results -show slave status; ---horizontal_results - -# Now we repeat 2), but with BEGIN in the same relay log as -# COMMIT (to see if seeking into hot log is ok). -set @my_max_relay_log_size= @@global.max_relay_log_size; -set global max_relay_log_size=0; - -# This is really copy-paste of 2) of above -stop slave; -delete from t3; -change master to master_log_pos=539; -begin; -select * from t2 for update; -start slave; ---real_sleep 10 -select count(*) from t3 /* must be zero */; # replaying begins after rollback -commit; -sync_with_master; -select * from t1; -select * from t2; ---replace_column 1 # 8 # 9 # 11 # 23 # 33 # ---replace_result $MASTER_MYPORT MASTER_MYPORT ---vertical_results -show slave status; ---horizontal_results - -connection master; -drop table t1,t2,t3,t4; -sync_slave_with_master; -set global max_relay_log_size= @my_max_relay_log_size; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_delete_all.test b/mysql-test/t/rpl_delete_all.test deleted file mode 100644 index e0c0757bbc2..00000000000 --- a/mysql-test/t/rpl_delete_all.test +++ /dev/null @@ -1,43 +0,0 @@ -source include/master-slave.inc; - -connection slave; -create database mysqltest; -connection master; -drop database if exists mysqltest; -sync_slave_with_master; -# can't read dir ---replace_result "Errcode: 1" "Errcode: X" "Errcode: 2" "Errcode: X" \\ / ---error 1049 -show tables from mysqltest; - -connection slave; -create table t1 (a int); -connection master; -drop table if exists t1; -sync_slave_with_master; -# table does not exist ---error 1146 -select * from t1; - -connection master; -create table t1 (a int); -sync_slave_with_master; -insert into t1 values(1); -connection master; -delete from t1; -sync_slave_with_master; -select * from t1; - -insert into t1 values(1); -connection master; -insert into t1 values(2); -update t1 set a=2; -sync_slave_with_master; -select * from t1; - -# cleanup -connection master; -drop table t1; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_do_grant.test b/mysql-test/t/rpl_do_grant.test deleted file mode 100644 index 4a9c1554630..00000000000 --- a/mysql-test/t/rpl_do_grant.test +++ /dev/null @@ -1,64 +0,0 @@ -# Test that GRANT and SET PASSWORD are replicated to the slave - -source include/master-slave.inc; - -# do not be influenced by other tests. -connection master; -delete from mysql.user where user=_binary'rpl_do_grant'; -delete from mysql.db where user=_binary'rpl_do_grant'; -flush privileges; -save_master_pos; -connection slave; -sync_with_master; -# if these DELETE did nothing on the master, we need to do them manually on the -# slave. -delete from mysql.user where user=_binary'rpl_ignore_grant'; -delete from mysql.db where user=_binary'rpl_ignore_grant'; -flush privileges; - -# test replication of GRANT -connection master; -grant select on *.* to rpl_do_grant@localhost; -grant drop on test.* to rpl_do_grant@localhost; -save_master_pos; -connection slave; -sync_with_master; -show grants for rpl_do_grant@localhost; - -# test replication of SET PASSWORD -connection master; -set password for rpl_do_grant@localhost=password("does it work?"); -save_master_pos; -connection slave; -sync_with_master; -select password<>_binary'' from mysql.user where user=_binary'rpl_do_grant'; - -# -# Bug#24158 SET PASSWORD in binary log fails under ANSI_QUOTES -# -connection master; -update mysql.user set password='' where user='rpl_do_grant'; -flush privileges; -select password<>'' from mysql.user where user='rpl_do_grant'; -set sql_mode='ANSI_QUOTES'; -set password for rpl_do_grant@localhost=password('does it work?'); -set sql_mode=''; -save_master_pos; -connection slave; -sync_with_master; -select password<>'' from mysql.user where user='rpl_do_grant'; - - -# clear what we have done, to not influence other tests. -connection master; -delete from mysql.user where user=_binary'rpl_do_grant'; -delete from mysql.db where user=_binary'rpl_do_grant'; -flush privileges; -save_master_pos; -connection slave; -sync_with_master; -# no need to delete manually, as the DELETEs must have done some real job on -# master (updated binlog) -flush privileges; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_drop.test b/mysql-test/t/rpl_drop.test deleted file mode 100644 index ebb33c92a20..00000000000 --- a/mysql-test/t/rpl_drop.test +++ /dev/null @@ -1,14 +0,0 @@ -# Testcase for BUG#4552 (DROP on two tables, one of which does not -# exist, must be binlogged with a non-zero error code) -source include/master-slave.inc; ---disable_warnings -drop table if exists t1, t2; ---enable_warnings -create table t1 (a int); ---error 1051 -drop table t1, t2; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_drop_db.test b/mysql-test/t/rpl_drop_db.test deleted file mode 100644 index f14c9bc0164..00000000000 --- a/mysql-test/t/rpl_drop_db.test +++ /dev/null @@ -1,62 +0,0 @@ -# test case for BUG#4680 -- if there are extra files in the db directory -# dropping the db on the master causes replication problems - --- source include/master-slave.inc -connection master; - ---disable_warnings -drop database if exists mysqltest1; ---enable_warnings -create database mysqltest1; -create table mysqltest1.t1 (n int); -insert into mysqltest1.t1 values (1); -select * from mysqltest1.t1 into outfile 'mysqltest1/f1.txt'; -create table mysqltest1.t2 (n int); -create table mysqltest1.t3 (n int); ---replace_result \\ / ---error 1010 -drop database mysqltest1; -use mysqltest1; -show tables; - -# test the branch of the code that deals with the query buffer overflow - ---disable_query_log -let $1=50; -while ($1) -{ - eval create table mysqltest1.mysqltest_long_table_name$1 (n int); - dec $1; -} ---enable_query_log - ---replace_result \\ / ---error 1010 -drop database mysqltest1; -use mysqltest1; -show tables; -use test; -create table t1 (n int); -insert into t1 values (1234); -sync_slave_with_master; - -connection slave; -use mysqltest1; -show tables; -use test; -select * from t1; - -connection master; -drop table t1; -sync_slave_with_master; - -#cleanup -connection slave; -stop slave; -drop database mysqltest1; - -connection master; -# Remove the "extra" file created above ---remove_file $MYSQLTEST_VARDIR/master-data/mysqltest1/f1.txt -drop database mysqltest1; - diff --git a/mysql-test/t/rpl_drop_if_exists.test b/mysql-test/t/rpl_drop_if_exists.test deleted file mode 100644 index a042fa8caff..00000000000 --- a/mysql-test/t/rpl_drop_if_exists.test +++ /dev/null @@ -1,77 +0,0 @@ -# BUG#13684: -# SP: DROP PROCEDURE|FUNCTION IF EXISTS not binlogged if routine -# does not exist -# -# There is an inconsistency with DROP DATABASE IF EXISTS, DROP -# TABLE IF EXISTS and DROP VIEW IF EXISTS: those are binlogged even -# if the DB or TABLE does not exist, whereas DROP PROCEDURE IF -# EXISTS does not. It would be nice or at least consistent if DROP -# PROCEDURE/STATEMENT worked the same too. -# -# Description: -# DROP PROCEDURE|FUNCTION IF EXISTS does not get binlogged whereas DROP -# DATABASE|TABLE|TRIGGER|... IF EXISTS do. -# -# Fixed DROP PROCEDURE|FUNCTION IF EXISTS by adding a call to -# mysql_bin_log.write in mysql_execute_command. Checked also if all -# documented "DROP (...) IF EXISTS" get binlogged. -# -# Test is implemented as follows: -# -# i) test each "drop if exists" (DDL) -# ii) show binlog events; -# iii) create an object for each drop if exists statement; -# iv) issue "drop if exists" in existent objects. -# v) show binlog events; -# - ---source include/have_log_bin.inc -RESET MASTER; - -disable_warnings; - -# test all "drop if exists" in manual with inexistent objects -DROP PROCEDURE IF EXISTS db_bug_13684.p; -DROP FUNCTION IF EXISTS db_bug_13684.f; -DROP TRIGGER IF EXISTS db_bug_13684.tr; -DROP VIEW IF EXISTS db_bug_13684.v; -DROP TABLE IF EXISTS db_bug_13684.t; -DROP DATABASE IF EXISTS db_bug_13684; - ---source include/show_binlog_events.inc - -# test drop with existing values - -# create -CREATE DATABASE db_bug_13684; - -CREATE TABLE db_bug_13684.t (a int); - -CREATE VIEW db_bug_13684.v - AS SELECT * FROM db_bug_13684.t; - -CREATE TRIGGER db_bug_13684.tr BEFORE INSERT ON db_bug_13684.t - FOR EACH ROW BEGIN - END; - -CREATE PROCEDURE db_bug_13684.p (OUT p1 INT) - BEGIN - END; - -CREATE FUNCTION db_bug_13684.f (s CHAR(20)) - RETURNS CHAR(50) DETERMINISTIC - RETURN s; - ---source include/show_binlog_events.inc - -# drop existing -DROP PROCEDURE IF EXISTS db_bug_13684.p; -DROP FUNCTION IF EXISTS db_bug_13684.f; -DROP TRIGGER IF EXISTS db_bug_13684.tr; -DROP VIEW IF EXISTS db_bug_13684.v; -DROP TABLE IF EXISTS db_bug_13684.t; -DROP DATABASE IF EXISTS db_bug_13684; - ---source include/show_binlog_events.inc - -enable_warnings; diff --git a/mysql-test/t/rpl_drop_temp-slave.opt b/mysql-test/t/rpl_drop_temp-slave.opt deleted file mode 100644 index 2f9244c65ff..00000000000 --- a/mysql-test/t/rpl_drop_temp-slave.opt +++ /dev/null @@ -1,2 +0,0 @@ ---replicate-ignore-table=mysqltest.t2 - diff --git a/mysql-test/t/rpl_drop_temp.test b/mysql-test/t/rpl_drop_temp.test deleted file mode 100644 index c22bcbe63d0..00000000000 --- a/mysql-test/t/rpl_drop_temp.test +++ /dev/null @@ -1,24 +0,0 @@ -source include/master-slave.inc; ---disable_warnings -create database if not exists mysqltest; ---enable_warnings - -connect (con_temp,127.0.0.1,root,,test,$MASTER_MYPORT,); - -connection con_temp; -use mysqltest; -create temporary table mysqltest.t1 (n int); -create temporary table mysqltest.t2 (n int); -select get_lock("con_temp",10); - -connection master; -disconnect con_temp; -select get_lock("con_temp",10); -sync_slave_with_master; - -connection slave; -show status like 'Slave_open_temp_tables'; -connection master; -drop database mysqltest; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_drop_view.test b/mysql-test/t/rpl_drop_view.test deleted file mode 100644 index 8d826b8214d..00000000000 --- a/mysql-test/t/rpl_drop_view.test +++ /dev/null @@ -1,31 +0,0 @@ -# test case for bug#30998 -# Drop View breaks replication if view does not exist -# - -source include/master-slave.inc; ---disable_warnings -drop table if exists t1, t2; -drop view if exists v1, v2, v3, not_exist_view; ---enable_warnings -create table t1 (a int); -create table t2 (b int); -create table t3 (c int); -create view v1 as select * from t1; -create view v2 as select * from t2; -create view v3 as select * from t3; ---error 1051 -drop view not_exist_view; ---error 1051 -drop view v1, not_exist_view; ---error 1146 -select * from v1; -drop view v2, v3; -save_master_pos; -connection slave; -sync_with_master; ---error 1146 -select * from v1; ---error 1146 -select * from v2; ---error 1146 -select * from v3; diff --git a/mysql-test/t/rpl_dual_pos_advance-slave.opt b/mysql-test/t/rpl_dual_pos_advance-slave.opt deleted file mode 100644 index 627becdbfb5..00000000000 --- a/mysql-test/t/rpl_dual_pos_advance-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb diff --git a/mysql-test/t/rpl_dual_pos_advance.test b/mysql-test/t/rpl_dual_pos_advance.test deleted file mode 100644 index 6a3cf9e4f97..00000000000 --- a/mysql-test/t/rpl_dual_pos_advance.test +++ /dev/null @@ -1,122 +0,0 @@ -# This test checks that in a dual-head setup -# A->B->A, where A has --log-slave-updates (why would it? -# assume that there is a C as slave of A), -# then the Exec_master_log_pos of SHOW SLAVE STATUS does -# not stay too low on B(BUG#13023 due to events ignored because -# of their server id). -# It also will test BUG#13861. - -source include/master-slave.inc; -source include/have_innodb.inc; - - -# set up "dual head" - -connection slave; -reset master; - -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval change master to master_host="127.0.0.1",master_port=$SLAVE_MYPORT,master_user="root"; - -start slave; - -# now we test it - -connection slave; - -create table t1 (n int); - -save_master_pos; -connection master; -sync_with_master; - -# -# BUG#13861 - START SLAVE UNTIL may stop 1 evnt too late if -# log-slave-updates and circul repl -# -stop slave; - -create table t2 (n int); # create one ignored event - -save_master_pos; -connection slave; -sync_with_master; - -connection slave; - -show tables; - -save_master_pos; - -create table t3 (n int) engine=innodb; -set @a=1; -insert into t3 values(@a); -begin; -insert into t3 values(2); -insert into t3 values(3); -commit; -insert into t3 values(4); - - -connection master; - -# bug is that START SLAVE UNTIL may stop too late, we test that by -# asking it to stop before creation of t3. - -start slave until master_log_file="slave-bin.000001",master_log_pos=195; -wait_for_slave_to_stop; - -# then BUG#13861 causes t3 to show up below (because stopped too -# late). - -show tables; - -# ensure that we do not break set @a=1; insert into t3 values(@a); -start slave until master_log_file="slave-bin.000001",master_log_pos=438; -wait_for_slave_to_stop; -select * from t3; - -# ensure that we do not break transaction -start slave until master_log_file="slave-bin.000001",master_log_pos=663; -wait_for_slave_to_stop; -select * from t3; - -start slave; - -# BUG#13023 is that Exec_master_log_pos may stay too low "forever": - -connection master; - -create table t4 (n int); # create 3 ignored events -create table t5 (n int); -create table t6 (n int); - -save_master_pos; -connection slave; -sync_with_master; - -connection slave; - -save_master_pos; - -connection master; - -# then BUG#13023 caused hang below ("master" looks behind, while it's -# not in terms of updates done). - -sync_with_master; - -show tables; - -# cleanup - -stop slave; -reset slave; -drop table t1,t2,t3,t4,t5,t6; - -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_empty_master_crash-master.opt b/mysql-test/t/rpl_empty_master_crash-master.opt deleted file mode 100644 index cef79bc8585..00000000000 --- a/mysql-test/t/rpl_empty_master_crash-master.opt +++ /dev/null @@ -1 +0,0 @@ ---force-restart diff --git a/mysql-test/t/rpl_empty_master_crash.test b/mysql-test/t/rpl_empty_master_crash.test deleted file mode 100644 index 5f26bedc9fe..00000000000 --- a/mysql-test/t/rpl_empty_master_crash.test +++ /dev/null @@ -1,15 +0,0 @@ -source include/master-slave.inc; - ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -# -# Load table should not succeed on the master as this is not a slave -# ---error 1218 -load table t1 from master; -connection slave; ---error 1188 -load table t1 from master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_error_ignored_table-slave.opt b/mysql-test/t/rpl_error_ignored_table-slave.opt deleted file mode 100644 index cb49119bfcb..00000000000 --- a/mysql-test/t/rpl_error_ignored_table-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-ignore-table=test.t1 --replicate-ignore-table=test.t2 --replicate-ignore-table=test.t3 diff --git a/mysql-test/t/rpl_error_ignored_table.test b/mysql-test/t/rpl_error_ignored_table.test deleted file mode 100644 index fbe3b93813f..00000000000 --- a/mysql-test/t/rpl_error_ignored_table.test +++ /dev/null @@ -1,60 +0,0 @@ -# Test for -# Bug #797: If a query is ignored on slave (replicate-ignore-table) the slave -# still checks that it has the same error as on the master. - -source include/master-slave.inc; -connection master; -create table t1 (a int primary key); -# generate an error that goes to the binlog ---error 1062 -insert into t1 values (1),(1); -save_master_pos; -connection slave; -# as the t1 table is ignored on the slave, the slave should be able to sync -sync_with_master; -# The port number is different when doing the release build with -# Do-compile, hence we have to replace the port number here accordingly ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; -# check that the table has been ignored, because otherwise the test is nonsense -show tables like 't1'; -connection master; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; - -# Now test that even critical errors (connection killed) -# are ignored if rules allow it. -# The "kill" idea was copied from rpl000001.test. - -connection master1; -select get_lock('crash_lock%20C', 10); - -connection master; -create table t2 (a int primary key); -insert into t2 values(1); -create table t3 (id int); -insert into t3 values(connection_id()); -send update t2 set a = a + 1 + get_lock('crash_lock%20C', 10); - -connection master1; -real_sleep 2; -select (@id := id) - id from t3; -kill @id; -drop table t2,t3; -connection master; ---error 0,1317,2013 -reap; -connection master1; ---replace_column 2 # 5 # -show binlog events from 98; -save_master_pos; -connection slave; -# SQL slave thread should not have stopped (because table of the killed -# query is in the ignore list). -sync_with_master; - -# End of 4.1 tests -# Adding comment for force manual merge 5.0 -> wl1012. delete me if needed diff --git a/mysql-test/t/rpl_failed_optimize-master.opt b/mysql-test/t/rpl_failed_optimize-master.opt deleted file mode 100644 index 3f82baff598..00000000000 --- a/mysql-test/t/rpl_failed_optimize-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-innodb-lock-wait-timeout=1 diff --git a/mysql-test/t/rpl_failed_optimize.test b/mysql-test/t/rpl_failed_optimize.test deleted file mode 100644 index 8c4698c0d9b..00000000000 --- a/mysql-test/t/rpl_failed_optimize.test +++ /dev/null @@ -1,23 +0,0 @@ -source include/have_innodb.inc; -source include/master-slave.inc; - -# -# BUG#5551 "Failed OPTIMIZE TABLE is logged to binary log" -# Replication should work when OPTIMIZE TABLE timeouts, and -# when OPTIMIZE TABLE is executed on a non-existing table -# - -CREATE TABLE t1 ( a int ) ENGINE=InnoDB; -BEGIN; -INSERT INTO t1 VALUES (1); - -connection master1; -OPTIMIZE TABLE t1; - -OPTIMIZE TABLE non_existing; -sync_slave_with_master; - -connection master; -drop table t1; -sync_slave_with_master; -# End of 4.1 tests diff --git a/mysql-test/t/rpl_filter_tables_not_exist-slave.opt b/mysql-test/t/rpl_filter_tables_not_exist-slave.opt deleted file mode 100644 index 42acd3ea33d..00000000000 --- a/mysql-test/t/rpl_filter_tables_not_exist-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-do-table=test.t1 --replicate-do-table=test.t2 --replicate-do-table=test.t3 --replicate-ignore-table=test.t4 --replicate-ignore-table=test.t5 --replicate-ignore-table=test.t6 diff --git a/mysql-test/t/rpl_filter_tables_not_exist.test b/mysql-test/t/rpl_filter_tables_not_exist.test deleted file mode 100644 index d1153e584c8..00000000000 --- a/mysql-test/t/rpl_filter_tables_not_exist.test +++ /dev/null @@ -1,206 +0,0 @@ -# Test evaluation of replication table filter rules -# -# ==== Purpose ==== -# -# Test if replication table filter rules are properly evaluated when -# some of the tables referenced by the multiple-table update do not -# exist on slave. -# -# ==== Method ==== -# -# Master creates tables t1, t2, t3, t4, t5, t6, t7, t8, t9 and the -# slave is started with the following replication table filter rules: -# -# --replicate-do-table=t1 -# --replicate-do-table=t2 -# --replicate-do-table=t3 -# -# and -# -# --replicate-ignore-table=t4 -# --replicate-ignore-table=t5 -# --replicate-ignore-table=t6 -# -# So the slave only replicate changes to tables t1, t2 and t3 and only -# these tables exist on slave. -# -# From now on, tables t1, t2, and t3 are referenced as do tables, -# tables t4, t5, t6 are referenced as ignore tables, and tables t7, -# t8, t9 are referenced as other tables. -# -# All multi-table update tests reference tables that are not do -# tables, which do not exist on slave. And the following situations -# of multi-table update will be tested: -# -# 1. Do tables are not referenced at all -# 2. Do tables are not referenced for update -# 3. Ignore tables are referenced for update before do tables -# 4. Only do tables are referenced for update -# 5. Do tables and other tables are referenced for update -# 6. Do tables are referenced for update before ignore tables -# -# For 1, 2 and 3, the statement should be ignored by slave, for 4, 5 -# and 6 the statement should be accepted by slave and cause an error -# because of non-exist tables. -# -# ==== Related bugs ==== -# -# BUG#37051 Replication rules not evaluated correctly - - -source include/master-slave.inc; - -# These tables are mentioned in do-table rules -CREATE TABLE t1 (id int, a int); -CREATE TABLE t2 (id int, b int); -CREATE TABLE t3 (id int, c int); - -# These tables are mentioned in ignore-table rules -CREATE TABLE t4 (id int, d int); -CREATE TABLE t5 (id int, e int); -CREATE TABLE t6 (id int, f int); - -# These tables are not mentioned in do-table or ignore-table rules -CREATE TABLE t7 (id int, g int); -CREATE TABLE t8 (id int, h int); -CREATE TABLE t9 (id int, i int); - -INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); -INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3); -INSERT INTO t3 VALUES (1, 1), (2, 2), (3, 3); - -INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3); -INSERT INTO t5 VALUES (1, 1), (2, 2), (3, 3); -INSERT INTO t6 VALUES (1, 1), (2, 2), (3, 3); - -INSERT INTO t7 VALUES (1, 1), (2, 2), (3, 3); -INSERT INTO t8 VALUES (1, 1), (2, 2), (3, 3); -INSERT INTO t9 VALUES (1, 1), (2, 2), (3, 3); - -# Only t1, t2, t3 should be replicated to slave -sync_slave_with_master; -echo [on slave]; -SHOW TABLES LIKE 't%'; - -connection master; -echo [on master]; - -# -# Do tables are not referenced, these statements should be ignored by -# slave. -# -UPDATE t7 LEFT JOIN t4 ON (t4.id=t7.id) SET d=0, g=0 where t7.id=1; -UPDATE t7 LEFT JOIN (t4, t5, t6) ON (t7.id=t4.id and t7.id=t5.id and t7.id=t6.id) SET d=0, e=0, f=0, g=0 where t7.id=1; -UPDATE t4 LEFT JOIN (t7, t8, t9) ON (t4.id=t7.id and t4.id=t8.id and t4.id=t9.id) SET d=0, g=0, h=0, i=0 where t4.id=1; -UPDATE t7 LEFT JOIN (t8, t9) ON (t7.id=t8.id and t7.id=t9.id) SET g=0, h=0, i=0 where t7.id=1; - -# -# Do tables are not referenced for update, these statements should be -# ignored by slave. -# -UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET d=0 where t1.id=1; -UPDATE t1 LEFT JOIN t7 ON (t1.id=t7.id) SET g=0 where t1.id=1; -UPDATE t1 LEFT JOIN (t4, t5, t6) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t6.id) SET d=0, e=0, f=0 where t1.id=1; -UPDATE t1 LEFT JOIN (t4, t5, t8) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t8.id) SET d=0, e=0, h=0 where t1.id=1; -UPDATE t1 LEFT JOIN (t7, t8, t5) ON (t1.id=t7.id and t1.id=t8.id and t1.id=t5.id) SET g=0, h=0, e=0 where t1.id=1; -UPDATE t1 LEFT JOIN (t2, t3, t5) ON (t1.id=t2.id and t1.id=t3.id and t1.id=t5.id) SET e=0 where t1.id=1; - -# -# Ignore tables are referenced for update before do tables, these -# statements should be ignore by slave. -# -UPDATE t4 LEFT JOIN t1 ON (t1.id=t4.id) SET a=0, d=0 where t4.id=1; -UPDATE t4 LEFT JOIN (t1, t7) ON (t4.id=t1.id and t7.id=t4.id) SET a = 0, d=0, g=0 where t4.id=1; -UPDATE t4 LEFT JOIN (t1, t2, t3) ON (t1.id=t4.id and t2.id=t4.id and t3.id=t4.id) SET a=0, b=0, c=0, d=0 where t4.id=1; -UPDATE t4 LEFT JOIN (t1, t2, t5) ON (t1.id=t4.id and t2.id=t4.id and t5.id=t4.id) SET a=0, b=0, e=0, d=0 where t4.id=1; -UPDATE t4 LEFT JOIN (t1, t6, t7) ON (t4.id=t1.id and t4.id=t6.id and t4.id=t7.id) SET a=0, d=0, f=0, g=0 where t4.id=1; -UPDATE t7 LEFT JOIN (t4, t1, t2) ON (t7.id=t4.id and t7.id=t1.id and t7.id=t2.id) SET a=0, b=0, d=0, g=0 where t7.id=1; -UPDATE t7 LEFT JOIN (t8, t4, t1) ON (t7.id=t8.id and t7.id=t4.id and t7.id=t1.id) SET a=0, d=0, g=0, h=0 where t7.id=1; - -# Sync slave to make sure all above statements are correctly ignored, -# if any of the above statement are not ignored, it would cause error -# and stop slave sql thread. -sync_slave_with_master; -connection master; - -# Parameters for include/wait_for_slave_sql_error_and_skip.inc: -# Ask it to show SQL error message. -let $show_sql_error= 1; -# The expected error will always be 1146 (ER_NO_SUCH_TABLE). -let $slave_sql_errno= 1146; - -# -# Only do tables are referenced for update, these statements should -# cause error on slave -# -UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET a=0 where t1.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t1 LEFT JOIN (t4, t7) ON (t1.id=t4.id and t1.id=t7.id) SET a=0 where t1.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t1 LEFT JOIN (t2, t4, t7) ON (t1.id=t2.id and t1.id=t4.id and t1.id=t7.id) SET a=0, b=0 where t1.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t1 LEFT JOIN (t2, t3, t7) ON (t1.id=t2.id and t1.id=t3.id and t1.id=t7.id) SET a=0, b=0, c=0 where t1.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -# -# Do tables and other tables are referenced for update, these -# statements should cause error on slave -# -UPDATE t1 LEFT JOIN t7 ON (t1.id=t7.id) SET a=0, g=0 where t1.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t7 LEFT JOIN t1 ON (t1.id=t7.id) SET a=0, g=0 where t7.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t1 LEFT JOIN (t4, t5, t7) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t7.id) SET a=0, g=0 where t1.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t1 LEFT JOIN (t4, t7, t8) ON (t1.id=t4.id and t1.id=t7.id and t1.id=t8.id) SET a=0, g=0 where t1.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t1 LEFT JOIN (t7, t8, t9) ON (t1.id=t7.id and t1.id=t8.id and t1.id=t9.id) SET a=0, g=0, h=0, i=0 where t1.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t7 LEFT JOIN (t1, t2, t3) ON (t7.id=t1.id and t7.id=t2.id and t7.id=t3.id) SET g=0, a=0, b=0, c=0 where t7.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t7 LEFT JOIN (t4, t5, t3) ON (t7.id=t4.id and t7.id=t5.id and t7.id=t3.id) SET g=0, c=0 where t7.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t7 LEFT JOIN (t8, t9, t3) ON (t7.id=t8.id and t7.id=t9.id and t7.id=t3.id) SET g=0, h=0, i=0, c=0 where t7.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -# -# Do tables are referenced for update before ignore tables -# -UPDATE t1 LEFT JOIN t4 ON (t1.id=t4.id) SET a=0, d=0 where t1.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t1 LEFT JOIN (t4, t5, t6) ON (t1.id=t4.id and t1.id=t5.id and t1.id=t6.id) SET a=0, d=0, e=0, f=0 where t1.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t4 LEFT JOIN (t1, t5, t6) ON (t4.id=t1.id and t4.id=t5.id and t4.id=t6.id) SET a=0, e=0, f=0 where t4.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -UPDATE t7 LEFT JOIN (t1, t4, t2) ON (t7.id=t1.id and t7.id=t4.id and t7.id=t2.id) SET a=0, b=0, d=0, g=0 where t7.id=1; -source include/wait_for_slave_sql_error_and_skip.inc; - -sync_slave_with_master; -echo [on slave]; - -# We should only have tables t1, t2, t3 on slave -show tables like 't%'; - -# The rows in these tables should remain untouched -SELECT * FROM t1; -SELECT * FROM t2; -SELECT * FROM t3; - -# Clean up -connection master; -echo [on master]; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -source include/master-slave-end.inc; diff --git a/mysql-test/t/rpl_flush_log_loop-master.opt b/mysql-test/t/rpl_flush_log_loop-master.opt deleted file mode 100644 index a4d1d403dc9..00000000000 --- a/mysql-test/t/rpl_flush_log_loop-master.opt +++ /dev/null @@ -1 +0,0 @@ --O max_binlog_size=1M --relay-log=$MYSQLTEST_VARDIR/master-data/relay-log diff --git a/mysql-test/t/rpl_flush_log_loop-master.sh b/mysql-test/t/rpl_flush_log_loop-master.sh deleted file mode 100755 index a321dd690cd..00000000000 --- a/mysql-test/t/rpl_flush_log_loop-master.sh +++ /dev/null @@ -1,5 +0,0 @@ -rm -f $MYSQLTEST_VARDIR/slave-data/*-bin.* -rm -f $MYSQLTEST_VARDIR/slave-data/master.info -rm -f $MYSQLTEST_VARDIR/slave-data/*.index - - diff --git a/mysql-test/t/rpl_flush_log_loop-slave.opt b/mysql-test/t/rpl_flush_log_loop-slave.opt deleted file mode 100644 index 95839c831c9..00000000000 --- a/mysql-test/t/rpl_flush_log_loop-slave.opt +++ /dev/null @@ -1 +0,0 @@ --O max_binlog_size=1M --relay-log=$MYSQLTEST_VARDIR/slave-data/relay-log diff --git a/mysql-test/t/rpl_flush_log_loop-slave.sh b/mysql-test/t/rpl_flush_log_loop-slave.sh deleted file mode 100755 index e46ea6d400b..00000000000 --- a/mysql-test/t/rpl_flush_log_loop-slave.sh +++ /dev/null @@ -1,4 +0,0 @@ -rm -f $MYSQLTEST_VARDIR/master-data/master.info -rm -f $MYSQLTEST_VARDIR/master-data/*-bin.* -rm -f $MYSQLTEST_VARDIR/master-data/*.index - diff --git a/mysql-test/t/rpl_flush_log_loop.test b/mysql-test/t/rpl_flush_log_loop.test deleted file mode 100644 index c3707372e08..00000000000 --- a/mysql-test/t/rpl_flush_log_loop.test +++ /dev/null @@ -1,38 +0,0 @@ -# Testing if "flush logs" command bouncing resulting in logs created in a loop -# in case of bi-directional replication - -source include/master-slave.inc; - ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -show variables like 'relay_log%'; - -connection slave; -stop slave; ---replace_result $MASTER_MYPORT MASTER_PORT -eval change master to master_host='127.0.0.1',master_user='root', - master_password='',master_port=$MASTER_MYPORT; -start slave; - -connection master; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval change master to master_host='127.0.0.1',master_user='root', - master_password='',master_port=$SLAVE_MYPORT; -start slave; ---source include/wait_for_slave_to_start.inc - -# Calculate file name of relay log after flush logs -let $relay_file= query_get_value(show slave status, Relay_Log_File,1); -let $relay_name= `select substring_index('$relay_file','.',1);`; -let $relay_index= `select substring_index('$relay_file','.',-1);`; -let $relay_index_len= `select length(substring_index('$relay_file','.',-1));`; -let $relay_index_next=`select $relay_index+1`; -let $relay_file=`select concat('$relay_name','.',repeat('0',($relay_index_len-length($relay_index_next))),$relay_index_next);`; -flush logs; -let $slave_param= Relay_Log_File; -let $slave_param_value= $relay_file; -source include/wait_for_slave_param.inc; ---replace_result $SLAVE_MYPORT SLAVE_PORT $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 16 # 23 # 33 # 34 # 35 # ---query_vertical show slave status - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_flush_tables.test b/mysql-test/t/rpl_flush_tables.test deleted file mode 100644 index f7c8774286a..00000000000 --- a/mysql-test/t/rpl_flush_tables.test +++ /dev/null @@ -1,58 +0,0 @@ -# -# Test of replicating FLUSH TABLES to make -# RENAME TABLE work with MERGE tables on the slave. -# Test of FLUSH NO_WRITE_TO_BINLOG by the way. -# ---source include/master-slave.inc -# Skipped on Windows because it can't handle a table underlying an open -# merge table getting renamed. ---source include/not_windows.inc - -let $SERVER_VERSION=`select version()`; - -create table t1 (a int); -insert into t1 values (10); -create table t2 (a int); -create table t3 (a int) engine=merge union(t1); -create table t4 (a int); -# We force the slave to open t3 (because we want to try confusing him) with this : -insert into t4 select * from t3; -rename table t1 to t5, t2 to t1; -# RENAME may have confused the master (this is a known bug): so FLUSH tables, -# first don't write it to the binlog, to test the NO_WRITE_TO_BINLOG keyword. -flush no_write_to_binlog tables; -# Check that it's not in the binlog. ---replace_result $SERVER_VERSION SERVER_VERSION ---replace_column 2 # 5 # -show binlog events; -# Check that the master is not confused. -select * from t3; -# This FLUSH should go into the binlog to not confuse the slave. -flush tables; -# Check that it's in the binlog. ---replace_result $SERVER_VERSION SERVER_VERSION ---replace_column 2 # 5 # -show binlog events; -save_master_pos; -connection slave; -sync_with_master; -# Check that the slave is not confused. -select * from t3; -# Note that all this confusion may cause warnings 'table xx is open on rename' -# in the .err files; these are not fatal and are not reported by mysql-test-run. - -stop slave; -connection master; -drop table t1; -connection slave; -flush tables with read lock; -start slave; -sleep 1; ---error 1192 -stop slave; - -connection master; -drop table t3, t4, t5; - -# End of 4.1 tests -# Adding comment for force manual merge 5.0 -> wl1012. Delete me if needed. diff --git a/mysql-test/t/rpl_free_items-slave.opt b/mysql-test/t/rpl_free_items-slave.opt deleted file mode 100644 index b828d03fafb..00000000000 --- a/mysql-test/t/rpl_free_items-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-wild-ignore-table=test.% diff --git a/mysql-test/t/rpl_free_items.test b/mysql-test/t/rpl_free_items.test deleted file mode 100644 index 043e84160b8..00000000000 --- a/mysql-test/t/rpl_free_items.test +++ /dev/null @@ -1,22 +0,0 @@ -source include/master-slave.inc; -create table t1 (a int); -create table t2 (a int); -disable_query_log; -SET @query="INSERT INTO t2 SELECT * FROM t1 WHERE a REGEXP \"0\""; -let $1 = 2000; -while ($1) -{ - eval SET @query=concat(@query, " OR a REGEXP '$1'"); - dec $1; -} -let $1=`select @query`; -eval $1; -enable_query_log; -# I have seen the slave crash either now or at shutdown -sync_slave_with_master; -connection master; -drop table t1; -drop table t2; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_get_lock.test b/mysql-test/t/rpl_get_lock.test deleted file mode 100644 index 945bd98c993..00000000000 --- a/mysql-test/t/rpl_get_lock.test +++ /dev/null @@ -1,43 +0,0 @@ -source include/master-slave.inc; - -create table t1(n int); -insert into t1 values(get_lock("lock",2)); -dirty_close master; -connection master1; -select get_lock("lock",2); - -select release_lock("lock"); -#ignore -disable_query_log; -let $1=2000; -while ($1) -{ - do get_lock("lock",2); - do release_lock("lock"); - dec $1; -} -enable_query_log; -save_master_pos; -connection slave; -sync_with_master; -select get_lock("lock",3); -select * from t1; -# There is no point in testing REPLICATIION of the IS_*_LOCK -# functions; slave does not run with the same concurrency context as -# master (generally in slave we can't know that on master this lock -# was already held by another connection and so that the the -# get_lock() we're replicating timed out on master hence returned 0, -# or that the is_free_lock() we're playing returned 0 etc. -# But here all we do is test these functions outside of replication. -select is_free_lock("lock"), is_used_lock("lock") = connection_id(); -explain extended select is_free_lock("lock"), is_used_lock("lock"); -# Check lock functions -select is_free_lock("lock2"); -select is_free_lock(NULL); -connection master1; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_grant.test b/mysql-test/t/rpl_grant.test deleted file mode 100644 index dbb5c624f2b..00000000000 --- a/mysql-test/t/rpl_grant.test +++ /dev/null @@ -1,42 +0,0 @@ -# Tests of grants and users - -source include/master-slave.inc; -source include/not_embedded.inc; - ---echo **** On Master **** -connection master; - -CREATE USER dummy@localhost; -CREATE USER dummy1@localhost, dummy2@localhost; - -SELECT user, host FROM mysql.user WHERE user != 'root'; # root host non-determ -SELECT COUNT(*) FROM mysql.user WHERE user != 'root' or (host != 'localhost' and host != @hostname); -sync_slave_with_master; ---echo **** On Slave **** -SELECT user,host FROM mysql.user WHERE user != 'root'; # root host non-determ -SELECT COUNT(*) FROM mysql.user WHERE user != 'root' or (host != 'localhost' and host != @hostname); - ---echo **** On Master **** -connection master; - -# No user exists -error ER_CANNOT_USER; -DROP USER nonexisting@localhost; - -# At least one user exists, but not all -error ER_CANNOT_USER; -DROP USER nonexisting@localhost, dummy@localhost; - -# All users exist -DROP USER dummy1@localhost, dummy2@localhost; - -SELECT user, host FROM mysql.user WHERE user != 'root'; # root host non-determ -SELECT COUNT(*) FROM mysql.user WHERE user != 'root' or (host != 'localhost' and host != @hostname); -sync_slave_with_master; ---echo **** On Slave **** -SELECT user,host FROM mysql.user WHERE user != 'root'; # root host non-determ -SELECT COUNT(*) FROM mysql.user WHERE user != 'root' or (host != 'localhost' and host != @hostname); - ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -query_vertical SHOW SLAVE STATUS; diff --git a/mysql-test/t/rpl_ignore_grant-slave.opt b/mysql-test/t/rpl_ignore_grant-slave.opt deleted file mode 100644 index e931bfbd37e..00000000000 --- a/mysql-test/t/rpl_ignore_grant-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-wild-ignore-table=mysql.% diff --git a/mysql-test/t/rpl_ignore_grant.test b/mysql-test/t/rpl_ignore_grant.test deleted file mode 100644 index 2e6e2ce9a31..00000000000 --- a/mysql-test/t/rpl_ignore_grant.test +++ /dev/null @@ -1,59 +0,0 @@ -# Test that GRANT is not replicated to the slave -# when --replicate-wild-ignore-table=mysql.% -# In BUG#980, this test would _randomly_ fail. - -source include/master-slave.inc; - -# do not be influenced by other tests. -connection master; -delete from mysql.user where user=_binary'rpl_ignore_grant'; -delete from mysql.db where user=_binary'rpl_ignore_grant'; -flush privileges; -save_master_pos; -connection slave; -sync_with_master; -# as these DELETE were not replicated, we need to do them manually on the -# slave. -delete from mysql.user where user=_binary'rpl_ignore_grant'; -delete from mysql.db where user=_binary'rpl_ignore_grant'; -flush privileges; - -# test non-replication of GRANT -connection master; -grant select on *.* to rpl_ignore_grant@localhost; -grant drop on test.* to rpl_ignore_grant@localhost; -show grants for rpl_ignore_grant@localhost; -save_master_pos; -connection slave; -sync_with_master; ---error 1141 #("no such grant for user") -show grants for rpl_ignore_grant@localhost; -# check it another way -select count(*) from mysql.user where user=_binary'rpl_ignore_grant'; -select count(*) from mysql.db where user=_binary'rpl_ignore_grant'; - -# test non-replication of SET PASSWORD -# first force creation of the user on slave (because as the user does not exist -# on slave, the SET PASSWORD may be replicated but silently do nothing; this is -# not what we want; we want it to be not-replicated). -grant select on *.* to rpl_ignore_grant@localhost; -connection master; -set password for rpl_ignore_grant@localhost=password("does it work?"); -save_master_pos; -connection slave; -sync_with_master; -select password<>_binary'' from mysql.user where user=_binary'rpl_ignore_grant'; - -# clear what we have done, to not influence other tests. -connection master; -delete from mysql.user where user=_binary'rpl_ignore_grant'; -delete from mysql.db where user=_binary'rpl_ignore_grant'; -flush privileges; -save_master_pos; -connection slave; -sync_with_master; -delete from mysql.user where user=_binary'rpl_ignore_grant'; -delete from mysql.db where user=_binary'rpl_ignore_grant'; -flush privileges; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_ignore_revoke-slave.opt b/mysql-test/t/rpl_ignore_revoke-slave.opt deleted file mode 100644 index e931bfbd37e..00000000000 --- a/mysql-test/t/rpl_ignore_revoke-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-wild-ignore-table=mysql.% diff --git a/mysql-test/t/rpl_ignore_revoke.test b/mysql-test/t/rpl_ignore_revoke.test deleted file mode 100644 index 00171605a92..00000000000 --- a/mysql-test/t/rpl_ignore_revoke.test +++ /dev/null @@ -1,51 +0,0 @@ -# test verifies that REVOKE must not be replicated when -# slave server starts with --replicate-wild-ignore-table=mysql.% -# the option is set in rpl_ignore_revoke-slave.opt -# The first part of BUG#9483 for GRANT is checked by -# existed specific rpl_ignore_grant test case (BUG#980) - - -source include/master-slave.inc; - -### CLEAN-UP: create an account and manually duplicate it on the slave - -connection master; -grant select on *.* to 'user_foo'@'%' identified by 'user_foopass'; -revoke select on *.* from 'user_foo'@'%'; -select select_priv from mysql.user where user='user_foo' /* master:must be N */; - -sync_slave_with_master; -#connection slave; -grant select on *.* to 'user_foo'@'%' identified by 'user_foopass'; -revoke select on *.* from 'user_foo'@'%'; -select select_priv from mysql.user where user='user_foo' /* slave:must be N */; - - -### TEST - -#connection slave; -grant select on *.* to 'user_foo'@'%' identified by 'user_foopass'; -select select_priv from mysql.user where user='user_foo' /* slave:must be Y */; - -connection master; -revoke select on *.* from 'user_foo'; -select select_priv from mysql.user where user='user_foo' /* master:must be N */; - -sync_slave_with_master; -#connection slave; -select select_priv from mysql.user where user='user_foo' /* slave:must get Y */; - -### CLEAN-UP - -connection slave; ---disable_abort_on_error -revoke select on *.* FROM 'user_foo'; ---enable_abort_on_error - -connection master; -delete from mysql.user where user="user_foo"; -sync_slave_with_master; - -# Since changes to mysql.* are ignored, the revoke need to -# be done on slave as well -delete from mysql.user where user="user_foo"; diff --git a/mysql-test/t/rpl_ignore_table-slave.opt b/mysql-test/t/rpl_ignore_table-slave.opt deleted file mode 100644 index 3aabbb2e0f5..00000000000 --- a/mysql-test/t/rpl_ignore_table-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-ignore-table=test.t1 --replicate-ignore-table=test.t2 --replicate-ignore-table=test.t3 --replicate-wild-ignore-table=%.tmptbl% diff --git a/mysql-test/t/rpl_ignore_table.test b/mysql-test/t/rpl_ignore_table.test deleted file mode 100644 index 79235f0cd4a..00000000000 --- a/mysql-test/t/rpl_ignore_table.test +++ /dev/null @@ -1,150 +0,0 @@ -source include/master-slave.inc; - -# -# BUG#16487 -# -# Requirement: -# Multi-updates on ignored tables should not fail even if the slave does -# not have the ignored tables. -# -# Note table t1, t2, and t3 are ignored in the option file to this test. -# - ---echo **** Test case for BUG#16487 **** ---echo **** Master **** -connection master; -CREATE TABLE test.t4 (a int); -CREATE TABLE test.t1 (a int); - -# Expect: The row must *not* by updated on slave, since t1 is ignored -UPDATE test.t4 NATURAL JOIN test.t1 SET t1.a=5; - ---echo **** Slave **** -sync_slave_with_master; -SELECT * FROM t4; - -connection master; -DROP TABLE t1; -DROP TABLE t4; - - -# -# Bug#25482 GRANT statements are not replicated if -# you use "replicate-ignore-table" -# - ---echo **** Test case for BUG#25482 **** ---echo **** Adding GRANTS on master **** - -connection master; -create table test.t1(a int); -create table test.t4(a int); - -# Simple user that should not replicate -GRANT SELECT ON test.t1 TO mysqltest1@localhost; - -# Partial replicate -GRANT INSERT ON test.t4 TO mysqltest2@localhost; -GRANT select, update, insert, references on t1 - to mysqltest2@localhost; - -# Partial replicate 2 -GRANT SELECT ON test.* TO mysqltest3@localhost; -GRANT INSERT ON test.t4 TO mysqltest3@localhost; -GRANT select(a), update(a), insert(a), references(a) on t4 - to mysqltest3@localhost; - -# Create another database and table -create database mysqltest2; -create table mysqltest2.t2 (id int); -# Create a grant that should replicate -GRANT SELECT ON mysqltest2.t2 TO mysqltest4@localhost IDENTIFIED BY 'pass'; - -# Create a grant manually -insert into mysql.user (user, host) values ("mysqltest5", "somehost"); - -# Partial replicate 3 with *.* -GRANT SELECT ON *.* TO mysqltest6@localhost; -GRANT INSERT ON *.* TO mysqltest6@localhost; -GRANT INSERT ON test.* TO mysqltest6@localhost; -GRANT INSERT ON test.t1 TO mysqltest6@localhost; - -show grants for mysqltest1@localhost; -show grants for mysqltest2@localhost; -show grants for mysqltest3@localhost; -show grants for mysqltest4@localhost; -show grants for mysqltest6@localhost; - -flush privileges; -show grants for mysqltest5@somehost; - - -sync_slave_with_master; - ---echo **** Checking grants on slave **** - -# Check that grants are replicated to slave -show grants for mysqltest2@localhost; -show grants for mysqltest3@localhost; -show grants for mysqltest4@localhost; -show grants for mysqltest5@somehost; -show grants for mysqltest6@localhost; - -# mysqltest1 should not be on slave ---error 1141 -show grants for mysqltest1@localhost; - ---echo **** Revoking grants on master **** -connection master; -REVOKE SELECT ON test.t1 FROM mysqltest1@localhost; -REVOKE SELECT ON mysqltest2.t2 FROM mysqltest4@localhost; -REVOKE select(a) on t4 - from mysqltest3@localhost; - -show grants for mysqltest1@localhost; -show grants for mysqltest3@localhost; -show grants for mysqltest4@localhost; - -sync_slave_with_master; - ---echo **** Checking grants on slave **** - -# mysqltest1 should not be on slave ---error 1141 -show grants for mysqltest1@localhost; -show grants for mysqltest3@localhost; -show grants for mysqltest4@localhost; - -# Cleanup -connection master; -drop table t1, t4, mysqltest2.t2; -drop database mysqltest2; -delete from mysql.user where user like "mysqltest%"; -delete from mysql.db where user like "mysqltest%"; -delete from mysql.tables_priv where user like "mysqltest%"; -delete from mysql.columns_priv where user like "mysqltest%"; -sync_slave_with_master; - -connection master; - -# -# bug#22877 replication character sets get out of sync -# using replicate-wild-ignore-table -# ---disable_warnings -DROP TABLE IF EXISTS t5; ---enable_warnings -CREATE TABLE t5 ( - word varchar(50) collate utf8_unicode_ci NOT NULL default '' -) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -SET @@session.character_set_client=33,@@session.collation_connection=192; -CREATE TEMPORARY TABLE tmptbl504451f4258$1 (id INT NOT NULL) ENGINE=MEMORY; -INSERT INTO t5 (word) VALUES ('TEST’'); -SELECT HEX(word) FROM t5; -sync_slave_with_master; -connection slave; -SELECT HEX(word) FROM t5; ---error 1146 -SELECT * FROM tmptbl504451f4258$1; -connection master; -DROP TABLE t5; diff --git a/mysql-test/t/rpl_init_slave-slave.opt b/mysql-test/t/rpl_init_slave-slave.opt deleted file mode 100644 index 337e8a60d97..00000000000 --- a/mysql-test/t/rpl_init_slave-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---init-slave="set global max_connections=500" diff --git a/mysql-test/t/rpl_init_slave.test b/mysql-test/t/rpl_init_slave.test deleted file mode 100644 index 139b4902e12..00000000000 --- a/mysql-test/t/rpl_init_slave.test +++ /dev/null @@ -1,34 +0,0 @@ -source include/master-slave.inc; - -# -# Test of init_slave variable -# - -save_master_pos; -connection slave; -sleep 1; -show variables like 'init_slave'; -show variables like 'max_connections'; -sync_with_master; -reset master; -connection master; -show variables like 'init_slave'; -show variables like 'max_connections'; -save_master_pos; -connection slave; -sync_with_master; -# Save variable value -set @my_global_init_connect= @@global.init_connect; -set global init_connect="set @c=1"; -show variables like 'init_connect'; -connection master; -save_master_pos; -connection slave; -sync_with_master; -stop slave; - -# Restore changed global variable -set global init_connect= @my_global_init_connect; -set global max_connections= default; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_innodb.test b/mysql-test/t/rpl_innodb.test deleted file mode 100644 index b88276e2107..00000000000 --- a/mysql-test/t/rpl_innodb.test +++ /dev/null @@ -1,48 +0,0 @@ -# File for specialities regarding replication from or to InnoDB -# tables. - -source include/master-slave.inc; -source include/have_innodb.inc; - -# -# Bug#11401: Load data infile 'REPLACE INTO' fails on slave. -# -connection master; -CREATE TABLE t4 ( - id INT(5) unsigned NOT NULL auto_increment, - name varchar(15) NOT NULL default '', - number varchar(35) NOT NULL default 'default', - PRIMARY KEY (id), - UNIQUE KEY unique_rec (name,number) -) ENGINE=InnoDB; - ---disable_warnings -LOAD DATA - INFILE '../std_data_ln/loaddata_pair.dat' - REPLACE INTO TABLE t4 - (name,number); ---enable_warnings -SELECT * FROM t4; - -sync_slave_with_master; -SELECT * FROM t4; - -connection master; ---disable_warnings -LOAD DATA - INFILE '../std_data_ln/loaddata_pair.dat' - REPLACE INTO TABLE t4 - (name,number); ---enable_warnings -SELECT * FROM t4; - -sync_slave_with_master; -SELECT * FROM t4; - -connection master; ---disable_query_log -DROP TABLE t4; ---enable_query_log -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_insert_delayed.test b/mysql-test/t/rpl_insert_delayed.test deleted file mode 100644 index 09e0c5cc2e9..00000000000 --- a/mysql-test/t/rpl_insert_delayed.test +++ /dev/null @@ -1,97 +0,0 @@ ---source include/master-slave.inc ---source include/not_embedded.inc ---source include/not_windows.inc - -connection master; - -let $binlog_format_statement=1; - -CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64)); - -sync_slave_with_master; - -# -# BUG#26116 "If multi-row INSERT DELAYED has errors, -# statement-based binlogging breaks"; -# happened only in statement-based binlogging. -# - -connection master; -truncate table t1; -# first scenario: duplicate on first row -insert delayed into t1 values(10, "my name"); -if ($binlog_format_statement) -{ - # statement below will be converted to non-delayed INSERT and so - # will stop at first error, guaranteeing replication. - --error ER_DUP_ENTRY - insert delayed into t1 values(10, "is Bond"), (20, "James Bond"); -} -if (!$binlog_format_statement) -{ - insert delayed into t1 values(10, "is Bond"), (20, "James Bond"); -} -flush table t1; # to wait for INSERT DELAYED to be done -select * from t1; -sync_slave_with_master; -# when bug existed in statement-based binlogging, t1 on slave had -# different content from on master -select * from t1; - -# second scenario: duplicate on second row -connection master; -delete from t1 where id!=10; -if ($binlog_format_statement) -{ - # statement below will be converted to non-delayed INSERT and so - # will be binlogged with its ER_DUP_ENTRY error code, guaranteeing - # replication (slave will hit the same error code and so be fine). - --error ER_DUP_ENTRY - insert delayed into t1 values(20, "is Bond"), (10, "James Bond"); -} -if (!$binlog_format_statement) -{ - insert delayed into t1 values(20, "is Bond"), (10, "James Bond"); -} -flush table t1; # to wait for INSERT DELAYED to be done -select * from t1; -sync_slave_with_master; -# when bug existed in statement-based binlogging, query was binlogged -# with error_code=0 so slave stopped -select * from t1; - -# clean up -connection master; -drop table t1; -sync_slave_with_master; -connection master; - -# -# Bug #29571: INSERT DELAYED IGNORE written to binary log on the master but -# on the slave -# -CREATE TABLE t1(a int, UNIQUE(a)); -INSERT DELAYED IGNORE INTO t1 VALUES(1); -INSERT DELAYED IGNORE INTO t1 VALUES(1); -flush table t1; # to wait for INSERT DELAYED to be done - -#must show two INSERT DELAYED ---replace_column 1 x 2 x 3 x 4 x 5 x -show binlog events limit 11,100; -select * from t1; - -sync_slave_with_master; -echo On slave; -#must show two INSERT DELAYED ---replace_column 1 x 2 x 3 x 4 x 5 x -show binlog events limit 12,100; -select * from t1; - - -# clean up -connection master; -drop table t1; -sync_slave_with_master; -connection master; - ---echo End of 5.0 tests diff --git a/mysql-test/t/rpl_insert_id-slave.opt b/mysql-test/t/rpl_insert_id-slave.opt deleted file mode 100644 index 627becdbfb5..00000000000 --- a/mysql-test/t/rpl_insert_id-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb diff --git a/mysql-test/t/rpl_insert_id.test b/mysql-test/t/rpl_insert_id.test deleted file mode 100644 index be2948e9678..00000000000 --- a/mysql-test/t/rpl_insert_id.test +++ /dev/null @@ -1,435 +0,0 @@ ---echo # ---echo # Setup ---echo # - -source include/master-slave.inc; -source include/have_innodb.inc; -use test; ---disable_warnings -drop table if exists t1, t2, t3; ---enable_warnings - ---echo # ---echo # See if queries that use both auto_increment and LAST_INSERT_ID() ---echo # are replicated well ---echo # ---echo # We also check how the foreign_key_check variable is replicated ---echo # - -connection master; -create table t1(a int auto_increment, key(a)); -create table t2(b int auto_increment, c int, key(b)); -insert into t1 values (1),(2),(3); -insert into t1 values (null); -insert into t2 values (null,last_insert_id()); -save_master_pos; -connection slave; -sync_with_master; -select * from t1; -select * from t2; -connection master; -#check if multi-line inserts, -#which set last_insert_id to the first id inserted, -#are replicated the same way -drop table t1; -drop table t2; ---disable_warnings -create table t1(a int auto_increment, key(a)) engine=innodb; -create table t2(b int auto_increment, c int, key(b), foreign key(b) references t1(a)) engine=innodb; ---enable_warnings -SET FOREIGN_KEY_CHECKS=0; -insert into t1 values (10); -insert into t1 values (null),(null),(null); -insert into t2 values (5,0); -insert into t2 values (null,last_insert_id()); -SET FOREIGN_KEY_CHECKS=1; -save_master_pos; -connection slave; -sync_with_master; -select * from t1; -select * from t2; -connection master; - ---echo # ---echo # check if INSERT SELECT in auto_increment is well replicated (bug #490) ---echo # - -drop table t2; -drop table t1; -create table t1(a int auto_increment, key(a)); -create table t2(b int auto_increment, c int, key(b)); -insert into t1 values (10); -insert into t1 values (null),(null),(null); -insert into t2 values (5,0); -insert into t2 (c) select * from t1; -select * from t2; -save_master_pos; -connection slave; -sync_with_master; -select * from t1; -select * from t2; -connection master; -drop table t1; -drop table t2; -save_master_pos; -connection slave; -sync_with_master; - ---echo # ---echo # Bug#8412: Error codes reported in binary log for CHARACTER SET, ---echo # FOREIGN_KEY_CHECKS ---echo # - -connection master; -SET TIMESTAMP=1000000000; -CREATE TABLE t1 ( a INT UNIQUE ); -SET FOREIGN_KEY_CHECKS=0; ---error 1062 -INSERT INTO t1 VALUES (1),(1); -sync_slave_with_master; - -connection master; -drop table t1; -sync_slave_with_master; - ---echo # ---echo # Bug#14553: NULL in WHERE resets LAST_INSERT_ID ---echo # - -connection master; -create table t1(a int auto_increment, key(a)); -create table t2(a int); -insert into t1 (a) values (null); -insert into t2 (a) select a from t1 where a is null; -insert into t2 (a) select a from t1 where a is null; -select * from t2; -sync_slave_with_master; -connection slave; -select * from t2; -connection master; -drop table t1; -drop table t2; -sync_slave_with_master; - ---echo # ---echo # End of 4.1 tests ---echo # - -# -# BUG#15728: LAST_INSERT_ID function inside a stored function returns 0 -# -# The solution is not to reset last_insert_id on enter to sub-statement. -# -connection master; ---disable_warnings -drop function if exists bug15728; -drop function if exists bug15728_insert; -drop table if exists t1, t2; ---enable_warnings - -create table t1 ( - id int not null auto_increment, - last_id int, - primary key (id) -); -create function bug15728() returns int(11) - return last_insert_id(); - -insert into t1 (last_id) values (0); -insert into t1 (last_id) values (last_insert_id()); -insert into t1 (last_id) values (bug15728()); - -# Check that nested call replicates too. -create table t2 ( - id int not null auto_increment, - last_id int, - primary key (id) -); -delimiter |; -create function bug15728_insert() returns int(11) modifies sql data -begin - insert into t2 (last_id) values (bug15728()); - return bug15728(); -end| -create trigger t1_bi before insert on t1 for each row -begin - declare res int; - select bug15728_insert() into res; - set NEW.last_id = res; -end| -delimiter ;| - -insert into t1 (last_id) values (0); - -drop trigger t1_bi; - -# Check that nested call doesn't affect outer context. -select last_insert_id(); -select bug15728_insert(); -select last_insert_id(); -insert into t1 (last_id) values (bug15728()); -# This should be exactly one greater than in the previous call. -select last_insert_id(); - -save_master_pos; -connection slave; -sync_with_master; -select * from t1; -select * from t2; -connection master; - -drop function bug15728; -drop function bug15728_insert; -drop table t1, t2; - -# test of BUG#20188 REPLACE or ON DUPLICATE KEY UPDATE in -# auto_increment breaks binlog - -create table t1 (n int primary key auto_increment not null, -b int, unique(b)); - -# First, test that we do not call restore_auto_increment() too early -# in write_record(): -set sql_log_bin=0; -insert into t1 values(null,100); -replace into t1 values(null,50),(null,100),(null,150); -select * from t1 order by n; -truncate table t1; -set sql_log_bin=1; - -insert into t1 values(null,100); -select * from t1 order by n; -sync_slave_with_master; -# make slave's table autoinc counter bigger -insert into t1 values(null,200),(null,300); -delete from t1 where b <> 100; -# check that slave's table content is identical to master -select * from t1 order by n; -# only the auto_inc counter differs. - -connection master; -replace into t1 values(null,100),(null,350); -select * from t1 order by n; -sync_slave_with_master; -select * from t1 order by n; - -# Same test as for REPLACE, but for ON DUPLICATE KEY UPDATE - -# We first check that if we update a row using a value larger than the -# table's counter, the counter for next row is bigger than the -# after-value of the updated row. -connection master; -insert into t1 values (NULL,400),(3,500),(NULL,600) on duplicate key UPDATE n=1000; -select * from t1 order by n; -sync_slave_with_master; -select * from t1 order by n; - -# and now test for the bug: -connection master; -drop table t1; -create table t1 (n int primary key auto_increment not null, -b int, unique(b)); -insert into t1 values(null,100); -select * from t1 order by n; -sync_slave_with_master; -insert into t1 values(null,200),(null,300); -delete from t1 where b <> 100; -select * from t1 order by n; - -connection master; -insert into t1 values(null,100),(null,350) on duplicate key update n=2; -select * from t1 order by n; -sync_slave_with_master; -select * from t1 order by n; - -connection master; -drop table t1; - -# -# BUG#24432 "INSERT... ON DUPLICATE KEY UPDATE skips auto_increment values" -# - -# testcase with INSERT VALUES -CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT, -UNIQUE(b)); -INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10; -SELECT * FROM t1; -sync_slave_with_master; -SELECT * FROM t1; -connection master; -drop table t1; - -# tescase with INSERT SELECT -CREATE TABLE t1 ( - id bigint(20) unsigned NOT NULL auto_increment, - field_1 int(10) unsigned NOT NULL, - field_2 varchar(255) NOT NULL, - field_3 varchar(255) NOT NULL, - PRIMARY KEY (id), - UNIQUE KEY field_1 (field_1, field_2) -); -CREATE TABLE t2 ( - field_a int(10) unsigned NOT NULL, - field_b varchar(255) NOT NULL, - field_c varchar(255) NOT NULL -); -INSERT INTO t2 (field_a, field_b, field_c) VALUES (1, 'a', '1a'); -INSERT INTO t2 (field_a, field_b, field_c) VALUES (2, 'b', '2b'); -INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c'); -INSERT INTO t2 (field_a, field_b, field_c) VALUES (4, 'd', '4d'); -INSERT INTO t2 (field_a, field_b, field_c) VALUES (5, 'e', '5e'); -# Updating table t1 based on values from table t2 -INSERT INTO t1 (field_1, field_2, field_3) -SELECT t2.field_a, t2.field_b, t2.field_c -FROM t2 -ON DUPLICATE KEY UPDATE -t1.field_3 = t2.field_c; -# Inserting new record into t2 -INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f'); -# Updating t1 again -INSERT INTO t1 (field_1, field_2, field_3) -SELECT t2.field_a, t2.field_b, t2.field_c -FROM t2 -ON DUPLICATE KEY UPDATE -t1.field_3 = t2.field_c; -SELECT * FROM t1; -sync_slave_with_master; -SELECT * FROM t1; -connection master; -drop table t1, t2; - -# -# BUG#20339: stored procedure using LAST_INSERT_ID() does not -# replicate statement-based -# ---disable_warnings -DROP PROCEDURE IF EXISTS p1; -DROP TABLE IF EXISTS t1, t2; ---enable_warnings - -# Reset result of LAST_INSERT_ID(). -SELECT LAST_INSERT_ID(0); - -CREATE TABLE t1 ( - id INT NOT NULL DEFAULT 0, - last_id INT, - PRIMARY KEY (id) -); - -CREATE TABLE t2 ( - id INT NOT NULL AUTO_INCREMENT, - last_id INT, - PRIMARY KEY (id) -); - -delimiter |; -CREATE PROCEDURE p1() -BEGIN - INSERT INTO t2 (last_id) VALUES (LAST_INSERT_ID()); - INSERT INTO t1 (last_id) VALUES (LAST_INSERT_ID()); -END| -delimiter ;| - -CALL p1(); -SELECT * FROM t1; -SELECT * FROM t2; - -sync_slave_with_master; -SELECT * FROM t1; -SELECT * FROM t2; - -connection master; - -DROP PROCEDURE p1; -DROP TABLE t1, t2; - - -# -# BUG#21726: Incorrect result with multiple invocations of -# LAST_INSERT_ID -# ---disable_warnings -DROP PROCEDURE IF EXISTS p1; -DROP FUNCTION IF EXISTS f1; -DROP FUNCTION IF EXISTS f2; -DROP FUNCTION IF EXISTS f3; -DROP TABLE IF EXISTS t1, t2; ---enable_warnings - -CREATE TABLE t1 ( - i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - j INT DEFAULT 0 -); -CREATE TABLE t2 (i INT); - -delimiter |; -CREATE PROCEDURE p1() -BEGIN - INSERT INTO t1 (i) VALUES (NULL); - INSERT INTO t2 (i) VALUES (LAST_INSERT_ID()); - INSERT INTO t1 (i) VALUES (NULL), (NULL); - INSERT INTO t2 (i) VALUES (LAST_INSERT_ID()); -END | - -CREATE FUNCTION f1() RETURNS INT MODIFIES SQL DATA -BEGIN - INSERT INTO t1 (i) VALUES (NULL); - INSERT INTO t2 (i) VALUES (LAST_INSERT_ID()); - INSERT INTO t1 (i) VALUES (NULL), (NULL); - INSERT INTO t2 (i) VALUES (LAST_INSERT_ID()); - RETURN 0; -END | - -CREATE FUNCTION f2() RETURNS INT NOT DETERMINISTIC - RETURN LAST_INSERT_ID() | - -CREATE FUNCTION f3() RETURNS INT MODIFIES SQL DATA -BEGIN - INSERT INTO t2 (i) VALUES (LAST_INSERT_ID()); - RETURN 0; -END | -delimiter ;| - -INSERT INTO t1 VALUES (NULL, -1); -CALL p1(); -SELECT f1(); -INSERT INTO t1 VALUES (NULL, f2()), (NULL, LAST_INSERT_ID()), - (NULL, LAST_INSERT_ID()), (NULL, f2()), (NULL, f2()); -INSERT INTO t1 VALUES (NULL, f2()); -INSERT INTO t1 VALUES (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID(5)), - (NULL, @@LAST_INSERT_ID); -# Test replication of substitution "IS NULL" -> "= LAST_INSERT_ID". -INSERT INTO t1 VALUES (NULL, 0), (NULL, LAST_INSERT_ID()); -UPDATE t1 SET j= -1 WHERE i IS NULL; - -# Test statement-based replication of function calls. -INSERT INTO t1 (i) VALUES (NULL); - -connection master1; -INSERT INTO t1 (i) VALUES (NULL); - -connection master; -SELECT f3(); - -SELECT * FROM t1; -SELECT * FROM t2; - -sync_slave_with_master; -SELECT * FROM t1; -SELECT * FROM t2; - -connection master; -DROP PROCEDURE p1; -DROP FUNCTION f1; -DROP FUNCTION f2; -DROP FUNCTION f3; -DROP TABLE t1, t2; - - -sync_slave_with_master; - ---echo ---echo # End of 5.0 tests ---echo - - diff --git a/mysql-test/t/rpl_insert_ignore-slave.opt b/mysql-test/t/rpl_insert_ignore-slave.opt deleted file mode 100644 index 627becdbfb5..00000000000 --- a/mysql-test/t/rpl_insert_ignore-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb diff --git a/mysql-test/t/rpl_insert_ignore.test b/mysql-test/t/rpl_insert_ignore.test deleted file mode 100644 index a6cc69b1df8..00000000000 --- a/mysql-test/t/rpl_insert_ignore.test +++ /dev/null @@ -1,73 +0,0 @@ -# Testcase for BUG#6287 "Slave skips auto_increment values in Replication with InnoDB" -# The bug was that if on master, INSERT IGNORE ignored some -# rows, and the table was InnoDB with auto_inc column, then on slave -# some rows received an auto_inc bigger than on master. -# Slave needs to be started with --innodb to store table in InnoDB. -# Same test for MyISAM (which had no bug). - --- source include/have_innodb.inc - --- source include/master-slave.inc - -CREATE TABLE t1 ( - a int unsigned not null auto_increment primary key, - b int unsigned, - unique (b) -) ENGINE=innodb; - -CREATE TABLE t2 ( - a int unsigned, # to force INSERT SELECT to have a certain order - b int unsigned -) ENGINE=innodb; - - -INSERT INTO t1 VALUES (NULL, 1); -INSERT INTO t1 VALUES (NULL, 2); -INSERT INTO t1 VALUES (NULL, 3); -INSERT INTO t1 VALUES (NULL, 4); - -# An alternation of values which will conflict in t1 and will not. - -INSERT INTO t2 VALUES (1, 1); -INSERT INTO t2 VALUES (2, 2); -INSERT INTO t2 VALUES (3, 5); -INSERT INTO t2 VALUES (4, 3); -INSERT INTO t2 VALUES (5, 4); -INSERT INTO t2 VALUES (6, 6); - -INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a; - -# Compare results - -SELECT * FROM t1 ORDER BY a; - -sync_slave_with_master; -SELECT * FROM t1 ORDER BY a; - -# Now do the same for MyISAM - -connection master; -drop table t1; -CREATE TABLE t1 ( - a int unsigned not null auto_increment primary key, - b int unsigned, - unique (b) -) ENGINE=myisam; - -INSERT INTO t1 VALUES (1, 1); -INSERT INTO t1 VALUES (2, 2); -INSERT INTO t1 VALUES (3, 3); -INSERT INTO t1 VALUES (4, 4); - -INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a; - -SELECT * FROM t1 ORDER BY a; - -sync_slave_with_master; -SELECT * FROM t1 ORDER BY a; - -connection master; -drop table t1, t2; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_insert_select.test b/mysql-test/t/rpl_insert_select.test deleted file mode 100644 index 677be526982..00000000000 --- a/mysql-test/t/rpl_insert_select.test +++ /dev/null @@ -1,19 +0,0 @@ -# Testcase for BUG#10456 - INSERT INTO ... SELECT violating a primary key -# breaks replication - --- source include/master-slave.inc -connection master; - -create table t1 (n int not null primary key); -insert into t1 values (1); -create table t2 (n int); -insert into t2 values (1); -insert ignore into t1 select * from t2; -insert into t1 values (2); -sync_slave_with_master; -connection slave; -select * from t1; - -connection master; -drop table t1,t2; -sync_slave_with_master; diff --git a/mysql-test/t/rpl_killed_ddl-master.opt b/mysql-test/t/rpl_killed_ddl-master.opt deleted file mode 100644 index aaf2d8a4251..00000000000 --- a/mysql-test/t/rpl_killed_ddl-master.opt +++ /dev/null @@ -1 +0,0 @@ ---debug=d,debug_lock_before_query_log_event diff --git a/mysql-test/t/rpl_killed_ddl.test b/mysql-test/t/rpl_killed_ddl.test deleted file mode 100644 index f4f2f6ac320..00000000000 --- a/mysql-test/t/rpl_killed_ddl.test +++ /dev/null @@ -1,271 +0,0 @@ -# ==== Purpose ==== -# -# This test check if DDL statements are correctly binlogged when the -# thread is killed -# -# ==== Method ==== -# -# Start a DDL query and kill it, check if the error code of the binlog -# event is correct. -# -# DDL statements tested: -# CREATE/ALTER/RENAME/DROP DATABASE -# CREATE/ALTER/DROP FUNCTION -# CREATE/ALTER/DROP PROCEDURE -# CREATE/ALTER/RENAME/DROP TABLE -# CREATE/DROP TRIGGER -# CREATE/ALTER/DROP VIEW -# -# ==== Bugs ===== -# - -source include/have_debug.inc; -source include/master-slave.inc; - -# Use the DBUG_SYNC_POINT to make sure the thread running the DDL is -# waiting before creating the query log event - -let $debug_lock= "debug_lock.before_query_log_event"; - -######## INITIALIZATION ######## - -disable_warnings; -DROP DATABASE IF EXISTS d1; -DROP DATABASE IF EXISTS d2; -DROP DATABASE IF EXISTS d3; -DROP DATABASE IF EXISTS d4; -DROP FUNCTION IF EXISTS f1; -DROP FUNCTION IF EXISTS f2; -DROP FUNCTION IF EXISTS f3; -DROP FUNCTION IF EXISTS f4; -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS t2; -DROP TABLE IF EXISTS t3; -DROP TABLE IF EXISTS t4; -DROP PROCEDURE IF EXISTS p1; -DROP PROCEDURE IF EXISTS p2; -DROP PROCEDURE IF EXISTS p3; -DROP PROCEDURE IF EXISTS p4; -DROP TRIGGER IF EXISTS tr1; -DROP TRIGGER IF EXISTS tr2; -DROP TRIGGER IF EXISTS tr3; -DROP TRIGGER IF EXISTS tr4; -enable_warnings; - -CREATE DATABASE d1; - -CREATE FUNCTION f1 () RETURNS INT DETERMINISTIC - RETURN 1; - -DELIMITER //; -CREATE PROCEDURE p1 (OUT rows INT) - BEGIN - SELECT COUNT(*) INTO rows FROM t1; - END; - // -DELIMITER ;// - -CREATE TABLE t1 (a int); -CREATE TABLE t3 (a int); - -DELIMITER //; -CREATE TRIGGER tr1 BEFORE INSERT ON t1 - FOR EACH ROW BEGIN - DELETE FROM t4 WHERE a=NEW.a; - END; - // -DELIMITER ;// - -CREATE INDEX i1 ON t1 (a); - -CREATE VIEW v1 AS SELECT a FROM t1 WHERE a < 100; - -sync_slave_with_master; - -connection master1; -let $connection_name= master1; -let $connection_id= `SELECT CONNECTION_ID()`; - -connection master; -echo [on master]; - -# This will block the execution of a statement at the DBUG_SYNC_POINT -# with given lock name -if (`SELECT '$debug_lock' != ''`) -{ - disable_query_log; - disable_result_log; - eval SELECT IS_FREE_LOCK($debug_lock); - eval SELECT GET_LOCK($debug_lock, 10); - eval SELECT IS_FREE_LOCK($debug_lock); - enable_query_log; - enable_result_log; -} - -######## START TEST ######## - -connection master1; -echo [on master1]; - -disable_warnings; - -######## DATABASE ######## - -let $diff_statement= SHOW DATABASES LIKE 'd%'; - -send CREATE DATABASE d2; -source include/kill_query_and_diff_master_slave.inc; - -send ALTER DATABASE d1 - DEFAULT CHARACTER SET = 'utf8'; -source include/kill_query_and_diff_master_slave.inc; - -send DROP DATABASE d1; -source include/kill_query_and_diff_master_slave.inc; - -send DROP DATABASE d2; -source include/kill_query_and_diff_master_slave.inc; - -######## FUNCTION ######## - -let $diff_statement= SHOW FUNCTION STATUS LIKE 'f%'; - -send CREATE FUNCTION f2 () RETURNS INT DETERMINISTIC - RETURN 1; -source include/kill_query_and_diff_master_slave.inc; - -send ALTER FUNCTION f1 SQL SECURITY INVOKER; -source include/kill_query_and_diff_master_slave.inc; - -# function f1 probably does not exist because the ALTER query was -# killed -send DROP FUNCTION IF EXISTS f1; -source include/kill_query_and_diff_master_slave.inc; - -# function f2 probably does not exist because the CREATE query was -# killed -send DROP FUNCTION IF EXISTS f2; -source include/kill_query_and_diff_master_slave.inc; - -######## PROCEDURE ######## - -let $diff_statement= SHOW PROCEDURE STATUS LIKE 'p%'; - -DELIMITER //; -send CREATE PROCEDURE p2 (OUT rows INT) - BEGIN - SELECT COUNT(*) INTO rows FROM t2; - END; - // -DELIMITER ;// -source include/kill_query_and_diff_master_slave.inc; - -send ALTER PROCEDURE p1 SQL SECURITY INVOKER COMMENT 'return rows of table t1'; -source include/kill_query_and_diff_master_slave.inc; - -send DROP PROCEDURE IF EXISTS p1; -source include/kill_query_and_diff_master_slave.inc; - -send DROP PROCEDURE IF EXISTS p2; -source include/kill_query_and_diff_master_slave.inc; - -######## TABLE ######## - -let $diff_statement= SHOW TABLES LIKE 't%'; - -send CREATE TABLE t2 (b int); -source include/kill_query_and_diff_master_slave.inc; - -send ALTER TABLE t1 ADD (d int); -source include/kill_query_and_diff_master_slave.inc; - -send RENAME TABLE t3 TO t4; -source include/kill_query_and_diff_master_slave.inc; - -######## INDEX ######## - -let $diff_statement= SHOW INDEX FROM t1; - -send CREATE INDEX i2 on t1 (a); -source include/kill_query_and_diff_master_slave.inc; - -send DROP INDEX i1 on t1; -source include/kill_query_and_diff_master_slave.inc; - -######## TRIGGER ######## - -let $diff_statement= SHOW TRIGGERS LIKE 'v%'; - -DELIMITER //; -send CREATE TRIGGER tr2 BEFORE INSERT ON t4 - FOR EACH ROW BEGIN - DELETE FROM t1 WHERE a=NEW.a; - END; - // -DELIMITER ;// -source include/kill_query_and_diff_master_slave.inc; - -send DROP TRIGGER tr1; -source include/kill_query_and_diff_master_slave.inc; - -send DROP TRIGGER IF EXISTS tr2; -source include/kill_query_and_diff_master_slave.inc; - -######## VIEW ######## - -let $diff_statement= SHOW TABLES LIKE 'v%'; - -send CREATE VIEW v2 AS SELECT a FROM t1 WHERE a > 100; -source include/kill_query_and_diff_master_slave.inc; - -send DROP VIEW v1; -source include/kill_query_and_diff_master_slave.inc; - -send DROP VIEW IF EXISTS v2; -source include/kill_query_and_diff_master_slave.inc; - -######## DROP TABLE ######## - -# Because of BUG#43529, we cannot use the DBUG_SYNC_POINT for DROP -# TABLE statements on 5.0 -connection master; -disable_query_log; -disable_result_log; -eval SELECT RELEASE_LOCK($debug_lock); -enable_result_log; -enable_query_log; -let $debug_lock=; - -connection master1; - -let $diff_statement= SHOW TABLES LIKE 't%'; - -send DROP TABLE t1; -source include/kill_query_and_diff_master_slave.inc; - -send DROP TABLE IF EXISTS t2; -source include/kill_query_and_diff_master_slave.inc; - -######## CLEAN UP ######## - -# The DROP statements above are killed during the process, so they -# does not make sure the objects are dropped. - -disable_warnings; -DROP DATABASE IF EXISTS d1; -DROP DATABASE IF EXISTS d2; -DROP DATABASE IF EXISTS d3; -DROP DATABASE IF EXISTS d4; -DROP FUNCTION IF EXISTS f1; -DROP FUNCTION IF EXISTS f2; -DROP FUNCTION IF EXISTS f3; -DROP FUNCTION IF EXISTS f4; -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS t2; -DROP TABLE IF EXISTS t3; -DROP TABLE IF EXISTS t4; -DROP PROCEDURE IF EXISTS p1; -DROP PROCEDURE IF EXISTS p2; -DROP PROCEDURE IF EXISTS p3; -DROP PROCEDURE IF EXISTS p4; -enable_warnings; diff --git a/mysql-test/t/rpl_known_bugs_detection-master.opt b/mysql-test/t/rpl_known_bugs_detection-master.opt deleted file mode 100644 index d4ba386a1a0..00000000000 --- a/mysql-test/t/rpl_known_bugs_detection-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-debug=d,pretend_version_50034_in_binlog diff --git a/mysql-test/t/rpl_known_bugs_detection.test b/mysql-test/t/rpl_known_bugs_detection.test deleted file mode 100644 index 4719716d4a1..00000000000 --- a/mysql-test/t/rpl_known_bugs_detection.test +++ /dev/null @@ -1,90 +0,0 @@ -# Test to see if slave can detect certain known bugs present -# on the master, and appropriately decides to stop -# (assuming the bug is fixed in the slave, slave cannot of course -# imitate the bug, so it has to stop). - -source include/have_debug.inc; -source include/master-slave.inc; - -# -# This is to test that slave properly detects if -# master may suffer from: -# BUG#24432 "INSERT... ON DUPLICATE KEY UPDATE skips auto_increment values" -# (i.e. on master, INSERT ON DUPLICATE KEY UPDATE is used and manipulates -# an auto_increment column, and is binlogged statement-based). -# - -# testcase with INSERT VALUES -CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT, -UNIQUE(b)); -sync_slave_with_master; -connection master; -INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10; -SELECT * FROM t1; -connection slave; -wait_for_slave_to_stop; -# show the error message ---replace_column 1 # 4 # 7 # 8 # 9 # 23 # 33 # ---query_vertical show slave status; -# show that it was not replicated -SELECT * FROM t1; - -# restart replication for the next testcase -stop slave; -reset slave; -connection master; -reset master; -drop table t1; -connection slave; -start slave; - -# testcase with INSERT SELECT -connection master; -CREATE TABLE t1 ( - id bigint(20) unsigned NOT NULL auto_increment, - field_1 int(10) unsigned NOT NULL, - field_2 varchar(255) NOT NULL, - field_3 varchar(255) NOT NULL, - PRIMARY KEY (id), - UNIQUE KEY field_1 (field_1, field_2) -); -CREATE TABLE t2 ( - field_a int(10) unsigned NOT NULL, - field_b varchar(255) NOT NULL, - field_c varchar(255) NOT NULL -); -INSERT INTO t2 (field_a, field_b, field_c) VALUES (1, 'a', '1a'); -INSERT INTO t2 (field_a, field_b, field_c) VALUES (2, 'b', '2b'); -INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c'); -INSERT INTO t2 (field_a, field_b, field_c) VALUES (4, 'd', '4d'); -INSERT INTO t2 (field_a, field_b, field_c) VALUES (5, 'e', '5e'); -sync_slave_with_master; -connection master; -# Updating table t1 based on values from table t2 -INSERT INTO t1 (field_1, field_2, field_3) -SELECT t2.field_a, t2.field_b, t2.field_c -FROM t2 -ON DUPLICATE KEY UPDATE -t1.field_3 = t2.field_c; -# Inserting new record into t2 -INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f'); -# Updating t1 again -INSERT INTO t1 (field_1, field_2, field_3) -SELECT t2.field_a, t2.field_b, t2.field_c -FROM t2 -ON DUPLICATE KEY UPDATE -t1.field_3 = t2.field_c; -SELECT * FROM t1; -connection slave; -wait_for_slave_to_stop; -# show the error message ---replace_column 1 # 4 # 7 # 8 # 9 # 23 # 33 # ---query_vertical show slave status; -# show that it was not replicated -SELECT * FROM t1; -connection master; -drop table t1, t2; -connection slave; -drop table t1, t2; - -# End of 5.0 tests diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test deleted file mode 100644 index ee80bdfde45..00000000000 --- a/mysql-test/t/rpl_loaddata.test +++ /dev/null @@ -1,173 +0,0 @@ -# See if replication of a "LOAD DATA in an autoincrement column" -# Honours autoincrement values -# i.e. if the master and slave have the same sequence -# -# check replication of load data for temporary tables with additional -# parameters -# -# check if duplicate entries trigger an error (they should unless IGNORE or -# REPLACE was used on the master) (bug 571). -# -# check if START SLAVE, RESET SLAVE, CHANGE MASTER reset Last_slave_error and -# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986) - -source include/master-slave.inc; -source include/have_innodb.inc; - -connection slave; -reset master; -connection master; - -create table t1(a int not null auto_increment, b int, primary key(a) ); -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; - -create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60)); -load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; - -create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60)); -insert into t3 select * from t2; - -save_master_pos; -connection slave; -sync_with_master; - -select * from t1; -select * from t3; -# We want to be sure that LOAD DATA is in the slave's binlog. -# But we can't simply read this binlog, because as the slave has not been -# restarted for this test, the file_id is uncertain (would cause test -# failures). So instead, we test if the binlog looks long enough to -# contain LOAD DATA. Since 5.0.3 we assume that binlog of 1292 is ok. -# If LOAD DATA was not logged, the binlog would be shorter. -show master status; - -connection master; - -drop table t1; -drop table t2; -drop table t3; -create table t1(a int, b int, unique(b)); - -save_master_pos; -connection slave; -sync_with_master; - -# See if slave stops when there's a duplicate entry for key error in LOAD DATA - -insert into t1 values(1,10); - -connection master; -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; - -save_master_pos; -connection slave; -# The SQL slave thread should be stopped now. -wait_for_slave_to_stop; - -# Skip the bad event and see if error is cleared in SHOW SLAVE STATUS by START -# SLAVE, even though we are not executing any event (as sql_slave_skip_counter -# takes us directly to the end of the relay log). - -set global sql_slave_skip_counter=1; -start slave; -sync_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -# Trigger error again to test CHANGE MASTER - -connection master; -set sql_log_bin=0; -delete from t1; -set sql_log_bin=1; -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; -save_master_pos; -connection slave; -# The SQL slave thread should be stopped now. -# Exec_Master_Log_Pos should point to the start of Execute event -# for last load data. -wait_for_slave_to_stop; - -# CHANGE MASTER and see if error is cleared in SHOW SLAVE STATUS. -stop slave; -change master to master_user='test'; -change master to master_user='root'; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -# Trigger error again to test RESET SLAVE - -set global sql_slave_skip_counter=1; -start slave; -sync_with_master; -connection master; -set sql_log_bin=0; -delete from t1; -set sql_log_bin=1; -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; -save_master_pos; -connection slave; -# The SQL slave thread should be stopped now. -wait_for_slave_to_stop; - -# RESET SLAVE and see if error is cleared in SHOW SLAVE STATUS. -stop slave; -reset slave; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -# Finally, see if logging is done ok on master for a failing LOAD DATA INFILE - -connection master; -reset master; -create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60), -unique(day)) engine=MyISAM; # no transactions ---error 1062 -load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields -terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by -'\n##\n' starting by '>' ignore 1 lines; -select * from t2; -save_master_pos; -connection slave; -start slave; -sync_with_master; -select * from t2; - -# verify that if no error on slave, this is an error - -alter table t2 drop key day; -connection master; -delete from t2; ---error 1062 -load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields -terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by -'\n##\n' starting by '>' ignore 1 lines; -connection slave; -wait_for_slave_to_stop; - -# cleanup: - -set @@global.sql_slave_skip_counter=1; -start slave; - -connection master; -drop table t2; -drop table t1; - -sync_slave_with_master; - -# BUG#17233 LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed -connection master; -CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB; - ---error 1062 -LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1; - -DROP TABLE t1; - -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_loaddata_charset.test b/mysql-test/t/rpl_loaddata_charset.test deleted file mode 100644 index 05dbdd01b39..00000000000 --- a/mysql-test/t/rpl_loaddata_charset.test +++ /dev/null @@ -1,50 +0,0 @@ -# -# Check LOAD DATA + character sets + replication -# -source include/master-slave.inc; - -# -# Bug#15126 character_set_database is not replicated -# (LOAD DATA INFILE need it) -# -connection master; -create table t1 (a varchar(10) character set utf8); -load data infile '../std_data_ln/loaddata6.dat' into table t1; -set @@character_set_database=koi8r; -load data infile '../std_data_ln/loaddata6.dat' into table t1; -set @@character_set_database=DEFAULT; -load data infile '../std_data_ln/loaddata6.dat' into table t1; -load data infile '../std_data_ln/loaddata6.dat' into table t1; -load data infile '../std_data_ln/loaddata6.dat' into table t1; -set @@character_set_database=koi8r; -load data infile '../std_data_ln/loaddata6.dat' into table t1; -set @@character_set_database=DEFAULT; -load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r; - -select hex(a) from t1; - -save_master_pos; -connection slave; -sync_with_master; - -select hex(a) from t1; -connection master; -drop table t1; -sync_slave_with_master; - -# -# Bug#45516 -# When slave SQL thread executing LOAD DATA command, the -# thd->variables.collation_database was not set properly to the default -# database charset -# - -echo -------------test bug#45516------------------; - -# LOAD DATA INFILE -let $LOAD_LOCAL=1; -source include/rpl_loaddata_charset.inc; - -# LOAD DATA LOCAL INFILE -let $LOAD_LOCAL=0; -source include/rpl_loaddata_charset.inc; diff --git a/mysql-test/t/rpl_loaddata_map-master.opt b/mysql-test/t/rpl_loaddata_map-master.opt deleted file mode 100644 index f3c797b19c8..00000000000 --- a/mysql-test/t/rpl_loaddata_map-master.opt +++ /dev/null @@ -1 +0,0 @@ ---read_buffer_size=9K --max_allowed_packet=8K diff --git a/mysql-test/t/rpl_loaddata_map-slave.opt b/mysql-test/t/rpl_loaddata_map-slave.opt deleted file mode 100644 index 95f55bcf7d8..00000000000 --- a/mysql-test/t/rpl_loaddata_map-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---max_allowed_packet=8K diff --git a/mysql-test/t/rpl_loaddata_map.test b/mysql-test/t/rpl_loaddata_map.test deleted file mode 100644 index 0a2883bfcca..00000000000 --- a/mysql-test/t/rpl_loaddata_map.test +++ /dev/null @@ -1,52 +0,0 @@ -# -# check replication of load data with the server parameters subjected to -# read_buffer_size > max_allowed_packet -# -# BUG#30435 loading large LOAD DATA INFILE breaks slave with -# read_buffer_size set on master -# BUG#33413 show binlog events fails if binlog has event size of close -# to max_allowed_packet - -source include/master-slave.inc; -source include/have_innodb.inc; - ---disable_query_log -let $rows= 5000; -create table t1 (id int not null primary key auto_increment); - -while($rows) -{ - eval insert into t1 values (null); - dec $rows; -} -eval select * into outfile '$MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' from t1; -flush logs; ---enable_query_log - -connection master; -create table t2 (id int not null primary key auto_increment); - -select @@session.read_buffer_size - @@session.max_allowed_packet > 0 ; - ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval load data infile '$MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' into table t2; -select count(*) from t2 /* 5 000 */; - -# the binglog will show fragmented Append_block events ---let $binlog_start=98 ---replace_column 5 # ---replace_regex /\/\* xid=.* \*\//\/* XID *\// /file_id=[0-9]+/file_id=#/ ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---eval show binlog events in 'master-bin.000002' from $binlog_start - - -sync_slave_with_master; -#connection slave; -select count(*) from t2 /* 5 000 */; - -connection master; -drop table t1, t2; -sync_slave_with_master; -remove_file $MYSQLTEST_VARDIR/tmp/bug30435_5k.txt; - ---echo end of the tests diff --git a/mysql-test/t/rpl_loaddata_rule_m-master.opt b/mysql-test/t/rpl_loaddata_rule_m-master.opt deleted file mode 100644 index 9d4a8f0b95e..00000000000 --- a/mysql-test/t/rpl_loaddata_rule_m-master.opt +++ /dev/null @@ -1 +0,0 @@ ---binlog_ignore_db=test diff --git a/mysql-test/t/rpl_loaddata_rule_m.test b/mysql-test/t/rpl_loaddata_rule_m.test deleted file mode 100644 index 4b8e5326c98..00000000000 --- a/mysql-test/t/rpl_loaddata_rule_m.test +++ /dev/null @@ -1,33 +0,0 @@ -# See if the master logs LOAD DATA INFILE correctly when binlog_*_db rules -# exist. -# This is for BUG#1100 (LOAD DATA INFILE was half-logged). - -source include/master-slave.inc; - ---disable_warnings -drop database if exists mysqltest; ---enable_warnings - -connection slave; -stop slave; # don't need slave for this test - -# Test logging on master - -connection master; -# 'test' is the current database -create database mysqltest; -create table t1(a int, b int, unique(b)); -use mysqltest; -load data infile '../std_data_ln/rpl_loaddata.dat' into table test.t1; -# Starting from 5.0.3 LOAD DATA is replicated much in the same way as ordinary -# query so "show binlog ..." should show two events (before 5.0.3 no events -# were returned). ---replace_column 2 # 5 # -show binlog events from 98; - -drop database mysqltest; -use test; -drop table t1; - -# End of 4.1 tests -# Adding comment for force manual merge 5.0 -> wl1012: Delete me diff --git a/mysql-test/t/rpl_loaddata_rule_s-slave.opt b/mysql-test/t/rpl_loaddata_rule_s-slave.opt deleted file mode 100644 index 9d4a8f0b95e..00000000000 --- a/mysql-test/t/rpl_loaddata_rule_s-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---binlog_ignore_db=test diff --git a/mysql-test/t/rpl_loaddata_rule_s.test b/mysql-test/t/rpl_loaddata_rule_s.test deleted file mode 100644 index 2061e898811..00000000000 --- a/mysql-test/t/rpl_loaddata_rule_s.test +++ /dev/null @@ -1,25 +0,0 @@ -# See if the slave logs (in its own binlog, with --log-slave-updates) a -# replicated LOAD DATA INFILE correctly when it has binlog_*_db rules. -# This is for BUG#1100 (LOAD DATA INFILE was half-logged). - -source include/master-slave.inc; -connection slave; -reset master; - -connection master; -# 'test' is the current database -create table t1(a int, b int, unique(b)); -load data infile '../std_data_ln/rpl_loaddata.dat' into table test.t1; - -# Test logging on slave; - -save_master_pos; -connection slave; -sync_with_master; -select count(*) from t1; # check that LOAD was replicated -show binlog events from 98; # should be nothing - -connection master; -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_loaddatalocal.test b/mysql-test/t/rpl_loaddatalocal.test deleted file mode 100644 index d3149bea427..00000000000 --- a/mysql-test/t/rpl_loaddatalocal.test +++ /dev/null @@ -1,65 +0,0 @@ -# See if "LOAD DATA LOCAL INFILE" is well replicated -# (LOAD DATA LOCAL INFILE is not written to the binlog -# the same way as LOAD DATA INFILE : Append_blocks are smaller). -# In MySQL 4.0 <4.0.12 there were 2 bugs with LOAD DATA LOCAL INFILE : -# - the loaded file was not written entirely to the master's binlog, -# only the first 4KB, 8KB or 16KB usually. -# - the loaded file's first line was not written entirely to the -# master's binlog (1st char was absent) -source include/master-slave.inc; - -create table t1(a int); -let $1=10000; -disable_query_log; -set SQL_LOG_BIN=0; -while ($1) -{ - insert into t1 values(1); - dec $1; -} -set SQL_LOG_BIN=1; -enable_query_log; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval select * into outfile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' from t1; -#This will generate a 20KB file, now test LOAD DATA LOCAL -truncate table t1; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1; ---remove_file $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile -save_master_pos; -connection slave; -sync_with_master; -select a,count(*) from t1 group by a; -connection master; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests - -# -# Now let us test how well we replicate LOAD DATA LOCAL in situation when -# we met duplicates in tables to which we are adding rows. -# (It supposed that LOAD DATA LOCAL ignores such errors) -# -connection master; -create table t1(a int); -insert into t1 values (1), (2), (2), (3); ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval select * into outfile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' from t1; -drop table t1; -create table t1(a int primary key); ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1; -remove_file $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile ; -select * from t1; -save_master_pos; -connection slave; -sync_with_master; -select * from t1; -connection master; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; diff --git a/mysql-test/t/rpl_locale.test b/mysql-test/t/rpl_locale.test deleted file mode 100644 index 2f2d637e1b4..00000000000 --- a/mysql-test/t/rpl_locale.test +++ /dev/null @@ -1,24 +0,0 @@ -# Replication of locale variables - -source include/master-slave.inc; - -# -# Bug#22645 LC_TIME_NAMES: Statement not replicated -# -connection master; -create table t1 (s1 char(10)); -set lc_time_names= 'de_DE'; -insert into t1 values (date_format('2001-01-01','%W')); -set lc_time_names= 'en_US'; -insert into t1 values (date_format('2001-01-01','%W')); -select * from t1; -sync_slave_with_master; -connection slave; -select * from t1; -connection master; -drop table t1; -sync_slave_with_master; - -# End of 4.1 tests - - diff --git a/mysql-test/t/rpl_log-master.opt b/mysql-test/t/rpl_log-master.opt deleted file mode 100644 index cef79bc8585..00000000000 --- a/mysql-test/t/rpl_log-master.opt +++ /dev/null @@ -1 +0,0 @@ ---force-restart diff --git a/mysql-test/t/rpl_log-slave.opt b/mysql-test/t/rpl_log-slave.opt deleted file mode 100644 index 203fc2287ec..00000000000 --- a/mysql-test/t/rpl_log-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---log-slave-updates diff --git a/mysql-test/t/rpl_log.test b/mysql-test/t/rpl_log.test deleted file mode 100644 index 52c4a3e0606..00000000000 --- a/mysql-test/t/rpl_log.test +++ /dev/null @@ -1,124 +0,0 @@ -source include/master-slave.inc; - -# Clean up old slave's binlogs. -# The slave is started with --log-slave-updates -# and this test does SHOW BINLOG EVENTS on the slave's -# binlog. But previous tests can influence the current test's -# binlog (e.g. a temporary table in the previous test has not -# been explicitly deleted, and at the beginning of the current -# test the slave immediately writes DROP TEMPORARY TABLE this_old_table). -# We wait for the slave to have written all he wants to the binlog -# (otherwise RESET MASTER may come too early). -save_master_pos; -connection slave; -sync_with_master; -stop slave; ---source include/wait_for_slave_to_stop.inc -reset master; -reset slave; -start slave; ---source include/wait_for_slave_to_start.inc - -let $VERSION=`select version()`; - -connection master; -create table t1(n int not null auto_increment primary key); -insert into t1 values (NULL); -drop table t1; -create table t1 (word char(20) not null); -load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines; -select count(*) from t1; -drop table t1; ---replace_result $VERSION VERSION ---replace_regex /file_id=[0-9]+/file_id=#/ /block_len=[0-9]+/block_len=#/ /infile '.+'/infile 'words.dat'/ -show binlog events; -show binlog events from 98 limit 1; -show binlog events from 98 limit 2; -show binlog events from 98 limit 2,1; -flush logs; - -# We need an extra update before doing save_master_pos. -# Otherwise, an unlikely scenario may occur: -# * When the master's binlog_dump thread reads the end of master-bin.001, -# it send the rotate event which is at this end, plus a fake rotate event -# because it's starting to read a new binlog. -# save_master_pos will record the position of the first of the two rotate -# (because the fake one is not in the master's binlog anyway). -# * Later the slave waits for the position of the first rotate event, -# and it may quickly stop (in 'slave stop') without having received the fake -# one. -# So, depending on a few milliseconds, we end up with 2 rotate events in the -# relay log or one, which influences the output of SHOW SLAVE STATUS, making -# it not predictable and causing random test failures. -# To make it predictable, we do a useless update now, but which has the -# interest of making the slave catch both rotate events. - -create table t5 (a int); -drop table t5; - -# Sync slave and force it to start on another binary log - -save_master_pos; -connection slave; -# Note that the above 'slave start' will cause a 3rd rotate event (a fake one) -# to go into the relay log (the master always sends a fake one when replication -# starts). -sync_with_master; -flush logs; -stop slave; ---source include/wait_for_slave_to_stop.inc -connection master; - -# Create some entries for second log - -create table t1 (n int); -insert into t1 values (1); -drop table t1; ---replace_result $VERSION VERSION ---replace_regex /file_id=[0-9]+/file_id=#/ /block_len=[0-9]+/block_len=#/ /infile '.+'/infile 'words.dat'/ -show binlog events; ---replace_result $VERSION VERSION -show binlog events in 'master-bin.000002'; -show binary logs; -save_master_pos; -connection slave; -start slave; ---source include/wait_for_slave_to_start.inc -sync_with_master; -show binary logs; ---replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION ---replace_regex /file_id=[0-9]+/file_id=#/ /block_len=[0-9]+/block_len=#/ /INFILE '.+'/INFILE 'words.dat'/ -show binlog events in 'slave-bin.000001' from 4; ---replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION -show binlog events in 'slave-bin.000002' from 4; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -# Need to recode the following - -#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=4 and master_server_id=1; -#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=79 and master_server_id=1; -#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=311 and master_server_id=1; -#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=4 and master_server_id=1; -#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=122 and master_server_id=1; - ---error 1220 -show binlog events in 'slave-bin.000005' from 4; - -# -# Bug #6880: LAST_INSERT_ID() within a statement -# - -create table t1(a int auto_increment primary key, b int); -insert into t1 values (NULL, 1); -reset master; -set insert_id=5; -insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id()); ---replace_result $VERSION VERSION -show binlog events; -select * from t1; -drop table t1; - -# End of 4.1 tests -# Adding comment for force manual merge 5.0 -> wl1012: Delete me diff --git a/mysql-test/t/rpl_log_pos.test b/mysql-test/t/rpl_log_pos.test deleted file mode 100644 index ee8da494f86..00000000000 --- a/mysql-test/t/rpl_log_pos.test +++ /dev/null @@ -1,46 +0,0 @@ -# -# Testing of setting slave to wrong log position with master_log_pos -# -source include/master-slave.inc; -show master status; -sync_slave_with_master; - -stop slave; ---source include/wait_for_slave_to_stop.inc - -change master to master_log_pos=73; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -query_vertical show slave status; - -start slave; -let $slave_param= Slave_SQL_Running; -let $slave_param_value= Yes; ---source include/wait_for_slave_param.inc -let $slave_param= Slave_IO_Running; -let $slave_param_value= No; ---source include/wait_for_slave_param.inc -stop slave; ---source include/wait_for_slave_to_stop.inc - ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -query_vertical show slave status; - -connection master; -show master status; -create table if not exists t1 (n int); -drop table if exists t1; -create table t1 (n int); -insert into t1 values (1),(2),(3); -save_master_pos; -connection slave; -change master to master_log_pos=98; -start slave; -sync_with_master; -select * from t1; -connection master; -drop table t1; -sync_slave_with_master; - ---echo End of 5.0 tests diff --git a/mysql-test/t/rpl_many_optimize.test b/mysql-test/t/rpl_many_optimize.test deleted file mode 100644 index 91fab0b27a8..00000000000 --- a/mysql-test/t/rpl_many_optimize.test +++ /dev/null @@ -1,22 +0,0 @@ -# Test for BUG#7658 "optimize crashes slave thread (1 in 1000)]" - -source include/master-slave.inc; - -create table t1 (a int not null auto_increment primary key, b int, key(b)); -INSERT INTO t1 (a) VALUES (1),(2); -# Now many OPTIMIZE to test if we crash (BUG#7658) -let $1=300; -disable_query_log; -disable_result_log; -while ($1) -{ - eval OPTIMIZE TABLE t1; - dec $1; -} -enable_result_log; -enable_query_log; -drop table t1; -# Bug was that slave segfaulted after ~ a hundred of OPTIMIZE (or ANALYZE) -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_master_pos_wait.test b/mysql-test/t/rpl_master_pos_wait.test deleted file mode 100644 index 2f7b18ae04b..00000000000 --- a/mysql-test/t/rpl_master_pos_wait.test +++ /dev/null @@ -1,29 +0,0 @@ -# See if master_pos_wait(,,timeout) -# Terminates with "timeout expired" (-1) -source include/master-slave.inc; -save_master_pos; -connection slave; -sync_with_master; -# Ask for a master log that has certainly not been reached yet -# timeout= 2 seconds -select master_pos_wait('master-bin.999999',0,2); -explain extended select master_pos_wait('master-bin.999999',0,2); -# Testcase for bug 651 (master_pos_wait() hangs if slave idle and STOP SLAVE). -send select master_pos_wait('master-bin.999999',0); -connection slave1; -stop slave sql_thread; -connection slave; -reap; - -# -# bug#26622 MASTER_POS_WAIT does not work as documented -# - -connection master; -echo "*** must be empty ***"; -query_vertical show slave status; - -echo "*** must be NULL ***"; -select master_pos_wait('foo', 98); - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_max_relay_size.test b/mysql-test/t/rpl_max_relay_size.test deleted file mode 100644 index e5278ff5727..00000000000 --- a/mysql-test/t/rpl_max_relay_size.test +++ /dev/null @@ -1,137 +0,0 @@ -# Test of options max_binlog_size and max_relay_log_size and -# how they act (if max_relay_log_size == 0, use max_binlog_size -# for relay logs too). -# Test of manual relay log rotation with FLUSH LOGS. - -source include/master-slave.inc; -connection slave; -stop slave; -connection master; - ---echo # ---echo # Generate a big enough master's binlog to cause relay log rotations ---echo # - -create table t1 (a int); -let $1=800; -disable_query_log; -begin; -while ($1) -{ -# eval means expand $ expressions - eval insert into t1 values( $1 ); - dec $1; -} -enable_query_log; -drop table t1; -save_master_pos; -connection slave; -reset slave; - ---echo # ---echo # Test 1 ---echo # - -set @my_max_binlog_size= @@global.max_binlog_size; -set global max_binlog_size=8192; -set global max_relay_log_size=8192-1; # mapped to 4096 -select @@global.max_relay_log_size; -start slave; -sync_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # ---vertical_results -show slave status; - ---echo # ---echo # Test 2 ---echo # - -stop slave; -reset slave; -set global max_relay_log_size=(5*4096); -select @@global.max_relay_log_size; -start slave; -sync_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # ---vertical_results -show slave status; - ---echo # ---echo # Test 3: max_relay_log_size = 0 ---echo # - -stop slave; -reset slave; -set global max_relay_log_size=0; -select @@global.max_relay_log_size; -start slave; -sync_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # ---vertical_results -show slave status; - ---echo # ---echo # Test 4: Tests below are mainly to ensure that we have not coded with wrong assumptions ---echo # - -stop slave; -reset slave; -# test of relay log rotation when the slave is stopped -# (to make sure it does not crash). -flush logs; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # ---vertical_results -show slave status; - ---echo # ---echo # Test 5 ---echo # - -reset slave; -start slave; -sync_with_master; -# test of relay log rotation when the slave is started -flush logs; -# We have now easy way to be sure that the SQL thread has now deleted the -# log we just closed. But a trick to achieve this is do an update on the master. -connection master; -create table t1 (a int); -save_master_pos; -connection slave; -sync_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # ---vertical_results -show slave status; - ---echo # ---echo # Test 6: one more rotation, to be sure Relay_Log_Space is correctly updated ---echo # - -flush logs; -connection master; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # ---vertical_results -show slave status; - -connection master; -# test that the absence of relay logs does not make a master crash -flush logs; -show master status; - -# Restore max_binlog_size -connection slave; -set global max_binlog_size= @my_max_binlog_size; - ---echo # ---echo # End of 4.1 tests ---echo # diff --git a/mysql-test/t/rpl_misc_functions-slave.sh b/mysql-test/t/rpl_misc_functions-slave.sh deleted file mode 100755 index 8ce79797822..00000000000 --- a/mysql-test/t/rpl_misc_functions-slave.sh +++ /dev/null @@ -1 +0,0 @@ -rm -f $MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile diff --git a/mysql-test/t/rpl_misc_functions.test b/mysql-test/t/rpl_misc_functions.test deleted file mode 100644 index 1c94471c975..00000000000 --- a/mysql-test/t/rpl_misc_functions.test +++ /dev/null @@ -1,114 +0,0 @@ -# -# Test of replicating some difficult functions -# -source include/master-slave.inc; - -create table t1(id int, i int, r1 int, r2 int, p varchar(100)); -insert into t1 values(1, connection_id(), 0, 0, ""); -# don't put rand and password in the same query, to see if they replicate -# independently -# Pure rand test -insert into t1 values(2, 0, rand()*1000, rand()*1000, ""); -# change the rand suite on the master (we do this because otherwise password() -# benefits from the fact that the above rand() is well replicated : -# it picks the same sequence element, which hides a possible bug in password() replication. -set sql_log_bin=0; -insert into t1 values(6, 0, rand(), rand(), ""); -delete from t1 where id=6; -set sql_log_bin=1; -# Pure password test -insert into t1 values(3, 0, 0, 0, password('does_this_work?')); -# "altogether now" -insert into t1 values(4, connection_id(), rand()*1000, rand()*1000, password('does_this_still_work?')); -select * into outfile 'rpl_misc_functions.outfile' from t1; -sync_slave_with_master; -create table t2 like t1; -# read the values from the master table ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval load data local infile '$MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile' into table t2; -# compare them with the replica; the SELECT below should return no row -select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p); - -connection master; -drop table t1; - -# End of 4.1 tests - -# -# BUG#25543 test calling rand() multiple times on the master in -# a stored procedure. -# - ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - -CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - col_a DOUBLE DEFAULT NULL); - -DELIMITER |; - -# Use a SP that calls rand() multiple times -CREATE PROCEDURE test_replication_sp1() -BEGIN - INSERT INTO t1 (col_a) VALUES (rand()), (rand()); - INSERT INTO t1 (col_a) VALUES (rand()); -END| - -# Use a SP that calls another SP to call rand() multiple times -CREATE PROCEDURE test_replication_sp2() -BEGIN - CALL test_replication_sp1(); - CALL test_replication_sp1(); -END| - -# Use a SF that calls rand() multiple times -CREATE FUNCTION test_replication_sf() RETURNS DOUBLE DETERMINISTIC -BEGIN - RETURN (rand() + rand()); -END| - -DELIMITER ;| - -# Exercise the functions and procedures then compare the results on -# the master to those on the slave. -CALL test_replication_sp1(); -CALL test_replication_sp2(); -INSERT INTO t1 (col_a) VALUES (test_replication_sf()); -INSERT INTO t1 (col_a) VALUES (test_replication_sf()); -INSERT INTO t1 (col_a) VALUES (test_replication_sf()); - ---sync_slave_with_master - -# Dump table on slave -select * from t1 into outfile "../tmp/t1_slave.txt"; - -# Load data from slave into temp table on master -connection master; -create temporary table t1_slave select * from t1 where 1=0; -load data infile '../tmp/t1_slave.txt' into table t1_slave; ---remove_file $MYSQLTEST_VARDIR/tmp/t1_slave.txt - -# Compare master and slave temp table, use subtraction -# for floating point comparison of "double" -select count(*) into @aux from t1 join t1_slave using (id) -where ABS(t1.col_a - t1_slave.col_a) < 0.0000001 ; -SELECT @aux; -if (`SELECT @aux <> 12 OR @aux IS NULL`) -{ - --echo # ERROR: We expected to get count(*) = 12. - SELECT id, col_a FROM t1; - SELECT id, col_a FROM t1_slave; - --echo # abort - exit; -} - -# Cleanup -connection master; -DROP TABLE t1, t1_slave; -DROP PROCEDURE test_replication_sp1; -DROP PROCEDURE test_replication_sp2; -DROP FUNCTION test_replication_sf; ---sync_slave_with_master - - diff --git a/mysql-test/t/rpl_multi_delete-slave.opt b/mysql-test/t/rpl_multi_delete-slave.opt deleted file mode 100644 index c98fe0b0a46..00000000000 --- a/mysql-test/t/rpl_multi_delete-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-wild-do-table=test.% diff --git a/mysql-test/t/rpl_multi_delete.test b/mysql-test/t/rpl_multi_delete.test deleted file mode 100644 index 4a8c0ab6912..00000000000 --- a/mysql-test/t/rpl_multi_delete.test +++ /dev/null @@ -1,41 +0,0 @@ -source include/master-slave.inc; -create table t1 (a int); -create table t2 (a int); - -insert into t1 values (1); -insert into t2 values (1); - -delete t1.* from t1, t2 where t1.a = t2.a; - -save_master_pos; -select * from t1; -select * from t2; - -connection slave; -sync_with_master; -select * from t1; -select * from t2; - -# End of 4.1 tests - -# Check if deleting 0 rows is binlogged (BUG#13348) - -connection master; -delete from t1; -delete from t2; - -sync_slave_with_master; -# force a difference to see if master's multi-DELETE will correct it -insert into t1 values(1); -insert into t2 values(1); - -connection master; -DELETE t1.*, t2.* from t1, t2; - -sync_slave_with_master; -select * from t1; -select * from t2; - -connection master; -drop table t1,t2; -sync_slave_with_master; diff --git a/mysql-test/t/rpl_multi_delete2-slave.opt b/mysql-test/t/rpl_multi_delete2-slave.opt deleted file mode 100644 index 0febb2891b1..00000000000 --- a/mysql-test/t/rpl_multi_delete2-slave.opt +++ /dev/null @@ -1 +0,0 @@ -"--replicate-rewrite-db=mysqltest_from->mysqltest_to" --replicate-do-table=mysqltest_to.a diff --git a/mysql-test/t/rpl_multi_delete2.test b/mysql-test/t/rpl_multi_delete2.test deleted file mode 100644 index c50311de363..00000000000 --- a/mysql-test/t/rpl_multi_delete2.test +++ /dev/null @@ -1,68 +0,0 @@ -#multi delete replication bugs - - -source include/master-slave.inc; - -#BUG#11139 - improper wild-table and table rules -#checking for multi deletes with an alias - -connection master; -set sql_log_bin=0; -create database mysqltest_from; -set sql_log_bin=1; - -connection slave; -create database mysqltest_to; - - -connection master; -use mysqltest_from; ---disable_warnings -drop table if exists a; ---enable_warnings -CREATE TABLE a (i INT); -INSERT INTO a VALUES(1); -DELETE alias FROM a alias WHERE alias.i=1; -SELECT * FROM a; -insert into a values(2),(3); -delete a alias FROM a alias where alias.i=2; -select * from a; -save_master_pos; -connection slave; - -use mysqltest_to; -sync_with_master; -select * from a; - -# BUG#3461 -connection master; -create table t1 (a int); -create table t2 (a int); - -insert into t1 values (1); -insert into t2 values (1); - -delete t1.* from t1, t2 where t1.a = t2.a; - -save_master_pos; -select * from t1; -select * from t2; - -connection slave; -# BUG#3461 would cause sync to fail -sync_with_master; -error 1146; -select * from t1; -error 1146; -select * from t2; - -# cleanup -connection master; -set sql_log_bin=0; -drop database mysqltest_from; -set sql_log_bin=1; -connection slave; -drop database mysqltest_to; - -# End of 4.1 tests - diff --git a/mysql-test/t/rpl_multi_query.test b/mysql-test/t/rpl_multi_query.test deleted file mode 100644 index b4cd88f756e..00000000000 --- a/mysql-test/t/rpl_multi_query.test +++ /dev/null @@ -1,32 +0,0 @@ -# Test for BUG#8436: verify that a multi-query (i.e. one query -# containing several queries (assuming client has -# CLIENT_MULTI_STATEMENTS) will be binlogged ONE-query-per-event (not -# one binlog event containing all queries) - -# PS doesn't support multi-statements ---disable_ps_protocol - -source include/master-slave.inc; ---disable_warnings -drop database if exists mysqltest; ---enable_warnings -create database mysqltest; - -delimiter /; -create table mysqltest.t1 ( n int); -insert into mysqltest.t1 values(1)/ -insert into mysqltest.t1 values(2); -insert into mysqltest.t1 values(3); -insert into mysqltest.t1 values(4); -insert into mysqltest.t1 values(5)/ -delimiter ;/ -sync_slave_with_master; -select * from mysqltest.t1; -connection master; ---replace_column 2 # 5 # -show binlog events from 98; -drop database mysqltest; -sync_slave_with_master; - -# End of 4.1 tests -# diff --git a/mysql-test/t/rpl_multi_update.test b/mysql-test/t/rpl_multi_update.test deleted file mode 100644 index f6a960434ad..00000000000 --- a/mysql-test/t/rpl_multi_update.test +++ /dev/null @@ -1,49 +0,0 @@ -source include/master-slave.inc; - -CREATE TABLE t1 ( - a int unsigned not null auto_increment primary key, - b int unsigned -) ENGINE=MyISAM; - -CREATE TABLE t2 ( - a int unsigned not null auto_increment primary key, - b int unsigned -) ENGINE=MyISAM; - -INSERT INTO t1 VALUES (NULL, 0); -INSERT INTO t1 SELECT NULL, 0 FROM t1; - -INSERT INTO t2 VALUES (NULL, 0), (NULL,1); - -SELECT * FROM t1 ORDER BY a; -SELECT * FROM t2 ORDER BY a; - -UPDATE t1, t2 SET t1.b = t2.b WHERE t1.a = t2.a; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests - -# Check if updating 0 rows is binlogged (BUG#13348) - -connection master; -delete from t1; -delete from t2; -insert into t1 values(1,1); -insert into t2 values(1,1); - -sync_slave_with_master; -# force a difference to see if master's multi-UPDATE will correct it -update t1 set a=2; - -connection master; -UPDATE t1, t2 SET t1.a = t2.a; - -sync_slave_with_master; -select * from t1; -select * from t2; - -connection master; -drop table t1, t2; -sync_slave_with_master; diff --git a/mysql-test/t/rpl_multi_update2-slave.opt b/mysql-test/t/rpl_multi_update2-slave.opt deleted file mode 100644 index 17d4171af0e..00000000000 --- a/mysql-test/t/rpl_multi_update2-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-ignore-table=nothing.sensible diff --git a/mysql-test/t/rpl_multi_update2.test b/mysql-test/t/rpl_multi_update2.test deleted file mode 100644 index a78b1901f51..00000000000 --- a/mysql-test/t/rpl_multi_update2.test +++ /dev/null @@ -1,62 +0,0 @@ -# Let's verify that multi-update is not always skipped by slave if -# some replicate-* rules exist. -# (BUG#7011) - -source include/master-slave.inc; - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - -CREATE TABLE t1 ( - a int unsigned not null auto_increment primary key, - b int unsigned -) ENGINE=MyISAM; - -CREATE TABLE t2 ( - a int unsigned not null auto_increment primary key, - b int unsigned -) ENGINE=MyISAM; - -INSERT INTO t1 VALUES (NULL, 0); -INSERT INTO t1 SELECT NULL, 0 FROM t1; - -INSERT INTO t2 VALUES (NULL, 0), (NULL,1); - -SELECT * FROM t1 ORDER BY a; -SELECT * FROM t2 ORDER BY a; - -UPDATE t1, t2 SET t1.b = (t2.b+4) WHERE t1.a = t2.a; -SELECT * FROM t1 ORDER BY a; -SELECT * FROM t2 ORDER BY a; - -save_master_pos; -connection slave; -sync_with_master; -SELECT * FROM t1 ORDER BY a; -SELECT * FROM t2 ORDER BY a; - -connection master; -drop table t1,t2; -sync_slave_with_master; - -# -# BUG#13236 multi-update with subquery & --replicate-ignore-table -# -reset master; - -connection master; -CREATE TABLE t1 ( a INT ); -INSERT INTO t1 VALUES (0); -UPDATE t1, (SELECT 3 as b) AS x SET t1.a = x.b; -select * from t1; -sync_slave_with_master; - -connection slave; -select * from t1; - -connection master; -drop table t1; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_multi_update3.test b/mysql-test/t/rpl_multi_update3.test deleted file mode 100644 index 8d566764ad9..00000000000 --- a/mysql-test/t/rpl_multi_update3.test +++ /dev/null @@ -1,223 +0,0 @@ -source include/master-slave.inc; - -############################################################################## -# -# Let's verify that multi-update with a subselect does not cause the slave to crash -# (BUG#10442) -# ---disable_query_log -SELECT '-------- Test for BUG#9361 --------' as ""; ---enable_query_log - -CREATE TABLE t1 ( - a int unsigned not null auto_increment primary key, - b int unsigned -) ENGINE=MyISAM; - -CREATE TABLE t2 ( - a int unsigned not null auto_increment primary key, - b int unsigned -) ENGINE=MyISAM; - -INSERT INTO t1 VALUES (NULL, 0); -INSERT INTO t1 SELECT NULL, 0 FROM t1; - -INSERT INTO t2 VALUES (NULL, 0), (NULL,1); - -SELECT * FROM t1 ORDER BY a; -SELECT * FROM t2 ORDER BY a; - -UPDATE t2, (SELECT a FROM t1) AS t SET t2.b = t.a+5 ; -SELECT * FROM t1 ORDER BY a; -SELECT * FROM t2 ORDER BY a; - -sync_slave_with_master; -connection slave; -SELECT * FROM t1 ORDER BY a; -SELECT * FROM t2 ORDER BY a; - -connection master; -drop table t1,t2; - -############################################################################## -# -# Test for BUG#9361: -# Subselects should work inside multi-updates -# ---disable_query_log -SELECT '-------- Test 1 for BUG#9361 --------' as ""; ---enable_query_log - -connection master; - ---disable_warnings -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS t2; ---enable_warnings - -CREATE TABLE t1 ( - a1 char(30), - a2 int, - a3 int, - a4 char(30), - a5 char(30) -); - -CREATE TABLE t2 ( - b1 int, - b2 char(30) -); - -# Insert one row per table -INSERT INTO t1 VALUES ('Yes', 1, NULL, 'foo', 'bar'); -INSERT INTO t2 VALUES (1, 'baz'); - -# This should update the row in t1 -UPDATE t1 a, t2 - SET a.a1 = 'No' - WHERE a.a2 = - (SELECT b1 - FROM t2 - WHERE b2 = 'baz') - AND a.a3 IS NULL - AND a.a4 = 'foo' - AND a.a5 = 'bar'; - -sync_slave_with_master; -connection slave; -SELECT * FROM t1; -SELECT * FROM t2; - -connection master; -DROP TABLE t1, t2; - -############################################################################## -# -# Second test for BUG#9361 -# - ---disable_query_log -SELECT '-------- Test 2 for BUG#9361 --------' as ""; ---enable_query_log - -connection master; - ---disable_warnings -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS t2; -DROP TABLE IF EXISTS t3; ---enable_warnings - -CREATE TABLE t1 ( - i INT, - j INT, - x INT, - y INT, - z INT -); - -CREATE TABLE t2 ( - i INT, - k INT, - x INT, - y INT, - z INT -); - -CREATE TABLE t3 ( - j INT, - k INT, - x INT, - y INT, - z INT -); - -INSERT INTO t1 VALUES ( 1, 2,13,14,15); -INSERT INTO t2 VALUES ( 1, 3,23,24,25); -INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36); - -UPDATE t1 AS a -INNER JOIN t2 AS b - ON a.i = b.i -INNER JOIN t3 AS c - ON a.j = c.j AND b.k = c.k -SET a.x = b.x, - a.y = b.y, - a.z = ( - SELECT sum(z) - FROM t3 - WHERE y = 34 - ) -WHERE b.x = 23; - -sync_slave_with_master; -connection slave; - -SELECT * FROM t1; - -connection master; -DROP TABLE t1, t2, t3; - -############################################################################## -# -# BUG#12618 -# -# TEST: Replication of a statement containing a join in a multi-update. - -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS t2; - -CREATE TABLE t1 ( - idp int(11) NOT NULL default '0', - idpro int(11) default NULL, - price decimal(19,4) default NULL, - PRIMARY KEY (idp) -); - -CREATE TABLE t2 ( - idpro int(11) NOT NULL default '0', - price decimal(19,4) default NULL, - nbprice int(11) default NULL, - PRIMARY KEY (idpro) -); - -INSERT INTO t1 VALUES - (1,1,'3.0000'), - (2,2,'1.0000'), - (3,1,'1.0000'), - (4,1,'4.0000'), - (5,3,'2.0000'), - (6,2,'4.0000'); - -INSERT INTO t2 VALUES - (1,'0.0000',0), - (2,'0.0000',0), - (3,'0.0000',0); - -# This update sets t2 to the minimal prices for each product -update - t2 - join - ( select idpro, min(price) as min_price, count(*) as nbr_price - from t1 - where idpro>0 and price>0 - group by idpro - ) as table_price -on t2.idpro = table_price.idpro -set t2.price = table_price.min_price, - t2.nbprice = table_price.nbr_price; - -select "-- MASTER AFTER JOIN --" as ""; -select * from t1; -select * from t2; - -sync_slave_with_master; - -select "-- SLAVE AFTER JOIN --" as ""; -select * from t1; -select * from t2; - -connection master; -drop table t1, t2; -sync_slave_with_master; -# End of 4.1 tests diff --git a/mysql-test/t/rpl_multi_update4-slave.opt b/mysql-test/t/rpl_multi_update4-slave.opt deleted file mode 100644 index fea27db43ee..00000000000 --- a/mysql-test/t/rpl_multi_update4-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-wild-do-table=d1.% diff --git a/mysql-test/t/rpl_multi_update4.test b/mysql-test/t/rpl_multi_update4.test deleted file mode 100644 index 3d909b8e5cd..00000000000 --- a/mysql-test/t/rpl_multi_update4.test +++ /dev/null @@ -1,44 +0,0 @@ -# Let's verify that multi-update is not always skipped by slave if -# some replicate-* rules exist. -# (BUG#15699) - -source include/master-slave.inc; - -### Clean-up - -connection master; ---disable_warnings -drop database if exists d1; -drop database if exists d2; - -connection slave; -drop database if exists d2; ---enable_warnings - -### Test - -connection master; -create database d1; # accepted by slave -create table d1.t0 (id int); -create database d2; # ignored by slave -use d2; -create table t1 (id int); -create table t2 (id int); -insert into t1 values (1), (2), (3), (4), (5); -insert into t2 select id + 3 from t1; -# a problematic query which must be filter out by slave -update t1 join t2 using (id) set t1.id = 0; -insert into d1.t0 values (0); # replication works - -sync_slave_with_master; -use d1; -#connection slave; -select * from t0 where id=0; # must find - -### Clean-up -connection master; -drop database d1; -drop database d2; - - -# End of test diff --git a/mysql-test/t/rpl_mystery22.test b/mysql-test/t/rpl_mystery22.test deleted file mode 100644 index f190968a03c..00000000000 --- a/mysql-test/t/rpl_mystery22.test +++ /dev/null @@ -1,40 +0,0 @@ -# test case to make slave thread get ahead by 22 bytes - -source include/master-slave.inc; - -# first, cause a duplicate key problem on the slave -create table t1(n int auto_increment primary key); -sync_slave_with_master; -insert into t1 values (2); -connection master; -insert into t1 values(NULL); -insert into t1 values(NULL); -save_master_pos; -connection slave; -sleep 3; # there is no way around this sleep - we have to wait until -# the slave tries to run the query, fails and aborts slave thread -delete from t1 where n = 2; -start slave; -sync_with_master; -#now the buggy slave would be confused on the offset but it can replicate -#in order to make it break, we need to stop/start the slave one more time -stop slave; -connection master; -# to be able to really confuse the slave, we need some non-auto-increment -# events in the log -create table t2(n int); -drop table t2; -insert into t1 values(NULL); -save_master_pos; -connection slave; -start slave; -#now the truth comes out - if the slave is buggy, it will never sync because -#the slave thread is not able to read events -sync_with_master; -select * from t1; -#clean up -connection master; -drop table t1; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_name_const.test b/mysql-test/t/rpl_name_const.test deleted file mode 100644 index adb71d452ef..00000000000 --- a/mysql-test/t/rpl_name_const.test +++ /dev/null @@ -1,47 +0,0 @@ -# ==== Purpose ==== -# -# Test that aliases of variables in binary log aren't ignored with NAME_CONST. -# -# ==== Method ==== -# -# Create a procedure with aliases of variables, then replicate it to slave. -# BUG#35515 Aliases of variables in binary log are ignored with NAME_CONST. -# - -source include/master-slave.inc; - ---echo ==== Initialize ==== - ---echo [on master] ---connection master - -create table t1 (id int); - ---echo ==== create a procedure that has a column aliase in a subquery ==== ---disable_warnings -drop procedure if exists test_procedure; ---enable_warnings -delimiter $$; -create procedure test_procedure(_id int) -begin -insert into t1 (id) -select a.id -from -( select _id as id ) a; -end;$$ -delimiter ;$$ - ---echo ==== enable the binary log, then call the procedure ==== -call test_procedure(1234); - - ---echo [on slave] -sync_slave_with_master; -select * from t1 order by id; - ---echo ==== Clean up ==== - ---echo [on master] -connection master; -drop table t1; -drop procedure test_procedure; diff --git a/mysql-test/t/rpl_ndb_innodb_trans-slave.opt b/mysql-test/t/rpl_ndb_innodb_trans-slave.opt deleted file mode 100644 index 627becdbfb5..00000000000 --- a/mysql-test/t/rpl_ndb_innodb_trans-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb diff --git a/mysql-test/t/rpl_ndb_innodb_trans.test b/mysql-test/t/rpl_ndb_innodb_trans.test deleted file mode 100644 index 127c2464570..00000000000 --- a/mysql-test/t/rpl_ndb_innodb_trans.test +++ /dev/null @@ -1,66 +0,0 @@ -# Test of a transaction mixing the two engines - --- source include/have_ndb.inc --- source include/have_innodb.inc --- source include/master-slave.inc - -create table t1 (a int, unique(a)) engine=ndbcluster; -create table t2 (a int, unique(a)) engine=innodb; - - -begin; -insert into t1 values(1); -insert into t2 values(1); -rollback; - -select count(*) from t1; -select count(*) from t2; -sync_slave_with_master; -select count(*) from t1; -select count(*) from t2; -connection master; - -begin; -load data infile '../std_data_ln/rpl_loaddata.dat' into table t2; -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; -rollback; - -select count(*) from t1; -select count(*) from t2; -sync_slave_with_master; -select count(*) from t1; -select count(*) from t2; -connection master; - -delete from t1; -delete from t2; -begin; -load data infile '../std_data_ln/rpl_loaddata.dat' into table t2; -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; -rollback; - -select count(*) from t1; -select count(*) from t2; -sync_slave_with_master; -select count(*) from t1; -select count(*) from t2; -connection master; - -delete from t1; -delete from t2; -begin; -insert into t2 values(3),(4); -insert into t1 values(3),(4); -load data infile '../std_data_ln/rpl_loaddata.dat' into table t2; -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; -rollback; - -select count(*) from t1; -select count(*) from t2; -sync_slave_with_master; -select count(*) from t1; -select count(*) from t2; -connection master; - -drop table t1,t2; -sync_slave_with_master; diff --git a/mysql-test/t/rpl_openssl.test b/mysql-test/t/rpl_openssl.test deleted file mode 100644 index 085620a9692..00000000000 --- a/mysql-test/t/rpl_openssl.test +++ /dev/null @@ -1,65 +0,0 @@ -source include/have_ssl.inc; -source include/master-slave.inc; - -# We don't test all types of ssl auth params here since it's a bit hard -# until problems with OpenSSL 0.9.7 are unresolved - -# creating replication user for whom ssl auth is required -# preparing playground -connection master; -grant replication slave on *.* to replssl@localhost require ssl; -create table t1 (t int); -save_master_pos; - -#syncing with master -connection slave; -sync_with_master; - -#trying to use this user without ssl -stop slave; -change master to master_user='replssl',master_password=''; -start slave; - -#showing that replication don't work -connection master; -insert into t1 values (1); -#reasonable timeout for changes to propagate to slave -sleep 3; -connection slave; -select * from t1; - -#showing that replication could work with ssl params -stop slave; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval change master to master_ssl=1 , master_ssl_ca ='$MYSQL_TEST_DIR/std_data/cacert.pem', master_ssl_cert='$MYSQL_TEST_DIR/std_data/client-cert.pem', master_ssl_key='$MYSQL_TEST_DIR/std_data/client-key.pem'; -start slave; - -#avoiding unneeded sleeps -connection master; -save_master_pos; -connection slave; -sync_with_master; - -#checking that replication is ok -select * from t1; - -#checking show slave status ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -#checking if replication works without ssl also performing clean up -stop slave; -change master to master_user='root',master_password='', master_ssl=0; -start slave; -connection master; -drop user replssl@localhost; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_optimize.test b/mysql-test/t/rpl_optimize.test deleted file mode 100644 index 6858f52abab..00000000000 --- a/mysql-test/t/rpl_optimize.test +++ /dev/null @@ -1,45 +0,0 @@ -# Test for BUG#1858 "OPTIMIZE TABLE done by a client -# thread stops the slave SQL thread". -# You can replace OPTIMIZE by REPAIR. - -source include/master-slave.inc; - -create table t1 (a int not null auto_increment primary key, b int, key(b)); -INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -INSERT INTO t1 (a) SELECT null FROM t1; -save_master_pos; -# a few updates to force OPTIMIZE to do something -update t1 set b=(a/2*rand()); -delete from t1 order by b limit 10000; - -connection slave; -sync_with_master; -optimize table t1; -connection master; -save_master_pos; -connection slave; -# Bug was that when the INSERT terminated on slave, -# the slave SQL thread got killed by OPTIMIZE. -sync_with_master; # won't work if slave SQL thread stopped - -connection master; # cleanup -drop table t1; -connection slave; -sync_with_master; - -# If the machine is so fast that slave syncs before OPTIMIZE -# starts, this test wil demonstrate nothing but will pass. - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_packet-master.opt b/mysql-test/t/rpl_packet-master.opt deleted file mode 100644 index 42d4f94c999..00000000000 --- a/mysql-test/t/rpl_packet-master.opt +++ /dev/null @@ -1 +0,0 @@ --O max_allowed_packet=1024 -O net_buffer_length=1024 diff --git a/mysql-test/t/rpl_packet-slave.opt b/mysql-test/t/rpl_packet-slave.opt deleted file mode 100644 index 42d4f94c999..00000000000 --- a/mysql-test/t/rpl_packet-slave.opt +++ /dev/null @@ -1 +0,0 @@ --O max_allowed_packet=1024 -O net_buffer_length=1024 diff --git a/mysql-test/t/rpl_packet.test b/mysql-test/t/rpl_packet.test deleted file mode 100644 index f7066c93b30..00000000000 --- a/mysql-test/t/rpl_packet.test +++ /dev/null @@ -1,98 +0,0 @@ -# -# Check replication protocol packet size handling -# Bug#19402 SQL close to the size of the max_allowed_packet fails on slave -# - -# max-out size db name -source include/master-slave.inc; - -let $db= DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________; -disable_warnings; -eval drop database if exists $db; -enable_warnings; -eval create database $db; - -connection master; -SET @@global.max_allowed_packet=1024; -SET @@global.net_buffer_length=1024; - -# Restart slave for setting to take effect -connection slave; -STOP SLAVE; -source include/wait_for_slave_to_stop.inc; -START SLAVE; -source include/wait_for_slave_to_start.inc; - -# Reconnect to master for new setting to take effect -disconnect master; - -# alas, can't use eval here; if db name changed apply the change here -connect (master,localhost,root,,DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________); - -connection master; -select @@net_buffer_length, @@max_allowed_packet; - -create table `t1` (`f1` LONGTEXT) ENGINE=MyISAM; - -INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1023'); -save_master_pos; - -connection slave; -sync_with_master; -eval select count(*) from `$db`.`t1` /* must be 1 */; - -connection master; -eval drop database $db; -save_master_pos; - -connection slave; -sync_with_master; - -# -# Bug #23755: Replicated event larger that max_allowed_packet infinitely re-transmits -# -# Check that a situation when the size of event on the master is greater than -# max_allowed_packet on the slave does not lead to infinite re-transmits. - -connection master; - -# Change the max packet size on master - -SET @@global.max_allowed_packet=4096; -SET @@global.net_buffer_length=4096; - -# Restart slave for new setting to take effect -connection slave; -STOP SLAVE; -source include/wait_for_slave_to_stop.inc; -START SLAVE; -source include/wait_for_slave_to_start.inc; - -# Reconnect to master for new setting to take effect -disconnect master; -connect (master, localhost, root); -connection master; - -CREATE TABLE `t1` (`f1` LONGTEXT) ENGINE=MyISAM; - -sync_slave_with_master; - -connection master; - -INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048'); - -# The slave I/O thread must stop after trying to read the above event -connection slave; ---source include/wait_for_slave_io_to_stop.inc -let $slave_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1); ---echo Slave_IO_Running = $slave_io_running (expect No) - - ---echo ==== clean up ==== -connection master; -DROP TABLE t1; -# slave is stopped -connection slave; -DROP TABLE t1; - -# End of tests diff --git a/mysql-test/t/rpl_ps.test b/mysql-test/t/rpl_ps.test deleted file mode 100644 index adf39b1e4ab..00000000000 --- a/mysql-test/t/rpl_ps.test +++ /dev/null @@ -1,44 +0,0 @@ -# -# Test of replicating user variables -# -source include/master-slave.inc; - -#save_master_pos; -#connection slave; -#sync_with_master; -#reset master; -#connection master; - ---disable_warnings -drop table if exists t1; ---enable_warnings - -create table t1(n char(30)); - -prepare stmt1 from 'insert into t1 values (?)'; -set @var1= "from-master-1"; -execute stmt1 using @var1; -set @var1= "from-master-2-'',"; -execute stmt1 using @var1; -select * from t1; - -set @var2= 'insert into t1 values (concat("from-var-", ?))'; -prepare stmt2 from @var2; -set @var1='from-master-3'; -execute stmt2 using @var1; - -save_master_pos; -connection slave; -sync_with_master; -select * from t1; - -connection master; - -drop table t1; - -save_master_pos; -connection slave; -sync_with_master; -stop slave; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_redirect.test b/mysql-test/t/rpl_redirect.test deleted file mode 100644 index beb18348b40..00000000000 --- a/mysql-test/t/rpl_redirect.test +++ /dev/null @@ -1,45 +0,0 @@ -# -# Test of automatic redirection of queries to master/slave. -# - -source include/master-slave.inc; -# We disable this for now as PS doesn't handle redirection ---disable_ps_protocol - -#first, make sure the slave has had enough time to register -save_master_pos; -connection slave; -sync_with_master; - -#discover slaves -connection master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -SHOW SLAVE STATUS; ---replace_result $SLAVE_MYPORT SLAVE_PORT -SHOW SLAVE HOSTS; -rpl_probe; - -#turn on master/slave query direction auto-magic -enable_rpl_parse; -create table t1 ( n int); -insert into t1 values (1),(2),(3),(4); -disable_rpl_parse; -save_master_pos; -connection slave; -sync_with_master; -insert into t1 values(5); -connection master; -enable_rpl_parse; -# The first of the queries will be sent to the slave, the second to the master. -select * from t1; -select * from t1; -disable_rpl_parse; -select * from t1; -connection slave; -select * from t1; -drop table t1; -connection master; -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_relayrotate-slave.opt b/mysql-test/t/rpl_relayrotate-slave.opt deleted file mode 100644 index 3a4abbf091e..00000000000 --- a/mysql-test/t/rpl_relayrotate-slave.opt +++ /dev/null @@ -1,3 +0,0 @@ --O max_relay_log_size=16384 ---innodb ---log-warnings diff --git a/mysql-test/t/rpl_relayrotate.test b/mysql-test/t/rpl_relayrotate.test deleted file mode 100644 index 04f03367e20..00000000000 --- a/mysql-test/t/rpl_relayrotate.test +++ /dev/null @@ -1,75 +0,0 @@ -# When the relay log gets rotated while the I/O thread -# is reading a transaction, the transaction spans on two or more -# relay logs. If STOP SLAVE occurs while the SQL thread is -# executing a part of the transaction in the non-first relay logs, -# we test if START SLAVE will resume in the beginning of the -# transaction (i.e., step back to the first relay log) - -# The slave is started with max_binlog_size=16384 bytes, -# to force many rotations (approximately 30 rotations) - -source include/have_innodb.inc; -source include/master-slave.inc; -connection slave; -stop slave; -connection master; ---disable_warnings -create table t1 (a int) engine=innodb; ---enable_warnings -let $1=8000; -disable_query_log; -begin; -while ($1) -{ -# eval means expand $ expressions - eval insert into t1 values( $1 ); - dec $1; -} -commit; -# This will generate a 500kB master's binlog, -# which corresponds to 30 slave's relay logs. -enable_query_log; -save_master_pos; -connection slave; -reset slave; -start slave; -# We wait 1 sec for the SQL thread to be somewhere in -# the middle of the transaction, hopefully not in -# the first relay log, and hopefully before the COMMIT. -# Usually it stops when the SQL thread is around the 15th relay log. -# We cannot use MASTER_POS_WAIT() as master's position -# increases only when the slave executes the COMMIT. -# Note that except when using Valgrind, 1 second is enough for the I/O slave -# thread to fetch the whole master's binlog. -sleep 1; -stop slave; -# We suppose the SQL thread stopped before COMMIT. -# If so the transaction was rolled back -# and the table is now empty. -# Now restart -start slave; -# And see if the table contains '8000' -# which proves that the transaction restarted at -# the right place. -# We must wait for the transaction to commit before -# reading: -sync_with_master; -select max(a) from t1; -connection master; - -# The following DROP is a very important cleaning task: -# imagine the next test is run with --skip-innodb: it will do -# DROP TABLE IF EXISTS t1; but this will delete the frm and leave -# some data in the InnoDB datafile (because at that time mysqld -# does not know about InnoDB : --skip-innodb). So if later in the -# test suite a test wants to create an InnoDB table called t1, it -# will fail with -# InnoDB: Error: table t1 already exists in InnoDB internal -# InnoDB: data dictionary. Have you deleted the .frm file etc -drop table t1; -# wait until this drop is executed on slave -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_relayspace-slave.opt b/mysql-test/t/rpl_relayspace-slave.opt deleted file mode 100644 index 06d96aa3b9a..00000000000 --- a/mysql-test/t/rpl_relayspace-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---relay_log_space_limit=10 diff --git a/mysql-test/t/rpl_relayspace.test b/mysql-test/t/rpl_relayspace.test deleted file mode 100644 index d4ef2fe59bd..00000000000 --- a/mysql-test/t/rpl_relayspace.test +++ /dev/null @@ -1,50 +0,0 @@ -# The slave is started with relay_log_space_limit=10 bytes, -# to force the deadlock after one event. - -source include/master-slave.inc; -connection slave; -stop slave; -connection master; -# This will generate a master's binlog > 10 bytes -create table t1 (a int); -drop table t1; -create table t1 (a int); -drop table t1; -connection slave; -reset slave; -start slave io_thread; -# Give the I/O thread time to block. -let $run= 1; -let $counter= 300; -while ($run) -{ - let $io_state= query_get_value("SHOW SLAVE STATUS", Slave_IO_State, 1); - if (`SELECT '$io_state' = 'Waiting for the slave SQL thread to free enough relay log space'`){ - let $run= 0; - } - sleep 0.1; - if (!$counter){ - --echo "Failed while waiting for slave IO thread block" - SHOW SLAVE STATUS; - exit; - } - dec $counter; -} -sleep 2; -# A bug caused the I/O thread to refuse stopping. -stop slave io_thread; -reset slave; -start slave; -# The I/O thread stops filling the relay log when -# it's >10b. And the SQL thread cannot purge this relay log -# as purge is done only when the SQL thread switches to another -# relay log, which does not exist here. -# So we should have a deadlock. -# if it is not resolved automatically we'll detect -# it with master_pos_wait that waits for farther than 1Ob; -# it will timeout after 10 seconds; -# also the slave will probably not cooperate to shutdown -# (as 2 threads are locked) -select master_pos_wait('master-bin.001',200,6)=-1; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_replicate_do-slave.opt b/mysql-test/t/rpl_replicate_do-slave.opt deleted file mode 100644 index da345474216..00000000000 --- a/mysql-test/t/rpl_replicate_do-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---replicate-do-table=test.t1 diff --git a/mysql-test/t/rpl_replicate_do.test b/mysql-test/t/rpl_replicate_do.test deleted file mode 100644 index 0e95d71514b..00000000000 --- a/mysql-test/t/rpl_replicate_do.test +++ /dev/null @@ -1,93 +0,0 @@ -# This test assumes we are ignoring updates on table t2, but doing -# updates on t1 - -source include/master-slave.inc; ---disable_warnings -drop table if exists t11; -connection slave; -drop table if exists t11; ---enable_warnings - -create table t2 (n int); -insert into t2 values(4); -connection master; -create table t2 (s char(20)); -load data infile '../std_data_ln/words.dat' into table t2; -insert into t2 values('five'); -create table t1 (m int); -insert into t1 values(15),(16),(17); -update t1 set m=20 where m=16; -delete from t1 where m=17; -create table t11 select * from t1; -save_master_pos; -connection slave; -sync_with_master; -select * from t1; -select * from t2; ---error 1146 -select * from t11; -connection master; -drop table if exists t1,t2,t11; -save_master_pos; -connection slave; -sync_with_master; -# show slave status, just to see of it prints replicate-do-table ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -# -# BUG#12542 -# TEST: "SET ONE_SHOT should always be executed on slave" -# -# We could use any timezone different than server default in this test -# -connection master; -create table t1 (ts timestamp); -set one_shot time_zone='met'; -insert into t1 values('2005-08-12 00:00:00'); -set one_shot time_zone='met'; -select * from t1; -sync_slave_with_master; - -connection slave; -set one_shot time_zone='met'; -select * from t1; - -connection master; -drop table t1; -sync_slave_with_master; - -# End of 4.1 tests - -# -# Bug#24478 DROP TRIGGER is not caught by replicate-*-table filters -# ---echo *** master *** -connection master; -create table t1 (a int, b int); -create trigger trg1 before insert on t1 for each row set new.b=2; -create table t2 (a int, b int); -create trigger trg2 before insert on t2 for each row set new.b=2; -show tables; -show triggers; -sync_slave_with_master; ---echo *** slave *** -connection slave; -show tables; -show triggers; ---echo *** master *** -connection master; -drop trigger trg1; -drop trigger trg2; -show triggers; -sync_slave_with_master; ---echo *** slave *** -connection slave; -show tables; -show triggers; ---echo *** master *** -connection master; -drop table t1; -drop table t2; -sync_slave_with_master; diff --git a/mysql-test/t/rpl_reset_slave.test b/mysql-test/t/rpl_reset_slave.test deleted file mode 100644 index 00b1cf68294..00000000000 --- a/mysql-test/t/rpl_reset_slave.test +++ /dev/null @@ -1,51 +0,0 @@ -# See SHOW SLAVE STATUS displays well after RESET SLAVE (it should display the -# --master-* options from mysqld, as this is what is going to be used next time -# slave threads will be started). In bug 985, it displayed old values (of before -# RESET SLAVE). -# See if slave crashes when doing a CREATE TEMPORARY TABLE twice, separated by -# RESET SLAVE. - -source include/master-slave.inc; -connection master; -save_master_pos; -connection slave; -sync_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -stop slave; -change master to master_user='test'; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -reset slave; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -start slave; -sync_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; - -# test of crash with temp tables & RESET SLAVE -# (test to see if RESET SLAVE clears temp tables in memory and disk) -stop slave; -reset slave; -start slave; -connection master; -create temporary table t1 (a int); -save_master_pos; -connection slave; -sync_with_master; -stop slave; -reset slave; -start slave; -sync_with_master; -show status like 'slave_open_temp_tables'; - -# End of 4.1 tests -# diff --git a/mysql-test/t/rpl_rewrite_db-slave.opt b/mysql-test/t/rpl_rewrite_db-slave.opt deleted file mode 100644 index 290b92e0a3e..00000000000 --- a/mysql-test/t/rpl_rewrite_db-slave.opt +++ /dev/null @@ -1 +0,0 @@ -"--replicate-rewrite-db=test->rewrite" "--replicate-rewrite-db=mysqltest1->test" "--replicate-rewrite-db=database_master_temp_01->database_slave_temp_01" "--replicate-rewrite-db=database_master_temp_02->database_slave_temp_02" "--replicate-rewrite-db=database_master_temp_03->database_slave_temp_03" diff --git a/mysql-test/t/rpl_rewrite_db.test b/mysql-test/t/rpl_rewrite_db.test deleted file mode 100644 index a9742f252be..00000000000 --- a/mysql-test/t/rpl_rewrite_db.test +++ /dev/null @@ -1,236 +0,0 @@ -source include/master-slave.inc; ---disable_warnings -drop database if exists mysqltest1; ---enable_warnings -create database mysqltest1; - -use mysqltest1; -create table t1 (a int); -insert into t1 values(9); -select * from mysqltest1.t1; -sync_slave_with_master; -show databases like 'mysqltest1'; # should be empty -select * from test.t1; -# cleanup -connection master; -drop table t1; -drop database mysqltest1; -sync_slave_with_master; - -# -# BUG#6353: -# Option --replicate-rewrite-db should work together with LOAD DATA INFILE -# - -connection slave; ---disable_warnings -drop database if exists rewrite; ---enable_warnings -create database rewrite; - -connection master; -use test; -create table t1 (a date, b date, c date not null, d date); -load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ','; -load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; -sync_slave_with_master; - -connection slave; -select * from rewrite.t1; - -connection master; -truncate table t1; -load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); -sync_slave_with_master; - -connection slave; -select * from rewrite.t1; - -connection master; -drop table t1; -create table t1 (a text, b text); -load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; -sync_slave_with_master; - -connection slave; -select concat('|',a,'|'), concat('|',b,'|') from rewrite.t1; - -connection master; -drop table t1; -create table t1 (a int, b char(10)); -load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; -sync_slave_with_master; - -connection slave; -select * from rewrite.t1; - -connection master; -truncate table t1; -load data infile '../std_data_ln/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; -sync_slave_with_master; - -connection slave; -# The empty line last comes from the end line field in the file -select * from rewrite.t1; - -set sql_log_bin= 0; -drop database rewrite; -set sql_log_bin= 1; - -connection master; -set sql_log_bin= 0; -drop table t1; -set sql_log_bin= 1; - -# End of 4.1 tests - ---echo ---echo **** ---echo **** Bug #46861 Auto-closing of temporary tables broken by replicate-rewrite-db ---echo **** ---echo - ---echo **** ---echo **** Preparing the environment ---echo **** -connection master; - -connect (con_temp_03,127.0.0.1,root,,test,$MASTER_MYPORT,); -connect (con_temp_02,127.0.0.1,root,,test,$MASTER_MYPORT,); -connect (con_temp_01,127.0.0.1,root,,test,$MASTER_MYPORT,); - -connection master; -SET sql_log_bin= 0; -CREATE DATABASE database_master_temp_01; -CREATE DATABASE database_master_temp_02; -CREATE DATABASE database_master_temp_03; -SET sql_log_bin= 1; - -connection slave; -SET sql_log_bin= 0; -CREATE DATABASE database_slave_temp_01; -CREATE DATABASE database_slave_temp_02; -CREATE DATABASE database_slave_temp_03; -SET sql_log_bin= 1; - ---echo ---echo **** ---echo **** Creating temporary tables on different databases with different connections ---echo **** ---echo **** con_temp_01 --> creates ---echo **** t_01_01_temp on database_master_temp_01 ---echo **** ---echo **** con_temp_02 --> creates ---echo **** t_01_01_temp on database_master_temp_01 ---echo **** t_02_01_temp, t_02_02_temp on database_master_temp_02 ---echo **** ---echo **** con_temp_02 --> creates ---echo **** t_01_01_temp on database_master_temp_01 ---echo **** t_02_01_temp, t_02_02_temp on database_master_temp_02 ---echo **** t_03_01_temp, t_03_02_temp, t_03_03_temp on database_master_temp_03 ---echo **** - ---echo ---echo con_temp_01 ---echo -connection con_temp_01; -USE database_master_temp_01; -CREATE TEMPORARY TABLE t_01_01_temp(a int); -INSERT INTO t_01_01_temp VALUES(1); - ---echo ---echo con_temp_02 ---echo -connection con_temp_02; -USE database_master_temp_01; -CREATE TEMPORARY TABLE t_01_01_temp(a int); -INSERT INTO t_01_01_temp VALUES(1); -USE database_master_temp_02; -CREATE TEMPORARY TABLE t_02_01_temp(a int); -INSERT INTO t_02_01_temp VALUES(1); -CREATE TEMPORARY TABLE t_02_02_temp(a int); -INSERT INTO t_02_02_temp VALUES(1); - ---echo ---echo con_temp_03 ---echo -connection con_temp_03; -USE database_master_temp_01; -CREATE TEMPORARY TABLE t_01_01_temp(a int); -INSERT INTO t_01_01_temp VALUES(1); -USE database_master_temp_02; -CREATE TEMPORARY TABLE t_02_01_temp(a int); -INSERT INTO t_02_01_temp VALUES(1); -CREATE TEMPORARY TABLE t_02_02_temp(a int); -INSERT INTO t_02_02_temp VALUES(1); -USE database_master_temp_03; -CREATE TEMPORARY TABLE t_03_01_temp(a int); -INSERT INTO t_03_01_temp VALUES(1); -CREATE TEMPORARY TABLE t_03_02_temp(a int); -INSERT INTO t_03_02_temp VALUES(1); -CREATE TEMPORARY TABLE t_03_03_temp(a int); -INSERT INTO t_03_03_temp VALUES(1); - ---echo ---echo **** Dropping the connections ---echo **** We want to SHOW BINLOG EVENTS, to know what was logged. But there is no ---echo **** guarantee that logging of the terminated con1 has been done yet.a To be ---echo **** sure that logging has been done, we use a user lock. ---echo -connection master; -sync_slave_with_master; -connection slave; -show status like 'Slave_open_temp_tables'; - -connection master; -let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); -connection con_temp_01; -select get_lock("con_01",10); -connection master; -disconnect con_temp_01; -select get_lock("con_01",10); - -connection con_temp_02; -select get_lock("con_02",10); -connection master; -disconnect con_temp_02; -select get_lock("con_02",10); - -connection con_temp_03; -select get_lock("con_03",10); -connection master; -disconnect con_temp_03; -select get_lock("con_03",10); - ---echo ---echo **** Checking the binary log and temporary tables ---echo -connection master; -sync_slave_with_master; -connection slave; -show status like 'Slave_open_temp_tables'; - -connection master; ---source include/show_binlog_events.inc - ---echo **** ---echo **** Cleaning up the test case ---echo **** -connection master; -SET sql_log_bin= 0; -DROP DATABASE database_master_temp_01; -DROP DATABASE database_master_temp_02; -DROP DATABASE database_master_temp_03; -SET sql_log_bin= 1; - -connection slave; -SET sql_log_bin= 0; -DROP DATABASE database_slave_temp_01; -DROP DATABASE database_slave_temp_02; -DROP DATABASE database_slave_temp_03; -SET sql_log_bin= 1; - -connection master; -sync_slave_with_master; - -# end of 5.0 tests diff --git a/mysql-test/t/rpl_rotate_logs-master.opt b/mysql-test/t/rpl_rotate_logs-master.opt deleted file mode 100644 index ad2c6a647b5..00000000000 --- a/mysql-test/t/rpl_rotate_logs-master.opt +++ /dev/null @@ -1 +0,0 @@ --O max_binlog_size=4096 diff --git a/mysql-test/t/rpl_rotate_logs-slave.sh b/mysql-test/t/rpl_rotate_logs-slave.sh deleted file mode 100755 index 81490a54b4b..00000000000 --- a/mysql-test/t/rpl_rotate_logs-slave.sh +++ /dev/null @@ -1,2 +0,0 @@ -rm -f $MYSQLTEST_VARDIR/slave-data/master.info -rm -f $MYSQLTEST_VARDIR/slave-data/*relay* diff --git a/mysql-test/t/rpl_rotate_logs.slave-mi b/mysql-test/t/rpl_rotate_logs.slave-mi deleted file mode 100644 index 80190bf6d29..00000000000 --- a/mysql-test/t/rpl_rotate_logs.slave-mi +++ /dev/null @@ -1 +0,0 @@ ---server-id=2 diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test deleted file mode 100644 index 0b7efb81f61..00000000000 --- a/mysql-test/t/rpl_rotate_logs.test +++ /dev/null @@ -1,184 +0,0 @@ -# This test uses chmod, can't be run with root permissions --- source include/not_as_root.inc - --- source include/have_log_bin.inc - -# -# Test is run with max_binlog_size=2048 to force automatic rotation of the -# binary log -# Tests done: -# - Check that slaves reports correct failures if master.info has strange -# modes/information -# - Automatic binary log rotation -# - Ensure that temporary tables works over flush logs and binary log -# changes -# - Test creating a duplicate key error and recover from it - -connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); ---disable_warnings -drop table if exists t1, t2, t3, t4; ---enable_warnings -connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK); -# Create empty file -write_file $MYSQLTEST_VARDIR/slave-data/master.info; -EOF -chmod 0000 $MYSQLTEST_VARDIR/slave-data/master.info; -connection slave; ---disable_warnings -drop table if exists t1, t2, t3, t4; ---enable_warnings - -# START SLAVE will fail because it can't read the file (mode 000) -# (system error 13) ---replace_result $MYSQL_TEST_DIR TESTDIR ---error 1105,1105,29 -start slave; -chmod 0600 $MYSQLTEST_VARDIR/slave-data/master.info; -# It will fail again because the file is empty so the slave cannot get valuable -# info about how to connect to the master from it (failure in -# init_strvar_from_file() in init_master_info()). ---error 1201 -start slave; ---replace_result $MASTER_MYPORT MASTER_PORT - -# CHANGE MASTER will fail because it first parses master.info before changing -# it (so when master.info is bad, people have to use RESET SLAVE first). ---error 1201 -eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root'; -reset slave; ---replace_result $MASTER_MYPORT MASTER_PORT -eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root'; -connection master; -reset master; -connection slave; -start slave; -connection master; - -# -# Test FLUSH LOGS -# -create temporary table temp_table (a char(80) not null); -insert into temp_table values ("testing temporary tables"); -create table t1 (s text); -insert into t1 values('Could not break slave'),('Tried hard'); -sync_slave_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; -select * from t1; -connection master; -flush logs; -create table t2(m int not null auto_increment primary key); -insert into t2 values (34),(67),(123); -flush logs; -show binary logs; -create table t3 select * from temp_table; - -sync_slave_with_master; - -select * from t3; -connection master; -drop table temp_table, t3; - -# -# Now lets make some duplicate key mess and see if we can recover from it -# - -# First insert a value on the slave -connection slave; -insert into t2 values(1234); - -#same value on the master -connection master; -set insert_id=1234; -insert into t2 values(NULL); -connection slave; -wait_for_slave_to_stop; - -#restart slave skipping one event -set global sql_slave_skip_counter=1; -start slave; - -connection master; - -#let slave catch up -sync_slave_with_master; -connection master; -purge master logs to 'master-bin.000002'; -show master logs; -# we just tests if synonyms are accepted -purge binary logs to 'master-bin.000002'; -show binary logs; - -# Calculate time to use in "purge master logs before" by taking -# last modification time of t2 and adding 1 second -# This is donw in order to handle the case where file system -# time differs from mysqld's time ---disable_result_log -select @time_for_purge:=DATE_ADD(UPDATE_TIME, INTERVAL 1 SECOND) - from information_schema.tables - where TABLE_SCHEMA="test" and TABLE_NAME="t2"; ---enable_result_log - -purge master logs before (@time_for_purge); -show binary logs; -insert into t2 values (65); -sync_slave_with_master; ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; -select * from t2; - -# -# Test forcing the replication log to rotate -# - -connection master; -create temporary table temp_table (a char(80) not null); -insert into temp_table values ("testing temporary tables part 2"); -let $1=100; - -create table t3 (n int); -disable_query_log; -while ($1) -{ -#eval means expand $ expressions - eval insert into t3 values($1 + 4); - dec $1; -} -enable_query_log; -select count(*) from t3 where n >= 4; -create table t4 select * from temp_table; -show binary logs; -show master status; -save_master_pos; -connection slave; -sync_with_master; -select * from t4; - ---replace_result $MASTER_MYPORT MASTER_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; -# because of concurrent insert, the table may not be up to date -# if we do not lock -lock tables t3 read; -select count(*) from t3 where n >= 4; -unlock tables; -#clean up -connection master; -drop table if exists t1,t2,t3,t4; -sync_slave_with_master; - ---echo End of 4.1 tests - -# -# Bug #29420: crash with show and purge binlogs -# ---error 1220 -show binlog events in 'non existing_binlog_file'; -purge master logs before now(); ---error 1220 -show binlog events in ''; -purge master logs before now(); - ---echo End of 5.0 tests diff --git a/mysql-test/t/rpl_server_id.test b/mysql-test/t/rpl_server_id.test deleted file mode 100644 index 6e98ec6ee6d..00000000000 --- a/mysql-test/t/rpl_server_id.test +++ /dev/null @@ -1,29 +0,0 @@ -# Test for BUG#28908 Replication: set global server_id is not setting the session server_id - --- source include/have_log_bin.inc - -let $saved_server_id=`select @@server_id`; -set global server_id=1; -reset master; - --- disable_warnings -drop table if exists t1,t2,t3; --- enable_warnings - -create table t1 (a int); -select @@server_id; -source include/show_binlog_events2.inc; - -set global server_id=2; -create table t2 (b int); -select @@server_id; -source include/show_binlog_events2.inc; - -set global server_id=3; -create table t3 (c int); -select @@server_id; -source include/show_binlog_events2.inc; - -# cleanup -eval set global server_id=$saved_server_id; -drop table t1,t2,t3; diff --git a/mysql-test/t/rpl_server_id1.test b/mysql-test/t/rpl_server_id1.test deleted file mode 100644 index 3583f05284c..00000000000 --- a/mysql-test/t/rpl_server_id1.test +++ /dev/null @@ -1,26 +0,0 @@ -# This test checks that the slave I/O thread refuses to start if slave -# and master have the same server id (because this is a useless setup, -# and otherwise SHOW SLAVE STATUS shows progress but all queries are -# ignored, which has caught our customers), unless -# --replicate-same-server-id. - -source include/master-slave.inc; -connection slave; -create table t1 (n int); -reset master; -# replicate ourselves -stop slave; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval change master to master_port=$SLAVE_MYPORT; ---replace_result $SLAVE_MYPORT SLAVE_PORT ---replace_column 18 # -show slave status; -start slave; -insert into t1 values (1); -# can't MASTER_POS_WAIT(), it does not work in this weird setup -# (when slave is its own master without --replicate-same-server-id) -sleep 2; # enough time for the event to be replicated (it should not) -show status like "slave_running"; -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_server_id2-slave.opt b/mysql-test/t/rpl_server_id2-slave.opt deleted file mode 100644 index 302889525dd..00000000000 --- a/mysql-test/t/rpl_server_id2-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---disable-log-slave-updates --replicate-same-server-id diff --git a/mysql-test/t/rpl_server_id2.test b/mysql-test/t/rpl_server_id2.test deleted file mode 100644 index 0f2eb560d18..00000000000 --- a/mysql-test/t/rpl_server_id2.test +++ /dev/null @@ -1,26 +0,0 @@ -# This test checks that a slave DOES execute queries originating -# from itself, if running with --replicate-same-server-id. - -source include/master-slave.inc; -connection slave; -create table t1 (n int); -reset master; -# replicate ourselves -stop slave; ---replace_result $SLAVE_MYPORT SLAVE_PORT -eval change master to master_port=$SLAVE_MYPORT; ---replace_result $SLAVE_MYPORT SLAVE_PORT ---replace_column 18 # -show slave status; -start slave; -insert into t1 values (1); -save_master_pos; -sync_with_master; -select * from t1; # check that indeed 2 were inserted -# We stop the slave before cleaning up otherwise we'll get -# 'drop table t1' executed twice, so an error in the slave.err -# (not critical). -stop slave; -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_session_var.test b/mysql-test/t/rpl_session_var.test deleted file mode 100644 index 8231a0dbefd..00000000000 --- a/mysql-test/t/rpl_session_var.test +++ /dev/null @@ -1,64 +0,0 @@ -# Replication of session variables. -# FOREIGN_KEY_CHECKS is tested in rpl_insert_id.test - -source include/master-slave.inc; -drop table if exists t1; -create table t1(a varchar(100),b int); -set @@session.sql_mode=pipes_as_concat; -insert into t1 values('My'||'SQL', 1); -set @@session.sql_mode=default; -insert into t1 values('1'||'2', 2); -select * from t1 where b<3 order by a; -save_master_pos; -connection slave; -sync_with_master; -select * from t1 where b<3 order by a; -connection master; -# if the slave does the next sync_with_master fine, then it means it accepts the -# two lines of ANSI syntax below, which is what we want to check. -set @@session.sql_mode=ignore_space; -insert into t1 values(password ('MySQL'), 3); -set @@session.sql_mode=ansi_quotes; -create table "t2" ("a" int); -drop table t1, t2; -set @@session.sql_mode=default; -create table t1(a int auto_increment primary key); -create table t2(b int, a int); -set @@session.sql_auto_is_null=1; -insert into t1 values(null); -insert into t2 select 1,a from t1 where a is null; -set @@session.sql_auto_is_null=0; -insert into t1 values(null); -insert into t2 select 2,a from t1 where a is null; -select * from t2 order by b; -save_master_pos; -connection slave; -sync_with_master; -select * from t2 order by b; -connection master; -drop table t1,t2; -save_master_pos; -connection slave; -sync_with_master; - -# -# Bug #29878 Garbage data generation when executing SESSION_USER() on a slave. -# - -connection master; -CREATE TABLE t1 ( - `id` int(11) NOT NULL auto_increment, - `data` varchar(100), - PRIMARY KEY (`id`) - ) ENGINE=MyISAM; - -INSERT INTO t1(data) VALUES(SESSION_USER()); -save_master_pos; -connection slave; -sync_with_master; -SELECT * FROM t1; -connection master; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; diff --git a/mysql-test/t/rpl_set_charset.test b/mysql-test/t/rpl_set_charset.test deleted file mode 100644 index c70eb2681f5..00000000000 --- a/mysql-test/t/rpl_set_charset.test +++ /dev/null @@ -1,35 +0,0 @@ -source include/master-slave.inc; ---disable_warnings -drop database if exists mysqltest1; -# 4.1 bases its conversion on the db's charset, -# while 4.0 uses the part of "SET CHARACTER SET" after "_". -# So for 4.1 we add a clause to CREATE DATABASE. -create database mysqltest1 /*!40100 character set latin2 */; -use mysqltest1; -drop table if exists t1; ---enable_warnings -create table t1 (a varchar(255) character set latin2, b varchar(4)); -SET CHARACTER SET cp1250_latin2; -INSERT INTO t1 VALUES ('','80'); -INSERT INTO t1 VALUES ('','90'); -INSERT INTO t1 VALUES ('','A0'); -INSERT INTO t1 VALUES ('','B0'); -INSERT INTO t1 VALUES ('','C0'); -INSERT INTO t1 VALUES ('','D0'); -INSERT INTO t1 VALUES ('','E0'); -INSERT INTO t1 VALUES ('','F0'); -select "--- on master ---"; -select hex(a),b from t1 order by b; -save_master_pos; -connection slave; -sync_with_master; -use mysqltest1; -select "--- on slave ---"; -select hex(a),b from t1 order by b; -connection master; -drop database mysqltest1; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_skip_error-slave.opt b/mysql-test/t/rpl_skip_error-slave.opt deleted file mode 100644 index f6f258f799f..00000000000 --- a/mysql-test/t/rpl_skip_error-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---slave-skip-error=1053,1062 diff --git a/mysql-test/t/rpl_skip_error.test b/mysql-test/t/rpl_skip_error.test deleted file mode 100644 index 0e3fd5d9e0d..00000000000 --- a/mysql-test/t/rpl_skip_error.test +++ /dev/null @@ -1,41 +0,0 @@ -source include/master-slave.inc; - -create table t1 (n int not null primary key); -save_master_pos; -connection slave; -sync_with_master; -insert into t1 values (1); -connection master; -insert into t1 values (1); -insert into t1 values (2),(3); -save_master_pos; -connection slave; -sync_with_master; -select * from t1; - -connection master; -drop table t1; -sync_slave_with_master; -# End of 4.1 tests - -# -# #28839 Errors in strict mode silently stop SQL thread if --slave-skip-errors exists -# -connection master; -create table t1(a int primary key); -insert into t1 values (1),(2); -delete from t1 where @@server_id=1; -set sql_mode=strict_trans_tables; -select @@server_id; -insert into t1 values (1),(2),(3); -sync_slave_with_master; -connection slave; -select @@server_id; -select * from t1; ---replace_column 1 # 8 # 9 # 23 # 33 # ---replace_result $MASTER_MYPORT MASTER_PORT -show slave status; -connection master; -drop table t1; -sync_slave_with_master; -# End of 5.0 tests diff --git a/mysql-test/t/rpl_slave_skip-slave.opt b/mysql-test/t/rpl_slave_skip-slave.opt deleted file mode 100644 index 627becdbfb5..00000000000 --- a/mysql-test/t/rpl_slave_skip-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb diff --git a/mysql-test/t/rpl_slave_skip.test b/mysql-test/t/rpl_slave_skip.test deleted file mode 100644 index 71e951aceea..00000000000 --- a/mysql-test/t/rpl_slave_skip.test +++ /dev/null @@ -1,366 +0,0 @@ -source include/have_innodb.inc; -source include/master-slave.inc; - -# This test is for checking that the use of SQL_SLAVE_SKIP_COUNTER -# behaves as expected, i.e., that it is guaranteed to skip an entire -# group and not start executing in the middle of a transaction. - -# We are checking the correct behaviour when using both a -# transactional and non-transactional table. The non-transactional -# table comes into play when rolling back a transaction containing a -# write to this table. In that case, the transaction should still be -# written to the binary log, and the slave will apply it and then roll -# it back to get the non-transactional change into the table. - ---echo **** On Master **** -CREATE TABLE t1 (a INT, b SET('master','slave')) ENGINE=InnoDB; -CREATE TABLE t2 (a INT, b SET('master','slave')) ENGINE=MyISAM; -CREATE TABLE t3 (a CHAR(20), b SET('master','slave')) ENGINE=InnoDB; -CREATE TABLE t4 (a CHAR(20), b SET('master','slave')) ENGINE=MyISAM; - ---echo ==== Skipping normal transactions ==== - ---echo **** On Slave **** -sync_slave_with_master; -STOP SLAVE; -source include/wait_for_slave_to_stop.inc; - ---echo **** On Master **** -connection master; - -BEGIN; -INSERT INTO t1 VALUES (1, 'master'); -INSERT INTO t1 VALUES (2, 'master'); -INSERT INTO t1 VALUES (3, 'master'); -COMMIT; - -BEGIN; -INSERT INTO t1 VALUES (4, 'master,slave'); -INSERT INTO t1 VALUES (5, 'master,slave'); -INSERT INTO t1 VALUES (6, 'master,slave'); -COMMIT; - -save_master_pos; - -SELECT * FROM t1 ORDER BY a; - -# This will skip a begin event and the first INSERT of the -# transaction, and it should keep skipping until it has reached the -# transaction terminator. - ---echo **** On Slave **** -connection slave; -SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; -START SLAVE; -source include/wait_for_slave_to_start.inc; -sync_with_master; -SELECT * FROM t1 ORDER BY a; - ---echo **** On Master **** -connection master; -DELETE FROM t1; -sync_slave_with_master; - ---echo ==== Skipping two normal transactions ==== - ---echo **** On Slave **** -connection slave; -STOP SLAVE; -source include/wait_for_slave_to_stop.inc; - ---echo **** On Master **** -connection master; - -BEGIN; -INSERT INTO t1 VALUES (1, 'master'); -INSERT INTO t1 VALUES (2, 'master'); -INSERT INTO t1 VALUES (3, 'master'); -COMMIT; - -BEGIN; -INSERT INTO t1 VALUES (4, 'master'); -INSERT INTO t1 VALUES (5, 'master'); -INSERT INTO t1 VALUES (6, 'master'); -COMMIT; - -BEGIN; -INSERT INTO t1 VALUES (7, 'master,slave'); -INSERT INTO t1 VALUES (8, 'master,slave'); -INSERT INTO t1 VALUES (9, 'master,slave'); -COMMIT; - -save_master_pos; - -SELECT * FROM t1 ORDER BY a; - -# This will skip a begin event and the first INSERT of the -# transaction, and it should keep skipping until it has reached the -# transaction terminator. - ---echo **** On Slave **** -connection slave; -SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8; -START SLAVE; -source include/wait_for_slave_to_start.inc; -sync_with_master; -SELECT * FROM t1 ORDER BY a; - ---echo **** On Master **** -connection master; -DELETE FROM t1; -sync_slave_with_master; - ---echo ==== Skipping without autocommit ==== - -# Testing without using autocommit instead. It should still write a -# BEGIN event, so the behaviour should be the same - ---echo **** On Slave **** -connection slave; -STOP SLAVE; -source include/wait_for_slave_to_stop.inc; - ---echo **** On Master **** -connection master; -SET AUTOCOMMIT=0; - -INSERT INTO t1 VALUES (1, 'master'); -INSERT INTO t1 VALUES (2, 'master'); -INSERT INTO t1 VALUES (3, 'master'); -COMMIT; - -INSERT INTO t1 VALUES (4, 'master,slave'); -INSERT INTO t1 VALUES (5, 'master,slave'); -INSERT INTO t1 VALUES (6, 'master,slave'); -COMMIT; - -save_master_pos; - -SELECT * FROM t1 ORDER BY a; - -# This will skip a begin event and the first INSERT of the -# transaction, and it should keep skipping until it has reached the -# transaction terminator. - ---echo **** On Slave **** -connection slave; -SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; -START SLAVE; -source include/wait_for_slave_to_start.inc; -sync_with_master; -SELECT * FROM t1 ORDER BY a; - -# Testing with a non-transactional table in the transaction. This will -# log a ROLLBACK as a transaction terminator, which is a normal Query -# log event. - ---echo ==== Rollback of transaction with non-transactional change ==== - ---echo **** On Master **** -connection master; -DELETE FROM t1; -SET AUTOCOMMIT=1; - ---echo **** On Slave **** -sync_slave_with_master; -STOP SLAVE; -source include/wait_for_slave_to_stop.inc; - ---echo **** On Master **** -connection master; -disable_warnings; -BEGIN; -INSERT INTO t1 VALUES (1, ''); -INSERT INTO t2 VALUES (2, 'master'); -INSERT INTO t1 VALUES (3, ''); -ROLLBACK; - -BEGIN; -INSERT INTO t1 VALUES (4, ''); -INSERT INTO t2 VALUES (5, 'master,slave'); -INSERT INTO t1 VALUES (6, ''); -ROLLBACK; -enable_warnings; - -save_master_pos; - -SELECT * FROM t1 ORDER BY a; -SELECT * FROM t2 ORDER BY a; - ---echo **** On Slave **** -connection slave; -SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; -START SLAVE; -source include/wait_for_slave_to_start.inc; -sync_with_master; - -SELECT * FROM t1 ORDER BY a; -SELECT * FROM t2 ORDER BY a; - ---echo ==== Skipping first event of a LOAD DATA for a transactional table ==== - ---echo **** On Slave **** -connection slave; -STOP SLAVE; -source include/wait_for_slave_to_stop.inc; - ---echo **** On Master **** -connection master; -SET AUTOCOMMIT=1; - -LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t3(a) SET b = 'master'; -INSERT INTO t3 VALUES ('Go Rin No Sho', 'master,slave'); - -save_master_pos; - -SELECT COUNT(*) FROM t3; - -# This will skip a begin event and the first INSERT of the -# transaction, and it should keep skipping until it has reached the -# transaction terminator. - ---echo **** On Slave **** -connection slave; -SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; -START SLAVE; -source include/wait_for_slave_to_start.inc; -sync_with_master; ---echo -- Should only contain records marked 'master,slave' -SELECT * FROM t3 ORDER BY a; - ---echo **** On Master **** -connection master; -DELETE FROM t3; -sync_slave_with_master; - ---echo ==== Skipping first event of a LOAD DATA for a non-transactional table ==== - ---echo **** On Slave **** -connection slave; -STOP SLAVE; -source include/wait_for_slave_to_stop.inc; - ---echo **** On Master **** -connection master; -SET AUTOCOMMIT=1; - -LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t4(a) SET b = 'master'; -INSERT INTO t4 VALUES ('Go Rin No Sho', 'master,slave'); - -save_master_pos; - -SELECT COUNT(*) FROM t4; - -# This will skip a begin event and the first INSERT of the -# transaction, and it should keep skipping until it has reached the -# transaction terminator. - ---echo **** On Slave **** -connection slave; -SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; -START SLAVE; -source include/wait_for_slave_to_start.inc; -sync_with_master; ---echo -- Should only contain records marked 'master,slave' -SELECT * FROM t4 ORDER BY a; - ---echo **** On Master **** -connection master; -DELETE FROM t4; -sync_slave_with_master; - ---echo ==== Try with a big file so that we get an append_block event as well - ---echo **** On Slave **** -connection slave; -STOP SLAVE; -source include/wait_for_slave_to_stop.inc; - ---echo **** On Master **** -connection master; -SET AUTOCOMMIT=1; - -# This contain about 70 words, so we double it a few times to get more than 128 KiB -SET SQL_LOG_BIN=0; -LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t4(a) SET b = 'master'; -INSERT INTO t4 SELECT * FROM t4; -INSERT INTO t4 SELECT * FROM t4; -INSERT INTO t4 SELECT * FROM t4; -INSERT INTO t4 SELECT * FROM t4; -INSERT INTO t4 SELECT * FROM t4; -INSERT INTO t4 SELECT * FROM t4; -INSERT INTO t4 SELECT * FROM t4; -INSERT INTO t4 SELECT * FROM t4; -INSERT INTO t4 SELECT * FROM t4; -INSERT INTO t4 SELECT * FROM t4; -INSERT INTO t4 SELECT * FROM t4; -SELECT a FROM t4 INTO OUTFILE 'rpl_slave_skip_words.dat'; -SET SQL_LOG_BIN=1; - -# Start the real job -LOAD DATA INFILE 'rpl_slave_skip_words.dat' INTO TABLE t4(a) SET b = 'master'; -INSERT INTO t4 VALUES ('Go Rin No Sho', 'master,slave'); - -#SHOW BINLOG EVENTS; - -save_master_pos; - -SELECT COUNT(*) FROM t4; - -# This will skip a begin event and the first INSERT of the -# transaction, and it should keep skipping until it has reached the -# transaction terminator. - ---echo **** On Slave **** -connection slave; -SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; -START SLAVE; -source include/wait_for_slave_to_start.inc; -sync_with_master; ---echo -- Should only contain records marked 'master,slave' -SELECT * FROM t4 ORDER BY a; - ---echo **** On Master **** -connection master; -DELETE FROM t4; -sync_slave_with_master; - -# Test to generate a Delete_file log event, and see that it works as well. ---echo **** On Master **** -connection master; -CREATE TABLE t5 (a int, b int, c SET('master','slave'), PRIMARY KEY (a,b)) ENGINE=MyISAM; -LOAD DATA INFILE '../std_data_ln/loaddata5.dat' INTO TABLE t5 FIELDS TERMINATED BY '' ENCLOSED BY '' (a,b) SET c='master,slave'; - ---echo **** On Slave **** -sync_slave_with_master; -STOP SLAVE; -source include/wait_for_slave_to_stop.inc; - ---echo **** On Master **** -connection master; -error ER_DUP_ENTRY; -LOAD DATA INFILE '../std_data_ln/loaddata5.dat' INTO TABLE t5 FIELDS TERMINATED BY '' ENCLOSED BY '' (a,b) SET c=''; -INSERT INTO t5 VALUES (42, 42, 'master,slave'); -save_master_pos; - -#SHOW BINLOG EVENTS; - -SELECT * FROM t5; - ---echo **** On Slave **** -connection slave; -SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; -START SLAVE; -source include/wait_for_slave_to_start.inc; - -sync_with_master; -SELECT * FROM t5; - -connection slave; - ---echo ==== Cleanup ==== - ---echo **** On Master **** -connection master; -DROP TABLE t1, t2, t3, t4, t5; -sync_slave_with_master; diff --git a/mysql-test/t/rpl_slave_status.test b/mysql-test/t/rpl_slave_status.test deleted file mode 100644 index 527e230854a..00000000000 --- a/mysql-test/t/rpl_slave_status.test +++ /dev/null @@ -1,40 +0,0 @@ -# Test case for BUG #10780 ---source include/master-slave.inc -connection master; -grant replication slave on *.* to rpl@127.0.0.1 identified by 'rpl'; -connection slave; -stop slave; -change master to master_user='rpl',master_password='rpl'; -start slave; -connection master; ---disable_warnings -drop table if exists t1; ---enable_warnings -create table t1 (n int); -insert into t1 values (1); -save_master_pos; -connection slave; -sync_with_master; -select * from t1; -connection master; -delete from mysql.user where user='rpl'; -flush privileges; -connection slave; -stop slave; -start slave; ---replace_result $MASTER_MYPORT MASTER_MYPORT -# Column 1 is replaced, since the output can be either -# "Connecting to master" or "Waiting for master update" ---replace_column 1 # 7 # 8 # 9 # 22 # 23 # ---vertical_results -show slave status; - -# cleanup: slave io thread has been stopped "irrecoverably" -# so we clean up mess manually - -connection master; -drop table t1; -connection slave; -drop table t1; - -# end of 4.1 tests diff --git a/mysql-test/t/rpl_sp-master.opt b/mysql-test/t/rpl_sp-master.opt deleted file mode 100644 index 709a224fd92..00000000000 --- a/mysql-test/t/rpl_sp-master.opt +++ /dev/null @@ -1 +0,0 @@ ---log_bin_trust_routine_creators=0 diff --git a/mysql-test/t/rpl_sp-slave.opt b/mysql-test/t/rpl_sp-slave.opt deleted file mode 100644 index 709a224fd92..00000000000 --- a/mysql-test/t/rpl_sp-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---log_bin_trust_routine_creators=0 diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test deleted file mode 100644 index 6ac6729e662..00000000000 --- a/mysql-test/t/rpl_sp.test +++ /dev/null @@ -1,641 +0,0 @@ -# Test of replication of stored procedures (WL#2146 for MySQL 5.0) -# Modified by WL#2971. - -# Note that in the .opt files we still use the old variable name -# log-bin-trust-routine-creators so that this test checks that it's -# still accepted (this test also checks that the new name is -# accepted). The old name could be removed in 5.1 or 6.0. - -source include/master-slave.inc; -# Save the current value and restore at end of testing -let $log_bin_trust_function_creators= - `SELECT @@global.log_bin_trust_function_creators`; - -# we need a db != test, where we don't have automatic grants ---disable_warnings -drop database if exists mysqltest1; ---enable_warnings -create database mysqltest1; -use mysqltest1; -create table t1 (a varchar(100)); -sync_slave_with_master; -use mysqltest1; - -# ********************** PART 1 : STORED PROCEDURES *************** - -# Does the same proc as on master get inserted into mysql.proc ? -# (same definer, same properties...) - -connection master; - -delimiter |; - -# Stored procedures don't have the limitations that functions have -# regarding binlogging: it's ok to create a procedure as not -# deterministic and updating data, while it's not ok to create such a -# function. We test this. - -create procedure foo() -begin - declare b int; - set b = 8; - insert into t1 values (b); - insert into t1 values (unix_timestamp()); -end| -delimiter ;| - -# we replace columns having times -# (even with fixed timestamp displayed time may changed based on TZ) ---replace_result localhost.localdomain localhost 127.0.0.1 localhost ---replace_column 13 # 14 # -select * from mysql.proc where name='foo' and db='mysqltest1'; -sync_slave_with_master; -# You will notice in the result that the definer does not match what -# it is on master, it is a known bug on which Alik is working ---replace_result localhost.localdomain localhost 127.0.0.1 localhost ---replace_column 13 # 14 # -select * from mysql.proc where name='foo' and db='mysqltest1'; - -connection master; -# see if timestamp used in SP on slave is same as on master -set timestamp=1000000000; -call foo(); -select * from t1; -sync_slave_with_master; -select * from t1; - -# Now a SP which is not updating tables - -connection master; -delete from t1; -create procedure foo2() - select * from mysqltest1.t1; -call foo2(); - -# check that this is allowed (it's not for functions): -alter procedure foo2 contains sql; - -# SP with definer's right - -drop table t1; -create table t1 (a int); -create table t2 like t1; - -create procedure foo3() - deterministic - insert into t1 values (15); - -# let's create a non-privileged user -grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1; -grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1; -grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1; - -# ToDo: BUG#14931: There is a race between the last grant binlogging, and -# the binlogging in the new connection made below, causing sporadic test -# failures due to switched statement order in binlog. To fix this we do -# SELECT 1 in the first connection before starting the second, ensuring -# that binlogging is done in the expected order. -# Please remove this SELECT 1 when BUG#14931 is fixed. -SELECT 1; - -connect (con1,127.0.0.1,zedjzlcsjhd,,mysqltest1,$MASTER_MYPORT,); -connection con1; - -# this routine will fail in the second INSERT because of privileges -delimiter |; -create procedure foo4() - deterministic - begin - insert into t2 values(3); - insert into t1 values (5); - end| - -delimiter ;| - -# I add ,0 so that it does not print the error in the test output, -# because this error is hostname-dependent ---error 1142,0 -call foo4(); # invoker has no INSERT grant on table t1 => failure - -connection master; -call foo3(); # success (definer == root) -show warnings; - ---error 1142,0 -call foo4(); # definer's rights => failure - -# we test replication of ALTER PROCEDURE -alter procedure foo4 sql security invoker; -call foo4(); # invoker's rights => success -show warnings; - -# Note that half-failed procedure calls are ok with binlogging; -# if we compare t2 on master and slave we see they are identical: - -select * from t1; -select * from t2; -sync_slave_with_master; -select * from t1; -select * from t2; - -# Let's check another failing-in-the-middle procedure -connection master; -delete from t2; -alter table t2 add unique (a); - -drop procedure foo4; -delimiter |; -create procedure foo4() - deterministic - begin - insert into t2 values(20),(20); - end| - -delimiter ;| - ---error 1062 -call foo4(); -show warnings; - -select * from t2; -sync_slave_with_master; -# check that this failed-in-the-middle replicated right: -select * from t2; - -# Test of DROP PROCEDURE - ---replace_result localhost.localdomain localhost 127.0.0.1 localhost ---replace_column 13 # 14 # -select * from mysql.proc where name="foo4" and db='mysqltest1'; -connection master; -drop procedure foo4; -select * from mysql.proc where name="foo4" and db='mysqltest1'; -sync_slave_with_master; -select * from mysql.proc where name="foo4" and db='mysqltest1'; - -# ********************** PART 2 : FUNCTIONS *************** - -connection master; -drop procedure foo; -drop procedure foo2; -drop procedure foo3; - -delimiter |; -# check that needs "deterministic" ---error 1418 -create function fn1(x int) - returns int -begin - insert into t1 values (x); - return x+2; -end| -create function fn1(x int) - returns int - deterministic -begin - insert into t1 values (x); - return x+2; -end| - -delimiter ;| -delete t1,t2 from t1,t2; -select fn1(20); -insert into t2 values(fn1(21)); -select * from t1; -select * from t2; -sync_slave_with_master; -select * from t1; -select * from t2; - -connection master; -delimiter |; - -drop function fn1; - -create function fn1() - returns int - no sql -begin - return unix_timestamp(); -end| - -delimiter ;| -# check that needs "deterministic" ---error 1418 -alter function fn1 contains sql; - -delete from t1; -set timestamp=1000000000; -insert into t1 values(fn1()); - -connection con1; - -delimiter |; ---error 1419 # only full-global-privs user can create a function -create function fn2() - returns int - no sql -begin - return unix_timestamp(); -end| -delimiter ;| -connection master; -# test old variable name: -set global log_bin_trust_routine_creators=1; -# now use new name: -set global log_bin_trust_function_creators=0; -set global log_bin_trust_function_creators=1; -# slave needs it too otherwise will not execute what master allowed: -connection slave; -set global log_bin_trust_function_creators=1; - -connection con1; - -delimiter |; -create function fn2() - returns int - no sql -begin - return unix_timestamp(); -end| -delimiter ;| - -connection master; - -# Now a function which is supposed to not update tables -# as it's "reads sql data", so should not give error even if -# non-deterministic. - -delimiter |; -create function fn3() - returns int - not deterministic - reads sql data -begin - return 0; -end| -delimiter ;| - -select fn3(); ---replace_result localhost.localdomain localhost 127.0.0.1 localhost ---replace_column 13 # 14 # -select * from mysql.proc where db='mysqltest1'; -select * from t1; - -sync_slave_with_master; -use mysqltest1; -select * from t1; ---replace_result localhost.localdomain localhost 127.0.0.1 localhost ---replace_column 13 # 14 # -select * from mysql.proc where db='mysqltest1'; - -# Let's check a failing-in-the-middle function -connection master; -delete from t2; -alter table t2 add unique (a); - -drop function fn1; - -delimiter |; -create function fn1(x int) - returns int -begin - insert into t2 values(x),(x); - return 10; -end| - -delimiter ;| - -do fn1(100); - ---error 1062 -select fn1(20); - -select * from t2; -sync_slave_with_master; - -# check that this failed-in-the-middle replicated right: -select * from t2; - -# ********************** PART 3 : TRIGGERS *************** - -connection con1; ---error 1227 -create trigger trg before insert on t1 for each row set new.a= 10; - -connection master; -delete from t1; -# TODO: when triggers can contain an update, test that this update -# does not go into binlog. -# I'm not setting user vars in the trigger, because replication of user vars -# would take care of propagating the user var's value to slave, so even if -# the trigger was not executed on slave it would not be discovered. -create trigger trg before insert on t1 for each row set new.a= 10; -insert into t1 values (1); -select * from t1; -sync_slave_with_master; -select * from t1; - -connection master; -delete from t1; -drop trigger trg; -insert into t1 values (1); -select * from t1; -sync_slave_with_master; -select * from t1; - - -# ********************** PART 4 : RELATED FIXED BUGS *************** - - -# -# Test for bug #13969 "Routines which are replicated from master can't be -# executed on slave". -# -connection master; -create procedure foo() - not deterministic - reads sql data - select * from t1; -sync_slave_with_master; -# This should not fail -call foo(); -connection master; -drop procedure foo; -sync_slave_with_master; - - -# Clean up -connection master; -drop function fn1; -drop database mysqltest1; -drop user "zedjzlcsjhd"@127.0.0.1; -use test; -sync_slave_with_master; -use test; - -# -# Bug#14077 "Failure to replicate a stored function with a cursor": -# verify that stored routines with cursors work on slave. -# -connection master; ---disable_warnings -drop function if exists f1; ---enable_warnings -delimiter |; -create function f1() returns int reads sql data -begin - declare var integer; - declare c cursor for select a from v1; - open c; - fetch c into var; - close c; - return var; -end| -delimiter ;| -create view v1 as select 1 as a; -create table t1 (a int); -insert into t1 (a) values (f1()); -select * from t1; -drop view v1; -drop function f1; -sync_slave_with_master; -connection slave; -select * from t1; - -# -# Bug#16621 "INSERTs in Stored Procedures causes data corruption in the Binary -# Log for 5.0.18" -# - -# Prepare environment. - -connection master; - ---disable_warnings -DROP PROCEDURE IF EXISTS p1; -DROP TABLE IF EXISTS t1; ---enable_warnings - -# Test case. - -CREATE TABLE t1(col VARCHAR(10)); - -CREATE PROCEDURE p1(arg VARCHAR(10)) - INSERT INTO t1 VALUES(arg); - -CALL p1('test'); - -SELECT * FROM t1; - -sync_slave_with_master; -connection slave; - -SELECT * FROM t1; - -# Cleanup. - -connection master; - -DROP PROCEDURE p1; - - -# -# BUG#20438: CREATE statements for views, stored routines and triggers can be -# not replicable. -# - ---echo ---echo ---> Test for BUG#20438 - -# Prepare environment. - ---echo ---echo ---> Preparing environment... ---echo ---> connection: master ---connection master - ---disable_warnings -DROP PROCEDURE IF EXISTS p1; -DROP FUNCTION IF EXISTS f1; ---enable_warnings - ---echo ---echo ---> Synchronizing slave with master... - ---save_master_pos ---connection slave ---sync_with_master - ---echo ---echo ---> connection: master ---connection master - -# Test. - ---echo ---echo ---> Creating procedure... - -/*!50003 CREATE PROCEDURE p1() SET @a = 1 */; - -/*!50003 CREATE FUNCTION f1() RETURNS INT RETURN 0 */; - ---echo ---echo ---> Checking on master... - -SHOW CREATE PROCEDURE p1; -SHOW CREATE FUNCTION f1; - ---echo ---echo ---> Synchronizing slave with master... - ---save_master_pos ---connection slave ---sync_with_master - ---echo ---> connection: master - ---echo ---echo ---> Checking on slave... - -SHOW CREATE PROCEDURE p1; -SHOW CREATE FUNCTION f1; - -# Cleanup. - ---echo ---echo ---> connection: master ---connection master - ---echo ---echo ---> Cleaning up... - -DROP PROCEDURE p1; -DROP FUNCTION f1; - ---save_master_pos ---connection slave ---sync_with_master ---connection master - - -# cleanup -connection master; -drop table t1; -sync_slave_with_master; - -# -# Bug22043: MySQL don't add "USE <DATABASE>" before "DROP PROCEDURE IF EXISTS" -# - -connection master; ---disable_warnings -drop database if exists mysqltest; -drop database if exists mysqltest2; ---enable_warnings -create database mysqltest; -create database mysqltest2; -use mysqltest2; -create table t ( t integer ); -create procedure mysqltest.test() begin end; -insert into t values ( 1 ); ---error ER_WRONG_DB_NAME -create procedure `\\`.test() begin end; - -# -# BUG#19725: Calls to stored function in other database are not -# replicated correctly in some cases -# - -connection master; -delimiter |; -create function f1 () returns int -begin - insert into t values (1); - return 0; -end| -delimiter ;| -sync_slave_with_master; -# Let us test if we don't forget to binlog the function's database -connection master; -use mysqltest; -set @a:= mysqltest2.f1(); -sync_slave_with_master; -connection master; - -# Final inspection which verifies how all statements of this test file -# were written to the binary log. ---replace_column 2 # 5 # -show binlog events in 'master-bin.000001' from 98; - - -# Restore log_bin_trust_function_creators to its original value. -# This is a cleanup for all parts above where we tested stored -# functions and triggers. -set global log_bin_trust_function_creators=0; -connection master; -set global log_bin_trust_function_creators=0; - -# Clean up -drop database mysqltest; -drop database mysqltest2; -sync_slave_with_master; - -# -# Bug#36570: Parse error of CREATE PROCEDURE stmt with comments on slave -# -connection master; -use test; -delimiter |; - -/*!50001 create procedure `mysqltestbug36570_p1`() */ -begin - select 1; -end| - -use mysql| -create procedure test.` mysqltestbug36570_p2`(/*!50001 a int*/)`label`: -begin - select a; -end| - -/*!50001 create function test.mysqltestbug36570_f1() */ - returns int - /*!50001 deterministic */ -begin - return 3; -end| -use test| - -delimiter ;| - ---replace_column 5 t 6 t -show procedure status like '%mysqltestbug36570%'; -show create procedure ` mysqltestbug36570_p2`; - -sync_slave_with_master; -connection slave; - ---replace_column 5 t 6 t -show procedure status like '%mysqltestbug36570%'; -show create procedure ` mysqltestbug36570_p2`; -call ` mysqltestbug36570_p2`(42); - ---replace_column 5 t 6 t -show function status like '%mysqltestbug36570%'; - -connection master; -flush logs; ---replace_regex s/$MYSQL_TEST_DIR/MYSQL_TEST_DIR/ s/TIMESTAMP=[0-9]*/TIMESTAMP=t/ ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 -use test; -drop procedure mysqltestbug36570_p1; -drop procedure ` mysqltestbug36570_p2`; -drop function mysqltestbug36570_f1; - -# Cleanup -sync_slave_with_master; -# Restore the initial value of log_bin_trust_function_creators -eval -set global log_bin_trust_function_creators = $log_bin_trust_function_creators; - diff --git a/mysql-test/t/rpl_sp_effects-master.opt b/mysql-test/t/rpl_sp_effects-master.opt deleted file mode 100644 index 61dd7a6ad0e..00000000000 --- a/mysql-test/t/rpl_sp_effects-master.opt +++ /dev/null @@ -1 +0,0 @@ ---log_bin_trust_routine_creators=1 diff --git a/mysql-test/t/rpl_sp_effects-slave.opt b/mysql-test/t/rpl_sp_effects-slave.opt deleted file mode 100644 index 61dd7a6ad0e..00000000000 --- a/mysql-test/t/rpl_sp_effects-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---log_bin_trust_routine_creators=1 diff --git a/mysql-test/t/rpl_sp_effects.test b/mysql-test/t/rpl_sp_effects.test deleted file mode 100644 index f18710efa37..00000000000 --- a/mysql-test/t/rpl_sp_effects.test +++ /dev/null @@ -1,254 +0,0 @@ -# Test of replication of stored procedures (WL#2146 for MySQL 5.0) - -source include/master-slave.inc; - -# **************************************************************** -connection master; - -# cleanup ---disable_warnings -drop procedure if exists p1; -drop procedure if exists p2; -drop function if exists f1; -drop table if exists t1,t2; -drop view if exists v1; ---enable_warnings -create table t1 (a int); - -# 1. Test simple variables use. -delimiter //; -create procedure p1() -begin - declare spv int default 0; - while spv < 5 do - insert into t1 values(spv+1); - set spv=spv+1; - end while; -end// -delimiter ;// - -call p1(); - -sync_slave_with_master; -connection slave; -select * from t1; -connection master; -delete from t1; - -# 2. Test SP variable name -delimiter //; -create procedure p2() -begin - declare a int default 4; - create table t2 as select a; -end// -delimiter ;// - -call p2(); -select * from t2; -sync_slave_with_master; -connection slave; -select * from t2; - -connection master; -drop procedure p1; -drop procedure p2; -drop table t2; - -# 3. Test FUNCTIONs in various places - -delimiter //; -create function f1(x int) returns int -begin - insert into t1 values(x); - return x+1; -end// - -create procedure p1(a int, b int) -begin - declare v int default f1(5); - if (f1(6)) then - select 'yes'; - end if; - set v = f1(7); - while f1(8) < 1 do - select 'this cant be'; - end while; - -end// -delimiter ;// - -call p1(f1(1), f1(2)); -select * from t1; - -create table t2(a int); -insert into t2 values (10),(11); -select a,f1(a) from t2; - -# This shouldn't put separate 'call f1(3)' into binlog: -insert into t2 select f1(3); -select 'master:',a from t1; - -sync_slave_with_master; -connection slave; -select 'slave:',a from t1; - -connection master; -drop procedure p1; -delete from t1; -delete from t2; - -# 4. VIEWs -delete from t1; -insert into t2 values(1),(2); -create view v1 as select f1(a) from t2; -select * from v1; -select 'master:',a from t1; - -sync_slave_with_master; -connection slave; -select 'slave:',a from t1; - -connection master; -drop view v1; -delete from t1; - -# 5. Prepared statements. -prepare s1 from 'select f1(?)'; -set @xx=123; -execute s1 using @xx; -select 'master:',a from t1; - -sync_slave_with_master; -connection slave; -select 'slave:',a from t1; - -connection master; -delete from t1; - -# 5. Cursors. -# t2 has (1),(2); -delimiter //; -create procedure p1(spv int) -begin - declare c cursor for select f1(spv) from t2; - while (spv > 2) do - open c; - fetch c into spv; - close c; - set spv= spv - 10; - end while; -end// -delimiter ;// - -call p1(15); -select 'master:',a from t1; -sync_slave_with_master; -connection slave; -select 'slave:',a from t1; - -connection master; -drop procedure p1; -drop function f1; -drop table t1,t2; - -# BUG#12637: User variables + SPs replication -create table t1 (a int); -delimiter //; -create procedure p1() -begin - insert into t1 values(@x); - set @x=@x+1; - insert into t1 values(@x); - if (f2()) then - insert into t1 values(1243); - end if; -end// - -create function f2() returns int -begin - insert into t1 values(@z); - set @z=@z+1; - insert into t1 values(@z); - return 0; -end// - -create function f1() returns int -begin - insert into t1 values(@y); - call p1(); - return 0; -end// - -delimiter ;// - -set @x=10; -set @y=20; -set @z=100; -select f1(); - -set @x=30; -call p1(); - -select 'master', a from t1; -sync_slave_with_master; -connection slave; -select 'slave', a from t1; - -# -# cleanup -# - -connection master; -drop table t1; -drop function f1; -drop function f2; -drop procedure p1; -sync_slave_with_master; - -# -# bug#26199 Replication Failure on Slave when using stored procs -# with bit-type parameters - -connection master; - -create table t2 (b BIT(7)); -delimiter //; -create procedure sp_bug26199(bitvalue BIT(7)) -begin - insert into t2 set b = bitvalue; -end // - -create function sf_bug26199(b BIT(7)) returns int -begin - insert into t2 values(b); - return 0; -end// - -DELIMITER ;// - - - -call sp_bug26199(b'1110'); -call sp_bug26199('\0'); -select sf_bug26199(b'1111111'); -select sf_bug26199(b'101111111'); -select sf_bug26199('\''); -select hex(b) from t2; - -sync_slave_with_master; -#connection slave; -select hex(b) from t2; - -# -# cleanup bug#26199 -# -connection master; -drop table t2; -drop procedure sp_bug26199; -drop function sf_bug26199; - -sync_slave_with_master; - - ---echo end of the tests diff --git a/mysql-test/t/rpl_sporadic_master-master.opt b/mysql-test/t/rpl_sporadic_master-master.opt deleted file mode 100644 index 6d5b66bed61..00000000000 --- a/mysql-test/t/rpl_sporadic_master-master.opt +++ /dev/null @@ -1 +0,0 @@ ---sporadic-binlog-dump-fail --max-binlog-dump-events=2 diff --git a/mysql-test/t/rpl_sporadic_master.test b/mysql-test/t/rpl_sporadic_master.test deleted file mode 100644 index 26b633a1c4f..00000000000 --- a/mysql-test/t/rpl_sporadic_master.test +++ /dev/null @@ -1,26 +0,0 @@ -# test to see if replication can continue when master sporadically fails on -# COM_BINLOG_DUMP and additionally limits the number of events per dump - -source include/master-slave.inc; - -create table t2(n int); -create table t1(n int not null auto_increment primary key); -insert into t1 values (NULL),(NULL); -truncate table t1; -# We have to use 4 in the following to make this test work with all table types -insert into t1 values (4),(NULL); -sync_slave_with_master; -stop slave; -start slave; -connection master; -insert into t1 values (NULL),(NULL); -flush logs; -truncate table t1; -insert into t1 values (10),(NULL),(NULL),(NULL),(NULL),(NULL); -sync_slave_with_master; -select * from t1; -connection master; -drop table t1,t2; -sync_slave_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_ssl.test b/mysql-test/t/rpl_ssl.test deleted file mode 100644 index bf4dcbf8af0..00000000000 --- a/mysql-test/t/rpl_ssl.test +++ /dev/null @@ -1,79 +0,0 @@ -source include/have_ssl.inc; -source include/master-slave.inc; - -# create a user for replication that requires ssl encryption -connection master; -grant replication slave on *.* to replssl@localhost require ssl; -create table t1 (t int auto_increment, KEY(t)); - -sync_slave_with_master; - -# Set slave to use SSL for connection to master -stop slave; ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -eval change master to - master_user='replssl', - master_password='', - master_ssl=1, - master_ssl_ca ='$MYSQL_TEST_DIR/std_data/cacert.pem', - master_ssl_cert='$MYSQL_TEST_DIR/std_data/client-cert.pem', - master_ssl_key='$MYSQL_TEST_DIR/std_data/client-key.pem'; -start slave; - -# Switch to master and insert one record, then sync it to slave -connection master; -insert into t1 values(1); -sync_slave_with_master; - -# The record should now be on slave -select * from t1; - -# The slave is synced and waiting/reading from master -# SHOW SLAVE STATUS will show "Waiting for master to send event" ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 8 # 9 # 23 # 33 # -query_vertical show slave status; - -# Stop the slave, as reported in bug#21871 it would hang -STOP SLAVE; - -select * from t1; - -# Do the same thing a number of times -disable_query_log; -disable_result_log; -let $i= 100; -while ($i) -{ - start slave; - connection master; - insert into t1 values (NULL); - select * from t1; # Some variance - connection slave; - select * from t1; # Some variance - stop slave; - dec $i; -} -start slave; -enable_query_log; -enable_result_log; -connection master; -insert into t1 values (NULL); -let $master_count= `select count(*) from t1`; - -sync_slave_with_master; ---source include/wait_for_slave_to_start.inc ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # -query_vertical show slave status; - -let $slave_count= `select count(*) from t1`; - -if (`select $slave_count != $master_count`) -{ - echo master and slave differed in number of rows; - echo master: $master_count; - echo slave: $slave_count; -} - ---echo End of 5.0 tests diff --git a/mysql-test/t/rpl_start_stop_slave.test b/mysql-test/t/rpl_start_stop_slave.test deleted file mode 100644 index 19988cf902a..00000000000 --- a/mysql-test/t/rpl_start_stop_slave.test +++ /dev/null @@ -1,36 +0,0 @@ -source include/master-slave.inc; - -# -# Bug#6148 () -# -connection slave; -stop slave; - -# Let the master do lots of insertions -connection master; -create table t1(n int); -let $1=5000; -disable_query_log; -while ($1) -{ - eval insert into t1 values($1); - dec $1; -} -enable_query_log; -save_master_pos; - -connection slave; -start slave; -sleep 1; -stop slave io_thread; -start slave io_thread; -sync_with_master; - -connection master; -drop table t1; -save_master_pos; - -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test deleted file mode 100644 index 4cd538877eb..00000000000 --- a/mysql-test/t/rpl_temporary.test +++ /dev/null @@ -1,290 +0,0 @@ -# Test need anonymous user when connection are made as "zedjzlcsjhd" -source include/add_anonymous_users.inc; - -source include/master-slave.inc; - -# Clean up old slave's binlogs. -# The slave is started with --log-slave-updates -# and this test does SHOW BINLOG EVENTS on the slave's -# binlog. But previous tests can influence the current test's -# binlog (e.g. a temporary table in the previous test has not -# been explicitly deleted, or it has but the slave hasn't had -# enough time to catch it before STOP SLAVE, -# and at the beginning of the current -# test the slave immediately writes DROP TEMPORARY TABLE this_old_table). -# We wait for the slave to have written all he wants to the binlog -# (otherwise RESET MASTER may come too early). -save_master_pos; -connection slave; -sync_with_master; -reset master; -connection master; - -connect (con1,localhost,root,,); -connect (con2,localhost,root,,); -# We want to connect as an unprivileged user. But if we use user="" then this -# will pick the Unix login, which will cause problems if you're running the -# test as root. -connect (con3,localhost,zedjzlcsjhd,,); - -# We are going to use SET PSEUDO_THREAD_ID in this test; -# check that it requires the SUPER privilege. - -connection con3; -SET @save_select_limit=@@session.sql_select_limit; ---error 1227 -SET @@session.sql_select_limit=10, @@session.pseudo_thread_id=100; -SELECT @@session.sql_select_limit = @save_select_limit; #shouldn't have changed -# While we are here we also test that SQL_LOG_BIN can't be set ---error 1227 -SET @@session.sql_select_limit=10, @@session.sql_log_bin=0; -SELECT @@session.sql_select_limit = @save_select_limit; #shouldn't have changed -# Now as root, to be sure it works -connection con2; -SET @@session.pseudo_thread_id=100; -SET @@session.pseudo_thread_id=connection_id(); -SET @@session.sql_log_bin=0; -SET @@session.sql_log_bin=1; - -connection con3; -let $VERSION=`select version()`; - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - -create table t1(f int); -create table t2(f int); -insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); - -connection con1; -create temporary table t3(f int); -insert into t3 select * from t1 where f<6; -sleep 1; - -connection con2; -create temporary table t3(f int); -sleep 1; - -connection con1; -insert into t2 select count(*) from t3; -sleep 1; - -connection con2; -insert into t3 select * from t1 where f>=4; -sleep 1; - -connection con1; -drop temporary table t3; -sleep 1; - -connection con2; -insert into t2 select count(*) from t3; -drop temporary table t3; - -select * from t2; - ---replace_result $VERSION VERSION ---replace_column 2 # 5 # -show binlog events; - -drop table t1, t2; - -use test; -SET TIMESTAMP=1040323920; -create table t1(f int); -SET TIMESTAMP=1040323931; -create table t2(f int); -SET TIMESTAMP=1040323938; -insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); - -SET TIMESTAMP=1040323945; -SET @@session.pseudo_thread_id=1; -create temporary table t3(f int); -SET TIMESTAMP=1040323952; -SET @@session.pseudo_thread_id=1; -insert into t3 select * from t1 where f<6; -SET TIMESTAMP=1040324145; -SET @@session.pseudo_thread_id=2; -create temporary table t3(f int); -SET TIMESTAMP=1040324186; -SET @@session.pseudo_thread_id=1; -insert into t2 select count(*) from t3; -SET TIMESTAMP=1040324200; -SET @@session.pseudo_thread_id=2; -insert into t3 select * from t1 where f>=4; -SET TIMESTAMP=1040324211; -SET @@session.pseudo_thread_id=1; -drop temporary table t3; -SET TIMESTAMP=1040324219; -SET @@session.pseudo_thread_id=2; -insert into t2 select count(*) from t3; -SET TIMESTAMP=1040324224; -SET @@session.pseudo_thread_id=2; -drop temporary table t3; - -select * from t2; -drop table t1,t2; - -# Create last a temporary table that is not dropped at end to ensure that we -# don't get any memory leaks for this - -create temporary table t3 (f int); -sync_slave_with_master; - -# The server will now close done - -# -# Bug#17284 erroneous temp table cleanup on slave -# - -connection master; -create temporary table t4 (f int); -create table t5 (f int); -sync_slave_with_master; -connection master; -# find dumper's $id -source include/get_binlog_dump_thread_id.inc; -insert into t4 values (1); -# a hint how to do that in 5.1 ---replace_result $id "`select id from information_schema.processlist where command='Binlog Dump'`" -eval kill $id; # to stimulate reconnection by slave w/o timeout -insert into t5 select * from t4; -save_master_pos; - -connection slave; -sync_with_master; -select * from t5 /* must be 1 after reconnection */; - -connection master; -drop temporary table t4; -drop table t5; - -# -# BUG#17263 incorrect generation DROP temp tables -# Temporary tables of connection are dropped in batches -# where a batch correspond to pseudo_thread_id -# value was set up at the moment of temp table creation -# -connection con1; -set @@session.pseudo_thread_id=100; -create temporary table t101 (id int); -create temporary table t102 (id int); -set @@session.pseudo_thread_id=200; -create temporary table t201 (id int); -create temporary table `t``201` (id int); -# emulate internal temp table not to come to binlog -create temporary table `#sql_not_user_table202` (id int); -set @@session.pseudo_thread_id=300; -create temporary table t301 (id int); -create temporary table t302 (id int); -create temporary table `#sql_not_user_table303` (id int); -disconnect con1; - -#now do something to show that slave is ok after DROP temp tables -connection master; -create table t1(f int); -insert into t1 values (1); - -sync_slave_with_master; -#connection slave; -select * from t1 /* must be 1 */; - -connection master; -drop table t1; - -# -#14157: utf8 encoding in binlog without set character_set_client -# ---write_file $MYSQLTEST_VARDIR/tmp/bug14157.sql -create table t1 (a int); -set names latin1; -create temporary table `` (a int); -insert into `` values (1); -insert into t1 select * from `` -EOF ---exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=latin1 test < $MYSQLTEST_VARDIR/tmp/bug14157.sql - -sync_slave_with_master; -#connection slave; -select * from t1; - -connection master; -drop table t1; - ---remove_file $MYSQLTEST_VARDIR/tmp/bug14157.sql - -# Delete the anonymous users -source include/delete_anonymous_users.inc; - -# ################################################################## -# BUG#41725: slave crashes when inserting into temporary table after -# stop/start slave -# -# This test checks that both reported issues (assertion failure and -# crash) go away. It is implemented as follows: -# -# case 1: assertion failure -# i) create and insert into temporary table on master -# ii) sync slave with master -# iii) stop and restart slave -# iv) insert into master another value -# v) sync slave with master -# -# -# case 2: crash (SIGSEV) -# i) create and insert into temporary table on master (insert -# produces warnings) -# ii) sync slave with master -# iii) stop and restart slave -# iv) insert into master more values -# v) sync slave with master - -# case 1: Assertion in Field_string::store() failed because current -# thread reference differed from table->in_use after slave -# restart - -connection master; - -disable_warnings; -DROP TABLE IF EXISTS t1; -enable_warnings; - -CREATE TEMPORARY TABLE t1 (a char(1)); -INSERT INTO t1 VALUES ('a'); -sync_slave_with_master; - -source include/stop_slave.inc; -source include/start_slave.inc; - -connection master; -INSERT INTO t1 VALUES ('b'); -sync_slave_with_master; - -# case 2: crash on sp_rcontext::find_handler because it used -# reference to invalid THD object after slave restart - -connection master; - -disable_warnings; -DROP TABLE IF EXISTS t1; -enable_warnings; -CREATE TEMPORARY TABLE `t1`(`a` tinyint,`b` char(1))engine=myisam; -INSERT INTO `t1` set `a`=128,`b`='128'; - -sync_slave_with_master; - -source include/stop_slave.inc; -source include/start_slave.inc; - -connection master; -INSERT INTO `t1` set `a`=128,`b`='128'; -sync_slave_with_master; - -# cleanup - -connection master; -DROP TABLE t1; -sync_slave_with_master; - -# End of 5.0 tests diff --git a/mysql-test/t/rpl_timezone-master.opt b/mysql-test/t/rpl_timezone-master.opt deleted file mode 100644 index 8e43bfbbb7e..00000000000 --- a/mysql-test/t/rpl_timezone-master.opt +++ /dev/null @@ -1 +0,0 @@ ---default-time-zone=Europe/Moscow diff --git a/mysql-test/t/rpl_timezone-slave.opt b/mysql-test/t/rpl_timezone-slave.opt deleted file mode 100644 index 191182c329c..00000000000 --- a/mysql-test/t/rpl_timezone-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---default-time-zone=Japan diff --git a/mysql-test/t/rpl_timezone.test b/mysql-test/t/rpl_timezone.test deleted file mode 100644 index d62dba52c0a..00000000000 --- a/mysql-test/t/rpl_timezone.test +++ /dev/null @@ -1,184 +0,0 @@ -# Test of replication of time zones. - -# There is currently some bug possibly in prepared statements (this -# test fails with --ps-protocol): sys_var_thd_time_zone::value_ptr() -# is called only at prepare time, not at execution time. So, -# thd->time_zone_used is not equal to 1 (it is back to 0, because of -# reset_thd_for_next_command called at execution time), so the -# timezone used in CONVERT_TZ is not binlogged. To debug (by Guilhem -# and possibly Konstantin). - ---disable_ps_protocol - -source include/master-slave.inc; - -# Save original timezone -set @my_time_zone= @@global.time_zone; - -# Some preparations -let $VERSION=`select version()`; -set timestamp=100000000; # for fixed output of mysqlbinlog -create table t1 (t timestamp); -create table t2 (t char(32)); - -connection slave; -select @@time_zone; - -# -# Let us check how well replication works when we are saving datetime -# value in TIMESTAMP field. -# -connection master; -select @@time_zone; -insert into t1 values ('20050101000000'), ('20050611093902'); -set time_zone='UTC'; -insert into t1 values ('20040101000000'), ('20040611093902'); -select * from t1; -sync_slave_with_master; -set time_zone='UTC'; -select * from t1; - -# Let us check also that setting of time_zone back to default also works -# well -connection master; -delete from t1; -set time_zone='Europe/Moscow'; -insert into t1 values ('20040101000000'), ('20040611093902'); -select * from t1; -sync_slave_with_master; -set time_zone='Europe/Moscow'; -select * from t1; -connection master; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 - -# Let us check with LOAD DATA INFILE -# (we do it after mysqlbinlog because the temp files names are not constant) -connection master; -delete from t1; -set time_zone='UTC'; -load data infile '../std_data_ln/rpl_timezone.dat' into table t1; -select * from t1; -sync_slave_with_master; -set time_zone='UTC'; -select * from t1; -set time_zone='Europe/Moscow'; - -# Put back values of before the LOAD -connection master; -set time_zone='Europe/Moscow'; -delete from t1; -insert into t1 values ('20040101000000'), ('20040611093902'); - -# -# Now let us check how well we replicate statments reading TIMESTAMP fields -# (We should see the same data on master and on slave but it should differ -# from originally inserted) -# -set time_zone='MET'; -insert into t2 (select t from t1); -select * from t1; -sync_slave_with_master; -select * from t2; - -# -# Now let us check how well we replicate various CURRENT_* functions -# -connection master; -delete from t2; -set timestamp=1000072000; -insert into t2 values (current_timestamp), (current_date), (current_time); -sync_slave_with_master; -select * from t2; - -# -# At last let us check replication of FROM_UNIXTIME/UNIX_TIMESTAMP functions. -# -connection master; -delete from t2; -insert into t2 values (from_unixtime(1000000000)), - (unix_timestamp('2001-09-09 03:46:40')); -select * from t2; -sync_slave_with_master; -# We should get same result on slave as on master -select * from t2; - -# -# Let us check that we are allowing to set global time_zone with -# replication -# -connection master; -set global time_zone='MET'; - -# -# Let us see if CONVERT_TZ(@@time_zone) replicates -# -delete from t2; -set time_zone='UTC'; -insert into t2 values(convert_tz('2004-01-01 00:00:00','MET',@@time_zone)); -insert into t2 values(convert_tz('2005-01-01 00:00:00','MET','Japan')); -select * from t2; -sync_slave_with_master; -select * from t2; - -# Clean up -connection master; -drop table t1, t2; -sync_slave_with_master; - -# Restore original timezone -connection master; -set global time_zone= @my_time_zone; - ---echo End of 4.1 tests - -# -# Bug #29536: timestamp inconsistent in replication around 1970 -# -connection master; - -CREATE TABLE t1 (a INT, b TIMESTAMP); -INSERT INTO t1 VALUES (1, NOW()); - -SET @@session.time_zone='Japan'; -UPDATE t1 SET b= '1970-01-01 08:59:59' WHERE a= 1; -SELECT * FROM t1 ORDER BY a; - -sync_slave_with_master; -SET @@session.time_zone='Japan'; -# must procdure the same result as the SELECT on the master -SELECT * FROM t1 ORDER BY a; - -SET @@session.time_zone = default; -connection master; -DROP TABLE t1; -SET @@session.time_zone = default; - -# Bug#41719 delayed INSERT into timestamp col needs set time_zone for concurrent binlogging -# To test that time_zone is correctly binloging for 'insert delayed' statement -# Insert 2 values into timestamp col with different time_zone. Check result. - ---connection master -reset master; -CREATE TABLE t1 (date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, a int(11) default NULL); - -SET @@session.time_zone='+01:00'; -insert into t1 values('2008-12-23 19:39:39',1); - ---connection master1 -SET @@session.time_zone='+02:00'; -insert delayed into t1 values ('2008-12-23 19:39:39',2); -# Forces table t1 to be closed and flushes the query cache. -# This makes sure that 'delayed insert' is executed before next statement. -flush table t1; -flush logs; -select * from t1; -DROP TABLE t1; - ---exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 | $MYSQL ---connection master1 -select * from t1 order by a; -DROP TABLE t1; -SET @@session.time_zone = default; - ---echo End of 5.0 tests diff --git a/mysql-test/t/rpl_transaction-master.opt b/mysql-test/t/rpl_transaction-master.opt deleted file mode 100644 index 5411960b4aa..00000000000 --- a/mysql-test/t/rpl_transaction-master.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb --debug=d,do_not_write_xid diff --git a/mysql-test/t/rpl_transaction-slave.opt b/mysql-test/t/rpl_transaction-slave.opt deleted file mode 100644 index 627becdbfb5..00000000000 --- a/mysql-test/t/rpl_transaction-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb diff --git a/mysql-test/t/rpl_transaction.test b/mysql-test/t/rpl_transaction.test deleted file mode 100644 index ee9de3b5a5e..00000000000 --- a/mysql-test/t/rpl_transaction.test +++ /dev/null @@ -1,107 +0,0 @@ -# Tests that transactions are replicated correctly, with various -# combinations of non-transactional and transactional non-XA tables. -# Also tests that an XA transaction where the master crashes just -# before writing the XID log event is executed correctly. See below -# for implementation details. - -# Note: this test should not exist in 5.1 or higher. It has been -# replaced by rpl_ndb_transaction.test, which tests a superset of what -# this test tests. - -source include/have_innodb.inc; -source include/have_debug.inc; -source include/master-slave.inc; - - -CREATE TABLE tmyisam (a int) ENGINE = MYISAM; -CREATE TABLE tinnodb (a int) ENGINE = INNODB; - -SHOW CREATE TABLE tmyisam; -SHOW CREATE TABLE tinnodb; - - ---echo ==== Test 1: Non-XA Engines ==== -# Test that everything works fine with non-XA engines. We just try -# all ways to do transactions involving ndb and/or myisam, with -# rollback or commit. - ---echo --- on master --- - -SET AUTOCOMMIT = 1; - -INSERT INTO tmyisam VALUES (1); - -BEGIN; -INSERT INTO tmyisam VALUES (2); -INSERT INTO tmyisam VALUES (3); -COMMIT; - -BEGIN; -INSERT INTO tmyisam VALUES (5); -INSERT INTO tmyisam VALUES (6); -#--warning 1196 -ROLLBACK; - -SELECT * FROM tmyisam ORDER BY a; - ---echo --- on slave --- ---sync_slave_with_master -SELECT * FROM tmyisam ORDER BY a; - - ---echo ==== Test 2: Master crash before writing XID event on XA engine ==== -# We now want to test the following scenario, to verify that BUG#26395 -# has been fixed: - -# "master and slave have a transactional table that uses XA. Master -# has AUTOCOMMIT on and executes a statement (in this case an -# INSERT). Master crashes just before writing the XID event." - -# In this scenario, master will roll back, so slave should not execute -# the statement, and slave should roll back later when master is -# restarted. - -# However, we the master to be alive so that we are sure it replicates -# the statement to the slave. So in the test case, we must therefore -# not crash the master. Instead, we fake the crash by just not writing -# the XID event to the binlog. This is done by the -# --debug=d,do_not_write_xid flag in the .opt file. - -# So, unlike if the master had crashed, the master *will* execute the -# statement. But the slave should not execute it. Hence, after the -# first test is executed, the expected result on master is a table -# with one row, and on slave a table with no rows. - -# To simulate the slave correctly, we wait until everything up to the -# XID is replicated. We cannot sync_slave_with_master, because that -# would wait for the transaction to end. Instead, we wait for -# "sufficiently long time". Then we stop the slave. - -# Note: since this puts the master binlog in an inconsistent state, -# this should be the last test of the file. - ---echo --- on master --- ---connection master - -INSERT INTO tinnodb VALUES (1); -SELECT * FROM tinnodb ORDER BY a; - ---echo --- on slave --- ---connection slave ---sleep 3 -STOP SLAVE; -source include/wait_for_slave_to_stop.inc; ---replace_column 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # -query_vertical SHOW SLAVE STATUS; -# the following statement should show that nothing has been replicated -SELECT * FROM tinnodb ORDER BY a; - - -# clean up -connection master; -DROP TABLE tmyisam; -DROP TABLE tinnodb; - -connection slave; -DROP TABLE tmyisam; -DROP TABLE tinnodb; diff --git a/mysql-test/t/rpl_trigger_not_windows.test b/mysql-test/t/rpl_trigger_not_windows.test deleted file mode 100644 index b90e0f504f4..00000000000 --- a/mysql-test/t/rpl_trigger_not_windows.test +++ /dev/null @@ -1,8 +0,0 @@ -# -# Test of triggers with replication -# - -source include/master-slave.inc; -source include/not_windows.inc; - ---source include/rpl_trigger_common.inc diff --git a/mysql-test/t/rpl_trigger_windows.test b/mysql-test/t/rpl_trigger_windows.test deleted file mode 100644 index f1bd73f10b6..00000000000 --- a/mysql-test/t/rpl_trigger_windows.test +++ /dev/null @@ -1,8 +0,0 @@ -# -# Test of triggers with replication -# - -source include/master-slave.inc; -source include/windows.inc; - ---source include/rpl_trigger_common.inc diff --git a/mysql-test/t/rpl_trunc_temp.test b/mysql-test/t/rpl_trunc_temp.test deleted file mode 100644 index b4ea3c318da..00000000000 --- a/mysql-test/t/rpl_trunc_temp.test +++ /dev/null @@ -1,32 +0,0 @@ -source include/master-slave.inc; - -# -# Bug#17137 Running "truncate table" on temporary table -# leaves the table open on a slave -# - -create temporary table t1 (n int); -insert into t1 values(1); -sync_slave_with_master; -show status like 'Slave_open_temp_tables'; - -# Perform a delete from temp table -connection master; -delete from t1; -sync_slave_with_master; -show status like 'Slave_open_temp_tables'; - -# Perform truncate on temp table -connection master; -truncate t1; -sync_slave_with_master; -show status like 'Slave_open_temp_tables'; - -# Disconnect the master, temp table on slave should dissapear -disconnect master; ---real_sleep 3 # time for DROP to be read by slave -connection slave; -show status like 'Slave_open_temp_tables'; - - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_until.test deleted file mode 100644 index c404ea7e58b..00000000000 --- a/mysql-test/t/rpl_until.test +++ /dev/null @@ -1,87 +0,0 @@ -source include/master-slave.inc; - -# prepare version for substitutions -let $VERSION=`select version()`; - -# stop slave before he will start replication also sync with master -# for avoiding undetermenistic behaviour -save_master_pos; -connection slave; -sync_with_master; -stop slave; - -connection master; -# create some events on master -create table t1(n int not null auto_increment primary key); -insert into t1 values (1),(2),(3),(4); -drop table t1; -create table t2(n int not null auto_increment primary key); -insert into t2 values (1),(2); -insert into t2 values (3),(4); -drop table t2; ---replace_result $VERSION VERSION -show binlog events; - -# try to replicate all queries until drop of t1 -connection slave; -start slave until master_log_file='master-bin.000001', master_log_pos=319; -sleep 2; -wait_for_slave_to_stop; -# here table should be still not deleted -select * from t1; ---replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 9 # 11 # 23 # 33 # ---query_vertical SHOW SLAVE STATUS - -# this should fail right after start -start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291; -# again this table should be still not deleted -select * from t1; -sleep 2; -wait_for_slave_to_stop; ---replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 9 # 11 # 23 # 33 # ---query_vertical SHOW SLAVE STATUS - -# try replicate all until second insert to t2; -start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746; -sleep 2; -wait_for_slave_to_stop; -select * from t2; ---replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 1 # 9 # 11 # 23 # 33 # ---query_vertical SHOW SLAVE STATUS - -# clean up -start slave; -connection master; -save_master_pos; -connection slave; -sync_with_master; -stop slave; - -# this should stop immediately as we are already there -start slave until master_log_file='master-bin.000001', master_log_pos=776; -sleep 2; -wait_for_slave_to_stop; -# here the sql slave thread should be stopped ---replace_result $MASTER_MYPORT MASTER_MYPORT bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004 ---replace_column 1 # 9 # 23 # 33 # ---query_vertical SHOW SLAVE STATUS - -#testing various error conditions ---error 1277 -start slave until master_log_file='master-bin', master_log_pos=561; ---error 1277 -start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12; ---error 1277 -start slave until master_log_file='master-bin.000001'; ---error 1277 -start slave until relay_log_file='slave-relay-bin.000002'; ---error 1277 -start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561; -# Warning should be given for second command -start slave sql_thread; -start slave until master_log_file='master-bin.000001', master_log_pos=776; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl_user.test b/mysql-test/t/rpl_user.test deleted file mode 100644 index a0aeeac62c2..00000000000 --- a/mysql-test/t/rpl_user.test +++ /dev/null @@ -1,62 +0,0 @@ -# BUG#33862 completely failed DROP USER statement gets replicated - ---source include/master-slave.inc - -# -# remove all users will be used in the test -# -connection master; -set sql_log_bin=0; -delete from mysql.user where Host='fakehost'; -set sql_log_bin=1; - -connection slave; -set sql_log_bin=0; -delete from mysql.user where Host='fakehost'; -set sql_log_bin=1; - - -# -# Test create user -# -connection master; -create user 'foo'@'fakehost'; ---error ER_CANNOT_USER -create user 'foo'@'fakehost', 'bar'@'fakehost'; ---error ER_CANNOT_USER -create user 'foo'@'fakehost', 'bar'@'fakehost'; - -sync_slave_with_master; -select Host,User from mysql.user where Host='fakehost'; - -# -# Test rename user -# -connection master; -rename user 'foo'@'fakehost' to 'foofoo'@'fakehost'; ---error ER_CANNOT_USER -rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'bar'@'fakehost' to 'barbar'@'fakehost'; ---error ER_CANNOT_USER -rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'not_exist_user2'@'fakehost' to 'barfoo'@'fakehost'; - -sync_slave_with_master; -select Host,User from mysql.user where Host='fakehost'; - -# -# Test drop user -# -connection master; -drop user 'foofoo'@'fakehost'; ---error ER_CANNOT_USER -drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost'; ---error ER_CANNOT_USER -drop user 'not_exist_user1'@'fakehost', 'not_exist_user2'@'fakehost'; - -sync_slave_with_master; -select Host,User from mysql.user where Host='fakehost'; - -# -# show the binlog events on the master -# -connection master; -source include/show_binlog_events.inc; diff --git a/mysql-test/t/rpl_user_variables.test b/mysql-test/t/rpl_user_variables.test deleted file mode 100644 index 70b708be258..00000000000 --- a/mysql-test/t/rpl_user_variables.test +++ /dev/null @@ -1,411 +0,0 @@ -# -# Test of replicating user variables -# -source include/master-slave.inc; -# Disable PS as the log positions differs ---disable_ps_protocol - - -# Clean up old slave's binlogs. -# The slave is started with --log-slave-updates -# and this test does SHOW BINLOG EVENTS on the slave's -# binlog. But previous tests can influence the current test's -# binlog (e.g. a temporary table in the previous test has not -# been explicitly deleted, or it has but the slave hasn't had -# enough time to catch it before STOP SLAVE, -# and at the beginning of the current -# test the slave immediately writes DROP TEMPORARY TABLE this_old_table). -# We wait for the slave to have written all he wants to the binlog -# (otherwise RESET MASTER may come too early). -save_master_pos; -connection slave; -sync_with_master; -reset master; -connection master; - -create table t1(n char(30)); -set @i1:=12345678901234, @i2:=-12345678901234, @i3:=0, @i4:=-1; -set @s1:='This is a test', @r1:=12.5, @r2:=-12.5; -set @n1:=null; -set @s2:='', @s3:='abc\'def', @s4:= 'abc\\def', @s5:= 'abc''def'; -insert into t1 values (@i1), (@i2), (@i3), (@i4); -insert into t1 values (@r1), (@r2); -insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5); -insert into t1 values (@n1); -insert into t1 values (@n2); # not explicitely set before -insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1); -insert into t1 values (@a+(@b:=@a+1)); -set @q:='abc'; -insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2')); -set @a:=5; -insert into t1 values (@a),(@a); -connection master1; # see if variable is reset in binlog when thread changes -insert into t1 values (@a),(@a),(@a*5); -select * from t1; -save_master_pos; -connection slave; -sync_with_master; -select * from t1; ---replace_column 2 # 5 # -show binlog events from 98; -# -# BUG19136: Crashing log-bin and uninitialized user variables in a derived table -# just to check nothing bad happens anymore -# -connection master; -insert into t1 select * FROM (select @var1 union select @var2) AS t2; -drop table t1; -save_master_pos; - ---echo End of 4.1 tests. - -# BUG#20141 -# The following tests ensure that if user-defined variables are used in SF/Triggers -# that they are replicated correctly. These tests should be run in both SBR and RBR -# modes. - -# This test uses a procedure that inserts data values based on the value of a -# user-defined variable. It also has a trigger that inserts data based on the -# same variable. Successful test runs show that the @var is replicated -# properly and that the procedure and trigger insert the correct data on the -# slave. -# -# The test of stored procedure was included for completeness. Replication of stored -# procedures was not directly affected by BUG#20141. -# -# This test was constructed for BUG#20141 - ---disable_warnings -DROP TABLE IF EXISTS t20; -DROP TABLE IF EXISTS t21; -DROP PROCEDURE IF EXISTS test.insert; ---enable_warnings - -CREATE TABLE t20 (a VARCHAR(20)); -CREATE TABLE t21 (a VARCHAR(20)); -DELIMITER |; - -# Create a procedure that uses the @var for flow control - -CREATE PROCEDURE test.insert() -BEGIN - IF (@VAR) - THEN - INSERT INTO test.t20 VALUES ('SP_TRUE'); - ELSE - INSERT INTO test.t20 VALUES ('SP_FALSE'); - END IF; -END| - -# Create a trigger that uses the @var for flow control - -CREATE TRIGGER test.insert_bi BEFORE INSERT - ON test.t20 FOR EACH ROW - BEGIN - IF (@VAR) - THEN - INSERT INTO test.t21 VALUES ('TRIG_TRUE'); - ELSE - INSERT INTO test.t21 VALUES ('TRIG_FALSE'); - END IF; - END| -DELIMITER ;| - -sync_slave_with_master; -connection master; - -# Set @var and call the procedure, repeat with different values - -SET @VAR=0; -CALL test.insert(); -SET @VAR=1; -CALL test.insert(); - ---echo On master: Check the tables for correct data - -SELECT * FROM t20; -SELECT * FROM t21; - -sync_slave_with_master; - ---echo On slave: Check the tables for correct data and it matches master - -SELECT * FROM t20; -SELECT * FROM t21; -connection master; - -# Cleanup - -DROP TABLE t20; -DROP TABLE t21; -DROP PROCEDURE test.insert; - -# This test uses a stored function that uses user-defined variables to return data -# This test was constructed for BUG#20141 - ---disable_warnings -DROP TABLE IF EXISTS t1; -DROP FUNCTION IF EXISTS test.square; ---enable_warnings - -CREATE TABLE t1 (i INT); - -# Create function that returns a value from @var. In this case, the square function - -CREATE FUNCTION test.square() RETURNS INTEGER DETERMINISTIC RETURN (@var * @var); - -sync_slave_with_master; -connection master; - -# Set the @var to different values and insert them into a table - -SET @var = 1; -INSERT INTO t1 VALUES (square()); -SET @var = 2; -INSERT INTO t1 VALUES (square()); -SET @var = 3; -INSERT INTO t1 VALUES (square()); -SET @var = 4; -INSERT INTO t1 VALUES (square()); -SET @var = 5; -INSERT INTO t1 VALUES (square()); - ---echo On master: Retrieve the values from the table - -SELECT * FROM t1; - -sync_slave_with_master; - ---echo On slave: Retrieve the values from the table and verify they are the same as on master - -SELECT * FROM t1; - -connection master; - -# Cleanup - -DROP TABLE t1; -DROP FUNCTION test.square; - -# This test uses stored functions that uses user-defined variables to return data -# based on the use of @vars inside a function body. -# This test was constructed for BUG#14914 - ---disable_warnings -DROP TABLE IF EXISTS t1; -DROP FUNCTION IF EXISTS f1; -DROP FUNCTION IF EXISTS f2; ---enable_warnings - -CREATE TABLE t1(a int); -DELIMITER |; - -# Create a function that simply returns the value of an @var. -# Create a function that uses an @var for flow control, creates and uses another -# @var and sets its value to a value based on another @var. - -CREATE FUNCTION f1() returns int deterministic -BEGIN - return @a; -END | - -CREATE FUNCTION f2() returns int deterministic -BEGIN - IF (@b > 0) then - SET @c = (@a + @b); - else - SET @c = (@a - 1); - END if; - return @c; -END | -DELIMITER ;| - -sync_slave_with_master; -connection master; - -# Set an @var to a value and insert data into a table using the first function. -# Set two more @vars to some values and insert data into a table using the second function. - -SET @a=500; -INSERT INTO t1 values(f1()); -SET @b = 125; -SET @c = 1; -INSERT INTO t1 values(f2()); - -sync_slave_with_master; - ---echo On master: Retrieve the values from the table - -SELECT * from t1; - ---echo On slave: Check the tables for correct data and it matches master - -SELECT * from t1; - -connection master; - -# Cleanup - -DROP TABLE t1; -DROP FUNCTION f1; -DROP FUNCTION f2; - -# This test uses a function that changes a user-defined variable in its body. This test -# will ensure the @vars are replicated when needed and not interrupt the normal execution -# of the function on the slave. This also applies to triggers. -# -# This test was constructed for BUG#25167 - ---disable_warnings -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS t2; ---enable_warnings -CREATE TABLE t1 (i int); -CREATE TABLE t2 (k int); -DELIMITER |; - -# Create a trigger that inserts data into another table, changes the @var then inserts -# another row with the modified value. - -CREATE trigger t1_bi before INSERT on t1 for each row -BEGIN - INSERT INTO t2 values (@a); - SET @a:=42; - INSERT INTO t2 values (@a); -END | -DELIMITER ;| - -sync_slave_with_master; -connection master; - -# Set the @var to a value then insert data into first table. - -SET @a:=100; -INSERT INTO t1 values (5); - ---echo On master: Check to see that data was inserted correctly in both tables - -SELECT * from t1; -SELECT * from t2; - -sync_slave_with_master; - ---echo On slave: Check the tables for correct data and it matches master - -SELECT * from t1; -SELECT * from t2; - -connection master; -drop table t1, t2; - -# -# Bug #26842: master binary log contains invalid queries - replication fails -# -save_master_pos; -connection slave; -sync_with_master; -reset master; - -connection master; -create table t1 (a int); -prepare s from "insert into t1 values (@a),(?)"; -set @a=98; execute s using @a; -prepare s from "insert into t1 values (?)"; -set @a=99; execute s using @a; -prepare s from "insert into t1 select 100 limit ?"; -set @a=100; execute s using @a; - -save_master_pos; -connection slave; -sync_with_master; -show binlog events from 98; -select * from t1; -connection master; -drop table t1; - -# -# Bug #12826: Possible to get inconsistent slave using SQL syntax Prepared Statements -# -connection master; -create table t1(a int, b int); -prepare s1 from 'insert into t1 values (@x:=@x+1, ?)'; -set @x=1; execute s1 using @x; -select * from t1; -sync_slave_with_master; -connection slave; -select * from t1; -connection master; -drop table t1; - -# -# Bug#33851: Passing UNSIGNED param to EXECUTE returns ERROR 1210 -# - -connection master; -create table t1(a int); -insert into t1 values (1),(2); -prepare s1 from 'insert into t1 select a from t1 limit ?'; -set @x='1.1'; -execute s1 using @x; -select * from t1; -sync_slave_with_master; -connection slave; -select * from t1; -connection master; -drop table t1; - ---echo End of 5.0 tests. - -# This test uses a stored function that uses user-defined variables to return data -# The test ensures the value of the user-defined variable is replicated correctly -# and in the correct order of assignment. -# This test was constructed for BUG#20141 - ---disable_warnings -DROP FUNCTION IF EXISTS f1; -DROP FUNCTION IF EXISTS f2; ---enable_warnings - -CREATE TABLE t1 (i INT); - -# Create two functions. One simply returns the user-defined variable. The other -# returns a value based on the user-defined variable. - -CREATE FUNCTION f1() RETURNS INT RETURN @a; -DELIMITER |; -CREATE FUNCTION f2() RETURNS INT -BEGIN - INSERT INTO t1 VALUES (10 + @a); - RETURN 0; -END| -DELIMITER ;| - -sync_slave_with_master; -connection master; - -# Set the variable and execute the functions. - -SET @a:=123; -SELECT f1(), f2(); - ---echo On master: Check to see that data was inserted correctly - -INSERT INTO t1 VALUES(f1()); -SELECT * FROM t1; - -sync_slave_with_master; - ---echo On slave: Check the table for correct data and it matches master - -SELECT * FROM t1; - -connection master; - -# Cleanup - -DROP FUNCTION f1; -DROP FUNCTION f2; -DROP TABLE t1; - -sync_slave_with_master; -stop slave; diff --git a/mysql-test/t/rpl_variables-master.opt b/mysql-test/t/rpl_variables-master.opt deleted file mode 100644 index a668c6bfbe8..00000000000 --- a/mysql-test/t/rpl_variables-master.opt +++ /dev/null @@ -1 +0,0 @@ ---slave-skip-errors=3,100,137,643,1752 diff --git a/mysql-test/t/rpl_variables.test b/mysql-test/t/rpl_variables.test deleted file mode 100644 index 4e2d07cad54..00000000000 --- a/mysql-test/t/rpl_variables.test +++ /dev/null @@ -1,27 +0,0 @@ -source include/master-slave.inc; - -connection master; - -# Init for rstore of variable values -set @my_slave_net_timeout =@@global.slave_net_timeout; - -set global slave_net_timeout=100; -set global sql_slave_skip_counter=100; - -# End of 4.1 tests - -# BUG #7800: Add various-slave related variables to SHOW VARIABLES -show variables like 'slave_compressed_protocol'; ---replace_column 2 SLAVE_LOAD_TMPDIR -show variables like 'slave_load_tmpdir'; -# We just set some arbitrary values in variables-master.opt so we can test -# that a list of values works correctly -show variables like 'slave_skip_errors'; - -# Restore touched values -set global slave_net_timeout =@my_slave_net_timeout; - -# bug#34427 slave misses rendezvous -# don't let the master be shut down until the slave has connected -sync_slave_with_master; - diff --git a/mysql-test/t/rpl_view.test b/mysql-test/t/rpl_view.test deleted file mode 100644 index 44ef0c3e1eb..00000000000 --- a/mysql-test/t/rpl_view.test +++ /dev/null @@ -1,182 +0,0 @@ -source include/master-slave.inc; ---disable_warnings -drop table if exists t1,v1; -drop view if exists t1,v1; -sync_slave_with_master; -reset master; ---enable_warnings - -# -# Check that createion drop of view is replicated, also check replication of -# updating of view -# -connection master; -create table t1 (a int); -insert into t1 values (1); -create view v1 as select a from t1; -insert into v1 values (2); -select * from v1 order by a; -sync_slave_with_master; -# view already have to be on slave -select * from v1 order by a; -connection master; -update v1 set a=3 where a=1; -select * from v1 order by a; -sync_slave_with_master; -select * from v1 order by a; -connection master; -delete from v1 where a=2; -select * from v1 order by a; -sync_slave_with_master; -select * from v1 order by a; -connection master; -# 'alter view' internally maped to creation, but still check that it works -alter view v1 as select a as b from t1; -sync_slave_with_master; -select * from v1 order by 1; -connection master; -drop view v1; -sync_slave_with_master; -#error, because view have to be removed from slave --- error 1146 -select * from v1 order by a; -connection master; -drop table t1; -sync_slave_with_master; ---replace_column 2 # 5 # -show binlog events limit 1,100; - - - -# -# BUG#20438: CREATE statements for views, stored routines and triggers can be -# not replicable. -# - ---echo ---echo ---> Test for BUG#20438 - -# Prepare environment. - ---echo ---echo ---> Preparing environment... ---echo ---> connection: master ---connection master - ---disable_warnings -DROP TABLE IF EXISTS t1; -DROP VIEW IF EXISTS v1; ---enable_warnings - ---echo ---echo ---> Synchronizing slave with master... - ---save_master_pos ---connection slave ---sync_with_master - ---echo ---echo ---> connection: master ---connection master - -# Test. - ---echo ---echo ---> Creating objects... - -CREATE TABLE t1(c INT); - -/*!50003 CREATE VIEW v1 AS SELECT * FROM t1 */; - ---echo ---echo ---> Inserting value... - -INSERT INTO t1 VALUES(1); - ---echo ---echo ---> Checking on master... - -SELECT * FROM t1; - ---echo ---echo ---> Synchronizing slave with master... - ---save_master_pos ---connection slave ---sync_with_master - ---echo ---> connection: master - ---echo ---echo ---> Checking on slave... - -SELECT * FROM t1; - -# Cleanup. - ---echo ---echo ---> connection: master ---connection master - ---echo ---echo ---> Cleaning up... - -DROP VIEW v1; -DROP TABLE t1; - ---save_master_pos ---connection slave ---sync_with_master ---connection master - -# -# BUG#19419: "VIEW: View that the column name is different -# by master and slave is made". -# -connection master; -create table t1(a int, b int); -insert into t1 values (1, 1), (1, 2), (1, 3); -create view v1(a, b) as select a, sum(b) from t1 group by a; - -sync_slave_with_master; -explain v1; -show create table v1; -select * from v1; - -connection master; -drop table t1; -drop view v1; - -sync_slave_with_master; - -# -# BUG#28244 CREATE VIEW breaks replication when view exists -# -connection master; -CREATE TABLE t1(a INT); -CREATE VIEW v1 AS SELECT * FROM t1; ---error ER_TABLE_EXISTS_ERROR -CREATE VIEW v1 AS SELECT * FROM t1; -DROP VIEW v1; -DROP TABLE t1; -sync_slave_with_master; - -# -# Bug#32575 Parse error of stmt with extended comments on slave side -# Verify that 'CREATE VIEW' with comments is properly logged to binlog -connection master; -CREATE TABLE t1 (a INT); ---echo # create view as output from mysqldump 10.11 (5.0.62) -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` < 3) */ -/*!50002 WITH CASCADED CHECK OPTION */; -SHOW CREATE VIEW v1; -sync_slave_with_master; -SHOW CREATE VIEW v1; -connection master; -DROP VIEW v1; -DROP TABLE t1; -sync_slave_with_master; - ---echo End of 5.0 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index d57163dfef6..1e7e853da32 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2286,25 +2286,6 @@ EXPLAIN SELECT * FROM t1 FORCE INDEX (a); DROP TABLE t1; # -# Bug #18759 "Incorrect string to numeric conversion" -# -# This test is here so that the behavior will not be changed to 4.1 -# and not to 5.0 either. In 4.1 and 5.0 sending an integer as a string -# will be converted internally to real (double) value and it is not -# as accurate as bigint (longlong) for integers. Thus the results may -# vary. In 5.1 internally it is decimal, which is a string type and -# will be more accurate. Due to rather big changes needed to fix this -# in 4.1 or 5.0 it is not desired to do it in the stable versions. -# -# This test is here only to make sure that behavior is not changed in -# 4.1 and 5.0 -# -CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); -INSERT INTO t1 VALUES (10); -SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; -DROP TABLE t1; - -# # Bug #21019: First result of SELECT COUNT(*) different than consecutive runs # CREATE TABLE t1 (a int, b int); @@ -2319,6 +2300,7 @@ SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NUL EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL; DROP TABLE IF EXISTS t1,t2; + # # Bug #20954 "avg(keyval) retuns 0.38 but max(keyval) returns an empty set" # @@ -2350,6 +2332,25 @@ DROP TABLE t1,t2; --enable_ps_protocol # +# Bug #18759 "Incorrect string to numeric conversion" +# +# This test is here so that the behavior will not be changed to 4.1 +# and not to 5.0 either. In 4.1 and 5.0 sending an integer as a string +# will be converted internally to real (double) value and it is not +# as accurate as bigint (longlong) for integers. Thus the results may +# vary. In 5.1 internally it is decimal, which is a string type and +# will be more accurate. Due to rather big changes needed to fix this +# in 4.1 or 5.0 it is not desired to do it in the stable versions. +# +# This test is here only to make sure that behavior is not changed in +# 4.1 and 5.0 +# +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; +DROP TABLE t1; + +# # Bug #22533: storing large hex strings # @@ -3124,18 +3125,7 @@ SELECT t3.a FROM t1,t2,t3 t3.c IN ('bb','ee'); DROP TABLE t1,t2,t3; - -# -# WL3527: Extend IGNORE INDEX so places where index is ignored can -# be specified -# -CREATE TABLE t1 (a INT, b INT, KEY (a)); INSERT INTO t1 VALUES (1,1),(2,2); -EXPLAIN SELECT 1 FROM t1 WHERE a = 1; -EXPLAIN SELECT 1 FROM t1 IGNORE INDEX FOR JOIN (a) WHERE a = 1; -EXPLAIN SELECT 1 FROM t1 USE INDEX FOR JOIN (a) WHERE a = 1; -EXPLAIN SELECT 1 FROM t1 FORCE INDEX FOR JOIN (a) WHERE a = 1; -DROP TABLE t1; - + # # Bug#25172: Not checked buffer size leads to a server crash # @@ -3262,7 +3252,6 @@ SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30 AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31"; DROP TABLE t1,t2; -# # Bug #22026: Warning when using IF statement and large unsigned bigint # @@ -3768,3 +3757,148 @@ DROP TABLE t1; --echo End of 5.0 tests + +# +# Bug #30639: limit offset,rowcount wraps when rowcount >= 2^32 in windows +# +create table t1(a INT, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5); +SELECT a FROM t1 ORDER BY a LIMIT 2; +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; +SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; +DROP TABLE t1; + +# +# Bug #37936: ASSERT_COLUMN_MARKED_FOR_WRITE in Field_datetime::store , +# Field_varstring::store +# + +CREATE TABLE A (date_key date); + +CREATE TABLE C ( + pk int, + int_nokey int, + int_key int, + date_key date NOT NULL, + date_nokey date, + varchar_key varchar(1) +); + +INSERT INTO C VALUES +(1,1,1,'0000-00-00',NULL,NULL), +(1,1,1,'0000-00-00',NULL,NULL); + +SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C); + +SELECT COUNT(DISTINCT 1) FROM C + WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk; +SELECT date_nokey FROM C + WHERE int_key IN (SELECT 1 FROM A) + HAVING date_nokey = '10:41:7' + ORDER BY date_key; + +DROP TABLE A,C; + +# +# Bug #42957: no results from +# select where .. (col=col and col=col) or ... (false expression) +# +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +DROP TABLE t1; + +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +DROP TABLE t1; + + +--echo # +--echo # Bug#45266: Uninitialized variable lead to an empty result. +--echo # +--disable_warnings +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + `date_key` date NOT NULL, + `date_nokey` date NOT NULL, + `datetime_key` datetime NOT NULL, + `int_nokey` int(11) NOT NULL, + `time_key` time NOT NULL, + `time_nokey` time NOT NULL, + PRIMARY KEY (`pk`), + KEY `date_key` (`date_key`), + KEY `time_key` (`time_key`), + KEY `datetime_key` (`datetime_key`) +); + +CREATE TABLE `AA` ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + `int_nokey` int(11) NOT NULL, + `time_key` time NOT NULL, + KEY `time_key` (`time_key`), + PRIMARY KEY (`pk`) +); + +CREATE TABLE `B` ( + `date_nokey` date NOT NULL, + `date_key` date NOT NULL, + `time_key` time NOT NULL, + `datetime_nokey` datetime NOT NULL, + `varchar_key` varchar(1) NOT NULL, + KEY `date_key` (`date_key`), + KEY `time_key` (`time_key`), + KEY `varchar_key` (`varchar_key`) +); + +INSERT INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); + +CREATE TABLE `BB` ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + `int_nokey` int(11) NOT NULL, + `date_key` date NOT NULL, + `varchar_nokey` varchar(1) NOT NULL, + `date_nokey` date NOT NULL, + PRIMARY KEY (`pk`), + KEY `date_key` (`date_key`) +); + +INSERT INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +# Test #1 +SELECT table1 . `pk` AS field1 + FROM + (BB AS table1 INNER JOIN + (AA AS table2 STRAIGHT_JOIN A AS table3 + ON ( table3 . `date_key` = table2 . `pk` )) + ON ( table3 . `datetime_key` = table2 . `int_nokey` )) + WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) + GROUP BY field1 ; + +SELECT table3 .`date_key` field1 + FROM + B table1 LEFT JOIN B table3 JOIN + (BB table6 JOIN A table7 ON table6 .`varchar_nokey`) + ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; + +# Test #2 +SELECT table4 . `time_nokey` AS field1 FROM + (AA AS table1 CROSS JOIN + (AA AS table2 STRAIGHT_JOIN + (B AS table3 STRAIGHT_JOIN A AS table4 + ON ( table4 . `date_key` = table3 . `time_key` )) + ON ( table4 . `pk` = table3 . `date_nokey` )) + ON ( table4 . `time_key` = table3 . `datetime_nokey` )) + WHERE ( table4 . `time_key` < table1 . `time_key` AND + table1 . `int_nokey` != 'f') + GROUP BY field1 ORDER BY field1 , field1; + +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +--enable_warnings + +drop table A,AA,B,BB; +--echo #end of test for bug#45266 +--echo End of 5.1 tests diff --git a/mysql-test/t/show_check-master.opt b/mysql-test/t/show_check-master.opt index 7a438da06cc..aab832e2848 100644 --- a/mysql-test/t/show_check-master.opt +++ b/mysql-test/t/show_check-master.opt @@ -1 +1 @@ ---log-slow-queries --log-long-format --log-queries-not-using-indexes --myisam-recover="" +--log-output=table,file --log-slow-queries --log-long-format --log-queries-not-using-indexes --myisam-recover="" diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 51029e376b1..0ce807ae73e 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -1,6 +1,10 @@ # Uses GRANT commands that usually disabled in embedded server -- source include/not_embedded.inc +# check that CSV engine was compiled in, as the result of the test +# depends on the presence of the log tables (which are CSV-based). +--source include/have_csv.inc + # Save the initial number of concurrent sessions --source include/count_sessions.inc @@ -200,43 +204,35 @@ drop table t1; SET @old_sql_mode= @@sql_mode, sql_mode= ''; SET @old_sql_quote_show_create= @@sql_quote_show_create, sql_quote_show_create= OFF; -######### hook for WL#1324 # ---error ER_WRONG_TABLE_NAME -CREATE TABLE `a/b` (i INT); -# the above test should WORK when WL#1324 is done, -# it should be removed and -# the following part should be uncommented then -######################################################### -# begin of part that must be uncommented when WL#1324 is done -######################################################### -#CREATE TABLE ```ab``cd``` (i INT); -#SHOW CREATE TABLE ```ab``cd```; -#DROP TABLE ```ab``cd```; - -#CREATE TABLE ```ab````cd``` (i INT); -#SHOW CREATE TABLE ```ab````cd```; -#DROP TABLE ```ab````cd```; -# -#CREATE TABLE ```a` (i INT); -#SHOW CREATE TABLE ```a`; -#DROP TABLE ```a`; -# -#SET sql_mode= 'ANSI_QUOTES'; -# -#CREATE TABLE """a" (i INT); -#SHOW CREATE TABLE """a"; -#DROP TABLE """a"; -# -#Bug#4374 SHOW TABLE STATUS FROM ignores collation_connection +CREATE TABLE ```ab``cd``` (i INT); +SHOW CREATE TABLE ```ab``cd```; +DROP TABLE ```ab``cd```; + +CREATE TABLE ```ab````cd``` (i INT); +SHOW CREATE TABLE ```ab````cd```; +DROP TABLE ```ab````cd```; + +CREATE TABLE ```a` (i INT); +SHOW CREATE TABLE ```a`; +DROP TABLE ```a`; + +CREATE TABLE `a.1` (i INT); +SHOW CREATE TABLE `a.1`; +DROP TABLE `a.1`; + +SET sql_mode= 'ANSI_QUOTES'; + +CREATE TABLE """a" (i INT); +SHOW CREATE TABLE """a"; +DROP TABLE """a"; + +# Bug#4374 SHOW TABLE STATUS FROM ignores collation_connection #set names latin1; #create database ``; #create table ``.`` (a int) engine=heap; #--replace_column 7 # 8 # 9 # #show table status from `` LIKE ''; #drop database ``; -######################################################### -# end of part that must be uncommented when WL#1324 is done -######################################################### # to test quotes around keywords.. : @@ -297,9 +293,9 @@ delete from t2 where b=3; delete from t3 where a=3; --replace_column 6 # 7 # 8 # 9 # 10 # show table status; -delete from t1; -delete from t2; -delete from t3; +truncate table t1; +truncate table t2; +truncate table t3; --replace_column 6 # 7 # 8 # 9 # show table status; insert into t1 values (5); @@ -353,7 +349,6 @@ connect (con3,localhost,mysqltest_3,,test); connection con3; --error ER_TABLEACCESS_DENIED_ERROR select * from mysqltest.t1; ---error ER_DBACCESS_DENIED_ERROR show create database mysqltest; drop table mysqltest.t1; drop database mysqltest; @@ -433,40 +428,87 @@ DROP TABLE t1; flush tables; # Create a junk frm file on disk -system echo "this is a junk file for test" >> $MYSQLTEST_VARDIR/master-data/test/t1.frm ; +let $MYSQLD_DATADIR= `select @@datadir`; +system echo "this is a junk file for test" >> $MYSQLD_DATADIR/test/t1.frm ; --replace_column 6 # 7 # 8 # 9 # SHOW TABLE STATUS like 't1'; --error ER_NOT_FORM_FILE show create table t1; -drop table t1; - - ---echo End of 4.1 tests +drop table if exists t1; +--error 1,0 +--remove_file $MYSQLD_DATADIR/test/t1.frm # # Bug#12183 SHOW OPEN TABLES behavior doesn't match grammar # First we close all open tables with FLUSH tables and then we open some. -CREATE TABLE txt1(a int); -CREATE TABLE tyt2(a int); -CREATE TABLE urkunde(a int); +# + +--echo +--echo # Bug#12183 SHOW OPEN TABLES behavior doesn't match grammar. +--echo + +# NOTE: SHOW OPEN TABLES does not sort result list by database or table names. +# Tables are listed in the order they were opened. We can not use the system +# database (mysql) for the test here, because we have no control over the order +# of opening tables in it. Consequently, we can not use 'SHOW OPEN TABLES'. + +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1; +--enable_warnings + +CREATE DATABASE mysqltest1; +use mysqltest1; + +--echo + +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT); + +--echo + +--disable_ps_protocol FLUSH TABLES; -SELECT 1 FROM mysql.db, mysql.proc, mysql.user, mysql.time_zone, mysql.time_zone_name, txt1, tyt2, urkunde LIMIT 0; -SHOW OPEN TABLES; -SHOW OPEN TABLES FROM mysql; -SHOW OPEN TABLES FROM mysql LIKE 'u%'; -SHOW OPEN TABLES LIKE 't%'; -SHOW OPEN TABLES LIKE '%o%'; + +--echo + +SELECT 1 FROM t1; +SELECT 1 FROM t2; + +--echo + +SHOW OPEN TABLES FROM mysqltest1; + +--echo + +SHOW OPEN TABLES FROM mysqltest1 LIKE 'z%'; + +--echo + +SHOW OPEN TABLES FROM mysqltest1 LIKE 't1%'; + +--echo + +SHOW OPEN TABLES FROM mysqltest1 LIKE '%1%'; + +--echo + FLUSH TABLES; -SHOW OPEN TABLES; -DROP TABLE txt1; -DROP TABLE tyt2; -DROP TABLE urkunde; +--enable_ps_protocol + +--echo + +DROP DATABASE mysqltest1; +use test; + +--echo + # # Bug#12591 SHOW TABLES FROM dbname produces wrong error message # --error ER_BAD_DB_ERROR SHOW TABLES FROM non_existing_database; +--echo End of 4.1 tests # # Bug#17203 "sql_no_cache sql_cache" in views created from prepared @@ -560,8 +602,70 @@ show status like 'slow_queries'; select 1 from information_schema.tables limit 1; show status like 'slow_queries'; +create table t1 (a int); +create trigger tr1 before insert on t1 for each row +begin +end; +create view v1 as select a from t1; +create procedure p1() +begin +end; +create function f1() +returns int +return 0; +create event e1 on schedule every 1 year starts now() + ends date_add(now(), interval 5 hour) do +begin +end; + +--disable_result_log +flush status; +show databases; +show tables; +show events; +show table status; +show open tables; +show plugins; +show columns in t1; +show slave hosts; +show keys in t1; +show column types; +show table types; +show storage engines; +show authors; +show contributors; +show privileges; +show count(*) warnings; +show count(*) errors; +show warnings; +show status; +show processlist; +show variables; +show charset; +show collation; +show grants; +show create database test; +show create table t1; +show create view v1; +show master status; +show slave status; +show create procedure p1; +show create function f1; +show create trigger tr1; +show procedure status; +show create event e1; +--enable_result_log + +show status like 'slow_queries'; + +drop view v1; +drop table t1; +drop procedure p1; +drop function f1; +drop event e1; + # -# BUG#10491 Server returns data as charset binary SHOW CREATE TABLE or SELECT +# Bug#10491 Server returns data as charset binary SHOW CREATE TABLE or SELECT # FROM I_S. # @@ -875,6 +979,236 @@ drop table t1; --echo End of 5.0 tests +--disable_result_log +SHOW AUTHORS; +--enable_result_log + +# +# Bug#9785 SELECT privilege for the whole database is needed to do +# SHOW CREATE DATABASE +# +create database mysqltest; +show create database mysqltest; +create table mysqltest.t1(a int); +insert into mysqltest.t1 values(1); +grant select on `mysqltest`.`t1` to mysqltest_4@localhost; +connect (con4,localhost,mysqltest_4,,mysqltest); +connection con4; +show create database mysqltest; +connection default; +delete from mysql.user where user='mysqltest_4'; +delete from mysql.db where user='mysqltest_4'; +delete from mysql.tables_priv where user='mysqltest_4'; +flush privileges; +drop database mysqltest; +connection default; +disconnect con4; + +# +# Ensure that show plugin code is tested +# + +--disable_result_log +show full plugin; +--enable_result_log +show warnings; +--disable_result_log +show plugin; +show plugins; +--enable_result_log + +# +# Bug#19874 SHOW COLUMNS and SHOW KEYS handle identifiers containing +# \ incorrectly +# +create database `mysqlttest\1`; +create table `mysqlttest\1`.`a\b` (a int); +show tables from `mysqlttest\1`; +show fields from `mysqlttest\1`.`a\b`; +show columns from `a\b` from `mysqlttest\1`; +show keys from `mysqlttest\1`.`a\b`; +drop table `mysqlttest\1`.`a\b`; +drop database `mysqlttest\1`; + +# +# Bug#24392 SHOW ENGINE MUTEX STATUS is a synonym for SHOW INNODB STATUS +# + +--error ER_UNKNOWN_STORAGE_ENGINE +show engine foobar status; +--error ER_UNKNOWN_STORAGE_ENGINE +show engine foobar logs; +--error ER_UNKNOWN_STORAGE_ENGINE +show engine foobar mutex; + +--error ER_UNKNOWN_STORAGE_ENGINE +show engine mutex status; + +show engine csv status; +show engine csv logs; +show engine csv mutex; +# +# Bug#25081 SHOW FULL TABLES on table with latin chars in name fails +# +set names utf8; +--disable_warnings +drop table if exists `été`; +--enable_warnings +create table `été` (field1 int); +show full tables; +drop table `été`; +set names latin1; + +# +# Bug#26402 Server crashes with old-style named table +# +--error ER_NO_SUCH_TABLE,ER_FILE_NOT_FOUND +show columns from `#mysql50#????????`; + +# +# SHOW CREATE TRIGGER test. +# + +# Prepare. + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +--enable_warnings + +CREATE TABLE t1(c1 INT); + +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1; + +# Test. + +SHOW CREATE TRIGGER t1_bi; + +CREATE PROCEDURE p1() SHOW CREATE TRIGGER t1_bi; + +CALL p1(); +CALL p1(); +CALL p1(); +CALL p1(); +CALL p1(); +CALL p1(); +CALL p1(); +CALL p1(); +CALL p1(); +CALL p1(); + +PREPARE stmt1 FROM 'SHOW CREATE TRIGGER t1_bi'; + +EXECUTE stmt1; +EXECUTE stmt1; +EXECUTE stmt1; +EXECUTE stmt1; +EXECUTE stmt1; +EXECUTE stmt1; +EXECUTE stmt1; +EXECUTE stmt1; +EXECUTE stmt1; +EXECUTE stmt1; + +# Cleanup. + +DROP TABLE t1; +DROP PROCEDURE p1; +DEALLOCATE PREPARE stmt1; + +# +# Bug#10491 Server returns data as charset binary SHOW CREATE TABLE or SELECT +# FROM INFORMATION_SCHEMA. +# +# Before the change performed to fix the bug, the metadata of the output of +# SHOW CREATE statements would always describe the result as 'binary'. That +# would ensure that the result is never converted to character_set_client +# (which was essential to mysqldump). Now we return to the client the actual +# character set of the object -- which is character_set_client of the +# connection that issues the CREATE statement, and this triggers an automatic +# conversion to character_set_results of the connection that issues SHOW CREATE +# statement. +# +# This test demonstrates that this conversion indeed is taking place. +# + +# Prepare: create objects in a one character set. + +set names koi8r; + +--disable_warnings +DROP VIEW IF EXISTS v1; +DROP PROCEDURE IF EXISTS p1; +DROP FUNCTION IF EXISTS f1; +DROP TABLE IF EXISTS t1; +DROP EVENT IF EXISTS ev1; +--enable_warnings + +CREATE VIEW v1 AS SELECT '' AS test; + +CREATE PROCEDURE p1() SELECT '' AS test; + +CREATE FUNCTION f1() RETURNS CHAR(10) RETURN ''; + +CREATE TABLE t1(c1 CHAR(10)); +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 + FOR EACH ROW + SET NEW.c1 = ''; + +CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO SELECT '' AS test; + +# Test: switch the character set and show that SHOW CREATE output is +# automatically converted to the new character_set_client. + +set names utf8; + +SHOW CREATE VIEW v1; + +SHOW CREATE PROCEDURE p1; + +SHOW CREATE FUNCTION f1; + +SHOW CREATE TRIGGER t1_bi; + +SHOW CREATE EVENT ev1; + +# Cleanup. + +DROP VIEW v1; +DROP PROCEDURE p1; +DROP FUNCTION f1; +DROP TABLE t1; +DROP EVENT ev1; + +# +# Bug#30036 SHOW TABLE TYPES causes the debug client to crash +# +--disable_result_log +SHOW TABLE TYPES; +--enable_result_log + + +# +# Bug#32710 SHOW INNODB STATUS requires SUPER +# + +CREATE USER test_u@localhost; +GRANT PROCESS ON *.* TO test_u@localhost; + +connect (conn1, localhost, test_u,,); + +--disable_result_log +SHOW ENGINE MYISAM MUTEX; +SHOW ENGINE MYISAM STATUS; +--enable_result_log + +disconnect conn1; +connection default; +DROP USER test_u@localhost; + + +--echo End of 5.1 tests + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/skip_grants.test b/mysql-test/t/skip_grants.test index 1021d629540..6f4d23e1e14 100644 --- a/mysql-test/t/skip_grants.test +++ b/mysql-test/t/skip_grants.test @@ -110,11 +110,25 @@ DROP FUNCTION f2; DROP FUNCTION f3; # +# Bug #26807 "set global event_scheduler=1" and --skip-grant-tables crashes server +# +--error ER_OPTION_PREVENTS_STATEMENT +set global event_scheduler=1; + +# # Bug#26285 Selecting information_schema crahes server # select count(*) from information_schema.COLUMN_PRIVILEGES; select count(*) from information_schema.SCHEMA_PRIVILEGES; select count(*) from information_schema.TABLE_PRIVILEGES; select count(*) from information_schema.USER_PRIVILEGES; - --echo End of 5.0 tests + +--echo # +--echo # Bug#29817 Queries with UDF fail with non-descriptive error +--echo # if mysql.proc is missing +--echo # +--error ER_SP_DOES_NOT_EXIST +select no_such_function(1); + +--echo End of 5.1 tests diff --git a/mysql-test/t/skip_log_bin-master.opt b/mysql-test/t/skip_log_bin-master.opt new file mode 100644 index 00000000000..9ebccecc95e --- /dev/null +++ b/mysql-test/t/skip_log_bin-master.opt @@ -0,0 +1 @@ +--loose-skip-log-bin diff --git a/mysql-test/t/skip_log_bin.test b/mysql-test/t/skip_log_bin.test new file mode 100644 index 00000000000..6175b2cf7d3 --- /dev/null +++ b/mysql-test/t/skip_log_bin.test @@ -0,0 +1,25 @@ +# +# binlog_off.test purpose is to verify that the --skip-log-bin flag +# works correctly +# + +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +# +# Bug #38798 Assertion mysql_bin_log.is_open() failed in +# binlog_trans_log_savepos() +# Testing that there is no crash. +# Before BUG#38798, the code for CREATE...SELECT called an internal function to +# binlog the statement, even with --skip-log-bin. This caused an assertion +# to be thrown since the binlog was not open. + +set @@session.binlog_format=row; + +create table t1 (a int); +insert into t1 values (1); +create table t2 select * from t1; + +# clean-up +drop table t1, t2; diff --git a/mysql-test/t/skip_name_resolve.test b/mysql-test/t/skip_name_resolve.test index 4e7d927fb15..df010d15fa0 100644 --- a/mysql-test/t/skip_name_resolve.test +++ b/mysql-test/t/skip_name_resolve.test @@ -18,8 +18,11 @@ DROP USER mysqltest_1@'127.0.0.1/255.255.255.255'; connect (con1, 127.0.0.1, root, , test, $MASTER_MYPORT, ); --replace_column 1 # SELECT USER(); ---replace_column 1 <id> 3 <host> 5 <command> 6 <time> 7 <state> 8 <info> +# We are only interested in the fact that statement below doesn't +# crash server. +--disable_result_log SHOW PROCESSLIST; +--enable_result_log connection default; disconnect con1; diff --git a/mysql-test/t/sp-code.test b/mysql-test/t/sp-code.test index a76863dd5fa..247c84fda39 100644 --- a/mysql-test/t/sp-code.test +++ b/mysql-test/t/sp-code.test @@ -631,3 +631,21 @@ drop procedure p_20906_a; drop procedure p_20906_b; --echo End of 5.0 tests. + +# +# Bug #26303: reserve() not called before qs_append() may lead to buffer +# overflow +# +DELIMITER //; +CREATE PROCEDURE p1() +BEGIN + DECLARE dummy int default 0; + + CASE 12 + WHEN 12 + THEN SET dummy = 0; + END CASE; +END// +DELIMITER ;// +SHOW PROCEDURE CODE p1; +DROP PROCEDURE p1; diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test index c568e6bb8f4..14c38a2fdb4 100644 --- a/mysql-test/t/sp-destruct.test +++ b/mysql-test/t/sp-destruct.test @@ -7,10 +7,16 @@ # In the case of trouble you might want to skip this. # +# embedded server returns different paths in error messages +# in lines like 'call bug14233();' +# mysqltest should be fixed to allow REPLACE_RESULT in error message +-- source include/not_embedded.inc + # Backup proc table ---copy_file $MYSQLTEST_VARDIR/master-data/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/proc.frm ---copy_file $MYSQLTEST_VARDIR/master-data/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/proc.MYD ---copy_file $MYSQLTEST_VARDIR/master-data/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/proc.MYI +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file $MYSQLD_DATADIR/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/proc.frm +--copy_file $MYSQLD_DATADIR/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/proc.MYD +--copy_file $MYSQLD_DATADIR/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/proc.MYI use test; @@ -32,18 +38,21 @@ create trigger t1_ai after insert on t1 for each row call bug14233(); # Unsupported tampering with the mysql.proc definition alter table mysql.proc drop type; +--replace_result $MYSQL_TEST_DIR . --error ER_SP_PROC_TABLE_CORRUPT call bug14233(); +--replace_result $MYSQL_TEST_DIR . --error ER_SP_PROC_TABLE_CORRUPT create view v1 as select bug14233_f(); +--replace_result $MYSQL_TEST_DIR . --error ER_SP_PROC_TABLE_CORRUPT insert into t1 values (0); flush table mysql.proc; # Thrashing the .frm file ---remove_file $MYSQLTEST_VARDIR/master-data/mysql/proc.frm ---write_file $MYSQLTEST_VARDIR/master-data/mysql/proc.frm +--remove_file $MYSQLD_DATADIR/mysql/proc.frm +--write_file $MYSQLD_DATADIR/mysql/proc.frm saljdfa EOF --replace_result $MYSQLTEST_VARDIR . master-data// '' '\\' '/' @@ -59,9 +68,9 @@ insert into t1 values (0); flush table mysql.proc; # Drop the mysql.proc table ---remove_file $MYSQLTEST_VARDIR/master-data/mysql/proc.frm ---remove_file $MYSQLTEST_VARDIR/master-data/mysql/proc.MYD ---remove_file $MYSQLTEST_VARDIR/master-data/mysql/proc.MYI +--remove_file $MYSQLD_DATADIR/mysql/proc.frm +--remove_file $MYSQLD_DATADIR/mysql/proc.MYD +--remove_file $MYSQLD_DATADIR/mysql/proc.MYI --error ER_NO_SUCH_TABLE call bug14233(); --error ER_NO_SUCH_TABLE @@ -70,9 +79,9 @@ create view v1 as select bug14233_f(); insert into t1 values (0); # Restore mysql.proc ---copy_file $MYSQLTEST_VARDIR/tmp/proc.frm $MYSQLTEST_VARDIR/master-data/mysql/proc.frm ---copy_file $MYSQLTEST_VARDIR/tmp/proc.MYD $MYSQLTEST_VARDIR/master-data/mysql/proc.MYD ---copy_file $MYSQLTEST_VARDIR/tmp/proc.MYI $MYSQLTEST_VARDIR/master-data/mysql/proc.MYI +--copy_file $MYSQLTEST_VARDIR/tmp/proc.frm $MYSQLD_DATADIR/mysql/proc.frm +--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYD $MYSQLD_DATADIR/mysql/proc.MYD +--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYI $MYSQLD_DATADIR/mysql/proc.MYI --remove_file $MYSQLTEST_VARDIR/tmp/proc.frm --remove_file $MYSQLTEST_VARDIR/tmp/proc.MYD --remove_file $MYSQLTEST_VARDIR/tmp/proc.MYI @@ -87,26 +96,33 @@ insert into mysql.proc ( db, name, type, specific_name, language, sql_data_access, is_deterministic, security_type, param_list, returns, body, definer, created, modified, - sql_mode, comment + sql_mode, comment, character_set_client, collation_connection, db_collation, + body_utf8 ) values ( 'test', 'bug14233_1', 'FUNCTION', 'bug14233_1', 'SQL', 'READS_SQL_DATA', 'NO', 'DEFINER', '', 'int(10)', 'select count(*) from mysql.user', - 'root@localhost', NOW() , '0000-00-00 00:00:00', '', '' + 'root@localhost', NOW() , '0000-00-00 00:00:00', '', '', + '', '', '', + 'select count(*) from mysql.user' ), ( 'test', 'bug14233_2', 'FUNCTION', 'bug14233_2', 'SQL', 'READS_SQL_DATA', 'NO', 'DEFINER', '', 'int(10)', 'begin declare x int; select count(*) into x from mysql.user; end', - 'root@localhost', NOW() , '0000-00-00 00:00:00', '', '' + 'root@localhost', NOW() , '0000-00-00 00:00:00', '', '', + '', '', '', + 'begin declare x int; select count(*) into x from mysql.user; end' ), ( 'test', 'bug14233_3', 'PROCEDURE', 'bug14233_3', 'SQL', 'READS_SQL_DATA','NO', 'DEFINER', '', '', 'alksj wpsj sa ^#!@ ', - 'root@localhost', NOW() , '0000-00-00 00:00:00', '', '' + 'root@localhost', NOW() , '0000-00-00 00:00:00', '', '', + '', '', '', + 'alksj wpsj sa ^#!@ ' ); --error ER_SP_PROC_TABLE_CORRUPT @@ -137,5 +153,5 @@ drop function bug14233_1; drop function bug14233_2; drop procedure bug14233_3; # Assert: These should show nothing. -show procedure status; -show function status; +show procedure status where db=DATABASE(); +show function status where db=DATABASE(); diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index c839b1e4374..66b960c938f 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -6,6 +6,10 @@ drop table if exists t1, t2; --enable_warnings +# Backup the mysql.proc table +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval SELECT * FROM mysql.proc INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/proc.txt'; + # Make sure we don't have any procedures left. delete from mysql.proc; @@ -196,7 +200,7 @@ select f(10)| drop function f| ---error 1322 +--error ER_PARSE_ERROR create procedure p() begin declare c cursor for insert into test.t1 values ("foo", 42); @@ -508,7 +512,7 @@ end| insert into t1 values (666, 51.3)| --error 1054 call bug2272()| -delete from t1| +truncate table t1| drop procedure bug2272| # @@ -586,7 +590,7 @@ begin end| set @x = 0| ---error 1062 +--error ER_DUP_ENTRY call bug3279(@x)| select @x| drop procedure bug3279| @@ -742,7 +746,7 @@ begin fetch c into v; end| -delete from t1| +truncate table t1| --error ER_SP_FETCH_NO_DATA call bug7299()| drop procedure bug7299| @@ -871,7 +875,7 @@ insert into t1 value (2, 2.7), (3, 3.14), (7, 7.0)| select *,bug8408() from t1| drop function bug8408| -delete from t1| +truncate table t1| # @@ -1114,6 +1118,10 @@ execute stmt; drop function bug11834_1; # Attempt to execute statement should return proper error and # should not crash server. + +# NOTE! The error we get from the below query indicates that the sp bug11834_2 +# does not exist(this is wrong but can be accepted) +# This behaviour has been reported as bug#21294 --error ER_SP_DOES_NOT_EXIST execute stmt; deallocate prepare stmt; @@ -1383,6 +1391,21 @@ CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create user 'mysqltest CREATE FUNCTION bug_13627_f() returns int BEGIN create user 'mysqltest_1'; return 1; END | -- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +CREATE TRIGGER bug21975 BEFORE INSERT ON t1 FOR EACH ROW BEGIN grant select on t1 to 'mysqltest_1'; END | +-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +CREATE FUNCTION bug21975() returns int BEGIN grant select on t1 to 'mysqltest_1'; return 1; END | + +-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +CREATE TRIGGER bug21975 BEFORE INSERT ON t1 FOR EACH ROW BEGIN revoke select on t1 from 'mysqltest_1'; END | +-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +CREATE FUNCTION bug21975() returns int BEGIN revoke select on t1 from 'mysqltest_1'; return 1; END | + +-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +CREATE TRIGGER bug21975 BEFORE INSERT ON t1 FOR EACH ROW BEGIN revoke all privileges on *.* from 'mysqltest_1'; END | +-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG +CREATE FUNCTION bug21975() returns int BEGIN revoke all privileges on *.* from 'mysqltest_1'; return 1; END | + +-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop user 'mysqltest_1'; END | -- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG CREATE FUNCTION bug_13627_f() returns int BEGIN drop user 'mysqltest_1'; return 1; END | @@ -1451,10 +1474,6 @@ execute stmt1; drop function bug12329; create function bug12329() returns int return (select a+100 from t2); select bug12329(); -# Until we implement proper mechanism for invalidation of PS/SP when table -# or SP's are changed the following statement will fail with 'Table ... was -# not locked' error (this mechanism should be based on the new TDC). ---error ER_NO_SUCH_TABLE execute stmt1; deallocate prepare stmt1; drop function bug12329; @@ -1747,7 +1766,7 @@ drop function if exists bug16896; --error ER_PARSE_ERROR create aggregate function bug16896() returns int return 1; - +# # # BUG#14702: misleading error message when syntax error in CREATE # PROCEDURE @@ -2022,6 +2041,44 @@ drop function func_25345; drop function func_25345_b; # +# End of 5.0 tests +# +--echo End of 5.0 tests + +# +# Bug#16164 "Easter egg": check that SHOW AUTHORS is disabled in +# stored functions/triggers +# +--disable_warnings +drop function if exists bug16164; +--enable_warnings +delimiter |; +--error ER_SP_NO_RETSET +create function bug16164() returns int +begin + show authors; + return 42; +end| +delimiter ;| + + +# +# BUG#20701: BINARY keyword should be forbidden in stored routines +# +--disable_warnings +drop function if exists bug20701; +--enable_warnings +# +# This was disabled in 5.1.12. See bug #20701 +# When collation support in SP is implemented, then this test should +# be removed. +# +--error ER_NOT_SUPPORTED_YET +create function bug20701() returns varchar(25) binary return "test"; +create function bug20701() returns varchar(25) return "test"; +drop function bug20701; + +# # Bug#26503 (Illegal SQL exception handler code causes the server to crash) # @@ -2089,6 +2146,55 @@ end// delimiter ;// + +# +# Bug#28360 (RENAME DATABASE destroys routines) +# + +--disable_warnings +drop procedure if exists proc_28360; +drop function if exists func_28360; +--enable_warnings + +delimiter //; + +--error ER_SP_NO_DROP_SP +CREATE PROCEDURE proc_28360() +BEGIN + ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME; +END// + +--error ER_SP_NO_DROP_SP +CREATE FUNCTION func_28360() RETURNS int +BEGIN + ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME; + RETURN 0; +END// + +delimiter ;// + + +# +# Bug#29223 declare cursor c for SHOW ..... +# + +--disable_warnings +DROP PROCEDURE IF EXISTS p1; +--enable_warnings +--delimiter | +--error ER_PARSE_ERROR +CREATE PROCEDURE p1() +BEGIN + DECLARE c char(100); + DECLARE cur1 CURSOR FOR SHOW TABLES; + + OPEN cur1; + FETCH cur1 INTO c; + select c; + CLOSE cur1; +END| +--delimiter ; + # # Bug#29816 Syntactically wrong query fails with misleading error message # @@ -2113,6 +2219,93 @@ SELECT ..inexistent(); USE test; # +# Bug#30904 SET PASSWORD statement is non-transactional +# + +delimiter |; + +--error ER_SP_CANT_SET_AUTOCOMMIT +create function f1() returns int +begin + set @test = 1, password = password('foo'); + return 1; +end| + +--error ER_SP_CANT_SET_AUTOCOMMIT +create trigger t1 + before insert on t2 for each row set password = password('foo');| + +delimiter ;| + +# +# Bug#30882 Dropping a temporary table inside a stored function may cause a server crash +# + +--disable_warnings +drop function if exists f1; +drop function if exists f2; +drop table if exists t1, t2; +--enable_warnings + +delimiter |; +create function f1() returns int +begin + drop temporary table t1; + return 1; +end| +delimiter ;| +--error ER_CANT_REOPEN_TABLE +create temporary table t1 as select f1(); + +delimiter |; +create function f2() returns int +begin + create temporary table t2 as select f1(); + return 1; +end| +delimiter ;| +--error ER_CANT_REOPEN_TABLE +create temporary table t1 as select f2(); + +drop function f1; +drop function f2; + +delimiter |; +create function f1() returns int +begin + drop temporary table t2,t1; + return 1; +end| +create function f2() returns int +begin + create temporary table t2 as select f1(); + return 1; +end| +delimiter ;| +--error ER_CANT_REOPEN_TABLE +create temporary table t1 as select f2(); + +drop function f1; +drop function f2; + +create temporary table t2(a int); +select * from t2; +delimiter |; +create function f2() returns int +begin + drop temporary table t2; + return 1; +end| +delimiter ;| +select f2(); + +drop function f2; +--error ER_BAD_TABLE_ERROR +drop table t2; + +--echo End of 5.1 tests + +# # Bug#33983 (Stored Procedures: wrong end <label> syntax is accepted) # @@ -2184,9 +2377,74 @@ DROP TABLE t1| delimiter ;| # +# Bug#21801: SQL exception handlers and warnings +# + +--disable_warnings +drop procedure if exists p1; +--enable_warnings +delimiter |; +create procedure p1() +begin + create table t1 (a int) type=MyISAM; + drop table t1; +end| +delimiter ;| +call p1(); +call p1(); +drop procedure p1; + +# +# Bug#8759 (Stored Procedures: SQLSTATE '00000' should be illegal) +# + +--disable_warnings +drop procedure if exists proc_8759; +--enable_warnings + +delimiter $$; + +--error ER_SP_BAD_SQLSTATE +create procedure proc_8759() +begin + declare should_be_illegal condition for sqlstate '00000'; + declare continue handler for should_be_illegal set @x=0; +end$$ + +--error ER_SP_BAD_SQLSTATE +create procedure proc_8759() +begin + declare continue handler for sqlstate '00000' set @x=0; +end$$ + +delimiter ;$$ + + +# # BUG#NNNN: New bug synopsis # #--disable_warnings -#drop procedure if exists bugNNNN| +#drop procedure if exists bugNNNN; +#drop function if exists bugNNNN; #--enable_warnings #create procedure bugNNNN... +#create function bugNNNN... + +# +# CLEANUP and RESTORE +# +LOAD DATA INFILE '../../tmp/proc.txt' INTO TABLE mysql.proc; +remove_file $MYSQLTEST_VARDIR/tmp/proc.txt; + +# +# Bug #38159: Function parsing problem generates misleading error message +# + +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1), (2,2); +--error ER_FUNC_INEXISTENT_NAME_COLLISION +SELECT MAX (a) FROM t1 WHERE b = 999999; +SELECT AVG (a) FROM t1 WHERE b = 999999; +--error ER_SP_DOES_NOT_EXIST +SELECT non_existent (a) FROM t1 WHERE b = 999999; +DROP TABLE t1; diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test index b8181fcb89b..a80fe89082a 100644 --- a/mysql-test/t/sp-security.test +++ b/mysql-test/t/sp-security.test @@ -246,11 +246,11 @@ disconnect con2user1; disconnect con3anon; disconnect con4user2; use test; -select type,db,name from mysql.proc; +select type,db,name from mysql.proc where db like 'db%'; drop database db1_secret; drop database db2; # Make sure the routines are gone -select type,db,name from mysql.proc; +select type,db,name from mysql.proc where db like 'db%'; # Get rid of the users delete from mysql.user where user='user1' or user='user2'; delete from mysql.user where user='' and host='%'; @@ -551,29 +551,6 @@ drop database db_bug14533; # -# Bug#7787 Stored procedures: improper warning for "grant execute" statement -# - -# Prepare. - -CREATE DATABASE db_bug7787; -USE db_bug7787; - -# Test. - -CREATE PROCEDURE p1() - SHOW INNODB STATUS; - -GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost; - -# Cleanup. - -DROP DATABASE db_bug7787; -drop user user_bug7787@localhost; -use test; - - -# # WL#2897 Complete definer support in the stored routines. # # The following cases are tested: @@ -767,7 +744,6 @@ DROP USER mysqltest_2@localhost; DROP DATABASE mysqltest; - # # Bug#19857 When a user with CREATE ROUTINE priv creates a routine, # it results in NULL p/w @@ -816,7 +792,7 @@ DROP USER user19857@localhost; --disconnect con1root --connection default - +use test; # # Bug#18630 Arguments of suid routine calculated in wrong security context diff --git a/mysql-test/t/sp-vars.test b/mysql-test/t/sp-vars.test index 2cc68b054d5..fe063889f81 100644 --- a/mysql-test/t/sp-vars.test +++ b/mysql-test/t/sp-vars.test @@ -1412,3 +1412,39 @@ DROP PROCEDURE bug27415_text_test2| DELIMITER ;| # End of 5.0 tests. + +# +# Bug #26277 User variable returns one type in SELECT @v and other for CREATE as SELECT @v +# +--disable_warnings +drop function if exists f1; +drop table if exists t1; +--enable_warnings + +delimiter |; +create function f1() returns int +begin + if @a=1 then set @b='abc'; + else set @b=1; + end if; + set @a=1; + return 0; +end| + +create table t1 (a int)| +insert into t1 (a) values (1), (2)| + +set @b=1| +set @a=0| +select f1(), @b from t1| + +set @b:='test'| +set @a=0| +select f1(), @b from t1| + +delimiter ;| + +drop function f1; +drop table t1; +# End of 5.1 tests. + diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index a785aa2334f..44c4556340e 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -11,6 +11,7 @@ # Tests that uses 'goto' to into sp-goto.test (currently disabled) # Tests that destroys system tables (e.g. mysql.proc) for error testing # go to sp-destruct. +# Tests that require --with-geometry go into sp_gis.test # Tests that require multibyte character sets, which are not always available, # go into separate files (e.g. sp-ucs2.test) @@ -146,7 +147,7 @@ begin end| call setcontext()| -select * from t1| +select * from t1 order by data| delete from t1| drop procedure setcontext| @@ -290,7 +291,7 @@ create procedure inc(inout io int) set io = io + 1| call iotest("io1", "io2", 1)| -select * from t1| +select * from t1 order by data desc| delete from t1| drop procedure iotest| drop procedure inc2| @@ -336,7 +337,7 @@ begin end| call cbv1()| -select * from t1| +select * from t1 order by data| delete from t1| drop procedure cbv1| drop procedure cbv2| @@ -365,7 +366,7 @@ end| --disable_warnings drop procedure if exists sub3| --enable_warnings -create function sub3(i int) returns int +create function sub3(i int) returns int deterministic return i+1| call sub1("sub1a", (select 7))| @@ -374,7 +375,7 @@ call sub1("sub1b", (select max(i) from t2))| call sub1("sub1c", (select i,d from t2 limit 1))| call sub1("sub1d", (select 1 from (select 1) a))| call sub2("sub2")| -select * from t1| +select * from t1 order by id| select sub3((select max(i) from t2))| drop procedure sub1| drop procedure sub2| @@ -395,7 +396,7 @@ while x do end while| call a0(3)| -select * from t1| +select * from t1 order by data desc| delete from t1| drop procedure a0| @@ -411,7 +412,7 @@ while x > 0 do end while| call a(3)| -select * from t1| +select * from t1 order by data desc| delete from t1| drop procedure a| @@ -427,7 +428,7 @@ repeat until x = 0 end repeat| call b(3)| -select * from t1| +select * from t1 order by data desc| delete from t1| drop procedure b| @@ -459,7 +460,7 @@ hmm: while x > 0 do end while hmm| call c(3)| -select * from t1| +select * from t1 order by data desc| delete from t1| drop procedure c| @@ -496,7 +497,7 @@ foo: loop end loop foo| call e(3)| -select * from t1| +select * from t1 order by data desc| delete from t1| drop procedure e| @@ -517,7 +518,7 @@ end if| call f(-2)| call f(0)| call f(4)| -select * from t1| +select * from t1 order by data| delete from t1| drop procedure f| @@ -539,7 +540,7 @@ end case| call g(-42)| call g(0)| call g(1)| -select * from t1| +select * from t1 order by data| delete from t1| drop procedure g| @@ -561,7 +562,7 @@ end case| call h(0)| call h(1)| call h(17)| -select * from t1| +select * from t1 order by data| delete from t1| drop procedure h| @@ -595,7 +596,7 @@ drop procedure if exists sel1| --enable_warnings create procedure sel1() begin - select * from t1; + select * from t1 order by data; end| call sel1()| @@ -606,8 +607,8 @@ drop procedure if exists sel2| --enable_warnings create procedure sel2() begin - select * from t1; - select * from t2; + select * from t1 order by data; + select * from t2 order by s; end| call sel2()| @@ -627,7 +628,7 @@ begin end| call into_test("into", 100)| -select * from t1| +select * from t1 order by data| delete from t1| drop procedure into_test| @@ -644,7 +645,7 @@ begin end| call into_test2("into", 100)| -select id,data,@z from t1| +select id,data,@z from t1 order by data| delete from t1| drop procedure into_test2| @@ -702,7 +703,7 @@ drop procedure into_test4| --disable_warnings drop procedure if exists into_outfile| --enable_warnings ---replace_result $MYSQLTEST_VARDIR .. +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval create procedure into_outfile(x char(16), y int) begin insert into test.t1 values (x, y); @@ -721,7 +722,7 @@ drop procedure into_outfile| --disable_warnings drop procedure if exists into_dumpfile| --enable_warnings ---replace_result $MYSQLTEST_VARDIR .. +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval create procedure into_dumpfile(x char(16), y int) begin insert into test.t1 values (x, y); @@ -826,9 +827,9 @@ insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))| # Disable PS because double's give a bit different values --disable_ps_protocol select * from t2 where s = append("a", "b")| -select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2)| +select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2) order by i| select * from t2 where d = e()| -select * from t2| +select * from t2 order by i| --enable_ps_protocol delete from t2| @@ -983,8 +984,8 @@ drop procedure if exists cur2| create procedure cur2() begin declare done int default 0; - declare c1 cursor for select id,data from test.t1; - declare c2 cursor for select i from test.t2; + declare c1 cursor for select id,data from test.t1 order by id,data; + declare c2 cursor for select i from test.t2 order by i; declare continue handler for sqlstate '02000' set done = 1; open c1; @@ -1010,7 +1011,7 @@ begin end| call cur2()| -select * from t3| +select * from t3 order by i,s| delete from t1| delete from t2| drop table t3| @@ -1185,13 +1186,13 @@ create function f1() returns int return (select sum(data) from t1)| select f1()| # This should work too (and give 2 rows as result) -select id, f1() from t1| +select id, f1() from t1 order by id| # Function which uses two instances of table simultaneously create function f2() returns int - return (select data from t1 where data <= (select sum(data) from t1) limit 1)| + return (select data from t1 where data <= (select sum(data) from t1) order by data limit 1)| select f2()| -select id, f2() from t1| +select id, f2() from t1 order by id| # Function which uses the same table twice in different queries create function f3() returns int @@ -1203,17 +1204,17 @@ begin return n < m; end| select f3()| -select id, f3() from t1| +select id, f3() from t1 order by id| # Calling two functions using same table select f1(), f3()| -select id, f1(), f3() from t1| +select id, f1(), f3() from t1 order by id| # Function which uses two different tables create function f4() returns double return (select d from t1, t2 where t1.data = t2.i and t1.id= "b")| select f4()| -select s, f4() from t2| +select s, f4() from t2 order by s| # Recursive functions which due to this recursion require simultaneous # access to several instance of the same table won't work @@ -1246,7 +1247,7 @@ end| create function f7() returns int return (select sum(data) from t1 where data <= f1())| select f6()| -select id, f6() from t1| +select id, f6() from t1 order by id| # # Let us test how new locking work with views @@ -1254,12 +1255,12 @@ select id, f6() from t1| # The most trivial view create view v1 (a) as select f1()| select * from v1| -select id, a from t1, v1| +select id, a from t1, v1 order by id| select * from v1, v1 as v| # A bit more complex construction create view v2 (a) as select a*10 from v1| select * from v2| -select id, a from t1, v2| +select id, a from t1, v2 order by id| select * from v1, v2| # Nice example where the same view is used on @@ -1304,7 +1305,7 @@ select *, f0() from v0| lock tables t1 read, t1 as t11 read| # These should work well select f3()| -select id, f3() from t1 as t11| +select id, f3() from t1 as t11 order by id| # Degenerate cases work too :) select f0()| select * from v0| @@ -1412,8 +1413,8 @@ drop function f12_2| drop view v0| drop view v1| drop view v2| -delete from t1 | -delete from t2 | +truncate table t1 | +truncate table t2 | drop table t4| # End of non-bug tests @@ -1451,11 +1452,11 @@ end| call ifac(20)| select * from t3| drop table t3| ---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' +--replace_column 4 'root@localhost' 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' show function status like '%f%'| drop procedure ifac| drop function fac| ---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' +--replace_column 4 'root@localhost' 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' show function status like '%f%'| @@ -1539,7 +1540,7 @@ begin end| show create procedure opp| --replace_column 4 'root@localhost' 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' -show procedure status like '%p%'| +show procedure status where name like '%p%' and db='test'| # This isn't the fastest way in the world to compute prime numbers, so # don't be too ambitious. ;-) @@ -1557,7 +1558,7 @@ drop table t3| drop procedure opp| drop procedure ip| --replace_column 4 'root@localhost' 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' -show procedure status like '%p%'| +show procedure status where name like '%p%' and db='test'| # @@ -1643,7 +1644,6 @@ begin end if; return x; end| - select * from t1 where data = getcount("bar")| select * from t3| select getcount("zip")| @@ -2070,7 +2070,7 @@ delete from t1| call bug822('foo', 42)| call bug822('foo', 42)| call bug822('bar', 666)| -select * from t1| +select * from t1 order by data| delete from t1| drop procedure bug822| @@ -2098,7 +2098,7 @@ delete from t1 where id='foo'| insert into t1 values ('bar', 7)| call bug1495()| delete from t1 where id='bar'| -select * from t1| +select * from t1 order by data| delete from t1| drop procedure bug1495| @@ -2123,7 +2123,7 @@ end| insert into t1 values ("foo", 12), ("bar", 7)| call bug1547("foo")| call bug1547("bar")| -select * from t1| +select * from t1 order by id| delete from t1| drop procedure bug1547| @@ -2190,7 +2190,7 @@ end| insert into t1 (data) values (3), (1), (5), (9), (4)| call bug1874()| -select * from t2| +select * from t2 order by i| delete from t1| delete from t2| drop procedure bug1874| @@ -2225,7 +2225,7 @@ drop procedure if exists bug2267_1| --enable_warnings create procedure bug2267_1() begin - show procedure status; + show procedure status where db='test'; end| --disable_warnings @@ -2233,7 +2233,7 @@ drop procedure if exists bug2267_2| --enable_warnings create procedure bug2267_2() begin - show function status; + show function status where db='test'; end| --disable_warnings @@ -2539,6 +2539,9 @@ begin end if; end| +# so that from_unixtime() has a deterministic result +set time_zone='+03:00'; + call bug3426(1000, @i)| select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time| call bug3426(NULL, @i)| @@ -2887,13 +2890,15 @@ begin show columns from t1; show keys from t1; show open tables like 'foo'; - show privileges; + # Removed because result will differ in embedded mode. + #show privileges; show status like 'foo'; show tables like 'foo'; show variables like 'foo'; show warnings; end| --disable_parsing +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events| show storage engines| show master status| @@ -4331,12 +4336,23 @@ drop table t3| --disable_warnings drop function if exists bug9048| --enable_warnings -create function bug9048(f1 char binary) returns char binary +create function bug9048(f1 char binary) returns char begin set f1= concat( 'hello', f1 ); return f1; end| drop function bug9048| +# +# This was disabled in 5.1.12. See bug #20701 +# When collation support in SP is implemented, then this test should +# be removed. +# +--error ER_NOT_SUPPORTED_YET +create function bug9048(f1 char binary) returns char binary +begin + set f1= concat( 'hello', f1 ); + return f1; +end| # Bug #12849 Stored Procedure: Crash on procedure call with CHAR type # 'INOUT' parameter @@ -4449,9 +4465,13 @@ end| --error ER_DUP_ENTRY select bug12379()| select 1| +# statement-based binlogging will show warning which row-based won't; +# so we hide it (this warning is already tested in rpl_stm_sp.test) +--disable_warnings call bug12379_1()| select 2| call bug12379_2()| +--enable_warnings select 3| --error ER_DUP_ENTRY call bug12379_3()| @@ -4886,7 +4906,7 @@ end| # a procedure which use tables and recursion create table t3 (a int)| insert into t3 values (0)| -create view v1 as select a from t3; +create view v1 as select a from t3| create procedure bug10100pt(level int, lim int) begin if level < lim then @@ -4909,7 +4929,7 @@ begin end if; end| # dynamic sql & recursion -prepare stmt2 from "select * from t3;"; +prepare stmt2 from "select * from t3;"| create procedure bug10100pd(level int, lim int) begin if level < lim then @@ -5188,8 +5208,8 @@ drop procedure bug5967| --disable_warnings drop procedure if exists bug13012| +# Disable warnings also for BACKUP/RESTORE: they are deprecated. --replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> ---enable_warnings eval create procedure bug13012() BEGIN REPAIR TABLE t1; @@ -5199,8 +5219,10 @@ eval create procedure bug13012() END| call bug13012()| +--enable_warnings --remove_file $backupdir/t1.frm --remove_file $backupdir/t1.MYD + drop procedure bug13012| create view v1 as select * from t1| @@ -5214,8 +5236,8 @@ call bug13012()| call bug13012()| call bug13012()| drop procedure bug13012| -drop view v1; -select * from t1| +drop view v1| +select * from t1 order by data| # # A test case for Bug#15392 "Server crashes during prepared statement @@ -5569,26 +5591,6 @@ drop table t3| drop procedure bug16887| # -# Bug#13575 SP funcs in select with distinct/group and order by can -# produce bad data -# -# Disable warnings to allow test to run also without InnoDB ---disable_warnings -create table t3 (f1 int, f2 varchar(3), primary key(f1)) engine=innodb| ---enable_warnings -insert into t3 values (1,'aaa'),(2,'bbb'),(3,'ccc')| -CREATE FUNCTION bug13575 ( p1 integer ) -returns varchar(3) -BEGIN -DECLARE v1 VARCHAR(10) DEFAULT null; -SELECT f2 INTO v1 FROM t3 WHERE f1 = p1; -RETURN v1; -END| -select distinct f1, bug13575(f1) from t3 order by f1| -drop function bug13575; -drop table t3| - -# # BUG#16474: SP crashed MySQL # (when using "order by localvar", where 'localvar' is just that. # @@ -5604,7 +5606,7 @@ create procedure bug16474_1() begin declare x int; - select id from t1 order by x; + select id from t1 order by x, id; end| # @@ -5624,7 +5626,7 @@ drop procedure bug14945| # This does NOT order by column index; variable is an expression. create procedure bug16474_2(x int) - select id from t1 order by x| + select id from t1 order by x, id| call bug16474_1()| call bug16474_2(1)| @@ -5634,7 +5636,7 @@ drop procedure bug16474_2| # For reference: user variables are expressions too and do not affect ordering. set @x = 2| -select * from t1 order by @x| +select * from t1 order by @x, data| delete from t1| @@ -6203,6 +6205,8 @@ SELECT bug19862(a) FROM t12 ORDER BY 1| SELECT * FROM t11| DROP TABLE t11, t12| DROP FUNCTION bug19862| + + # Bug#21002 "Derived table not selecting from a "real" table fails in JOINs" # # A regression caused by the fix for Bug#18444: for derived tables we should @@ -6228,10 +6232,8 @@ use test| drop table t3| -# # Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause. # - # Prepare. --disable_warnings @@ -6292,7 +6294,7 @@ set names utf8| drop database if exists това_е_дълго_име_за_база_данни_нали| --enable_warnings create database това_е_дълго_име_за_база_данни_нали| -INSERT INTO mysql.proc VALUES ('това_е_дълго_име_за_база_данни_нали','това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго','PROCEDURE','това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго','SQL','CONTAINS_SQL','NO','DEFINER','','','bad_body','root@localhost',now(), now(),'','')| +INSERT INTO mysql.proc VALUES ('това_е_дълго_име_за_база_данни_нали','това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго','PROCEDURE','това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго','SQL','CONTAINS_SQL','NO','DEFINER','','','bad_body','root@localhost',now(), now(),'','', 'utf8', 'utf8_general_ci', 'utf8_general_ci', 'n/a')| --error ER_SP_PROC_TABLE_CORRUPT call това_е_дълго_име_за_база_данни_нали.това_е_процедура_с_доста_дълго_име_нали_и_още_по_дълго()| drop database това_е_дълго_име_за_база_данни_нали| @@ -6597,6 +6599,124 @@ DROP PROCEDURE p1| DROP VIEW v1, v2| DROP TABLE t3, t4| +--echo End of 5.0 tests + +--echo Begin of 5.1 tests + +# +# BUG#18239: Possible to overload internal functions with stored functions +# + +delimiter ;| + +--disable_warnings +drop function if exists pi; +--enable_warnings + +create function pi() returns varchar(50) +return "pie, my favorite desert."; + +SET @save_sql_mode=@@sql_mode; + +SET SQL_MODE='IGNORE_SPACE'; + +select pi(), pi (); + +# Non deterministic warnings from db_load_routine +--disable_warnings +select test.pi(), test.pi (); +--enable_warnings + +SET SQL_MODE=''; + +select pi(), pi (); + +# Non deterministic warnings from db_load_routine +--disable_warnings +select test.pi(), test.pi (); +--enable_warnings + +SET @@sql_mode=@save_sql_mode; + +drop function pi; +# End of BUG#18239 + +# +# BUG#22619: Spaces considered harmful +# + +--disable_warnings +drop function if exists test.database; +drop function if exists test.current_user; +drop function if exists test.md5; +--enable_warnings + +create database nowhere; +use nowhere; +drop database nowhere; + +SET @save_sql_mode=@@sql_mode; + +SET SQL_MODE='IGNORE_SPACE'; + +select database(), database (); +select current_user(), current_user (); +select md5("aaa"), md5 ("aaa"); + +SET SQL_MODE=''; + +select database(), database (); +select current_user(), current_user (); +select md5("aaa"), md5 ("aaa"); + +use test; + +create function `database`() returns varchar(50) +return "Stored function database"; + +create function `current_user`() returns varchar(50) +return "Stored function current_user"; + +create function md5(x varchar(50)) returns varchar(50) +return "Stored function md5"; + +SET SQL_MODE='IGNORE_SPACE'; + +select database(), database (); +select current_user(), current_user (); +select md5("aaa"), md5 ("aaa"); + +# Non deterministic warnings from db_load_routine +--disable_warnings +select test.database(), test.database (); +select test.current_user(), test.current_user (); +select test.md5("aaa"), test.md5 ("aaa"); +--enable_warnings + +SET SQL_MODE=''; + +select database(), database (); +select current_user(), current_user (); +select md5("aaa"), md5 ("aaa"); + +# Non deterministic warnings from db_load_routine +--disable_warnings +select test.database(), test.database (); +select test.current_user(), test.current_user (); +select test.md5("aaa"), test.md5 ("aaa"); +--enable_warnings + +SET @@sql_mode=@save_sql_mode; + +drop function test.database; +drop function test.current_user; +drop function md5; + +use test; +delimiter |; +# End of BUG#22619 + +--echo End of 5.1 tests # # BUG#23760: ROW_COUNT() and store procedure not owrking together @@ -7029,6 +7149,9 @@ show create procedure proc_21513| drop procedure proc_21513| +### +--echo End of 5.0 tests. + # # BUG#NNNN: New bug synopsis # @@ -7200,6 +7323,106 @@ drop procedure sp_bug29050; drop table t1; # +# Bug #30120 SP with local variables with non-ASCII names crashes server. +# + +SET NAMES latin1; + +DELIMITER |; + +CREATE PROCEDURE p1() +BEGIN + DECLARE INT; + SELECT ; +END| + +DELIMITER ;| + +CALL p1(); + +SET NAMES default; +DROP PROCEDURE p1; + +# +# Bug#25411 (trigger code truncated) +# + +--disable_warnings +drop procedure if exists proc_25411_a; +drop procedure if exists proc_25411_b; +drop procedure if exists proc_25411_c; +--enable_warnings + +delimiter $$; + +create procedure proc_25411_a() +begin + /* real comment */ + select 1; + /*! select 2; */ + select 3; + /*!00000 select 4; */ + /*!99999 select 5; */ +end +$$ + +create procedure proc_25411_b( +/* real comment */ +/*! p1 int, */ +/*!00000 p2 int */ +/*!99999 ,p3 int */ +) +begin + select p1, p2; +end +$$ + +create procedure proc_25411_c() +begin + select 1/*!,2*//*!00000,3*//*!99999,4*/; + select 1/*! ,2*//*!00000 ,3*//*!99999 ,4*/; + select 1/*!,2 *//*!00000,3 *//*!99999,4 */; + select 1/*! ,2 *//*!00000 ,3 *//*!99999 ,4 */; + select 1 /*!,2*/ /*!00000,3*/ /*!99999,4*/ ; +end +$$ + +delimiter ;$$ + +show create procedure proc_25411_a; +call proc_25411_a(); + +show create procedure proc_25411_b; +select name, param_list, body from mysql.proc where name like "%25411%"; +call proc_25411_b(10, 20); + +show create procedure proc_25411_c; +call proc_25411_c(); + +drop procedure proc_25411_a; +drop procedure proc_25411_b; +drop procedure proc_25411_c; + + +# +# Bug#26302 (MySQL server cuts off trailing "*/" from comments in SP/func) +# + +--disable_warnings +drop procedure if exists proc_26302; +--enable_warnings + +create procedure proc_26302() +select 1 /* testing */; + +show create procedure proc_26302; + +select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES +where ROUTINE_NAME = "proc_26302"; + +drop procedure proc_26302; + + # Bug #29338: no optimization for stored functions with a trivial body # always returning constant. # @@ -7230,27 +7453,6 @@ DROP FUNCTION f2; DROP TABLE t1; # -# Bug #30120 SP with local variables with non-ASCII names crashes server. -# - -SET NAMES latin1; - -DELIMITER |; - -CREATE PROCEDURE p1() -BEGIN - DECLARE INT; - SELECT ; -END| - -DELIMITER ;| - -CALL p1(); - -SET NAMES default; -DROP PROCEDURE p1; - -# # Bug#29408 Cannot find view in columns table if the selection contains a function # delimiter |; @@ -7654,7 +7856,9 @@ DROP PROCEDURE db28318_a.t1; DROP PROCEDURE db28318_b.t2; DROP DATABASE db28318_a; DROP DATABASE db28318_b; -USE test; +use test; + +########################################################################### # # Bug#29770 Two handlers are allowed to catch an error in an stored procedure. @@ -7700,7 +7904,7 @@ begin declare count1 int default '0'; declare vb varchar(30); declare last_row int; - + while(num>=1) do set num=num-1; begin @@ -7730,6 +7934,7 @@ call proc_33618(20); drop table t_33618; drop procedure proc_33618; + --echo # --echo # Bug#30787: Stored function ignores user defined alias. --echo # @@ -7765,6 +7970,8 @@ CALL test_sp(); DROP PROCEDURE test_sp; DROP TABLE t1; + +########################################################################### # # Bug#38291 memory corruption and server crash with view/sp/function # @@ -7832,3 +8039,231 @@ drop procedure p1; --echo # ------------------------------------------------------------------ --echo # -- End of 5.0 tests --echo # ------------------------------------------------------------------ + +########################################################################### + +# +# Bug#20550: Stored function: wrong RETURN type metadata when used in a VIEW. +# + +########################################################################### + +--echo + +--echo # +--echo # Bug#20550. +--echo # + +--echo + +--echo # +--echo # - Prepare. +--echo # + +--echo + +--disable_warnings +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +--enable_warnings + +--echo + +--echo # +--echo # - Create required objects. +--echo # + +--echo + +CREATE FUNCTION f1() RETURNS VARCHAR(65525) RETURN 'Hello'; + +--echo + +CREATE FUNCTION f2() RETURNS TINYINT RETURN 1; + +--echo + +CREATE VIEW v1 AS SELECT f1(); + +--echo + +CREATE VIEW v2 AS SELECT f2(); + +--echo + +--echo # +--echo # - Check. +--echo # + +--echo + +SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v1'; + +--echo + +SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'v2'; + +--echo + +--echo # +--echo # - Cleanup. +--echo # + +--echo + +DROP FUNCTION f1; +DROP FUNCTION f2; +DROP VIEW v1; +DROP VIEW v2; + +--echo + +########################################################################### + +# +# Bug#24923: Functions with ENUM issues. +# + +########################################################################### + +--echo # +--echo # - Bug#24923: prepare. +--echo # + +--echo + +--disable_warnings +DROP FUNCTION IF EXISTS f1; +--enable_warnings + +--echo + +--echo # +--echo # - Bug#24923: create required objects. +--echo # + +--echo + +delimiter |; + +CREATE FUNCTION f1(p INT) + RETURNS ENUM ('Very_long_enum_element_identifier', + 'Another_very_long_enum_element_identifier') + BEGIN + CASE p + WHEN 1 THEN + RETURN 'Very_long_enum_element_identifier'; + ELSE + RETURN 'Another_very_long_enum_element_identifier'; + END CASE; + END| + +delimiter ;| + +--echo + +--echo # +--echo # - Bug#24923: check. +--echo # + +--echo + +SELECT f1(1); + +--echo + +SELECT f1(2); + +--echo + +SHOW CREATE FUNCTION f1; + +--echo # +--echo # - Bug#24923: cleanup. +--echo # + +--echo + +DROP FUNCTION f1; + +--echo + +########################################################################### + +# +# Bug#32633 Can not create any routine if SQL_MODE=no_engine_substitution +# +# Ensure that when new SQL modes are introduced, they are also added to +# the mysql.proc table. +# + +--disable_warnings +drop procedure if exists p; +--enable_warnings +set @old_mode= @@sql_mode; +set @@sql_mode= pow(2,32)-1; +select @@sql_mode into @full_mode; +create procedure p() begin end; +call p(); +select @@sql_mode; +set @@sql_mode= @old_mode; +# Rename SQL modes that differ in name between the server and the table definition. +select replace(@full_mode, '?', 'NOT_USED') into @full_mode; +select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode; +select name from mysql.proc where name = 'p' and sql_mode = @full_mode; +drop procedure p; + +# +# Bug#43962 "Packets out of order" calling a SHOW TABLE STATUS +# +DELIMITER //; +CREATE DEFINER = 'root'@'localhost' PROCEDURE p1() +NOT DETERMINISTIC +CONTAINS SQL +SQL SECURITY DEFINER +COMMENT '' +BEGIN + SHOW TABLE STATUS like 't1'; +END;// +DELIMITER ;// + + +CREATE TABLE t1 (f1 INT); +--disable_result_log +let $tab_count= 4; +while ($tab_count) +{ + EVAL CALL p1(); + dec $tab_count ; +} +--enable_result_log +DROP PROCEDURE p1; +DROP TABLE t1; + + +--echo # +--echo # Bug #46629: Item_in_subselect::val_int(): Assertion `0' +--echo # on subquery inside a SP +--echo # +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT, b INT PRIMARY KEY); + +DELIMITER |; +CREATE PROCEDURE p1 () +BEGIN + SELECT a FROM t1 A WHERE A.b IN (SELECT b FROM t2 AS B); +END| +DELIMITER ;| +--error ER_BAD_FIELD_ERROR +CALL p1; +--error ER_BAD_FIELD_ERROR +CALL p1; +DROP PROCEDURE p1; +DROP TABLE t1, t2; + + +--echo # ------------------------------------------------------------------ +--echo # -- End of 5.1 tests +--echo # ------------------------------------------------------------------ diff --git a/mysql-test/t/sp_gis.test b/mysql-test/t/sp_gis.test new file mode 100644 index 00000000000..51ed78b27d5 --- /dev/null +++ b/mysql-test/t/sp_gis.test @@ -0,0 +1,39 @@ +-- source include/have_geometry.inc + +use test; + +# +# BUG#21025: misleading error message when creating functions named 'x', or 'y' +# + +--disable_warnings +drop function if exists a; +drop function if exists x; +drop function if exists y; +--enable_warnings + +create function a() returns int +return 1; + +create function x() returns int +return 2; + +create function y() returns int +return 3; + +select a(); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select x(); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select y(); +select x(PointFromText("POINT(10 20)")), y(PointFromText("POINT(10 20)")); + +# Non deterministic warnings from db_load_routine +--disable_warnings +select test.a(), test.x(), test.y(); +--enable_warnings + +drop function a; +drop function x; +drop function y; + diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test index d539d4bf8ab..f593e184ad2 100644 --- a/mysql-test/t/sp_notembedded.test +++ b/mysql-test/t/sp_notembedded.test @@ -1,5 +1,8 @@ # Can't test with embedded server -- source include/not_embedded.inc +# Disable concurrent inserts to avoid test failures +set @old_concurrent_insert= @@global.concurrent_insert; +set @@global.concurrent_insert= 0; # Save the initial number of concurrent sessions --source include/count_sessions.inc @@ -11,7 +14,7 @@ delimiter |; # -# Bug#4902: Stored procedure with SHOW WARNINGS leads to packet error +# Bug#4902 Stored procedure with SHOW WARNINGS leads to packet error # # Added tests for show grants command --disable_warnings @@ -42,41 +45,25 @@ create procedure bug4902_2() begin show processlist; end| ---replace_column 1 # 6 # 3 localhost +--disable_result_log call bug4902_2()| ---replace_column 1 # 6 # 3 localhost +--enable_result_log +show warnings| +--disable_result_log call bug4902_2()| +--enable_result_log +show warnings| drop procedure bug4902_2| - -# -# Bug#5278: Stored procedure packets out of order if SET PASSWORD. -# ---disable_warnings -drop function if exists bug5278| ---enable_warnings -create function bug5278 () returns char -begin - SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass'); - return 'okay'; -end| - ---error ER_PASSWORD_NO_MATCH -select bug5278()| ---error ER_PASSWORD_NO_MATCH -select bug5278()| -drop function bug5278| - - # -# Bug#3583: query cache doesn't work for stored procedures +# Bug#3583 query cache doesn't work for stored procedures # --disable_warnings drop table if exists t1| --enable_warnings create table t1 ( - id char(16) not null default '', - data int not null + id char(16) not null default '', + data int not null )| --disable_warnings drop procedure if exists bug3583| @@ -115,7 +102,7 @@ drop table t1| # -# Bug#6807: Stored procedure crash if CREATE PROCEDURE ... KILL QUERY +# Bug#6807 Stored procedure crash if CREATE PROCEDURE ... KILL QUERY # --disable_warnings drop procedure if exists bug6807| @@ -138,7 +125,7 @@ drop procedure bug6807| # -# Bug#10100: function (and stored procedure?) recursivity problem +# Bug#10100 function (and stored procedure?) recursivity problem # --disable_warnings drop function if exists bug10100f| @@ -293,10 +280,84 @@ drop procedure 15298_1; drop procedure 15298_2; # +# Bug#29936 Stored Procedure DML ignores low_priority_updates setting +# + +--disable_warnings +drop table if exists t1; +drop procedure if exists p1; +--enable_warnings + +create table t1 (value varchar(15)); +create procedure p1() update t1 set value='updated' where value='old'; + +# load the procedure into sp cache and execute once +call p1(); + +insert into t1 (value) values ("old"); + +connect (rl_holder, localhost, root,,); +connect (rl_acquirer, localhost, root,,); +connect (rl_contender, localhost, root,,); +connect (rl_wait, localhost, root,,); + +connection rl_holder; +select get_lock('b26162',120); + +connection rl_acquirer; +--send select 'rl_acquirer', value from t1 where get_lock('b26162',120); + +# we must wait till this select opens and locks the tables +connection rl_wait; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "User lock" and + info = "select 'rl_acquirer', value from t1 where get_lock('b26162',120)"; +--source include/wait_condition.inc + +connection default; +set session low_priority_updates=on; +--send call p1(); + +connection rl_wait; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Locked" and + info = "update t1 set value='updated' where value='old'"; +--source include/wait_condition.inc + +connection rl_contender; +select 'rl_contender', value from t1; + +connection rl_holder; +select release_lock('b26162'); + +connection rl_acquirer; +--reap +connection default; +--reap + +disconnect rl_holder; +disconnect rl_acquirer; +disconnect rl_wait; +disconnect rl_contender; +drop procedure p1; +drop table t1; +set session low_priority_updates=default; + +# # Bug#44798 MySQL engine crashes when creating stored procedures with execute_priv=N # -INSERT INTO mysql.user (Host, User, Password, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, Create_user_priv, ssl_type, ssl_cipher, x509_issuer, x509_subject, max_questions, max_updates, max_connections, max_user_connections) -VALUES('%', 'mysqltest_1', password(''), 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'N', '', '', '', '', '0', '0', '0', '0'); +INSERT INTO mysql.user (Host, User, Password, Select_priv, Insert_priv, Update_priv, +Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, +Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, +Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, +Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, +Create_user_priv, ssl_type, ssl_cipher, x509_issuer, x509_subject, max_questions, +max_updates, max_connections, max_user_connections) +VALUES('%', 'mysqltest_1', password(''), 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', +'N', 'N', 'N', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'N', '', +'', '', '', '0', '0', '0', '0'); FLUSH PRIVILEGES; connect (con1, localhost, mysqltest_1,,); @@ -309,6 +370,49 @@ DROP PROCEDURE p1; DELETE FROM mysql.user WHERE User='mysqltest_1'; FLUSH PRIVILEGES; + +# +# Restore global concurrent_insert value. Keep in the end of the test file. +# + +set @@global.concurrent_insert= @old_concurrent_insert; + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc + +--echo # +--echo # Bug#44521 Prepared Statement: CALL p() - crashes: `! thd->main_da.is_sent' failed et.al. +--echo # +SELECT GET_LOCK('Bug44521', 0); +--connect (con1,localhost,root,,) +--echo ** Connection con1 +delimiter $; +CREATE PROCEDURE p() +BEGIN + SELECT 1; + SELECT GET_LOCK('Bug44521', 100); + SELECT 2; +END$ +delimiter ;$ +--send CALL p(); +--connection default +--echo ** Default connection +let $wait_condition= + SELECT count(*) = 1 FROM information_schema.processlist + WHERE state = "User lock" AND info = "SELECT GET_LOCK('Bug44521', 100)"; +--source include/wait_condition.inc +let $conid = + `SELECT id FROM information_schema.processlist + WHERE state = "User lock" AND info = "SELECT GET_LOCK('Bug44521', 100)"`; +dirty_close con1; +SELECT RELEASE_LOCK('Bug44521'); +let $wait_condition= + SELECT count(*) = 0 FROM information_schema.processlist + WHERE id = $conid; +--source include/wait_condition.inc +DROP PROCEDURE p; + +--echo # ------------------------------------------------------------------ +--echo # -- End of 5.1 tests +--echo # ------------------------------------------------------------------ diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index 60f7e3326b4..0b04b9d7668 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -90,7 +90,7 @@ create function bug10015_5(i int) returns int end if; return i; end| ---error 1062 +--error ER_DUP_ENTRY insert into t1 values (bug10015_5(4)), (bug10015_5(5))| select * from t1| drop function bug10015_5| @@ -553,6 +553,45 @@ drop table t3, t4| drop procedure bug14210| set @@session.max_heap_table_size=default| +# +# BUG#7787: Stored procedures: improper warning for "grant execute" statement +# + +# Prepare. + +CREATE DATABASE db_bug7787| +use db_bug7787| + +# Test. + +CREATE PROCEDURE p1() + SHOW INNODB STATUS; | + +GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost| + +# Cleanup. + +DROP DATABASE db_bug7787| +drop user user_bug7787@localhost| +use test| + +# +# Bug#13575 SP funcs in select with distinct/group and order by can +# produce bad data +# +create table t3 (f1 int, f2 varchar(3), primary key(f1)) engine=innodb| +insert into t3 values (1,'aaa'),(2,'bbb'),(3,'ccc')| +CREATE FUNCTION bug13575 ( p1 integer ) +returns varchar(3) +BEGIN +DECLARE v1 VARCHAR(10) DEFAULT null; +SELECT f2 INTO v1 FROM t3 WHERE f1 = p1; +RETURN v1; +END| +select distinct f1, bug13575(f1) from t3 order by f1| +drop function bug13575| +drop table t3| + # # BUG#NNNN: New bug synopsis diff --git a/mysql-test/t/sp_trans_log.test b/mysql-test/t/sp_trans_log.test index effa3ca80cf..2f2b84a9bef 100644 --- a/mysql-test/t/sp_trans_log.test +++ b/mysql-test/t/sp_trans_log.test @@ -1,5 +1,9 @@ --- source include/have_innodb.inc --- source include/have_log_bin.inc +# binlog disabled in embedded server +-- source include/not_embedded.inc + +# part of sp_trans test that appeared to be sensitive to binlog format +--source include/have_innodb.inc +--source include/have_binlog_format_mixed_or_row.inc delimiter |; @@ -31,7 +35,7 @@ reset master| --error ER_DUP_ENTRY insert into t2 values (bug23333(),1)| --replace_column 2 # 5 # 6 # -show binlog events from 98 /* with fixes for #23333 will show there are 2 queries */| +show binlog events from 106 /* with fixes for #23333 will show there is the query */| select count(*),@a from t1 /* must be 1,1 */| delimiter ;| diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test index 2699cb66471..4a9f34443cb 100644 --- a/mysql-test/t/sql_mode.test +++ b/mysql-test/t/sql_mode.test @@ -209,18 +209,18 @@ SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b"; # is not available # -set session sql_mode = 'NO_ENGINE_SUBSTITUTION'; ---error 1289 -create table t1 (a int) engine=isam; ---error 1146 -show create table t1; -drop table if exists t1; - -# for comparison, lets see the warnings... -set session sql_mode = ''; -create table t1 (a int) engine=isam; -show create table t1; -drop table t1; +#set session sql_mode = 'NO_ENGINE_SUBSTITUTION'; +#--error 1289 +#create table t1 (a int) engine=isam; +#--error 1146 +#show create table t1; +#drop table if exists t1; +# +## for comparison, lets see the warnings... +#set session sql_mode = ''; +#create table t1 (a int) engine=isam; +#show create table t1; +#drop table t1; # # Bug #6903: ANSI_QUOTES does not come into play with SHOW CREATE FUNCTION @@ -264,7 +264,83 @@ select @@sql_mode; set sql_mode=16384+(65536*4); select @@sql_mode; --error 1231 -set sql_mode=2147483648; # that mode does not exist +set sql_mode=2147483648*2; # that mode does not exist select @@sql_mode; +# +# Test WL921: Retain spaces when retrieving CHAR column values + +set sql_mode=PAD_CHAR_TO_FULL_LENGTH; +create table t1 (a int auto_increment primary key, b char(5)); +insert into t1 (b) values('a'),('b\t'),('c '); +select concat('x',b,'x') from t1; +set sql_mode=0; +select concat('x',b,'x') from t1; +drop table t1; + SET @@SQL_MODE=@OLD_SQL_MODE; + + +# +# Bug #32753: PAD_CHAR_TO_FULL_LENGTH is not documented and interferes +# with grant tables +# + +create user mysqltest_32753@localhost; + +# try to make the user-table space-padded +--connection default +set @OLD_SQL_MODE=@@SESSION.SQL_MODE; +set session sql_mode='PAD_CHAR_TO_FULL_LENGTH'; +flush privileges; + +# if user-table is affected by PAD_CHAR_TO_FULL_LENGTH, our connect will fail +# --error 1045 +connect (user_32753,localhost,mysqltest_32753,,test,$MASTER_MYPORT,$MASTER_MYSOCK); +select current_user(); + +# clean up +--connection default +set session sql_mode=@OLD_SQL_MODE; +flush privileges; + +--disconnect user_32753 + +--connection default +drop user mysqltest_32753@localhost; + +# +# Bug#45100: Incomplete DROP USER in case of SQL_MODE = 'PAD_CHAR_TO_FULL_LENGTH' +# + +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings + +# Generate some prerequisites +CREATE USER 'user_PCTFL'@'localhost' identified by 'PWD'; +CREATE USER 'user_no_PCTFL'@'localhost' identified by 'PWD'; + +CREATE TABLE t1 (f1 BIGINT); +CREATE TABLE t2 (f1 CHAR(3) NOT NULL, f2 CHAR(20)); + +# Grant privilege on a TABLE +GRANT ALL ON t1 TO 'user_PCTFL'@'localhost','user_no_PCTFL'@'localhost'; +# Grant privilege on some COLUMN of a table +GRANT SELECT(f1) ON t2 TO 'user_PCTFL'@'localhost','user_no_PCTFL'@'localhost'; + +SET @OLD_SQL_MODE = @@SESSION.SQL_MODE; +SET SESSION SQL_MODE = 'PAD_CHAR_TO_FULL_LENGTH'; +DROP USER 'user_PCTFL'@'localhost'; +SET SESSION SQL_MODE = @OLD_SQL_MODE; +DROP USER 'user_no_PCTFL'@'localhost'; + +FLUSH PRIVILEGES; + +SELECT * FROM mysql.db WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL'; +SELECT * FROM mysql.tables_priv WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL'; +SELECT * FROM mysql.columns_priv WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL'; + +# Cleanup +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/t/status-master.opt b/mysql-test/t/status-master.opt new file mode 100644 index 00000000000..eb3bb4fe50d --- /dev/null +++ b/mysql-test/t/status-master.opt @@ -0,0 +1 @@ +--log-output=table,file diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test index 3e4d4eb7ffe..5da210f5a69 100644 --- a/mysql-test/t/status.test +++ b/mysql-test/t/status.test @@ -1,9 +1,23 @@ +# This test requires that --log-output includes 'table', and the general +# log is on + # embedded server causes different stat -- source include/not_embedded.inc # Save the initial number of concurrent sessions --source include/count_sessions.inc +# Disable concurrent inserts to avoid sporadic test failures as it might +# affect the the value of variables used throughout the test case. +set @old_concurrent_insert= @@global.concurrent_insert; +set @@global.concurrent_insert= 0; + +# Disable logging to table, since this will also cause table locking and unlocking, which will +# show up in SHOW STATUS and may cause sporadic failures + +SET @old_log_output = @@global.log_output; +SET GLOBAL LOG_OUTPUT = 'FILE'; + # PS causes different statistics --disable_ps_protocol @@ -11,33 +25,54 @@ connect (con1,localhost,root,,); connect (con2,localhost,root,,); flush status; + show status like 'Table_lock%'; +select * from information_schema.session_status where variable_name like 'Table_lock%'; + connection con1; -SET SQL_LOG_BIN=0; +--echo # Switched to connection: con1 +set sql_log_bin=0; +set @old_general_log = @@global.general_log; +set global general_log = 'OFF'; --disable_warnings drop table if exists t1; --enable_warnings create table t1(n int) engine=myisam; insert into t1 values(1); +# Execute dummy select in order to ensure that tables used in the +# previous statement are unlocked and closed. +select 1; + connection con2; +--echo # Switched to connection: con2 lock tables t1 read; unlock tables; lock tables t1 read; + connection con1; ---send -update t1 set n = 3; +--echo # Switched to connection: con1 +let $ID= `select connection_id()`; +--send update t1 set n = 3 + connection con2; -sleep 1; +--echo # Switched to connection: con2 +# wait for the other query to start executing +let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST where ID = $ID and STATE = "Locked"; +--source include/wait_condition.inc unlock tables; + connection con1; +--echo # Switched to connection: con1 reap; -show status like 'Table_lock%'; +show status like 'Table_locks_waited'; drop table t1; +set global general_log = @old_general_log; disconnect con2; disconnect con1; connection default; +--echo # Switched to connection: default # End of 4.1 tests @@ -47,9 +82,22 @@ connection default; select 1; show status like 'last_query_cost'; +create table t1 (a int); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +select * from t1 where a=6; +show status like 'last_query_cost'; +# Ensure value dosn't change by second status call +show status like 'last_query_cost'; +select 1; +show status like 'last_query_cost'; +drop table t1; # -# Test for Bug #15933 max_used_connections is wrong after FLUSH STATUS +# Test for Bug#15933 max_used_connections is wrong after FLUSH STATUS # if connections are cached # # @@ -88,6 +136,7 @@ while ($wait_more) # Prerequisite. SHOW STATUS LIKE 'max_used_connections'; +SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; # Save original setting. SET @save_thread_cache_size=@@thread_cache_size; @@ -101,6 +150,7 @@ disconnect con2; # Check that max_used_connections still reflects maximum value. SHOW STATUS LIKE 'max_used_connections'; +SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; # Check that after flush max_used_connections equals to current number # of connections. First wait for previous disconnect to finish. @@ -124,15 +174,18 @@ while ($wait_more) --enable_result_log # Check that we don't count disconnected thread any longer. SHOW STATUS LIKE 'max_used_connections'; +SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; # Check that max_used_connections is updated when cached thread is # reused... connect (con2,localhost,root,,); SHOW STATUS LIKE 'max_used_connections'; +SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; # ...and when new thread is created. connect (con3,localhost,root,,); SHOW STATUS LIKE 'max_used_connections'; +SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; # Restore original setting. connection default; @@ -144,7 +197,7 @@ disconnect con1; # -# Bug #30377: EXPLAIN loses last_query_cost when used with UNION +# Bug#30377 EXPLAIN loses last_query_cost when used with UNION # CREATE TABLE t1 ( a INT ); @@ -174,6 +227,94 @@ SHOW SESSION STATUS LIKE 'Last_query_cost'; DROP TABLE t1; +# End of 5.0 tests + +# +# Ensure that SHOW STATUS only changes global status variables +# + +connect (con1,localhost,root,,); +let $rnd_next = `show global status like 'handler_read_rnd_next'`; +let $tmp_table = `show global status like 'Created_tmp_tables'`; +show status like 'com_show_status'; +show status like 'hand%write%'; +show status like '%tmp%'; +show status like 'hand%write%'; +show status like '%tmp%'; +show status like 'com_show_status'; +let $rnd_next2 = `show global status like 'handler_read_rnd_next'`; +let $tmp_table2 = `show global status like 'Created_tmp_tables'`; +--disable_query_log +eval select substring_index('$rnd_next2',0x9,-1)-substring_index('$rnd_next',0x9,-1) as rnd_diff, substring_index('$tmp_table2',0x9,-1)-substring_index('$tmp_table',0x9,-1) as tmp_table_diff; +--enable_query_log +disconnect con1; +connection default; + +# +# Bug#30252 Com_create_function is not incremented. +# +flush status; +show status like 'Com%function'; + +DELIMITER //; +create function f1 (x INTEGER) returns integer + begin + declare ret integer; + set ret = x * 10; + return ret; + end // +DELIMITER ;// + +drop function f1; + +show status like 'Com%function'; + +# +# Bug#37908 Skipped access right check caused server crash. +# +connect (root, localhost, root,,test); +connection root; +let $root_connection_id= `select connection_id()`; +--disable_warnings +create database db37908; +--enable_warnings +create table db37908.t1(f1 int); +insert into db37908.t1 values(1); +grant usage,execute on test.* to mysqltest_1@localhost; +delimiter |; +create procedure proc37908() begin select 1; end | +create function func37908() returns int sql security invoker + return (select * from db37908.t1 limit 1)| +delimiter ;| + +connect (user1,localhost,mysqltest_1,,test); +connection user1; +let $user1_connection_id= `select connection_id()`; + +--error ER_TABLEACCESS_DENIED_ERROR +select * from db37908.t1; +--error ER_TABLEACCESS_DENIED_ERROR +show status where variable_name ='uptime' and 2 in (select * from db37908.t1); +--error ER_TABLEACCESS_DENIED_ERROR +show procedure status where name ='proc37908' and 1 in (select f1 from db37908.t1); +--error ER_TABLEACCESS_DENIED_ERROR +show function status where name ='func37908' and 1 in (select func37908()); + +connection default; +disconnect user1; +disconnect root; +drop database db37908; +drop procedure proc37908; +drop function func37908; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +DROP USER mysqltest_1@localhost; +# Wait till the sessions user1 and root are disconnected +let $wait_condition = + SELECT COUNT(*) = 0 + FROM information_schema.processlist + WHERE id in ('$root_connection_id','$user1_connection_id'); +--source include/wait_condition.inc + # # Bug#41131 "Questions" fails to increment - ignores statements instead stored procs # @@ -201,17 +342,22 @@ let $org_queries= `SHOW STATUS LIKE 'Queries'`; SELECT f1(); CALL p1(); let $new_queries= `SHOW STATUS LIKE 'Queries'`; ---disable_log +--disable_query_log let $diff= `SELECT SUBSTRING('$new_queries',9)-SUBSTRING('$org_queries',9)`; ---enable_log +--enable_query_log eval SELECT $diff; disconnect con1; connection default; DROP PROCEDURE p1; DROP FUNCTION f1; -# End of 5.0 tests +# End of 5.1 tests + +# Restore global concurrent_insert value. Keep in the end of the test file. +--connection default +set @@global.concurrent_insert= @old_concurrent_insert; +SET GLOBAL log_output = @old_log_output; -# Wait till all disconnects are completed +# Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/status2.test b/mysql-test/t/status2.test index 058a2fa1d25..2d1541c54f2 100644 --- a/mysql-test/t/status2.test +++ b/mysql-test/t/status2.test @@ -1,20 +1,11 @@ +--source include/not_embedded.inc + --echo # --echo # Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines --echo # -# The bogus connection below is needed to make the gobal statement count -# deterministic when the test is run for the first time. -connect (con1,localhost,root,,); -connection con1; -connection default; -disconnect con1; FLUSH STATUS; ---disable_warnings -DROP TABLE IF EXISTS t1,t2; -DROP PROCEDURE IF EXISTS p1; -DROP FUNCTION IF EXISTS f1; ---enable_warnings DELIMITER $$; -CREATE FUNCTION f1() RETURNS INTEGER +CREATE FUNCTION testQuestion() RETURNS INTEGER BEGIN DECLARE foo INTEGER; DECLARE bar INTEGER; @@ -22,43 +13,56 @@ BEGIN SET bar=2; RETURN foo; END $$ -CREATE PROCEDURE p1() +CREATE PROCEDURE testQuestion2() BEGIN SELECT 1; END $$ DELIMITER ;$$ +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings CREATE TABLE t1 (c1 INT); CREATE TABLE t2 (c1 INT); -INSERT INTO t1 VALUES (1); +CREATE EVENT ev1 ON SCHEDULE EVERY 1 SECOND + DO INSERT INTO t1 VALUES(1); + +--echo Assert Questions == 7 +SHOW STATUS LIKE 'Questions'; +SELECT testQuestion(); --echo Assert Questions == 9 SHOW STATUS LIKE 'Questions'; -SELECT f1(); +CALL testQuestion2(); --echo Assert Questions == 11 SHOW STATUS LIKE 'Questions'; -CALL p1(); ---echo Assert Questions == 13 -SHOW STATUS LIKE 'Questions'; SELECT 1; ---echo Assert Questions == 15 +--echo Assert Questions == 13 SHOW STATUS LIKE 'Questions'; connect (con1,localhost,root,,); connection con1; -FLUSH STATUS; -let $org_questions= `SHOW GLOBAL STATUS LIKE 'questions'`; SELECT 1; connection default; +disconnect con1; +--echo Assert Questions == 14 +SHOW STATUS LIKE 'Questions'; +DELIMITER $$; +CREATE TRIGGER trigg1 AFTER INSERT ON t1 + FOR EACH ROW BEGIN + INSERT INTO t2 VALUES (1); + END; +$$ +DELIMITER ;$$ --echo Assert Questions == 16 SHOW STATUS LIKE 'Questions'; ---echo Global status updated; Assert diff == 4 -FLUSH STATUS; -let $new_questions= `SHOW GLOBAL STATUS LIKE 'questions'`; ---disable_log -let $diff= `SELECT SUBSTRING('$new_questions',10)-SUBSTRING('$org_questions',10)`; ---enable_log -eval SELECT $diff; -disconnect con1; +INSERT INTO t1 VALUES (1); +--echo Assert Questions == 18 +SHOW STATUS LIKE 'Questions'; +# TODO: Uncomment the lines below when FLUSH GLOBAL STATUS is implemented. +# FLUSH STATUS; +# SHOW GLOBAL STATUS LIKE 'Questions'; +DROP PROCEDURE testQuestion2; +DROP TRIGGER trigg1; +DROP FUNCTION testQuestion; +DROP EVENT ev1; DROP TABLE t1,t2; -DROP PROCEDURE p1; -DROP FUNCTION f1; --echo End of 6.0 tests diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index f66c2913ac9..5779ea97bc2 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -822,7 +822,6 @@ INSERT INTO t1 (col2) VALUES (-1.1E-3); INSERT INTO t1 (col1) VALUES ('+1.8E+309'); --error 1264 INSERT INTO t1 (col2) VALUES ('-1.2E-3'); ---error 1264 UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0; --error 1365 UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0; @@ -1164,11 +1163,11 @@ set @@sql_mode= @org_mode; # Bug #13934 Silent truncation of table comments # set @@sql_mode='traditional'; ---error 1105 +--error ER_TOO_LONG_TABLE_COMMENT create table t1 (i int) comment '123456789*123456789*123456789*123456789*123456789* 123456789*123456789*123456789*123456789*123456789*'; ---error 1105 +--error ER_TOO_LONG_FIELD_COMMENT create table t1 ( i int comment '123456789*123456789*123456789*123456789* diff --git a/mysql-test/t/strict_autoinc_4bdb.test b/mysql-test/t/strict_autoinc_4bdb.test deleted file mode 100644 index 10d6bfd41e7..00000000000 --- a/mysql-test/t/strict_autoinc_4bdb.test +++ /dev/null @@ -1,10 +0,0 @@ --- source include/have_bdb.inc - -# -# Bug#20573 Strict mode auto-increment -# - -let $type= 'BDB' ; ---source include/strict_autoinc.inc - -# end of test diff --git a/mysql-test/t/strict_autoinc_5ndb.test b/mysql-test/t/strict_autoinc_5ndb.test deleted file mode 100644 index 9e2090fddef..00000000000 --- a/mysql-test/t/strict_autoinc_5ndb.test +++ /dev/null @@ -1,10 +0,0 @@ --- source include/have_ndb.inc - -# -# Bug#20573 Strict mode auto-increment -# - -let $type= 'NDB' ; ---source include/strict_autoinc.inc - -# end of test diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 79918ca78a2..544017ebb97 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1042,13 +1042,14 @@ DROP TABLE t1; create table t1 (a int, b decimal(13, 3)); insert into t1 values (1, 0.123); -let $outfile = $MYSQLTEST_VARDIR/master-data/test/subselect.out.file.1; +let $outfile_abs= $MYSQLTEST_VARDIR/tmp/subselect.out.file.1; +let $outfile_rel= ../../tmp/subselect.out.file.1; --error 0,1 ---remove_file $outfile -select a, (select max(b) from t1) into outfile "subselect.out.file.1" from t1; +--remove_file $outfile_abs +eval select a, (select max(b) from t1) into outfile "$outfile_rel" from t1; delete from t1; -load data infile "subselect.out.file.1" into table t1; ---remove_file $outfile +eval load data infile "$outfile_rel" into table t1; +--remove_file $outfile_abs select * from t1; drop table t1; @@ -3073,54 +3074,6 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a!=0) FROM t1; SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=1) FROM t1; DROP TABLE t1,t2; - -# -# Bug31048 Many nested subqueries may cause server crash. -# -create table t1(a int,b int,key(a),key(b)); -insert into t1(a,b) values (1,2),(2,1),(2,3),(3,4),(5,4),(5,5), - (6,7),(7,4),(5,3); - -let $nesting= 26; -let $should_work_nesting= 5; -let $start= select sum(a),a from t1 where a> ( select sum(a) from t1 ; -let $end= )group by a ; -let $start_app= where a> ( select sum(a) from t1 ; -let $end_pre= )group by b limit 1 ; - ---disable_result_log ---disable_query_log -# At least 4 level nesting should work without errors -while ($should_work_nesting) -{ ---echo $should_work_nesting - eval $start $end; - eval explain $start $end; - let $start= $start - $start_app; - let $end= $end_pre - $end; - dec $should_work_nesting; -} -# Other may fail with the 'stack overrun error' -while ($nesting) -{ ---echo $nesting ---error 0,ER_STACK_OVERRUN_NEED_MORE - eval $start $end; ---error 0,ER_STACK_OVERRUN_NEED_MORE - eval explain $start $end; - let $start= $start - $start_app; - let $end= $end_pre - $end; - dec $nesting; -} ---enable_result_log ---enable_query_log -drop table t1; - - # # Bug#31884 Assertion + crash in subquery in the SELECT clause. # @@ -3362,72 +3315,6 @@ EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 GROUP BY a); EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a); DROP TABLE t1; - -# -# Bug#38191 Server crash with subquery containing DISTINCT and ORDER BY -# - -CREATE TABLE t1(pk int PRIMARY KEY, a int, INDEX idx(a)); -INSERT INTO t1 VALUES (1, 10), (3, 30), (2, 20); -CREATE TABLE t2(pk int PRIMARY KEY, a int, b int, INDEX idxa(a)); -INSERT INTO t2 VALUES (2, 20, 700), (1, 10, 200), (4, 10, 100); -SELECT * FROM t1 - WHERE EXISTS (SELECT DISTINCT a FROM t2 WHERE t1.a < t2.a ORDER BY b); -DROP TABLE t1,t2; - -# -# Bug#20835 (literal string with =any values) -# -CREATE TABLE t1 (s1 char(1)); -INSERT INTO t1 VALUES ('a'); -SELECT * FROM t1 WHERE _utf8'a' = ANY (SELECT s1 FROM t1); -DROP TABLE t1; - -# -# Bug#40519 Subselect query using bigint fails -# -CREATE TABLE t1(id BIGINT); -CREATE TABLE t2(id1 BIGINT, id2 BIGINT); -INSERT INTO t1 VALUES (1),(2),(3); -INSERT INTO t2 VALUES (2,1),(3,1); -SELECT * FROM t1 i WHERE 1 IN (SELECT l.id2 FROM t2 l WHERE i.id=l.id1); -DROP TABLE t1, t2; - -# -# Bug#37460 Assertion failed: -# !table->file || table->file->inited == handler::NONE -# -CREATE TABLE t1 (id int); -CREATE TABLE t2 (id int, c int); - -INSERT INTO t1 (id) VALUES (1); -INSERT INTO t2 (id) VALUES (1); -INSERT INTO t1 (id) VALUES (1); -INSERT INTO t2 (id) VALUES (1); - -CREATE VIEW v1 AS - SELECT t2.c AS c FROM t1, t2 - WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION; -UPDATE v1 SET c=1; - -CREATE VIEW v2 (a,b) AS - SELECT t2.id, t2.c AS c FROM t1, t2 - WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION; - ---error ER_VIEW_CHECK_FAILED -INSERT INTO v2(a,b) VALUES (2,2); -INSERT INTO v2(a,b) VALUES (1,2); -SELECT * FROM v1; - -CREATE VIEW v3 AS - SELECT t2.c AS c FROM t2 - WHERE 1 IN (SELECT id FROM t1) WITH CHECK OPTION; - -DELETE FROM v3; - -DROP VIEW v1,v2,v3; -DROP TABLE t1,t2; - --echo # --echo # Bug#45061: Incorrectly market field caused wrong result. --echo # @@ -3482,3 +3369,179 @@ WHERE a = 230; DROP TABLE t1, st1, st2; --echo End of 5.0 tests. + +# +# Bug#27348 SET FUNCTION used in a subquery from WHERE condition +# + +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (2,22),(1,11),(2,22); + +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a; +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a; + +SELECT a FROM t1 t0 + WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a; + +SET @@sql_mode='ansi'; +--error ER_INVALID_GROUP_FUNC_USE +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a; +--error ER_INVALID_GROUP_FUNC_USE +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a; + +--error ER_INVALID_GROUP_FUNC_USE +SELECT a FROM t1 t0 + WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a; + +SET @@sql_mode=default; +DROP TABLE t1; + +# +# Bug#20835 (literal string with =any values) +# +CREATE TABLE t1 (s1 CHAR(1)); +INSERT INTO t1 VALUES ('a'); +SELECT * FROM t1 WHERE _utf8'a' = ANY (SELECT s1 FROM t1); +DROP TABLE t1; + +# +# Bug#37004 NOT IN subquery with MAX over an empty set +# + +CREATE TABLE t1(c INT, KEY(c)); +CREATE TABLE t2(a INT, b INT); +INSERT INTO t2 VALUES (1, 10), (2, NULL); +INSERT INTO t1 VALUES (1), (3); + +SELECT * FROM t2 WHERE b NOT IN (SELECT max(t.c) FROM t1, t1 t WHERE t.c>10); + +DROP TABLE t1,t2; + +# +# Bug#38191 Server crash with subquery containing DISTINCT and ORDER BY +# + +CREATE TABLE t1(pk INT PRIMARY KEY, a INT, INDEX idx(a)); +INSERT INTO t1 VALUES (1, 10), (3, 30), (2, 20); +CREATE TABLE t2(pk INT PRIMARY KEY, a INT, b INT, INDEX idxa(a)); +INSERT INTO t2 VALUES (2, 20, 700), (1, 10, 200), (4, 10, 100); +SELECT * FROM t1 + WHERE EXISTS (SELECT DISTINCT a FROM t2 WHERE t1.a < t2.a ORDER BY b); +DROP TABLE t1,t2; + +# +# Bug#37548 result value erronously reported being NULL in certain subqueries +# + +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), KEY b (b)); + +INSERT INTO t1 VALUES (1,NULL), (9,NULL); + +CREATE TABLE t2 ( + a INT, + b INT, + c INT, + d INT, + PRIMARY KEY (a), + UNIQUE KEY b (b,c,d), + KEY b_2 (b), + KEY c (c), + KEY d (d) +); + +INSERT INTO t2 VALUES + (43, 2, 11 ,30), + (44, 2, 12 ,30), + (45, 1, 1 ,10000), + (46, 1, 2 ,10000), + (556,1, 32 ,10000); + +CREATE TABLE t3 ( + a INT, + b INT, + c INT, + PRIMARY KEY (a), + UNIQUE KEY b (b,c), + KEY c (c), + KEY b_2 (b) +); + +INSERT INTO t3 VALUES (1,1,1), (2,32,1); + +explain +SELECT t1.a, (SELECT 1 FROM t2 WHERE t2.b=t3.c AND t2.c=t1.a ORDER BY t2.d LIMIT 1) AS incorrect FROM t1, t3 WHERE t3.b=t1.a; +SELECT t1.a, (SELECT 1 FROM t2 WHERE t2.b=t3.c AND t2.c=t1.a ORDER BY t2.d LIMIT 1) AS incorrect FROM t1, t3 WHERE t3.b=t1.a; + +DROP TABLE t1,t2,t3; + +# +# Bug#37460 Assertion failed: +# !table->file || table->file->inited == handler::NONE +# +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int, c int); + +INSERT INTO t1 (id) VALUES (1); +INSERT INTO t2 (id) VALUES (1); +INSERT INTO t1 (id) VALUES (1); +INSERT INTO t2 (id) VALUES (1); + +CREATE VIEW v1 AS +SELECT t2.c AS c FROM t1, t2 +WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION; +UPDATE v1 SET c=1; + +CREATE VIEW v2 (a,b) AS +SELECT t2.id, t2.c AS c FROM t1, t2 +WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION; + +--error ER_VIEW_CHECK_FAILED +INSERT INTO v2(a,b) VALUES (2,2); +INSERT INTO v2(a,b) VALUES (1,2); +SELECT * FROM v1; + +CREATE VIEW v3 AS +SELECT t2.c AS c FROM t2 +WHERE 1 IN (SELECT id FROM t1) WITH CHECK OPTION; + +DELETE FROM v3; + +DROP VIEW v1,v2,v3; +DROP TABLE t1,t2; + +--echo # +--echo # Bug#37822 Correlated subquery with IN and IS UNKNOWN provides wrong result +--echo # +create table t1(id integer primary key, g integer, v integer, s char(1)); +create table t2(id integer primary key, g integer, v integer, s char(1)); +insert into t1 values + (10, 10, 10, 'l'), + (20, 20, 20, 'l'), + (40, 40, 40, 'l'), + (41, 40, null, 'l'), + (50, 50, 50, 'l'), + (51, 50, null, 'l'), + (60, 60, 60, 'l'), + (61, 60, null, 'l'), + (70, 70, 70, 'l'), + (90, 90, null, 'l'); +insert into t2 values + (10, 10, 10, 'r'), + (30, 30, 30, 'r'), + (50, 50, 50, 'r'), + (60, 60, 60, 'r'), + (61, 60, null, 'r'), + (70, 70, 70, 'r'), + (71, 70, null, 'r'), + (80, 80, 80, 'r'), + (81, 80, null, 'r'), + (100,100,null, 'r'); + +select * +from t1 +where v in(select v + from t2 + where t1.g=t2.g) is unknown; +drop table t1, t2; + +--echo End of 5.1 tests. diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test index 6f08ebef86d..7a2a9f328ef 100644 --- a/mysql-test/t/subselect3.test +++ b/mysql-test/t/subselect3.test @@ -1,5 +1,5 @@ --disable_warnings -drop table if exists t0, t1, t2, t3, t4; +drop table if exists t0, t1, t2, t3, t4, t5; --enable_warnings # @@ -689,3 +689,42 @@ DROP TABLE t1; --echo End of 5.0 tests + +# +# BUG#36135 "void Diagnostics_area::set_eof_status(THD*): Assertion `!is_set()' failed." +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 ( + a int(11) default null, + b int(11) default null, + key (a) +); +# produce numbers 0..999 +insert into t1 select A.a+10*(B.a+10*C.a),A.a+10*(B.a+10*C.a) from t0 A, t0 B, t0 C; + +create table t2 (a int(11) default null); +insert into t2 values (0),(1); + +create table t3 (a int(11) default null); +insert into t3 values (0),(1); + +create table t4 (a int(11) default null); +insert into t4 values (0),(1); + +create table t5 (a int(11) default null); +insert into t5 values (0),(1),(0),(1); + +# this must not fail assertion +--error 1242 +select * from t2, t3 +where + t2.a < 10 and + t3.a+1 = 2 and + t3.a in (select t1.b from t1 + where t1.a+1=t1.a+1 and + t1.a < (select t4.a+10 + from t4, t5 limit 2)); + +drop table t0, t1, t2, t3, t4, t5; diff --git a/mysql-test/t/subselect_debug.test b/mysql-test/t/subselect_debug.test new file mode 100644 index 00000000000..358705da4f2 --- /dev/null +++ b/mysql-test/t/subselect_debug.test @@ -0,0 +1,16 @@ +--source include/have_debug.inc + +# +# Bug #37627: Killing query with sum(exists()) or avg(exists()) reproducibly +# crashes server +# + +CREATE TABLE t1(id INT); +INSERT INTO t1 VALUES (1),(2),(3),(4); +INSERT INTO t1 SELECT a.id FROM t1 a,t1 b,t1 c,t1 d; +# Setup the mysqld to crash at certain point +SET SESSION debug="d,subselect_exec_fail"; +SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1; +SELECT REVERSE(EXISTS(SELECT RAND() FROM t1)); +SET SESSION debug=DEFAULT; +DROP TABLE t1; diff --git a/mysql-test/t/subselect_notembedded.test b/mysql-test/t/subselect_notembedded.test index c112272e8ad..2f1cc261f56 100644 --- a/mysql-test/t/subselect_notembedded.test +++ b/mysql-test/t/subselect_notembedded.test @@ -7,3 +7,51 @@ --error 1064 purge master logs before (select adddate(current_timestamp(), interval -4 day)); purge master logs before adddate(current_timestamp(), interval -4 day); + +# +# Bug31048: Many nested subqueries may cause server crash. +# +create table t1(a int,b int,key(a),key(b)); +insert into t1(a,b) values (1,2),(2,1),(2,3),(3,4),(5,4),(5,5), + (6,7),(7,4),(5,3); + +let $nesting= 26; +let $should_work_nesting= 5; +let $start= select sum(a),a from t1 where a> ( select sum(a) from t1 ; +let $end= )group by a ; +let $start_app= where a> ( select sum(a) from t1 ; +let $end_pre= )group by b limit 1 ; + +--disable_result_log +--disable_query_log +# At least 4 level nesting should work without errors +while ($should_work_nesting) +{ +--echo $should_work_nesting + eval $start $end; + eval explain $start $end; + let $start= $start + $start_app; + let $end= $end_pre + $end; + dec $should_work_nesting; +} +# Other may fail with the 'stack overrun error' +while ($nesting) +{ +--echo $nesting +--error 0,1436 + eval $start $end; +--error 0,1436 + eval explain $start $end; + let $start= $start + $start_app; + let $end= $end_pre + $end; + dec $nesting; +} +--enable_result_log +--enable_query_log +drop table t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index af1867b5b66..c805dd40fe8 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -1,8 +1,4 @@ --- require r/have_symlink.require -disable_query_log; -show variables like "have_symlink"; -enable_query_log; - +--source include/have_symlink.inc --source include/not_windows.inc --disable_warnings @@ -42,9 +38,8 @@ drop table t2; # We use t9 here to not crash with tables generated by the backup test # -disable_query_log; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval create table t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp" index directory="$MYSQLTEST_VARDIR/run"; -enable_query_log; insert into t9 select * from t1; check table t9; @@ -70,7 +65,6 @@ drop table t1; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR SHOW CREATE TABLE t9; -disable_query_log; # Check that we cannot link over a table from another database. @@ -80,17 +74,18 @@ create database mysqltest; create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="/this-dir-does-not-exist"; # temporarily disabled as it returns different result in the embedded server -# --error ER_WRONG_ARGUMENTS,ER_WRONG_ARGUMENTS +# --error ER_WRONG_ARGUMENTS, ER_WRONG_ARGUMENTS # create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="not-hard-path"; # Should fail becasue the file t9.MYI already exist in 'run' ---error 1,1,1105 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--error 1,1,ER_UNKNOWN_ERROR eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="$MYSQLTEST_VARDIR/run"; # Should fail becasue the file t9.MYD already exist in 'tmp' +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --error 1,1 eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp"; -enable_query_log; # Check moving table t9 from default database to mysqltest; # In this case the symlinks should be removed. @@ -106,20 +101,17 @@ drop database mysqltest; # create table t1 (a int not null) engine=myisam; -disable_query_log; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval alter table t1 data directory="$MYSQLTEST_VARDIR/tmp"; -enable_query_log; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show create table t1; alter table t1 add b int; -disable_query_log; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval alter table t1 data directory="$MYSQLTEST_VARDIR/log"; -enable_query_log; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show create table t1; -disable_query_log; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval alter table t1 index directory="$MYSQLTEST_VARDIR/log"; -enable_query_log; show create table t1; drop table t1; @@ -128,8 +120,9 @@ drop table t1; # --write_file $MYSQLTEST_VARDIR/tmp/t1.MYI EOF ---replace_result $MYSQLTEST_VARDIR TEST_DIR ---error 1 + +--replace_result $MYSQLTEST_VARDIR TEST_DIR $MYSQLTEST_VARDIR TEST_DIR +--error 1,1 eval CREATE TABLE t1(a INT) DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp' INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp'; @@ -150,18 +143,16 @@ connect (session1,localhost,root,,); connect (session2,localhost,root,,); connection session1; -disable_query_log; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 9 a; -enable_query_log; # If running test suite with a non standard tmp dir, the "show create table" # will print "DATA_DIRECTORY=". Use replace_result to mask it out --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show create table t1; connection session2; -disable_query_log; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 99 a; -enable_query_log; # If running test suite with a non standard tmp dir, the "show create table" # will print "DATA_DIRECTORY=". Use replace_result to mask it out --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR @@ -180,67 +171,82 @@ connection default; select * from t1; drop table t1; -# -# CREATE TABLE with DATA DIRECTORY option -# -# Protect ourselves from data left in tmp/ by a previos possibly failed -# test ---error 0,1 ---remove_file $MYSQLTEST_VARDIR/tmp/t1.frm ---error 0,1 ---remove_file $MYSQLTEST_VARDIR/tmp/t1.MYD ---error 0,1 ---remove_file $MYSQLTEST_VARDIR/tmp/t1.MYI ---disable_query_log -eval prepare stmt from "create table t1 (c char(10)) data directory='$MYSQLTEST_VARDIR/tmp'"; ---enable_query_log -execute stmt; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -show create table t1; -drop table t1; -execute stmt; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -show create table t1; -drop table t1; -deallocate prepare stmt; - -# -# Bug#32167 another privilege bypass with DATA/INDEX DIRECORY -# ---replace_result $MYSQL_TEST_DIR TEST_DIR ---error 1,ER_WRONG_ARGUMENTS -eval CREATE TABLE t1(a INT) -DATA DIRECTORY='$MYSQL_TEST_DIR/var/master-data/test'; ---replace_result $MYSQL_TEST_DIR TEST_DIR ---error 1,ER_WRONG_ARGUMENTS -eval CREATE TABLE t1(a INT) -DATA DIRECTORY='$MYSQL_TEST_DIR/var/master-data/'; ---replace_result $MYSQL_TEST_DIR TEST_DIR ---error 1,ER_WRONG_ARGUMENTS -eval CREATE TABLE t1(a INT) -INDEX DIRECTORY='$MYSQL_TEST_DIR/var/master-data'; ---replace_result $MYSQL_TEST_DIR TEST_DIR ---error 1,ER_WRONG_ARGUMENTS -eval CREATE TABLE t1(a INT) -INDEX DIRECTORY='$MYSQL_TEST_DIR/var/master-data_var'; - --echo End of 4.1 tests # # Bug #29325: create table overwrites .MYD file of other table (datadir) # +let $MYSQLD_DATADIR= `select @@datadir`; SET SESSION keep_files_on_create = TRUE; ---write_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD +--write_file $MYSQLD_DATADIR/test/t1.MYD EOF --disable_abort_on_error ---error 1 ---replace_result $MYSQLTEST_VARDIR . master-data/ '' +--error 1,1,ER_TABLE_EXISTS_ERROR CREATE TABLE t1 (a INT) ENGINE MYISAM; --error 0,1 ---remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD; +--remove_file $MYSQLD_DATADIR/test/t1.MYD; --enable_abort_on_error SET SESSION keep_files_on_create = FALSE; CREATE TABLE t1 (a INT) ENGINE MYISAM; DROP TABLE t1; --echo End of 5.0 tests + +# +# Bug#32167: another privilege bypass with DATA/INDEX DIRECTORY +# +# With Bug#41002 (symlink.test fails on symlinked datadir) it was +# decided that the below statements may also succeed if the data +# home directory is symlinked, e.g. mysql-test-run --mem. +# This will be fixed in 6.0 only. +# +let $MYSQLD_DATADIR= `select @@datadir`; +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--error 0,ER_WRONG_ARGUMENTS +eval CREATE TABLE t1(a INT) +INDEX DIRECTORY='$MYSQLD_DATADIR/mysql'; +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +# +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--error 0,ER_WRONG_ARGUMENTS +eval CREATE TABLE t1(a INT) +DATA DIRECTORY='$MYSQLD_DATADIR/test'; +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +# +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--error 0,ER_WRONG_ARGUMENTS +eval CREATE TABLE t1(a INT) +DATA DIRECTORY='$MYSQLD_DATADIR/'; +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +# +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--error 0,ER_WRONG_ARGUMENTS +eval CREATE TABLE t1(a INT) +INDEX DIRECTORY='$MYSQLD_DATADIR'; +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +# +--replace_result $MYSQLTEST_VARDIR TEST_DIR +--error 1 +eval CREATE TABLE t1(a INT) +INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data_var'; + +# +# BUG#25677 - With --skip-symbolic-links option on, DATA DIRECTORY clause is +# silently ignored +# + +SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='NO_DIR_IN_CREATE'; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t1(a INT) DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp' INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp'; +DROP TABLE t1; +SET @@SQL_MODE=@OLD_SQL_MODE; + +--echo End of 5.1 tests diff --git a/mysql-test/t/system_mysql_db.test b/mysql-test/t/system_mysql_db.test index 27c17da2731..398a222b642 100644 --- a/mysql-test/t/system_mysql_db.test +++ b/mysql-test/t/system_mysql_db.test @@ -2,10 +2,9 @@ # This test must examine integrity of system database "mysql" # -# First delete some tables maybe left over from previous tests ---disable_warnings -drop table if exists t1,t1aa,t2aa; ---enable_warnings +# check that CSV engine was compiled in, as the result of the test +# depends on the presence of the log tables (which are CSV-based). +--source include/have_csv.inc -- disable_query_log use mysql; diff --git a/mysql-test/t/system_mysql_db_fix30020.test b/mysql-test/t/system_mysql_db_fix30020.test index 23562807c14..0a7d9dad7c9 100644 --- a/mysql-test/t/system_mysql_db_fix30020.test +++ b/mysql-test/t/system_mysql_db_fix30020.test @@ -7,6 +7,9 @@ if (`SELECT LENGTH("$MYSQL_FIX_SYSTEM_TABLES") <= 0`) { skip Test need MYSQL_FIX_SYSTEM_TABLES; } +# check that CSV engine was compiled in, as the test relies on the presence +# of the log tables (which are CSV-based) +--source include/have_csv.inc # # This is the test for mysql_fix_privilege_tables @@ -18,10 +21,6 @@ if (`SELECT LENGTH("$MYSQL_FIX_SYSTEM_TABLES") <= 0`) # mysql_fix_system_tables which should be ignored. # Instead, concentrate on the errors in r/system_mysql_db.reject ---disable_warnings -drop table if exists t1,t1aa,t2aa; ---enable_warnings - -- disable_result_log -- disable_query_log @@ -43,7 +42,7 @@ CREATE TABLE db ( PRIMARY KEY Host (Host,Db,User), KEY User (User) ) -type=ISAM; +engine=MyISAM; --enable_warnings INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y'); @@ -61,7 +60,7 @@ CREATE TABLE host ( Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) -type=ISAM; +engine=MyISAM; --enable_warnings --disable_warnings @@ -80,7 +79,7 @@ CREATE TABLE user ( Process_priv enum('N','Y') DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,User) ) -type=ISAM; +engine=MyISAM; --enable_warnings INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y'); @@ -95,11 +94,15 @@ INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N',' -- disable_query_log -DROP TABLE db, host, user, func, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type; +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, +procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, +time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, +time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index; -- enable_query_log # check that we dropped all system tables show tables; +exit; # End of 4.1 tests diff --git a/mysql-test/t/system_mysql_db_fix40123.test b/mysql-test/t/system_mysql_db_fix40123.test index 012d05af3b8..440fcc8aa8a 100644 --- a/mysql-test/t/system_mysql_db_fix40123.test +++ b/mysql-test/t/system_mysql_db_fix40123.test @@ -18,10 +18,6 @@ if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`) # mysql_fix_system_tables which should be ignored. # Instead, concentrate on the errors in r/system_mysql_db.reject ---disable_warnings -drop table if exists t1,t1aa,t2aa; ---enable_warnings - -- disable_result_log -- disable_query_log @@ -76,7 +72,7 @@ CREATE TABLE time_zone_leap_second ( Transition_time bigint signed NOT NULL, -- disable_query_log # Drop all tables created by this test -DROP TABLE db, host, user, func, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type; +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index; -- enable_query_log diff --git a/mysql-test/t/system_mysql_db_fix50030-master.opt b/mysql-test/t/system_mysql_db_fix50030-master.opt new file mode 100644 index 00000000000..7e4fa9a3ee8 --- /dev/null +++ b/mysql-test/t/system_mysql_db_fix50030-master.opt @@ -0,0 +1 @@ +--result-file=system_mysql_db diff --git a/mysql-test/t/system_mysql_db_fix50030.test b/mysql-test/t/system_mysql_db_fix50030.test new file mode 100644 index 00000000000..4924c625d57 --- /dev/null +++ b/mysql-test/t/system_mysql_db_fix50030.test @@ -0,0 +1,88 @@ +# Embedded server doesn't support external clients +--source include/not_embedded.inc + +# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set +# to the location of mysql_fix_privilege_tables.sql +if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`) +{ + skip Test needs MYSQL_FIX_PRIVILEGE_TABLES; +} + +# +# This is the test for mysql_fix_privilege_tables +# It checks that a system tables from mysql 5.0.30 +# can be upgraded to current system table format +# +# Note: If this test fails, don't be confused about the errors reported +# by mysql-test-run This shows warnings generated by +# mysql_fix_system_tables which should be ignored. +# Instead, concentrate on the errors in r/system_mysql_db.reject + +-- disable_result_log +-- disable_query_log + +use test; + +# create system tables as in mysql-5.0.30 +# created by executing "./mysql_create_system_tables real ." + +set table_type=myisam; +CREATE TABLE db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges'; +INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N'); +INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N'); + +CREATE TABLE host ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Host privileges; Merged with database privileges'; + +CREATE TABLE user ( Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL, ssl_cipher BLOB NOT NULL, x509_issuer BLOB NOT NULL, x509_subject BLOB NOT NULL, max_questions int(11) unsigned DEFAULT 0 NOT NULL, max_updates int(11) unsigned DEFAULT 0 NOT NULL, max_connections int(11) unsigned DEFAULT 0 NOT NULL, max_user_connections int(11) unsigned DEFAULT 0 NOT NULL, PRIMARY KEY Host (Host,User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges'; +INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); +INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0, 0); + +CREATE TABLE func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions'; + +CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges'; + +CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges'; + +CREATE TABLE help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics'; +CREATE TABLE help_category ( help_category_id smallint unsigned not null, name char(64) not null, parent_category_id smallint unsigned null, url char(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories'; +CREATE TABLE help_relation ( help_topic_id int unsigned not null references help_topic, help_keyword_id int unsigned not null references help_keyword, primary key (help_keyword_id, help_topic_id) ) engine=MyISAM CHARACTER SET utf8 comment='keyword-topic relation'; +CREATE TABLE help_keyword ( help_keyword_id int unsigned not null, name char(64) not null, primary key (help_keyword_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help keywords'; + +CREATE TABLE time_zone_name ( Name char(64) NOT NULL, Time_zone_id int unsigned NOT NULL, PRIMARY KEY Name (Name) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone names'; + +CREATE TABLE time_zone ( Time_zone_id int unsigned NOT NULL auto_increment, Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY TzId (Time_zone_id) ) engine=MyISAM CHARACTER SET utf8 comment='Time zones'; + +CREATE TABLE time_zone_transition ( Time_zone_id int unsigned NOT NULL, Transition_time bigint signed NOT NULL, Transition_type_id int unsigned NOT NULL, PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone transitions'; + +CREATE TABLE time_zone_transition_type ( Time_zone_id int unsigned NOT NULL, Transition_type_id int unsigned NOT NULL, Offset int signed DEFAULT 0 NOT NULL, Is_DST tinyint unsigned DEFAULT 0 NOT NULL, Abbreviation char(8) DEFAULT '' NOT NULL, PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone transition types'; + +CREATE TABLE time_zone_leap_second ( Transition_time bigint signed NOT NULL, Correction int signed NOT NULL, PRIMARY KEY TranTime (Transition_time) ) engine=MyISAM CHARACTER SET utf8 comment='Leap seconds information for time zones'; + +CREATE TABLE proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob DEFAULT '' NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob DEFAULT '' NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures'; + +CREATE TABLE procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges'; + +CREATE TABLE servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table'; + +INSERT INTO servers VALUES ('test','localhost','test','root','', 0,'','mysql','root'); + +# Run the mysql_fix_privilege_tables.sql using "mysql --force" +--exec $MYSQL --force test < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/log/system_mysql_db_fix50030.log 2>&1 + +-- enable_query_log +-- enable_result_log + +# Dump the tables that should be compared +-- source include/system_db_struct.inc + +-- disable_query_log + +# Drop all tables created by this test +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index; + +-- enable_query_log + +# check that we dropped all system tables +show tables; + +# End of 4.1 tests diff --git a/mysql-test/t/system_mysql_db_fix50117-master.opt b/mysql-test/t/system_mysql_db_fix50117-master.opt new file mode 100644 index 00000000000..7e4fa9a3ee8 --- /dev/null +++ b/mysql-test/t/system_mysql_db_fix50117-master.opt @@ -0,0 +1 @@ +--result-file=system_mysql_db diff --git a/mysql-test/t/system_mysql_db_fix50117.test b/mysql-test/t/system_mysql_db_fix50117.test new file mode 100644 index 00000000000..d88c4edba93 --- /dev/null +++ b/mysql-test/t/system_mysql_db_fix50117.test @@ -0,0 +1,107 @@ +# Embedded server doesn't support external clients +--source include/not_embedded.inc + +# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set +# to the location of mysql_fix_privilege_tables.sql +if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`) +{ + skip Test needs MYSQL_FIX_PRIVILEGE_TABLES; +} + +# +# This is the test for mysql_fix_privilege_tables +# It checks that a system tables from mysql 5.1.17 +# can be upgraded to current system table format +# +# Note: If this test fails, don't be confused about the errors reported +# by mysql-test-run This shows warnings generated by +# mysql_fix_system_tables which should be ignored. +# Instead, concentrate on the errors in r/system_mysql_db.reject + +-- disable_result_log +-- disable_query_log + +use test; + +# create system tables as in mysql-5.1.17 + + +CREATE TABLE IF NOT EXISTS db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges'; + + +CREATE TABLE IF NOT EXISTS host ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Host privileges; Merged with database privileges'; + + +CREATE TABLE IF NOT EXISTS user ( Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL, ssl_cipher BLOB NOT NULL, x509_issuer BLOB NOT NULL, x509_subject BLOB NOT NULL, max_questions int(11) unsigned DEFAULT 0 NOT NULL, max_updates int(11) unsigned DEFAULT 0 NOT NULL, max_connections int(11) unsigned DEFAULT 0 NOT NULL, max_user_connections int(11) unsigned DEFAULT 0 NOT NULL, PRIMARY KEY Host (Host,User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges'; + + +CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions'; + + +CREATE TABLE IF NOT EXISTS plugin ( name char(64) binary DEFAULT '' NOT NULL, dl char(128) DEFAULT '' NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='MySQL plugins'; + + +CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table'; + + +CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges'; + +CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges'; + + +CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics'; + + +CREATE TABLE IF NOT EXISTS help_category ( help_category_id smallint unsigned not null, name char(64) not null, parent_category_id smallint unsigned null, url char(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories'; + + +CREATE TABLE IF NOT EXISTS help_relation ( help_topic_id int unsigned not null references help_topic, help_keyword_id int unsigned not null references help_keyword, primary key (help_keyword_id, help_topic_id) ) engine=MyISAM CHARACTER SET utf8 comment='keyword-topic relation'; + + +CREATE TABLE IF NOT EXISTS help_keyword ( help_keyword_id int unsigned not null, name char(64) not null, primary key (help_keyword_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help keywords'; + + +CREATE TABLE IF NOT EXISTS time_zone_name ( Name char(64) NOT NULL, Time_zone_id int unsigned NOT NULL, PRIMARY KEY Name (Name) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone names'; + + +CREATE TABLE IF NOT EXISTS time_zone ( Time_zone_id int unsigned NOT NULL auto_increment, Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY TzId (Time_zone_id) ) engine=MyISAM CHARACTER SET utf8 comment='Time zones'; + + +CREATE TABLE IF NOT EXISTS time_zone_transition ( Time_zone_id int unsigned NOT NULL, Transition_time bigint signed NOT NULL, Transition_type_id int unsigned NOT NULL, PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone transitions'; + + +CREATE TABLE IF NOT EXISTS time_zone_transition_type ( Time_zone_id int unsigned NOT NULL, Transition_type_id int unsigned NOT NULL, Offset int signed DEFAULT 0 NOT NULL, Is_DST tinyint unsigned DEFAULT 0 NOT NULL, Abbreviation char(8) DEFAULT '' NOT NULL, PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone transition types'; + + +CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint signed NOT NULL, Correction int signed NOT NULL, PRIMARY KEY TranTime (Transition_time) ) engine=MyISAM CHARACTER SET utf8 comment='Leap seconds information for time zones'; + + +CREATE TABLE IF NOT EXISTS proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures'; + + +CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges'; + +CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events'; + +CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM; + +# Run the mysql_fix_privilege_tables.sql using "mysql --force" +--exec $MYSQL --force test < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/log/system_mysql_db_fix50117.log 2>&1 + +-- enable_query_log +-- enable_result_log + +# Dump the tables that should be compared +-- source include/system_db_struct.inc + +-- disable_query_log + +# Drop all tables created by this test +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index; + +-- enable_query_log + +# check that we dropped all system tables +show tables; + +# End of 4.1 tests diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test index 90f868f5932..2bfa4936c91 100644 --- a/mysql-test/t/temp_table.test +++ b/mysql-test/t/temp_table.test @@ -73,7 +73,7 @@ drop table t1,t2; # create temporary table t1 (a int not null); insert into t1 values (1),(1); --- error 1062 +-- error ER_DUP_ENTRY alter table t1 add primary key (a); drop table t1; @@ -179,3 +179,60 @@ SELECT 1 UNION SELECT * FROM t2 UNION SELECT 1; SELECT c/1 FROM t1 UNION SELECT 1; DROP TABLE t1, t2; + +# +# Test truncate with temporary tables +# + +create temporary table t1 (a int); +insert into t1 values (4711); +select * from t1; +truncate t1; +insert into t1 values (42); +select * from t1; +drop table t1; + +# +# Bug #35392: Delete all statement does not execute properly after +# few delete statements +# +CREATE TEMPORARY TABLE t1(a INT, b VARCHAR(20)); +INSERT INTO t1 VALUES(1, 'val1'), (2, 'val2'), (3, 'val3'); +DELETE FROM t1 WHERE a=1; +SELECT count(*) FROM t1; +DELETE FROM t1; +SELECT * FROM t1; +DROP TABLE t1; + +# +# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table +# + +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +DROP FUNCTION IF EXISTS f1; +--enable_warnings + +CREATE TEMPORARY TABLE t1 (a INT); +CREATE TEMPORARY TABLE t2 LIKE t1; + +DELIMITER |; +CREATE FUNCTION f1() RETURNS INT + BEGIN + return 1; + END| +DELIMITER ;| + +INSERT INTO t2 SELECT * FROM t1; +INSERT INTO t1 SELECT f1(); + +CREATE TABLE t3 SELECT * FROM t1; +INSERT INTO t1 SELECT f1(); + +UPDATE t1,t2 SET t1.a = t2.a; +INSERT INTO t2 SELECT f1(); + +DROP TABLE t1,t2,t3; +DROP FUNCTION f1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index 75e5d4bfe81..15ddceb8d68 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -69,7 +69,7 @@ set time_zone='UTC'; select * from t1; -delete from t1; +truncate table t1; # Simple check for 'Europe/Moscow' time zone just for showing that it works set time_zone='Europe/Moscow'; @@ -79,7 +79,7 @@ insert into t1 (i, ts) values (unix_timestamp('2004-08-01 00:00:00'),'2003-08-01 00:00:00'), (unix_timestamp('2004-10-31 02:30:00'),'2004-10-31 02:30:00'); select * from t1; -delete from t1; +truncate table t1; # @@ -94,7 +94,7 @@ insert into t1 (i, ts) values (unix_timestamp('2004-08-01 00:00:00'),'2003-08-01 00:00:00'), (unix_timestamp('2004-10-31 02:30:00'),'2004-10-31 02:30:00'); select * from t1; -delete from t1; +truncate table t1; # Let us test leap jump insert into t1 (i, ts) values (unix_timestamp('1981-07-01 03:59:59'),'1981-07-01 03:59:59'), @@ -115,14 +115,14 @@ insert into t1 values ('0000-00-00 00:00:00'),('1969-12-31 23:59:59'), ('1970-01-01 00:00:00'),('1970-01-01 00:00:01'), ('2038-01-19 03:14:07'),('2038-01-19 03:14:08'); select * from t1; -delete from t1; +truncate table t1; # MET time zone has range shifted by one hour set time_zone='MET'; insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 00:30:00'), ('1970-01-01 01:00:00'),('1970-01-01 01:00:01'), ('2038-01-19 04:14:07'),('2038-01-19 04:14:08'); select * from t1; -delete from t1; +truncate table t1; # same for +01:30 time zone set time_zone='+01:30'; insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 01:00:00'), @@ -228,6 +228,9 @@ drop table t1; # Test for bug #11081 "Using a CONVERT_TZ function in a stored function # or trigger fails". # +SET @old_log_bin_trust_function_creators = @@global.log_bin_trust_function_creators; +SET GLOBAL log_bin_trust_function_creators = 1; + create table t1 (ldt datetime, udt datetime); create function f1(i datetime) returns datetime return convert_tz(i, 'UTC', 'Europe/Moscow'); @@ -241,4 +244,34 @@ select ldt, f1(udt) as ldt2 from t1; drop table t1; drop function f1; +SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators; + # End of 5.0 tests + + +# +# BUG#9953: CONVERT_TZ requires mysql.time_zone_name to be locked +# BUG#19339: CONVERT_TZ(): overly aggressive in locking time_zone_name +# table +# +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (t TIMESTAMP); +INSERT INTO t1 VALUES (NULL), (NULL); + +LOCK TABLES t1 WRITE; + +# The following two queries should not return error that time zone +# tables aren't locked. We use IS NULL below to supress timestamp +# result. +SELECT CONVERT_TZ(NOW(), 'UTC', 'Europe/Moscow') IS NULL; +UPDATE t1 SET t = CONVERT_TZ(t, 'UTC', 'Europe/Moscow'); + +UNLOCK TABLES; + +DROP TABLE t1; + + +--echo End of 5.1 tests diff --git a/mysql-test/t/trigger-compat.test b/mysql-test/t/trigger-compat.test index db410ba2f18..2cc86692d0d 100644 --- a/mysql-test/t/trigger-compat.test +++ b/mysql-test/t/trigger-compat.test @@ -35,8 +35,7 @@ CREATE DATABASE mysqltest_db1; CREATE USER mysqltest_dfn@localhost; CREATE USER mysqltest_inv@localhost; -GRANT SUPER ON *.* TO mysqltest_dfn@localhost; -GRANT CREATE ON mysqltest_db1.* TO mysqltest_dfn@localhost; +GRANT CREATE, TRIGGER ON mysqltest_db1.* TO mysqltest_dfn@localhost; # # Create a table and the first trigger. @@ -67,17 +66,17 @@ CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUE --disable_query_log --connection default CREATE TABLE patch (a blob); -eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG' INTO TABLE patch; +let $MYSQLD_DATADIR = `select @@datadir`; +eval LOAD DATA LOCAL INFILE '$MYSQLD_DATADIR/mysqltest_db1/t1.TRG' INTO TABLE patch; # remove original t1.TRG file so SELECT INTO OUTFILE won't fail ---remove_file $MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG +--remove_file $MYSQLD_DATADIR/mysqltest_db1/t1.TRG eval SELECT SUBSTRING_INDEX(a,'definers=',1) INTO OUTFILE - '$MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG' + '$MYSQLD_DATADIR/mysqltest_db1/t1.TRG' FROM patch; DROP TABLE patch; --connection wl2818_definer_con --enable_query_log - # # Create a new trigger. # diff --git a/mysql-test/t/trigger-trans.test b/mysql-test/t/trigger-trans.test index 5db5b982773..4d6e82dedcb 100644 --- a/mysql-test/t/trigger-trans.test +++ b/mysql-test/t/trigger-trans.test @@ -162,3 +162,18 @@ DROP TABLE t2, t1; --echo End of 5.0 tests + +--echo BUG#31612 +--echo Trigger fired multiple times leads to gaps in auto_increment sequence +create table t1 (a int, val char(1)) engine=InnoDB; +create table t2 (b int auto_increment primary key, + val char(1)) engine=InnoDB; +create trigger t1_after_insert after + insert on t1 for each row insert into t2 set val=NEW.val; +insert into t1 values ( 123, 'a'), ( 123, 'b'), ( 123, 'c'), + (123, 'd'), (123, 'e'), (123, 'f'), (123, 'g'); +insert into t1 values ( 654, 'a'), ( 654, 'b'), ( 654, 'c'), + (654, 'd'), (654, 'e'), (654, 'f'), (654, 'g'); +select * from t2 order by b; +drop trigger t1_after_insert; +drop table t1,t2; diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 9a0277a98c2..1e55f9d5993 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -472,11 +472,11 @@ create trigger trg1 before insert on t1 for each row set new.k = new.i; create trigger trg2 after insert on t1 for each row set @b:= "Fired"; set @b:=""; # Test triggers with file with separators -load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, i); +load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, i); select *, @b from t1; set @b:=""; # Test triggers with fixed size row file -load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j); +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j); select *, @b from t1; # This also will drop triggers drop table t1; @@ -510,7 +510,7 @@ delete from t1 where i = 2; select * from t1; # Should fail and insert only 1 row --error ER_BAD_FIELD_ERROR -load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); select * from t1; --error ER_BAD_FIELD_ERROR insert into t1 select 3, 3; @@ -567,7 +567,7 @@ select * from t1; delete from t1; select * from t1; --error ER_BAD_FIELD_ERROR -load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); select * from t1; --error ER_BAD_FIELD_ERROR insert into t1 select 3, 3; @@ -997,11 +997,10 @@ call p1(); # Altering trigger forcing it use different set of tables drop trigger t1_bi; create trigger t1_bi after insert on t1 for each row insert into t3 values (new.id); -# Until we implement proper mechanism for invalidation of PS/SP when table -# or SP's are changed these two statements will fail with 'Table ... was -# not locked' error (this mechanism should be based on the new TDC). ---error ER_NO_SUCH_TABLE execute stmt1; +# Until we implement proper mechanism for invalidation of SP statements +# invoked whenever a table used in SP changes, this statement will fail with +# 'Table ... does not exist' error. --error ER_NO_SUCH_TABLE call p1(); deallocate prepare stmt1; @@ -1142,11 +1141,13 @@ select trigger_schema, trigger_name, event_object_schema, event_object_table, action_statement from information_schema.triggers where event_object_schema = 'test'; # Trick which makes update of second .TRN file impossible -write_file $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; +let $MYSQLD_DATADIR= `select @@datadir`; +write_file $MYSQLD_DATADIR/test/t1_ai.TRN~; dummy EOF -chmod 0000 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; ---replace_result $MYSQLTEST_VARDIR . master-data/ '' +chmod 0000 $MYSQLD_DATADIR/test/t1_ai.TRN~; +# Normalize the datadir path; the embedded server doesn't chdir to datadir +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' --error 1 rename table t1 to t2; # 't1' should be still there and triggers should work correctly @@ -1155,8 +1156,8 @@ select @a, @b; select trigger_schema, trigger_name, event_object_schema, event_object_table, action_statement from information_schema.triggers where event_object_schema = 'test'; -chmod 0600 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; -remove_file $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; +chmod 0600 $MYSQLD_DATADIR/test/t1_ai.TRN~; +remove_file $MYSQLD_DATADIR/test/t1_ai.TRN~; # Let us check that updates to .TRN files were rolled back too drop trigger t1_bi; drop trigger t1_ai; @@ -1189,7 +1190,7 @@ insert into t1 (a) values create trigger t2_ai after insert on t2 for each row set @a:= (select max(a) from t2); insert into t2 select * from t1; -load data infile '../std_data_ln/words.dat' into table t1 (a); +load data infile '../../std_data/words.dat' into table t1 (a); drop trigger t1_ai; drop trigger t2_ai; # Test that the problem for functions is fixed as well @@ -1199,10 +1200,10 @@ insert into t1 values ("And",f1()),("the",f1()),("mome", f1()),("raths",f1()),("outgrabe",f1()); create function f2() returns int return (select max(b) from t2); insert into t2 select a, f2() from t1; -load data infile '../std_data_ln/words.dat' into table t1 (a) set b:= f1(); -drop table t1, t2; +load data infile '../../std_data/words.dat' into table t1 (a) set b:= f1(); drop function f1; drop function f2; +drop table t1, t2; # # Test for bug #16021 "Wrong index given to function in trigger" which @@ -2251,3 +2252,148 @@ DROP TRIGGER t_insert; DROP TABLE t2; --echo End of 5.0 tests + +# +# Bug#25411 (trigger code truncated) +# + +--disable_warnings +drop table if exists table_25411_a; +drop table if exists table_25411_b; +--enable_warnings + +create table table_25411_a(a int); +create table table_25411_b(b int); + +create trigger trg_25411a_ai after insert on table_25411_a +for each row + insert into table_25411_b select new.*; + +select * from table_25411_a; + +--error ER_BAD_TABLE_ERROR +insert into table_25411_a values (1); + +select * from table_25411_a; + +drop table table_25411_a; +drop table table_25411_b; + +# +# Bug #31866: MySQL Server crashes on SHOW CREATE TRIGGER statement +# + +--disable_warnings +DROP TRIGGER IF EXISTS trg; +--enable_warnings + +--error ER_TRG_DOES_NOT_EXIST +SHOW CREATE TRIGGER trg; + +# +# Bug#23713 LOCK TABLES + CREATE TRIGGER + FLUSH TABLES WITH READ LOCK = deadlock +# +# Test of trigger creation and removal under LOCK TABLES +# + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (i int, j int); + +create trigger t1_bi before insert on t1 for each row begin end; +--error ER_NOT_SUPPORTED_YET +create trigger t1_bi before insert on t1 for each row begin end; +drop trigger t1_bi; +--error ER_TRG_DOES_NOT_EXIST +drop trigger t1_bi; + +lock tables t1 read; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +create trigger t1_bi before insert on t1 for each row begin end; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +create trigger t1_bi before insert on t1 for each row begin end; +--error ER_TRG_DOES_NOT_EXIST +drop trigger t1_bi; +unlock tables; + +create trigger t1_bi before insert on t1 for each row begin end; +lock tables t1 read; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +create trigger t1_bi before insert on t1 for each row begin end; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +drop trigger t1_bi; +unlock tables; +drop trigger t1_bi; + +lock tables t1 write; +create trigger b1_bi before insert on t1 for each row set new.i = new.i + 10; +insert into t1 values (10, 10); +drop trigger b1_bi; +insert into t1 values (10, 10); +select * from t1; +unlock tables; + +drop table t1; + +# +# Bug#23771 AFTER UPDATE trigger not invoked when there are no changes of the data +# + +--disable_warnings +drop table if exists t1, t2; +drop trigger if exists trg1; +drop trigger if exists trg2; +--enable_warnings +create table t1 (a int); +create table t2 (b int); +create trigger trg1 after update on t1 for each row set @a= @a+1; +create trigger trg2 after update on t2 for each row set @b= @b+1; +insert into t1 values (1), (2), (3); +insert into t2 values (1), (2), (3); +set @a= 0; +set @b= 0; +update t1, t2 set t1.a= t1.a, t2.b= t2.b; +select @a, @b; +update t1, t2 set t1.a= t2.b, t2.b= t1.a; +select @a, @b; +update t1 set a= a; +select @a, @b; +update t2 set b= b; +select @a, @b; +update t1 set a= 1; +select @a, @b; +update t2 set b= 1; +select @a, @b; +drop trigger trg1; +drop trigger trg2; +drop table t1, t2; + +# +# Bug#44653: Server crash noticed when executing random queries with partitions. +# +CREATE TABLE t1 ( a INT, b INT ); +CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY, b INT ); + +INSERT INTO t1 (a) VALUES (1); + +delimiter //; +CREATE TRIGGER tr1 +BEFORE INSERT ON t2 +FOR EACH ROW +BEGIN + UPDATE a_nonextisting_table SET a = 1; +END// +delimiter ;// + +--disable_abort_on_error +CREATE TABLE IF NOT EXISTS t2 ( a INT, b INT ) SELECT a, b FROM t1; +--enable_abort_on_error + +# Caused failed assertion +SELECT * FROM t2; + +DROP TABLE t1, t2; + +--echo End of 5.1 tests. diff --git a/mysql-test/t/trigger-grant.test b/mysql-test/t/trigger_notembedded.test index 96bd6acd02d..7a7e6c6bc85 100644 --- a/mysql-test/t/trigger-grant.test +++ b/mysql-test/t/trigger_notembedded.test @@ -44,9 +44,124 @@ CREATE DATABASE mysqltest_db1; CREATE USER mysqltest_dfn@localhost; CREATE USER mysqltest_inv@localhost; -GRANT SUPER ON *.* TO mysqltest_dfn@localhost; GRANT CREATE ON mysqltest_db1.* TO mysqltest_dfn@localhost; +--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1) +--connection wl2818_definer_con +--echo +--echo ---> connection: wl2818_definer_con + +CREATE TABLE t1(num_value INT); +CREATE TABLE t2(user_str TEXT); + +--disconnect wl2818_definer_con + +--connection default +--echo +--echo ---> connection: default + +GRANT INSERT, DROP ON mysqltest_db1.t1 TO mysqltest_dfn@localhost; +GRANT INSERT, DROP ON mysqltest_db1.t2 TO mysqltest_dfn@localhost; + +# +# Check that the user must have TRIGGER privilege to create a trigger. +# + +--connection default +--echo +--echo ---> connection: default + +GRANT SUPER ON *.* TO mysqltest_dfn@localhost; + +--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1) +--connection wl2818_definer_con +--echo +--echo ---> connection: wl2818_definer_con + +--error ER_TABLEACCESS_DENIED_ERROR +CREATE TRIGGER trg1 AFTER INSERT ON t1 + FOR EACH ROW + INSERT INTO t2 VALUES(CURRENT_USER()); + +--disconnect wl2818_definer_con + +# +# Check that the user must have TRIGGER privilege to drop a trigger. +# + +--connection default +--echo +--echo ---> connection: default + +GRANT TRIGGER ON mysqltest_db1.t1 TO mysqltest_dfn@localhost; + +--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1) +--connection wl2818_definer_con +--echo +--echo ---> connection: wl2818_definer_con + +CREATE TRIGGER trg1 AFTER INSERT ON t1 + FOR EACH ROW + INSERT INTO t2 VALUES(CURRENT_USER()); + +--disconnect wl2818_definer_con + +--connection default +--echo +--echo ---> connection: default + +REVOKE TRIGGER ON mysqltest_db1.t1 FROM mysqltest_dfn@localhost; + +--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1) +--connection wl2818_definer_con +--echo +--echo ---> connection: wl2818_definer_con + +--error ER_TABLEACCESS_DENIED_ERROR +DROP TRIGGER trg1; + +--disconnect wl2818_definer_con + +# +# Check that the definer must have TRIGGER privilege to activate a trigger. +# + +--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1) +--connection wl2818_definer_con +--echo +--echo ---> connection: wl2818_definer_con + +--error ER_TABLEACCESS_DENIED_ERROR +INSERT INTO t1 VALUES(0); + +--disconnect wl2818_definer_con + +--connection default +--echo +--echo ---> connection: default + +GRANT TRIGGER ON mysqltest_db1.t1 TO mysqltest_dfn@localhost; + +--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1) +--connection wl2818_definer_con +--echo +--echo ---> connection: wl2818_definer_con + +INSERT INTO t1 VALUES(0); + +# Cleanup for further tests. +DROP TRIGGER trg1; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; + +--disconnect wl2818_definer_con + +--connection default +--echo +--echo ---> connection: default + +REVOKE SUPER ON *.* FROM mysqltest_dfn@localhost; + # # Check that triggers are executed under the authorization of the definer: # - create two tables under "definer"; @@ -64,9 +179,6 @@ GRANT CREATE ON mysqltest_db1.* TO mysqltest_dfn@localhost; --echo --echo ---> connection: wl2818_definer_con -CREATE TABLE t1(num_value INT); -CREATE TABLE t2(user_str TEXT); - CREATE TRIGGER trg1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES(CURRENT_USER()); @@ -145,10 +257,6 @@ SELECT * FROM t2; # # Check DEFINER clause of CREATE TRIGGER statement. # -# NOTE: there is no dedicated TRIGGER privilege for CREATE TRIGGER statement. -# SUPER privilege is used instead. I.e., if one invokes CREATE TRIGGER, it should -# have SUPER privilege, so this test is meaningless right now. -# # - Check that SUPER privilege required to create a trigger with different # definer: # - try to create a trigger with DEFINER="definer@localhost" under @@ -174,7 +282,26 @@ use mysqltest_db1; DROP TRIGGER trg1; # Check that SUPER is required to specify different DEFINER. -# NOTE: meaningless at the moment + +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +CREATE DEFINER='mysqltest_inv'@'localhost' + TRIGGER trg1 BEFORE INSERT ON t1 + FOR EACH ROW + SET @new_sum = 0; + +--connection default +--echo +--echo ---> connection: default + +use mysqltest_db1; + +GRANT SUPER ON *.* TO mysqltest_dfn@localhost; + +--disconnect wl2818_definer_con +--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1) +--connection wl2818_definer_con +--echo +--echo ---> connection: wl2818_definer_con CREATE DEFINER='mysqltest_inv'@'localhost' TRIGGER trg1 BEFORE INSERT ON t1 @@ -190,7 +317,7 @@ CREATE DEFINER='mysqltest_nonexs'@'localhost' # Check that trg2 will not be activated. ---error ER_SPECIFIC_ACCESS_DENIED_ERROR +--error ER_NO_SUCH_USER INSERT INTO t1 VALUES(6); # @@ -233,10 +360,11 @@ CREATE TRIGGER trg5 BEFORE DELETE ON t1 SET @a = 5; # Replace definers with the "weird" definers +let MYSQLD_DATADIR= `select @@datadir`; perl; use strict; use warnings; -my $fname= "$ENV{'MYSQLTEST_VARDIR'}/master-data/mysqltest_db1/t1.TRG"; +my $fname= "$ENV{'MYSQLD_DATADIR'}/mysqltest_db1/t1.TRG"; open(FILE, "<", $fname) or die; my @content= grep($_ !~ /^definers=/, <FILE>); close FILE; @@ -269,6 +397,7 @@ DROP USER mysqltest_inv@localhost; DROP DATABASE mysqltest_db1; + ########################################################################### # # BUG#15166: Wrong update [was: select/update] permissions required to execute @@ -306,8 +435,7 @@ CREATE TABLE t4(col CHAR(20)); # table for "write-value" trigger CREATE USER mysqltest_u1@localhost; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost; -GRANT SUPER ON *.* TO mysqltest_u1@localhost; -GRANT SELECT ON mysqltest_db1.t1 TO mysqltest_u1@localhost; # to allow connect +GRANT TRIGGER ON mysqltest_db1.* TO mysqltest_u1@localhost; SET @mysqltest_var = NULL; @@ -323,7 +451,6 @@ SET @mysqltest_var = NULL; use mysqltest_db1; -REVOKE SELECT ON mysqltest_db1.t1 FROM mysqltest_u1@localhost; GRANT DELETE ON mysqltest_db1.* TO mysqltest_u1@localhost; SHOW GRANTS FOR mysqltest_u1@localhost; @@ -604,7 +731,7 @@ CREATE TABLE t2 (i1 INT); CREATE USER mysqltest_dfn@localhost; CREATE USER mysqltest_inv@localhost; -GRANT EXECUTE, CREATE ROUTINE, SUPER ON *.* TO mysqltest_dfn@localhost; +GRANT EXECUTE, CREATE ROUTINE, TRIGGER ON *.* TO mysqltest_dfn@localhost; GRANT INSERT ON mysqltest_db1.* TO mysqltest_inv@localhost; connect (definer,localhost,mysqltest_dfn,,mysqltest_db1); @@ -749,3 +876,60 @@ DROP DATABASE mysqltest_db1; USE test; --echo End of 5.0 tests. + +# +# Bug#23713 LOCK TABLES + CREATE TRIGGER + FLUSH TABLES WITH READ LOCK = deadlock +# + +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (i int); +connect (flush,localhost,root,,test,,); +connection default; +--echo connection: default +lock tables t1 write; +connection flush; +--echo connection: flush +--send flush tables with read lock; +connection default; +--echo connection: default +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Flushing tables"; +--source include/wait_condition.inc +create trigger t1_bi before insert on t1 for each row begin end; +unlock tables; +connection flush; +--echo connection: flush +--reap +unlock tables; +connection default; +select * from t1; +drop table t1; +disconnect flush; + +# +# Bug#45412 SHOW CREATE TRIGGER does not require privileges to disclose trigger data +# +CREATE DATABASE db1; +CREATE TABLE db1.t1 (a char(30)) ENGINE=MEMORY; +CREATE TRIGGER db1.trg AFTER INSERT ON db1.t1 FOR EACH ROW + INSERT INTO db1.t1 VALUES('Some very sensitive data goes here'); + +CREATE USER 'no_rights'@'localhost'; +REVOKE ALL ON *.* FROM 'no_rights'@'localhost'; +FLUSH PRIVILEGES; + +connect (con1,localhost,no_rights,,); +SELECT trigger_name FROM INFORMATION_SCHEMA.TRIGGERS + WHERE trigger_schema = 'db1'; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +SHOW CREATE TRIGGER db1.trg; + +connection default; +disconnect con1; +DROP USER 'no_rights'@'localhost'; +DROP DATABASE db1; + +--echo End of 5.1 tests. diff --git a/mysql-test/t/type_binary.test b/mysql-test/t/type_binary.test index 91eba9b328e..4d5a5312472 100644 --- a/mysql-test/t/type_binary.test +++ b/mysql-test/t/type_binary.test @@ -31,7 +31,7 @@ drop table t1; create table t1 (s1 binary(2) primary key); insert into t1 values (0x01); insert into t1 values (0x0120); ---error 1062 +--error ER_DUP_ENTRY insert into t1 values (0x0100); select hex(s1) from t1 order by s1; # check index search diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 7ec0649cbdd..530389b3ab9 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -39,7 +39,7 @@ drop table t1; create table t1 (a bit); insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001'); select hex(a) from t1; ---error 1062 +--error ER_DUP_ENTRY alter table t1 add unique (a); drop table t1; @@ -409,3 +409,20 @@ DROP TABLE t1; --echo End of 5.0 tests + +# +# Bug #28631: problem after alter +# +create table t1(a bit(7)); +insert into t1 values(0x40); +alter table t1 modify column a bit(8); +select hex(a) from t1; +insert into t1 values(0x80); +select hex(a) from t1; +create index a on t1(a); +insert into t1 values(0x81); +select hex(a) from t1; +show create table t1; +drop table t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index 2b465e6be77..460da1c1614 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -308,20 +308,20 @@ create table t1 (id integer auto_increment unique,imagem LONGBLOB not null defau insert into t1 (id) values (1); # We have to clean up the path in the results for safe comparison eval select - charset(load_file('../std_data_ln/words.dat')), - collation(load_file('../std_data_ln/words.dat')), - coercibility(load_file('../std_data_ln/words.dat')); + charset(load_file('../../std_data/words.dat')), + collation(load_file('../../std_data/words.dat')), + coercibility(load_file('../../std_data/words.dat')); --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval explain extended select - charset(load_file('$MYSQLTEST_VARDIR/std_data_ln/words.dat')), - collation(load_file('$MYSQLTEST_VARDIR/std_data_ln/words.dat')), - coercibility(load_file('$MYSQLTEST_VARDIR/std_data_ln/words.dat')); + charset(load_file('$MYSQLTEST_VARDIR/std_data/words.dat')), + collation(load_file('$MYSQLTEST_VARDIR/std_data/words.dat')), + coercibility(load_file('$MYSQLTEST_VARDIR/std_data/words.dat')); --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval update t1 set imagem=load_file('$MYSQLTEST_VARDIR/std_data_ln/words.dat') where id=1; +eval update t1 set imagem=load_file('$MYSQLTEST_VARDIR/std_data/words.dat') where id=1; select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1; drop table t1; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -eval create table t1 select load_file('$MYSQLTEST_VARDIR/std_data_ln/words.dat') l; +eval create table t1 select load_file('$MYSQLTEST_VARDIR/std_data/words.dat') l; # We mask out the Privileges column because it differs for embedded server --replace_column 8 # show full fields from t1; @@ -333,9 +333,9 @@ drop table t1; # create table t1 (id integer primary key auto_increment, txt text not null, unique index txt_index (txt (20))); ---error 1062 +--error ER_DUP_ENTRY insert into t1 (txt) values ('Chevy'), ('Chevy '); ---error 1062 +--error ER_DUP_ENTRY insert into t1 (txt) values ('Chevy'), ('CHEVY'); alter table t1 drop index txt_index, add index txt_index (txt(20)); insert into t1 (txt) values ('Chevy '); diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index 3369d64d0ae..aec60bc2dee 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -62,7 +62,7 @@ drop table t1; # Test of date and not null # -create table t1 (date date); +create table t1 (date date); insert into t1 values ("2000-08-10"),("2000-08-11"); select date_add(date,INTERVAL 1 DAY),date_add(date,INTERVAL 1 SECOND) from t1; drop table t1; @@ -75,9 +75,12 @@ CREATE TABLE t1(AFIELD INT); INSERT INTO t1 VALUES(1); CREATE TABLE t2(GMT VARCHAR(32)); INSERT INTO t2 VALUES('GMT-0800'); -SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) FROM t1, t2 GROUP BY t1.AFIELD; +SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +FROM t1, t2 GROUP BY t1.AFIELD; INSERT INTO t1 VALUES(1); -SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)), DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) FROM t1,t2 GROUP BY t1.AFIELD; +SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)), + DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)) +FROM t1,t2 GROUP BY t1.AFIELD; drop table t1,t2; # @@ -90,7 +93,7 @@ SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1; DROP TABLE t1; # -# Bug 4937: different date -> string conversion when using SELECT ... UNION +# Bug#4937: different date -> string conversion when using SELECT ... UNION # and INSERT ... SELECT ... UNION # @@ -128,9 +131,12 @@ drop table t1; # Bug #23093: Implicit conversion of 9912101 to date does not match # cast(9912101 as date) # -select @d:=1111, year(@d), month(@d), day(@d), cast(@d as date); -select @d:=011111, year(@d), month(@d), day(@d), cast(@d as date); -select @d:=1311, year(@d), month(@d), day(@d), cast(@d as date); +select @d:=1111; +select year(@d), month(@d), day(@d), cast(@d as date); +select @d:=011111; +select year(@d), month(@d), day(@d), cast(@d as date); +select @d:=1311; +select year(@d), month(@d), day(@d), cast(@d as date); create table t1 (d date , dt datetime , ts timestamp); insert into t1 values (9912101,9912101,9912101); insert into t1 values (11111,11111,11111); @@ -138,7 +144,7 @@ select * from t1; drop table t1; # -# Bug #30942: select str_to_date from derived table returns varying results +# Bug#30942: select str_to_date from derived table returns varying results # CREATE TABLE t1 ( a INT @@ -152,10 +158,22 @@ DROP TABLE t1; # -# Bug #31221: Optimizer incorrectly identifies impossible WHERE clause +# Bug#31221: Optimizer incorrectly identifies impossible WHERE clause # -CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b)); +CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b)); +## The current sub test could fail (difference to expected result) if we +## have just reached midnight. +## (Bug#41776 type_date.test may fail if run around midnight) +## Therefore we sleep a bit if we are too close to midnight. +## The complete test itself needs in average less than 1 second. +## Therefore a time_distance to midnight of 5 seconds should be sufficient. +if (`SELECT CURTIME() > SEC_TO_TIME(24 * 3600 - 5)`) +{ + # We are here when CURTIME() is between '23:59:56' and '23:59:59'. + # So a sleep time of 5 seconds brings us between '00:00:01' and '00:00:04'. + --real_sleep 5 +} INSERT INTO t1 VALUES (DATE(NOW()), 1); SELECT COUNT(*) FROM t1 WHERE a = NOW(); EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); @@ -171,7 +189,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); DROP TABLE t1; # -# Bug #28687: Search fails on '0000-00-00' date after sql_mode change +# Bug#28687: Search fails on '0000-00-00' date after sql_mode change # CREATE TABLE t1 (a DATE); @@ -219,3 +237,13 @@ SELECT hour(f1), minute(f1), second(f1) FROM t1; DROP TABLE t1; --echo End of 5.0 tests + +# +# Bug#32021: Using Date 000-00-01 in WHERE causes wrong result +# +create table t1 (a date, primary key (a))engine=memory; +insert into t1 values ('0000-01-01'), ('0000-00-01'), ('0001-01-01'); +select * from t1 where a between '0000-00-01' and '0000-00-02'; +drop table t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index 16a7bb66755..d4fa6bed186 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -98,7 +98,7 @@ insert into t1 values select * from t1; delete from t1; insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer"); -select * from t1; +select * from t1 order by t; drop table t1; # @@ -245,7 +245,7 @@ select least(cast('01-01-01' as date), '01-01-02') + 0; select greatest(cast('01-01-01' as date), '01-01-02') + 0; select least(cast('01-01-01' as datetime), '01-01-02') + 0; select cast(least(cast('01-01-01' as datetime), '01-01-02') as signed); -select cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(20,2)); +select cast(least(cast('01-01-01' as datetime), '01-01-02') as decimal(16,2)); --disable_warnings DROP PROCEDURE IF EXISTS test27759 ; --enable_warnings @@ -405,3 +405,44 @@ SELECT --echo End of 5.0 tests +# +# Test of storing datetime into date fields +# + +set @org_mode=@@sql_mode; +create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03'); +show create table t1; +insert into t1 values (); +insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38'); +set @@sql_mode='ansi,traditional'; +insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38'); +insert into t1 set dt='2007-03-23 13:49:38',da=dt; +# Test error handling +--error 1292 +insert into t1 values ('2007-03-32','2007-03-23 13:49:38'); +select * from t1; +drop table t1; +--error 1067 +create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '1962-03-03'); +--error 1067 +create table t1 (t time default '916:00:00 a'); +set @@sql_mode= @org_mode; + +# +# Bug #42146 - DATETIME fractional seconds parse error +# +# show we trucate microseconds from the right -- special case: leftmost is 0 +SELECT CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME) AS DECIMAL(30,7)); + +# show that we ignore leading zeroes for all other fields +SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME) AS DECIMAL(30,7)); +# once more with feeling (but no warnings) +SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME) AS DECIMAL(30,7)); + +# +# Bug #38435 - LONG Microseconds cause MySQL to fail a CAST to DATETIME or DATE +# +# show we truncate microseconds from the right +SELECT CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime) AS DECIMAL(30,7)); + +--echo End of 5.1 tests diff --git a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test index 3dedb0018b1..2043342e2c8 100644 --- a/mysql-test/t/type_enum.test +++ b/mysql-test/t/type_enum.test @@ -220,7 +220,4 @@ SELECT a FROM t1 WHERE a=0; DROP TABLE t1; - - - - +--echo End of 5.1 tests diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index a5331582df6..65bafaae77e 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -1101,6 +1101,17 @@ select * from t1; drop table t1; # +# Bug #18014: problem with 'alter table' +# + +create table t1(a decimal(7,2)); +insert into t1 values(123.12); +select * from t1; +alter table t1 modify a decimal(10,2); +select * from t1; +drop table t1; + +# # Bug#19667 group by a decimal expression yields wrong result # create table t1 (i int, j int); @@ -1123,7 +1134,6 @@ select cast(19999999999999999999 as unsigned); # # Bug #24558: Increasing decimal column length causes data loss # - create table t1(a decimal(18)); insert into t1 values(123456789012345678); alter table t1 modify column a decimal(19); @@ -1236,3 +1246,177 @@ select * from t1; DROP TABLE t1; --echo End of 5.0 tests + +# +# Bug#16172 DECIMAL data type processed incorrectly +# +select cast(143.481 as decimal(4,1)); +select cast(143.481 as decimal(4,0)); +select cast(143.481 as decimal(2,1)); +select cast(-3.4 as decimal(2,1)); +select cast(99.6 as decimal(2,0)); +select cast(-13.4 as decimal(2,1)); +select cast(98.6 as decimal(2,0)); + +--echo # +--echo # Bug #45262: Bad effects with CREATE TABLE and DECIMAL +--echo # + +CREATE TABLE t1 SELECT .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +DESCRIBE t1; +SELECT my_col FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT 1 + .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +DESCRIBE t1; +SELECT my_col FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT 1 * .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +DESCRIBE t1; +SELECT my_col FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT 1 / .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +DESCRIBE t1; +SELECT my_col FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +DESCRIBE t1; +SELECT my_col FROM t1; +DROP TABLE t1; + +--echo # +--echo # Bug#45261: Crash, stored procedure + decimal +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 SELECT + /* 81 */ 100000000000000000000000000000000000000000000000000000000000000000000000000000001 + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT + /* 81 */ 100000000000000000000000000000000000000000000000000000000000000000000000000000001. + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT + /* 81 */ 100000000000000000000000000000000000000000000000000000000000000000000000000000001.1 /* 1 */ + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT + /* 82 */ 1000000000000000000000000000000000000000000000000000000000000000000000000000000001 + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT + /* 40 */ 1000000000000000000000000000000000000001.1000000000000000000000000000000000000001 /* 40 */ + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT + /* 1 */ 1.10000000000000000000000000000000000000000000000000000000000000000000000000000001 /* 80 */ + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT + /* 1 */ 1.100000000000000000000000000000000000000000000000000000000000000000000000000000001 /* 81 */ + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT + .100000000000000000000000000000000000000000000000000000000000000000000000000000001 /* 81 */ + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT + /* 45 */ 123456789012345678901234567890123456789012345.123456789012345678901234567890123456789012345 /* 45 */ + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT + /* 65 */ 12345678901234567890123456789012345678901234567890123456789012345.1 /* 1 */ + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT + /* 66 */ 123456789012345678901234567890123456789012345678901234567890123456.1 /* 1 */ + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT + .123456789012345678901234567890123456789012345678901234567890123456 /* 66 */ + AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 AS SELECT 123.1234567890123456789012345678901 /* 31 */ AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT 1.1 + CAST(1 AS DECIMAL(65,30)) AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # Test that the integer and decimal parts are properly calculated. +--echo # + +CREATE TABLE t1 (a DECIMAL(30,30)); +INSERT INTO t1 VALUES (0.1),(0.2),(0.3); +CREATE TABLE t2 SELECT MIN(a + 0.0000000000000000000000000000001) AS c1 FROM t1; +DESC t2; +DROP TABLE t1,t2; + +CREATE TABLE t1 (a DECIMAL(30,30)); +INSERT INTO t1 VALUES (0.1),(0.2),(0.3); +CREATE TABLE t2 SELECT IFNULL(a + 0.0000000000000000000000000000001, NULL) AS c1 FROM t1; +DESC t2; +DROP TABLE t1,t2; + +CREATE TABLE t1 (a DECIMAL(30,30)); +INSERT INTO t1 VALUES (0.1),(0.2),(0.3); +CREATE TABLE t2 SELECT CASE a WHEN 0.1 THEN 0.0000000000000000000000000000000000000000000000000000000000000000001 END AS c1 FROM t1; +DESC t2; +DROP TABLE t1,t2; + +--echo # +--echo # Test that variables get maximum precision. +--echo # + +SET @decimal= 1.1; +CREATE TABLE t1 SELECT @decimal AS c1; +DESC t1; +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/t/type_ranges.test b/mysql-test/t/type_ranges.test index 03ee91f14d8..4a897c1e440 100644 --- a/mysql-test/t/type_ranges.test +++ b/mysql-test/t/type_ranges.test @@ -162,7 +162,7 @@ select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id); create table t3 (id_A integer unsigned not null, id_B integer unsigned null ); insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id ); select * from t3; -delete from t3; +truncate table t3; insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id); select * from t3; drop table t3; diff --git a/mysql-test/t/type_set.test b/mysql-test/t/type_set.test index e98555e137b..a851d116743 100644 --- a/mysql-test/t/type_set.test +++ b/mysql-test/t/type_set.test @@ -75,4 +75,23 @@ INSERT INTO t1 VALUES(9223372036854775808); SELECT * FROM t1; DROP TABLE t1; +# +# Bug #38701: Crash in String::append when inserting duplicate empty strings +# an uft8 SET col +# + +CREATE TABLE t1 ( + set_unique_utf8 set ('a','b','c','d','e','f','g','h','i','j','k','l', + 'm','n','o','p','q','r','s','t','u','v','w','x', + 'y','z') CHARACTER SET utf8, + unique (set_unique_utf8) +); + +INSERT INTO t1 ( set_unique_utf8 ) VALUES ( '' ); +--error ER_DUP_ENTRY +INSERT INTO t1 ( set_unique_utf8 ) VALUES ( '' ); + +DROP TABLE t1; + + --echo End of 5.0 tests diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index ce1d3f21ff5..e8374e0ebfc 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -44,7 +44,7 @@ drop table t1; create table t1 (ix timestamp); insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000); select ix+0 from t1; -delete from t1; +truncate table t1; insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000"); select ix+0 from t1; drop table t1; @@ -85,10 +85,10 @@ drop table t1; create table t1 (ix timestamp); insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000); select ix+0 from t1; -delete from t1; +truncate table t1; insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000"); select ix+0 from t1; -delete from t1; +truncate table t1; insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer"); select ix+0 from t1; drop table t1; @@ -189,7 +189,7 @@ insert into t1 (t1) values (default); select * from t1; show create table t1; show columns from t1; -delete from t1; +truncate table t1; # # Let us test some cases when auto-set should be disabled or influence diff --git a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test index 0aa5fb92129..9098881e379 100644 --- a/mysql-test/t/type_varchar.test +++ b/mysql-test/t/type_varchar.test @@ -3,7 +3,8 @@ drop table if exists t1, t2; --enable_warnings create table t1 (v varchar(30), c char(3), e enum('abc','def','ghi'), t text); -copy_file $MYSQL_TEST_DIR/std_data/vchar.frm $MYSQLTEST_VARDIR/master-data/test/vchar.frm; +let $MYSQLD_DATADIR= `select @@datadir`; +copy_file $MYSQL_TEST_DIR/std_data/vchar.frm $MYSQLD_DATADIR/test/vchar.frm; truncate table vchar; show create table t1; show create table vchar; @@ -25,7 +26,7 @@ select v='a' from t1; select binary v='a' from t1; select binary v='a ' from t1; insert into t1 values('a'); ---error 1062 +--error ER_DUP_ENTRY alter table t1 add primary key (v); drop table t1; create table t1 (v varbinary(20)); @@ -162,8 +163,8 @@ create table t3 ( en varchar(255) character set utf8, cz varchar(255) character set utf8 ); -remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm; -copy_file $MYSQL_TEST_DIR/std_data/14897.frm $MYSQLTEST_VARDIR/master-data/test/t3.frm; +remove_file $MYSQLD_DATADIR/test/t3.frm; +copy_file $MYSQL_TEST_DIR/std_data/14897.frm $MYSQLD_DATADIR/test/t3.frm; truncate table t3; insert into t3 (id, en, cz) values (1,'en string 1','cz string 1'), diff --git a/mysql-test/t/udf-master.opt b/mysql-test/t/udf-master.opt new file mode 100644 index 00000000000..7d8786c156a --- /dev/null +++ b/mysql-test/t/udf-master.opt @@ -0,0 +1 @@ +$UDF_EXAMPLE_LIB_OPT diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 648494b3df9..7bf252040e5 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -35,20 +35,20 @@ eval CREATE FUNCTION reverse_lookup eval CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "$UDF_EXAMPLE_LIB"; ---error 0 +--error ER_CANT_INITIALIZE_UDF select myfunc_double(); select myfunc_double(1); select myfunc_double(78654); --error 1305 select myfunc_nonexist(); select myfunc_int(); ---error 0 +--error ER_CANT_INITIALIZE_UDF select lookup(); select lookup("127.0.0.1"); ---error 0 +--error ER_CANT_INITIALIZE_UDF select lookup(127,0,0,1); select lookup("localhost"); ---error 0 +--error ER_CANT_INITIALIZE_UDF select reverse_lookup(); # These two functions should return "localhost", but it's @@ -59,9 +59,9 @@ select reverse_lookup(127,0,0,1); --enable_result_log select reverse_lookup("localhost"); ---error 0 +--error ER_CANT_INITIALIZE_UDF select avgcost(); ---error 0 +--error ER_CANT_INITIALIZE_UDF select avgcost(100,23.76); create table t1(sum int, price float(24)); insert into t1 values(100, 50.00), (100, 100.00); @@ -149,9 +149,9 @@ EXPLAIN EXTENDED SELECT myfunc_int(a AS attr_name) FROM t1; EXPLAIN EXTENDED SELECT myfunc_int(a) FROM t1; SELECT a,c FROM v1; ---error ER_PARSE_ERROR +--error ER_WRONG_PARAMETERS_TO_STORED_FCT SELECT a, fn(MIN(b) xx) as c FROM t1 GROUP BY a; ---error ER_PARSE_ERROR +--error ER_WRONG_PARAMETERS_TO_STORED_FCT SELECT myfunc_int(fn(MIN(b) xx)) as c FROM t1 GROUP BY a; --error ER_PARSE_ERROR SELECT myfunc_int(test.fn(MIN(b) xx)) as c FROM t1 GROUP BY a; @@ -174,6 +174,59 @@ DROP FUNCTION fn; --echo End of 5.0 tests. # +# Bug#24736: UDF functions parsed as Stored Functions +# + +select myfunc_double(3); +select myfunc_double(3 AS three); +select myfunc_double(abs(3)); +select myfunc_double(abs(3) AS named_param); +select abs(myfunc_double(3)); +select abs(myfunc_double(3 AS three)); + +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select myfunc_double(abs(3 AS wrong)); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select abs(myfunc_double(3) AS wrong); + +# +# BUG#18239: Possible to overload internal functions with stored functions +# + +--disable_warnings +drop function if exists pi; +--enable_warnings + +--error ER_NATIVE_FCT_NAME_COLLISION +CREATE FUNCTION pi RETURNS STRING SONAME "should_not_parse.so"; + +# Verify that Stored Functions and UDF are mutually exclusive +DROP FUNCTION IF EXISTS metaphon; + +CREATE FUNCTION metaphon(a int) RETURNS int +return 0; + +# this currently passes, and eclipse the stored function +--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; + +DROP FUNCTION metaphon; +DROP FUNCTION metaphon; + +--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; + +--error ER_UDF_EXISTS +CREATE FUNCTION metaphon(a int) RETURNS int +return 0; + +--error ER_UDF_EXISTS +CREATE FUNCTION test.metaphon(a int) RETURNS int +return 0; + +# End of Bug#18239 + +# # Drop the example functions from udf_example # @@ -383,4 +436,16 @@ SELECT * FROM t2 WHERE a = sequence(); DROP FUNCTION sequence; DROP TABLE t1,t2; +--echo # +--echo # Bug#46259: 5.0.83 -> 5.1.36, query doesn't work +--echo # +CREATE TABLE t1 ( a INT ); + +INSERT INTO t1 VALUES (1), (2), (3); + +SELECT IF( a = 1, a, a ) AS `b` FROM t1 ORDER BY field( `b` + 1, 1 ); +SELECT IF( a = 1, a, a ) AS `b` FROM t1 ORDER BY field( `b`, 1 ); + +DROP TABLE t1; + --echo End of 5.0 tests. diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 0c8e025e54e..ec169838d59 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -91,6 +91,88 @@ SELECT @a:=1 UNION SELECT @a:=@a+1; (SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a); (SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2); + +# +# Bug#32858: Erro: "Incorrect usage of UNION and INTO" does not take subselects +# into account +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); + +SELECT a INTO @v FROM ( + SELECT a FROM t1 + UNION + SELECT a FROM t1 +) alias; + +--let $outfile = $MYSQLTEST_VARDIR/tmp/union.out.file +--error 0,1 +--remove_file $outfile + +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval SELECT a INTO OUTFILE '$outfile' FROM ( + SELECT a FROM t1 + UNION + SELECT a FROM t1 WHERE 0 +) alias; +--remove_file $outfile + +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval SELECT a INTO DUMPFILE '$outfile' FROM ( + SELECT a FROM t1 + UNION + SELECT a FROM t1 WHERE 0 +) alias; +--remove_file $outfile + +# +# INTO will not be allowed in subqueries in version 5.1 and above. +# +SELECT a FROM ( + SELECT a FROM t1 + UNION + SELECT a INTO @v FROM t1 +) alias; + +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval SELECT a FROM ( + SELECT a FROM t1 + UNION + SELECT a INTO OUTFILE '$outfile' FROM t1 +) alias; +--remove_file $outfile + +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval SELECT a FROM ( + SELECT a FROM t1 + UNION + SELECT a INTO DUMPFILE '$outfile' FROM t1 +) alias; +--remove_file $outfile + +SELECT a FROM t1 UNION SELECT a INTO @v FROM t1; + +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval SELECT a FROM t1 UNION SELECT a INTO OUTFILE '$outfile' FROM t1; +--remove_file $outfile + +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +eval SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '$outfile' FROM t1; +--remove_file $outfile + +--error ER_WRONG_USAGE +SELECT a INTO @v FROM t1 UNION SELECT a FROM t1; + +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +--error ER_WRONG_USAGE +eval SELECT a INTO OUTFILE '$outfile' FROM t1 UNION SELECT a FROM t1; + +--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> +--error ER_WRONG_USAGE +eval SELECT a INTO DUMPFILE '$outfile' FROM t1 UNION SELECT a FROM t1; + +DROP TABLE t1; + # # Test bug reported by joc@presence-pc.com # @@ -774,6 +856,7 @@ drop table t1,t2; # # correct conversion long string to TEXT (BUG#10025) # + CREATE TABLE t1 (a mediumtext); CREATE TABLE t2 (b varchar(20)); INSERT INTO t1 VALUES ('a'),('b'); @@ -783,6 +866,54 @@ show create table t3; drop tables t1,t2,t3; # +# Extended fix to Bug#10025 - the test above should result to mediumtext +# and the one below to longtext. Earlier above test resulted to longtext +# type also. +# + +CREATE TABLE t1 (a longtext); +CREATE TABLE t2 (b varchar(20)); +INSERT INTO t1 VALUES ('a'),('b'); +SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2; +create table t3 SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2; +show create table t3; +drop tables t1,t2,t3; + +# +# Testing here that mediumtext converts into longtext if the result +# exceeds mediumtext maximum length +# + +SELECT @tmp_max:= @@global.max_allowed_packet; +SET @@global.max_allowed_packet=25000000; +# switching connection to allow the new max_allowed_packet take effect +--connect (newconn, localhost, root,,) +CREATE TABLE t1 (a mediumtext); +CREATE TABLE t2 (b varchar(20)); +INSERT INTO t1 VALUES ('a'); +CREATE TABLE t3 SELECT REPEAT(a,20000000) AS a FROM t1 UNION SELECT b FROM t2; +SHOW CREATE TABLE t3; +DROP TABLES t1,t3; +CREATE TABLE t1 (a tinytext); +INSERT INTO t1 VALUES ('a'); +CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2; +SHOW CREATE TABLE t3; +DROP TABLES t1,t3; +CREATE TABLE t1 (a mediumtext); +INSERT INTO t1 VALUES ('a'); +CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2; +SHOW CREATE TABLE t3; +DROP TABLES t1,t3; +CREATE TABLE t1 (a tinyblob); +INSERT INTO t1 VALUES ('a'); +CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2; +SHOW CREATE TABLE t3; +DROP TABLES t1,t2,t3; +--connection default +SET @@global.max_allowed_packet:= @tmp_max; +--disconnect newconn + +# # Bug #10032 Bug in parsing UNION with ORDER BY when one node does not use FROM # @@ -921,86 +1052,6 @@ SELECT 1,1; DROP TABLE t1,t2; -# Bug#32858: Erro: "Incorrect usage of UNION and INTO" does not take subselects -# into account -# -CREATE TABLE t1 (a INT); -INSERT INTO t1 VALUES (1); - -SELECT a INTO @v FROM ( - SELECT a FROM t1 - UNION - SELECT a FROM t1 -) alias; - ---let $outfile = $MYSQLTEST_VARDIR/tmp/union.out.file ---error 0,1 ---remove_file $outfile - ---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> -eval SELECT a INTO OUTFILE '$outfile' FROM ( - SELECT a FROM t1 - UNION - SELECT a FROM t1 WHERE 0 -) alias; ---remove_file $outfile - ---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> -eval SELECT a INTO DUMPFILE '$outfile' FROM ( - SELECT a FROM t1 - UNION - SELECT a FROM t1 WHERE 0 -) alias; ---remove_file $outfile - -# -# INTO will not be allowed in subqueries in version 5.1 and above. -# -SELECT a FROM ( - SELECT a FROM t1 - UNION - SELECT a INTO @v FROM t1 -) alias; - ---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> -eval SELECT a FROM ( - SELECT a FROM t1 - UNION - SELECT a INTO OUTFILE '$outfile' FROM t1 -) alias; ---remove_file $outfile - ---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> -eval SELECT a FROM ( - SELECT a FROM t1 - UNION - SELECT a INTO DUMPFILE '$outfile' FROM t1 -) alias; ---remove_file $outfile - -SELECT a FROM t1 UNION SELECT a INTO @v FROM t1; - ---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> -eval SELECT a FROM t1 UNION SELECT a INTO OUTFILE '$outfile' FROM t1; ---remove_file $outfile - ---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> -eval SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '$outfile' FROM t1; ---remove_file $outfile - ---error ER_WRONG_USAGE -SELECT a INTO @v FROM t1 UNION SELECT a FROM t1; - ---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> ---error ER_WRONG_USAGE -eval SELECT a INTO OUTFILE '$outfile' FROM t1 UNION SELECT a FROM t1; - ---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> ---error ER_WRONG_USAGE -eval SELECT a INTO DUMPFILE '$outfile' FROM t1 UNION SELECT a FROM t1; - -DROP TABLE t1; - # Bug#32848: Data type conversion bug in union subselects in MySQL 5.0.38 # CREATE TABLE t1 (a INT); diff --git a/mysql-test/t/unsafe_binlog_innodb-master.opt b/mysql-test/t/unsafe_binlog_innodb-master.opt new file mode 100644 index 00000000000..9581c225d6d --- /dev/null +++ b/mysql-test/t/unsafe_binlog_innodb-master.opt @@ -0,0 +1 @@ +--innodb_locks_unsafe_for_binlog=true --innodb_lock_wait_timeout=1 diff --git a/mysql-test/t/unsafe_binlog_innodb.test b/mysql-test/t/unsafe_binlog_innodb.test new file mode 100644 index 00000000000..a0516749451 --- /dev/null +++ b/mysql-test/t/unsafe_binlog_innodb.test @@ -0,0 +1,16 @@ +# t/unsafe_binlog_innodb.test +# +# Note that this test uses at least in case of InnoDB options +# innodb_locks_unsafe_for_binlog = true +# innodb_lock_timeout = 5 +# +# Last update: +# 2006-08-02 ML test refactored +# old name was innodb_unsafe_binlog.test +# main code went into include/unsafe_binlog.inc +# + +--source include/have_innodb.inc +let $engine_type= InnoDB; + +--source include/unsafe_binlog.inc diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index f79c9e773aa..02e8763a630 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -430,4 +430,40 @@ drop table t1,t2; connection default; disconnect con1; +# +# Bug #40745: Error during WHERE clause calculation in UPDATE +# leads to an assertion failure +# +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +--enable_warnings + +CREATE FUNCTION f1() RETURNS INT RETURN f1(); +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1); + +--error ER_SP_NO_RECURSION +UPDATE t1 SET i = 3 WHERE f1(); +--error ER_SP_NO_RECURSION +UPDATE t1 SET i = f1(); + +DROP TABLE t1; +DROP FUNCTION f1; + --echo End of 5.0 tests + +--echo # +--echo # Bug #47919 assert in open_table during ALTER temporary table +--echo # + +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1)); +CREATE TEMPORARY TABLE t2 LIKE t1; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +ALTER TABLE t2 COMMENT = 'ABC'; +UPDATE t2, t1 SET t2.f1 = 2, t1.f1 = 9; +ALTER TABLE t2 COMMENT = 'DEF'; + +DROP TABLE t1, t2; diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test new file mode 100644 index 00000000000..e390e8a1253 --- /dev/null +++ b/mysql-test/t/upgrade.test @@ -0,0 +1,139 @@ +-- source include/not_embedded.inc + +--disable_warnings +drop database if exists `mysqltest1`; +drop database if exists `mysqltest-1`; +drop database if exists `#mysql50#mysqltest-1`; +--enable_warnings + +create database `mysqltest1`; +create database `#mysql50#mysqltest-1`; +create table `mysqltest1`.`t1` (a int); +create table `mysqltest1`.`#mysql50#t-1` (a int); +create table `#mysql50#mysqltest-1`.`t1` (a int); +create table `#mysql50#mysqltest-1`.`#mysql50#t-1` (a int); +show create database `mysqltest1`; +--error 1049 +show create database `mysqltest-1`; +show create database `#mysql50#mysqltest-1`; +show tables in `mysqltest1`; +show tables in `#mysql50#mysqltest-1`; + +--exec $MYSQL_CHECK --all-databases --fix-db-names --fix-table-names + +show create database `mysqltest1`; +show create database `mysqltest-1`; +--error 1049 +show create database `#mysql50#mysqltest-1`; +show tables in `mysqltest1`; +show tables in `mysqltest-1`; +drop database `mysqltest1`; +drop database `mysqltest-1`; + +# +# Bug#17142: Crash if create with encoded name +# +--disable_warnings +drop table if exists `txu@0023p@0023p1`; +drop table if exists `txu#p#p1`; +--enable_warnings +create table `txu#p#p1` (s1 int); +insert into `txu#p#p1` values (1); +--error 1146 +select * from `txu@0023p@0023p1`; +create table `txu@0023p@0023p1` (s1 int); +insert into `txu@0023p@0023p1` values (2); +select * from `txu@0023p@0023p1`; +select * from `txu#p#p1`; +drop table `txu@0023p@0023p1`; +drop table `txu#p#p1`; + +--echo # +--echo # Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1 +--echo # +--echo # copy table created using mysql4.0 into the data dir +let $MYSQLD_DATADIR= `SELECT @@datadir`; +copy_file std_data/bug37631.frm $MYSQLD_DATADIR/test/t1.frm; +copy_file std_data/bug37631.MYD $MYSQLD_DATADIR/test/t1.MYD; +copy_file std_data/bug37631.MYI $MYSQLD_DATADIR/test/t1.MYI; +--echo # check the table created using mysql 4.0 +CHECK TABLE t1; +--echo # query the table created using mysql 4.0 +SELECT * FROM t1; +DROP TABLE t1; + +# +# Check if old tables work +# + +let $MYSQLD_DATADIR= `select @@datadir`; +--error 0,1 +--remove_file $MYSQLD_DATADIR/test/t1.frm +--copy_file std_data/old_table-323.frm $MYSQLD_DATADIR/test/t1.frm +truncate t1; +drop table t1; + +# +# Bug#28360 (RENAME DATABASE destroys routines) +# + +--disable_warnings +drop database if exists `tabc`; +drop database if exists `a-b-c`; +--enable_warnings + +create database `tabc` default character set latin2; +create table tabc.t1 (a int); +FLUSH TABLES; + +# Manually make a 5.0 database from the template +--mkdir $MYSQLD_DATADIR/a-b-c +--copy_file $MYSQLD_DATADIR/tabc/db.opt $MYSQLD_DATADIR/a-b-c/db.opt +--copy_file $MYSQLD_DATADIR/tabc/t1.frm $MYSQLD_DATADIR/a-b-c/t1.frm +--copy_file $MYSQLD_DATADIR/tabc/t1.MYD $MYSQLD_DATADIR/a-b-c/t1.MYD +--copy_file $MYSQLD_DATADIR/tabc/t1.MYI $MYSQLD_DATADIR/a-b-c/t1.MYI + +show databases like '%a-b-c%'; +ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME; +# The physical directory name is now a@002db@002dc, the logical name still a-b-c +show databases like '%a-b-c%'; +show create database `a-b-c`; +show tables in `a-b-c`; +show create table `a-b-c`.`t1`; +drop database `a-b-c`; +drop database `tabc`; + +# +# Bug#43385 Cannot ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME when Views exist +# +let $MYSQLD_DATADIR= `select @@datadir`; +--mkdir $MYSQLD_DATADIR/a-b-c +use `#mysql50#a-b-c`; +create table t1(f1 char(10)); + +--write_file $MYSQLD_DATADIR/a-b-c/v1.frm +TYPE=VIEW +query=select `a`.`f1` AS `f1` from `a-b-c`.`t1` `a` join `information_schema`.`tables` `b` where (convert(`a`.`f1` using utf8) = `b`.`TABLE_NAME`) +md5=068271f1c657fe115e497856ca0fa493 +updatable=0 +algorithm=0 +definer_user=root +definer_host=localhost +suid=2 +with_check_option=0 +timestamp=2009-04-10 11:53:37 +create-version=1 +source=select f1 from `a-b-c`.t1 a, information_schema.tables b\nwhere a.f1 = b.table_name +client_cs_name=utf8 +connection_cl_name=utf8_general_ci +EOF + +show databases like '%a-b-c%'; +ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME; +show databases like '%a-b-c%'; +show create view `a-b-c`.v1; +--disable_ps_protocol +select * from `a-b-c`.v1; +--enable_ps_protocol +drop database `a-b-c`; +use test; diff --git a/mysql-test/t/user_var-binlog.test b/mysql-test/t/user_var-binlog.test index 57bf9df2fb0..0098f237de9 100644 --- a/mysql-test/t/user_var-binlog.test +++ b/mysql-test/t/user_var-binlog.test @@ -1,4 +1,6 @@ --- source include/have_log_bin.inc +# Requires statement logging +-- source include/have_binlog_format_mixed_or_statement.inc +# TODO: Create row based version once $MYSQL_BINLOG has new RB version # Check that user variables are binlogged correctly (BUG#3875) create table t1 (a varchar(50)); @@ -9,12 +11,14 @@ INSERT INTO t1 VALUES(@`a b`); set @var1= "';aaa"; SET @var2=char(ascii('a')); insert into t1 values (@var1),(@var2); -show binlog events from 98; +source include/show_binlog_events.inc; + # more important than SHOW BINLOG EVENTS, mysqlbinlog (where we # absolutely need variables names to be quoted and strings to be # escaped). ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 +let $MYSQLD_DATADIR= `select @@datadir`; +flush logs; +--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000001 drop table t1; # End of 4.1 tests diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index d39b49a0e87..c0740458a88 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -239,6 +239,53 @@ select @a:=f4, count(f4) from t1 group by 1 desc; drop table t1; # +# Bug#32482: Crash for a query with ORDER BY a user variable. +# +create table t1 (f1 int); +insert into t1 values (2), (1); +select @i := f1 as j from t1 order by 1; +drop table t1; +# Bug #32260: User variables in query cause server crash +# +create table t1(a int); +insert into t1 values(5),(4),(4),(3),(2),(2),(2),(1); +set @rownum := 0; +set @rank := 0; +set @prev_score := NULL; +# Disable the result log as we assign a value to a user variable in one part +# of a statement and use the same variable in other part of the same statement, +# so we can get unexpected results. +--disable_result_log +select @rownum := @rownum + 1 as row, + @rank := IF(@prev_score!=a, @rownum, @rank) as rank, + @prev_score := a as score +from t1 order by score desc; +--enable_result_log +drop table t1; + +# +# Bug#26020: User-Defined Variables are not consistent with columns data types +# + +create table t1(b bigint); +insert into t1 (b) values (10), (30), (10); +set @var := 0; +select if(b=@var, 999, b) , @var := b from t1 order by b; +drop table t1; + +create temporary table t1 (id int); +insert into t1 values (2), (3), (3), (4); +set @lastid=-1; +select @lastid != id, @lastid, @lastid := id from t1; +drop table t1; + +create temporary table t1 (id bigint); +insert into t1 values (2), (3), (3), (4); +set @lastid=-1; +select @lastid != id, @lastid, @lastid := id from t1; +drop table t1; + +# # Bug#42009: SELECT into variable gives different results to direct SELECT # CREATE TABLE t1(a INT, b INT); @@ -249,3 +296,16 @@ SELECT a, b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; DROP TABLE t1; --echo End of 5.0 tests + +# +# Bug#42188: crash and/or memory corruption with user variables in trigger +# + +CREATE TABLE t1 (i INT); +CREATE TRIGGER t_after_insert AFTER INSERT ON t1 FOR EACH ROW SET @bug42188 = 10; +INSERT INTO t1 VALUES (1); +--change_user root,,test +INSERT INTO t1 VALUES (1); +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/utils.sh b/mysql-test/t/utils.sh deleted file mode 100644 index b3f4744947d..00000000000 --- a/mysql-test/t/utils.sh +++ /dev/null @@ -1,55 +0,0 @@ -########################################################################### -# -# This file provides utility functions and is included by other scripts. -# -# The following global variables must be set before calling functions from this -# file: -# - basename -- base name of the calling script (main application); -# - log_file -- where to store log records; -# -########################################################################### - -log() -{ - [ -z "$log_file" ] && return; - - log_level="$1" - log_msg="$2" - ts=`date` - - echo "[$ts] [$basename] [$log_level] $log_msg" >> "$log_file"; -} - -########################################################################### - -log_debug() -{ - log 'DEBUG' "$1" -} - -########################################################################### - -log_info() -{ - log 'INFO' "$1" - echo "$1" -} - -########################################################################### - -log_error() -{ - log 'ERROR' "$1" - echo "Error: $1" -} - -########################################################################### - -quit() -{ - exit_status="$1" - - log_debug "-- $basename: finished (exit_status: $exit_status) --" - - exit $exit_status -} diff --git a/mysql-test/t/varbinary.test b/mysql-test/t/varbinary.test index a53a3b8d5b4..1f9f7b5412d 100644 --- a/mysql-test/t/varbinary.test +++ b/mysql-test/t/varbinary.test @@ -47,12 +47,13 @@ drop table t1; # # Test with a saved table from 4.1 -copy_file std_data/bug19371.frm $MYSQLTEST_VARDIR/master-data/test/t1.frm; -chmod 0777 $MYSQLTEST_VARDIR/master-data/test/t1.frm; -copy_file std_data/bug19371.MYD $MYSQLTEST_VARDIR/master-data/test/t1.MYD; -chmod 0777 $MYSQLTEST_VARDIR/master-data/test/t1.MYD; -copy_file std_data/bug19371.MYI $MYSQLTEST_VARDIR/master-data/test/t1.MYI; -chmod 0777 $MYSQLTEST_VARDIR/master-data/test/t1.MYI; +let $MYSQLD_DATADIR= `select @@datadir`; +copy_file std_data/bug19371.frm $MYSQLD_DATADIR/test/t1.frm; +chmod 0777 $MYSQLD_DATADIR/test/t1.frm; +copy_file std_data/bug19371.MYD $MYSQLD_DATADIR/test/t1.MYD; +chmod 0777 $MYSQLD_DATADIR/test/t1.MYD; +copy_file std_data/bug19371.MYI $MYSQLD_DATADIR/test/t1.MYI; +chmod 0777 $MYSQLD_DATADIR/test/t1.MYI; # Everything _looks_ fine show create table t1; @@ -85,6 +86,25 @@ alter table t1 modify a varchar(255); select length(a) from t1; drop table t1; + +# +# Bug#28127 (Some valid identifiers names are not parsed correctly) +# + +--disable_warnings +drop table if exists table_28127_a; +drop table if exists table_28127_b; +--enable_warnings + +create table table_28127_a(0b02 int); +show create table table_28127_a; + +create table table_28127_b(0b2 int); +show create table table_28127_b; + +drop table table_28127_a; +drop table table_28127_b; + # # Bug#35658 (An empty binary value leads to mysqld crash) # diff --git a/mysql-test/t/information_schema_community.test b/mysql-test/t/variables+c.test index d150e0bbb8b..0092d34133d 100644 --- a/mysql-test/t/information_schema_community.test +++ b/mysql-test/t/variables+c.test @@ -1,4 +1,4 @@ --- source include/have_community_features.inc +--source include/have_community_features.inc # # Bug#24822: Patch: uptime_since_flush_status @@ -9,5 +9,3 @@ flush status; --replace_column 2 # show global status like "Uptime_%"; # Almost certainly zero ---echo End of 5.0 tests. - diff --git a/mysql-test/t/variables-notembedded-master.opt b/mysql-test/t/variables-notembedded-master.opt new file mode 100644 index 00000000000..8a173a043ac --- /dev/null +++ b/mysql-test/t/variables-notembedded-master.opt @@ -0,0 +1 @@ +--loose-slave-skip-errors=3,100,137,0,643,1752 diff --git a/mysql-test/t/variables-notembedded.test b/mysql-test/t/variables-notembedded.test new file mode 100644 index 00000000000..7cc068c68c7 --- /dev/null +++ b/mysql-test/t/variables-notembedded.test @@ -0,0 +1,111 @@ +# Tests that variables work correctly (setting and showing). This +# test is like the main.variables test, but for variables not +# available in embedded mode. + +source include/not_embedded.inc; + +--echo ---- Init ---- +# Backup global variables so they can be restored at end of test. +set @my_slave_net_timeout =@@global.slave_net_timeout; + +--echo ---- Test ---- +set global slave_net_timeout=100; +set global sql_slave_skip_counter=100; + +# End of 4.1 tests + +# BUG #7800: Add various-slave related variables to SHOW VARIABLES +show variables like 'slave_compressed_protocol'; +--replace_column 2 SLAVE_LOAD_TMPDIR +show variables like 'slave_load_tmpdir'; +# We just set some arbitrary values in variables-master.opt so we can test +# that a list of values works correctly +show variables like 'slave_skip_errors'; + +--echo ---- Clean Up ---- + +set global slave_net_timeout=default; +# sql_slave_skip_counter is write-only, so we can't save previous +# value and restore it here. That's ok, because it's normally 0. +set global sql_slave_skip_counter= 0; +set @@global.slave_net_timeout= @my_slave_net_timeout; + +# +# Bug#28234 - global/session scope - documentation vs implementation +# +--echo +# +# Additional variables fixed from sql_repl.cc. +# +--echo # +SHOW VARIABLES like 'log_slave_updates'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.log_slave_updates; +SELECT @@global.log_slave_updates; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.log_slave_updates= true; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.log_slave_updates= true; +# +--echo # +SHOW VARIABLES like 'relay_log'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.relay_log; +SELECT @@global.relay_log; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.relay_log= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.relay_log= 'x'; +# +--echo # +SHOW VARIABLES like 'relay_log_index'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.relay_log_index; +SELECT @@global.relay_log_index; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.relay_log_index= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.relay_log_index= 'x'; +# +--echo # +SHOW VARIABLES like 'relay_log_info_file'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.relay_log_info_file; +SELECT @@global.relay_log_info_file; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.relay_log_info_file= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.relay_log_info_file= 'x'; +# +--echo # +SHOW VARIABLES like 'relay_log_space_limit'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.relay_log_space_limit; +SELECT @@global.relay_log_space_limit; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.relay_log_space_limit= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.relay_log_space_limit= 7; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'slave_load_tmpdir'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.slave_load_tmpdir; +--replace_column 1 # +SELECT @@global.slave_load_tmpdir; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.slave_load_tmpdir= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.slave_load_tmpdir= 'x'; +# +--echo # +SHOW VARIABLES like 'slave_skip_errors'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.slave_skip_errors; +SELECT @@global.slave_skip_errors; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.slave_skip_errors= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.slave_skip_errors= 7; +# diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 91f75cf6cd4..1580d7f36d7 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -18,13 +18,13 @@ set @my_key_buffer_size =@@global.key_buffer_size; set @my_max_binlog_cache_size =@@global.max_binlog_cache_size; set @my_max_binlog_size =@@global.max_binlog_size; set @my_max_connect_errors =@@global.max_connect_errors; +set @my_max_connections =@@global.max_connections; set @my_max_delayed_threads =@@global.max_delayed_threads; set @my_max_heap_table_size =@@global.max_heap_table_size; set @my_max_insert_delayed_threads=@@global.max_insert_delayed_threads; set @my_max_join_size =@@global.max_join_size; -set @my_max_user_connections =@@global.max_user_connections; -set @my_max_write_lock_count =@@global.max_write_lock_count; set @my_myisam_data_pointer_size =@@global.myisam_data_pointer_size; +set @my_myisam_max_sort_file_size =@@global.myisam_max_sort_file_size; set @my_net_buffer_length =@@global.net_buffer_length; set @my_net_write_timeout =@@global.net_write_timeout; set @my_net_read_timeout =@@global.net_read_timeout; @@ -35,7 +35,8 @@ set @my_server_id =@@global.server_id; set @my_slow_launch_time =@@global.slow_launch_time; set @my_storage_engine =@@global.storage_engine; set @my_thread_cache_size =@@global.thread_cache_size; - +set @my_max_allowed_packet =@@global.max_allowed_packet; +set @my_join_buffer_size =@@global.join_buffer_size; # case insensitivity tests (new in 5.0) set @`test`=1; select @test, @`test`, @TEST, @`TEST`, @"teSt"; @@ -83,16 +84,24 @@ drop table t1; set GLOBAL max_join_size=10; set max_join_size=100; show variables like 'max_join_size'; +select * from information_schema.session_variables where variable_name like 'max_join_size'; --replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR show global variables like 'max_join_size'; +--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR +select * from information_schema.global_variables where variable_name like 'max_join_size'; set GLOBAL max_join_size=2000; show global variables like 'max_join_size'; +select * from information_schema.global_variables where variable_name like 'max_join_size'; set max_join_size=DEFAULT; --replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR show variables like 'max_join_size'; +--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR +select * from information_schema.session_variables where variable_name like 'max_join_size'; set GLOBAL max_join_size=DEFAULT; --replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR show global variables like 'max_join_size'; +--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR +select * from information_schema.global_variables where variable_name like 'max_join_size'; set @@max_join_size=1000, @@global.max_join_size=2000; select @@local.max_join_size, @@global.max_join_size; select @@identity, length(@@version)>0; @@ -106,55 +115,66 @@ set big_tables=OFF, big_tables=ON, big_tables=0, big_tables=1, big_tables="OFF", set global concurrent_insert=2; show variables like 'concurrent_insert'; +select * from information_schema.session_variables where variable_name like 'concurrent_insert'; set global concurrent_insert=1; show variables like 'concurrent_insert'; +select * from information_schema.session_variables where variable_name like 'concurrent_insert'; set global concurrent_insert=0; show variables like 'concurrent_insert'; +select * from information_schema.session_variables where variable_name like 'concurrent_insert'; set global concurrent_insert=DEFAULT; select @@concurrent_insert; set global timed_mutexes=ON; show variables like 'timed_mutexes'; +select * from information_schema.session_variables where variable_name like 'timed_mutexes'; set global timed_mutexes=0; show variables like 'timed_mutexes'; +select * from information_schema.session_variables where variable_name like 'timed_mutexes'; set storage_engine=MYISAM, storage_engine="HEAP", global storage_engine="MERGE"; show local variables like 'storage_engine'; +select * from information_schema.session_variables where variable_name like 'storage_engine'; show global variables like 'storage_engine'; +select * from information_schema.global_variables where variable_name like 'storage_engine'; set GLOBAL query_cache_size=100000; set GLOBAL myisam_max_sort_file_size=2000000; show global variables like 'myisam_max_sort_file_size'; +select * from information_schema.global_variables where variable_name like 'myisam_max_sort_file_size'; set GLOBAL myisam_max_sort_file_size=default; --replace_result 9223372036853727232 FILE_SIZE 2146435072 FILE_SIZE show global variables like 'myisam_max_sort_file_size'; +--replace_result 9223372036853727232 FILE_SIZE 2146435072 FILE_SIZE +select * from information_schema.global_variables where variable_name like 'myisam_max_sort_file_size'; +# bug#22891: modified to take read-only SESSION net_buffer_length into account set global net_retry_count=10, session net_retry_count=10; set global net_buffer_length=1024, net_write_timeout=200, net_read_timeout=300; -set session net_write_timeout=500, net_read_timeout=600; show global variables like 'net_%'; +select * from information_schema.global_variables where variable_name like 'net_%' order by 1; show session variables like 'net_%'; -set global net_buffer_length=8000, net_read_timeout=900, net_write_timeout=1000; +select * from information_schema.session_variables where variable_name like 'net_%' order by 1; +set global net_buffer_length=8000, global net_read_timeout=900, net_write_timeout=1000; show global variables like 'net_%'; -show session variables like 'net_%'; +select * from information_schema.global_variables where variable_name like 'net_%' order by 1; set global net_buffer_length=1; show global variables like 'net_buffer_length'; +select * from information_schema.global_variables where variable_name like 'net_buffer_length'; #warning 1292 set global net_buffer_length=2000000000; show global variables like 'net_buffer_length'; - ---error ER_UNKNOWN_ERROR -set session net_buffer_length=1024; ---error ER_UNKNOWN_ERROR -set session max_allowed_packet=1024; +select * from information_schema.global_variables where variable_name like 'net_buffer_length'; set character set cp1251_koi8; show variables like "character_set_client"; +select * from information_schema.session_variables where variable_name like 'character_set_client'; select @@timestamp>0; set @@rand_seed1=10000000,@@rand_seed2=1000000; select ROUND(RAND(),5); + --echo --echo ==+ Testing %alloc% system variables +== --echo ==+ NOTE: These values *must* be a multiple of 1024 +== @@ -164,7 +184,12 @@ select ROUND(RAND(),5); SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size', 'query_alloc_block_size', 'query_prealloc_size', 'transaction_alloc_block_size', 'transaction_prealloc_size'); ---echo ==+ Manipulate variable values += + +--echo ==+ information_schema data +== +SELECT * FROM information_schema.session_variables +WHERE variable_name IN ('range_alloc_block_size', +'query_alloc_block_size', 'query_prealloc_size', +'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1; --echo Testing values that are multiples of 1024 set @@range_alloc_block_size=1024*15+1024; set @@query_alloc_block_size=1024*15+1024*2; @@ -172,9 +197,15 @@ set @@query_prealloc_size=1024*18-1024; set @@transaction_alloc_block_size=1024*21-1024*1; set @@transaction_prealloc_size=1024*21-2048; --echo ==+ Check manipulated values ==+ +select @@query_alloc_block_size; SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size', 'query_alloc_block_size', 'query_prealloc_size', 'transaction_alloc_block_size', 'transaction_prealloc_size'); +--echo ==+ information_schema data +== +SELECT * FROM information_schema.session_variables +WHERE variable_name IN ('range_alloc_block_size', +'query_alloc_block_size', 'query_prealloc_size', +'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1; --echo ==+ Manipulate variable values +== --echo Testing values that are not 1024 multiples set @@range_alloc_block_size=1024*16+1023; @@ -187,6 +218,11 @@ select @@query_alloc_block_size; SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size', 'query_alloc_block_size', 'query_prealloc_size', 'transaction_alloc_block_size', 'transaction_prealloc_size'); +--echo ==+ information_schema data +== +SELECT * FROM information_schema.session_variables +WHERE variable_name IN ('range_alloc_block_size', +'query_alloc_block_size', 'query_prealloc_size', +'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1; --echo ==+ Set values back to the default values +== set @@range_alloc_block_size=default; set @@query_alloc_block_size=default, @@query_prealloc_size=default; @@ -275,7 +311,10 @@ set interactive_timeout=100; set join_buffer_size=100; set last_insert_id=1; set global local_infile=1; -set long_query_time=100; +set long_query_time=0.000001; +select @@long_query_time; +set long_query_time=100.000001; +select @@long_query_time; set low_priority_updates=1; set global max_allowed_packet=100; set global max_binlog_cache_size=100; @@ -326,7 +365,7 @@ set sql_select_limit=1; # reset it, so later tests don't get confused set sql_select_limit=default; set sql_warnings=1; -set global table_cache=100; +set global table_open_cache=100; set storage_engine=myisam; set global thread_cache_size=100; set timestamp=1, timestamp=default; @@ -334,6 +373,7 @@ set tmp_table_size=100; set tx_isolation="READ-COMMITTED"; set wait_timeout=100; set log_warnings=1; +set global log_warnings=1; # # Bugs: #20392: INSERT_ID session variable has weird value @@ -397,6 +437,8 @@ set global ft_boolean_syntax = @@init_connect; set global myisam_max_sort_file_size=4294967296; --replace_result 4294967296 MAX_FILE_SIZE 2146435072 MAX_FILE_SIZE show global variables like 'myisam_max_sort_file_size'; +--replace_result 4294967296 MAX_FILE_SIZE 2146435072 MAX_FILE_SIZE +select * from information_schema.global_variables where variable_name like 'myisam_max_sort_file_size'; set global myisam_max_sort_file_size=default; # @@ -432,12 +474,16 @@ SELECT @@global.local.key_buffer_size; # BUG#5135: cannot turn on log_warnings with SET in 4.1 (and 4.0) set @tstlw = @@log_warnings; show global variables like 'log_warnings'; +select * from information_schema.global_variables where variable_name like 'log_warnings'; set global log_warnings = 0; show global variables like 'log_warnings'; +select * from information_schema.global_variables where variable_name like 'log_warnings'; set global log_warnings = 42; show global variables like 'log_warnings'; +select * from information_schema.global_variables where variable_name like 'log_warnings'; set global log_warnings = @tstlw; show global variables like 'log_warnings'; +select * from information_schema.global_variables where variable_name like 'log_warnings'; # # BUG#4788 show create table provides incorrect statement @@ -469,14 +515,16 @@ drop table t1; SET GLOBAL MYISAM_DATA_POINTER_SIZE= 7; SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE'; +SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'MYISAM_DATA_POINTER_SIZE'; # # Bug #6958: negative arguments to integer options wrap around # -SET GLOBAL table_cache=-1; -SHOW VARIABLES LIKE 'table_cache'; -SET GLOBAL table_cache=DEFAULT; +SET GLOBAL table_open_cache=-1; +SHOW VARIABLES LIKE 'table_open_cache'; +SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'table_open_cache'; +SET GLOBAL table_open_cache=DEFAULT; # # Bugs12363: character_set_results is nullable, @@ -600,12 +648,14 @@ set @@global.error_count=1; # Bug #10351: Setting ulong variable to > MAX_ULONG fails on 32-bit platform # +--disable_warnings set @@max_heap_table_size= 4294967296; select @@max_heap_table_size > 0; set global max_heap_table_size= 4294967296; select @@max_heap_table_size > 0; set @@max_heap_table_size= 4294967296; select @@max_heap_table_size > 0; +--enable_warnings # # Bug #11775 Variable character_set_system does not exist (sometimes) @@ -636,6 +686,7 @@ select @@global.character_set_filesystem; set @old_sql_big_selects = @@sql_big_selects; set @@sql_big_selects = 1; show variables like 'sql_big_selects'; +select * from information_schema.session_variables where variable_name like 'sql_big_selects'; set @@sql_big_selects = @old_sql_big_selects; # @@ -644,10 +695,14 @@ set @@sql_big_selects = @old_sql_big_selects; # set @@sql_notes = 0, @@sql_warnings = 0; show variables like 'sql_notes'; +select * from information_schema.session_variables where variable_name like 'sql_notes'; show variables like 'sql_warnings'; +select * from information_schema.session_variables where variable_name like 'sql_warnings'; set @@sql_notes = 1, @@sql_warnings = 1; show variables like 'sql_notes'; +select * from information_schema.session_variables where variable_name like 'sql_notes'; show variables like 'sql_warnings'; +select * from information_schema.session_variables where variable_name like 'sql_warnings'; # # Bug #12792: @@system_time_zone is not SELECTable. @@ -674,9 +729,15 @@ select @@basedir, @@datadir, @@tmpdir; --replace_column 2 # show variables like 'basedir'; --replace_column 2 # +select * from information_schema.session_variables where variable_name like 'basedir'; +--replace_column 2 # show variables like 'datadir'; --replace_column 2 # +select * from information_schema.session_variables where variable_name like 'datadir'; +--replace_column 2 # show variables like 'tmpdir'; +--replace_column 2 # +select * from information_schema.session_variables where variable_name like 'tmpdir'; # # Bug #19606: make ssl settings available via SHOW VARIABLES and @@variables @@ -686,6 +747,8 @@ show variables like 'tmpdir'; select @@ssl_ca, @@ssl_capath, @@ssl_cert, @@ssl_cipher, @@ssl_key; --replace_column 2 # show variables like 'ssl%'; +--replace_column 2 # +select * from information_schema.session_variables where variable_name like 'ssl%' order by 1; # # Bug #19616: make log_queries_not_using_indexes available in SHOW VARIABLES @@ -693,6 +756,7 @@ show variables like 'ssl%'; # select @@log_queries_not_using_indexes; show variables like 'log_queries_not_using_indexes'; +select * from information_schema.session_variables where variable_name like 'log_queries_not_using_indexes'; # # Bug#20908: Crash if select @@"" @@ -715,21 +779,19 @@ set @@hostname= "anothername"; --replace_column 2 # show variables like 'hostname'; +--echo End of 5.0 tests + # -# Bug #29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it +# Bug#36446: Attempt to set @@join_buffer_size to its minimum value +# produces spurious warning # -SHOW VARIABLES LIKE 'log'; -SELECT @@log; ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -SET GLOBAL log=0; - -SHOW VARIABLES LIKE 'log_slow_queries'; -SELECT @@log_slow_queries; ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -SET GLOBAL log_slow_queries=0; - ---echo End of 5.0 tests +# set to 1 so mysqld will correct to minimum (+ warn) +set join_buffer_size=1; +# save minimum +set @save_join_buffer_size=@@join_buffer_size; +# set minimum +set join_buffer_size=@save_join_buffer_size; # This is at the very after the versioned tests, since it involves doing # cleanup @@ -744,16 +806,18 @@ set global delayed_queue_size =@my_delayed_queue_size; set global flush =@my_flush; set global flush_time =@my_flush_time; set global key_buffer_size =@my_key_buffer_size; -set global max_binlog_cache_size =default; #@my_max_binlog_cache_size; +set global max_binlog_cache_size =@my_max_binlog_cache_size; set global max_binlog_size =@my_max_binlog_size; set global max_connect_errors =@my_max_connect_errors; +set global max_connections =@my_max_connections; set global max_delayed_threads =@my_max_delayed_threads; set global max_heap_table_size =@my_max_heap_table_size; set global max_insert_delayed_threads=@my_max_insert_delayed_threads; set global max_join_size =@my_max_join_size; -set global max_user_connections =@my_max_user_connections; -set global max_write_lock_count =@my_max_write_lock_count; +set global max_user_connections =default; +set global max_write_lock_count =default; set global myisam_data_pointer_size =@my_myisam_data_pointer_size; +set global myisam_max_sort_file_size =@my_myisam_max_sort_file_size; set global net_buffer_length =@my_net_buffer_length; set global net_write_timeout =@my_net_write_timeout; set global net_read_timeout =@my_net_read_timeout; @@ -764,4 +828,402 @@ set global server_id =@my_server_id; set global slow_launch_time =@my_slow_launch_time; set global storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; +set global max_allowed_packet =@my_max_allowed_packet; +set global join_buffer_size =@my_join_buffer_size; + +# +# Bug#28580 Repeatation of status variables +# +--replace_column 2 # +show global variables where Variable_name='table_definition_cache' or +Variable_name='table_lock_wait_timeout'; + +########################################################################### + +--echo +--echo # -- +--echo # -- Bug#34820: log_output can be set to illegal value. +--echo # -- + +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL log_output = ''; + +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL log_output = 0; + +--echo +--echo # -- End of Bug#34820. + +# +# Bug#28234 - global/session scope - documentation vs implementation +# +--echo +--echo # +SHOW VARIABLES like 'ft_max_word_len'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.ft_max_word_len; +SELECT @@global.ft_max_word_len; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.ft_max_word_len= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.ft_max_word_len= 7; +# +--echo # +SHOW VARIABLES like 'ft_min_word_len'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.ft_min_word_len; +SELECT @@global.ft_min_word_len; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.ft_min_word_len= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.ft_min_word_len= 7; +# +--echo # +SHOW VARIABLES like 'ft_query_expansion_limit'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.ft_query_expansion_limit; +SELECT @@global.ft_query_expansion_limit; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.ft_query_expansion_limit= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.ft_query_expansion_limit= 7; +# +--echo # +SHOW VARIABLES like 'ft_stopword_file'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.ft_stopword_file; +SELECT @@global.ft_stopword_file; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.ft_stopword_file= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.ft_stopword_file= 'x'; +# +# Additional variables fixed. +# +--echo # +SHOW VARIABLES like 'back_log'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.back_log; +SELECT @@global.back_log; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.back_log= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.back_log= 7; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'large_files_support'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.large_files_support; +--replace_column 1 # +SELECT @@global.large_files_support; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.large_files_support= true; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.large_files_support= true; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'character_sets_dir'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.character_sets_dir; +--replace_column 1 # +SELECT @@global.character_sets_dir; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.character_sets_dir= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.character_sets_dir= 'x'; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'init_file'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.init_file; +--replace_column 1 # +SELECT @@global.init_file; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.init_file= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.init_file= 'x'; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'language'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.language; +--replace_column 1 # +SELECT @@global.language; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.language= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.language= 'x'; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'large_page_size'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.large_page_size; +--replace_column 1 # +SELECT @@global.large_page_size; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.large_page_size= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.large_page_size= 7; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'large_pages'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.large_pages; +--replace_column 1 # +SELECT @@global.large_pages; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.large_pages= true; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.large_pages= true; +# +--echo # +SHOW VARIABLES like 'log_bin'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.log_bin; +SELECT @@global.log_bin; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.log_bin= true; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.log_bin= true; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'log_error'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.log_error; +--replace_column 1 # +SELECT @@global.log_error; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.log_error= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.log_error= 'x'; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'lower_case_file_system'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.lower_case_file_system; +--replace_column 1 # +SELECT @@global.lower_case_file_system; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.lower_case_file_system= true; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.lower_case_file_system= true; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'lower_case_table_names'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.lower_case_table_names; +--replace_column 1 # +SELECT @@global.lower_case_table_names; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.lower_case_table_names= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.lower_case_table_names= 7; +# +--echo # +SHOW VARIABLES like 'myisam_recover_options'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.myisam_recover_options; +SELECT @@global.myisam_recover_options; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.myisam_recover_options= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.myisam_recover_options= 'x'; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'open_files_limit'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.open_files_limit; +--replace_column 1 # +SELECT @@global.open_files_limit; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.open_files_limit= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.open_files_limit= 7; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'pid_file'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.pid_file; +--replace_column 1 # +SELECT @@global.pid_file; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.pid_file= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.pid_file= 'x'; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'plugin_dir'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.plugin_dir; +--replace_column 1 # +SELECT @@global.plugin_dir; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.plugin_dir= 'x'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.plugin_dir= 'x'; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'port'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.port; +--replace_column 1 # +SELECT @@global.port; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.port= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.port= 7; +# +--echo # +SHOW VARIABLES like 'protocol_version'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.protocol_version; +SELECT @@global.protocol_version; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.protocol_version= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.protocol_version= 7; +# +--echo # +SHOW VARIABLES like 'skip_external_locking'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.skip_external_locking; +SELECT @@global.skip_external_locking; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.skip_external_locking= true; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.skip_external_locking= true; +# +--echo # +SHOW VARIABLES like 'skip_networking'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.skip_networking; +SELECT @@global.skip_networking; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.skip_networking= true; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.skip_networking= true; +# +--echo # +SHOW VARIABLES like 'skip_show_database'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.skip_show_database; +SELECT @@global.skip_show_database; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.skip_show_database= true; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.skip_show_database= true; +# +--echo # +--replace_column 2 # +SHOW VARIABLES like 'thread_stack'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.thread_stack; +--replace_column 1 # +SELECT @@global.thread_stack; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@session.thread_stack= 7; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.thread_stack= 7; +# + +# +# Bug #40657 - assertion with out of range variables and traditional sql_mode +# + +SELECT @@global.expire_logs_days INTO @old_eld; + +SET GLOBAL expire_logs_days = -1; +--echo needs to've been adjusted (0) +SELECT @@global.expire_logs_days; + +SET GLOBAL expire_logs_days = 11; +SET @old_mode=@@sql_mode; +SET SESSION sql_mode = 'TRADITIONAL'; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL expire_logs_days = 100; +--echo needs to be unchanged (11) +SELECT @@global.expire_logs_days; +SET SESSION sql_mode = @old_mode; + +SET GLOBAL expire_logs_days = 100; +--echo needs to've been adjusted (99) +SELECT @@global.expire_logs_days; + +SET GLOBAL expire_logs_days = 11; +SET GLOBAL expire_logs_days = 99; +--echo needs to pass with no warnings (99) +SELECT @@global.expire_logs_days; + +# cleanup +SET GLOBAL expire_logs_days = @old_eld; + +# show that warning uses underscore (sysvar-name), not hyphens (option-name) +SET GLOBAL auto_increment_offset=-1; +SET GLOBAL auto_increment_offset=0; + + + +# +# Bug#41030 Wrong meta data (incorrect fieldlen) +# + +--enable_metadata +select @@storage_engine; +--disable_metadata + +# +# Bug#36540: CREATE EVENT and ALTER EVENT statements fail with large server_id +# + +SET @old_server_id = @@GLOBAL.server_id; +SET GLOBAL server_id = (1 << 32) - 1; +SELECT @@GLOBAL.server_id; +SET GLOBAL server_id = (1 << 32); +SELECT @@GLOBAL.server_id; +SET GLOBAL server_id = (1 << 60); +SELECT @@GLOBAL.server_id; +SET GLOBAL server_id = 0; +SELECT @@GLOBAL.server_id; +SET GLOBAL server_id = -1; +SELECT @@GLOBAL.server_id; +SET GLOBAL server_id = @old_server_id; + +# +# Bug #42778: delete order by null global variable causes +# assertion .\filesort.cc, line 797 +# + +SELECT @@GLOBAL.INIT_FILE, @@GLOBAL.INIT_FILE IS NULL; + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (); +SET @bug42778= @@sql_safe_updates; +SET @@sql_safe_updates= 0; +DELETE FROM t1 ORDER BY (@@GLOBAL.INIT_FILE) ASC LIMIT 10; +SET @@sql_safe_updates= @bug42778; + +DROP TABLE t1; + +--echo # +--echo # BUG#10206 - InnoDB: Transaction requiring Max_BinLog_Cache_size > 4GB always rollsback +--echo # +SET @old_max_binlog_cache_size = @@GLOBAL.max_binlog_cache_size; +--echo # Set the max_binlog_cache_size to size more than 4GB. +SET GLOBAL max_binlog_cache_size = 5 * 1024 * 1024 * 1024; +SELECT @@GLOBAL.max_binlog_cache_size; +SET GLOBAL max_binlog_cache_size = @old_max_binlog_cache_size; +--echo End of 5.1 tests diff --git a/mysql-test/t/variables_debug.test b/mysql-test/t/variables_debug.test new file mode 100644 index 00000000000..7dcaf246803 --- /dev/null +++ b/mysql-test/t/variables_debug.test @@ -0,0 +1,12 @@ +--source include/have_debug.inc + +# +# Bug#34678 @@debug variable's incremental mode +# + +set debug= 'T'; +select @@debug; +set debug= '+P'; +select @@debug; +set debug= '-P'; +select @@debug; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 6f03ff12448..a788b5ab41e 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -702,11 +702,11 @@ drop function `f``1`; # # tested problem when function name length close to ALIGN_SIZE # -create function x () returns int return 5; -create view v1 as select x (); +create function a() returns int return 5; +create view v1 as select a(); select * from v1; drop view v1; -drop function x; +drop function a; # # VIEW with collation @@ -752,6 +752,11 @@ drop view v1; # # VIEWs with national characters # + +SET @old_cs_client = @@character_set_client; +SET @old_cs_results = @@character_set_results; +SET @old_cs_connection = @@character_set_connection; + set names utf8; create table tü (cü char); create view vü as select cü from tü; @@ -759,7 +764,10 @@ insert into vü values ('ü'); select * from vü; drop view vü; drop table tü; -set names latin1; + +SET character_set_client = @old_cs_client; +SET character_set_results = @old_cs_results; +SET character_set_connection = @old_cs_connection; # # problem with used_tables() of outer reference resolved in VIEW @@ -836,6 +844,7 @@ drop table t1; # create table t1 (col1 int); create table t2 (col1 int); +create table t3 (col1 datetime not null); create view v1 as select * from t1; create view v2 as select * from v1; create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1; @@ -942,7 +951,7 @@ insert into v3 (col1) values ((select max(col1) from v2)); insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2)); insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); -- error ER_BAD_NULL_ERROR -insert into mysql.time_zone values ('', (select CONVERT_TZ('20050101000000','UTC','MET') from t2)); +insert into t3 values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); # temporary table algorithm view should be equal to subquery in the from clause create algorithm=temptable view v4 as select * from t1; insert into t1 values (1),(2),(3); @@ -950,7 +959,7 @@ insert into t1 (col1) values ((select max(col1) from v4)); select * from t1; drop view v4,v3,v2,v1; -drop table t1,t2; +drop table t1,t2,t3; # # HANDLER with VIEW @@ -1033,18 +1042,18 @@ create table t2 (a int); insert into t2 values (2),(3),(0); # INSERT SELECT with ignore test insert ignore into v1 SELECT a from t2; -select * from t1; +select * from t1 order by a desc; # simple UPDATE test update v1 set a=-1 where a=0; -- error ER_VIEW_CHECK_FAILED update v1 set a=2 where a=1; -select * from t1; +select * from t1 order by a desc; # prepare data for next check update v1 set a=0 where a=0; insert into t2 values (1); # multiupdate test update v1,t2 set v1.a=v1.a-1 where v1.a=t2.a; -select * from t1; +select * from t1 order by a desc; # prepare data for next check update v1 set a=a+1; # multiupdate with ignore test @@ -1219,24 +1228,24 @@ drop table t1; create table t1 (a int, b char(10)); create view v1 as select * from t1 where a != 0 with check option; -- error ER_VIEW_CHECK_FAILED -load data infile '../std_data_ln/loaddata3.dat' into table v1 fields terminated by '' enclosed by '' ignore 1 lines; +load data infile '../../std_data/loaddata3.dat' into table v1 fields terminated by '' enclosed by '' ignore 1 lines; select * from t1; select * from v1; delete from t1; -load data infile '../std_data_ln/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines; -select * from t1; -select * from v1; +load data infile '../../std_data/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines; +select * from t1 order by a,b; +select * from v1 order by a,b; drop view v1; drop table t1; # variable length fields create table t1 (a text, b text); create view v1 as select * from t1 where a <> 'Field A' with check option; -- error ER_VIEW_CHECK_FAILED -load data infile '../std_data_ln/loaddata2.dat' into table v1 fields terminated by ',' enclosed by ''''; +load data infile '../../std_data/loaddata2.dat' into table v1 fields terminated by ',' enclosed by ''''; select concat('|',a,'|'), concat('|',b,'|') from t1; select concat('|',a,'|'), concat('|',b,'|') from v1; delete from t1; -load data infile '../std_data_ln/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by ''''; +load data infile '../../std_data/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by ''''; select concat('|',a,'|'), concat('|',b,'|') from t1; select concat('|',a,'|'), concat('|',b,'|') from v1; drop view v1; @@ -1892,16 +1901,6 @@ DROP TABLE t1; # -# Bug#11335 View redefines column types -# -create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime); -create view v1 as select * from t1; -desc v1; -drop view v1; -drop table t1; - - -# # Bug#11760 Typo in Item_func_add_time::print() results in NULLs returned # subtime() in view create table t1(f1 datetime); @@ -2094,6 +2093,7 @@ drop view v1, v2; drop table t1, t2; +# # Bug#6808 Views: CREATE VIEW v ... FROM t AS v fails # @@ -2481,6 +2481,7 @@ DROP TABLE t1, t2; # # Bug#16069 VIEW does return the same results as underlying SELECT # with WHERE condition containing BETWEEN over dates +# Dates as strings should be casted to date type CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, td date DEFAULT NULL, KEY idx(td)); @@ -3465,7 +3466,6 @@ SELECT profile.person_id AS person_id INSERT INTO t1 VALUES (6,'Sw','A'), (-1136332546,'ols','e'), (0,' *\n','0'), (-717462680,'ENTS Ta','0'), (-904346964,'ndard SQL\n','0'); - INSERT INTO t2 VALUES (1,3,6),(2,4,7),(3,5,8),(4,6,9),(5,1,6),(6,1,7),(7,1,8),(8,1,9),(9,1,10); @@ -3703,38 +3703,173 @@ DROP TABLE t1; --echo # -- End of test case for Bug#40825 --echo ---echo # ---echo # Bug #45806 crash when replacing into a view with a join! ---echo # -CREATE TABLE t1(a INT UNIQUE); -CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a; -INSERT INTO t1 VALUES (1), (2); +--echo # ----------------------------------------------------------------- +--echo # -- End of 5.0 tests. +--echo # ----------------------------------------------------------------- + +# +# Bug#21370 View renaming lacks tablename_to_filename encoding +# +--disable_warnings +DROP DATABASE IF EXISTS `d-1`; +--enable_warnings +CREATE DATABASE `d-1`; +USE `d-1`; +CREATE TABLE `t-1` (c1 INT); +CREATE VIEW `v-1` AS SELECT c1 FROM `t-1`; +SHOW TABLES; +RENAME TABLE `t-1` TO `t-2`; +RENAME TABLE `v-1` TO `v-2`; +SHOW TABLES; +DROP TABLE `t-2`; +DROP VIEW `v-2`; +DROP DATABASE `d-1`; +USE test; + +--echo +--echo # +--echo # Bug#26676 VIEW using old table schema in a session. +--echo # +--echo + +--disable_warnings +DROP VIEW IF EXISTS v1; +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1(c1 INT, c2 INT); +INSERT INTO t1 VALUES (1, 2), (3, 4); + +--echo + +SELECT * FROM t1; + +--echo + +CREATE VIEW v1 AS SELECT * FROM t1; + +--echo -REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c; -SELECT * FROM v1; -REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c; SELECT * FROM v1; -DELETE FROM t1 WHERE a=3; -INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c -ON DUPLICATE KEY UPDATE `v1`.`a`= 1; + +--echo + +ALTER TABLE t1 ADD COLUMN c3 INT AFTER c2; + +--echo + +SELECT * FROM t1; + +--echo + SELECT * FROM v1; -CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a; +--echo -REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c; -SELECT * FROM v2; -REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c; -SELECT * FROM v2; -INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c -ON DUPLICATE KEY UPDATE `v2`.`a`= 1; -SELECT * FROM v2; +SHOW CREATE VIEW v1; + +--echo DROP VIEW v1; -DROP VIEW v2; DROP TABLE t1; ---echo # -- End of test case for Bug#45806 +--echo +--echo # End of test case for Bug#26676. +--echo + +########################################################################### --echo # ----------------------------------------------------------------- ---echo # -- End of 5.0 tests. +--echo # -- Bug#32538 View definition picks up character set, but not collation +--echo # ----------------------------------------------------------------- +--echo + +--disable_warnings +DROP VIEW IF EXISTS v1; +--enable_warnings + +--echo + +SET collation_connection = latin1_general_ci; +CREATE VIEW v1 AS SELECT _latin1 'text1' AS c1, 'text2' AS c2; + +--echo + +SELECT COLLATION(c1), COLLATION(c2) FROM v1; + +--echo + +SHOW CREATE VIEW v1; + +--echo + +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT * FROM v1 WHERE c1 = 'text1'; + +--echo + +SELECT * FROM v1 WHERE c2 = 'text2'; + +--echo + +use test; +SET names latin1; + +--echo + +SELECT COLLATION(c1), COLLATION(c2) FROM v1; + +--echo + +SELECT * FROM v1 WHERE c1 = 'text1'; + +--echo + +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT * FROM v1 WHERE c2 = 'text2'; + +--echo + +DROP VIEW v1; + +--echo +--echo # -- End of test case for Bug#32538. +--echo + +# +# Bug#34587 Creating a view inside a stored procedure leads to a server crash +# + +--disable_warnings +drop view if exists a; +drop procedure if exists p; +--enable_warnings + +delimiter |; +create procedure p() +begin + declare continue handler for sqlexception begin end; + create view a as select 1; +end| +delimiter ;| +call p(); +call p(); +drop view a; +drop procedure p; + +########################################################################### + + +--echo # +--echo # Bug #44860: ALTER TABLE on view crashes server +--echo # +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +ALTER TABLE v1; +DROP VIEW v1; +DROP TABLE t1; + + +--echo # ----------------------------------------------------------------- +--echo # -- End of 5.1 tests. --echo # ----------------------------------------------------------------- diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index ff17cde5184..175468db702 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -4,6 +4,12 @@ # Save the initial number of concurrent sessions --source include/count_sessions.inc +--disable_warnings +drop database if exists mysqltest; +drop view if exists v1,v2,v3; +--enable_warnings + + # simple test of grants grant create view on test.* to test@localhost; show grants for test@localhost; @@ -1231,8 +1237,298 @@ DROP VIEW db1.v1; DROP TABLE db1.t1; DROP DATABASE db1; -connection default; --echo End of 5.0 tests. + +# +# Test that ALTER VIEW accepts DEFINER and ALGORITHM, see bug#16425. +# +connection default; +--disable_warnings +DROP VIEW IF EXISTS v1; +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT * FROM t1; + +ALTER VIEW v1 AS SELECT * FROM t1; +SHOW CREATE VIEW v1; +ALTER DEFINER=no_such@user_1 VIEW v1 AS SELECT * FROM t1; +SHOW CREATE VIEW v1; +ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; +SHOW CREATE VIEW v1; +ALTER ALGORITHM=TEMPTABLE DEFINER=no_such@user_2 VIEW v1 AS SELECT * FROM t1; +SHOW CREATE VIEW v1; + +DROP VIEW v1; +DROP TABLE t1; + +# +# Bug#37191: Failed assertion in CREATE VIEW +# +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; + +USE mysqltest1; + +CREATE TABLE t1 ( a INT ); +CREATE TABLE t2 ( b INT ); + +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (1), (2); + +GRANT CREATE VIEW ON mysqltest1.* TO mysqluser1@localhost; + +GRANT SELECT ON t1 TO mysqluser1@localhost; +GRANT INSERT ON t2 TO mysqluser1@localhost; + +--connect (connection1, localhost, mysqluser1, , mysqltest1) + +--echo This would lead to failed assertion. +CREATE VIEW v1 AS SELECT a, b FROM t1, t2; + +--error ER_TABLEACCESS_DENIED_ERROR +SELECT * FROM v1; +--error ER_TABLEACCESS_DENIED_ERROR +SELECT b FROM v1; + +--disconnect connection1 +--connection default + +DROP TABLE t1, t2; +DROP VIEW v1; +DROP DATABASE mysqltest1; +DROP USER mysqluser1@localhost; +USE test; + +--echo End of 5.1 tests. + +# +# Bug#36086: SELECT * from views don't check column grants +# +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; + +USE mysqltest1; + +CREATE TABLE t1 ( a INT, b INT ); +CREATE TABLE t2 ( a INT, b INT ); + +CREATE VIEW v1 AS SELECT a, b FROM t1; + +GRANT SELECT( a ) ON v1 TO mysqluser1@localhost; +GRANT UPDATE( b ) ON t2 TO mysqluser1@localhost; + +--connect (connection1, localhost, mysqluser1, , test) + +--error ER_TABLEACCESS_DENIED_ERROR +SELECT * FROM mysqltest1.v1; + +--error ER_TABLEACCESS_DENIED_ERROR +CREATE VIEW v1 AS SELECT * FROM mysqltest1.t2; + +--disconnect connection1 + +--connection default + +DROP TABLE t1, t2; +DROP VIEW v1; +DROP DATABASE mysqltest1; +DROP USER mysqluser1@localhost; + +# +# Bug#35600 Security breach via view, I_S table and prepared +# statement/stored procedure +# +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; + +USE mysqltest1; + +CREATE VIEW v1 AS SELECT * FROM information_schema.tables LIMIT 1; +CREATE ALGORITHM = TEMPTABLE VIEW v2 AS SELECT 1 AS A; + +CREATE VIEW test.v3 AS SELECT 1 AS a; + +--connection default +GRANT SELECT ON mysqltest1.* to mysqluser1@localhost; +GRANT ALL ON test.* TO mysqluser1@localhost; + +--connect (connection1, localhost, mysqluser1, , test) +PREPARE stmt_v1 FROM "SELECT * FROM mysqltest1.v1"; +PREPARE stmt_v2 FROM "SELECT * FROM mysqltest1.v2"; + +--connection default +REVOKE SELECT ON mysqltest1.* FROM mysqluser1@localhost; + +--connection connection1 + +--error ER_TABLEACCESS_DENIED_ERROR +EXECUTE stmt_v1; +--error ER_TABLEACCESS_DENIED_ERROR +EXECUTE stmt_v2; +--disconnect connection1 + +--connect (connection2, localhost, mysqluser1,,) +PREPARE stmt FROM "SELECT a FROM v3"; +EXECUTE stmt; +--disconnect connection2 + +--connection default +DROP VIEW v1, v2; +DROP DATABASE mysqltest1; +DROP VIEW test.v3; +DROP USER mysqluser1@localhost; +USE test; + +--echo # +--echo # Bug#35996: SELECT + SHOW VIEW should be enough to display view +--echo # definition +--echo # +-- source include/not_embedded.inc +CREATE USER mysqluser1@localhost; +CREATE DATABASE mysqltest1; +CREATE DATABASE mysqltest2; +GRANT USAGE, SELECT, CREATE VIEW, SHOW VIEW +ON mysqltest2.* TO mysqluser1@localhost; + +USE mysqltest1; + +CREATE TABLE t1( a INT ); +CREATE TABLE t2( a INT, b INT ); +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE VIEW v1 AS SELECT 1 AS a; +CREATE VIEW v2 AS SELECT 1 AS a, 2 AS b; + +GRANT SELECT ON TABLE t1 TO mysqluser1@localhost; +GRANT SELECT (a, b) ON TABLE t2 TO mysqluser1@localhost; +GRANT EXECUTE ON FUNCTION f1 TO mysqluser1@localhost; +GRANT SELECT ON TABLE v1 TO mysqluser1@localhost; +GRANT SELECT (a, b) ON TABLE v2 TO mysqluser1@localhost; + +CREATE VIEW v_t1 AS SELECT * FROM t1; +CREATE VIEW v_t2 AS SELECT * FROM t2; +CREATE VIEW v_f1 AS SELECT f1() AS a; +CREATE VIEW v_v1 AS SELECT * FROM v1; +CREATE VIEW v_v2 AS SELECT * FROM v2; + +GRANT SELECT, SHOW VIEW ON v_t1 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_t2 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_f1 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_v1 TO mysqluser1@localhost; +GRANT SELECT, SHOW VIEW ON v_v2 TO mysqluser1@localhost; + +--connect (connection1, localhost, mysqluser1,, mysqltest2) +CREATE VIEW v_mysqluser1_t1 AS SELECT * FROM mysqltest1.t1; +CREATE VIEW v_mysqluser1_t2 AS SELECT * FROM mysqltest1.t2; +CREATE VIEW v_mysqluser1_f1 AS SELECT mysqltest1.f1() AS a; +CREATE VIEW v_mysqluser1_v1 AS SELECT * FROM mysqltest1.v1; +CREATE VIEW v_mysqluser1_v2 AS SELECT * FROM mysqltest1.v2; + +SHOW CREATE VIEW mysqltest1.v_t1; +SHOW CREATE VIEW mysqltest1.v_t2; +SHOW CREATE VIEW mysqltest1.v_f1; +SHOW CREATE VIEW mysqltest1.v_v1; +SHOW CREATE VIEW mysqltest1.v_v2; + +SHOW CREATE VIEW v_mysqluser1_t1; +SHOW CREATE VIEW v_mysqluser1_t2; +SHOW CREATE VIEW v_mysqluser1_f1; +SHOW CREATE VIEW v_mysqluser1_v1; +SHOW CREATE VIEW v_mysqluser1_v2; + +--connection default +REVOKE SELECT ON TABLE t1 FROM mysqluser1@localhost; +REVOKE SELECT (a) ON TABLE t2 FROM mysqluser1@localhost; +REVOKE EXECUTE ON FUNCTION f1 FROM mysqluser1@localhost; +REVOKE SELECT ON TABLE v1 FROM mysqluser1@localhost; + +--connection connection1 +SHOW CREATE VIEW mysqltest1.v_t1; +SHOW CREATE VIEW mysqltest1.v_t2; +SHOW CREATE VIEW mysqltest1.v_f1; +SHOW CREATE VIEW mysqltest1.v_v1; +SHOW CREATE VIEW mysqltest1.v_v2; + +SHOW CREATE VIEW v_mysqluser1_t1; +SHOW CREATE VIEW v_mysqluser1_t2; +SHOW CREATE VIEW v_mysqluser1_f1; +SHOW CREATE VIEW v_mysqluser1_v1; +SHOW CREATE VIEW v_mysqluser1_v2; + +--connection default +--echo # Testing the case when the views reference missing objects. +--echo # Obviously, there are no privileges to check for, so we +--echo # need only each object type once. +DROP TABLE t1; +DROP FUNCTION f1; +DROP VIEW v1; + +--connection connection1 +SHOW CREATE VIEW mysqltest1.v_t1; +SHOW CREATE VIEW mysqltest1.v_f1; +SHOW CREATE VIEW mysqltest1.v_v1; + +SHOW CREATE VIEW v_mysqluser1_t1; +SHOW CREATE VIEW v_mysqluser1_f1; +SHOW CREATE VIEW v_mysqluser1_v1; + +--connection default +REVOKE SHOW VIEW ON v_t1 FROM mysqluser1@localhost; +REVOKE SHOW VIEW ON v_f1 FROM mysqluser1@localhost; +REVOKE SHOW VIEW ON v_v1 FROM mysqluser1@localhost; + +--connection connection1 +--error ER_TABLEACCESS_DENIED_ERROR +SHOW CREATE VIEW mysqltest1.v_t1; +--error ER_TABLEACCESS_DENIED_ERROR +SHOW CREATE VIEW mysqltest1.v_f1; +--error ER_TABLEACCESS_DENIED_ERROR +SHOW CREATE VIEW mysqltest1.v_v1; +SHOW CREATE VIEW v_mysqluser1_t1; +SHOW CREATE VIEW v_mysqluser1_f1; +SHOW CREATE VIEW v_mysqluser1_v1; + +--disconnect connection1 +--connection default +DROP USER mysqluser1@localhost; +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; +USE test; + +CREATE TABLE t1( a INT ); +CREATE DEFINER = no_such_user@no_such_host VIEW v1 AS SELECT * FROM t1; +SHOW CREATE VIEW v1; +DROP TABLE t1; +DROP VIEW v1; + # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc + +--echo # +--echo # Bug #46019: ERROR 1356 When selecting from within another +--echo # view that has Group By +--echo # +CREATE DATABASE mysqltest1; +USE mysqltest1; + +CREATE TABLE t1 (a INT); + +CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT a FROM t1 GROUP BY a; +CREATE SQL SECURITY INVOKER VIEW v2 AS SELECT a FROM v1; + +CREATE USER mysqluser1; + +GRANT SELECT ON TABLE t1 TO mysqluser1; +GRANT SELECT, SHOW VIEW ON TABLE v1 TO mysqluser1; +GRANT SELECT, SHOW VIEW ON TABLE v2 TO mysqluser1; + +--connect (mysqluser1, localhost, mysqluser1,,mysqltest1) +SELECT a FROM v1; +SELECT a FROM v2; + +--connection default +--disconnect mysqluser1 +DROP USER mysqluser1; +DROP DATABASE mysqltest1; diff --git a/mysql-test/t/wait_for_process.sh b/mysql-test/t/wait_for_process.sh deleted file mode 100755 index 2143ab2002f..00000000000 --- a/mysql-test/t/wait_for_process.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/sh - -########################################################################### - -# NOTE: this script returns 0 (success) even in case of failure (except for -# usage-error). This is because this script is executed under -# mysql-test-run[.pl] and it's better to examine particular problem in log -# file, than just having said that the test case has failed. - -########################################################################### - -basename=`basename "$0"` -dirname=`dirname "$0"` - -########################################################################### - -. "$dirname/utils.sh" - -########################################################################### - -check_started() -{ - if [ ! -r "$pid_path" ]; then - log_debug "No PID-file ($pid_path) found -- not started." - return 1 - fi - - new_pid=`cat "$pid_path" 2>/dev/null` - err_code=$? - - log_debug "err_code: $err_code; new_pid: $new_pid." - - if [ $? -ne 0 -o -z "$new_pid" ]; then - log_debug "The process was not started." - return 1 - fi - - log_debug "The process was started." - return 0 -} - -########################################################################### - -check_stopped() -{ - if [ -r "$pid_path" ]; then - log_debug "PID-file '$pid_path' exists -- not stopped." - return 1 - fi - - log_debug "No PID-file ($pid_path) found -- stopped." - return 0 -} - -########################################################################### - -if [ $# -ne 4 ]; then - echo "Usage: $basename <pid file path> <total attempts> started|stopped <test id>" - exit 1 -fi - -pid_path="$1" -total_attempts="$2" -event="$3" -test_id="$4" -log_file="$MYSQLTEST_VARDIR/log/$test_id.script.log" - -log_debug "-- $basename: starting --" -log_debug "pid_path: '$pid_path'" -log_debug "total_attempts: '$total_attempts'" -log_debug "event: '$event'" -log_debug "test_id: '$test_id'" -log_debug "log_file: '$log_file'" - -########################################################################### - -case "$event" in - started) - check_fn='check_started'; - ;; - - stopped) - check_fn='check_stopped'; - ;; - - *) - log_error "Invalid third argument ('started' or 'stopped' expected)." - quit 0 -esac - -########################################################################### - -cur_attempt=1 - -while true; do - - log_debug "cur_attempt: $cur_attempt." - - if ( eval $check_fn ); then - log_info "Success: the process has been $event." - quit 0 - fi - - [ $cur_attempt -ge $total_attempts ] && break - - log_debug "Sleeping for 1 second..." - sleep 1 - - cur_attempt=`expr $cur_attempt + 1` - -done - -log_error "The process has not been $event in $total_attempts secs." -quit 0 diff --git a/mysql-test/t/wait_for_socket.sh b/mysql-test/t/wait_for_socket.sh deleted file mode 100755 index 2fa7d5c5b7e..00000000000 --- a/mysql-test/t/wait_for_socket.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh - -########################################################################### - -# NOTE: this script returns 0 (success) even in case of failure (except for -# usage-error). This is because this script is executed under -# mysql-test-run[.pl] and it's better to examine particular problem in log -# file, than just having said that the test case has failed. - -########################################################################### - -basename=`basename "$0"` -dirname=`dirname "$0"` - -########################################################################### - -. "$dirname/utils.sh" - -########################################################################### - -if [ $# -ne 7 ]; then - echo "Usage: wait_for_socket.sh <executable path> <socket path> <username> <password> <db> <timeout> <test id>" - exit 1 -fi - -client_exe="$1" -socket_path="$2" -username="$3" -password="$4" -db="$5" -total_timeout="$6" -test_id="$7" -log_file="$MYSQLTEST_VARDIR/log/$test_id.script.log" - -log_debug "-- $basename: starting --" -log_debug "client_exe: '$client_exe'" -log_debug "socket_path: '$socket_path'" -log_debug "username: '$username'" -log_debug "password: '$password'" -log_debug "db: '$db'" -log_debug "total_timeout: '$total_timeout'" -log_debug "test_id: '$test_id'" -log_debug "log_file: '$log_file'" - -########################################################################### - -if [ -z "$client_exe" ]; then - log_error "Invalid path to client executable ($client_exe)." - quit 0; -fi - -if [ ! -x "$client_exe" ]; then - log_error "Client by path '$client_exe' is not available." - quit 0; -fi - -if [ -z "$socket_path" ]; then - log_error "Invalid socket patch ($socket_path)." - quit 0 -fi - -########################################################################### - -client_args="--no-defaults --silent --socket=$socket_path --connect_timeout=1 " - -[ -n "$username" ] && client_args="$client_args --user=$username " -[ -n "$password" ] && client_args="$client_args --password=$password " -[ -n "$db" ] && client_args="$client_args $db" - -log_debug "client_args: '$client_args'" - -########################################################################### - -cur_attempt=1 - -while true; do - - log_debug "cur_attempt: $cur_attempt." - - if ( echo 'quit' | "$client_exe" $client_args >/dev/null 2>&1 ); then - log_info "Success: server is ready to accept connection on socket." - quit 0 - fi - - [ $cur_attempt -ge $total_timeout ] && break - - sleep 1 - - cur_attempt=`expr $cur_attempt + 1` - -done - -log_error "Server does not accept connections after $total_timeout seconds." -quit 0 diff --git a/mysql-test/t/wait_timeout-master.opt b/mysql-test/t/wait_timeout-master.opt deleted file mode 100644 index 9e5c2289eb2..00000000000 --- a/mysql-test/t/wait_timeout-master.opt +++ /dev/null @@ -1 +0,0 @@ ---wait-timeout=1 diff --git a/mysql-test/t/wait_timeout.test b/mysql-test/t/wait_timeout.test index 093f69f0143..6947e346675 100644 --- a/mysql-test/t/wait_timeout.test +++ b/mysql-test/t/wait_timeout.test @@ -1,39 +1,54 @@ -# This tests not performed with embedded server +# Last modification: +# 2009-01-19 H.Hunger Fix Bug#39108 main.wait_timeout fails sporadically +# - Increase wait timeout to 2 seconds +# - Eliminated the corresponding opt file, +# set global wait timeout within the test. +# - Replaced sleeps by wait condition +# - Minor improvements +############################################################################### +# These tests cannot run with the embedded server -- source include/not_embedded.inc +-- source include/one_thread_per_connection.inc + +# Save the initial number of concurrent sessions +--source include/count_sessions.inc # # Bug#8731 wait_timeout does not work on Mac OS X # +let $start_value= `SELECT @@global.wait_timeout`; +SET @@global.wait_timeout= 2; +--echo disconnect default; +disconnect default; # Connect with another connection and reset counters --disable_query_log connect (wait_con,localhost,root,,test,,); +--echo connection wait_con; connection wait_con; -set session wait_timeout=100; +SET SESSION wait_timeout=100; let $retries=300; -set @aborted_clients= 0; +SET @aborted_clients= 0; --enable_query_log # Disable reconnect and do the query +connect (default,localhost,root,,test,,); +--echo connection default; connection default; -# If slow host (Valgrind...), we may have already timed out here. -# So force a reconnect if necessary, using a dummy query. And issue a -# 'flush status' to reset the 'aborted_clients' counter. ---enable_reconnect -select 0; -flush status; +--echo --disable_reconnect; --disable_reconnect -select 1; +SELECT 1; # Switch to wait_con and wait until server has aborted the connection --disable_query_log +--echo connection wait_con; connection wait_con; while (!`select @aborted_clients`) { - sleep 0.1; + real_sleep 0.1; let $aborted_clients = `SHOW STATUS LIKE 'aborted_clients'`; - eval set @aborted_clients= SUBSTRING('$aborted_clients', 16)+0; + eval SET @aborted_clients= SUBSTRING('$aborted_clients', 16)+0; dec $retries; if (!$retries) @@ -42,43 +57,53 @@ while (!`select @aborted_clients`) } } --enable_query_log - +# The server has disconnected, add small sleep to make sure +# the disconnect has reached client +let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist; +--source include/wait_condition.inc +--echo connection default; connection default; # When the connection is closed in this way, the error code should -# be consistent see bug#2845 for an explanation +# be consistent see Bug#2845 for an explanation # depending on platform/client, either errno 2006 or 2013 can occur below --error 2006,2013 -select 2; +SELECT 2; +--echo --enable_reconnect; --enable_reconnect -select 3; +SELECT 3; # Disconnect so that we will not be confused by a future abort from this # connection. +--echo disconnection default; disconnect default; # # Do the same test as above on a TCP connection -# (which we get by specifying a ip adress) +# (which we get by specifying an ip adress) # Connect with another connection and reset counters --disable_query_log +--echo connection wait_con; connection wait_con; -flush status; # Reset counters +FLUSH STATUS; # Reset counters let $retries=300; -set @aborted_clients= 0; +SET @aborted_clients= 0; --enable_query_log +--echo connection con1; connect (con1,127.0.0.1,root,,test,$MASTER_MYPORT,); +--echo --disable_reconnect; --disable_reconnect -select 1; +SELECT 1; # Switch to wait_con and wait until server has aborted the connection --disable_query_log +--echo connection wait_con; connection wait_con; while (!`select @aborted_clients`) { - sleep 0.1; + real_sleep 0.1; let $aborted_clients = `SHOW STATUS LIKE 'aborted_clients'`; - eval set @aborted_clients= SUBSTRING('$aborted_clients', 16)+0; + eval SET @aborted_clients= SUBSTRING('$aborted_clients', 16)+0; dec $retries; if (!$retries) @@ -87,16 +112,31 @@ while (!`select @aborted_clients`) } } --enable_query_log +# The server has disconnected, add small sleep to make sure +# the disconnect has reached client +let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist; +--source include/wait_condition.inc disconnect wait_con; +--echo connection con1; connection con1; # When the connection is closed in this way, the error code should -# be consistent see bug#2845 for an explanation +# be consistent see Bug#2845 for an explanation # depending on platform/client, either errno 2006 or 2013 can occur below --error 2006,2013 -select 2; +SELECT 2; +--echo --enable_reconnect; --enable_reconnect -select 3; +SELECT 3; +--replace_result $start_value <start_value> +eval SET @@global.wait_timeout= $start_value; +--echo disconnection con1; disconnect con1; + + # The last connect is to keep tools checking the current test happy. connect (default,localhost,root,,test,,); + +# Wait till all disconnects are completed +--source include/wait_until_count_sessions.inc + diff --git a/mysql-test/t/warnings-master.opt b/mysql-test/t/warnings-master.opt index e924a22e2ce..21356507809 100644 --- a/mysql-test/t/warnings-master.opt +++ b/mysql-test/t/warnings-master.opt @@ -1 +1 @@ ---skip-isam --skip-merge +--loose-skip-innodb diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test index c42dd22024c..176f320e390 100644 --- a/mysql-test/t/warnings.test +++ b/mysql-test/t/warnings.test @@ -50,7 +50,7 @@ drop table t1; # create table t1(a tinyint, b int not null, c date, d char(5)); -load data infile '../std_data_ln/warnings_loaddata.dat' into table t1 fields terminated by ','; +load data infile '../../std_data/warnings_loaddata.dat' into table t1 fields terminated by ','; # PS doesn't work good with @@warning_count --disable_ps_protocol select @@warning_count; @@ -109,24 +109,6 @@ show variables like 'max_error_count'; set max_error_count=10; show variables like 'max_error_count'; -# -# Test for handler type -# -drop table t1; -create table t1 (id int) engine=isam; -alter table t1 engine=isam; -drop table t1; - -create table t1 (id int) engine=merge; -alter table t1 engine=merge; -drop table t1; - -# -# Test for deprecated TYPE= syntax -# - -create table t1 (id int) type=heap; -alter table t1 type=myisam; drop table t1; # @@ -162,8 +144,6 @@ drop table t1; # Bug#20778: strange characters in warning message 1366 when called in SP # -let $engine_type= innodb; - CREATE TABLE t1( f1 CHAR(20) ); CREATE TABLE t2( f1 CHAR(20), f2 CHAR(25) ); CREATE TABLE t3( f1 CHAR(20), f2 CHAR(25), f3 DATE ); @@ -245,4 +225,11 @@ insert into t2 values(@q); drop table t1, t2; +# +# Bug#42364 SHOW ERRORS returns empty resultset after dropping non existent table +# +--error ER_BAD_TABLE_ERROR +DROP TABLE t1; +SHOW ERRORS; + --echo End of 5.0 tests diff --git a/mysql-test/t/warnings_engine_disabled-master.opt b/mysql-test/t/warnings_engine_disabled-master.opt new file mode 100644 index 00000000000..f51c1789a16 --- /dev/null +++ b/mysql-test/t/warnings_engine_disabled-master.opt @@ -0,0 +1 @@ +--loose-skip-plugin-ndbcluster diff --git a/mysql-test/t/warnings_engine_disabled.test b/mysql-test/t/warnings_engine_disabled.test new file mode 100644 index 00000000000..b8751a062b7 --- /dev/null +++ b/mysql-test/t/warnings_engine_disabled.test @@ -0,0 +1,24 @@ +# +# Only run this test with a compiled in but disabled +# engine +# +disable_query_log; +--require r/true.require +select support = 'NO' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; +enable_query_log; + + +# +# Test for handler type, will select MyISAM and print a warning +# about that - since NDB is disabled +# +create table t1 (id int) engine=NDB; +alter table t1 engine=NDB; +drop table t1; + +# +# Bug#29263 disabled storage engines omitted in SHOW ENGINES +# +SELECT ENGINE, SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE='ndbcluster'; +SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE +PLUGIN_NAME='ndbcluster'; diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test index adaf8d3ea17..b7d31948d23 100755 --- a/mysql-test/t/windows.test +++ b/mysql-test/t/windows.test @@ -67,3 +67,34 @@ USE test; DROP DATABASE `TESTDB`; --echo End of 5.0 tests. + +--disable_warnings +drop procedure if exists proc_1; +--enable_warnings +# +# Bug #20665: All commands supported in Stored Procedures should work in +# Prepared Statements +# + +create procedure proc_1() install plugin my_plug soname '\\root\\some_plugin.dll'; +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +drop procedure proc_1; + +prepare abc from "install plugin my_plug soname '\\\\root\\\\some_plugin.dll'"; +--error ER_UDF_NO_PATHS +execute abc; +--error ER_UDF_NO_PATHS +execute abc; +deallocate prepare abc; + +--echo # +--echo # Bug#45498: Socket variable not available on Windows +--echo # + +SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES + WHERE VARIABLE_NAME = 'socket'; diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test index 04ecf518577..7b1c6a268d5 100644 --- a/mysql-test/t/xa.test +++ b/mysql-test/t/xa.test @@ -124,6 +124,31 @@ drop table t1; --echo End of 5.0 tests +# +# Bug#44672: Assertion failed: thd->transaction.xid_state.xid.is_null() +# + +xa start 'a'; +xa end 'a'; +xa rollback 'a'; +xa start 'a'; +xa end 'a'; +xa rollback 'a'; + +# +# Bug#45548: XA transaction without access to InnoDB tables crashes the server +# + +xa start 'a'; +xa end 'a'; +xa prepare 'a'; +xa commit 'a'; + +xa start 'a'; +xa end 'a'; +xa prepare 'a'; +xa commit 'a'; + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test new file mode 100644 index 00000000000..6e7d38cdfca --- /dev/null +++ b/mysql-test/t/xml.test @@ -0,0 +1,620 @@ +SET @xml='<a aa1="aa1" aa2="aa2">a1<b ba1="ba1">b1<c>c1</c>b2</b>a2</a>'; +SELECT extractValue(@xml,'/a'); +SELECT extractValue(@xml,'/a/b'); +SELECT extractValue(@xml,'/a/b/c'); +SELECT extractValue(@xml,'/a/@aa1'); +SELECT extractValue(@xml,'/a/@aa2'); +SELECT extractValue(@xml,'/a/@*'); +SELECT extractValue(@xml,'//@ba1'); + +SELECT extractValue(@xml,'//a'); +SELECT extractValue(@xml,'//b'); +SELECT extractValue(@xml,'//c'); +SELECT extractValue(@xml,'/a//b'); +SELECT extractValue(@xml,'/a//c'); +SELECT extractValue(@xml,'//*'); +SELECT extractValue(@xml,'/a//*'); +SELECT extractValue(@xml,'/./a'); +SELECT extractValue(@xml,'/a/b/.'); +SELECT extractValue(@xml,'/a/b/..'); +SELECT extractValue(@xml,'/a/b/../@aa1'); +SELECT extractValue(@xml,'/*'); +SELECT extractValue(@xml,'/*/*'); +SELECT extractValue(@xml,'/*/*/*'); + +SELECT extractValue(@xml,'/a/child::*'); +SELECT extractValue(@xml,'/a/self::*'); +SELECT extractValue(@xml,'/a/descendant::*'); +SELECT extractValue(@xml,'/a/descendant-or-self::*'); +SELECT extractValue(@xml,'/a/attribute::*'); +SELECT extractValue(@xml,'/a/b/c/parent::*'); +SELECT extractValue(@xml,'/a/b/c/ancestor::*'); +SELECT extractValue(@xml,'/a/b/c/ancestor-or-self::*'); +SELECT extractValue(@xml,'/descendant-or-self::*'); + +SET @xml='<a>a11<b ba="ba11" ba="ba12">b11</b><b ba="ba21" ba="ba22">b21<c>c1</c>b22</b>a12</a>'; +SELECT extractValue(@xml,'/a/b/c/ancestor-or-self::*'); +SELECT extractValue(@xml,'//@ba'); + +SET @xml='<a><b>b</b><c>c</c></a>'; +SELECT extractValue(@xml,'/a/b'); +SELECT extractValue(@xml,'/a/c'); +SELECT extractValue(@xml,'/a/child::b'); +SELECT extractValue(@xml,'/a/child::c'); + +SET @xml='<a><b>b1</b><c>c1</c><b>b2</b><c>c2</c></a>'; +SELECT extractValue(@xml,'/a/b[1]'); +SELECT extractValue(@xml,'/a/b[2]'); +SELECT extractValue(@xml,'/a/c[1]'); +SELECT extractValue(@xml,'/a/c[2]'); + +SET @xml='<a><b x="xb1" x="xb2"/><c x="xc1" x="xc2"/></a>'; +SELECT extractValue(@xml,'/a//@x'); +SELECT extractValue(@xml,'/a//@x[1]'); +SELECT extractValue(@xml,'/a//@x[2]'); + +SET @xml='<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</c></b></a>'; +SELECT extractValue(@xml,'//b[1]'); +SELECT extractValue(@xml,'/descendant::b[1]'); + +SET @xml='<a><b>b1</b><b>b2</b></a>'; +SELECT extractValue(@xml,'/a/b[1+0]'); +SELECT extractValue(@xml,'/a/b[1*1]'); +SELECT extractValue(@xml,'/a/b[--1]'); +SELECT extractValue(@xml,'/a/b[2*1-1]'); + +SELECT extractValue(@xml,'/a/b[1+1]'); +SELECT extractValue(@xml,'/a/b[1*2]'); +SELECT extractValue(@xml,'/a/b[--2]'); +SELECT extractValue(@xml,'/a/b[1*(3-1)]'); + +SELECT extractValue(@xml,'//*[1=1]'); +SELECT extractValue(@xml,'//*[1!=1]'); +SELECT extractValue(@xml,'//*[1>1]'); +SELECT extractValue(@xml,'//*[2>1]'); +SELECT extractValue(@xml,'//*[1>2]'); +SELECT extractValue(@xml,'//*[1>=1]'); +SELECT extractValue(@xml,'//*[2>=1]'); +SELECT extractValue(@xml,'//*[1>=2]'); +SELECT extractValue(@xml,'//*[1<1]'); +SELECT extractValue(@xml,'//*[2<1]'); +SELECT extractValue(@xml,'//*[1<2]'); +SELECT extractValue(@xml,'//*[1<=1]'); +SELECT extractValue(@xml,'//*[2<=1]'); +SELECT extractValue(@xml,'//*[1<=2]'); + +SET @xml='<a><b>b11<c>c11</c></b><b>b21<c>c21</c></b></a>'; +SELECT extractValue(@xml,'/a/b[c="c11"]'); +SELECT extractValue(@xml,'/a/b[c="c21"]'); + +SET @xml='<a><b c="c11">b11</b><b c="c21">b21</b></a>'; +SELECT extractValue(@xml,'/a/b[@c="c11"]'); +SELECT extractValue(@xml,'/a/b[@c="c21"]'); + +SET @xml='<a>a1<b c="c11">b11<d>d11</d></b><b c="c21">b21<d>d21</d></b></a>'; +SELECT extractValue(@xml, '/a/b[@c="c11"]/d'); +SELECT extractValue(@xml, '/a/b[@c="c21"]/d'); +SELECT extractValue(@xml, '/a/b[d="d11"]/@c'); +SELECT extractValue(@xml, '/a/b[d="d21"]/@c'); +SELECT extractValue(@xml, '/a[b="b11"]'); +SELECT extractValue(@xml, '/a[b/@c="c11"]'); +SELECT extractValue(@xml, '/a[b/d="d11"]'); +SELECT extractValue(@xml, '/a[/a/b="b11"]'); +SELECT extractValue(@xml, '/a[/a/b/@c="c11"]'); +SELECT extractValue(@xml, '/a[/a/b/d="d11"]'); + +SELECT extractValue('<a>a</a>', '/a[false()]'); +SELECT extractValue('<a>a</a>', '/a[true()]'); +SELECT extractValue('<a>a</a>', '/a[not(false())]'); +SELECT extractValue('<a>a</a>', '/a[not(true())]'); +SELECT extractValue('<a>a</a>', '/a[true() and true()]'); +SELECT extractValue('<a>a</a>', '/a[true() and false()]'); +SELECT extractValue('<a>a</a>', '/a[false()and false()]'); +SELECT extractValue('<a>a</a>', '/a[false()and true()]'); +SELECT extractValue('<a>a</a>', '/a[true() or true()]'); +SELECT extractValue('<a>a</a>', '/a[true() or false()]'); +SELECT extractValue('<a>a</a>', '/a[false()or false()]'); +SELECT extractValue('<a>a</a>', '/a[false()or true()]'); + +SET @xml='<a>ab<b c="c" c="e">b1</b><b c="d">b2</b><b c="f" c="e">b3</b></a>'; +select extractValue(@xml,'/a/b[@c="c"]'); +select extractValue(@xml,'/a/b[@c="d"]'); +select extractValue(@xml,'/a/b[@c="e"]'); +select extractValue(@xml,'/a/b[not(@c="e")]'); +select extractValue(@xml,'/a/b[@c!="e"]'); +select extractValue(@xml,'/a/b[@c="c" or @c="d"]'); +select extractValue(@xml,'/a/b[@c="c" and @c="e"]'); + +SET @xml='<a><b c="c" d="d">b1</b><b d="d" e="e">b2</b></a>'; +select extractValue(@xml,'/a/b[@c]'); +select extractValue(@xml,'/a/b[@d]'); +select extractValue(@xml,'/a/b[@e]'); +select extractValue(@xml,'/a/b[not(@c)]'); +select extractValue(@xml,'/a/b[not(@d)]'); +select extractValue(@xml,'/a/b[not(@e)]'); + +select extractValue(@xml, '/a/b[boolean(@c) or boolean(@d)]'); +select extractValue(@xml, '/a/b[boolean(@c) or boolean(@e)]'); +select extractValue(@xml, '/a/b[boolean(@d) or boolean(@e)]'); +select extractValue(@xml, '/a/b[boolean(@c) and boolean(@d)]'); +select extractValue(@xml, '/a/b[boolean(@c) and boolean(@e)]'); +select extractValue(@xml, '/a/b[boolean(@d) and boolean(@e)]'); + +select extractValue(@xml, '/a/b[@c or @d]'); +select extractValue(@xml, '/a/b[@c or @e]'); +select extractValue(@xml, '/a/b[@d or @e]'); +select extractValue(@xml, '/a/b[@c and @d]'); +select extractValue(@xml, '/a/b[@c and @e]'); +select extractValue(@xml, '/a/b[@d and @e]'); + +SET @xml='<a><b c="c">b1</b><b>b2</b></a>'; +SELECT extractValue(@xml,'/a/b[@*]'); +SELECT extractValue(@xml,'/a/b[not(@*)]'); + +SELECT extractValue('<a>a</a>', '/a[ceiling(3.1)=4]'); +SELECT extractValue('<a>a</a>', '/a[floor(3.1)=3]'); +SELECT extractValue('<a>a</a>', '/a[round(3.1)=3]'); +SELECT extractValue('<a>a</a>', '/a[round(3.8)=4]'); + +SELECT extractValue('<a><b>b</b><c>c</c></a>', '/a/b | /a/c'); + +select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=1]'); +select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=2]'); +select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=3]'); +select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[1=position()]'); +select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2=position()]'); +select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[3=position()]'); +select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2>=position()]'); +select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2<=position()]'); +select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=3 or position()=2]'); + +SELECT extractValue('<a>a<b>a1<c>c1</c></b><b>a2</b></a>','/a/b[count(c)=0]'); +SELECT extractValue('<a>a<b>a1<c>c1</c></b><b>a2</b></a>','/a/b[count(c)=1]'); +select extractValue('<a>a1<b ba="1" ba="2">b1</b><b>b2</b>4</a>','/a/b[sum(@ba)=3]'); + +select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[1]'); +select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[boolean(1)]'); +select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[true()]'); +select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[number(true())]'); + +select extractValue('<a>ab</a>','/a[contains("abc","b")]'); +select extractValue('<a>ab</a>','/a[contains(.,"a")]'); +select extractValue('<a>ab</a>','/a[contains(.,"b")]'); +select extractValue('<a>ab</a>','/a[contains(.,"c")]'); + +select extractValue('<a b="1">ab</a>','/a[concat(@b,"2")="12"]'); + +SET @xml='<a b="11" b="12" b="21" b="22">ab</a>'; +select extractValue(@xml, '/a/@b[substring(.,2)="1"]'); +select extractValue(@xml, '/a/@b[substring(.,2)="2"]'); +select extractValue(@xml, '/a/@b[substring(.,1,1)="1"]'); +select extractValue(@xml, '/a/@b[substring(.,1,1)="2"]'); +select extractValue(@xml, '/a/@b[substring(.,2,1)="1"]'); +select extractValue(@xml, '/a/@b[substring(.,2,1)="2"]'); + +# +# Bug#16319: XML: extractvalue() returns syntax errors for some functions +# +SET @xml='<a><b>b1</b><b>b2</b></a>'; +SELECT extractValue(@xml, '/a/b[string-length("x")=1]'); +SELECT extractValue(@xml, '/a/b[string-length("xx")=2]'); +SELECT extractValue(@xml, '/a/b[string-length("xxx")=2]'); +SELECT extractValue(@xml, '/a/b[string-length("x")]'); +SELECT extractValue(@xml, '/a/b[string-length("xx")]'); +SELECT extractValue(@xml, '/a/b[string-length()]'); +--error 1105 +SELECT extractValue(@xml, 'string-length()'); +SELECT extractValue(@xml, 'string-length("x")'); + +SET @xml='<a b="b11" b="b12" b="b21" b="22"/>'; +select extractValue(@xml,'/a/@b'); +select extractValue(@xml,'/a/@b[contains(.,"1")]'); +select extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")]'); +select extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")][2]'); + +SET @xml='<a>a1<b>b1<c>c1</c>b2</b>a2</a>'; +select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','+++++++++'); +select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','<c1>+++++++++</c1>'); +select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','<c1/>'); + +SET @xml='<a><b>bb</b></a>'; +select UpdateXML(@xml, '/a/b', '<b>ccc</b>'); + +SET @xml='<a aa1="aa1" aa2="aa2"><b bb1="bb1" bb2="bb2">bb</b></a>'; +select UpdateXML(@xml, '/a/b', '<b>ccc</b>'); +select UpdateXML(@xml, '/a/@aa1', ''); +select UpdateXML(@xml, '/a/@aa1', 'aa3="aa3"'); +select UpdateXML(@xml, '/a/@aa2', ''); +select UpdateXML(@xml, '/a/@aa2', 'aa3="aa3"'); +select UpdateXML(@xml, '/a/b/@bb1', ''); +select UpdateXML(@xml, '/a/b/@bb1', 'bb3="bb3"'); +select UpdateXML(@xml, '/a/b/@bb2', ''); +select UpdateXML(@xml, '/a/b/@bb2', 'bb3="bb3"'); + +# +# Bug#27898 UPDATEXML Crashes the Server! +# +select updatexml('<div><div><span>1</span><span>2</span></div></div>', + '/','<tr><td>1</td><td>2</td></tr>') as upd1; +select updatexml('', '/', '') as upd2; + +# +# Bug#16234 XML: Crash if ExtractValue() +# +SET @xml= '<order><clerk>lesser wombat</clerk></order>'; +select extractvalue(@xml,'order/clerk'); +select extractvalue(@xml,'/order/clerk'); + +# +# Bug#16314 XML: extractvalue() crash if vertical bar +# +select extractvalue('<a><b>B</b></a>','/a|/b'); +select extractvalue('<a><b>B</b></a>','/a|b'); +select extractvalue('<a>a<b>B</b></a>','/a|/b'); +select extractvalue('<a>a<b>B</b></a>','/a|b'); +select extractvalue('<a>a<b>B</b></a>','a|/b'); + +# +# Bug#16312 XML: extractvalue() crash if angle brackets +# +--error 1105 +select extractvalue('<a>A</a>','/<a>'); + +# +# Bug#16313 XML: extractvalue() ignores '!' in names +# +--error 1105 +select extractvalue('<a><b>b</b><b!>b!</b!></a>','//b!'); + +# +# Bug #16315 XML: extractvalue() handles self badly +# +select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*'); +select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/self::*'); +select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant-or-self::*'); +# Bug #16320 XML: extractvalue() won't accept names containing underscores +# +select extractvalue('<A_B>A</A_B>','/A_B'); + +# +# Bug#16318: XML: extractvalue() incorrectly returns last() = 1 +# +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[position()]'); +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=last()]'); +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()]'); +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()-1]'); +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=1]'); +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=2]'); +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=position()]'); +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)]'); +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)-1]'); +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=1]'); +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=2]'); +select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=position()]'); +# +# Bug#16316: XML: extractvalue() is case-sensitive with contains() +# +select extractvalue('<a>Jack</a>','/a[contains(../a,"J")]'); +select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]'); +select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin); +select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]'); + +# +# Bug#18285: ExtractValue not returning character +# data within <![CDATA[]]> as expected +# +select ExtractValue('<tag1><![CDATA[test]]></tag1>','/tag1'); + +# +# Bug#18201: XML: ExtractValue works even if the xml fragment +# is not well-formed xml +# +select extractValue('<a>a','/a'); +select extractValue('<a>a<','/a'); +select extractValue('<a>a</','/a'); +select extractValue('<a>a</a','/a'); +select extractValue('<a>a</a></b>','/a'); +select extractValue('<a b=>a</a>','/a'); + +# +# Bug #18171 XML: ExtractValue: the XPath position() +# function crashes the server! +# +--error 1105 +select extractValue('<e>1</e>','position()'); +--error 1105 +select extractValue('<e>1</e>','last()'); + + +# +# Bug #18172 XML: Extractvalue() accepts mallformed +# XPath without a XPath syntax error +# +--error 1105 +select extractValue('<e><a>1</a></e>','/e/'); + +# +# Bug#16233: XML: ExtractValue() fails with special characters +# +set names utf8; +select extractValue('<Ñ><r>r</r></Ñ>','/Ñ/r'); +select extractValue('<r><Ñ>Ñ</Ñ></r>','/r/Ñ'); +select extractValue('<Ñ r="r"/>','/Ñ/@r'); +select extractValue('<r Ñ="Ñ"/>','/r/@Ñ'); +--disable_warnings +DROP PROCEDURE IF EXISTS p2; +--enable_warnings +DELIMITER //; +CREATE PROCEDURE p2 () +BEGIN + DECLARE p LONGTEXT CHARACTER SET UTF8 DEFAULT '<Ñ><r>A</r></Ñ>'; + SELECT EXTRACTVALUE(p,'/Ñ/r'); +END// +DELIMITER ;// +CALL p2(); +DROP PROCEDURE p2; + +# +# Bug#18170: XML: ExtractValue(): +# XPath expression can't use QNames (colon in names) +# +select extractValue('<ns:element xmlns:ns="myns"/>','count(ns:element)'); +select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element'); +select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element/@xmlns:ns'); + +# +# Bug#20795 extractvalue() won't accept names containing a dot (.) +# +select extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/foo.bar'); +select extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/something'); + +# +# Bug#20854 XML functions: wrong result in ExtractValue +# +--error 1105 +select extractValue('<zot><tim0><01>10:39:15</01><02>140</02></tim0></zot>','/zot/tim0/02'); +select extractValue('<zot><tim0><01>10:39:15</01><02>140</02></tim0></zot>','//*'); +# dot and dash are bad identtifier start character +select extractValue('<.>test</.>','//*'); +select extractValue('<->test</->','//*'); +# semicolon is good identifier start character +select extractValue('<:>test</:>','//*'); +# underscore is good identifier start character +select extractValue('<_>test</_>','//*'); +# dot, dash, underscore and semicolon are good identifier middle characters +select extractValue('<x.-_:>test</x.-_:>','//*'); + +# +# Bug#22823 gt and lt operators appear to be +# reversed in ExtractValue() command +# +set @xml= "<entry><id>pt10</id><pt>10</pt></entry><entry><id>pt50</id><pt>50</pt></entry>"; +select ExtractValue(@xml, "/entry[(pt=10)]/id"); +select ExtractValue(@xml, "/entry[(pt!=10)]/id"); +select ExtractValue(@xml, "/entry[(pt<10)]/id"); +select ExtractValue(@xml, "/entry[(pt<=10)]/id"); +select ExtractValue(@xml, "/entry[(pt>10)]/id"); +select ExtractValue(@xml, "/entry[(pt>=10)]/id"); +select ExtractValue(@xml, "/entry[(pt=50)]/id"); +select ExtractValue(@xml, "/entry[(pt!=50)]/id"); +select ExtractValue(@xml, "/entry[(pt<50)]/id"); +select ExtractValue(@xml, "/entry[(pt<=50)]/id"); +select ExtractValue(@xml, "/entry[(pt>50)]/id"); +select ExtractValue(@xml, "/entry[(pt>=50)]/id"); +select ExtractValue(@xml, "/entry[(10=pt)]/id"); +select ExtractValue(@xml, "/entry[(10!=pt)]/id"); +select ExtractValue(@xml, "/entry[(10>pt)]/id"); +select ExtractValue(@xml, "/entry[(10>=pt)]/id"); +select ExtractValue(@xml, "/entry[(10<pt)]/id"); +select ExtractValue(@xml, "/entry[(10<=pt)]/id"); +select ExtractValue(@xml, "/entry[(50=pt)]/id"); +select ExtractValue(@xml, "/entry[(50!=pt)]/id"); +select ExtractValue(@xml, "/entry[(50>pt)]/id"); +select ExtractValue(@xml, "/entry[(50>=pt)]/id"); +select ExtractValue(@xml, "/entry[(50<pt)]/id"); +select ExtractValue(@xml, "/entry[(50<=pt)]/id"); + +# +# Bug#24747 XPath error with the node name "Text" +# +# +# Test nodetypes in node name context +# +select ExtractValue('<a><b><Text>test</Text></b></a>','/a/b/Text'); +select ExtractValue('<a><b><comment>test</comment></b></a>','/a/b/comment'); +select ExtractValue('<a><b><node>test</node></b></a>','/a/b/node'); +select ExtractValue('<a><b><processing-instruction>test</processing-instruction></b></a>','/a/b/processing-instruction'); +# +# Test keywords in node name contexts +# +select ExtractValue('<a><and>test</and></a>', '/a/and'); +select ExtractValue('<a><or>test</or></a>', '/a/or'); +select ExtractValue('<a><mod>test</mod></a>', '/a/mod'); +select ExtractValue('<a><div>test</div></a>', '/a/div'); +select ExtractValue('<a><and:and>test</and:and></a>', '/a/and:and'); +select ExtractValue('<a><or:or>test</or:or></a>', '/a/or:or'); +select ExtractValue('<a><mod:mod>test</mod:mod></a>', '/a/mod:mod'); +select ExtractValue('<a><div:div>test</div:div></a>', '/a/div:div'); +# +# Test axis names in node name context +# +select ExtractValue('<a><ancestor>test</ancestor></a>', '/a/ancestor'); +select ExtractValue('<a><ancestor-or-self>test</ancestor-or-self></a>', '/a/ancestor-or-self'); +select ExtractValue('<a><attribute>test</attribute></a>', '/a/attribute'); +select ExtractValue('<a><child>test</child></a>', '/a/child'); +select ExtractValue('<a><descendant>test</descendant></a>', '/a/descendant'); +select ExtractValue('<a><descendant-or-self>test</descendant-or-self></a>', '/a/descendant-or-self'); +select ExtractValue('<a><following>test</following></a>', '/a/following'); +select ExtractValue('<a><following-sibling>test</following-sibling></a>', '/a/following-sibling'); +select ExtractValue('<a><namespace>test</namespace></a>', '/a/namespace'); +select ExtractValue('<a><parent>test</parent></a>', '/a/parent'); +select ExtractValue('<a><preceding>test</preceding></a>', '/a/preceding'); +select ExtractValue('<a><preceding-sibling>test</preceding-sibling></a>', '/a/preceding-sibling'); +select ExtractValue('<a><self>test</self></a>', '/a/self'); + +# +# Bug#26518 XPath and variables problem +# Check with user defined variables +# +set @i=1; +select ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]'); +set @i=2; +select ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]'); +set @i=NULL; +select ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]'); + +# +# Check variables in a stored procedure - both local and user variables +# Make sure that SP and local variables with the same name work together. +# +DELIMITER |; +CREATE PROCEDURE spxml(xml VARCHAR(128)) +BEGIN + DECLARE c INT; + DECLARE i INT DEFAULT 1; + SET c= ExtractValue(xml,'count(/a/b)'); + SET @i= c; + WHILE i <= c DO + BEGIN + SELECT i, @i, ExtractValue(xml,'/a/b[$i]'), ExtractValue(xml,'/a/b[$@i]'); + SET i= i + 1; + SET @i= @i - 1; + END; + END WHILE; +END| +DELIMITER ;| + +call spxml('<a><b>b1</b><b>b2</b><b>b3</b></a>'); +drop procedure spxml; + +# +# Additional tests for bug#26518 +--echo Multiple matches, but no index specification +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b'); +--echo No matches +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/c'); +--echo Index out of range +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[-1]'); +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[10]'); +--echo With string-to-number conversion +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["1"]'); +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["1 and string"]'); +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["string and 1"]'); +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b["string"]'); +--echo String-to-number conversion from a user variable +SET @i='1'; +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]'); +SET @i='1 and string'; +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]'); +SET @i='string and 1'; +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]'); +SET @i='string'; +SELECT ExtractValue('<a><b>b1</b><b>b2</b></a>','/a/b[$@i]'); + +--echo String-to-number conversion with a CHAR SP variable +DELIMITER |; +CREATE PROCEDURE spxml(xml VARCHAR(128), i CHAR(16)) +BEGIN + SELECT ExtractValue(xml,'/a/b[$i]'); +END| +DELIMITER ;| +CALL spxml('<a><b>b1</b><b>b2</b></a>', '1'); +CALL spxml('<a><b>b1</b><b>b2</b></a>', '1 and string'); +CALL spxml('<a><b>b1</b><b>b2</b></a>', 'string and 1'); +CALL spxml('<a><b>b1</b><b>b2</b></a>', 'string'); +DROP PROCEDURE spxml; + +# +# Bug#28558 UpdateXML called with garbage crashes server +# +--error 1105 +select UpdateXML('<a>a</a>',repeat('a b ',1000),''); +--error 1105 +select ExtractValue('<a>a</a>', '/a[@x=@y0123456789_0123456789_0123456789_0123456789]'); +--error 1105 +select ExtractValue('<a>a</a>', '/a[@x=$y0123456789_0123456789_0123456789_0123456789]'); + +# +# Bug #31438: updatexml still crashes +# + +select updatexml(NULL, 1, 1), updatexml(1, NULL, 1), updatexml(1, 1, NULL); +select updatexml(NULL, NULL, 1), updatexml(1, NULL, NULL), + updatexml(NULL, 1, NULL); +select updatexml(NULL, NULL, NULL); + +# +# Bug #32557: order by updatexml causes assertion in filesort +# +CREATE TABLE t1(a INT NOT NULL); +INSERT INTO t1 VALUES (0), (0); +SELECT 1 FROM t1 ORDER BY(UPDATEXML(a, '1', '1')); +DROP TABLE t1; + +# +# BUG#38227 EXTRACTVALUE doesn't work with DTD declarations +# +# Check that quoted strings work fine in DOCTYPE declaration. +# + +SET @xml= +'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> + <head> + <title> Title - document with document declaration</title> + </head> + <body> Hi, Im a webpage with document a declaration </body> +</html>'; + +SELECT ExtractValue(@xml, 'html/head/title'); +SELECT ExtractValue(@xml, 'html/body'); + +# These two documents will fail. +# Quoted strings are not allowed in regular tags +# +SELECT ExtractValue('<xml "xxx" "yyy">CharData</xml>', '/xml'); +SELECT ExtractValue('<xml xxx "yyy">CharData</xml>', '/xml'); + +# +# Bug#42495 updatexml: Assertion failed: xpath->context, file .\item_xmlfunc.cc, line 2507 +# +set @x=10; +--error ER_UNKNOWN_ERROR +select extractvalue('<a></a>','$@x/a'); +--error ER_UNKNOWN_ERROR +select extractvalue('<a></a>','round(123.4)/a'); +--error ER_UNKNOWN_ERROR +select extractvalue('<a></a>','1/a'); +--error ER_UNKNOWN_ERROR +select extractvalue('<a></a>','"b"/a'); +--error ER_UNKNOWN_ERROR +select extractvalue('<a></a>','(1)/a'); + +# +# Bug#43183 ExctractValue() brings result list in missorder +# +CREATE TABLE IF NOT EXISTS t1 ( + id int(10) unsigned NOT NULL AUTO_INCREMENT, + xml text, + PRIMARY KEY (id) +) ENGINE=MyISAM; + +INSERT INTO t1 (id, xml) VALUES +(15, '<?xml version="1.0"?><bla name="blubb"></bla>'), +(14, '<xml version="kaputt">'); + + +SELECT +extractvalue( xml, '/bla/@name' ), +extractvalue( xml, '/bla/@name' ) +FROM t1 ORDER BY t1.id; + + +SELECT +UpdateXML(xml, '/bla/@name', 'test'), +UpdateXML(xml, '/bla/@name', 'test') +FROM t1 ORDER BY t1.id; + +DROP TABLE t1; + +--echo End of 5.1 tests |