diff options
Diffstat (limited to 'mysql-test/t')
195 files changed, 7304 insertions, 855 deletions
diff --git a/mysql-test/t/almost_full.test b/mysql-test/t/almost_full.test index 24801f9cbc3..2517008fdf8 100644 --- a/mysql-test/t/almost_full.test +++ b/mysql-test/t/almost_full.test @@ -13,11 +13,13 @@ CREATE TABLE t1 (a int auto_increment primary key not null, b longtext) ENGINE=M --disable_query_log let $1= 303; +begin; while ($1) { INSERT INTO t1 SET b=repeat('a',200); dec $1; } +commit; --enable_query_log DELETE FROM t1 WHERE a=1 or a=5; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 2a8ac2a00d6..d0114a94dfd 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -121,11 +121,15 @@ alter table t1 disable keys; show keys from t1; #let $1=10000; let $1=10; +--disable_query_log +begin; while ($1) { eval insert into t1 values($1,RAND()*1000,RAND()*1000,RAND()); dec $1; } +commit; +--enable_query_log alter table t1 enable keys; show keys from t1; drop table t1; @@ -144,11 +148,15 @@ drop table t1; create table t1 (a int, b int); let $1=100; +--disable_query_log +begin; while ($1) { eval insert into t1 values(1,$1), (2,$1), (3, $1); dec $1; } +commit; +--enable_query_log alter table t1 add unique (a,b), add key (b); show keys from t1; analyze table t1; @@ -159,7 +167,7 @@ drop table t1; # Test of ALTER TABLE DELAYED # -CREATE TABLE t1 (i int(10), index(i) ); +CREATE TABLE t1 (i int(10), index(i) ) ENGINE=MyISAM; ALTER TABLE t1 DISABLE KEYS; INSERT DELAYED INTO t1 VALUES(1),(2),(3); ALTER TABLE t1 ENABLE KEYS; @@ -966,12 +974,14 @@ DROP TABLE t1; create table t1(f1 int not null, f2 int not null, key (f1), key (f2)); let $count= 50; --disable_query_log +begin; 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 ; } +commit; --enable_query_log select index_length into @unpaked_keys_size from @@ -1000,6 +1010,23 @@ ALTER TABLE t1 MODIFY b ENUM('a', 'z', 'b', 'c') NOT NULL; SELECT * FROM t1; DROP TABLE t1; +# +# Test for ALTER column DROP DEFAULT +# + +SET @save_sql_mode=@@sql_mode; +SET sql_mode=strict_all_tables; + +CREATE TABLE t1 (a int NOT NULL default 42); +INSERT INTO t1 values (); +SELECT * FROM t1; +ALTER TABLE t1 ALTER COLUMN a DROP DEFAULT; +--error 1364 +INSERT INTO t1 values (); +INSERT INTO t1 (a) VALUES (11); +SELECT * FROM t1 ORDER BY a; +DROP TABLE t1; +SET @@sql_mode=@save_sql_mode; --echo # --echo # Bug#45567: Fast ALTER TABLE broken for enum and set --echo # diff --git a/mysql-test/t/alter_table_trans.test b/mysql-test/t/alter_table_trans.test new file mode 100644 index 00000000000..9096a392af4 --- /dev/null +++ b/mysql-test/t/alter_table_trans.test @@ -0,0 +1,15 @@ +# +# Test of alter table with transactional tables +# + +--source include/have_innodb.inc +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +# +# This test caused a crash in wait_if_global_read_lock() +# +CREATE TABLE t1 (a INT, INDEX(a)) engine=innodb; +ALTER TABLE t1 RENAME TO t2, DISABLE KEYS; +DROP TABLE t2; diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 98ba5e03ede..9ecbee1ac9f 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -5,6 +5,8 @@ -- source include/have_archive.inc -- source include/have_binlog_format_mixed_or_statement.inc +call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired"); + --disable_warnings DROP TABLE if exists t1,t2,t3,t4,t5,t6; --enable_warnings @@ -1576,11 +1578,13 @@ CREATE TABLE t1(a VARCHAR(510)) ENGINE = ARCHIVE; let $bug31036=41; --disable_query_log +begin; while($bug31036) { INSERT INTO t1(a) VALUES (REPEAT('a', 510)); dec $bug31036; } +commit; --enable_query_log INSERT INTO t1(a) VALUES (''); @@ -1628,6 +1632,11 @@ SET @@join_buffer_size= @save_join_buffer_size; # BUG#47012 archive tables are not upgradeable, and server crashes on any access # let $MYSQLD_DATADIR= `SELECT @@datadir`; + +# Remove files to handle possible restart of test +flush tables; +remove_files_wildcard $MYSQLD_DATADIR/test t1.*; + copy_file std_data/bug47012.frm $MYSQLD_DATADIR/test/t1.frm; copy_file std_data/bug47012.ARZ $MYSQLD_DATADIR/test/t1.ARZ; copy_file std_data/bug47012.ARM $MYSQLD_DATADIR/test/t1.ARM; @@ -1678,7 +1687,18 @@ SELECT * FROM t1; REPAIR TABLE t1 EXTENDED; SELECT * FROM t1; DROP TABLE t1; - +# +# Bug #47012 archive tables are not upgradeable, and server crashes on +# any access +# +copy_file std_data/archive_5_0.frm $MYSQLD_DATADIR/test/t1.frm; +copy_file std_data/archive_5_0.ARZ $MYSQLD_DATADIR/test/t1.ARZ; +copy_file std_data/archive_5_0.ARM $MYSQLD_DATADIR/test/t1.ARM; +--error ER_TABLE_NEEDS_UPGRADE +select * from t1; +repair table t1; +select sum(length(a)),sum(b) from t1; +drop table t1; --echo # --echo # BUG#57162 - valgrind errors, random data when returning --echo # ordered data from archive tables diff --git a/mysql-test/t/bench_count_distinct.test b/mysql-test/t/bench_count_distinct.test index 131208f1fa1..87e3d75e996 100644 --- a/mysql-test/t/bench_count_distinct.test +++ b/mysql-test/t/bench_count_distinct.test @@ -7,14 +7,16 @@ drop table if exists t1; --enable_warnings create table t1(n int not null, key(n)) delay_key_write = 1; let $1=100; -disable_query_log; +--disable_query_log +begin; while ($1) { eval insert into t1 values($1); eval insert into t1 values($1); dec $1; } -enable_query_log; +commit; +--enable_query_log select count(distinct n) from t1; explain extended select count(distinct n) from t1; drop table t1; diff --git a/mysql-test/t/bootstrap.test b/mysql-test/t/bootstrap.test index db89269b35d..3b62887869d 100644 --- a/mysql-test/t/bootstrap.test +++ b/mysql-test/t/bootstrap.test @@ -5,7 +5,6 @@ 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; diff --git a/mysql-test/t/bug46080-master.opt b/mysql-test/t/bug46080-master.opt index f59740afe60..ff809c0cc69 100644 --- a/mysql-test/t/bug46080-master.opt +++ b/mysql-test/t/bug46080-master.opt @@ -1 +1 @@ ---skip-grant-tables --skip-name-resolve --safemalloc-mem-limit=4000000 +--skip-grant-tables --skip-name-resolve --safemalloc-mem-limit=20000000 --loose-maria-pagecache-buffer-size=1M diff --git a/mysql-test/t/bug46261-master.opt b/mysql-test/t/bug46261-master.opt index 6be4269e809..5699a3387b8 100644 --- a/mysql-test/t/bug46261-master.opt +++ b/mysql-test/t/bug46261-master.opt @@ -1 +1 @@ ---skip-grant-tables $EXAMPLE_PLUGIN_OPT +--skip-grant-tables diff --git a/mysql-test/t/bug46261.test b/mysql-test/t/bug46261.test index 67bdc995850..9d8eecf3d52 100644 --- a/mysql-test/t/bug46261.test +++ b/mysql-test/t/bug46261.test @@ -7,7 +7,7 @@ --replace_regex /\.dll/.so/ --error ER_OPTION_PREVENTS_STATEMENT -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$HA_EXAMPLE_SO'; --replace_regex /\.dll/.so/ --error ER_OPTION_PREVENTS_STATEMENT diff --git a/mysql-test/t/bug46760-master.opt b/mysql-test/t/bug46760-master.opt index f830d135149..2d7be7fb9b1 100644 --- a/mysql-test/t/bug46760-master.opt +++ b/mysql-test/t/bug46760-master.opt @@ -1,2 +1,2 @@ ---innodb-lock-wait-timeout=2 ---innodb-file-per-table +--loose-innodb-lock-wait-timeout=2 +--loose-innodb-file-per-table diff --git a/mysql-test/t/bug47671-master.opt b/mysql-test/t/bug47671-master.opt index 0afdf49e022..ad54fbc3467 100644 --- a/mysql-test/t/bug47671-master.opt +++ b/mysql-test/t/bug47671-master.opt @@ -1 +1 @@ ---default-character-set=utf8 --skip-character-set-client-handshake +--character-set-server=utf8 --skip-character-set-client-handshake diff --git a/mysql-test/t/change_user.test b/mysql-test/t/change_user.test index 3ed798e8d36..1d3a3fd810f 100644 --- a/mysql-test/t/change_user.test +++ b/mysql-test/t/change_user.test @@ -1,5 +1,6 @@ # # Bug#20023 mysql_change_user() resets the value of SQL_BIG_SELECTS +# The replace's are here to fix things for 32 bit systems # --echo Bug#20023 @@ -26,6 +27,10 @@ SET @@session.max_join_size = default; --echo change_user --change_user SELECT @@session.sql_big_selects; +--replace_result 4294967295 18446744073709551615 +SELECT @@global.max_join_size; +--replace_result 4294967295 18446744073709551615 +SELECT @@session.max_join_size; # # Bug#31418 User locks misfunctioning after mysql_change_user() @@ -52,13 +57,13 @@ FLUSH STATUS; --disable_query_log let $i = 100; - +begin; while ($i) { dec $i; - SELECT 1; } +commit; --enable_query_log --enable_result_log diff --git a/mysql-test/t/check.test b/mysql-test/t/check.test index ff23b352b5a..78644523976 100644 --- a/mysql-test/t/check.test +++ b/mysql-test/t/check.test @@ -12,13 +12,15 @@ drop view if exists v1; # Add a lot of keys to slow down check create table t1(n int not null, key(n), key(n), key(n), key(n)); let $1=10000; -disable_query_log; +--disable_query_log +begin; while ($1) { eval insert into t1 values ($1); dec $1; } -enable_query_log; +commit; +--enable_query_log send check table t1 extended; connection con2; insert into t1 values (200000); diff --git a/mysql-test/t/compress.test b/mysql-test/t/compress.test index 0a20daef8de..8fc21d9c961 100644 --- a/mysql-test/t/compress.test +++ b/mysql-test/t/compress.test @@ -3,8 +3,9 @@ # Can't test with embedded server -- source include/not_embedded.inc - -- source include/have_compress.inc +# Slow test, don't run during staging part +-- source include/not_staging.inc # Save the initial number of concurrent sessions --source include/count_sessions.inc diff --git a/mysql-test/t/concurrent_innodb_safelog-master.opt b/mysql-test/t/concurrent_innodb_safelog-master.opt index 462f8fbe828..82dec8b25fd 100644 --- a/mysql-test/t/concurrent_innodb_safelog-master.opt +++ b/mysql-test/t/concurrent_innodb_safelog-master.opt @@ -1 +1 @@ ---innodb_lock_wait_timeout=1 +--loose-innodb_lock_wait_timeout=1 diff --git a/mysql-test/t/concurrent_innodb_unsafelog-master.opt b/mysql-test/t/concurrent_innodb_unsafelog-master.opt index 210212a40bc..ea9c1b860e9 100644 --- a/mysql-test/t/concurrent_innodb_unsafelog-master.opt +++ b/mysql-test/t/concurrent_innodb_unsafelog-master.opt @@ -1,2 +1,2 @@ ---innodb_locks_unsafe_for_binlog ---innodb_lock_wait_timeout=1 +--loose-innodb_locks_unsafe_for_binlog +--loose-innodb_lock_wait_timeout=1 diff --git a/mysql-test/t/connect.cnf b/mysql-test/t/connect.cnf new file mode 100644 index 00000000000..caf51ee2085 --- /dev/null +++ b/mysql-test/t/connect.cnf @@ -0,0 +1,8 @@ +!include include/default_my.cnf + +[mysqld.1] +extra-port= @mysqld.1.#extra-port +extra-max-connections=1 + +[ENV] +MASTER_EXTRA_PORT= @mysqld.1.#extra-port diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index d0b79ab6bd3..671f7baa61e 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -293,6 +293,32 @@ SET GLOBAL event_scheduler = OFF; --echo # -- End of Bug#35074. --echo +# Test connections to the extra port. + +connect(extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,); +connection extracon; +SELECT 'Connection on extra port ok'; + +connect(extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,); +connection extracon2; +SELECT 'Connection on extra port 2 ok'; + +--disable_abort_on_error +--disable_result_log +--disable_query_log +connect(extracon3,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,); +--enable_query_log +--enable_result_log +--enable_abort_on_error +let $error = $mysql_errno; +if (!$error) +{ + --echo # -- Error: managed to establish more than --extra-max-connections + 1 connections +} +if ($error) +{ + --echo # -- Success: more than --extra-max-connections + 1 normal connections not possible +} ########################################################################### @@ -319,12 +345,14 @@ FLUSH PRIVILEGES; --echo # -- End of Bug#49752 --echo # - - --echo # ------------------------------------------------------------------ --echo # -- End of 5.1 tests --echo # ------------------------------------------------------------------ +--disconnect extracon +--disconnect extracon2 +--connection default + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/count_distinct2.test b/mysql-test/t/count_distinct2.test index 8dcb2a70065..95086ad04aa 100644 --- a/mysql-test/t/count_distinct2.test +++ b/mysql-test/t/count_distinct2.test @@ -51,13 +51,15 @@ drop table t1; # test the conversion from tree to MyISAM create table t1 (n int default NULL); let $1=5000; -disable_query_log; +--disable_query_log +begin; while ($1) { eval insert into t1 values($1); dec $1; } -enable_query_log; +commit; +--enable_query_log flush status; select count(distinct n) from t1; @@ -67,13 +69,15 @@ drop table t1; # Test use of MyISAM tmp tables create table t1 (s text); let $1=5000; -disable_query_log; +--disable_query_log +begin; while ($1) { eval insert into t1 values('$1'); dec $1; } -enable_query_log; +commit; +--enable_query_log flush status; select count(distinct s) from t1; show status like 'Created_tmp_disk_tables'; diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test index ad2bbee95a3..8aecd628423 100644 --- a/mysql-test/t/count_distinct3.test +++ b/mysql-test/t/count_distinct3.test @@ -3,8 +3,8 @@ # mysql-4.1 # +# Slow test --source include/big_test.inc - --disable_warnings DROP TABLE IF EXISTS t1, t2; --enable_warnings @@ -14,6 +14,7 @@ CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER); --disable_query_log SET @rnd_max= 2147483647; let $1 = 1000; +begin; while ($1) { SET @rnd= RAND(); @@ -23,7 +24,7 @@ while ($1) INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev); dec $1; } - +commit; # We increase the size of t1 here. SET @orig_myisam_sort_buffer_size = @@session.myisam_sort_buffer_size; SET session myisam_sort_buffer_size=20000000; diff --git a/mysql-test/t/crash_commit_before-master.opt b/mysql-test/t/crash_commit_before-master.opt index a745693594e..425fda95086 100644 --- a/mysql-test/t/crash_commit_before-master.opt +++ b/mysql-test/t/crash_commit_before-master.opt @@ -1,2 +1 @@ --skip-stack-trace --skip-core-file - diff --git a/mysql-test/t/crash_commit_before.test b/mysql-test/t/crash_commit_before.test index 6e36d2345e1..f99690777c9 100644 --- a/mysql-test/t/crash_commit_before.test +++ b/mysql-test/t/crash_commit_before.test @@ -14,7 +14,7 @@ START TRANSACTION; insert into t1 values(9); # Setup the mysqld to crash at certain point -SET SESSION debug="d,crash_commit_before"; +SET GLOBAL 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 diff --git a/mysql-test/t/create-uca.test b/mysql-test/t/create-uca.test new file mode 100644 index 00000000000..0acb51f7286 --- /dev/null +++ b/mysql-test/t/create-uca.test @@ -0,0 +1,26 @@ +# Prerequisites +let collation=utf8_unicode_ci; +--source include/have_collation.inc + +# Initial cleanup +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +# +# Bug#21380: DEFAULT definition not always transfered by CREATE +# TABLE/SELECT to the new table. +# + +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; +SHOW CREATE TABLE t1; +CREATE TABLE t2 AS SELECT * FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE t1,t2; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 692721b5955..fa991aab0d7 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -1105,12 +1105,12 @@ drop table t1; 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); +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); # Get error for max key parts --error 1070 alter table t1 add key i1 ( - c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, c17); + c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31,c32,c33); # Get error for max key-name length --error 1059 @@ -1384,9 +1384,11 @@ drop function f1; # Bug#25629 CREATE TABLE LIKE does not work with INFORMATION_SCHEMA # create table t1 like information_schema.processlist; +--replace_result ENGINE=MyISAM "" ENGINE=MARIA "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" "" show create table t1; drop table t1; create temporary table t1 like information_schema.processlist; +--replace_result ENGINE=MyISAM "" ENGINE=MARIA "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" "" show create table t1; drop table t1; create table t1 like information_schema.character_sets; @@ -1397,52 +1399,6 @@ 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 @@ -1570,14 +1526,38 @@ drop table `me:i`; --disable_warnings drop table if exists t1,t2,t3; --enable_warnings ---error ER_PARSE_ERROR +--echo # Fix modified for MariaDB: we support this syntax 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; +drop table t1,t2,t3; --echo --echo # -- End of Bug#45829 +# +--echo # new table creation/renaming blocked if old encoded table present +# +let $MYSQLD_DATADIR= `select @@datadir`; +create table `t-1` (a int) engine=myisam; +insert into `t-1` values (1); +show tables; +flush tables; +--echo convert table files in mysql 5.0 file name encoding +--copy_file $MYSQLD_DATADIR/test/t@002d1.MYD $MYSQLD_DATADIR/test/t-1.MYD +--copy_file $MYSQLD_DATADIR/test/t@002d1.MYI $MYSQLD_DATADIR/test/t-1.MYI +--copy_file $MYSQLD_DATADIR/test/t@002d1.frm $MYSQLD_DATADIR/test/t-1.frm +--remove_file $MYSQLD_DATADIR/test/t@002d1.MYD +--remove_file $MYSQLD_DATADIR/test/t@002d1.MYI +--remove_file $MYSQLD_DATADIR/test/t@002d1.frm +show tables; +--error ER_TABLE_EXISTS_ERROR +create table `t-1` (a int); +create table t1 (a int); +--error ER_TABLE_EXISTS_ERROR +alter table t1 rename `t-1`; +--error ER_TABLE_EXISTS_ERROR +rename table t1 to `t-1`; +drop table `#mysql50#t-1`, t1; + --echo --echo End of 5.1 tests diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 4e337d54660..fd08f7c5a40 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -4,6 +4,9 @@ --source include/have_csv.inc +call mtr.add_suppression("Table 'test_repair_table2' is marked as crashed and should be repaired"); +call mtr.add_suppression("Table 'test_repair_table4' is marked as crashed and should be repaired"); + # # Simple select test # diff --git a/mysql-test/t/ctype_euckr.test b/mysql-test/t/ctype_euckr.test index fcb94e7b6d1..dcfb980fc37 100644 --- a/mysql-test/t/ctype_euckr.test +++ b/mysql-test/t/ctype_euckr.test @@ -77,11 +77,13 @@ DROP TABLE t1; CREATE TABLE t1 (a binary(1), key(a)); --disable_query_log let $1=255; +begin; while($1) { eval INSERT INTO t1 VALUES (unhex(hex($1))); dec $1; } +commit; --enable_query_log CREATE TABLE t2 (s VARCHAR(4), a VARCHAR(1) CHARACTER SET euckr); diff --git a/mysql-test/t/ctype_filesystem.test b/mysql-test/t/ctype_filesystem.test index 2b993c2b924..42f1ef06478 100644 --- a/mysql-test/t/ctype_filesystem.test +++ b/mysql-test/t/ctype_filesystem.test @@ -1,3 +1,5 @@ +--source include/not_windows.inc + SET CHARACTER SET utf8; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR SHOW VARIABLES like 'character_sets_dir'; diff --git a/mysql-test/t/ctype_latin1_de-master.opt b/mysql-test/t/ctype_latin1_de-master.opt index 79fdb1c63dc..063fe5b7792 100644 --- a/mysql-test/t/ctype_latin1_de-master.opt +++ b/mysql-test/t/ctype_latin1_de-master.opt @@ -1 +1 @@ ---default-character-set=latin1 --default-collation=latin1_german2_ci +--character-set-server=latin1 --default-collation=latin1_german2_ci diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index 11a489ba24d..96831c8c915 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -186,6 +186,7 @@ insert into t1 values (_ucs2 0x01fc),(_ucs2 0x01fd),(_ucs2 0x01fe),(_ucs2 0x01ff insert into t1 values ('AA'),('Aa'),('aa'),('aA'); insert into t1 values ('CH'),('Ch'),('ch'),('cH'); insert into t1 values ('DZ'),('Dz'),('dz'),('dZ'); +insert into t1 values ('DŽ'),('Dž'),('dž'),('dŽ'); insert into t1 values ('IJ'),('Ij'),('ij'),('iJ'); insert into t1 values ('LJ'),('Lj'),('lj'),('lJ'); insert into t1 values ('LL'),('Ll'),('ll'),('lL'); @@ -213,6 +214,7 @@ select group_concat(c1 order by c1) from t1 group by c1 collate utf8_spanish2_ci select group_concat(c1 order by c1) from t1 group by c1 collate utf8_roman_ci; select group_concat(c1 order by c1) from t1 group by c1 collate utf8_esperanto_ci; select group_concat(c1 order by c1) from t1 group by c1 collate utf8_hungarian_ci; +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_croatian_ci; drop table t1; diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index a9ce6b0b23d..8b266fb4748 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -748,3 +748,34 @@ SELECT HEX(CHAR(COALESCE(NULL, CHAR(COUNT('%s') USING ucs2), 1, @@global.license SELECT CONVERT(QUOTE(CHAR(0xf5 using ucs2)), SIGNED); --echo End of 5.0 tests + + +--echo Start of 5.1 tests +# +# Checking my_like_range_ucs2 +# +SET NAMES utf8; +CREATE TABLE t1 ( + a varchar(10) CHARACTER SET ucs2 COLLATE ucs2_czech_ci, + key(a) +); +INSERT INTO t1 VALUES +('aa'),('bb'),('cc'),('dd'),('ee'),('ff'),('gg'),('hh'),('ii'), +('jj'),('kk'),('ll'),('mm'),('nn'),('oo'),('pp'),('rr'),('ss'), +('tt'),('uu'),('vv'),('ww'),('xx'),('yy'),('zz'); +INSERT INTO t1 VALUES ('ca'),('cz'),('ch'); +INSERT INTO t1 VALUES ('da'),('dz'), (X'0064017E'); +# This one should scan only one row +EXPLAIN SELECT * FROM t1 WHERE a LIKE 'b%'; +# This one should scan many rows: 'c' is a contraction head +EXPLAIN SELECT * FROM t1 WHERE a LIKE 'c%'; +SELECT * FROM t1 WHERE a LIKE 'c%'; +EXPLAIN SELECT * FROM t1 WHERE a LIKE 'ch%'; +SELECT * FROM t1 WHERE a LIKE 'ch%'; +ALTER TABLE t1 MODIFY a VARCHAR(10) CHARACTER SET ucs2 COLLATE ucs2_croatian_ci; +EXPLAIN SELECT * FROM t1 WHERE a LIKE 'd%'; +SELECT hex(concat('d',_ucs2 0x017E,'%')); +EXPLAIN SELECT * FROM t1 WHERE a LIKE concat('d',_ucs2 0x017E,'%'); +SELECT hex(a) FROM t1 WHERE a LIKE concat('D',_ucs2 0x017E,'%'); + +DROP TABLE t1; diff --git a/mysql-test/t/ctype_ucs2_def-master.opt b/mysql-test/t/ctype_ucs2_def-master.opt index 84d2a52b639..d42c50f3c7e 100644 --- a/mysql-test/t/ctype_ucs2_def-master.opt +++ b/mysql-test/t/ctype_ucs2_def-master.opt @@ -1 +1 @@ ---default-collation=ucs2_unicode_ci --default-character-set=ucs2,latin1 +--default-collation=ucs2_unicode_ci --character-set-server=ucs2,latin1 diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 8e9f09d1e56..352ace03102 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -2,6 +2,15 @@ # Tests with the utf8 character set # +let collation=utf8_unicode_ci; +--source include/have_collation.inc + +--disable_warnings +drop table if exists t1,t2,t3,t4; +drop database if exists mysqltest; +--enable_warnings + + --disable_warnings drop table if exists t1,t2; --enable_warnings @@ -164,7 +173,7 @@ drop table t1; # UTF8 breaks primary keys for cols > 333 characters # --error 1071 -create table t1 (a text character set utf8, primary key(a(360))); +create table t1 (a text character set utf8, primary key(a(371))); # diff --git a/mysql-test/t/ddl_i18n_koi8r.test b/mysql-test/t/ddl_i18n_koi8r.test index fecef2f95d5..9df9806526c 100644 --- a/mysql-test/t/ddl_i18n_koi8r.test +++ b/mysql-test/t/ddl_i18n_koi8r.test @@ -36,6 +36,8 @@ --source include/have_cp866.inc --source include/have_cp1251.inc --source include/have_koi8r.inc +let collation=utf8_unicode_ci; +--source include/have_collation.inc ########################################################################### diff --git a/mysql-test/t/ddl_i18n_utf8.test b/mysql-test/t/ddl_i18n_utf8.test index 8788d0604f2..1d8c5676dee 100644 --- a/mysql-test/t/ddl_i18n_utf8.test +++ b/mysql-test/t/ddl_i18n_utf8.test @@ -36,6 +36,8 @@ --source include/have_cp866.inc --source include/have_cp1251.inc --source include/have_koi8r.inc +let collation=utf8_unicode_ci; +--source include/have_collation.inc ########################################################################### diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 689341391c9..ead1d0dfd14 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -5,6 +5,15 @@ # (Can't be tested with purify :( ) # +# limit the test to engines which support INSERT DELAYED +disable_query_log; +--require r/true.require +select @@global.storage_engine in +("memory","myisam","archive","blackhole") and +@@session.storage_engine in +("memory","myisam","archive","blackhole") as `TRUE`; +enable_query_log; + --disable_warnings drop table if exists t1; --enable_warnings @@ -247,7 +256,11 @@ DROP TABLE t1; # Bug #32676: insert delayed crash with wrong column and function specified # CREATE TABLE t1 (a INT); ---error ER_BAD_FIELD_ERROR +--error ER_SP_DOES_NOT_EXIST +INSERT DELAYED INTO t1 SET a= b(); +--error ER_BAD_FIELD_ERROR +INSERT DELAYED INTO t1 SET b= 1; +--error ER_SP_DOES_NOT_EXIST INSERT DELAYED INTO t1 SET b= b(); DROP TABLE t1; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 5ce6b52b74f..962cec95add 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -45,14 +45,16 @@ select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1; drop table t1, t2; create table t1(a int not null, t char(8), index(a)); -disable_query_log; +--disable_query_log +begin; let $1 = 10000; while ($1) { eval insert into t1 values ($1,'$1'); dec $1; } -enable_query_log; +commit; +--enable_query_log SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20; explain select count(*) from t1 as tt1, (select * from t1) as tt2; drop table t1; diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index bb4dd3e11f9..66fe3bb03b2 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -195,9 +195,10 @@ 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); +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234` (a int); --error ER_WRONG_TABLE_NAME -create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int); +create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345` (a int); +show tables; use test; drop database mysqltestbug26703; diff --git a/mysql-test/t/events_logs_tests-master.opt b/mysql-test/t/events_logs_tests-master.opt index 3ece9710a45..73d26b7260d 100644 --- a/mysql-test/t/events_logs_tests-master.opt +++ b/mysql-test/t/events_logs_tests-master.opt @@ -1 +1 @@ ---log-output=table,file --log-slow-queries +--slow-query-log --log-output=table --general-log --general-log-file="" --slow-query-log-file="" diff --git a/mysql-test/t/events_logs_tests.test b/mysql-test/t/events_logs_tests.test index 3240dccbc76..1c296ee302b 100644 --- a/mysql-test/t/events_logs_tests.test +++ b/mysql-test/t/events_logs_tests.test @@ -75,12 +75,10 @@ create event ev_log_general on schedule at now() on completion not preserve --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 # diff --git a/mysql-test/t/events_stress.test b/mysql-test/t/events_stress.test index e51fa734256..8ea7633877b 100644 --- a/mysql-test/t/events_stress.test +++ b/mysql-test/t/events_stress.test @@ -61,6 +61,7 @@ while ($1) } --enable_query_log SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; +SET @old_event_scheduler=@@event_scheduler; SET GLOBAL event_scheduler=on; --sleep 2.5 DROP DATABASE events_conn1_test2; @@ -137,5 +138,5 @@ DROP USER event_user3@localhost; DROP DATABASE events_test; # Cleanup -SET GLOBAL event_scheduler=off; +SET GLOBAL event_scheduler=@old_event_scheduler; --source include/check_events_off.inc diff --git a/mysql-test/t/events_time_zone.test b/mysql-test/t/events_time_zone.test index ccae7847618..5291eb96e6b 100644 --- a/mysql-test/t/events_time_zone.test +++ b/mysql-test/t/events_time_zone.test @@ -5,7 +5,7 @@ # 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; +let $N = 6; # # 2. Some subtests # - create a new time zone @@ -36,6 +36,9 @@ let $N = 5; # after a tests would be a perfect replacement. # +# Can't test with embedded server that doesn't support grants +-- source include/not_embedded.inc + --source include/big_test.inc @@ -115,6 +118,7 @@ INSERT INTO mysql.time_zone_transition_type let $transition_unix_time= `SELECT @unix_time`; let $count= 30; --disable_query_log +begin; while ($count) { eval INSERT INTO mysql.time_zone_transition @@ -123,6 +127,7 @@ while ($count) let $transition_unix_time= `SELECT $transition_unix_time + @step3`; dec $count; } +commit; --enable_query_log let $tz_name = `SELECT CONCAT('b16420_a',UNIX_TIMESTAMP())`; --replace_result $tz_name <TZ_NAME_1> @@ -169,13 +174,13 @@ CREATE EVENT e2 ON SCHEDULE EVERY @step SECOND # 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_timeout= `SELECT @step6*2 + 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_timeout= `SELECT @step*2 + 1`; let $wait_condition= SELECT UNIX_TIMESTAMP() % @step6 = 0; --source include/wait_condition.inc diff --git a/mysql-test/t/exampledb.test b/mysql-test/t/exampledb.test deleted file mode 100644 index fbb2a18f344..00000000000 --- a/mysql-test/t/exampledb.test +++ /dev/null @@ -1,22 +0,0 @@ -# -# Simple test for the example storage engine -# Taken fromm the select test -# --- 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 - -CREATE TABLE t1 ( - Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, - Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL -) ENGINE=example; - -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/feedback_plugin_install.opt b/mysql-test/t/feedback_plugin_install.opt new file mode 100644 index 00000000000..a711ae94e69 --- /dev/null +++ b/mysql-test/t/feedback_plugin_install.opt @@ -0,0 +1 @@ +--loose-feedback diff --git a/mysql-test/t/feedback_plugin_install.test b/mysql-test/t/feedback_plugin_install.test new file mode 100644 index 00000000000..81343c436c3 --- /dev/null +++ b/mysql-test/t/feedback_plugin_install.test @@ -0,0 +1,15 @@ +--source include/not_embedded.inc + +if (`select length('$FEEDBACK_SO') = 0`) { + skip No feedback plugin; +} + +--replace_regex /\.dll/.so/ +eval install plugin feedback soname '$FEEDBACK_SO'; +select plugin_status from information_schema.plugins where plugin_name='feedback'; +--replace_result https http +--sorted_result +select * from information_schema.feedback where variable_name like 'feed%' + and variable_name not like '%_uid'; +uninstall plugin feedback; + diff --git a/mysql-test/t/feedback_plugin_load.opt b/mysql-test/t/feedback_plugin_load.opt new file mode 100644 index 00000000000..5fbb2f83954 --- /dev/null +++ b/mysql-test/t/feedback_plugin_load.opt @@ -0,0 +1,2 @@ +--loose-feedback +--plugin-load=$FEEDBACK_SO diff --git a/mysql-test/t/feedback_plugin_load.test b/mysql-test/t/feedback_plugin_load.test new file mode 100644 index 00000000000..5ad301667b4 --- /dev/null +++ b/mysql-test/t/feedback_plugin_load.test @@ -0,0 +1,10 @@ +if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'feedback' and plugin_status='active'`) +{ + --skip Feedback plugin is not active +} + +select plugin_status from information_schema.plugins where plugin_name='feedback'; +--replace_result https http +--sorted_result +select * from information_schema.feedback where variable_name like 'feed%' + and variable_name not like '%_uid'; diff --git a/mysql-test/t/feedback_plugin_send.test b/mysql-test/t/feedback_plugin_send.test new file mode 100644 index 00000000000..b49c0d0e252 --- /dev/null +++ b/mysql-test/t/feedback_plugin_send.test @@ -0,0 +1,24 @@ +source t/feedback_plugin_load.test; +source include/big_test.inc; + +if (!$MTR_FEEDBACK_PLUGIN) { + skip MTR_FEEDBACK_PLUGIN is not set; +} + +# +# Yep. The plugin waits 5 minutes before sending anything, +# and there's no way to force it to send anything sooner. +# Let's wait, and hope that mtr is started with --parallel and +# is doing some work in other workers. +# +sleep 310; +source include/restart_mysqld.inc; + +replace_result https http; +perl; + $log_error= $ENV{'MYSQLTEST_VARDIR'} . '/log/mysqld.1.err'; + open(LOG, '<', $log_error) or die "open(< $log_error): $!"; + /feedback plugin:.*/ && print "$&\n" while $_=<LOG>; + close LOG; +EOF + diff --git a/mysql-test/t/foreign_key.test b/mysql-test/t/foreign_key.test index 0a3708e6dc8..e71d4494d31 100644 --- a/mysql-test/t/foreign_key.test +++ b/mysql-test/t/foreign_key.test @@ -2,8 +2,10 @@ # Test syntax of foreign keys # +-- source include/have_innodb.inc + --disable_warnings -drop table if exists t1; +drop table if exists t1,t2; --enable_warnings create table t1 ( @@ -23,3 +25,23 @@ create unique index b on t1 (a,b); drop table t1; # End of 4.1 tests + +# +# Test DELETE IGNORE +# Bug#44987 DELETE IGNORE and FK constraint +# + +create table t1 (id int primary key) engine = innodb; +create table t2 (id int PRIMARY KEY, FOREIGN KEY (id) REFERENCES t1(id)) engine=innodb; +insert into t1 values (1), (2), (3), (4), (5), (6); +insert into t2 values (3), (5); + +--error 1451 +delete from t1; +select * from t1; + +delete ignore from t1; +select row_count(); +select * from t1; +drop table t2; +drop table t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 6de8b87197c..7af9d3706e6 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -2,6 +2,9 @@ # Test of fulltext index # +let collation=utf8_unicode_ci; +--source include/have_collation.inc + --disable_warnings drop table if exists t1,t2,t3; --enable_warnings @@ -447,6 +450,15 @@ WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; DROP TABLE t1; # +# bug#34374 - mysql generates incorrect warning +# +create table t1(a text,b date,fulltext index(a))engine=myisam; +insert into t1 set a='water',b='2008-08-04'; +select 1 from t1 where match(a) against ('water' in boolean mode) and b>='2008-08-01'; +drop table t1; +show warnings; + +# # BUG#37245 - Full text search problem # CREATE TABLE t1(a CHAR(10)); diff --git a/mysql-test/t/fulltext2.test b/mysql-test/t/fulltext2.test index 88967a5dd04..78c7c859e95 100644 --- a/mysql-test/t/fulltext2.test +++ b/mysql-test/t/fulltext2.test @@ -2,6 +2,9 @@ # test of new fulltext search features # +let collation=utf8_unicode_ci; +--source include/have_collation.inc + # # two-level tree # @@ -18,6 +21,7 @@ CREATE TABLE t1 ( # two-level entry, second-level tree with depth 2 --disable_query_log +begin; let $1=260; while ($1) { @@ -40,6 +44,7 @@ while ($1) eval insert t1 (a) values ('aaayyy'); dec $1; } +commit; --enable_query_log # converting to two-level @@ -113,6 +118,7 @@ CREATE TABLE t1 ( # two-level entry, second-level tree with depth 2 --disable_query_log let $1=260; +begin; while ($1) { eval insert t1 (a) values ('aaaxxx'); @@ -130,6 +136,7 @@ while ($1) eval insert t1 (a) values ('aaayyy'); dec $1; } +commit; --enable_query_log select count(*) from t1 where match a against ('aaaxxx'); diff --git a/mysql-test/t/fulltext_plugin-master.opt b/mysql-test/t/fulltext_plugin-master.opt deleted file mode 100644 index a2554caa20b..00000000000 --- a/mysql-test/t/fulltext_plugin-master.opt +++ /dev/null @@ -1 +0,0 @@ -$SIMPLE_PARSER_OPT diff --git a/mysql-test/t/fulltext_plugin.test b/mysql-test/t/fulltext_plugin.test index 31978dadc51..0e2f53d5b15 100644 --- a/mysql-test/t/fulltext_plugin.test +++ b/mysql-test/t/fulltext_plugin.test @@ -3,7 +3,8 @@ # # BUG#39746 - Debug flag breaks struct definition (server crash) # -INSTALL PLUGIN simple_parser SONAME 'mypluglib.so'; +--replace_result .dll .so +eval 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; diff --git a/mysql-test/t/func_compress.test b/mysql-test/t/func_compress.test index d63130f190d..207f3a436d0 100644 --- a/mysql-test/t/func_compress.test +++ b/mysql-test/t/func_compress.test @@ -110,3 +110,8 @@ EXPLAIN EXTENDED SELECT * FROM (SELECT UNCOMPRESSED_LENGTH(c1) FROM t1) AS s; DROP TABLE t1; --echo End of 5.0 tests +--disable_result_log +--disable_query_log +set @@global.max_allowed_packet=default; +--enable_result_log +--enable_query_log diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index 4efea8e195e..8142f57c0de 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -5,6 +5,11 @@ drop table if exists t1; --enable_warnings +--disable_query_log +# Set timezone to something specific, to make it possible to use unix_timestamp +set time_zone="+03:00"; +--enable_query_log + # # Simple IF tests # @@ -163,5 +168,9 @@ SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te; DROP TABLE t1; - --echo End of 5.0 tests + +--disable_query_log +# Restore timezone to default +set time_zone= @@global.time_zone; +--enable_query_log diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index f47418fa773..2a72578aca7 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -103,194 +103,6 @@ show create table t1; drop table t1; # -# Bug#6760: Add SLEEP() function (feature request) -# -# Logics of original test: -# Reveal that a query with SLEEP does not need less time than estimated. -# -# Bug#12689: SLEEP() gets incorrectly cached/optimized-away -# -# Description from bug report (slightly modified) -# -# Bug 1 (happened all time): -# SELECT * FROM t1 WHERE SLEEP(1) will only result in a sleep of 1 -# second, regardless of the number of rows in t1. -# Bug 2 (happened all time): -# Such a query will also get cached by the query cache, but should not. -# -# Notes (mleich, 2008-05) -# ======================= -# -# Experiments around -# Bug#36345 Test 'func_misc' fails on RHAS3 x86_64 -# showed that the tests for both bugs could produce in case of parallel -# artificial system time (like via ntpd) -# - decreases false alarm -# - increases false success -# -# We try here to circumvent these issues by reimplementation of the tests -# and sophisticated scripting, although the cause of the problems is a massive -# error within the setup of the testing environment. -# Tests relying on or checking derivates of the system time must never meet -# parallel manipulations of system time. -# -# Results of experiments with/without manipulation of system time, -# information_schema.processlist content, high load on testing box -# ---------------------------------------------------------------- -# Definition: Predicted_cumulative_sleep_time = -# #_of_result_rows * sleep_time_per_result_row -# -# 1. Total (real sleep time) ~= predicted_cumulative_sleep_time !! -# 2. The state of a session within the PROCESSLIST changes to 'User sleep' -# if the sessions runs a statement containing the sleep function and the -# processing of the statement is just within the phase where the sleep -# is done. (*) -# 3. NOW() and processlist.time behave "synchronous" to system time and -# show also the "jumps" caused by system time manipulations. (*) -# 4. processlist.time is unsigned, the "next" value below 0 is ~ 4G (*) -# 5. Current processlist.time ~= current real sleep time if the system time -# was not manipulated. (*) -# 6. High system load can cause delays of <= 2 seconds. -# 7. Thanks to Davi for excellent hints and ideas. -# -# (*) -# - information_schema.processlist is not available before MySQL 5.1. -# - Observation of processlist content requires a -# - "worker" session sending the query with "send" and pulling results -# with "reap" -# - session observing the processlist parallel to the worker session -# "send" and "reap" do not work in case of an embedded server. -# Conclusion: Tests based on processlist have too many restrictions. -# -# Solutions for subtests based on TIMEDIFF of values filled via NOW() -# ------------------------------------------------------------------- -# Run the following sequence three times -# 1. SELECT <start_time> -# 2. Query with SLEEP -# 3. SELECT <end_time> -# If TIMEDIFF(<end_time>,<start_time>) is at least two times within a -# reasonable range assume that we did not met errors we were looking for. -# -# It is extreme unlikely that we have two system time changes within the -# < 30 seconds runtime. Even if the unlikely happens, there are so -# frequent runs of this test on this or another testing box which will -# catch the problem. -# - ---echo #------------------------------------------------------------------------ ---echo # Tests for Bug#6760 and Bug#12689 -# Number of rows within the intended result set. -SET @row_count = 4; -# Parameter within SLEEP function -SET @sleep_time_per_result_row = 1; -# Maximum acceptable delay caused by high load on testing box -SET @max_acceptable_delay = 2; -# TIMEDIFF = time for query with sleep (mostly the time caused by SLEEP) -# + time for delays caused by high load on testing box -# Ensure that at least a reasonable fraction of TIMEDIFF belongs to the SLEEP -# by appropriate setting of variables. -# Ensure that any "judging" has a base of minimum three attempts. -# (Test 2 uses all attempts except the first one.) -if (!` SELECT (@sleep_time_per_result_row * @row_count - @max_acceptable_delay > - @sleep_time_per_result_row) AND (@row_count - 1 >= 3)`) -{ - --echo # Have to abort because of error in plausibility check - --echo ###################################################### - --vertical_results - SELECT @sleep_time_per_result_row * @row_count - @max_acceptable_delay > - @sleep_time_per_result_row AS must_be_1, - @row_count - 1 >= 3 AS must_be_also_1, - @sleep_time_per_result_row, @row_count, @max_acceptable_delay; - exit; -} -SET @@global.query_cache_size = 1024 * 64; ---disable_warnings -DROP TEMPORARY TABLE IF EXISTS t_history; -DROP TABLE IF EXISTS t1; ---enable_warnings -CREATE TEMPORARY TABLE t_history (attempt SMALLINT, -start_ts DATETIME, end_ts DATETIME, -start_cached INTEGER, end_cached INTEGER); -CREATE TABLE t1 (f1 BIGINT); -let $num = `SELECT @row_count`; -while ($num) -{ - INSERT INTO t1 VALUES (1); - dec $num; -} - -let $loops = 4; -let $num = $loops; -while ($num) -{ - let $Qcache_queries_in_cache = - query_get_value(SHOW STATUS LIKE 'Qcache_queries_in_cache', Value, 1); - eval - INSERT INTO t_history - SET attempt = $loops - $num + 1, start_ts = NOW(), - start_cached = $Qcache_queries_in_cache; - SELECT *, SLEEP(@sleep_time_per_result_row) FROM t1; - # - # Do not determine Qcache_queries_in_cache before updating end_ts. The SHOW - # might cost too much time on an overloaded box. - eval - UPDATE t_history SET end_ts = NOW() - WHERE attempt = $loops - $num + 1; - let $Qcache_queries_in_cache = - query_get_value(SHOW STATUS LIKE 'Qcache_queries_in_cache', Value, 1); - eval - UPDATE t_history SET end_cached = $Qcache_queries_in_cache - WHERE attempt = $loops - $num + 1; - # DEBUG eval SELECT * FROM t_history WHERE attempt = $loops - $num + 1; - dec $num; -} - -# 1. The majority of queries with SLEEP must need a reasonable time -# -> SLEEP has an impact on runtime -# = Replacement for original Bug#6760 test -# -> total runtime is clear more needed than for one result row needed -# = Replacement for one of the original Bug#12689 tests ---echo # Test 1: Does the query with SLEEP need a reasonable time? -eval SELECT COUNT(*) >= $loops - 1 INTO @aux1 FROM t_history -WHERE TIMEDIFF(end_ts,start_ts) - @sleep_time_per_result_row * @row_count - BETWEEN 0 AND @max_acceptable_delay; -SELECT @aux1 AS "Expect 1"; -# -# 2. The majority of queries (the first one must be ignored) with SLEEP must -# need a reasonable time -# -> If we assume that the result of a cached query will be sent back -# immediate, without any sleep, than the query with SLEEP cannot be cached -# (current and intended behaviour for queries with SLEEP). -# -> It could be also not excluded that the query was cached but the server -# honoured somehow the SLEEP. Such a behaviour would be also acceptable. -# = Replacement for one of the original Bug#12689 tests ---echo # Test 2: Does the query with SLEEP need a reasonable time even in case ---echo # of the non first execution? -eval SELECT COUNT(*) >= $loops - 1 - 1 INTO @aux2 FROM t_history -WHERE TIMEDIFF(end_ts,start_ts) - @sleep_time_per_result_row * @row_count - BETWEEN 0 AND @max_acceptable_delay - AND attempt > 1; -SELECT @aux2 AS "Expect 1"; -# -# 3. The query with SLEEP should be not cached. -# -> SHOW STATUS Qcache_queries_in_cache must be not incremented after -# the execution of the query with SLEEP ---echo # Test 3: The query with SLEEP must be not cached. -eval SELECT COUNT(*) = $loops INTO @aux3 FROM t_history -WHERE end_cached = start_cached; -SELECT @aux3 AS "Expect 1"; -# -# Dump the content of t_history if one of the tests failed. -if (`SELECT @aux1 + @aux2 + @aux3 <> 3`) -{ - --echo # Some tests failed, dumping the content of t_history - SELECT * FROM t_history; -} -DROP TABLE t1; -DROP TEMPORARY TABLE t_history; -SET @@global.query_cache_size = default; - -# # Bug #21466: INET_ATON() returns signed, not unsigned # diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 2dcac0d5796..2d4f50c8271 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -650,7 +650,7 @@ 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; +insert into t1 select sysdate(), sleep(2), sysdate() from dual; select a != b from t1; drop table t1; diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test index e7e6fa59df0..b99d35ecd48 100644 --- a/mysql-test/t/gis-rtree.test +++ b/mysql-test/t/gis-rtree.test @@ -17,12 +17,16 @@ SHOW CREATE TABLE t1; let $1=150; let $2=150; +--disable_query_log +begin; while ($1) { eval INSERT INTO t1 (g) VALUES (GeomFromText('LineString($1 $1, $2 $2)')); dec $1; inc $2; } +commit; +--enable_query_log SELECT count(*) FROM t1; EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')); @@ -35,6 +39,8 @@ CREATE TABLE t2 ( g GEOMETRY NOT NULL ) ENGINE=MyISAM; +--disable_query_log +begin; let $1=10; while ($1) { @@ -46,6 +52,8 @@ while ($1) } dec $1; } +commit; +--enable_query_log ALTER TABLE t2 ADD SPATIAL KEY(g); SHOW CREATE TABLE t2; @@ -55,6 +63,8 @@ EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g, SELECT fid, AsText(g) FROM t2 WHERE Within(g, GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))')); +--disable_query_log +begin; let $1=10; while ($1) { @@ -67,6 +77,8 @@ while ($1) } dec $1; } +commit; +--enable_query_log DROP TABLE t2; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 03a6ceafb36..e17c17f446e 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -35,7 +35,7 @@ revoke delete on mysqltest.* from mysqltest_1@localhost; show grants for mysqltest_1@localhost; grant select on mysqltest.* to mysqltest_1@localhost require NONE; show grants for mysqltest_1@localhost; -grant USAGE on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "testsubject" ISSUER "MySQL AB"; +grant USAGE on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "testsubject" ISSUER "Monty Program Ab"; show grants for mysqltest_1@localhost; revoke all privileges on mysqltest.* from mysqltest_1@localhost; show grants for mysqltest_1@localhost; @@ -1819,7 +1819,7 @@ connect (con1,localhost,testbug,,db1); SELECT * FROM `../db2/tb2`; --error ER_TABLEACCESS_DENIED_ERROR SELECT * FROM `../db2`.tb2; ---error ER_NO_SUCH_TABLE +--error ER_WRONG_TABLE_NAME SELECT * FROM `#mysql50#/../db2/tb2`; connection default; disconnect con1; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 29ed26215bf..8f38f0e9fd9 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1219,6 +1219,23 @@ EXPLAIN SELECT MAX(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a; SELECT MAX(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a; DROP TABLE t1, t2; +# +# min() returns wrong value when used in expression when there is no matching +# rows +# + +CREATE TABLE t1 (a int(11) NOT NULL); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 ( + key_col int(11) NOT NULL, + KEY (key_col) +); +INSERT INTO t2 VALUES (1),(2); + +select min(t2.key_col) from t1,t2 where t1.a=1; +select min(t2.key_col) from t1,t2 where t1.a > 1000; +select min(t2.key_col)+1 from t1,t2 where t1.a> 1000; +drop table t1,t2; --echo # --echo # Bug#55188: GROUP BY, GROUP_CONCAT and TEXT - inconsistent results diff --git a/mysql-test/t/handler_innodb.test b/mysql-test/t/handler_innodb.test deleted file mode 100644 index 02982716f78..00000000000 --- a/mysql-test/t/handler_innodb.test +++ /dev/null @@ -1,20 +0,0 @@ -# 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 deleted file mode 100644 index e78072ef8a0..00000000000 --- a/mysql-test/t/handler_myisam.test +++ /dev/null @@ -1,100 +0,0 @@ -# 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 # ---echo # BUG#51877 - HANDLER interface causes invalid memory read ---echo # -CREATE TABLE t1(a INT, KEY(a)); -HANDLER t1 OPEN; -HANDLER t1 READ a FIRST; -INSERT INTO t1 VALUES(1); -HANDLER t1 READ a NEXT; -HANDLER t1 CLOSE; -DROP TABLE t1; - - ---echo # ---echo # Bug #54007: assert in ha_myisam::index_next , HANDLER ---echo # -CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a), KEY b(b), KEY ab(a, b)); - -HANDLER t1 OPEN; -HANDLER t1 READ FIRST; -HANDLER t1 READ `PRIMARY` NEXT; -HANDLER t1 READ ab NEXT; -HANDLER t1 READ b NEXT; -HANDLER t1 READ NEXT; -HANDLER t1 CLOSE; - -INSERT INTO t1 VALUES (2, 20), (1, 10), (4, 40), (3, 30); -HANDLER t1 OPEN; -HANDLER t1 READ FIRST; -HANDLER t1 READ NEXT; -HANDLER t1 READ `PRIMARY` NEXT; -HANDLER t1 READ `PRIMARY` NEXT; -HANDLER t1 READ ab NEXT; -HANDLER t1 READ ab NEXT; -HANDLER t1 READ b NEXT; -HANDLER t1 READ b NEXT; -HANDLER t1 READ b NEXT; -HANDLER t1 READ b NEXT; -HANDLER t1 READ b NEXT; -HANDLER t1 READ NEXT; -HANDLER t1 READ NEXT; -HANDLER t1 READ NEXT; -HANDLER t1 CLOSE; - -HANDLER t1 OPEN; -HANDLER t1 READ FIRST; -HANDLER t1 READ `PRIMARY` PREV; -HANDLER t1 READ `PRIMARY` PREV; -HANDLER t1 READ b PREV; -HANDLER t1 READ b PREV; -HANDLER t1 CLOSE; - -HANDLER t1 OPEN; -HANDLER t1 READ FIRST; -HANDLER t1 READ `PRIMARY` PREV LIMIT 3; -HANDLER t1 READ b NEXT LIMIT 5; -HANDLER t1 CLOSE; - -DROP TABLE t1; - - ---echo End of 5.1 tests diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index 3f91b9966e7..e5700eaeeb8 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -234,7 +234,8 @@ drop table t1,t2,t3; # create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10))); show create table t1; -disable_query_log; +--disable_query_log +begin; let $1=10; while ($1) { @@ -248,7 +249,9 @@ while ($1) } dec $1; } -enable_query_log; +commit; +--enable_query_log + select count(*) from t1; insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1))); select count(*) from t1 where v='a'; @@ -318,7 +321,8 @@ drop table t1; create table t1 (v varchar(10), c char(10), t varchar(50), key using btree (v), key using btree (c), key using btree (t(10))); show create table t1; -disable_query_log; +--disable_query_log +begin; let $1=10; while ($1) { @@ -332,7 +336,8 @@ while ($1) } dec $1; } -enable_query_log; +commit; +--enable_query_log select count(*) from t1; insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1))); select count(*) from t1 where v='a'; diff --git a/mysql-test/t/index_merge_innodb.test b/mysql-test/t/index_merge_innodb.test index a3bda0ad00c..04f8c5a659b 100644 --- a/mysql-test/t/index_merge_innodb.test +++ b/mysql-test/t/index_merge_innodb.test @@ -10,7 +10,10 @@ # include/index_merge*.inc files # +# Slow test, don't run during staging part +--source include/not_staging.inc --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; @@ -26,3 +29,58 @@ let $merge_table_support= 0; --source include/index_merge2.inc --source include/index_merge_2sweeps.inc --source include/index_merge_ror_cpk.inc + +--echo # +--echo # BUG#56862/640419: Wrong result with sort_union index merge when one +--echo # of the merged index scans is the primary key scan +--echo # + +CREATE TABLE t1 ( + pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, + a int, + b int, + INDEX idx(a)) +ENGINE=INNODB; + +INSERT INTO t1(a,b) VALUES + (11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500), + (3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800), + (6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700), + (13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000); +INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1; +INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1; +INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1; +INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t1 VALUES (1000000, 0, 0); + +SET SESSION sort_buffer_size = 1024*36; + +# We have to use FORCE INDEX here as Innodb gives inconsistent estimates +# which causes different query plans. +EXPLAIN +SELECT COUNT(*) FROM + (SELECT * FROM t1 FORCE INDEX(primary,idx) + WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; +SELECT COUNT(*) FROM + (SELECT * FROM t1 FORCE INDEX(primary,idx) + WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; + +--replace_column 9 # +EXPLAIN +SELECT COUNT(*) FROM + (SELECT * FROM t1 IGNORE INDEX(idx) + WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; +SELECT COUNT(*) FROM + (SELECT * FROM t1 IGNORE INDEX(idx) + WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; + +DROP TABLE t1; diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test index dccaecef20a..0c4b9c6886c 100644 --- a/mysql-test/t/index_merge_myisam.test +++ b/mysql-test/t/index_merge_myisam.test @@ -25,15 +25,19 @@ let $merge_table_support= 1; --echo # we get another @@optimizer_switch user) --echo # +--replace_regex /,table_elimination=on// select @@optimizer_switch; set optimizer_switch='index_merge=off,index_merge_union=off'; +--replace_regex /,table_elimination=on// select @@optimizer_switch; set optimizer_switch='index_merge_union=on'; +--replace_regex /,table_elimination=on// select @@optimizer_switch; set optimizer_switch='default,index_merge_sort_union=off'; +--replace_regex /,table_elimination=on// select @@optimizer_switch; --error ER_WRONG_VALUE_FOR_VAR @@ -71,17 +75,21 @@ 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'; +--replace_regex /,table_elimination=on// select @@optimizer_switch; set optimizer_switch=default; # Check setting defaults for global vars +--replace_regex /,table_elimination=on// select @@global.optimizer_switch; set @@global.optimizer_switch=default; +--replace_regex /,table_elimination=on// select @@global.optimizer_switch; --echo # --echo # Check index_merge's @@optimizer_switch flags --echo # +--replace_regex /,table_elimination.on// select @@optimizer_switch; create table t0 (a int); @@ -182,6 +190,7 @@ 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; +--replace_regex /,table_elimination.on// show variables like 'optimizer_switch'; drop table t0, t1; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 1fa4d6da600..e78b180caf7 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -5,6 +5,9 @@ # on the presence of the log tables (which are CSV-based). --source include/have_csv.inc +# Check that InnoDB/XtraDB was compiled in as result depends on it +-- source include/have_innodb.inc + # Save the initial number of concurrent sessions --source include/count_sessions.inc @@ -45,14 +48,15 @@ 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; + table_name<>'ndb_apply_status' AND + NOT (table_schema = 'INFORMATION_SCHEMA' AND table_name LIKE 'PBXT_%'); +select * from v1 ORDER BY c COLLATE utf8_bin; -select c,table_name from v1 +select c,table_name from v1 inner join information_schema.TABLES v2 on (v1.c=v2.table_name) where v1.c like "t%"; -select c,table_name from v1 +select c,table_name from v1 left join information_schema.TABLES v2 on (v1.c=v2.table_name) where v1.c like "t%"; @@ -527,7 +531,8 @@ drop table t1; grant select on test.* to mysqltest_4@localhost; connect (user10261,localhost,mysqltest_4,,); connection user10261; -SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS +--sorted_result +SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS where COLUMN_NAME='TABLE_NAME'; connection default; disconnect user10261; @@ -536,13 +541,6 @@ delete from mysql.db where user='mysqltest_4'; flush privileges; # -# Bug#9404 information_schema: Weird error messages -# with SELECT SUM() ... GROUP BY queries -# -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; - - -# # TRIGGERS table test # create table t1 (i int, j int); @@ -912,41 +910,8 @@ DROP PROCEDURE p1; DROP USER mysql_bug20230@localhost; # -# Bug#18925 subqueries with MIN/MAX functions on INFORMARTION_SCHEMA -# - -SELECT t.table_name, c1.column_name - FROM information_schema.tables t - INNER JOIN - information_schema.columns c1 - ON t.table_schema = c1.table_schema AND - t.table_name = c1.table_name - WHERE t.table_schema = 'information_schema' AND - c1.ordinal_position = - ( SELECT COALESCE(MIN(c2.ordinal_position),1) - FROM information_schema.columns c2 - WHERE c2.table_schema = t.table_schema AND - c2.table_name = t.table_name AND - c2.column_name LIKE '%SCHEMA%' - ); -SELECT t.table_name, c1.column_name - FROM information_schema.tables t - INNER JOIN - information_schema.columns c1 - ON t.table_schema = c1.table_schema AND - t.table_name = c1.table_name - WHERE t.table_schema = 'information_schema' AND - c1.ordinal_position = - ( SELECT COALESCE(MIN(c2.ordinal_position),1) - FROM information_schema.columns c2 - WHERE c2.table_schema = 'information_schema' AND - c2.table_name = t.table_name AND - c2.column_name LIKE '%SCHEMA%' - ); - -# -# Bug#2123 query with a simple non-correlated subquery over -# INFORMARTION_SCHEMA.TABLES +# Bug#21231 query with a simple non-correlated subquery over +# INFORMARTION_SCHEMA.TABLES # SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test'); @@ -954,7 +919,7 @@ SELECT table_name from information_schema.tables WHERE table_name=(SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test')); # -# Bug#23037 Bug in field "Default" of query "SHOW COLUMNS FROM table" +# Bug #23037 Bug in field "Default" of query "SHOW COLUMNS FROM table" # # Note, MyISAM/InnoDB can't take more that 65532 chars, because the row # size is limited to 65535 bytes (BLOBs not counted) @@ -1021,29 +986,6 @@ drop table t1,t2; # -# Bug#24630 Subselect query crashes mysqld -# -select 1 as f1 from information_schema.tables where "CHARACTER_SETS"= -(select cast(table_name as char) from information_schema.tables - order by table_name limit 1) limit 1; - -select t.table_name, group_concat(t.table_schema, '.', t.table_name), - count(*) as num1 -from information_schema.tables t -inner join information_schema.columns c1 -on t.table_schema = c1.table_schema AND t.table_name = c1.table_name -where t.table_schema = 'information_schema' and - c1.ordinal_position = - (select isnull(c2.column_type) - - isnull(group_concat(c2.table_schema, '.', c2.table_name)) + - count(*) as num - from information_schema.columns c2 where - c2.table_schema='information_schema' and - (c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)') - 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 # create table t1(f1 int); @@ -1161,6 +1103,25 @@ disconnect con3148; drop user user3148@localhost; # +# `time` and `time_ms` columns of INFORMATION_SCHEMA.PROCESSLIST. +# +connect (pslistcon,localhost,root,,test); +let $ID= `select connection_id()`; +SELECT 'other connection here' AS who; +connection default; +sleep 2; +--disable_query_log +eval SET @tid=$ID; +--enable_query_log +SELECT IF(`time` > 0, 'OK', `time`) AS time_low, + IF(`time` < 1000, 'OK', `time`) AS time_high, + IF(time_ms >= 1000, 'OK', time_ms) AS time_ms_low, + IF(time_ms < 1000000, 'OK', time_ms) AS time_ms_high + FROM INFORMATION_SCHEMA.PROCESSLIST + WHERE ID=@tid; +disconnect pslistcon; + +# # Bug#26174 Server Crash: INSERT ... SELECT ... FROM I_S.GLOBAL_STATUS # in Event (see also openssl_1.test) # @@ -1414,9 +1375,16 @@ DROP TABLE t1; # Bug #22047: Time in SHOW PROCESSLIST for SQL thread in replication seems # to become negative # +# Note that at the time of writing, MariaDB differs in behaviour from MySQL on +# the `time` column. In MySQL this changes depending on the setting of +# @TIMESTAMP, which is contrary to the documented (and sensible) behaviour. +# In MariaDB, the `time` column is independent of @TIMESTAMP. +# (The rationale for this is to keep `time` and `time_ms` consistent; +# @TIMESTAMP has no microsecond precision). +# SET TIMESTAMP=@@TIMESTAMP + 10000000; -SELECT 'OK' AS TEST_RESULT FROM INFORMATION_SCHEMA.PROCESSLIST WHERE time < 0; +SELECT 'NOT_OK' AS TEST_RESULT FROM INFORMATION_SCHEMA.PROCESSLIST WHERE time < 0; SET TIMESTAMP=DEFAULT; diff --git a/mysql-test/t/information_schema_all_engines-master.opt b/mysql-test/t/information_schema_all_engines-master.opt new file mode 100644 index 00000000000..9104e73e554 --- /dev/null +++ b/mysql-test/t/information_schema_all_engines-master.opt @@ -0,0 +1 @@ +--loose-skip-safemalloc --loose-mutex-deadlock-detector=0 diff --git a/mysql-test/t/information_schema_all_engines.test b/mysql-test/t/information_schema_all_engines.test new file mode 100644 index 00000000000..b3b1d2d2f6b --- /dev/null +++ b/mysql-test/t/information_schema_all_engines.test @@ -0,0 +1,81 @@ +# This file contains tests moved from information_schema.test and +# information_schema_db.test whose results depends on which engines are +# available (since these engines inject tables into INFORMATION_SCHEMA). + +--source include/not_embedded.inc +--source include/have_pbxt.inc +--source include/have_innodb.inc +--source include/not_staging.inc + +use INFORMATION_SCHEMA; +--replace_result Tables_in_INFORMATION_SCHEMA Tables_in_information_schema +show tables; + +# +# Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA +# + +SELECT t.table_name, c1.column_name + FROM information_schema.tables t + INNER JOIN + information_schema.columns c1 + ON t.table_schema = c1.table_schema AND + t.table_name = c1.table_name + WHERE t.table_schema = 'information_schema' AND + c1.ordinal_position = + ( SELECT COALESCE(MIN(c2.ordinal_position),1) + FROM information_schema.columns c2 + WHERE c2.table_schema = t.table_schema AND + c2.table_name = t.table_name AND + c2.column_name LIKE '%SCHEMA%' + ); +SELECT t.table_name, c1.column_name + FROM information_schema.tables t + INNER JOIN + information_schema.columns c1 + ON t.table_schema = c1.table_schema AND + t.table_name = c1.table_name + WHERE t.table_schema = 'information_schema' AND + c1.ordinal_position = + ( SELECT COALESCE(MIN(c2.ordinal_position),1) + FROM information_schema.columns c2 + WHERE c2.table_schema = 'information_schema' AND + c2.table_name = t.table_name AND + c2.column_name LIKE '%SCHEMA%' + ); + +# +# Bug#24630 Subselect query crashes mysqld +# +select 1 as f1 from information_schema.tables where "CHARACTER_SETS"= +(select cast(table_name as char) from information_schema.tables + order by table_name limit 1) limit 1; + +select t.table_name, group_concat(t.table_schema, '.', t.table_name), + count(*) as num1 +from information_schema.tables t +inner join information_schema.columns c1 +on t.table_schema = c1.table_schema AND t.table_name = c1.table_name +where t.table_schema = 'information_schema' and + c1.ordinal_position = + (select isnull(c2.column_type) - + isnull(group_concat(c2.table_schema, '.', c2.table_name)) + + count(*) as num + from information_schema.columns c2 where + c2.table_schema='information_schema' and + (c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)') + group by c2.column_type order by num limit 1) +group by t.table_name order by num1, t.table_name; + +# +# Bug #19147: mysqlshow INFORMATION_SCHEMA does not work +# +--exec $MYSQL_SHOW information_schema +--exec $MYSQL_SHOW INFORMATION_SCHEMA +--exec $MYSQL_SHOW inf_rmation_schema + +# +# Bug #9404 information_schema: Weird error messages +# with SELECT SUM() ... GROUP BY queries +# +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; diff --git a/mysql-test/t/information_schema_db.test b/mysql-test/t/information_schema_db.test index 2f651057e5c..bfe6745f5ae 100644 --- a/mysql-test/t/information_schema_db.test +++ b/mysql-test/t/information_schema_db.test @@ -11,9 +11,6 @@ drop function if exists f1; drop function if exists f2; --enable_warnings -use INFORMATION_SCHEMA; ---replace_result Tables_in_INFORMATION_SCHEMA Tables_in_information_schema -show tables; --replace_result 'Tables_in_INFORMATION_SCHEMA (T%)' 'Tables_in_information_schema (T%)' show tables from INFORMATION_SCHEMA like 'T%'; create database `inf%`; diff --git a/mysql-test/t/init_file.test b/mysql-test/t/init_file.test index d73a9c60e8e..573396f625d 100644 --- a/mysql-test/t/init_file.test +++ b/mysql-test/t/init_file.test @@ -19,7 +19,7 @@ DROP DATABASE init_file; --echo ok --echo end of 4.1 tests # -# Chec 5.x features +# Check 5.x features # # Expected: # 3, 5, 7, 11, 13 diff --git a/mysql-test/t/innodb-analyze.test b/mysql-test/t/innodb-analyze.test new file mode 100644 index 00000000000..9bdb9db697c --- /dev/null +++ b/mysql-test/t/innodb-analyze.test @@ -0,0 +1,65 @@ +# +# Test that mysqld does not crash when running ANALYZE TABLE with +# different values of the parameter innodb_stats_sample_pages. +# + +-- source include/have_innodb.inc + +# we care only that the following SQL commands do not produce errors +# and do not crash the server +-- disable_query_log +-- disable_result_log +-- enable_warnings + +let $sample_pages=`select @@innodb_stats_sample_pages`; +SET GLOBAL innodb_stats_sample_pages=0; + +# check that the value has been adjusted to 1 +-- enable_result_log +SHOW VARIABLES LIKE 'innodb_stats_sample_pages'; +-- disable_result_log + +CREATE TABLE innodb_analyze ( + a INT, + b INT, + KEY(a), + KEY(b,a) +) ENGINE=InnoDB; + +# test with empty table + +ANALYZE TABLE innodb_analyze; + +SET GLOBAL innodb_stats_sample_pages=2; +ANALYZE TABLE innodb_analyze; + +SET GLOBAL innodb_stats_sample_pages=4; +ANALYZE TABLE innodb_analyze; + +SET GLOBAL innodb_stats_sample_pages=8; +ANALYZE TABLE innodb_analyze; + +SET GLOBAL innodb_stats_sample_pages=16; +ANALYZE TABLE innodb_analyze; + +INSERT INTO innodb_analyze VALUES +(1,1), (1,1), (1,2), (1,3), (1,4), (1,5), +(8,1), (8,8), (8,2), (7,1), (1,4), (3,5); + +SET GLOBAL innodb_stats_sample_pages=1; +ANALYZE TABLE innodb_analyze; + +SET GLOBAL innodb_stats_sample_pages=2; +ANALYZE TABLE innodb_analyze; + +SET GLOBAL innodb_stats_sample_pages=4; +ANALYZE TABLE innodb_analyze; + +SET GLOBAL innodb_stats_sample_pages=8; +ANALYZE TABLE innodb_analyze; + +SET GLOBAL innodb_stats_sample_pages=16; +ANALYZE TABLE innodb_analyze; + +DROP TABLE innodb_analyze; +EVAL SET GLOBAL innodb_stats_sample_pages=$sample_pages; diff --git a/mysql-test/t/innodb-consistent-master.opt b/mysql-test/t/innodb-consistent-master.opt new file mode 100644 index 00000000000..cb48f1aaf60 --- /dev/null +++ b/mysql-test/t/innodb-consistent-master.opt @@ -0,0 +1 @@ +--loose-innodb_lock_wait_timeout=2 diff --git a/mysql-test/t/innodb-consistent.test b/mysql-test/t/innodb-consistent.test new file mode 100644 index 00000000000..5a7f4dc392d --- /dev/null +++ b/mysql-test/t/innodb-consistent.test @@ -0,0 +1,58 @@ +-- source include/not_embedded.inc +-- source include/have_innodb.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# REPLACE INTO ... SELECT and INSERT INTO ... SELECT should do +# a consistent read of the source table. + +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +set session transaction isolation level read committed; +create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; +create table t2 like t1; +insert into t2 values (1),(2),(3),(4),(5),(6),(7); +set autocommit=0; + +# REPLACE INTO ... SELECT case +begin; +# this should not result in any locks on t2. +replace into t1 select * from t2; + +connection b; +set session transaction isolation level read committed; +set autocommit=0; +# should not cuase a lock wait. +delete from t2 where a=5; +commit; +delete from t2; +commit; +connection a; +commit; + +# INSERT INTO ... SELECT case +begin; +# this should not result in any locks on t2. +insert into t1 select * from t2; + +connection b; +set session transaction isolation level read committed; +set autocommit=0; +# should not cuase a lock wait. +delete from t2 where a=5; +commit; +delete from t2; +commit; +connection a; +commit; + +select * from t1; +drop table t1; +drop table t2; + +connection default; +disconnect a; +disconnect b; diff --git a/mysql-test/t/innodb-index_ucs2.test b/mysql-test/t/innodb-index_ucs2.test new file mode 100644 index 00000000000..fff9a4da1a8 --- /dev/null +++ b/mysql-test/t/innodb-index_ucs2.test @@ -0,0 +1,5 @@ +-- source include/have_innodb.inc +-- source include/have_ucs2.inc + +-- let charset = ucs2 +-- source include/innodb-index.inc diff --git a/mysql-test/t/innodb-lock.test b/mysql-test/t/innodb-lock.test new file mode 100644 index 00000000000..eacf7e562be --- /dev/null +++ b/mysql-test/t/innodb-lock.test @@ -0,0 +1,102 @@ +-- source include/have_innodb.inc + +# +# Check and select innodb lock type +# + +set global innodb_table_locks=1; + +select @@innodb_table_locks; + +# +# Testing of explicit table locks with enforced table locks +# + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Testing of explicit table locks with enforced table locks +# + +set @@innodb_table_locks=1; + +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 statement should hang because con1 is locking the page +--send +lock table t1 write; +--sleep 2 + +connection con1; +update t1 set x=1 where id = 0; +select * from t1; +commit; + +connection con2; +reap; +update t1 set x=2 where id = 0; +commit; +unlock tables; + +connection con1; +select * from t1; +commit; + +drop table t1; + +# +# Try with old lock method (where LOCK TABLE is ignored by InnoDB) +# + +set @@innodb_table_locks=0; + +create table t1 (id integer primary key, x integer) engine=INNODB; +insert into t1 values(0, 0),(1,1),(2,2); +commit; +SELECT * from t1 where id = 0 FOR UPDATE; + +connection con2; +set autocommit=0; +set @@innodb_table_locks=0; + +# The following statement should work becase innodb doesn't check table locks +lock table t1 write; + +connection con1; + +# This will be locked by MySQL +--send +update t1 set x=10 where id = 2; +--sleep 2 + +connection con2; + +# Note that we will get a deadlock if we try to select any rows marked +# for update by con1 ! + +SELECT * from t1 where id = 2; +UPDATE t1 set x=3 where id = 2; +commit; +SELECT * from t1; +commit; +unlock tables; + +connection con1; +reap; +commit; +select * from t1; +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/innodb-master.opt b/mysql-test/t/innodb-master.opt new file mode 100644 index 00000000000..72c88068345 --- /dev/null +++ b/mysql-test/t/innodb-master.opt @@ -0,0 +1 @@ +--binlog_cache_size=32768 --loose_innodb_lock_wait_timeout=1 diff --git a/mysql-test/t/innodb-replace.test b/mysql-test/t/innodb-replace.test new file mode 100644 index 00000000000..8c3aacde5e8 --- /dev/null +++ b/mysql-test/t/innodb-replace.test @@ -0,0 +1,22 @@ +-- 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 #1078 +# +create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb; +select * from t1; +--error ER_DELAYED_NOT_SUPPORTED +replace delayed into t1 (c1, c2) values ( "text1","11"); +select * from t1; +--error ER_DELAYED_NOT_SUPPORTED +replace delayed into t1 (c1, c2) values ( "text1","12"); +select * from t1; +drop table t1; + +# End of 4.1 tests 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..cb48f1aaf60 --- /dev/null +++ b/mysql-test/t/innodb-semi-consistent-master.opt @@ -0,0 +1 @@ +--loose-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..f5ed4677c69 --- /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,t2; +--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-timeout.test b/mysql-test/t/innodb-timeout.test new file mode 100644 index 00000000000..7f7bcecb4ee --- /dev/null +++ b/mysql-test/t/innodb-timeout.test @@ -0,0 +1,69 @@ +-- source include/have_innodb.inc + +let $timeout=`select @@innodb_lock_wait_timeout`; +set global innodb_lock_wait_timeout=42; + +connect (a,localhost,root,,); +connect (b,localhost,root,,); + +connection a; +select @@innodb_lock_wait_timeout; +set innodb_lock_wait_timeout=1; +select @@innodb_lock_wait_timeout; + +connection b; +select @@innodb_lock_wait_timeout; +set global innodb_lock_wait_timeout=347; +select @@innodb_lock_wait_timeout; +set innodb_lock_wait_timeout=1; +select @@innodb_lock_wait_timeout; + +connect (c,localhost,root,,); +connection c; +select @@innodb_lock_wait_timeout; +connection default; +disconnect c; + +connection a; +create table t1(a int primary key)engine=innodb; +begin; +insert into t1 values(1),(2),(3); + +connection b; +set innodb_lock_wait_timeout=5; +--send +select * from t1 for update; + +connection a; +commit; + +connection b; +reap; + +connection a; +begin; +insert into t1 values(4); + +connection b; +# Test that we get a lock timeout. +# We cannot reliably test that the timeout is exactly 1 seconds due to +# process scheduling differences on the host running the test suite. But we +# can test that we are within reasonable range. +set innodb_lock_wait_timeout=2; +set @a= current_timestamp(); +--error ER_LOCK_WAIT_TIMEOUT +select * from t1 for update; +set @b= current_timestamp(); +set @c= timestampdiff(SECOND, @a, @b); +select if(@c >= 1 and @c <= 10, 'OK', concat("NOT OK, time passed=", @c)); + +connection a; +commit; +drop table t1; + +connection default; + +disconnect a; +disconnect b; + +eval set global innodb_lock_wait_timeout=$timeout; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test new file mode 100644 index 00000000000..2c9f84e823a --- /dev/null +++ b/mysql-test/t/innodb.test @@ -0,0 +1,2565 @@ +####################################################################### +# # +# Please, DO NOT TOUCH this file as well as the innodb.result file. # +# These files are to be modified ONLY BY INNOBASE guys. # +# # +# Use innodb_mysql.[test|result] files instead. # +# # +# If nevertheless you need to make some changes here, please, forward # +# your commit message # +# To: innodb_dev_ww@oracle.com # +# Cc: dev-innodb@mysql.com # +# (otherwise your changes may be erased). # +# # +####################################################################### + +-- source include/have_innodb.inc + +# Save the original values of some variables in order to be able to +# estimate how much they have changed during the tests. Previously this +# test assumed that e.g. rows_deleted is 0 here and after deleting 23 +# rows it expected that rows_deleted will be 23. Now we do not make +# assumptions about the values of the variables at the beginning, e.g. +# 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 +-- 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'); +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 +# The 'replace_column' statements are needed because the cardinality calculated +# by innodb is not always the same between runs +# + +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=innodb; +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 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 +select * from t1; +update ignore t1 set id=1023 where id=1010; +select * from t1 where parent_id=102; +--replace_column 9 # +explain select level from t1 where level=1; +--replace_column 9 # +explain select level,id from t1 where level=1; +--replace_column 9 # +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; +--replace_column 7 # +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=innodb; + +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 delete using hidden_primary_key +# + +create table t1 (a int) engine=innodb; +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=innodb; +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; +--replace_column 7 # +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=innodb; +insert into t1 values (1,""), (2,"testing"); +select * from t1 where a = 1; +drop table t1; + +# +# Test rollback +# + +create table t1 (n int not null primary key) engine=innodb; +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 ER_DUP_ENTRY +insert into t1 values (4); +commit; +select n, "after commit" from t1; +set autocommit=1; +insert into t1 values (6); +-- error ER_DUP_ENTRY +insert into t1 values (4); +select n from t1; +set autocommit=0; +# +# savepoints +# +begin; +savepoint `my_savepoint`; +insert into t1 values (7); +savepoint `savept2`; +insert into t1 values (3); +select n from t1; +savepoint savept3; +rollback to savepoint savept2; +--error 1305 +rollback to savepoint savept3; +rollback to savepoint savept2; +release savepoint `my_savepoint`; +select n from t1; +-- error 1305 +rollback to savepoint `my_savepoint`; +--error 1305 +rollback to savepoint savept2; +insert into t1 values (8); +savepoint sv; +commit; +savepoint sv; +set autocommit=1; +# nop +rollback; +drop table t1; + +# +# Test for commit and FLUSH TABLES WITH READ LOCK +# + +create table t1 (n int not null primary key) engine=innodb; +start transaction; +insert into t1 values (4); +flush tables with read lock; +# +# Current code can't handle a read lock in middle of transaction +#--error 1223; +commit; +unlock tables; +commit; +select * from t1; +drop table t1; + +# +# Testing transactions +# + +create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=innodb; +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=innodb; +insert into t1 values ('pippo', 12); +-- error ER_DUP_ENTRY +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; + +# +# Test of active transactions +# + +create table t1 (a integer) engine=innodb; +start transaction; +rename table t1 to t2; +create table t1 (b integer) engine=innodb; +insert into t1 values (1); +rollback; +drop table t1; +rename table t2 to 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=innodb; +INSERT INTO t1 VALUES (1, 'Jochen'); +select * from t1; +drop table t1; + +CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=innodb; +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=innodb; + +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)); +--replace_column 7 # +show index from t1; +drop table t1; + +# +# Test of ALTER TABLE and innodb tables +# + +create table t1 (col1 int not null, col2 char(4) not null, primary key(col1)); +alter table t1 engine=innodb; +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 innodb tables +# + +create table t1 (a int not null , b int, primary key (a)) engine = innodb; +create table t2 (a int not null , b int, primary key (a)) engine = 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; + +# +# 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=innodb; +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=innodb; +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_column 9 # +explain select level from t1 where level=1; +select level,id from t1 where level=1; +select level,id,parent_id from t1 where level=1; +select level,id from t1 where level=1 order by id; +delete from t1 where level=1; +select * from t1; +drop table t1; + +# +# Test of index only reads +# +CREATE TABLE t1 ( + sca_code char(6) NOT NULL, + cat_code char(6) NOT NULL, + sca_desc varchar(50), + lan_code char(2) NOT NULL, + sca_pic varchar(100), + sca_sdesc varchar(50), + sca_sch_desc varchar(16), + PRIMARY KEY (sca_code, cat_code, lan_code), + INDEX sca_pic (sca_pic) +) engine = innodb ; + +INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING'); +select count(*) from t1 where sca_code = 'PD'; +select count(*) from t1 where sca_code <= 'PD'; +select count(*) from t1 where sca_pic is null; +alter table t1 drop index sca_pic; +alter table t1 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; +alter table t1 add index (sca_pic, cat_code); +select count(*) from t1 where sca_code='PD' and sca_pic is null; +select count(*) from t1 where sca_pic >= 'n'; +select sca_pic from t1 where sca_pic is null; +update t1 set sca_pic="test" where sca_pic is null; +delete from t1 where sca_code='pd'; +drop table t1; + +# +# Test of opening table twice and timestamps +# +set @a:=now(); +CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb; +insert into t1 (a) values(1),(2),(3); +select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a; +select a from t1 natural join t1 as t2 where b >= @a order by a; +update t1 set a=5 where a=1; +select a from t1; +drop table t1; + +# +# Test with variable length primary key +# +create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb; +insert into t1 values("hello",1),("world",2); +select * from t1 order by b desc; +optimize table t1; +--replace_column 7 # +show keys from t1; +drop table t1; + +# +# Test of create index with NULL columns +# +create table t1 (i int, j int ) ENGINE=innodb; +insert into t1 values (1,2); +select * from t1 where i=1 and j=2; +create index ax1 on t1 (i,j); +select * from t1 where i=1 and j=2; +drop table t1; + +# +# Test min-max optimization +# + +CREATE TABLE t1 ( + a int3 unsigned NOT NULL, + b int1 unsigned NOT NULL, + UNIQUE (a, b) +) ENGINE = innodb; + +INSERT INTO t1 VALUES (1, 1); +SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1; +drop table t1; + +# +# Test INSERT DELAYED +# + +CREATE TABLE t1 (a int unsigned NOT NULL) engine=innodb; +# Can't test this in 3.23 +# INSERT DELAYED INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1); +SELECT * FROM t1; +DROP TABLE t1; + + +# +# Crash when using many tables (Test case by Jeremy D Zawodny) +# + +create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb; +insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); +--replace_column 9 # +explain select * from t1 where a > 0 and a < 50; +drop table t1; + +# +# Test lock tables +# + +create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb; +insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); +LOCK TABLES t1 WRITE; +--error ER_DUP_ENTRY +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=innodb; +insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); +LOCK TABLES t1 WRITE; +begin; +--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'); +commit; +select id,id3 from t1; +UNLOCK TABLES; +DROP TABLE t1; + +# +# Test prefix key +# +create table t1 (a char(20), unique (a(5))) engine=innodb; +drop table t1; +create table t1 (a char(20), index (a(5))) engine=innodb; +show create table t1; +drop table t1; + +# +# Test using temporary table and auto_increment +# + +create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb; +insert into t1 values (NULL),(NULL),(NULL); +delete from t1 where a=3; +insert into t1 values (NULL); +select * from t1; +alter table t1 add b int; +select * from t1; +drop table t1; + +#Slashdot bug +create table t1 + ( + id int auto_increment primary key, + name varchar(32) not null, + value text not null, + uid int not null, + unique key(name,uid) + ) engine=innodb; +insert into t1 values (1,'one','one value',101), + (2,'two','two value',102),(3,'three','three value',103); +set insert_id=5; +replace into t1 (value,name,uid) values ('other value','two',102); +delete from t1 where uid=102; +set insert_id=5; +replace into t1 (value,name,uid) values ('other value','two',102); +set insert_id=6; +replace into t1 (value,name,uid) values ('other value','two',102); +select * from t1; +drop table t1; + +# +# Test DROP DATABASE +# + +create database mysqltest; +create table mysqltest.t1 (a int not null) engine= innodb; +insert into mysqltest.t1 values(1); +create table mysqltest.t2 (a int not null) engine= myisam; +insert into mysqltest.t2 values(1); +create table mysqltest.t3 (a int not null) engine= heap; +insert into mysqltest.t3 values(1); +commit; +drop database mysqltest; +# Don't check error message +--error 1049 +show tables from mysqltest; + +# +# Test truncate table with and without auto_commit +# + +set autocommit=0; +create table t1 (a int not null) engine= innodb; +insert into t1 values(1),(2); +truncate table t1; +commit; +truncate table t1; +truncate table t1; +select * from t1; +insert into t1 values(1),(2); +delete from t1; +select * from t1; +commit; +drop table t1; +set autocommit=1; + +create table t1 (a int not null) engine= innodb; +insert into t1 values(1),(2); +truncate table t1; +insert into t1 values(1),(2); +select * from t1; +truncate table t1; +insert into t1 values(1),(2); +delete from t1; +select * from t1; +drop table t1; + +# +# Test of how ORDER BY works when doing it on the whole table +# + +create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=innodb; +insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4); +--replace_column 9 # +explain select * from t1 order by a; +--replace_column 9 # +explain select * from t1 order by b; +--replace_column 9 # +explain select * from t1 order by c; +--replace_column 9 # +explain select a from t1 order by a; +--replace_column 9 # +explain select b from t1 order by b; +--replace_column 9 # +explain select a,b from t1 order by b; +--replace_column 9 # +explain select a,b from t1; +--replace_column 9 # +explain select a,b,c from t1; +drop table t1; + +# +# Check describe +# + +create table t1 (t int not null default 1, key (t)) engine=innodb; +desc t1; +drop table t1; + +# +# Test of multi-table-delete +# + +CREATE TABLE t1 ( + number bigint(20) NOT NULL default '0', + cname char(15) NOT NULL default '', + carrier_id smallint(6) NOT NULL default '0', + privacy tinyint(4) NOT NULL default '0', + last_mod_date timestamp NOT NULL, + last_mod_id smallint(6) NOT NULL default '0', + last_app_date timestamp NOT NULL, + last_app_id smallint(6) default '-1', + version smallint(6) NOT NULL default '0', + assigned_scps int(11) default '0', + status tinyint(4) default '0' +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1); +INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0); +INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1); +INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0); +INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0); +INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0); +CREATE TABLE t2 ( + number bigint(20) NOT NULL default '0', + cname char(15) NOT NULL default '', + carrier_id smallint(6) NOT NULL default '0', + privacy tinyint(4) NOT NULL default '0', + last_mod_date timestamp NOT NULL, + last_mod_id smallint(6) NOT NULL default '0', + last_app_date timestamp NOT NULL, + last_app_id smallint(6) default '-1', + version smallint(6) NOT NULL default '0', + assigned_scps int(11) default '0', + status tinyint(4) default '0' +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1); +INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0); +INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1); +INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0); +select * from t1; +select * from t2; +delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or (t1.carrier_id=90 and t2.number is null); +select * from t1; +select * from t2; +select * from t2; +drop table t1,t2; + +# +# A simple test with some isolation levels +# TODO: Make this into a test using replication to really test how +# this works. +# + +create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb; + +BEGIN; +SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; +SELECT @@tx_isolation,@@global.tx_isolation; +insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'); +select id, code, name from t1 order by id; +COMMIT; + +BEGIN; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha'); +select id, code, name from t1 order by id; +COMMIT; + +SET binlog_format='MIXED'; +BEGIN; +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt'); +select id, code, name from t1 order by id; +COMMIT; +DROP TABLE t1; + +# +# Test of multi-table-update +# +create table t1 (n int(10), d int(10)) engine=innodb; +create table t2 (n int(10), d int(10)) engine=innodb; +insert into t1 values(1,1),(1,2); +insert into t2 values(1,10),(2,20); +UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n; +select * from t1; +select * from t2; +drop table t1,t2; + +# +# Bug #29136 erred multi-delete on trans table does not rollback +# + +# 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); + + +# exec cases A, B - see multi_update.test + +# A. send_error() w/o send_eof() branch + +--error ER_DUP_ENTRY +delete t2 from t2; + +# check + +select count(*) from t2 /* must be 2 as restored after rollback caused by the error */; + +# cleanup bug#29136 + +drop table t1, t2; + + +# +# Bug #29136 erred multi-delete on trans table does not rollback +# + +# 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); + + +# exec cases A, B - see multi_update.test + +# A. send_error() w/o send_eof() branch + +--error ER_DUP_ENTRY +delete t2 from t2; + +# check + +select count(*) from t2 /* must be 2 as restored after rollback caused by the error */; + +# cleanup bug#29136 + +drop table t1, t2; + + +# +# Testing of IFNULL +# +create table t1 (a int, b int) engine=innodb; +insert into t1 values(20,null); +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a; +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a order by 1; +insert into t1 values(10,null); +select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on +t2.b=t3.a order by 1; +drop table t1; + +# +# Test of read_through not existing const_table +# + +create table t1 (a varchar(10) not null) engine=myisam; +create table t2 (b varchar(10) not null unique) engine=innodb; +select t1.a from t1,t2 where t1.a=t2.b; +drop table t1,t2; +create table t1 (a int not null, b int, primary key (a)) engine = innodb; +create table t2 (a int not null, b int, primary key (a)) engine = innodb; +insert into t1 values (10, 20); +insert into t2 values (10, 20); +update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10; +drop table t1,t2; + +# +# Test of multi-table-delete with foreign key constraints +# + +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) ON DELETE CASCADE ) ENGINE=INNODB; +insert into t1 set id=1; +insert into t2 set id=1, t1_id=1; +delete t1,t2 from t1,t2 where t1.id=t2.t1_id; +select * from t1; +select * from t2; +drop table t2,t1; +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) ) ENGINE=INNODB; +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES(1, 1); +SELECT * from t1; +UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1; +SELECT * from t1; +UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id; +SELECT * from t1; +DROP TABLE t1,t2; + +# +# Test of range_optimizer +# + +set autocommit=0; + +CREATE TABLE t1 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; + +CREATE TABLE t2 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; + +CREATE TABLE t3 (id1 CHAR(15) NOT NULL, id2 CHAR(15) NOT NULL, PRIMARY KEY(id1, id2)) ENGINE=InnoDB; + +INSERT INTO t3 VALUES("my-test-1", "my-test-2"); +COMMIT; + +INSERT INTO t1 VALUES("this-key", "will disappear"); +INSERT INTO t2 VALUES("this-key", "will also disappear"); +DELETE FROM t3 WHERE id1="my-test-1"; + +SELECT * FROM t1; +SELECT * FROM t2; +SELECT * FROM t3; +ROLLBACK; + +SELECT * FROM t1; +SELECT * FROM t2; +SELECT * FROM t3; +SELECT * FROM t3 WHERE id1="my-test-1" LOCK IN SHARE MODE; +COMMIT; +set autocommit=1; +DROP TABLE t1,t2,t3; + +# +# Check update with conflicting key +# + +CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=innodb; +INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); +# We need the a < 1000 test here to quard against the halloween problems +UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000; +SELECT * from t1; +drop table t1; + +# +# Test multi update with different join methods +# + +CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=innodb; +CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=innodb; +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),(12,12); +INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); + +# Full join, without key +update t1,t2 set t1.a=t1.a+100; +select * from t1; + +# unique key +update t1,t2 set t1.a=t1.a+100 where t1.a=101; +select * from t1; + +# ref key +update t1,t2 set t1.b=t1.b+10 where t1.b=2; +select * from t1; + +# Range key (in t1) +update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100; +select * from t1; +select * from t2; + +drop table t1,t2; +CREATE TABLE t2 ( NEXT_T BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM; +CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB; +SET AUTOCOMMIT=0; +INSERT INTO t1 ( B_ID ) VALUES ( 1 ); +INSERT INTO t2 ( NEXT_T ) VALUES ( 1 ); +ROLLBACK; +SELECT * FROM t1; +drop table t1,t2; +create table t1 ( pk int primary key, parent int not null, child int not null, index (parent) ) engine = innodb; +insert into t1 values (1,0,4), (2,1,3), (3,2,1), (4,1,2); +select distinct parent,child from t1 order by parent; +drop table t1; + +# +# Test that MySQL priorities clustered indexes +# +create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb; +create table t2 (a int not null auto_increment primary key, b int); +insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null); +insert into t2 (a) select b from t1; +insert into t1 (b) 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 2500; +update t1 set c=a; +--replace_column 9 # +explain select * from t1 where c between 1 and 2500; +drop table t1,t2; + +# +# Test of UPDATE ... ORDER BY +# + +create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb; + +insert into t1 (id) values (null),(null),(null),(null),(null); +update t1 set fk=69 where fk is null order by id limit 1; +SELECT * from t1; +drop table t1; + +create table t1 (a int not null, b int not null, key (a)); +insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3); +SET @tmp=0; +update t1 set b=(@tmp:=@tmp+1) order by a; +update t1 set b=99 where a=1 order by b asc limit 1; +update t1 set b=100 where a=1 order by b desc limit 2; +update t1 set a=a+10+b where a=1 order by b; +select * from t1 order by a,b; +drop table t1; + +# +# Test of multi-table-updates (bug #1980). +# + +create table t1 ( c char(8) not null ) engine=innodb; +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=innodb; +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 autoincrement with TRUNCATE +# + +SET AUTOCOMMIT=1; +create table t1 (a integer auto_increment primary key) engine=innodb; +insert into t1 (a) values (NULL),(NULL); +truncate table t1; +insert into t1 (a) values (NULL),(NULL); +SELECT * from t1; +drop table t1; + +# +# Test dictionary handling with spaceand quoting +# + +CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`) ON DELETE CASCADE ) ENGINE=INNODB; +#show create table t2; +drop table t2,t1; + +# +# Test of multi updated and foreign keys +# + +create table `t1` (`id` int( 11 ) not null ,primary key ( `id` )) engine = innodb; +insert into `t1`values ( 1 ) ; +create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb; +insert into `t2`values ( 1 ) ; +create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb; +insert into `t3`values ( 1 ) ; +--error 1451 +delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; +--error 1451 +update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; +--error 1054 +update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; +drop table t3,t2,t1; + +# +# test for recursion depth limit +# +create table t1( + id int primary key, + pid int, + index(pid), + foreign key(pid) references t1(id) on delete cascade) engine=innodb; +insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6), + (8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14); +-- error 1451 +delete from t1 where id=0; +delete from t1 where id=15; +delete from t1 where id=0; + +drop table t1; + +# +# Test timestamps +# + +CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB; +CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx +(stamp))ENGINE=InnoDB; +insert into t1 values (1),(2),(3); +# Note that timestamp 3 is wrong +insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000); +SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp < +'20020204120000' GROUP BY col1; +drop table t1,t2; + +# +# Test by Francois MASUREL +# + +CREATE TABLE t1 ( + `id` int(10) unsigned NOT NULL auto_increment, + `id_object` int(10) unsigned default '0', + `id_version` int(10) unsigned NOT NULL default '1', + `label` varchar(100) NOT NULL default '', + `description` text, + PRIMARY KEY (`id`), + KEY `id_object` (`id_object`), + KEY `id_version` (`id_version`) +) ENGINE=InnoDB; + +INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL); + +CREATE TABLE t2 ( + `id` int(10) unsigned NOT NULL auto_increment, + `id_version` int(10) unsigned NOT NULL default '1', + PRIMARY KEY (`id`), + KEY `id_version` (`id_version`) +) ENGINE=InnoDB; + +INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9"); + +SELECT t2.id, t1.`label` FROM t2 INNER JOIN +(SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl +ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object); +drop table t1,t2; + +create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam; +create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb; +create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb; +insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); +insert t2 select * from t1; +insert t3 select * from t1; +checksum table t1, t2, t3, t4 quick; +checksum table t1, t2, t3, t4; +checksum table t1, t2, t3, t4 extended; +#show table status; +drop table t1,t2,t3; + +# +# Test problem with refering to different fields in same table in UNION +# (Bug #2552) +# +create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb; +insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt'); +select trim(name2) from t1 union all select trim(name) from t1 union all select trim(id) from t1; +drop table t1; + +# +# Bug2160 +# +create table t1 (a int) engine=innodb; +create table t2 like t1; +drop table t1,t2; + +# +# Test of automaticly created foreign keys +# + +create table t1 (id int(11) not null, id2 int(11) not null, unique (id,id2)) engine=innodb; +create table t2 (id int(11) not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = innodb; +show create table t1; +show create table t2; +create index id on t2 (id); +show create table t2; +create index id2 on t2 (id); +show create table t2; +drop index id2 on t2; +--error ER_DROP_INDEX_FK +drop index id on t2; +show create table t2; +drop table t2; + +create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb; +show create table t2; +create unique index id on t2 (id,id2); +show create table t2; +drop table t2; + +# Check foreign key columns created in different order than key columns +create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb; +show create table t2; +drop table t2; + +create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb; +show create table t2; +drop table t2; + +create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb; +show create table t2; +drop table t2; + +create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb; +show create table t2; +drop table t2; + +create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb; +show create table t2; +alter table t2 add index id_test (id), add index id_test2 (id,id2); +show create table t2; +drop table t2; + +# Test error handling + +# 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; + +# bug#3749 + +create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb; +show create table t2; +drop table t2; +create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb; +show create table t2; +drop table t2, t1; + + +# +# Bug #6126: Duplicate columns in keys gives misleading error message +# +--error 1060 +create table t1 (c char(10), index (c,c)) engine=innodb; +--error 1060 +create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb; +--error 1060 +create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb; +--error 1060 +create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb; +create table t1 (c1 char(10), c2 char(10)) engine=innodb; +--error 1060 +alter table t1 add key (c1,c1); +--error 1060 +alter table t1 add key (c2,c1,c1); +--error 1060 +alter table t1 add key (c1,c2,c1); +--error 1060 +alter table t1 add key (c1,c1,c2); +drop table t1; + +# +# Bug #4082: integer truncation +# + +create table t1(a int(1) , b int(1)) engine=innodb; +insert into t1 values ('1111', '3333'); +select distinct concat(a, b) from t1; +drop table t1; + +# +# BUG#7709 test case - Boolean fulltext query against unsupported +# engines does not fail +# + +CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; +--error 1214 +SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); +DROP TABLE t1; + +# +# check null values #1 +# + +--disable_warnings +CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), + CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; +--enable_warnings +INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); +SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; +DROP TABLE t2; +DROP TABLE t1; + +# +# Bug#11816 - Truncate table doesn't work with temporary innodb tables +# This is not an innodb bug, but we test it using innodb. +# +create temporary table t1 (a int) engine=innodb; +insert into t1 values (4711); +truncate t1; +insert into t1 values (42); +select * from t1; +drop table t1; +# Show that it works with permanent tables too. +create table t1 (a int) engine=innodb; +insert into t1 values (4711); +truncate t1; +insert into t1 values (42); +select * from t1; +drop table t1; + +# +# Bug #13025 Server crash during filesort +# + +create table t1 (a int not null, b int not null, c blob not null, d int not null, e int, primary key (a,b,c(255),d)) engine=innodb; +insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3); +select * from t1 order by a,b,c,d; +explain select * from t1 order by a,b,c,d; +drop table t1; + +# +# BUG#11039,#13218 Wrong key length in min() +# + +create table t1 (a char(1), b char(1), key(a, b)) engine=innodb; +insert into t1 values ('8', '6'), ('4', '7'); +select min(a) from t1; +select min(b) from t1 where a='8'; +drop table t1; + +# End of 4.1 tests + +# +# range optimizer problem +# + +create table t1 (x bigint unsigned not null primary key) engine=innodb; +insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1); +select * from t1; +select count(*) from t1 where x>0; +select count(*) from t1 where x=0; +select count(*) from t1 where x<0; +select count(*) from t1 where x < -16; +select count(*) from t1 where x = -16; +explain select count(*) from t1 where x > -16; +select count(*) from t1 where x > -16; +select * from t1 where x > -16; +select count(*) from t1 where x = 18446744073709551601; +drop table t1; + + +# Test for testable InnoDB status variables. This test +# uses previous ones(pages_created, rows_deleted, ...). + +# InnoDB aligns the memory for the buffer pool to a page boundary. This may +# cause actual pool size to be one less than requested depending on exact +# alignment of obtained memory. +--replace_result 8192 8191 +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. +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 +SET @innodb_sync_spin_loops_orig = @@innodb_sync_spin_loops; +show variables like "innodb_sync_spin_loops"; +set global innodb_sync_spin_loops=1000; +show variables like "innodb_sync_spin_loops"; +set global innodb_sync_spin_loops=0; +show variables like "innodb_sync_spin_loops"; +set global innodb_sync_spin_loops=20; +show variables like "innodb_sync_spin_loops"; +set global innodb_sync_spin_loops=@innodb_sync_spin_loops_orig; + +# Test for innodb_thread_concurrency variable +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"; +set global innodb_thread_concurrency=0; +show variables like "innodb_thread_concurrency"; +set global innodb_thread_concurrency=16; +show variables like "innodb_thread_concurrency"; +SET @@global.innodb_thread_concurrency= @old_innodb_thread_concurrency; + +# Test for innodb_concurrency_tickets variable +show variables like "innodb_concurrency_tickets"; +set global innodb_concurrency_tickets=1000; +show variables like "innodb_concurrency_tickets"; +set global innodb_concurrency_tickets=0; +show variables like "innodb_concurrency_tickets"; +set global innodb_concurrency_tickets=500; +show variables like "innodb_concurrency_tickets"; + +# Test for innodb_thread_sleep_delay variable +show variables like "innodb_thread_sleep_delay"; +set global innodb_thread_sleep_delay=100000; +show variables like "innodb_thread_sleep_delay"; +set global innodb_thread_sleep_delay=0; +show variables like "innodb_thread_sleep_delay"; +set global innodb_thread_sleep_delay=10000; +show variables like "innodb_thread_sleep_delay"; + +# +# Test varchar +# + +let $default=`select @@storage_engine`; +set storage_engine=INNODB; +source include/varchar.inc; + +# +# Some errors/warnings on create +# + +# 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)); +show create table t1; +drop table t1; +create table t1 (v varchar(65530) character set utf8); +show create table t1; +drop table t1; + +eval set storage_engine=$default; + +# InnoDB specific varchar tests +create table t1 (v varchar(16384)) engine=innodb; +drop table t1; + +# +# BUG#11039 Wrong key length in min() +# + +create table t1 (a char(1), b char(1), key(a, b)) engine=innodb; +insert into t1 values ('8', '6'), ('4', '7'); +select min(a) from t1; +select min(b) from t1 where a='8'; +drop table t1; + +# +# Bug #11080 & #11005 Multi-row REPLACE fails on a duplicate key error +# + +CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb; +insert into t1 (b) values (1); +replace into t1 (b) values (2), (1), (3); +select * from t1; +truncate table t1; +insert into t1 (b) values (1); +replace into t1 (b) values (2); +replace into t1 (b) values (1); +replace into t1 (b) values (3); +select * from t1; +drop table t1; + +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 ER_DUP_ENTRY +insert into t1 (val) values ('1'),('2'); +select * from t1; +drop table t1; + +# +# Test that update does not change internal auto-increment value +# + +create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB; +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 ER_DUP_ENTRY +insert into t1 (val) values (1); +select * from t1; +drop table t1; +# +# Bug #10465 +# + +--disable_warnings +CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB; +--enable_warnings +INSERT INTO t1 (GRADE) VALUES (151),(252),(343); +SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300; +SELECT GRADE FROM t1 WHERE GRADE= 151; +DROP TABLE t1; + +# +# Bug #12340 multitable delete deletes only one record +# +create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb; +create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb; +insert into t2 values ('aa','cc'); +insert into t1 values ('aa','bb'),('aa','cc'); +delete t1 from t1,t2 where f1=f3 and f4='cc'; +select * from t1; +drop table t1,t2; + +# +# Test that the slow TRUNCATE implementation resets autoincrement columns +# (bug #11946) +# + +CREATE TABLE t1 ( +id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) +) ENGINE=InnoDB; + +CREATE TABLE t2 ( +id INTEGER NOT NULL, +FOREIGN KEY (id) REFERENCES t1 (id) +) ENGINE=InnoDB; + +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; +TRUNCATE t1; +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; + +# continued from above; test that doing a slow TRUNCATE on a table with 0 +# rows resets autoincrement columns +DELETE FROM t1; +TRUNCATE t1; +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; +DROP TABLE t2, t1; + +# Test that foreign keys in temporary tables are not accepted (bug #12084) +CREATE TABLE t1 +( + id INT PRIMARY KEY +) ENGINE=InnoDB; + +--error 1005,1005 +CREATE TEMPORARY TABLE t2 +( + id INT NOT NULL PRIMARY KEY, + b INT, + FOREIGN KEY (b) REFERENCES test.t1(id) +) ENGINE=InnoDB; +DROP TABLE t1; + +# +# Test that index column max sizes are honored (bug #13315) +# + +# prefix index +create table t1 (col1 varchar(2000), index (col1(767))) + character set = latin1 engine = innodb; + +# normal indexes +create table t2 (col1 char(255), index (col1)) + character set = latin1 engine = innodb; +create table t3 (col1 binary(255), index (col1)) + character set = latin1 engine = innodb; +create table t4 (col1 varchar(767), index (col1)) + character set = latin1 engine = innodb; +create table t5 (col1 varchar(767) primary key) + character set = latin1 engine = innodb; +create table t6 (col1 varbinary(767) primary key) + character set = latin1 engine = innodb; +create table t7 (col1 text, index(col1(767))) + character set = latin1 engine = innodb; +create table t8 (col1 blob, index(col1(767))) + character set = latin1 engine = innodb; + +# multi-column indexes are allowed to be longer +create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2)) + character set = latin1 engine = innodb; + +show create table t9; + +drop table t1, t2, t3, t4, t5, t6, t7, t8, t9; + +# these should have their index length trimmed +create table t1 (col1 varchar(768), index(col1)) + character set = latin1 engine = innodb; +create table t2 (col1 varbinary(768), index(col1)) + character set = latin1 engine = innodb; +create table t3 (col1 text, index(col1(768))) + character set = latin1 engine = innodb; +create table t4 (col1 blob, index(col1(768))) + character set = latin1 engine = innodb; + +show create table t1; + +drop table t1, t2, t3, t4; + +# these should be refused +--error 1071 +create table t1 (col1 varchar(768) primary key) + character set = latin1 engine = innodb; +--error 1071 +create table t2 (col1 varbinary(768) primary key) + character set = latin1 engine = innodb; +--error 1071 +create table t3 (col1 text, primary key(col1(768))) + character set = latin1 engine = innodb; +--error 1071 +create table t4 (col1 blob, primary key(col1(768))) + character set = latin1 engine = innodb; + +# +# Test improved foreign key error messages (bug #3443) +# + +CREATE TABLE t1 +( + id INT PRIMARY KEY +) ENGINE=InnoDB; + +CREATE TABLE t2 +( + v INT, + CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id) +) ENGINE=InnoDB; + +--error 1452 +INSERT INTO t2 VALUES(2); + +INSERT INTO t1 VALUES(1); +INSERT INTO t2 VALUES(1); + +--error 1451 +DELETE FROM t1 WHERE id = 1; + +--error 1217 +DROP TABLE t1; + +SET FOREIGN_KEY_CHECKS=0; +DROP TABLE t1; +SET FOREIGN_KEY_CHECKS=1; + +--error 1452 +INSERT INTO t2 VALUES(3); + +DROP TABLE t2; +# +# Test that checksum table uses a consistent read Bug #12669 +# +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; +insert into t1 values (1),(2); +set autocommit=0; +checksum table t1; +connection b; +insert into t1 values(3); +connection a; +# +# Here checksum should not see insert +# +checksum table t1; +connection a; +commit; +checksum table t1; +commit; +drop table t1; +# +# autocommit = 1 +# +connection a; +create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; +insert into t1 values (1),(2); +set autocommit=1; +checksum table t1; +connection b; +set autocommit=1; +insert into t1 values(3); +connection a; +# +# Here checksum sees insert +# +checksum table t1; +drop table t1; + +connection default; +disconnect a; +disconnect b; + +# tests for bugs #9802 and #13778 + +# test that FKs between invalid types are not accepted + +set foreign_key_checks=0; +create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb; +# 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; +drop table t2; + +# test that FKs between different charsets are not accepted in CREATE even +# when f_k_c is 0 + +set foreign_key_checks=0; +create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1; +# 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; +drop table t1; + +# test that invalid datatype conversions with ALTER are not allowed + +set foreign_key_checks=0; +create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb; +create table t1(a varchar(10) primary key) engine = innodb; +-- error 1025,1025 +alter table t1 modify column a int; +set foreign_key_checks=1; +drop table t2,t1; + +# test that charset conversions with ALTER are allowed when f_k_c is 0 + +set foreign_key_checks=0; +create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1; +create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1; +alter table t1 convert to character set utf8; +set foreign_key_checks=1; +drop table t2,t1; + +# test that RENAME does not allow invalid charsets when f_k_c is 0 + +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; +# 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; +drop table t2,t3; + +# test that foreign key errors are reported correctly (Bug #15550) + +create table t1(a int primary key) row_format=redundant engine=innodb; +create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb; +create table t3(a int primary key) row_format=compact engine=innodb; +create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb; + +insert into t1 values(1); +insert into t3 values(1); +-- error 1452 +insert into t2 values(2); +-- error 1452 +insert into t4 values(2); +insert into t2 values(1); +insert into t4 values(1); +-- error 1451 +update t1 set a=2; +-- error 1452 +update t2 set a=2; +-- error 1451 +update t3 set a=2; +-- error 1452 +update t4 set a=2; +-- error 1451 +truncate t1; +-- error 1451 +truncate t3; +truncate t2; +truncate t4; +truncate t1; +truncate t3; + +drop table t4,t3,t2,t1; + + +# +# Test that we can create a large (>1K) 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=innodb; +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=innodb; + + +# test the padding of BINARY types and collations (Bug #14189) + +create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb; +create table t2 (s1 binary(2),primary key (s1)) engine=innodb; +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 ER_DUP_ENTRY +insert into t2 values (0x41),(0x4120),(0x4100); +insert into t2 values (0x41),(0x4120); +-- error ER_DUP_ENTRY +insert into t3 values (0x41),(0x4120),(0x4100); +insert into t3 values (0x41),(0x4100); +-- error ER_DUP_ENTRY +insert into t4 values (0x41),(0x4120),(0x4100); +insert into t4 values (0x41),(0x4100); +select hex(s1) from t1; +select hex(s1) from t2; +select hex(s1) from t3; +select hex(s1) from t4; +drop table t1,t2,t3,t4; + +create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb; +create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb; + +insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42); +-- error 1452 +insert into t2 values(0x42); +insert into t2 values(0x41); +select hex(s1) from t2; +update t1 set s1=0x123456 where a=2; +select hex(s1) from t2; +-- error 1451 +update t1 set s1=0x12 where a=1; +-- error 1451 +update t1 set s1=0x12345678 where a=1; +-- error 1451 +update t1 set s1=0x123457 where a=1; +update t1 set s1=0x1220 where a=1; +select hex(s1) from t2; +update t1 set s1=0x1200 where a=1; +select hex(s1) from t2; +update t1 set s1=0x4200 where a=1; +select hex(s1) from t2; +-- error 1451 +delete from t1 where a=1; +delete from t1 where a=2; +update t2 set s1=0x4120; +-- error 1451 +delete from t1; +delete from t1 where a!=3; +select a,hex(s1) from t1; +select hex(s1) from t2; + +drop table t2,t1; + +create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb; +create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb; + +insert into t1 values(1,0x4100),(2,0x41); +insert into t2 values(0x41); +select hex(s1) from t2; +update t1 set s1=0x1234 where a=1; +select hex(s1) from t2; +update t1 set s1=0x12 where a=2; +select hex(s1) from t2; +delete from t1 where a=1; +-- error 1451 +delete from t1 where a=2; +select a,hex(s1) from t1; +select hex(s1) from t2; + +drop table t2,t1; +# Ensure that <tablename>_ibfk_0 is not mistreated as a +# generated foreign key identifier. (Bug #16387) + +CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB; +CREATE TABLE t2(a INT) ENGINE=InnoDB; +ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a); +ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1; +ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a); +ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0; +SHOW CREATE TABLE t2; +DROP TABLE t2,t1; + +# +# Test case for bug #16229: MySQL/InnoDB uses full explicit table locks in trigger processing +# + +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb; +insert into t1(a) values (1),(2),(3); +commit; +connection b; +set autocommit = 0; +update t1 set b = 5 where a = 2; +connection a; +delimiter |; +create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end | +delimiter ;| +set autocommit = 0; +connection a; +insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100), +(11),(21),(31),(41),(51),(61),(71),(81),(91),(101), +(12),(22),(32),(42),(52),(62),(72),(82),(92),(102), +(13),(23),(33),(43),(53),(63),(73),(83),(93),(103), +(14),(24),(34),(44),(54),(64),(74),(84),(94),(104); +connection b; +commit; +connection a; +commit; +drop trigger t1t; +drop table t1; +disconnect a; +disconnect b; +# +# Another trigger test +# +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb; +create table t2(a int not null, b int, c int, d int, primary key(a)) engine=innodb; +create table t3(a int not null, b int, c int, d int, primary key(a)) engine=innodb; +create table t4(a int not null, b int, c int, d int, primary key(a)) engine=innodb; +create table t5(a int not null, b int, c int, d int, primary key(a)) engine=innodb; +insert into t1(a) values (1),(2),(3); +insert into t2(a) values (1),(2),(3); +insert into t3(a) values (1),(2),(3); +insert into t4(a) values (1),(2),(3); +insert into t3(a) values (5),(7),(8); +insert into t4(a) values (5),(7),(8); +insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12); + +delimiter |; +create trigger t1t before insert on t1 for each row begin + INSERT INTO t2 SET a = NEW.a; +end | + +create trigger t2t before insert on t2 for each row begin + DELETE FROM t3 WHERE a = NEW.a; +end | + +create trigger t3t before delete on t3 for each row begin + UPDATE t4 SET b = b + 1 WHERE a = OLD.a; +end | + +create trigger t4t before update on t4 for each row begin + UPDATE t5 SET b = b + 1 where a = NEW.a; +end | +delimiter ;| +commit; +set autocommit = 0; +update t1 set b = b + 5 where a = 1; +update t2 set b = b + 5 where a = 1; +update t3 set b = b + 5 where a = 1; +update t4 set b = b + 5 where a = 1; +insert into t5(a) values(20); +connection b; +set autocommit = 0; +insert into t1(a) values(7); +insert into t2(a) values(8); +delete from t2 where a = 3; +update t4 set b = b + 1 where a = 3; +commit; +drop trigger t1t; +drop trigger t2t; +drop trigger t3t; +drop trigger t4t; +drop table t1, t2, t3, t4, t5; +connection default; +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 +# + +create table t1(a date) engine=innodb; +create table t2(a date, key(a)) engine=innodb; +insert into t1 values('2005-10-01'); +insert into t2 values('2005-10-01'); +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" +--error ER_WRONG_COLUMN_NAME +CREATE TABLE t1 (DB_ROW_ID int) engine=innodb; + +# +# Bug #17152: Wrong result with BINARY comparison on aliased column +# + +CREATE TABLE t1 ( + a BIGINT(20) NOT NULL, + PRIMARY KEY (a) + ) ENGINE=INNODB DEFAULT CHARSET=UTF8; + +CREATE TABLE t2 ( + a BIGINT(20) NOT NULL, + b VARCHAR(128) NOT NULL, + c TEXT NOT NULL, + PRIMARY KEY (a,b), + KEY idx_t2_b_c (b,c(200)), + CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a) + ON DELETE CASCADE + ) ENGINE=INNODB DEFAULT CHARSET=UTF8; + +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1, 'bar', 'vbar'); +INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR'); +INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi'); +INSERT INTO t2 VALUES (1, 'customer_over', '1'); + +SELECT * FROM t2 WHERE b = 'customer_over'; +SELECT * FROM t2 WHERE BINARY b = 'customer_over'; +SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over'; +/* Bang: Empty result set, above was expected: */ +SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over'; +SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over'; + +drop table t2, t1; + +# +# 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) +# + +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 +# for which there is a foreign key constraint ON ... SET NULL. +# + +CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB; +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; +# 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; +DROP TABLE t2,t1; + +# +# Bug #23313 (AUTO_INCREMENT=# not reported back for InnoDB tables) +# Bug #21404 (AUTO_INCREMENT value reset when Adding FKEY (or ALTER?)) +# + +CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB +AUTO_INCREMENT=42; + +INSERT INTO t1 VALUES (0),(347),(0); +SELECT * FROM t1; + +SHOW CREATE TABLE t1; + +CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t2 VALUES(42),(347),(348); +ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id); +SHOW CREATE TABLE t1; + +DROP TABLE t1,t2; + +# +# Bug #21101 (Prints wrong error message if max row size is too large) +# +set innodb_strict_mode=on; +--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; + +-- enable_query_log + +####################################################################### +# # +# Please, DO NOT TOUCH this file as well as the innodb.result file. # +# These files are to be modified ONLY BY INNOBASE guys. # +# # +# Use innodb_mysql.[test|result] files instead. # +# # +# If nevertheless you need to make some changes here, please, forward # +# 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_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..5b1939e648e --- /dev/null +++ b/mysql-test/t/innodb_bug34300.test @@ -0,0 +1,36 @@ +# +# 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_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; +EVAL SET @@global.max_allowed_packet=$max_packet; diff --git a/mysql-test/t/innodb_bug35220.test b/mysql-test/t/innodb_bug35220.test new file mode 100644 index 00000000000..26f7d6b1ddd --- /dev/null +++ b/mysql-test/t/innodb_bug35220.test @@ -0,0 +1,16 @@ +# +# Bug#35220 ALTER TABLE too picky on reserved word "foreign" +# http://bugs.mysql.com/35220 +# + +-- source include/have_innodb.inc + +SET storage_engine=InnoDB; + +# we care only that the following SQL commands do not produce errors +-- disable_query_log +-- disable_result_log + +CREATE TABLE bug35220 (foreign_col INT, dummy_cant_delete_all_columns INT); +ALTER TABLE bug35220 DROP foreign_col; +DROP TABLE bug35220; diff --git a/mysql-test/t/innodb_bug36169.test b/mysql-test/t/innodb_bug36169.test new file mode 100644 index 00000000000..5bf55193b5c --- /dev/null +++ b/mysql-test/t/innodb_bug36169.test @@ -0,0 +1,1159 @@ +# +# Bug#36169 create innodb compressed table with too large row size crashed +# http://bugs.mysql.com/36169 +# + +-- source include/have_innodb.inc + +let $file_format=`select @@innodb_file_format`; +let $file_per_table=`select @@innodb_file_per_table`; +SET GLOBAL innodb_file_format='Barracuda'; +SET GLOBAL innodb_file_per_table=ON; + +# +# The following is copied from http://bugs.mysql.com/36169 +# (http://bugs.mysql.com/file.php?id=9121) +# Probably it can be simplified but that is not obvious. +# + +# we care only that the following SQL commands do produce errors +# as expected and do not crash the server +-- disable_query_log +-- disable_result_log + +# Generating 10 tables +# Creating a table with 94 columns and 24 indexes +DROP TABLE IF EXISTS `table0`; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table0` +(`col0` BOOL, +`col1` BOOL, +`col2` TINYINT, +`col3` DATE, +`col4` TIME, +`col5` SET ('test1','test2','test3'), +`col6` TIME, +`col7` TEXT, +`col8` DECIMAL, +`col9` SET ('test1','test2','test3'), +`col10` FLOAT, +`col11` DOUBLE PRECISION, +`col12` ENUM ('test1','test2','test3'), +`col13` TINYBLOB, +`col14` YEAR, +`col15` SET ('test1','test2','test3'), +`col16` NUMERIC, +`col17` NUMERIC, +`col18` BLOB, +`col19` DATETIME, +`col20` DOUBLE PRECISION, +`col21` DECIMAL, +`col22` DATETIME, +`col23` NUMERIC, +`col24` NUMERIC, +`col25` LONGTEXT, +`col26` TINYBLOB, +`col27` TIME, +`col28` TINYBLOB, +`col29` ENUM ('test1','test2','test3'), +`col30` SMALLINT, +`col31` REAL, +`col32` FLOAT, +`col33` CHAR (175), +`col34` TINYTEXT, +`col35` TINYTEXT, +`col36` TINYBLOB, +`col37` TINYBLOB, +`col38` TINYTEXT, +`col39` MEDIUMBLOB, +`col40` TIMESTAMP, +`col41` DOUBLE, +`col42` SMALLINT, +`col43` LONGBLOB, +`col44` VARCHAR (80), +`col45` MEDIUMTEXT, +`col46` NUMERIC, +`col47` BIGINT, +`col48` DATE, +`col49` TINYBLOB, +`col50` DATE, +`col51` BOOL, +`col52` MEDIUMINT, +`col53` FLOAT, +`col54` TINYBLOB, +`col55` LONGTEXT, +`col56` SMALLINT, +`col57` ENUM ('test1','test2','test3'), +`col58` DATETIME, +`col59` MEDIUMTEXT, +`col60` VARCHAR (232), +`col61` NUMERIC, +`col62` YEAR, +`col63` SMALLINT, +`col64` TIMESTAMP, +`col65` BLOB, +`col66` LONGBLOB, +`col67` INT, +`col68` LONGTEXT, +`col69` ENUM ('test1','test2','test3'), +`col70` INT, +`col71` TIME, +`col72` TIMESTAMP, +`col73` TIMESTAMP, +`col74` VARCHAR (170), +`col75` SET ('test1','test2','test3'), +`col76` TINYBLOB, +`col77` BIGINT, +`col78` NUMERIC, +`col79` DATETIME, +`col80` YEAR, +`col81` NUMERIC, +`col82` LONGBLOB, +`col83` TEXT, +`col84` CHAR (83), +`col85` DECIMAL, +`col86` FLOAT, +`col87` INT, +`col88` VARCHAR (145), +`col89` DATE, +`col90` DECIMAL, +`col91` DECIMAL, +`col92` MEDIUMBLOB, +`col93` TIME, +KEY `idx0` (`col69`,`col90`,`col8`), +KEY `idx1` (`col60`), +KEY `idx2` (`col60`,`col70`,`col74`), +KEY `idx3` (`col22`,`col32`,`col72`,`col30`), +KEY `idx4` (`col29`), +KEY `idx5` (`col19`,`col45`(143)), +KEY `idx6` (`col46`,`col48`,`col5`,`col39`(118)), +KEY `idx7` (`col48`,`col61`), +KEY `idx8` (`col93`), +KEY `idx9` (`col31`), +KEY `idx10` (`col30`,`col21`), +KEY `idx11` (`col67`), +KEY `idx12` (`col44`,`col6`,`col8`,`col38`(226)), +KEY `idx13` (`col71`,`col41`,`col15`,`col49`(88)), +KEY `idx14` (`col78`), +KEY `idx15` (`col63`,`col67`,`col64`), +KEY `idx16` (`col17`,`col86`), +KEY `idx17` (`col77`,`col56`,`col10`,`col55`(24)), +KEY `idx18` (`col62`), +KEY `idx19` (`col31`,`col57`,`col56`,`col53`), +KEY `idx20` (`col46`), +KEY `idx21` (`col83`(54)), +KEY `idx22` (`col51`,`col7`(120)), +KEY `idx23` (`col7`(163),`col31`,`col71`,`col14`) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +# Creating a table with 10 columns and 32 indexes +DROP TABLE IF EXISTS `table1`; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table1` +(`col0` CHAR (113), +`col1` FLOAT, +`col2` BIGINT, +`col3` DECIMAL, +`col4` BLOB, +`col5` LONGTEXT, +`col6` SET ('test1','test2','test3'), +`col7` BIGINT, +`col8` BIGINT, +`col9` TINYBLOB, +KEY `idx0` (`col5`(101),`col7`,`col8`), +KEY `idx1` (`col8`), +KEY `idx2` (`col4`(177),`col9`(126),`col6`,`col3`), +KEY `idx3` (`col5`(160)), +KEY `idx4` (`col9`(242)), +KEY `idx5` (`col4`(139),`col2`,`col3`), +KEY `idx6` (`col7`), +KEY `idx7` (`col6`,`col2`,`col0`,`col3`), +KEY `idx8` (`col9`(66)), +KEY `idx9` (`col5`(253)), +KEY `idx10` (`col1`,`col7`,`col2`), +KEY `idx11` (`col9`(242),`col0`,`col8`,`col5`(163)), +KEY `idx12` (`col8`), +KEY `idx13` (`col0`,`col9`(37)), +KEY `idx14` (`col0`), +KEY `idx15` (`col5`(111)), +KEY `idx16` (`col8`,`col0`,`col5`(13)), +KEY `idx17` (`col4`(139)), +KEY `idx18` (`col5`(189),`col2`,`col3`,`col9`(136)), +KEY `idx19` (`col0`,`col3`,`col1`,`col8`), +KEY `idx20` (`col8`), +KEY `idx21` (`col0`,`col7`,`col9`(227),`col3`), +KEY `idx22` (`col0`), +KEY `idx23` (`col2`), +KEY `idx24` (`col3`), +KEY `idx25` (`col2`,`col3`), +KEY `idx26` (`col0`), +KEY `idx27` (`col5`(254)), +KEY `idx28` (`col3`), +KEY `idx29` (`col3`), +KEY `idx30` (`col7`,`col3`,`col0`,`col4`(220)), +KEY `idx31` (`col4`(1),`col0`) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +# Creating a table with 141 columns and 18 indexes +DROP TABLE IF EXISTS `table2`; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table2` +(`col0` BOOL, +`col1` MEDIUMINT, +`col2` VARCHAR (209), +`col3` MEDIUMBLOB, +`col4` CHAR (13), +`col5` DOUBLE, +`col6` TINYTEXT, +`col7` REAL, +`col8` SMALLINT, +`col9` BLOB, +`col10` TINYINT, +`col11` DECIMAL, +`col12` BLOB, +`col13` DECIMAL, +`col14` LONGBLOB, +`col15` SMALLINT, +`col16` LONGBLOB, +`col17` TINYTEXT, +`col18` FLOAT, +`col19` CHAR (78), +`col20` MEDIUMTEXT, +`col21` SET ('test1','test2','test3'), +`col22` MEDIUMINT, +`col23` INT, +`col24` MEDIUMBLOB, +`col25` ENUM ('test1','test2','test3'), +`col26` TINYBLOB, +`col27` VARCHAR (116), +`col28` TIMESTAMP, +`col29` BLOB, +`col30` SMALLINT, +`col31` DOUBLE PRECISION, +`col32` DECIMAL, +`col33` DECIMAL, +`col34` TEXT, +`col35` MEDIUMINT, +`col36` MEDIUMINT, +`col37` BIGINT, +`col38` VARCHAR (253), +`col39` TINYBLOB, +`col40` MEDIUMBLOB, +`col41` BIGINT, +`col42` DOUBLE, +`col43` TEXT, +`col44` BLOB, +`col45` TIME, +`col46` MEDIUMINT, +`col47` DOUBLE PRECISION, +`col48` SET ('test1','test2','test3'), +`col49` DOUBLE PRECISION, +`col50` VARCHAR (97), +`col51` TEXT, +`col52` NUMERIC, +`col53` ENUM ('test1','test2','test3'), +`col54` MEDIUMTEXT, +`col55` MEDIUMINT, +`col56` DATETIME, +`col57` DATETIME, +`col58` MEDIUMTEXT, +`col59` CHAR (244), +`col60` LONGBLOB, +`col61` MEDIUMBLOB, +`col62` DOUBLE, +`col63` SMALLINT, +`col64` BOOL, +`col65` SMALLINT, +`col66` VARCHAR (212), +`col67` TIME, +`col68` REAL, +`col69` BOOL, +`col70` BIGINT, +`col71` DATE, +`col72` TINYINT, +`col73` ENUM ('test1','test2','test3'), +`col74` DATE, +`col75` TIME, +`col76` DATETIME, +`col77` BOOL, +`col78` TINYTEXT, +`col79` MEDIUMINT, +`col80` NUMERIC, +`col81` LONGTEXT, +`col82` SET ('test1','test2','test3'), +`col83` DOUBLE PRECISION, +`col84` NUMERIC, +`col85` VARCHAR (184), +`col86` DOUBLE PRECISION, +`col87` MEDIUMTEXT, +`col88` MEDIUMBLOB, +`col89` BOOL, +`col90` SMALLINT, +`col91` TINYINT, +`col92` ENUM ('test1','test2','test3'), +`col93` BOOL, +`col94` TIMESTAMP, +`col95` BOOL, +`col96` MEDIUMTEXT, +`col97` DECIMAL, +`col98` BOOL, +`col99` DECIMAL, +`col100` MEDIUMINT, +`col101` DOUBLE PRECISION, +`col102` TINYINT, +`col103` BOOL, +`col104` MEDIUMINT, +`col105` DECIMAL, +`col106` NUMERIC, +`col107` TIMESTAMP, +`col108` MEDIUMBLOB, +`col109` TINYBLOB, +`col110` SET ('test1','test2','test3'), +`col111` YEAR, +`col112` TIMESTAMP, +`col113` CHAR (201), +`col114` BOOL, +`col115` TINYINT, +`col116` DOUBLE, +`col117` TINYINT, +`col118` TIMESTAMP, +`col119` SET ('test1','test2','test3'), +`col120` SMALLINT, +`col121` TINYBLOB, +`col122` TIMESTAMP, +`col123` BLOB, +`col124` DATE, +`col125` SMALLINT, +`col126` ENUM ('test1','test2','test3'), +`col127` MEDIUMBLOB, +`col128` DOUBLE PRECISION, +`col129` REAL, +`col130` VARCHAR (159), +`col131` MEDIUMBLOB, +`col132` BIGINT, +`col133` INT, +`col134` SET ('test1','test2','test3'), +`col135` CHAR (198), +`col136` SET ('test1','test2','test3'), +`col137` MEDIUMTEXT, +`col138` SMALLINT, +`col139` BLOB, +`col140` LONGBLOB, +KEY `idx0` (`col14`(139),`col24`(208),`col38`,`col35`), +KEY `idx1` (`col48`,`col118`,`col29`(131),`col100`), +KEY `idx2` (`col86`,`col67`,`col43`(175)), +KEY `idx3` (`col19`), +KEY `idx4` (`col40`(220),`col67`), +KEY `idx5` (`col99`,`col56`), +KEY `idx6` (`col68`,`col28`,`col137`(157)), +KEY `idx7` (`col51`(160),`col99`,`col45`,`col39`(9)), +KEY `idx8` (`col15`,`col52`,`col90`,`col94`), +KEY `idx9` (`col24`(3),`col139`(248),`col108`(118),`col41`), +KEY `idx10` (`col36`,`col92`,`col114`), +KEY `idx11` (`col115`,`col9`(116)), +KEY `idx12` (`col130`,`col93`,`col134`), +KEY `idx13` (`col123`(65)), +KEY `idx14` (`col44`(90),`col86`,`col119`), +KEY `idx15` (`col69`), +KEY `idx16` (`col132`,`col81`(118),`col18`), +KEY `idx17` (`col24`(250),`col7`,`col92`,`col45`) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +# Creating a table with 199 columns and 1 indexes +DROP TABLE IF EXISTS `table3`; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table3` +(`col0` SMALLINT, +`col1` SET ('test1','test2','test3'), +`col2` TINYTEXT, +`col3` DOUBLE, +`col4` NUMERIC, +`col5` DATE, +`col6` BIGINT, +`col7` DOUBLE, +`col8` TEXT, +`col9` INT, +`col10` REAL, +`col11` TINYINT, +`col12` NUMERIC, +`col13` NUMERIC, +`col14` TIME, +`col15` DOUBLE, +`col16` REAL, +`col17` MEDIUMBLOB, +`col18` YEAR, +`col19` TINYTEXT, +`col20` YEAR, +`col21` CHAR (250), +`col22` TINYINT, +`col23` TINYINT, +`col24` SMALLINT, +`col25` DATETIME, +`col26` MEDIUMINT, +`col27` LONGBLOB, +`col28` VARCHAR (106), +`col29` FLOAT, +`col30` MEDIUMTEXT, +`col31` TINYBLOB, +`col32` BIGINT, +`col33` YEAR, +`col34` REAL, +`col35` MEDIUMBLOB, +`col36` LONGTEXT, +`col37` LONGBLOB, +`col38` BIGINT, +`col39` FLOAT, +`col40` TIME, +`col41` DATETIME, +`col42` BOOL, +`col43` BIGINT, +`col44` SMALLINT, +`col45` TIME, +`col46` DOUBLE PRECISION, +`col47` TIME, +`col48` TINYTEXT, +`col49` DOUBLE PRECISION, +`col50` BIGINT, +`col51` NUMERIC, +`col52` TINYBLOB, +`col53` DATE, +`col54` DECIMAL, +`col55` SMALLINT, +`col56` TINYTEXT, +`col57` ENUM ('test1','test2','test3'), +`col58` YEAR, +`col59` TIME, +`col60` TINYINT, +`col61` DECIMAL, +`col62` DOUBLE, +`col63` DATE, +`col64` LONGTEXT, +`col65` DOUBLE, +`col66` VARCHAR (88), +`col67` MEDIUMTEXT, +`col68` DATE, +`col69` MEDIUMINT, +`col70` DECIMAL, +`col71` MEDIUMTEXT, +`col72` LONGTEXT, +`col73` REAL, +`col74` DOUBLE, +`col75` TIME, +`col76` DATE, +`col77` DECIMAL, +`col78` MEDIUMBLOB, +`col79` NUMERIC, +`col80` BIGINT, +`col81` YEAR, +`col82` SMALLINT, +`col83` MEDIUMINT, +`col84` TINYINT, +`col85` MEDIUMBLOB, +`col86` TIME, +`col87` MEDIUMBLOB, +`col88` LONGTEXT, +`col89` BOOL, +`col90` BLOB, +`col91` LONGBLOB, +`col92` YEAR, +`col93` BLOB, +`col94` INT, +`col95` TINYTEXT, +`col96` TINYINT, +`col97` DECIMAL, +`col98` ENUM ('test1','test2','test3'), +`col99` MEDIUMINT, +`col100` TINYINT, +`col101` MEDIUMBLOB, +`col102` TINYINT, +`col103` SET ('test1','test2','test3'), +`col104` TIMESTAMP, +`col105` TEXT, +`col106` DATETIME, +`col107` MEDIUMTEXT, +`col108` CHAR (220), +`col109` TIME, +`col110` VARCHAR (131), +`col111` DECIMAL, +`col112` FLOAT, +`col113` SMALLINT, +`col114` BIGINT, +`col115` LONGBLOB, +`col116` SET ('test1','test2','test3'), +`col117` ENUM ('test1','test2','test3'), +`col118` BLOB, +`col119` MEDIUMTEXT, +`col120` SET ('test1','test2','test3'), +`col121` DATETIME, +`col122` FLOAT, +`col123` VARCHAR (242), +`col124` YEAR, +`col125` MEDIUMBLOB, +`col126` TIME, +`col127` BOOL, +`col128` TINYBLOB, +`col129` DOUBLE, +`col130` TINYINT, +`col131` BIGINT, +`col132` SMALLINT, +`col133` INT, +`col134` DOUBLE PRECISION, +`col135` MEDIUMBLOB, +`col136` SET ('test1','test2','test3'), +`col137` TINYTEXT, +`col138` DOUBLE PRECISION, +`col139` NUMERIC, +`col140` BLOB, +`col141` SET ('test1','test2','test3'), +`col142` INT, +`col143` VARCHAR (26), +`col144` BLOB, +`col145` REAL, +`col146` SET ('test1','test2','test3'), +`col147` LONGBLOB, +`col148` TEXT, +`col149` BLOB, +`col150` CHAR (189), +`col151` LONGTEXT, +`col152` INT, +`col153` FLOAT, +`col154` LONGTEXT, +`col155` DATE, +`col156` LONGBLOB, +`col157` TINYBLOB, +`col158` REAL, +`col159` DATE, +`col160` TIME, +`col161` YEAR, +`col162` DOUBLE, +`col163` VARCHAR (90), +`col164` FLOAT, +`col165` NUMERIC, +`col166` ENUM ('test1','test2','test3'), +`col167` DOUBLE PRECISION, +`col168` DOUBLE PRECISION, +`col169` TINYBLOB, +`col170` TIME, +`col171` SMALLINT, +`col172` TINYTEXT, +`col173` SMALLINT, +`col174` DOUBLE, +`col175` VARCHAR (14), +`col176` VARCHAR (90), +`col177` REAL, +`col178` MEDIUMINT, +`col179` TINYBLOB, +`col180` FLOAT, +`col181` TIMESTAMP, +`col182` REAL, +`col183` DOUBLE PRECISION, +`col184` BIGINT, +`col185` INT, +`col186` MEDIUMTEXT, +`col187` TIME, +`col188` FLOAT, +`col189` TIME, +`col190` INT, +`col191` FLOAT, +`col192` MEDIUMINT, +`col193` TINYINT, +`col194` MEDIUMTEXT, +`col195` DATE, +`col196` TIME, +`col197` YEAR, +`col198` CHAR (206), +KEY `idx0` (`col39`,`col23`) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +# Creating a table with 133 columns and 16 indexes +DROP TABLE IF EXISTS `table4`; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table4` +(`col0` VARCHAR (60), +`col1` NUMERIC, +`col2` LONGTEXT, +`col3` MEDIUMTEXT, +`col4` LONGTEXT, +`col5` LONGBLOB, +`col6` LONGBLOB, +`col7` DATETIME, +`col8` TINYTEXT, +`col9` BLOB, +`col10` BOOL, +`col11` BIGINT, +`col12` TEXT, +`col13` VARCHAR (213), +`col14` TINYBLOB, +`col15` BOOL, +`col16` MEDIUMTEXT, +`col17` DOUBLE, +`col18` TEXT, +`col19` BLOB, +`col20` SET ('test1','test2','test3'), +`col21` TINYINT, +`col22` DATETIME, +`col23` TINYINT, +`col24` ENUM ('test1','test2','test3'), +`col25` REAL, +`col26` BOOL, +`col27` FLOAT, +`col28` LONGBLOB, +`col29` DATETIME, +`col30` FLOAT, +`col31` SET ('test1','test2','test3'), +`col32` LONGBLOB, +`col33` NUMERIC, +`col34` YEAR, +`col35` VARCHAR (146), +`col36` BIGINT, +`col37` DATETIME, +`col38` DATE, +`col39` SET ('test1','test2','test3'), +`col40` CHAR (112), +`col41` FLOAT, +`col42` YEAR, +`col43` TIME, +`col44` DOUBLE, +`col45` NUMERIC, +`col46` FLOAT, +`col47` DECIMAL, +`col48` BIGINT, +`col49` DECIMAL, +`col50` YEAR, +`col51` MEDIUMTEXT, +`col52` LONGBLOB, +`col53` SET ('test1','test2','test3'), +`col54` BLOB, +`col55` FLOAT, +`col56` REAL, +`col57` REAL, +`col58` TEXT, +`col59` MEDIUMBLOB, +`col60` INT, +`col61` INT, +`col62` DATE, +`col63` TEXT, +`col64` DATE, +`col65` ENUM ('test1','test2','test3'), +`col66` DOUBLE PRECISION, +`col67` TINYTEXT, +`col68` TINYBLOB, +`col69` FLOAT, +`col70` BLOB, +`col71` DATETIME, +`col72` DOUBLE, +`col73` LONGTEXT, +`col74` TIME, +`col75` DATETIME, +`col76` VARCHAR (122), +`col77` MEDIUMTEXT, +`col78` MEDIUMTEXT, +`col79` BOOL, +`col80` LONGTEXT, +`col81` TINYTEXT, +`col82` NUMERIC, +`col83` DOUBLE PRECISION, +`col84` DATE, +`col85` YEAR, +`col86` BLOB, +`col87` TINYTEXT, +`col88` DOUBLE PRECISION, +`col89` MEDIUMINT, +`col90` MEDIUMTEXT, +`col91` NUMERIC, +`col92` DATETIME, +`col93` NUMERIC, +`col94` SET ('test1','test2','test3'), +`col95` TINYTEXT, +`col96` SET ('test1','test2','test3'), +`col97` YEAR, +`col98` MEDIUMINT, +`col99` TEXT, +`col100` TEXT, +`col101` TIME, +`col102` VARCHAR (225), +`col103` TINYTEXT, +`col104` TEXT, +`col105` MEDIUMTEXT, +`col106` TINYINT, +`col107` TEXT, +`col108` LONGBLOB, +`col109` LONGTEXT, +`col110` TINYTEXT, +`col111` CHAR (56), +`col112` YEAR, +`col113` ENUM ('test1','test2','test3'), +`col114` TINYBLOB, +`col115` DATETIME, +`col116` DATE, +`col117` TIME, +`col118` MEDIUMTEXT, +`col119` DOUBLE PRECISION, +`col120` FLOAT, +`col121` TIMESTAMP, +`col122` MEDIUMINT, +`col123` YEAR, +`col124` DATE, +`col125` TEXT, +`col126` FLOAT, +`col127` TINYTEXT, +`col128` BOOL, +`col129` NUMERIC, +`col130` TIMESTAMP, +`col131` INT, +`col132` MEDIUMBLOB, +KEY `idx0` (`col130`), +KEY `idx1` (`col30`,`col55`,`col19`(31)), +KEY `idx2` (`col104`(186)), +KEY `idx3` (`col131`), +KEY `idx4` (`col64`,`col93`,`col2`(11)), +KEY `idx5` (`col34`,`col121`,`col22`), +KEY `idx6` (`col33`,`col55`,`col83`), +KEY `idx7` (`col17`,`col87`(245),`col99`(17)), +KEY `idx8` (`col65`,`col120`), +KEY `idx9` (`col82`), +KEY `idx10` (`col9`(72)), +KEY `idx11` (`col88`), +KEY `idx12` (`col128`,`col9`(200),`col71`,`col66`), +KEY `idx13` (`col77`(126)), +KEY `idx14` (`col105`(26),`col13`,`col117`), +KEY `idx15` (`col4`(246),`col130`,`col115`,`col3`(141)) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +# Creating a table with 176 columns and 13 indexes +DROP TABLE IF EXISTS `table5`; +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table5` +(`col0` MEDIUMTEXT, +`col1` VARCHAR (90), +`col2` TINYTEXT, +`col3` TIME, +`col4` BOOL, +`col5` TINYTEXT, +`col6` BOOL, +`col7` TIMESTAMP, +`col8` TINYBLOB, +`col9` TINYINT, +`col10` YEAR, +`col11` SET ('test1','test2','test3'), +`col12` TEXT, +`col13` CHAR (248), +`col14` BIGINT, +`col15` TEXT, +`col16` TINYINT, +`col17` NUMERIC, +`col18` SET ('test1','test2','test3'), +`col19` LONGBLOB, +`col20` FLOAT, +`col21` INT, +`col22` TEXT, +`col23` BOOL, +`col24` DECIMAL, +`col25` DOUBLE PRECISION, +`col26` FLOAT, +`col27` TINYBLOB, +`col28` NUMERIC, +`col29` MEDIUMBLOB, +`col30` DATE, +`col31` LONGTEXT, +`col32` DATE, +`col33` FLOAT, +`col34` BIGINT, +`col35` TINYTEXT, +`col36` MEDIUMTEXT, +`col37` TIME, +`col38` INT, +`col39` TINYINT, +`col40` SET ('test1','test2','test3'), +`col41` CHAR (130), +`col42` SMALLINT, +`col43` INT, +`col44` MEDIUMTEXT, +`col45` VARCHAR (126), +`col46` INT, +`col47` DOUBLE PRECISION, +`col48` BIGINT, +`col49` MEDIUMTEXT, +`col50` TINYBLOB, +`col51` MEDIUMINT, +`col52` TEXT, +`col53` VARCHAR (208), +`col54` VARCHAR (207), +`col55` NUMERIC, +`col56` DATETIME, +`col57` ENUM ('test1','test2','test3'), +`col58` NUMERIC, +`col59` TINYBLOB, +`col60` VARCHAR (73), +`col61` MEDIUMTEXT, +`col62` TINYBLOB, +`col63` DATETIME, +`col64` NUMERIC, +`col65` MEDIUMINT, +`col66` DATETIME, +`col67` NUMERIC, +`col68` TINYINT, +`col69` VARCHAR (58), +`col70` DECIMAL, +`col71` MEDIUMTEXT, +`col72` DATE, +`col73` TIME, +`col74` DOUBLE PRECISION, +`col75` DECIMAL, +`col76` MEDIUMBLOB, +`col77` REAL, +`col78` YEAR, +`col79` YEAR, +`col80` LONGBLOB, +`col81` BLOB, +`col82` BIGINT, +`col83` ENUM ('test1','test2','test3'), +`col84` NUMERIC, +`col85` SET ('test1','test2','test3'), +`col86` MEDIUMTEXT, +`col87` LONGBLOB, +`col88` TIME, +`col89` ENUM ('test1','test2','test3'), +`col90` DECIMAL, +`col91` FLOAT, +`col92` DATETIME, +`col93` TINYTEXT, +`col94` TIMESTAMP, +`col95` TIMESTAMP, +`col96` TEXT, +`col97` REAL, +`col98` VARCHAR (198), +`col99` TIME, +`col100` TINYINT, +`col101` BIGINT, +`col102` LONGBLOB, +`col103` LONGBLOB, +`col104` MEDIUMINT, +`col105` MEDIUMTEXT, +`col106` TIMESTAMP, +`col107` SMALLINT, +`col108` NUMERIC, +`col109` DECIMAL, +`col110` FLOAT, +`col111` DECIMAL, +`col112` REAL, +`col113` TINYTEXT, +`col114` FLOAT, +`col115` VARCHAR (7), +`col116` LONGTEXT, +`col117` DATE, +`col118` BIGINT, +`col119` TEXT, +`col120` BIGINT, +`col121` BLOB, +`col122` CHAR (110), +`col123` NUMERIC, +`col124` MEDIUMBLOB, +`col125` NUMERIC, +`col126` NUMERIC, +`col127` BOOL, +`col128` TIME, +`col129` TINYBLOB, +`col130` TINYBLOB, +`col131` DATE, +`col132` INT, +`col133` VARCHAR (123), +`col134` CHAR (238), +`col135` VARCHAR (225), +`col136` LONGTEXT, +`col137` LONGBLOB, +`col138` REAL, +`col139` TINYBLOB, +`col140` DATETIME, +`col141` TINYTEXT, +`col142` LONGBLOB, +`col143` BIGINT, +`col144` VARCHAR (236), +`col145` TEXT, +`col146` YEAR, +`col147` DECIMAL, +`col148` TEXT, +`col149` MEDIUMBLOB, +`col150` TINYINT, +`col151` BOOL, +`col152` VARCHAR (72), +`col153` INT, +`col154` VARCHAR (165), +`col155` TINYINT, +`col156` MEDIUMTEXT, +`col157` DOUBLE PRECISION, +`col158` TIME, +`col159` MEDIUMBLOB, +`col160` LONGBLOB, +`col161` DATETIME, +`col162` DOUBLE PRECISION, +`col163` BLOB, +`col164` ENUM ('test1','test2','test3'), +`col165` TIMESTAMP, +`col166` DATE, +`col167` TINYBLOB, +`col168` TINYBLOB, +`col169` LONGBLOB, +`col170` DATETIME, +`col171` BIGINT, +`col172` VARCHAR (30), +`col173` LONGTEXT, +`col174` TIME, +`col175` FLOAT, +KEY `idx0` (`col16`,`col156`(139),`col97`,`col120`), +KEY `idx1` (`col24`,`col0`(108)), +KEY `idx2` (`col117`,`col173`(34),`col132`,`col82`), +KEY `idx3` (`col2`(86)), +KEY `idx4` (`col2`(43)), +KEY `idx5` (`col83`,`col35`(87),`col111`), +KEY `idx6` (`col6`,`col134`,`col92`), +KEY `idx7` (`col56`), +KEY `idx8` (`col30`,`col53`,`col129`(66)), +KEY `idx9` (`col53`,`col113`(211),`col32`,`col15`(75)), +KEY `idx10` (`col34`), +KEY `idx11` (`col126`), +KEY `idx12` (`col24`) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +# Creating a table with 179 columns and 46 indexes +DROP TABLE IF EXISTS `table6`; +-- error ER_TOO_BIG_ROWSIZE +--error ER_TOO_BIG_ROWSIZE +CREATE TABLE IF NOT EXISTS `table6` +(`col0` ENUM ('test1','test2','test3'), +`col1` MEDIUMBLOB, +`col2` MEDIUMBLOB, +`col3` DATETIME, +`col4` DATE, +`col5` YEAR, +`col6` REAL, +`col7` NUMERIC, +`col8` MEDIUMBLOB, +`col9` TEXT, +`col10` TIMESTAMP, +`col11` DOUBLE, +`col12` DOUBLE, +`col13` SMALLINT, +`col14` TIMESTAMP, +`col15` DECIMAL, +`col16` DATE, +`col17` TEXT, +`col18` LONGBLOB, +`col19` BIGINT, +`col20` FLOAT, +`col21` DATETIME, +`col22` TINYINT, +`col23` MEDIUMBLOB, +`col24` SET ('test1','test2','test3'), +`col25` TIME, +`col26` TEXT, +`col27` LONGTEXT, +`col28` BIGINT, +`col29` REAL, +`col30` YEAR, +`col31` MEDIUMBLOB, +`col32` MEDIUMINT, +`col33` FLOAT, +`col34` TEXT, +`col35` DATE, +`col36` TIMESTAMP, +`col37` REAL, +`col38` BLOB, +`col39` BLOB, +`col40` BLOB, +`col41` TINYBLOB, +`col42` INT, +`col43` TINYINT, +`col44` REAL, +`col45` BIGINT, +`col46` TIMESTAMP, +`col47` BLOB, +`col48` ENUM ('test1','test2','test3'), +`col49` BOOL, +`col50` CHAR (109), +`col51` DOUBLE, +`col52` DOUBLE PRECISION, +`col53` ENUM ('test1','test2','test3'), +`col54` FLOAT, +`col55` DOUBLE PRECISION, +`col56` CHAR (166), +`col57` TEXT, +`col58` TIME, +`col59` DECIMAL, +`col60` TEXT, +`col61` ENUM ('test1','test2','test3'), +`col62` LONGTEXT, +`col63` YEAR, +`col64` DOUBLE, +`col65` CHAR (87), +`col66` DATE, +`col67` BOOL, +`col68` MEDIUMBLOB, +`col69` DATETIME, +`col70` DECIMAL, +`col71` TIME, +`col72` REAL, +`col73` LONGTEXT, +`col74` BLOB, +`col75` REAL, +`col76` INT, +`col77` INT, +`col78` FLOAT, +`col79` DOUBLE, +`col80` MEDIUMINT, +`col81` ENUM ('test1','test2','test3'), +`col82` VARCHAR (221), +`col83` BIGINT, +`col84` TINYINT, +`col85` BIGINT, +`col86` FLOAT, +`col87` MEDIUMBLOB, +`col88` CHAR (126), +`col89` MEDIUMBLOB, +`col90` DATETIME, +`col91` TINYINT, +`col92` DOUBLE, +`col93` NUMERIC, +`col94` DATE, +`col95` BLOB, +`col96` DATETIME, +`col97` TIME, +`col98` LONGBLOB, +`col99` INT, +`col100` SET ('test1','test2','test3'), +`col101` TINYBLOB, +`col102` INT, +`col103` MEDIUMBLOB, +`col104` MEDIUMTEXT, +`col105` FLOAT, +`col106` TINYBLOB, +`col107` VARCHAR (26), +`col108` TINYINT, +`col109` TIME, +`col110` TINYBLOB, +`col111` LONGBLOB, +`col112` TINYTEXT, +`col113` FLOAT, +`col114` TINYINT, +`col115` NUMERIC, +`col116` TIME, +`col117` SET ('test1','test2','test3'), +`col118` DATE, +`col119` SMALLINT, +`col120` BLOB, +`col121` TINYTEXT, +`col122` REAL, +`col123` YEAR, +`col124` REAL, +`col125` BOOL, +`col126` BLOB, +`col127` REAL, +`col128` MEDIUMBLOB, +`col129` TIMESTAMP, +`col130` LONGBLOB, +`col131` MEDIUMBLOB, +`col132` YEAR, +`col133` YEAR, +`col134` INT, +`col135` MEDIUMINT, +`col136` MEDIUMINT, +`col137` TINYTEXT, +`col138` TINYBLOB, +`col139` BLOB, +`col140` SET ('test1','test2','test3'), +`col141` ENUM ('test1','test2','test3'), +`col142` ENUM ('test1','test2','test3'), +`col143` TINYTEXT, +`col144` DATETIME, +`col145` TEXT, +`col146` DOUBLE PRECISION, +`col147` DECIMAL, +`col148` MEDIUMTEXT, +`col149` TINYTEXT, +`col150` SET ('test1','test2','test3'), +`col151` MEDIUMTEXT, +`col152` CHAR (126), +`col153` DOUBLE, +`col154` CHAR (243), +`col155` SET ('test1','test2','test3'), +`col156` SET ('test1','test2','test3'), +`col157` DATETIME, +`col158` DOUBLE, +`col159` NUMERIC, +`col160` DECIMAL, +`col161` FLOAT, +`col162` LONGBLOB, +`col163` LONGTEXT, +`col164` INT, +`col165` TIME, +`col166` CHAR (27), +`col167` VARCHAR (63), +`col168` TEXT, +`col169` TINYBLOB, +`col170` TINYBLOB, +`col171` ENUM ('test1','test2','test3'), +`col172` INT, +`col173` TIME, +`col174` DECIMAL, +`col175` DOUBLE, +`col176` MEDIUMBLOB, +`col177` LONGBLOB, +`col178` CHAR (43), +KEY `idx0` (`col131`(219)), +KEY `idx1` (`col67`,`col122`,`col59`,`col87`(33)), +KEY `idx2` (`col83`,`col42`,`col57`(152)), +KEY `idx3` (`col106`(124)), +KEY `idx4` (`col173`,`col80`,`col165`,`col89`(78)), +KEY `idx5` (`col174`,`col145`(108),`col23`(228),`col141`), +KEY `idx6` (`col157`,`col140`), +KEY `idx7` (`col130`(188),`col15`), +KEY `idx8` (`col52`), +KEY `idx9` (`col144`), +KEY `idx10` (`col155`), +KEY `idx11` (`col62`(230),`col1`(109)), +KEY `idx12` (`col151`(24),`col95`(85)), +KEY `idx13` (`col114`), +KEY `idx14` (`col42`,`col98`(56),`col146`), +KEY `idx15` (`col147`,`col39`(254),`col35`), +KEY `idx16` (`col79`), +KEY `idx17` (`col65`), +KEY `idx18` (`col149`(165),`col168`(119),`col32`,`col117`), +KEY `idx19` (`col64`), +KEY `idx20` (`col93`), +KEY `idx21` (`col64`,`col113`,`col104`(182)), +KEY `idx22` (`col52`,`col111`(189)), +KEY `idx23` (`col45`), +KEY `idx24` (`col154`,`col107`,`col110`(159)), +KEY `idx25` (`col149`(1),`col87`(131)), +KEY `idx26` (`col58`,`col115`,`col63`), +KEY `idx27` (`col95`(9),`col0`,`col87`(113)), +KEY `idx28` (`col92`,`col130`(1)), +KEY `idx29` (`col151`(129),`col137`(254),`col13`), +KEY `idx30` (`col49`), +KEY `idx31` (`col28`), +KEY `idx32` (`col83`,`col146`), +KEY `idx33` (`col155`,`col90`,`col17`(245)), +KEY `idx34` (`col174`,`col169`(44),`col107`), +KEY `idx35` (`col113`), +KEY `idx36` (`col52`), +KEY `idx37` (`col16`,`col120`(190)), +KEY `idx38` (`col28`), +KEY `idx39` (`col131`(165)), +KEY `idx40` (`col135`,`col26`(86)), +KEY `idx41` (`col69`,`col94`), +KEY `idx42` (`col105`,`col151`(38),`col97`), +KEY `idx43` (`col88`), +KEY `idx44` (`col176`(100),`col42`,`col73`(189),`col94`), +KEY `idx45` (`col2`(27),`col27`(116)) +)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; + +DROP TABLE IF EXISTS table0; +DROP TABLE IF EXISTS table1; +DROP TABLE IF EXISTS table2; +DROP TABLE IF EXISTS table3; +DROP TABLE IF EXISTS table4; +DROP TABLE IF EXISTS table5; +DROP TABLE IF EXISTS table6; + +EVAL SET GLOBAL innodb_file_format=$file_format; +EVAL SET GLOBAL innodb_file_per_table=$file_per_table; diff --git a/mysql-test/t/innodb_bug36172.test b/mysql-test/t/innodb_bug36172.test new file mode 100644 index 00000000000..67af2b2f7c2 --- /dev/null +++ b/mysql-test/t/innodb_bug36172.test @@ -0,0 +1,33 @@ +# +# Test case for bug 36172 +# + +-- 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 + +let $file_format=`select @@innodb_file_format`; +let $file_format_check=`select @@innodb_file_format_check`; +let $file_per_table=`select @@innodb_file_per_table`; +SET GLOBAL innodb_file_format='Barracuda'; +SET GLOBAL innodb_file_per_table=on; + +DROP TABLE IF EXISTS `table0`; +CREATE TABLE `table0` ( `col0` tinyint(1) DEFAULT NULL, `col1` tinyint(1) DEFAULT NULL, `col2` tinyint(4) DEFAULT NULL, `col3` date DEFAULT NULL, `col4` time DEFAULT NULL, `col5` set('test1','test2','test3') DEFAULT NULL, `col6` time DEFAULT NULL, `col7` text, `col8` decimal(10,0) DEFAULT NULL, `col9` set('test1','test2','test3') DEFAULT NULL, `col10` float DEFAULT NULL, `col11` double DEFAULT NULL, `col12` enum('test1','test2','test3') DEFAULT NULL, `col13` tinyblob, `col14` year(4) DEFAULT NULL, `col15` set('test1','test2','test3') DEFAULT NULL, `col16` decimal(10,0) DEFAULT NULL, `col17` decimal(10,0) DEFAULT NULL, `col18` blob, `col19` datetime DEFAULT NULL, `col20` double DEFAULT NULL, `col21` decimal(10,0) DEFAULT NULL, `col22` datetime DEFAULT NULL, `col23` decimal(10,0) DEFAULT NULL, `col24` decimal(10,0) DEFAULT NULL, `col25` longtext, `col26` tinyblob, `col27` time DEFAULT NULL, `col28` tinyblob, `col29` enum('test1','test2','test3') DEFAULT NULL, `col30` smallint(6) DEFAULT NULL, `col31` double DEFAULT NULL, `col32` float DEFAULT NULL, `col33` char(175) DEFAULT NULL, `col34` tinytext, `col35` tinytext, `col36` tinyblob, `col37` tinyblob, `col38` tinytext, `col39` mediumblob, `col40` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `col41` double DEFAULT NULL, `col42` smallint(6) DEFAULT NULL, `col43` longblob, `col44` varchar(80) DEFAULT NULL, `col45` mediumtext, `col46` decimal(10,0) DEFAULT NULL, `col47` bigint(20) DEFAULT NULL, `col48` date DEFAULT NULL, `col49` tinyblob, `col50` date DEFAULT NULL, `col51` tinyint(1) DEFAULT NULL, `col52` mediumint(9) DEFAULT NULL, `col53` float DEFAULT NULL, `col54` tinyblob, `col55` longtext, `col56` smallint(6) DEFAULT NULL, `col57` enum('test1','test2','test3') DEFAULT NULL, `col58` datetime DEFAULT NULL, `col59` mediumtext, `col60` varchar(232) DEFAULT NULL, `col61` decimal(10,0) DEFAULT NULL, `col62` year(4) DEFAULT NULL, `col63` smallint(6) DEFAULT NULL, `col64` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `col65` blob, `col66` longblob, `col67` int(11) DEFAULT NULL, `col68` longtext, `col69` enum('test1','test2','test3') DEFAULT NULL, `col70` int(11) DEFAULT NULL, `col71` time DEFAULT NULL, `col72` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `col73` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `col74` varchar(170) DEFAULT NULL, `col75` set('test1','test2','test3') DEFAULT NULL, `col76` tinyblob, `col77` bigint(20) DEFAULT NULL, `col78` decimal(10,0) DEFAULT NULL, `col79` datetime DEFAULT NULL, `col80` year(4) DEFAULT NULL, `col81` decimal(10,0) DEFAULT NULL, `col82` longblob, `col83` text, `col84` char(83) DEFAULT NULL, `col85` decimal(10,0) DEFAULT NULL, `col86` float DEFAULT NULL, `col87` int(11) DEFAULT NULL, `col88` varchar(145) DEFAULT NULL, `col89` date DEFAULT NULL, `col90` decimal(10,0) DEFAULT NULL, `col91` decimal(10,0) DEFAULT NULL, `col92` mediumblob, `col93` time DEFAULT NULL, KEY `idx0` (`col69`,`col90`,`col8`), KEY `idx1` (`col60`), KEY `idx2` (`col60`,`col70`,`col74`), KEY `idx3` (`col22`,`col32`,`col72`,`col30`), KEY `idx4` (`col29`), KEY `idx5` (`col19`,`col45`(143)), KEY `idx6` (`col46`,`col48`,`col5`,`col39`(118)), KEY `idx7` (`col48`,`col61`), KEY `idx8` (`col93`), KEY `idx9` (`col31`), KEY `idx10` (`col30`,`col21`), KEY `idx11` (`col67`), KEY `idx12` (`col44`,`col6`,`col8`,`col38`(226)), KEY `idx13` (`col71`,`col41`,`col15`,`col49`(88)), KEY `idx14` (`col78`), KEY `idx15` (`col63`,`col67`,`col64`), KEY `idx16` (`col17`,`col86`), KEY `idx17` (`col77`,`col56`,`col10`,`col55`(24)), KEY `idx18` (`col62`), KEY `idx19` (`col31`,`col57`,`col56`,`col53`), KEY `idx20` (`col46`), KEY `idx21` (`col83`(54)), KEY `idx22` (`col51`,`col7`(120)), KEY `idx23` (`col7`(163),`col31`,`col71`,`col14`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2; +insert ignore into `table0` set `col23` = 7887371.5084383683, `col24` = 4293854615.6906948000, `col25` = 'vitalist', `col26` = 'widespread', `col27` = '3570490', `col28` = 'habitual', `col30` = -5471, `col31` = 4286985783.6771750000, `col32` = 6354540.9826654866, `col33` = 'defoliation', `col34` = 'logarithms', `col35` = 'tegument\'s', `col36` = 'scouting\'s', `col37` = 'intermittency', `col38` = 'elongates', `col39` = 'prophecies', `col40` = '20560103035939', `col41` = 4292809130.0544143000, `col42` = 22057, `col43` = 'Hess\'s', `col44` = 'bandstand', `col45` = 'phenylketonuria', `col46` = 6338767.4018677324, `col47` = 5310247, `col48` = '12592418', `col49` = 'churchman\'s', `col50` = '32226125', `col51` = -58, `col52` = -6207968, `col53` = 1244839.3255104220, `col54` = 'robotized', `col55` = 'monotonous', `col56` = -26909, `col58` = '20720107023550', `col59` = 'suggestiveness\'s', `col60` = 'gemology', `col61` = 4287800670.2229986000, `col62` = '1944', `col63` = -16827, `col64` = '20700107212324', `col65` = 'Nicolais', `col66` = 'apteryx', `col67` = 6935317, `col68` = 'stroganoff', `col70` = 3316430, `col71` = '3277608', `col72` = '19300511045918', `col73` = '20421201003327', `col74` = 'attenuant', `col75` = '15173', `col76` = 'upstroke\'s', `col77` = 8118987, `col78` = 6791516.2735374002, `col79` = '20780701144624', `col80` = '2134', `col81` = 4290682351.3127537000, `col82` = 'unexplainably', `col83` = 'Storm', `col84` = 'Greyso\'s', `col85` = 4289119212.4306774000, `col86` = 7617575.8796655172, `col87` = -6325335, `col88` = 'fondue\'s', `col89` = '40608940', `col90` = 1659421.8093508712, `col91` = 8346904.6584368423, `col92` = 'reloads', `col93` = '5188366'; +CHECK TABLE table0 EXTENDED; +INSERT IGNORE INTO `table0` SET `col19` = '19940127002709', `col20` = 2383927.9055146948, `col21` = 4293243420.5621204000, `col22` = '20511211123705', `col23` = 4289899778.6573381000, `col24` = 4293449279.0540481000, `col25` = 'emphysemic', `col26` = 'dentally', `col27` = '2347406', `col28` = 'eruct', `col30` = 1222, `col31` = 4294372994.9941406000, `col32` = 4291385574.1173744000, `col33` = 'borrowing\'s', `col34` = 'septics', `col35` = 'ratter\'s', `col36` = 'Kaye', `col37` = 'Florentia', `col38` = 'allium', `col39` = 'barkeep', `col40` = '19510407003441', `col41` = 4293559200.4215522000, `col42` = 22482, `col43` = 'decussate', `col44` = 'Brom\'s', `col45` = 'violated', `col46` = 4925506.4635456400, `col47` = 930549, `col48` = '51296066', `col49` = 'voluminously', `col50` = '29306676', `col51` = -88, `col52` = -2153690, `col53` = 4290250202.1464887000, `col54` = 'expropriation', `col55` = 'Aberdeen\'s', `col56` = 20343, `col58` = '19640415171532', `col59` = 'extern', `col60` = 'Ubana', `col61` = 4290487961.8539081000, `col62` = '2147', `col63` = -24271, `col64` = '20750801194548', `col65` = 'Cunaxa\'s', `col66` = 'pasticcio', `col67` = 2795817, `col68` = 'Indore\'s', `col70` = 6864127, `col71` = '1817832', `col72` = '20540506114211', `col73` = '20040101012300', `col74` = 'rationalized', `col75` = '45522', `col76` = 'indene', `col77` = -6964559, `col78` = 4247535.5266884370, `col79` = '20720416124357', `col80` = '2143', `col81` = 4292060102.4466386000, `col82` = 'striving', `col83` = 'boneblack\'s', `col84` = 'redolent', `col85` = 6489697.9009369183, `col86` = 4287473465.9731131000, `col87` = 7726015, `col88` = 'perplexed', `col89` = '17153791', `col90` = 5478587.1108127078, `col91` = 4287091404.7004304000, `col92` = 'Boulez\'s', `col93` = '2931278'; +CHECK TABLE table0 EXTENDED; + +DROP TABLE table0; +EVAL SET GLOBAL innodb_file_format=$file_format; +EVAL SET GLOBAL innodb_file_format_check=$file_format_check; +EVAL SET GLOBAL innodb_file_per_table=$file_per_table; diff --git a/mysql-test/t/innodb_bug40360.test b/mysql-test/t/innodb_bug40360.test new file mode 100644 index 00000000000..e88837aab4f --- /dev/null +++ b/mysql-test/t/innodb_bug40360.test @@ -0,0 +1,16 @@ +# +# Make sure http://bugs.mysql.com/40360 remains fixed. +# + +-- source include/not_embedded.inc +-- source include/have_innodb.inc + +SET TX_ISOLATION='READ-COMMITTED'; + +# This is the default since MySQL 5.1.29 SET BINLOG_FORMAT='STATEMENT'; + +CREATE TABLE bug40360 (a INT) engine=innodb; + +INSERT INTO bug40360 VALUES (1); + +DROP TABLE bug40360; diff --git a/mysql-test/t/innodb_bug41904.test b/mysql-test/t/innodb_bug41904.test new file mode 100644 index 00000000000..365c5229adc --- /dev/null +++ b/mysql-test/t/innodb_bug41904.test @@ -0,0 +1,14 @@ +# +# Make sure http://bugs.mysql.com/41904 remains fixed. +# + +-- source include/not_embedded.inc +-- source include/have_innodb.inc + +CREATE TABLE bug41904 (id INT PRIMARY KEY, uniquecol CHAR(15)) ENGINE=InnoDB; + +INSERT INTO bug41904 VALUES (1,NULL), (2,NULL); + +CREATE UNIQUE INDEX ui ON bug41904 (uniquecol); + +DROP TABLE bug41904; diff --git a/mysql-test/t/innodb_bug44571.test b/mysql-test/t/innodb_bug44571.test new file mode 100644 index 00000000000..f5d79e3070a --- /dev/null +++ b/mysql-test/t/innodb_bug44571.test @@ -0,0 +1,13 @@ +# +# Bug#44571 InnoDB Plugin crashes on ADD INDEX +# http://bugs.mysql.com/44571 +# +-- source include/have_innodb.inc + +CREATE TABLE bug44571 (foo INT) ENGINE=InnoDB; +ALTER TABLE bug44571 CHANGE foo bar INT; +-- error ER_KEY_COLUMN_DOES_NOT_EXITS +ALTER TABLE bug44571 ADD INDEX bug44571b (foo); +ALTER TABLE bug44571 ADD INDEX bug44571b (bar); +CREATE INDEX bug44571c ON bug44571 (bar); +DROP TABLE bug44571; diff --git a/mysql-test/t/innodb_bug46676.test b/mysql-test/t/innodb_bug46676.test new file mode 100644 index 00000000000..440666c4226 --- /dev/null +++ b/mysql-test/t/innodb_bug46676.test @@ -0,0 +1,16 @@ +# This is the test for bug 46676: mysqld got exception 0xc0000005 +# It is reproducible with InnoDB plugin 1.0.4 + MySQL 5.1.37. +# But no longer reproducible after MySQL 5.1.38 (with plugin 1.0.5). + +--source include/have_innodb.inc + +SET foreign_key_checks=0; +CREATE TABLE t1 (id int, foreign key (id) references t2(id)) ENGINE=INNODB; +CREATE TABLE t2 (id int, foreign key (id) references t1(id)) ENGINE=INNODB; +SET foreign_key_checks=1; + +# Server crashes +SELECT COUNT(*) FROM information_schema.key_column_usage WHERE REFERENCED_TABLE_NAME in ('t1', 't2'); + +SET foreign_key_checks=0; +DROP TABLE t1, t2; diff --git a/mysql-test/t/innodb_bug47167.test b/mysql-test/t/innodb_bug47167.test new file mode 100644 index 00000000000..88e927c01bd --- /dev/null +++ b/mysql-test/t/innodb_bug47167.test @@ -0,0 +1,45 @@ +# This is the unit test for bug *47167. +# It tests setting the global variable +# "innodb_file_format_check" with a +# user-Defined Variable. + +--source include/have_innodb.inc + +# Save the value (Antelope) in 'innodb_file_format_check' to +# 'old_innodb_file_format_check' +set @old_innodb_file_format_check=@@innodb_file_format_check; + +# @old_innodb_file_format_check shall have the value of 'Antelope' +select @old_innodb_file_format_check; + +# Reset the value in 'innodb_file_format_check' to 'Barracuda' +set global innodb_file_format_check = Barracuda; + +select @@innodb_file_format_check; + +# Set 'innodb_file_format_check' to its default value, which +# is the latest file format supported in the current release. +set global innodb_file_format_check = DEFAULT; + +select @@innodb_file_format_check; + +# Put the saved value back to 'innodb_file_format_check' +set global innodb_file_format_check = @old_innodb_file_format_check; + +# Check whether 'innodb_file_format_check' get its original value. +select @@innodb_file_format_check; + +# Following are negative tests, all should fail. +--disable_warnings +--error ER_WRONG_ARGUMENTS +set global innodb_file_format_check = cheetah; + +--error ER_WRONG_ARGUMENTS +set global innodb_file_format_check = Bear; + +--error ER_WRONG_ARGUMENTS +set global innodb_file_format_check = on; + +--error ER_WRONG_ARGUMENTS +set global innodb_file_format_check = off; +--enable_warnings diff --git a/mysql-test/t/innodb_file_format.test b/mysql-test/t/innodb_file_format.test new file mode 100644 index 00000000000..6de026ad97f --- /dev/null +++ b/mysql-test/t/innodb_file_format.test @@ -0,0 +1,31 @@ +-- source include/have_innodb.inc + +call mtr.add_suppression("InnoDB: invalid innodb_file_format_check value"); + +select @@innodb_file_format; +select @@innodb_file_format_check; +set global innodb_file_format=antelope; +set global innodb_file_format=barracuda; +--error ER_WRONG_ARGUMENTS +set global innodb_file_format=cheetah; +select @@innodb_file_format; +set global innodb_file_format=default; +select @@innodb_file_format; +--error ER_WRONG_ARGUMENTS +set global innodb_file_format=on; +--error ER_WRONG_ARGUMENTS +set global innodb_file_format=off; +select @@innodb_file_format; +set global innodb_file_format_check=antelope; +set global innodb_file_format_check=barracuda; +--error ER_WRONG_ARGUMENTS +set global innodb_file_format_check=cheetah; +select @@innodb_file_format_check; +set global innodb_file_format_check=default; +select @@innodb_file_format_check; +--error ER_WRONG_ARGUMENTS +set global innodb_file_format=on; +--error ER_WRONG_ARGUMENTS +set global innodb_file_format=off; +select @@innodb_file_format_check; +set global innodb_file_format_check=antelope; diff --git a/mysql-test/t/innodb_ignore_builtin.test b/mysql-test/t/innodb_ignore_builtin.test index 6f987bcf891..66f7e47b703 100644 --- a/mysql-test/t/innodb_ignore_builtin.test +++ b/mysql-test/t/innodb_ignore_builtin.test @@ -3,6 +3,4 @@ # 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"; +where PLUGIN_NAME = "InnoDb" and PLUGIN_LIBRARY IS NULL; diff --git a/mysql-test/t/innodb_information_schema.test b/mysql-test/t/innodb_information_schema.test new file mode 100644 index 00000000000..fc1d38d8d14 --- /dev/null +++ b/mysql-test/t/innodb_information_schema.test @@ -0,0 +1,149 @@ +# +# Test that user data is correctly "visualized" in +# INFORMATION_SCHEMA.innodb_locks.lock_data +# + +-- source include/have_innodb.inc + +-- disable_query_log +-- disable_result_log + +SET storage_engine=InnoDB; + +-- disable_warnings +DROP TABLE IF EXISTS t_min, t_max; +-- enable_warnings + +let $table_def = +( + c01 TINYINT, + c02 TINYINT UNSIGNED, + c03 SMALLINT, + c04 SMALLINT UNSIGNED, + c05 MEDIUMINT, + c06 MEDIUMINT UNSIGNED, + c07 INT, + c08 INT UNSIGNED, + c09 BIGINT, + c10 BIGINT UNSIGNED, + PRIMARY KEY(c01, c02, c03, c04, c05, c06, c07, c08, c09, c10) +); + +-- eval CREATE TABLE t_min $table_def; +INSERT INTO t_min VALUES +(-128, 0, + -32768, 0, + -8388608, 0, + -2147483648, 0, + -9223372036854775808, 0); + +-- eval CREATE TABLE t_max $table_def; +INSERT INTO t_max VALUES +(127, 255, + 32767, 65535, + 8388607, 16777215, + 2147483647, 4294967295, + 9223372036854775807, 18446744073709551615); + +CREATE TABLE ```t'\"_str` ( + c1 VARCHAR(32), + c2 VARCHAR(32), + c3 VARCHAR(32), + c4 VARCHAR(32), + c5 VARCHAR(32), + c6 VARCHAR(32), + c7 VARCHAR(32), + PRIMARY KEY(c1, c2, c3, c4, c5, c6, c7) +); +INSERT INTO ```t'\"_str` VALUES +('1', 'abc', '''abc', 'abc''', 'a''bc', 'a''bc''', '''abc'''''); +INSERT INTO ```t'\"_str` VALUES +('2', 'abc', '"abc', 'abc"', 'a"bc', 'a"bc"', '"abc""'); +INSERT INTO ```t'\"_str` VALUES +('3', 'abc', '\\abc', 'abc\\', 'a\\bc', 'a\\bc\\', '\\abc\\\\'); +INSERT INTO ```t'\"_str` VALUES +('4', 'abc', 0x00616263, 0x61626300, 0x61006263, 0x6100626300, 0x610062630000); + +-- connect (con_lock,localhost,root,,) +-- connect (con_min_trylock,localhost,root,,) +-- connect (con_max_trylock,localhost,root,,) +-- connect (con_str_insert_supremum,localhost,root,,) +-- connect (con_str_lock_row1,localhost,root,,) +-- connect (con_str_lock_row2,localhost,root,,) +-- connect (con_str_lock_row3,localhost,root,,) +-- connect (con_str_lock_row4,localhost,root,,) +-- connect (con_verify_innodb_locks,localhost,root,,) + +-- connection con_lock +SET autocommit=0; +SELECT * FROM t_min FOR UPDATE; +SELECT * FROM t_max FOR UPDATE; +SELECT * FROM ```t'\"_str` FOR UPDATE; + +-- connection con_min_trylock +-- send +SELECT * FROM t_min FOR UPDATE; + +-- connection con_max_trylock +-- send +SELECT * FROM t_max FOR UPDATE; + +-- connection con_str_insert_supremum +-- send +INSERT INTO ```t'\"_str` VALUES +('z', 'z', 'z', 'z', 'z', 'z', 'z'); + +-- connection con_str_lock_row1 +-- send +SELECT * FROM ```t'\"_str` WHERE c1 = '1' FOR UPDATE; + +-- connection con_str_lock_row2 +-- send +SELECT * FROM ```t'\"_str` WHERE c1 = '2' FOR UPDATE; + +-- connection con_str_lock_row3 +-- send +SELECT * FROM ```t'\"_str` WHERE c1 = '3' FOR UPDATE; + +-- connection con_str_lock_row4 +-- send +SELECT * FROM ```t'\"_str` WHERE c1 = '4' FOR UPDATE; + +-- enable_result_log +-- connection con_verify_innodb_locks +# Wait for the above queries to execute before continuing. +# Without this, it sometimes happens that the SELECT from innodb_locks +# executes before some of them, resulting in less than expected number +# of rows being selected from innodb_locks. If there is a bug and there +# are no 14 rows in innodb_locks then this test will fail with timeout. +let $count = 14; +let $table = INFORMATION_SCHEMA.INNODB_LOCKS; +-- source include/wait_until_rows_count.inc +# the above enables the query log, re-disable it +-- disable_query_log +SELECT lock_mode, lock_type, lock_table, lock_index, lock_rec, lock_data +FROM INFORMATION_SCHEMA.INNODB_LOCKS ORDER BY lock_data; + +SELECT lock_table,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS +GROUP BY lock_table; + +set @save_sql_mode = @@sql_mode; +SET SQL_MODE='ANSI_QUOTES'; +SELECT lock_table,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS +GROUP BY lock_table; +SET @@sql_mode=@save_sql_mode; +-- disable_result_log + +-- connection default + +-- disconnect con_lock +-- disconnect con_min_trylock +-- disconnect con_max_trylock +-- disconnect con_str_insert_supremum +-- disconnect con_str_lock_row1 +-- disconnect con_str_lock_row2 +-- disconnect con_str_lock_row3 +-- disconnect con_str_lock_row4 +-- disconnect con_verify_innodb_locks + +DROP TABLE t_min, t_max, ```t'\"_str`; 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_utf8.test b/mysql-test/t/innodb_utf8.test new file mode 100644 index 00000000000..e52019588b0 --- /dev/null +++ b/mysql-test/t/innodb_utf8.test @@ -0,0 +1,24 @@ +# +# Tests for innodb that requires not default character sets +# + +--source include/have_innodb.inc +let collation=utf8_unicode_ci; +--source include/have_collation.inc + +# Setup +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Bug #26835: table corruption after delete+insert +# + +CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4); +DELETE FROM t1; +INSERT INTO t1 VALUES ('DDD'); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index 152f43a671d..045b5807391 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -151,7 +151,8 @@ drop table t1; create table t1(id1 int not null auto_increment primary key, t char(12)); create table t2(id2 int not null, t char(12)); create table t3(id3 int not null, t char(12), index(id3)); -disable_query_log; +--disable_query_log +begin; let $1 = 100; while ($1) { @@ -170,7 +171,9 @@ while ($1) } dec $1; } -enable_query_log; +commit; +--enable_query_log + select count(*) from t2; insert into t2 select t1.* from t1, t2 t, t3 where t1.id1 = t.id2 and t.id2 = t3.id3; select count(*) from t2; @@ -235,8 +238,10 @@ insert into t1 values (1,11), (2,22); insert into t2 values (1,12), (2,24); --error 1393 insert into v1 (f1) values (3) on duplicate key update f3= f3 + 10; +--error 1393 insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10; select * from t1; +--error 1393 insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10; select * from t1; drop view v1; diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index d7fe816bec7..d740445fb4d 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -392,8 +392,13 @@ insert into t1 values(1),(2),(3); create table t2 (key(f1)) engine=myisam select sql_buffer_result f1 from t1; check table t2 extended; drop table t1,t2; ---echo ################################################################## +--echo End of 5.0 tests + +# The following is not relevant for MariaDB as we are using Maria for +# tmp tables. + +--echo ################################################################## --echo # --echo # Bug #46075: Assertion failed: 0, file .\protocol.cc, line 416 --echo # @@ -407,12 +412,12 @@ SET GLOBAL myisam_data_pointer_size = 2; INSERT INTO t1 VALUES (1), (2), (3), (4), (5); -call mtr.add_suppression("mysqld.*: The table '.*#sql.*' is full"); ---error ER_RECORD_FILE_FULL,ER_RECORD_FILE_FULL +call mtr.add_suppression("mysqld: The table '.*#sql.*' is full"); +--error 0,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 SET GLOBAL myisam_data_pointer_size = @old_myisam_data_pointer_size; DROP TABLE t1; ---echo End of 5.0 tests +--echo End of 5.1 tests diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 05d630edfb2..0a573e7cd4f 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -2,6 +2,7 @@ # Initialization --disable_warnings drop table if exists t1,t2,t3; +drop view if exists v1,v2; --enable_warnings # @@ -921,4 +922,21 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1; +--echo # +--echo # Bug LP:798597: Incorrect "Duplicate entry" error with views and +--echo # GROUP BY +--echo # + +CREATE TABLE t1 ( f1 int NOT NULL , f2 int NOT NULL ) ; +INSERT INTO t1 VALUES (214,0),(6,6); +CREATE TABLE t2 ( f2 int) ; +INSERT INTO t2 VALUES (88),(88); +CREATE ALGORITHM=MERGE VIEW v1 AS SELECT t1.f1, t2.f2 FROM (t2 LEFT JOIN t1 ON (t2.f2 <> t1.f1)) WHERE (t1.f2 <= 0) ; +CREATE ALGORITHM=MERGE VIEW v2 AS SELECT t1.f1, t2.f2 FROM (t2 LEFT JOIN t1 ON (t2.f2 <> t1.f1)) WHERE (t1.f2 <= 0 or t1.f2 is null) ; +SELECT f1 , MIN(f2) FROM v1 GROUP BY f1; +SELECT f1 , MIN(f2) FROM v2 GROUP BY f1; +drop table t1,t2; +drop view v1,v2; + + --echo End of 5.1 tests diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test index 5b07d8966f1..6ae7fb6dfee 100644 --- a/mysql-test/t/join_nested.test +++ b/mysql-test/t/join_nested.test @@ -1196,5 +1196,45 @@ SELECT COUNT(*) DROP TABLE t1,t2,t3,t4,t5; +# +# BUG#49322: Nested left joins + not-exist optimization +# + +CREATE TABLE t1 ( + pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, + a int DEFAULT NULL, + KEY idx(a) +); +CREATE TABLE t2 ( + pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, + a int DEFAULT NULL, + KEY idx(a) +); +CREATE TABLE t3 ( + pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, + a int DEFAULT NULL, + KEY idx(a) +); + +INSERT INTO t1 VALUES + (1,2), (2,7), (3,5), (4,7), (5,5), (6,NULL), (7,NULL), (8,9); +INSERT INTO t2 VALUES + (1,NULL), (4,2), (5,2), (3,4), (2,8); +INSERT INTO t3 VALUES + (1,9), (2,2), (3,5), (4,2), (5,7), (6,0), (7,5); + +SELECT t1.pk, t1.a, t2.pk, t2.a,t3.pk, t3.a + FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t3.a=t2.a) ON t2.a=t1.a; + +SELECT t1.pk, t1.a, t2.pk, t2.a,t3.pk, t3.a + FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t3.a=t2.a) ON t2.a=t1.a + WHERE t2.pk IS NULL; + +SELECT t1.pk, t1.a, t2.pk, t2.a,t3.pk, t3.a + FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t3.a=t2.a) ON t2.a=t1.a + WHERE t3.pk IS NULL; + +DROP TABLE t1, t2, t3; + --echo End of 5.0 tests diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 3251ff292b6..c8fa2a35538 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1,3 +1,5 @@ +--source include/long_test.inc + # # test of left outer join # @@ -982,6 +984,97 @@ EXPLAIN EXTENDED SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 DROP TABLE t1; --echo # +--echo # Bug#49600: outer join of two single-row tables with joining attributes +--echo # evaluated to nulls + +create table t1 (a int, b int); +create table t2 (a int, b int); +insert into t1 values (1, NULL); +insert into t2 values (2, NULL); + +select * from t1 left join t2 on t1.b=t2.b; + +select * from t1 left join t2 on t1.b=t2.b where 1=1; + +drop table t1,t2; + +--echo # +--echo # Bug#53161: outer join in the derived table is erroneously converted +--echo # into an inner join for a query with a group by clause +--echo # + +create table t1 (pk int not null primary key, a int not null); +create table t2 like t1; +create table t3 like t1; +create table t4 (pk int not null primary key); +insert into t1 values (1000, 1), (1001, 1); +insert into t2 values (2000, 2), (2001, 2); +insert into t3 values (3000, 3), (3001, 2); +insert into t4 values (4000), (4001); + +explain extended +select t2.pk, + (select t3.pk+if(isnull(t4.pk),0,t4.pk) + from t3 left join t4 on t4.pk=t3.pk + where t3.pk=t2.pk+1000 limit 1 ) as t + from t1,t2 + where t2.pk=t1.pk+1000 and t1.pk>1000 + group by t2.pk; + +select t2.pk, + (select t3.pk+if(isnull(t4.pk),0,t4.pk) + from t3 left join t4 on t4.pk=t3.pk + where t3.pk=t2.pk+1000 limit 1 ) as t + from t1,t2 + where t2.pk=t1.pk+1000 and t1.pk>1000 + group by t2.pk; + +drop table t1,t2,t3,t4; + +--echo # +--echo # Bug#57024: Poor performance when conjunctive condition over the outer +--echo # table is used in the on condition of an outer join +--echo # + +create table t1 (a int); +insert into t1 values (NULL), (NULL), (NULL), (NULL); +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; +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 values (4), (2), (1), (3); + +create table t2 like t1; +insert into t2 select if(t1.a is null, 10, t1.a) from t1; + +create table t3 (a int, b int, index idx(a)); +insert into t3 values (1, 100), (3, 301), (4, 402), (1, 102), (1, 101); + +analyze table t1,t2,t3; + +flush status; +select sum(t3.b) from t1 left join t3 on t3.a=t1.a and t1.a is not null; +show status like "handler_read%"; +flush status; +select sum(t3.b) from t2 left join t3 on t3.a=t2.a and t2.a <> 10; +show status like "handler_read%"; + +drop table t1,t2,t3; + --echo # Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field --echo # diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index 02b033df2e5..b199a1224c3 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -67,12 +67,14 @@ connection conn1; -- disable_result_log -- disable_query_log +begin; let $1 = 4096; while ($1) { eval insert into t1 values ($1); dec $1; } +commit; -- enable_query_log -- enable_result_log @@ -265,6 +267,8 @@ connection con1; let $ID= `select connection_id()`; let $tab_count= 40; +--disable_query_log +begin; let $i= $tab_count; while ($i) { @@ -272,6 +276,8 @@ while ($i) eval INSERT INTO t$i VALUES (1),(2),(3),(4),(5),(6),(7); dec $i ; } +commit; +--enable_query_log set session optimizer_search_depth=0; let $i=$tab_count; diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test index 5847b90367a..4dbe13096d4 100644 --- a/mysql-test/t/limit.test +++ b/mysql-test/t/limit.test @@ -102,4 +102,16 @@ execute s using @a, @a; select 1 as a limit 4294967296,10; +# +# Test for LIMIT X OFFSET Y +# + +CREATE TABLE t1 (a int PRIMARY KEY auto_increment); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(); +SELECT a FROM t1 ORDER BY a LIMIT 10 OFFSET 1; +SELECT a FROM t1 ORDER BY a LIMIT 10 OFFSET 10; +SELECT a FROM t1 ORDER BY a LIMIT 2 OFFSET 14; +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 3d0fdea05ed..ca1bb168728 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -2,6 +2,8 @@ # Some simple test of load data # +-- source include/have_ucs2.inc + --disable_warnings drop table if exists t1, t2; --enable_warnings diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index 4df1a0f3478..742a83f7bad 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -484,22 +484,6 @@ 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; diff --git a/mysql-test/t/log_slow.test b/mysql-test/t/log_slow.test new file mode 100644 index 00000000000..303d5bf8deb --- /dev/null +++ b/mysql-test/t/log_slow.test @@ -0,0 +1,42 @@ +# +# Testing of slow log query options +# + +select @@log_slow_filter; +select @@log_slow_rate_limit; +select @@log_slow_verbosity; +show variables like "log_slow%"; + +# Some simple test to set log_slow_filter +set @@log_slow_filter= "filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk,admin"; +select @@log_slow_filter; +set @@log_slow_filter="admin,admin"; +select @@log_slow_filter; +set @@log_slow_filter=7; +select @@log_slow_filter; + +# Test of wrong values +--error 1231 +set @@log_slow_filter= "filesort,impossible,impossible2,admin"; +--error 1231 +set @@log_slow_filter= "filesort, admin"; +--error 1231 +set @@log_slow_filter= 1<<31; +select @@log_slow_filter; + +# Some simple test to set log_slow_verbosity +set @@log_slow_verbosity= "query_plan,innodb"; +select @@log_slow_verbosity; +set @@log_slow_verbosity=1; +select @@log_slow_verbosity; + +# +# Check which fields are in slow_log table +# + +show fields from mysql.slow_log; + +# Reset used variables + +set @@log_slow_filter=default; +set @@log_slow_verbosity=default; diff --git a/mysql-test/t/log_tables-big-master.opt b/mysql-test/t/log_tables-big-master.opt index 35ff7911705..b9bc885d0e4 100644 --- a/mysql-test/t/log_tables-big-master.opt +++ b/mysql-test/t/log_tables-big-master.opt @@ -1 +1 @@ ---log-slow-queries +--log-output=table,file --slow-query-log --general-log --general-log-file="" --slow-query-log-file="" diff --git a/mysql-test/t/log_tables-master.opt b/mysql-test/t/log_tables-master.opt index 3ece9710a45..4c25518cefe 100644 --- a/mysql-test/t/log_tables-master.opt +++ b/mysql-test/t/log_tables-master.opt @@ -1 +1 @@ ---log-output=table,file --log-slow-queries +--log-output=table,file --slow-query-log --general-log diff --git a/mysql-test/t/log_tables_upgrade.test b/mysql-test/t/log_tables_upgrade.test index 5d1b2b5aed6..a638a27c9d1 100644 --- a/mysql-test/t/log_tables_upgrade.test +++ b/mysql-test/t/log_tables_upgrade.test @@ -25,7 +25,7 @@ FLUSH TABLES; REPAIR TABLE test.bug49823; RENAME TABLE general_log TO renamed_general_log; RENAME TABLE test.bug49823 TO general_log; ---exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +--exec $MYSQL_UPGRADE --force 2>&1 DROP TABLE general_log; RENAME TABLE renamed_general_log TO general_log; SET GLOBAL general_log = @saved_general_log; diff --git a/mysql-test/t/merge-big.test b/mysql-test/t/merge-big.test index b687973c9d1..d39c2973688 100644 --- a/mysql-test/t/merge-big.test +++ b/mysql-test/t/merge-big.test @@ -43,7 +43,8 @@ LOCK TABLE t1 WRITE; --echo # connection con1 connect (con1,localhost,root,,); let $con1_id= `SELECT CONNECTION_ID()`; - SET SESSION debug="+d,sleep_open_and_lock_after_open"; + SET @orig_debug=@@debug; + SET GLOBAL debug="+d,sleep_open_and_lock_after_open"; send INSERT INTO t1 VALUES (1); --echo # connection default connection default; @@ -74,7 +75,7 @@ UNLOCK TABLES; --echo # connection con1 connection con1; reap; - SET SESSION debug="-d,sleep_open_and_lock_after_open"; + SET GLOBAL debug=@orig_debug; disconnect con1; --echo # connection default connection default; diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index a6affbb0540..90386a97fc6 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -2,6 +2,11 @@ # Test of MERGE TABLES # +# MERGE tables require MyISAM tables +let $default=`select @@global.storage_engine`; +set global storage_engine=myisam; +set session storage_engine=myisam; + --disable_warnings drop table if exists t1,t2,t3,t4,t5,t6; drop database if exists mysqltest; @@ -630,6 +635,7 @@ DROP TABLE t1, t2, m1, m2; --echo End of 5.0 tests + # # Bug #8306: TRUNCATE leads to index corruption # @@ -766,7 +772,7 @@ DROP TABLE t1, t2; # *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 +# Bug#26867 - LOCK TABLES REPAIR + merge table result in memory/cpu hogging # # CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; @@ -1113,35 +1119,38 @@ UNLOCK TABLES; --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; +CREATE TRIGGER t4_ai1 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; +DROP TRIGGER t4_ai1; +CHECK TABLE t3; --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; +CREATE TRIGGER t4_ai2 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; +DROP TRIGGER t4_ai2; UNLOCK TABLES; +CHECK TABLE t3; --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; +CREATE TRIGGER t3_ai3 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; +DROP TRIGGER t3_ai3; +CHECK TABLE t3; --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; +CREATE TRIGGER t3_ai4 AFTER INSERT ON t3 FOR EACH ROW SET @a=1; SET @a=0; INSERT INTO t4 VALUES (4); SELECT @a; @@ -1149,29 +1158,47 @@ INSERT INTO t3 VALUES (33); SELECT @a; SELECT * FROM t4 ORDER BY c1; DELETE FROM t4 WHERE c1 = 33; -DROP TRIGGER t3_ai; +DROP TRIGGER t3_ai4; +CHECK TABLE t3; --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); +CREATE TRIGGER t3_ai5 AFTER INSERT ON t3 FOR EACH ROW INSERT INTO t2 VALUES(22); +SELECT COUNT(*) FROM t2; 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; +DROP TRIGGER t3_ai5; +UNLOCK TABLES; +CHECK TABLE t2,t3; --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); +CREATE TRIGGER t3_ai6 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; +DROP TRIGGER t3_ai6; +UNLOCK TABLES; +check table t2,t3,t4; DELETE FROM t4 WHERE c1 = 22; DELETE FROM t4 WHERE c1 = 33; +--echo # Trigger with table use on child under different LOCK TABLES +DELETE FROM t4 WHERE c1 = 4; +LOCK TABLES t4 WRITE,t3 WRITE, t2 WRITE, t1 WRITE; +CREATE TRIGGER t3_ai7 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_ai7; UNLOCK TABLES; +check table t2,t3,t4; +DELETE FROM t4 WHERE c1 = 22; +DELETE FROM t4 WHERE c1 = 33; # --echo # --echo # Repair @@ -1270,6 +1297,8 @@ DROP TABLE t1, t2, t3; CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER); SET @rnd_max= 2147483647; let $1 = 10; +--disable_query_log +begin; while ($1) { SET @rnd= RAND(); @@ -1279,6 +1308,8 @@ while ($1) INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev); dec $1; } +commit; +--enable_query_log 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; @@ -1829,3 +1860,9 @@ UNLOCK TABLES; DROP TABLE t1, t2, t3, m1; --echo End of 5.1 tests + +--disable_result_log +--disable_query_log +eval set global storage_engine=$default; +--enable_result_log +--enable_query_log diff --git a/mysql-test/t/merge_debug.test b/mysql-test/t/merge_debug.test new file mode 100644 index 00000000000..2e30cf88b5d --- /dev/null +++ b/mysql-test/t/merge_debug.test @@ -0,0 +1,42 @@ +# +# Test failures with MERGE +# + +--source include/have_debug.inc + +let $default=`select @@global.storage_engine`; +set global storage_engine=myisam; +set session storage_engine=myisam; + +--disable_warnings +drop table if exists crashed,t2,t3,t4; +--enable_warnings + +SET @orig_debug=@@debug; + +# +# Check that MariaDB handles reopen that fails without crashing +# +CREATE TABLE crashed (c1 INT); +CREATE TABLE t2 (c1 INT); +CREATE TABLE t3 (c1 INT); +CREATE TABLE t4 (c1 INT) ENGINE=MRG_MYISAM UNION=(crashed,t2,t3) INSERT_METHOD=LAST; +INSERT INTO crashed VALUES (10); +INSERT INTO t2 VALUES (20); +INSERT INTO t3 VALUES (30); + +LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, crashed WRITE; +SET GLOBAL debug="+d,*,myisam_pretend_crashed_table_on_open"; +--disable_warnings +CREATE TRIGGER t1_ai AFTER INSERT ON crashed FOR EACH ROW INSERT INTO t2 VALUES(29); +--enable_warnings +SET GLOBAL debug=@orig_debug; +--error ER_TABLE_NOT_LOCKED +INSERT INTO t4 VALUES (39); +--error ER_TABLE_NOT_LOCKED +INSERT INTO crashed VALUES (11); +INSERT INTO t2 VALUES (21); +INSERT INTO t3 VALUES (31); +UNLOCK TABLES; +DROP TRIGGER t1_ai; +DROP TABLE t4,crashed,t2,t3; diff --git a/mysql-test/t/multi_statement-master.opt b/mysql-test/t/multi_statement-master.opt index b30df037531..c735cf4c21b 100644 --- a/mysql-test/t/multi_statement-master.opt +++ b/mysql-test/t/multi_statement-master.opt @@ -1,2 +1,3 @@ ---log-slow-queries=slow.log +--slow-query-log +--slow-query-log-file=slow.log --log-queries-not-using-indexes diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 5298701d790..09efdb74995 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -20,7 +20,8 @@ delete from mysql.user where user=_binary'mysqltest_1'; create table t1(id1 int not null auto_increment primary key, t char(12)); create table t2(id2 int not null, t char(12)); create table t3(id3 int not null, t char(12), index(id3)); -disable_query_log; +--disable_query_log +begin; let $1 = 100; while ($1) { @@ -39,7 +40,8 @@ while ($1) } dec $1; } -enable_query_log; +commit; +--enable_query_log select count(*) from t1 where id1 > 95; select count(*) from t2 where id2 > 95; @@ -75,7 +77,8 @@ drop table t1,t2,t3; create table t1(id1 int not null primary key, t varchar(100)) pack_keys = 1; create table t2(id2 int not null, t varchar(100), index(id2)) pack_keys = 1; -disable_query_log; +--disable_query_log +begin; let $1 = 1000; while ($1) { @@ -88,7 +91,8 @@ while ($1) } dec $1; } -enable_query_log; +commit; +--enable_query_log delete t1 from t1,t2 where t1.id1 = t2.id2 and t1.id1 > 500; drop table t1,t2; diff --git a/mysql-test/t/multi_update2.test b/mysql-test/t/multi_update2.test index a04518f4964..a0f17fabec4 100644 --- a/mysql-test/t/multi_update2.test +++ b/mysql-test/t/multi_update2.test @@ -1,3 +1,5 @@ +--source include/long_test.inc + # # Test of update statement that uses many tables. # @@ -48,13 +50,14 @@ CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL) ; INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4); let $1=19; set @d=4; +begin; while ($1) { eval INSERT INTO t1 SELECT a+@d,b+@d FROM t1; eval SET @d=@d*2; dec $1; } - +commit; --enable_query_log ALTER TABLE t1 ADD INDEX i1(a); DELETE FROM t1 WHERE a > 2000000; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 4abd7dd2b1b..d498d4e95ad 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -4,7 +4,7 @@ # Initialise --disable_warnings -drop table if exists t1,t2; +drop table if exists t1,t2,t3; --enable_warnings SET SQL_WARNINGS=1; @@ -33,7 +33,8 @@ drop table t1; create table t1 (a tinyint not null auto_increment, b blob not null, primary key (a)); let $1=100; -disable_query_log; +--disable_query_log +begin; --disable_warnings SET SQL_WARNINGS=0; while ($1) @@ -41,9 +42,10 @@ while ($1) eval insert into t1 (b) values(repeat(char(65+$1),65550-$1)); dec $1; } +commit; SET SQL_WARNINGS=1; --enable_warnings -enable_query_log; +--enable_query_log check table t1; repair table t1; delete from t1 where (a & 1); @@ -380,14 +382,16 @@ check table t1; # check updating with keys # -disable_query_log; +--disable_query_log +begin; let $1 = 100; while ($1) { eval insert into t1 (b) values (repeat(char(($1 & 32)+65), $1)); dec $1; } -enable_query_log; +commit; +--enable_query_log update t1 set b=repeat(left(b,1),255) where a between 1 and 5; update t1 set b=repeat(left(b,1),10) where a between 32 and 43; update t1 set b=repeat(left(b,1),2) where a between 64 and 66; @@ -551,11 +555,13 @@ create table t2 (a int); let $i=1000; set @@rand_seed1=31415926,@@rand_seed2=2718281828; --disable_query_log +begin; while ($i) { dec $i; insert t2 values (rand()*100000); } +commit; --enable_query_log insert t1 select * from t2; show keys from t1; @@ -1385,11 +1391,13 @@ CREATE TABLE t1 ( --disable_query_log let $count= 100; --echo # Insert $count rows. Query log disabled. +begin; while ($count) { INSERT INTO t1 VALUES ('a', 'b'); dec $count; } +commit; --enable_query_log # # Change most of the rows into long character values with > 127 characters. @@ -1469,11 +1477,13 @@ CREATE TABLE t1 ( --disable_query_log let $count= 100; --echo # Insert $count rows. Query log disabled. +begin; while ($count) { INSERT INTO t1 VALUES ('a', 'b'); dec $count; } +commit; --enable_query_log # # Change most of the rows into long character values with > 42 characters. @@ -1504,6 +1514,42 @@ let $MYSQLD_DATADIR= `select @@datadir`; DROP TABLE t1; # +# Test warnings with transactional=1 with MyISAM +# MariaDB: Note that the table will still have 'TRANSACTIONAL=1' attribute. +# That's the intended behavior atm. +# +create table t1 (n int not null, c char(1)) transactional=1; +show create table t1; +drop table t1; + +# +# Test of BUG#35570 CHECKSUM TABLE unreliable if LINESTRING field +# (same content / differen checksum) +# + +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; + +# +# Test number of supported key parts (32 is max) +# + +create table t1 (a1 int,a2 int,a3 int,a4 int,a5 int,a6 int,a7 int,a8 int,a9 int,a10 int,a11 int,a12 int,a13 int,a14 int,a15 int,a16 int,a17 int,a18 int,a19 int,a20 int,a21 int,a22 int,a23 int,a24 int,a25 int,a26 int,a27 int,a28 int,a29 int,a30 int,a31 int,a32 int, +key(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32)) engine=myisam; +drop table t1; + +--error 1070 +create table t1 (a1 int,a2 int,a3 int,a4 int,a5 int,a6 int,a7 int,a8 int,a9 int,a10 int,a11 int,a12 int,a13 int,a14 int,a15 int,a16 int,a17 int,a18 int,a19 int,a20 int,a21 int,a22 int,a23 int,a24 int,a25 int,a26 int,a27 int,a28 int,a29 int,a30 int,a31 int,a32 int, a33 int, +key(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33)) engine=myisam; + +# # Bug#43737: Select query return bad result # CREATE TABLE t1 ( @@ -1595,6 +1641,7 @@ DROP TABLE t1; CREATE TABLE t1(a INT, b BIT(1)); INSERT INTO t1 VALUES(1, 0), (2, 1); CREATE TABLE t2 SELECT * FROM t1; +FLUSH TABLES; --copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/t3.frm --copy_file $MYSQLD_DATADIR/test/t1.MYD $MYSQLD_DATADIR/test/t3.MYD --copy_file $MYSQLD_DATADIR/test/t1.MYI $MYSQLD_DATADIR/test/t3.MYI diff --git a/mysql-test/t/myisam_debug.test b/mysql-test/t/myisam_debug.test index 913668c5f22..43b5143441e 100644 --- a/mysql-test/t/myisam_debug.test +++ b/mysql-test/t/myisam_debug.test @@ -24,11 +24,15 @@ CREATE TABLE `t2` ( INSERT INTO t2 (id) VALUES (123); let $i = 10; +--disable_query_log +begin; while ($i) { INSERT INTO t2 (id) SELECT id FROM t2; dec $i; } +commit; +--enable_query_log --echo # Switch to insert Connection CONNECTION insertConn; diff --git a/mysql-test/t/myisampack.test b/mysql-test/t/myisampack.test index 9d27ed53254..fcd342168c4 100644 --- a/mysql-test/t/myisampack.test +++ b/mysql-test/t/myisampack.test @@ -69,11 +69,13 @@ CREATE TABLE t1(f1 VARCHAR(200), f2 TEXT); INSERT INTO t1 VALUES ('foo', 'foo1'), ('bar', 'bar1'); let $i=9; --disable_query_log +begin; while ($i) { INSERT INTO t1 SELECT * FROM t1; dec $i; } +commit; --enable_query_log FLUSH TABLE t1; --echo # Compress the table using MYISAMPACK tool diff --git a/mysql-test/t/mysql-bug41486.test b/mysql-test/t/mysql-bug41486.test index 6e014bca7d1..e7b0acc1935 100644 --- a/mysql-test/t/mysql-bug41486.test +++ b/mysql-test/t/mysql-bug41486.test @@ -27,7 +27,8 @@ connect (con1, localhost, root,,); CREATE TABLE t1(data LONGBLOB); INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024); - +# The following is to remove the race between end of insert and start of MYSQL_DUMP: +SELECT COUNT(*) FROM t1; let $outfile= $MYSQLTEST_VARDIR/tmp/bug41486.sql; --error 0,1 remove_file $outfile; diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index aa774036d10..d1ae90be864 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -1,3 +1,4 @@ +-- source include/have_working_dns.inc # This test should work in embedded server after we fix mysqltest -- source include/not_embedded.inc # diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test index 5f3ff9c7bb8..ea127fbcc6d 100644 --- a/mysql-test/t/mysql_upgrade.test +++ b/mysql-test/t/mysql_upgrade.test @@ -1,3 +1,4 @@ +-- source include/have_working_dns.inc # Can't run test of external client with embedded server -- source include/not_embedded.inc @@ -32,7 +33,7 @@ if (`SELECT $VALGRIND_TEST`) # expected binaries it uses. # --echo Run mysql_upgrade once ---exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +--exec $MYSQL_UPGRADE --force 2>&1 # It should have created a file in the MySQL Servers datadir let $MYSQLD_DATADIR= `select @@datadir`; @@ -41,13 +42,13 @@ file_exists $MYSQLD_DATADIR/mysql_upgrade_info; --echo Run it again - should say already completed --replace_result $MYSQL_SERVER_VERSION VERSION --error 1 ---exec $MYSQL_UPGRADE --skip-verbose 2>&1 +--exec $MYSQL_UPGRADE 2>&1 # It should have created a file in the MySQL Servers datadir 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 +--exec $MYSQL_UPGRADE --force 2>&1 # It should have created a file in the MySQL Servers datadir file_exists $MYSQLD_DATADIR/mysql_upgrade_info; @@ -62,7 +63,7 @@ file_exists $MYSQLD_DATADIR/mysql_upgrade_info; CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila'; GRANT ALL ON *.* TO mysqltest1@'%'; --echo Run mysql_upgrade with password protected account ---exec $MYSQL_UPGRADE --skip-verbose --force --user=mysqltest1 --password=sakila 2>&1 +--exec $MYSQL_UPGRADE --force --user=mysqltest1 --password=sakila 2>&1 DROP USER mysqltest1@'%'; @@ -75,7 +76,7 @@ DROP USER mysqltest1@'%'; --replace_result $MYSQLTEST_VARDIR var --replace_regex /.*mysqlcheck.*: Got/mysqlcheck: Got/ /\([0-9]*\)/(errno)/ --error 1 ---exec $MYSQL_UPGRADE --skip-verbose --force --host=not_existing_host 2>&1 +--exec $MYSQL_UPGRADE --force --host=not_existing_host 2>&1 # # Bug #28401 mysql_upgrade Failed with STRICT_ALL_TABLES, ANSI_QUOTES and NO_ZERO_DATE @@ -87,7 +88,7 @@ DROP USER mysqltest1@'%'; # Test by setting sql_mode before running mysql_upgrade set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE'; ---exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +--exec $MYSQL_UPGRADE --force 2>&1 eval set GLOBAL sql_mode=default; @@ -103,7 +104,7 @@ CREATE PROCEDURE testproc() BEGIN END; UPDATE mysql.proc SET character_set_client = NULL WHERE name LIKE 'testproc'; UPDATE mysql.proc SET collation_connection = NULL WHERE name LIKE 'testproc'; UPDATE mysql.proc SET db_collation = NULL WHERE name LIKE 'testproc'; ---exec $MYSQL_UPGRADE --skip-verbose --force 2> $MYSQLTEST_VARDIR/tmp/41569.txt +--exec $MYSQL_UPGRADE --force 2> $MYSQLTEST_VARDIR/tmp/41569.txt CALL testproc(); DROP PROCEDURE testproc; --cat_file $MYSQLTEST_VARDIR/tmp/41569.txt @@ -118,7 +119,7 @@ DROP PROCEDURE testproc; GRANT USAGE ON *.* TO 'user3'@'%'; GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'; --echo Run mysql_upgrade with all privileges on a user ---exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +--exec $MYSQL_UPGRADE --force 2>&1 SHOW GRANTS FOR 'user3'@'%'; DROP USER 'user3'@'%'; diff --git a/mysql-test/t/mysqlbinlog2-master.opt b/mysql-test/t/mysqlbinlog2-master.opt new file mode 100644 index 00000000000..4d69f3359db --- /dev/null +++ b/mysql-test/t/mysqlbinlog2-master.opt @@ -0,0 +1 @@ +--timezone=GMT-3 diff --git a/mysql-test/t/mysqlbinlog_row-master.opt b/mysql-test/t/mysqlbinlog_row-master.opt new file mode 100644 index 00000000000..4d69f3359db --- /dev/null +++ b/mysql-test/t/mysqlbinlog_row-master.opt @@ -0,0 +1 @@ +--timezone=GMT-3 diff --git a/mysql-test/t/mysqlbinlog_row_innodb-master.opt b/mysql-test/t/mysqlbinlog_row_innodb-master.opt new file mode 100644 index 00000000000..4d69f3359db --- /dev/null +++ b/mysql-test/t/mysqlbinlog_row_innodb-master.opt @@ -0,0 +1 @@ +--timezone=GMT-3 diff --git a/mysql-test/t/mysqlbinlog_row_myisam-master.opt b/mysql-test/t/mysqlbinlog_row_myisam-master.opt new file mode 100644 index 00000000000..4d69f3359db --- /dev/null +++ b/mysql-test/t/mysqlbinlog_row_myisam-master.opt @@ -0,0 +1 @@ +--timezone=GMT-3 diff --git a/mysql-test/t/mysqlbinlog_row_trans-master.opt b/mysql-test/t/mysqlbinlog_row_trans-master.opt new file mode 100644 index 00000000000..4d69f3359db --- /dev/null +++ b/mysql-test/t/mysqlbinlog_row_trans-master.opt @@ -0,0 +1 @@ +--timezone=GMT-3 diff --git a/mysql-test/t/mysqld_option_err.test b/mysql-test/t/mysqld_option_err.test new file mode 100644 index 00000000000..9c02dec51e6 --- /dev/null +++ b/mysql-test/t/mysqld_option_err.test @@ -0,0 +1,59 @@ +# +# Test error checks on mysqld command line option parsing. +# +# Call mysqld with different invalid options, and check that it fails in each case. +# +# This means that a test failure results in mysqld starting up, which is only +# caught when the test case times out. This is not ideal, but I did not find an +# easy way to have the server shut down after a successful startup. +# + +--source include/not_embedded.inc + +# mysqld refuses to run as root normally. +-- source include/not_as_root.inc + +# We have not run (and do not need) bootstrap of the server. We just +# give it a dummy data directory (for log files etc). + +mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err; + + +--echo Test that unknown option is not silently ignored. +--error 2 +--exec $MYSQLD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --nonexistentoption >$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 + + +--echo Test bad binlog format. +--error 1 +--exec $MYSQLD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --log-bin --binlog-format=badformat >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 + + +--echo Test bad default storage engine. +--error 1 +--exec $MYSQLD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --default-storage-engine=nonexistentengine >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 + + +--echo Test non-numeric value passed to number option. +--error 1 +--exec $MYSQLD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --min-examined-row-limit=notanumber >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 + + +# Test for MBug#423035: error in parsing enum value for plugin +# variable in mysqld command-line option. +# See also Bug#32034. +--echo Test that bad value for plugin enum option is rejected correctly. +--error 7 +--exec $MYSQLD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --plugin-dir=$MYSQLTEST_VARDIR/plugins --plugin-load=example=ha_example.so --plugin-example-enum-var=noexist >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 + +# +# Test that an wrong option with --help --verbose gives an error +# + +--echo Test that --help --verbose works +--exec $MYSQLD --help --verbose >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 +--echo Test that --not-known-option --help --verbose gives error +--error 2 +--exec $MYSQLD --not-known-option --help --verbose >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 + +--echo Done. diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 8ecf8187ff9..99537618011 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1,9 +1,15 @@ +call mtr.add_suppression("@003f.frm' \\(errno: 22\\)"); + # Embedded server doesn't support external clients --source include/not_embedded.inc # Binlog is required --source include/have_log_bin.inc +# utf8 is required +let collation=utf8_unicode_ci; +--source include/have_collation.inc + # Save the initial number of concurrent sessions --source include/count_sessions.inc @@ -209,7 +215,7 @@ DROP TABLE t1; --echo # Test for --insert-ignore --echo # -CREATE TABLE t1 (a INT); +CREATE TABLE t1 (a INT) ENGINE=MyISAM; INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t1 VALUES (4),(5),(6); --exec $MYSQL_DUMP --skip-comments --insert-ignore test t1 @@ -1509,13 +1515,12 @@ INSERT INTO t1 VALUES (1), (2); DROP TABLE t1; - # -# Bug#25993 crashes with a merge table and -c +# Bug #25993 crashes with a merge table and -c # -CREATE TABLE t2 (a INT); -CREATE TABLE t3 (a INT); +CREATE TABLE t2 (a INT) ENGINE=MyISAM; +CREATE TABLE t3 (a INT) ENGINE=MyISAM; CREATE TABLE t1 (a INT) ENGINE=merge UNION=(t2, t3); --exec $MYSQL_DUMP --skip-comments -c test DROP TABLE t1, t2, t3; @@ -1983,6 +1988,8 @@ drop table if exists `load`; create table `load` (a varchar(255)); --copy_file std_data/words.dat $MYSQLTEST_VARDIR/tmp/load.txt +# LOAD DATA requires the file to be world-readable. This may not be true +# automatically, depending on how the build directory was created. --chmod 0644 $MYSQLTEST_VARDIR/tmp/load.txt --exec $MYSQL_IMPORT --ignore test $MYSQLTEST_VARDIR/tmp/load.txt diff --git a/mysql-test/t/mysqlshow.test b/mysql-test/t/mysqlshow.test index 9ed93079f57..b545a430481 100644 --- a/mysql-test/t/mysqlshow.test +++ b/mysql-test/t/mysqlshow.test @@ -26,11 +26,4 @@ select "---- -v -v -t ------" as ""; --exec $MYSQL_SHOW test -v -v -t DROP TABLE t1, t2; -# -# Bug #19147: mysqlshow INFORMATION_SCHEMA does not work -# ---exec $MYSQL_SHOW information_schema ---exec $MYSQL_SHOW INFORMATION_SCHEMA ---exec $MYSQL_SHOW inf_rmation_schema - --echo End of 5.0 tests diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 52dfd8e86d3..51d12130b13 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -9,6 +9,14 @@ # Save the initial number of concurrent sessions --source include/count_sessions.inc +# Some tests below connect/disconnect rapidly in a loop. This causes a race +# where mysqld may not have time to register the previous disconnects before +# new connects, and eventually we run out of connections. So we need to +# increase the maximum. +let $saved_max_connections = `SELECT @@global.max_connections`; +SET GLOBAL max_connections = 1000; + + # ============================================================================ # # Test of mysqltest itself @@ -98,7 +106,7 @@ select otto from (select 1 as otto) as t1; # 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 +--exec echo "disable_warnings ; error S00000; remove_file $MYSQLTEST_VARDIR/tmp/test_nonexistent.tmp;" | $MYSQL_TEST 2>&1 # ---------------------------------------------------------------------------- @@ -1645,12 +1653,14 @@ select "this will be executed"; --exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1 remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result; +--disable_warnings --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; +--enable_warnings # # Test that a test file that does not generate any output fails. @@ -1844,11 +1854,13 @@ drop table t1; # test for remove_file # ---------------------------------------------------------------------------- +--disable_warnings --error 1 --exec echo "remove_file ;" | $MYSQL_TEST 2>&1 --error 1 remove_file non_existing_file; +--enable_warnings # ---------------------------------------------------------------------------- # test for remove_files_wildcard @@ -1888,7 +1900,7 @@ Content for test_file1 contains EOF END_DELIMITER file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; -# write to already exisiting file +# write to already existing file --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --error 1 --exec echo "write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;" | $MYSQL_TEST 2>&1 @@ -2005,8 +2017,10 @@ EOF --error 1 --exec echo "file_exists ;" | $MYSQL_TEST 2>&1 +--disable_warnings --error 0,1 remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; +--enable_warnings --error 1 file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; @@ -2043,6 +2057,7 @@ remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp; # - Check that if source file does not exist, nothing will be created. +--disable_warnings --error 1 file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; --error 1 @@ -2053,6 +2068,7 @@ move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp; file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; --error 1 file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; +--enable_warnings # - Check that if source file exists, everything works properly. @@ -2627,3 +2643,7 @@ disconnect $y; connection default; # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc + +--disable_query_log +--eval SET GLOBAL max_connections = $saved_max_connections +--enable_query_log diff --git a/mysql-test/t/mysqltest_ps.test b/mysql-test/t/mysqltest_ps.test new file mode 100644 index 00000000000..c5a332f691f --- /dev/null +++ b/mysql-test/t/mysqltest_ps.test @@ -0,0 +1,34 @@ +# +# Test mysqltest in --ps-protocol mode. +# + +if (`SELECT $PS_PROTOCOL = 0`) +{ + --skip Need ps-protocol +} + +# +# Test the --enable_prepare_warnings command. +# Test default value (off), enabling, and disabling. +# + +--enable_warnings + +select 1 + "2 a"; +create table t (a int primary key, b blob default ''); +# This statement gives warning both during prepare and execute. +# So gives double warnings when --enable_prepare_warnings. +select a, (2*a) AS a from t group by a; +drop table t; + +--enable_prepare_warnings +select 1 + "2 a"; +create table t (a int primary key, b blob default ''); +select a, (2*a) AS a from t group by a; +drop table t; + +--disable_prepare_warnings +select 1 + "2 a"; +create table t (a int primary key, b blob default ''); +select a, (2*a) AS a from t group by a; +drop table t; diff --git a/mysql-test/t/not_embedded_server.test b/mysql-test/t/not_embedded_server.test index 43cdb977386..714bf2e9c96 100644 --- a/mysql-test/t/not_embedded_server.test +++ b/mysql-test/t/not_embedded_server.test @@ -32,7 +32,7 @@ select 1; ## End of 4.1 tests # #prepare stmt1 from ' SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND!=\'Daemon\' '; -#--replace_column 1 number 6 time 3 localhost +#--replace_column 1 number 6 time 3 localhost 9 time_ms #execute stmt1; #deallocate prepare stmt1; diff --git a/mysql-test/t/old-mode-master.opt b/mysql-test/t/old-mode-master.opt new file mode 100644 index 00000000000..840ee0dedcf --- /dev/null +++ b/mysql-test/t/old-mode-master.opt @@ -0,0 +1 @@ +--old=1 diff --git a/mysql-test/t/old-mode.test b/mysql-test/t/old-mode.test new file mode 100644 index 00000000000..6d0fe64bbb8 --- /dev/null +++ b/mysql-test/t/old-mode.test @@ -0,0 +1,17 @@ +# +# Test 'old' mode +# + +# Initialise +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +create table t1 (a int, b varchar(200), c text not null) checksum=1; +create table t2 (a int, b varchar(200), c text not null) checksum=0; +insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); +insert t2 select * from t1; +checksum table t1, t2; +checksum table t1, t2 quick; +checksum table t1, t2 extended; +drop table t1,t2; diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test index 8ca70258bc0..8051dd0e866 100644 --- a/mysql-test/t/openssl_1.test +++ b/mysql-test/t/openssl_1.test @@ -73,6 +73,8 @@ drop table t1; # a different cacert # --exec echo "this query should not execute;" > $MYSQLTEST_VARDIR/tmp/test.sql +# Handle that openssl gives different error messages from YaSSL. +--replace_regex /error:00000005:lib\(0\):func\(0\):DH lib/ASN: bad other signature confirmation/ --error 1 --exec $MYSQL_TEST --ssl-ca=$MYSQL_TEST_DIR/std_data/untrusted-cacert.pem --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 @@ -80,6 +82,7 @@ drop table t1; # Test that we can't open connection to server if we are using # a blank ca # +--replace_regex /error:00000005:lib\(0\):func\(0\):DH lib/ASN: bad other signature confirmation/ --error 1 --exec $MYSQL_TEST --ssl-ca= --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 @@ -87,6 +90,7 @@ drop table t1; # Test that we can't open connection to server if we are using # a nonexistent ca file # +--replace_regex /error:00000005:lib\(0\):func\(0\):DH lib/ASN: bad other signature confirmation/ --error 1 --exec $MYSQL_TEST --ssl-ca=nonexisting_file.pem --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1 diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index e310d960c97..14b568f2b22 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -374,14 +374,16 @@ DROP TABLE t1; # create table t1(id int not null auto_increment primary key, t char(12)); -disable_query_log; +--disable_query_log +begin; let $1 = 1000; while ($1) { eval insert into t1(t) values ('$1'); dec $1; } -enable_query_log; +commit; +--enable_query_log explain select id,t from t1 order by id; explain select id,t from t1 force index (primary) order by id; drop table t1; diff --git a/mysql-test/t/order_fill_sortbuf.test b/mysql-test/t/order_fill_sortbuf.test index f13cf8cf350..7a8779b6e55 100644 --- a/mysql-test/t/order_fill_sortbuf.test +++ b/mysql-test/t/order_fill_sortbuf.test @@ -12,13 +12,15 @@ CREATE TABLE `t1` ( `id2` int(11) NOT NULL default '0', `id3` int(11) NOT NULL default '0'); let $1=4000; -disable_query_log; +--disable_query_log +begin; while ($1) { eval insert into t1 (id,id2,id3) values ($1,$1,$1); dec $1; } -enable_query_log; +commit; +--enable_query_log create table t2 select id2 from t1 order by id3; select count(*) from t2; drop table t1,t2; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 341e8780b2b..61aab8233ff 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1883,6 +1883,7 @@ create table t1 insert into t1 values (null,null); --disable_query_log +begin; let $cnt= 1000; while ($cnt) { @@ -1890,6 +1891,7 @@ while ($cnt) update t1 set s2 = 2; dec $cnt; } +commit; --enable_query_log drop table t1; @@ -2008,11 +2010,13 @@ CREATE TABLE t1(id MEDIUMINT NOT NULL AUTO_INCREMENT, PARTITION pa11 values less than MAXVALUE); --disable_query_log let $n= 15; +begin; while ($n) { insert into t1 (user) values ('mysql'); dec $n; } +commit; --enable_query_log show create table t1; drop table t1; diff --git a/mysql-test/t/partition_archive.test b/mysql-test/t/partition_archive.test index fad57107b7d..9e2377f1bbf 100644 --- a/mysql-test/t/partition_archive.test +++ b/mysql-test/t/partition_archive.test @@ -94,11 +94,13 @@ CREATE TABLE t1(id MEDIUMINT NOT NULL AUTO_INCREMENT, --disable_query_log let $n= 100; +begin; while ($n) { insert into t1 (f1) values (repeat('a',25)); dec $n; } +commit; --enable_query_log show create table t1; diff --git a/mysql-test/t/partition_binlog_stmt.test b/mysql-test/t/partition_binlog_stmt.test index c426de9f303..cc57222dc3c 100644 --- a/mysql-test/t/partition_binlog_stmt.test +++ b/mysql-test/t/partition_binlog_stmt.test @@ -8,7 +8,7 @@ DROP TABLE IF EXISTS t1; --echo # --echo # Bug#51851: Server with SBR locks mutex twice on LOAD DATA into --echo # partitioned MyISAM table ---write_file init_file.txt +--write_file $MYSQLTEST_VARDIR/tmp/init_file.txt abcd EOF @@ -19,8 +19,9 @@ CREATE TABLE t1 INDEX namelocs (name(255))) ENGINE = MyISAM PARTITION BY HASH(id) PARTITIONS 2; -LOAD DATA LOCAL INFILE 'init_file.txt' +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/init_file.txt' INTO TABLE t1 (name); ---remove_file init_file.txt +--remove_file $MYSQLTEST_VARDIR/tmp/init_file.txt DROP TABLE t1; diff --git a/mysql-test/t/partition_federated.test b/mysql-test/t/partition_federated.test deleted file mode 100644 index 0fe692ecd01..00000000000 --- a/mysql-test/t/partition_federated.test +++ /dev/null @@ -1,21 +0,0 @@ -# -# 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_innodb-master.opt b/mysql-test/t/partition_innodb-master.opt index 462f8fbe828..82dec8b25fd 100644 --- a/mysql-test/t/partition_innodb-master.opt +++ b/mysql-test/t/partition_innodb-master.opt @@ -1 +1 @@ ---innodb_lock_wait_timeout=1 +--loose-innodb_lock_wait_timeout=1 diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index dc8bcbb4cb9..835a73fd961 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -129,14 +129,14 @@ 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/ +--replace_regex /.*LIST OF TRANSACTIONS FOR EACH SESSION:// /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/ +--replace_regex /.*LIST OF TRANSACTIONS FOR EACH SESSION:// /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; diff --git a/mysql-test/t/partition_innodb_semi_consistent-master.opt b/mysql-test/t/partition_innodb_semi_consistent-master.opt index e76299453d3..cb48f1aaf60 100644 --- a/mysql-test/t/partition_innodb_semi_consistent-master.opt +++ b/mysql-test/t/partition_innodb_semi_consistent-master.opt @@ -1 +1 @@ ---innodb_lock_wait_timeout=2 +--loose-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 index 2711d79f194..9d3e2570256 100644 --- a/mysql-test/t/partition_innodb_semi_consistent.test +++ b/mysql-test/t/partition_innodb_semi_consistent.test @@ -117,7 +117,17 @@ INSERT INTO t1 VALUES (1,'init'); DELIMITER |; CREATE PROCEDURE p1() BEGIN - UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1; + # retry the UPDATE in case it times out the lock before con1 has time + # to COMMIT. + DECLARE do_retry INT DEFAULT 0; + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET do_retry = 1; + retry_loop:LOOP + UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1; + IF do_retry = 0 THEN + LEAVE retry_loop; + END IF; + SET do_retry = 0; + END LOOP; INSERT INTO t2 VALUES (); END| DELIMITER ;| diff --git a/mysql-test/t/plugin-master.opt b/mysql-test/t/plugin-master.opt deleted file mode 100644 index 367d5233e0e..00000000000 --- a/mysql-test/t/plugin-master.opt +++ /dev/null @@ -1 +0,0 @@ -$EXAMPLE_PLUGIN_OPT diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test index 788a7b336ef..9a1a750378c 100644 --- a/mysql-test/t/plugin.test +++ b/mysql-test/t/plugin.test @@ -5,15 +5,15 @@ CREATE TABLE t1(a int) ENGINE=EXAMPLE; DROP TABLE t1; --replace_regex /\.dll/.so/ -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$HA_EXAMPLE_SO'; --replace_regex /\.dll/.so/ --error 1125 -eval INSTALL PLUGIN EXAMPLE SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN EXAMPLE SONAME '$HA_EXAMPLE_SO'; UNINSTALL PLUGIN example; --replace_regex /\.dll/.so/ -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$HA_EXAMPLE_SO'; CREATE TABLE t1(a int) ENGINE=EXAMPLE; @@ -35,7 +35,7 @@ UNINSTALL PLUGIN non_exist; --echo # to impossible int val --echo # --replace_regex /\.dll/.so/ -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$HA_EXAMPLE_SO'; SET GLOBAL example_enum_var= e1; SET GLOBAL example_enum_var= e2; @@ -50,7 +50,7 @@ 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; +eval INSTALL PLUGIN example SONAME '$HA_EXAMPLE_SO'; select @@session.sql_mode into @old_sql_mode; diff --git a/mysql-test/t/plugin_innodb.test b/mysql-test/t/plugin_innodb.test new file mode 100644 index 00000000000..fb5dd84b997 --- /dev/null +++ b/mysql-test/t/plugin_innodb.test @@ -0,0 +1,27 @@ +--source include/not_embedded.inc +--source include/have_example_plugin.inc +--source include/have_innodb.inc + +if (!`select count(*) from information_schema.plugins + where plugin_name = 'innodb' and plugin_status = 'active' and + plugin_library is null`) { + skip Need compiled-in InnoDB; +} + + +--replace_regex /\.dll/.so/ +eval install plugin example soname '$HA_EXAMPLE_SO'; +create table t1(a int) engine=example; +drop table t1; + +alter table mysql.plugin engine=innodb; +--echo restart +--source include/restart_mysqld.inc + +create table t1(a int) engine=example; +select * from t1; +drop table t1; + +alter table mysql.plugin engine=myisam; +uninstall plugin example; + diff --git a/mysql-test/t/plugin_load-master.opt b/mysql-test/t/plugin_load-master.opt index bb7831c5769..aadeef2fb66 100644 --- a/mysql-test/t/plugin_load-master.opt +++ b/mysql-test/t/plugin_load-master.opt @@ -1,3 +1,2 @@ -$EXAMPLE_PLUGIN_OPT -$EXAMPLE_PLUGIN_LOAD +--plugin-load=EXAMPLE=$HA_EXAMPLE_SO --loose-plugin-example-enum-var=e2 diff --git a/mysql-test/t/plugin_not_embedded-master.opt b/mysql-test/t/plugin_not_embedded-master.opt deleted file mode 100644 index 367d5233e0e..00000000000 --- a/mysql-test/t/plugin_not_embedded-master.opt +++ /dev/null @@ -1 +0,0 @@ -$EXAMPLE_PLUGIN_OPT diff --git a/mysql-test/t/plugin_not_embedded.test b/mysql-test/t/plugin_not_embedded.test index 40024efcaad..3e3bd6e86ca 100644 --- a/mysql-test/t/plugin_not_embedded.test +++ b/mysql-test/t/plugin_not_embedded.test @@ -8,7 +8,7 @@ GRANT INSERT ON mysql.plugin TO bug51770@localhost; connect(con1,localhost,bug51770,,); --replace_regex /\.dll/.so/ -eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO; +eval INSTALL PLUGIN example SONAME '$HA_EXAMPLE_SO'; --error ER_TABLEACCESS_DENIED_ERROR UNINSTALL PLUGIN example; connection default; @@ -25,7 +25,7 @@ DROP USER bug51770@localhost; # The bug consisted of not recognizing / on Windows, so checking / on # all platforms should cover this case. -let $path = `select CONCAT_WS('/', '..', $HA_EXAMPLE_SO)`; +let $path = `select CONCAT_WS('/', '..', '$HA_EXAMPLE_SO')`; --replace_regex /\.dll/.so/ --error ER_UDF_NO_PATHS eval INSTALL PLUGIN example SONAME '$path'; diff --git a/mysql-test/t/pool_of_threads.cnf b/mysql-test/t/pool_of_threads.cnf new file mode 100644 index 00000000000..9ab0571df9f --- /dev/null +++ b/mysql-test/t/pool_of_threads.cnf @@ -0,0 +1,14 @@ +!include include/default_my.cnf + +[mysqld.1] +test-ignore-wrong-options +loose-thread-handling= pool-of-threads +loose-thread_pool_size= 2 +extra-port= @mysqld.1.#extra-port +extra-max-connections=1 + +[client] +connect-timeout= 2 + +[ENV] +MASTER_EXTRA_PORT= @mysqld.1.#extra-port diff --git a/mysql-test/t/pool_of_threads.test b/mysql-test/t/pool_of_threads.test new file mode 100644 index 00000000000..530038cee91 --- /dev/null +++ b/mysql-test/t/pool_of_threads.test @@ -0,0 +1,84 @@ +# Start with thread_handling=pool-of-threads +# and run a number of tests + +-- source include/have_pool_of_threads.inc +# Slow test, don't run during staging part +-- source include/not_staging.inc +-- source include/long_test.inc +-- source include/common-tests.inc + + +# Test that we cannot have more simultaneous connections than +# --thread-pool-size on the standard port, but _can_ have additional +# connections on the extra port. + +# First set two connections running, and check that extra connection +# on normal port fails due to--thread-pool-size=2 +connection default; +send SELECT sleep(5); + +connect(con2,localhost,root,,); +connection con2; +send SELECT sleep(5); +--sleep 1 + +--disable_abort_on_error +--disable_result_log +--disable_query_log +connect(con3,localhost,root,,); +--enable_query_log +--enable_result_log +--enable_abort_on_error +let $error = $mysql_errno; +if (!$error) +{ + --echo # -- Error: managed to establish more than --thread-pool-size connections +} +if ($error) +{ + --echo # -- Success: more than --thread-pool-size normal connections not possible +} + +connection default; +--reap +connection con2; +--reap + +# Now try again, but this time use the extra port to successfully connect. + +connection default; +send SELECT sleep(5); + +connection con2; +send SELECT sleep(5); +--sleep 1 + +connect(extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,); +connection extracon; +SELECT 'Connection on extra port ok'; + +connect(extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,); +connection extracon2; +SELECT 'Connection on extra port 2 ok'; + +--disable_abort_on_error +--disable_result_log +--disable_query_log +connect(extracon3,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,); +--enable_query_log +--enable_result_log +--enable_abort_on_error +let $error = $mysql_errno; +if (!$error) +{ + --echo # -- Error: managed to establish more than --extra-max-connections + 1 connections +} +if ($error) +{ + --echo # -- Success: more than --extra-max-connections + 1 normal connections not possible +} + +connection default; +--reap +connection con2; +--reap diff --git a/mysql-test/t/preload.test b/mysql-test/t/preload.test index 1b7f3c5b9eb..69949fccedc 100644 --- a/mysql-test/t/preload.test +++ b/mysql-test/t/preload.test @@ -2,6 +2,9 @@ # Testing of PRELOAD # +# Slow test, don't run during staging part +-- source include/not_staging.inc + --disable_warnings drop table if exists t1, t2; --enable_warnings diff --git a/mysql-test/t/ps-master.opt b/mysql-test/t/ps-master.opt index 31c287d2bb5..0e3f2e5092d 100644 --- a/mysql-test/t/ps-master.opt +++ b/mysql-test/t/ps-master.opt @@ -1 +1 @@ ---log-output=table,file --log-slow-queries --log-long-format --log-queries-not-using-indexes +--log-output=table,file --slow-query-log --log-long-format --log-queries-not-using-indexes --general-log diff --git a/mysql-test/t/ps_ddl.test b/mysql-test/t/ps_ddl.test index 1543c757908..10a96285451 100644 --- a/mysql-test/t/ps_ddl.test +++ b/mysql-test/t/ps_ddl.test @@ -58,6 +58,10 @@ drop function if exists f1; drop view if exists v1, v2; --enable_warnings +# Avoid selecting from a huge table possibly left over from previous tests, +# as this really hurts --valgrind testing. +TRUNCATE TABLE mysql.general_log; + delimiter |; create procedure p_verify_reprepare_count(expected int) begin diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index 0edc9cca385..24487db826a 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -1,4 +1,5 @@ -- source include/have_query_cache.inc +-- source include/long_test.inc # # Tests with query cache @@ -45,9 +46,9 @@ show status like "Qcache_queries_in_cache"; # # MERGE TABLES with INSERT/UPDATE and DELETE # -create table t1 (a int not null); +create table t1 (a int not null) ENGINE=MyISAM; insert into t1 values (1),(2),(3); -create table t2 (a int not null); +create table t2 (a int not null) ENGINE=MyISAM; insert into t2 values (4),(5),(6); create table t3 (a int not null) engine=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST; # insert @@ -294,7 +295,7 @@ drop table t1; flush query cache; reset query cache; -create table t1 (a int not null); +create table t1 (a int not null) ENGINE=MyISAM; insert into t1 values (1),(2),(3); select * from t1; select * from t1; @@ -882,6 +883,19 @@ drop procedure f4; drop table t1; set GLOBAL query_cache_size=0; +# Tests moved from main.variables due to needing query cache in server. +set GLOBAL query_cache_size=100000; +--error ER_GLOBAL_VARIABLE +set SESSION query_cache_size=10000; +set global query_cache_limit=100; +set global query_cache_size=100; +set global query_cache_type=demand; + +set GLOBAL query_cache_type=default; +set GLOBAL query_cache_limit=default; +set GLOBAL query_cache_size=default; + + --echo End of 4.1 tests # @@ -1288,6 +1302,198 @@ SHOW STATUS LIKE "Qcache_hits"; DROP TABLE t1; SET GLOBAL query_cache_size= default; +# +# Bug#6760: Add SLEEP() function (feature request) +# +# Logics of original test: +# Reveal that a query with SLEEP does not need less time than estimated. +# +# Bug#12689: SLEEP() gets incorrectly cached/optimized-away +# +# Description from bug report (slightly modified) +# +# Bug 1 (happened all time): +# SELECT * FROM t1 WHERE SLEEP(1) will only result in a sleep of 1 +# second, regardless of the number of rows in t1. +# Bug 2 (happened all time): +# Such a query will also get cached by the query cache, but should not. +# +# Notes (mleich, 2008-05) +# ======================= +# +# Experiments around +# Bug#36345 Test 'func_misc' fails on RHAS3 x86_64 +# showed that the tests for both bugs could produce in case of parallel +# artificial system time (like via ntpd) +# - decreases false alarm +# - increases false success +# +# We try here to circumvent these issues by reimplementation of the tests +# and sophisticated scripting, although the cause of the problems is a massive +# error within the setup of the testing environment. +# Tests relying on or checking derivates of the system time must never meet +# parallel manipulations of system time. +# +# Results of experiments with/without manipulation of system time, +# information_schema.processlist content, high load on testing box +# ---------------------------------------------------------------- +# Definition: Predicted_cumulative_sleep_time = +# #_of_result_rows * sleep_time_per_result_row +# +# 1. Total (real sleep time) ~= predicted_cumulative_sleep_time !! +# 2. The state of a session within the PROCESSLIST changes to 'User sleep' +# if the sessions runs a statement containing the sleep function and the +# processing of the statement is just within the phase where the sleep +# is done. (*) +# 3. NOW() and processlist.time behave "synchronous" to system time and +# show also the "jumps" caused by system time manipulations. (*) +# 4. processlist.time is unsigned, the "next" value below 0 is ~ 4G (*) +# 5. Current processlist.time ~= current real sleep time if the system time +# was not manipulated. (*) +# 6. High system load can cause delays of <= 2 seconds. +# 7. Thanks to Davi for excellent hints and ideas. +# +# (*) +# - information_schema.processlist is not available before MySQL 5.1. +# - Observation of processlist content requires a +# - "worker" session sending the query with "send" and pulling results +# with "reap" +# - session observing the processlist parallel to the worker session +# "send" and "reap" do not work in case of an embedded server. +# Conclusion: Tests based on processlist have too many restrictions. +# +# Solutions for subtests based on TIMEDIFF of values filled via NOW() +# ------------------------------------------------------------------- +# Run the following sequence three times +# 1. SELECT <start_time> +# 2. Query with SLEEP +# 3. SELECT <end_time> +# If TIMEDIFF(<end_time>,<start_time>) is at least two times within a +# reasonable range assume that we did not met errors we were looking for. +# +# It is extreme unlikely that we have two system time changes within the +# < 30 seconds runtime. Even if the unlikely happens, there are so +# frequent runs of this test on this or another testing box which will +# catch the problem. +# + +--echo #------------------------------------------------------------------------ +--echo # Tests for Bug#6760 and Bug#12689 +# Number of rows within the intended result set. +SET @row_count = 4; +# Parameter within SLEEP function +SET @sleep_time_per_result_row = 1; +# Maximum acceptable delay caused by high load on testing box +SET @max_acceptable_delay = 2; +# TIMEDIFF = time for query with sleep (mostly the time caused by SLEEP) +# + time for delays caused by high load on testing box +# Ensure that at least a reasonable fraction of TIMEDIFF belongs to the SLEEP +# by appropriate setting of variables. +# Ensure that any "judging" has a base of minimum three attempts. +# (Test 2 uses all attempts except the first one.) +if (!` SELECT (@sleep_time_per_result_row * @row_count - @max_acceptable_delay > + @sleep_time_per_result_row) AND (@row_count - 1 >= 3)`) +{ + --echo # Have to abort because of error in plausibility check + --echo ###################################################### + --vertical_results + SELECT @sleep_time_per_result_row * @row_count - @max_acceptable_delay > + @sleep_time_per_result_row AS must_be_1, + @row_count - 1 >= 3 AS must_be_also_1, + @sleep_time_per_result_row, @row_count, @max_acceptable_delay; + exit; +} +SET @@global.query_cache_size = 1024 * 64; +--disable_warnings +DROP TEMPORARY TABLE IF EXISTS t_history; +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TEMPORARY TABLE t_history (attempt SMALLINT, +start_ts DATETIME, end_ts DATETIME, +start_cached INTEGER, end_cached INTEGER); +CREATE TABLE t1 (f1 BIGINT); +let $num = `SELECT @row_count`; +--disable_query_log +begin; +while ($num) +{ + INSERT INTO t1 VALUES (1); + dec $num; +} +commit; +--enable_query_log + +let $loops = 4; +let $num = $loops; +while ($num) +{ + let $Qcache_queries_in_cache = + query_get_value(SHOW STATUS LIKE 'Qcache_queries_in_cache', Value, 1); + eval + INSERT INTO t_history + SET attempt = $loops - $num + 1, start_ts = NOW(), + start_cached = $Qcache_queries_in_cache; + SELECT *, SLEEP(@sleep_time_per_result_row) FROM t1; + # + # Do not determine Qcache_queries_in_cache before updating end_ts. The SHOW + # might cost too much time on an overloaded box. + eval + UPDATE t_history SET end_ts = NOW() + WHERE attempt = $loops - $num + 1; + let $Qcache_queries_in_cache = + query_get_value(SHOW STATUS LIKE 'Qcache_queries_in_cache', Value, 1); + eval + UPDATE t_history SET end_cached = $Qcache_queries_in_cache + WHERE attempt = $loops - $num + 1; + # DEBUG eval SELECT * FROM t_history WHERE attempt = $loops - $num + 1; + dec $num; +} + +# 1. The majority of queries with SLEEP must need a reasonable time +# -> SLEEP has an impact on runtime +# = Replacement for original Bug#6760 test +# -> total runtime is clear more needed than for one result row needed +# = Replacement for one of the original Bug#12689 tests +--echo # Test 1: Does the query with SLEEP need a reasonable time? +eval SELECT COUNT(*) >= $loops - 1 INTO @aux1 FROM t_history +WHERE TIMEDIFF(end_ts,start_ts) - @sleep_time_per_result_row * @row_count + BETWEEN 0 AND @max_acceptable_delay; +SELECT @aux1 AS "Expect 1"; +# +# 2. The majority of queries (the first one must be ignored) with SLEEP must +# need a reasonable time +# -> If we assume that the result of a cached query will be sent back +# immediate, without any sleep, than the query with SLEEP cannot be cached +# (current and intended behaviour for queries with SLEEP). +# -> It could be also not excluded that the query was cached but the server +# honoured somehow the SLEEP. Such a behaviour would be also acceptable. +# = Replacement for one of the original Bug#12689 tests +--echo # Test 2: Does the query with SLEEP need a reasonable time even in case +--echo # of the non first execution? +eval SELECT COUNT(*) >= $loops - 1 - 1 INTO @aux2 FROM t_history +WHERE TIMEDIFF(end_ts,start_ts) - @sleep_time_per_result_row * @row_count + BETWEEN 0 AND @max_acceptable_delay + AND attempt > 1; +SELECT @aux2 AS "Expect 1"; +# +# 3. The query with SLEEP should be not cached. +# -> SHOW STATUS Qcache_queries_in_cache must be not incremented after +# the execution of the query with SLEEP +--echo # Test 3: The query with SLEEP must be not cached. +eval SELECT COUNT(*) = $loops INTO @aux3 FROM t_history +WHERE end_cached = start_cached; +SELECT @aux3 AS "Expect 1"; +# +# Dump the content of t_history if one of the tests failed. +if (`SELECT @aux1 + @aux2 + @aux3 <> 3`) +{ + --echo # Some tests failed, dumping the content of t_history + SELECT * FROM t_history; +} +DROP TABLE t1; +DROP TEMPORARY TABLE t_history; +SET @@global.query_cache_size = default; + --echo End of 5.0 tests # diff --git a/mysql-test/t/query_cache_merge.test b/mysql-test/t/query_cache_merge.test index 4e25bc3ed14..189de8e4092 100644 --- a/mysql-test/t/query_cache_merge.test +++ b/mysql-test/t/query_cache_merge.test @@ -19,7 +19,7 @@ let $1 = 257; while ($1) { eval drop table if exists t$1; - eval create table t$1(a int); + eval create table t$1(a int) ENGINE=MyISAM; eval insert into t$1 values (1),(2); dec $1; } diff --git a/mysql-test/t/query_cache_notembedded.test b/mysql-test/t/query_cache_notembedded.test index 095d47f5bdf..d807215348c 100644 --- a/mysql-test/t/query_cache_notembedded.test +++ b/mysql-test/t/query_cache_notembedded.test @@ -274,5 +274,52 @@ set GLOBAL query_cache_limit=default; set GLOBAL query_cache_min_res_unit=default; set GLOBAL query_cache_size=default; +# +# Bug#3583 query cache doesn't work for stored procedures +# +delimiter |; +--disable_warnings +drop table if exists t1| +--enable_warnings +create table t1 ( + id char(16) not null default '', + data int not null +)| +--disable_warnings +drop procedure if exists bug3583| +--enable_warnings +--disable_warnings +drop procedure if exists bug3583| +--enable_warnings +create procedure bug3583() +begin + declare c int; + + select * from t1; + select count(*) into c from t1; + select c; +end| + +insert into t1 values ("x", 3), ("y", 5)| +set @x = @@query_cache_size| +set global query_cache_size = 10*1024*1024| + +flush status| +flush query cache| +show status like 'Qcache_hits'| +call bug3583()| +show status like 'Qcache_hits'| +call bug3583()| +call bug3583()| +show status like 'Qcache_hits'| + +set global query_cache_size = @x| +flush status| +flush query cache| +delete from t1| +drop procedure bug3583| +drop table t1| +delimiter ;| + # 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 index 6f4263eeef9..16533c7194e 100644 --- a/mysql-test/t/query_cache_ps_no_prot.test +++ b/mysql-test/t/query_cache_ps_no_prot.test @@ -11,8 +11,9 @@ # We cannot run on embedded server because we use multiple sessions. --source include/not_embedded.inc - --source include/have_query_cache.inc +let collation=utf8_unicode_ci; +--source include/have_collation.inc # The file with expected results fits only to a run without # ps-protocol/sp-protocol/cursor-protocol/view-protocol. diff --git a/mysql-test/t/query_cache_ps_ps_prot.test b/mysql-test/t/query_cache_ps_ps_prot.test index dc49624788a..d431ce349d2 100644 --- a/mysql-test/t/query_cache_ps_ps_prot.test +++ b/mysql-test/t/query_cache_ps_ps_prot.test @@ -11,8 +11,9 @@ # We cannot run on embedded server because we use multiple sessions. --source include/not_embedded.inc - --source include/have_query_cache.inc +let collation=utf8_unicode_ci; +--source include/have_collation.inc # The file with expected results fits only to a run with "--ps-protocol". if (`SELECT $SP_PROTOCOL + $CURSOR_PROTOCOL + $VIEW_PROTOCOL > 0 diff --git a/mysql-test/t/row-checksum-old-master.opt b/mysql-test/t/row-checksum-old-master.opt new file mode 100644 index 00000000000..8e7b7f9e36f --- /dev/null +++ b/mysql-test/t/row-checksum-old-master.opt @@ -0,0 +1 @@ +--old diff --git a/mysql-test/t/row-checksum-old.test b/mysql-test/t/row-checksum-old.test new file mode 100644 index 00000000000..71188ddf432 --- /dev/null +++ b/mysql-test/t/row-checksum-old.test @@ -0,0 +1,4 @@ +# +# Run row-checksum.test with old mode +# +--source t/row-checksum.test diff --git a/mysql-test/t/row-checksum.test b/mysql-test/t/row-checksum.test new file mode 100644 index 00000000000..920a2384aa8 --- /dev/null +++ b/mysql-test/t/row-checksum.test @@ -0,0 +1,62 @@ +# +# Test checksum +# + +-- source include/have_innodb.inc +-- source include/have_maria.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (a int null, v varchar(100)) engine=myisam checksum=0; +insert into t1 values(null, null), (1, "hello"); +checksum table t1; +checksum table t1 quick; +checksum table t1 extended; +drop table if exists t1; +create table t1 (a int null, v varchar(100)) engine=myisam checksum=1; +insert into t1 values(null, null), (1, "hello"); +checksum table t1; +checksum table t1 quick; +checksum table t1 extended; +drop table if exists t1; + +create table t1 (a int null, v varchar(100)) engine=innodb checksum=0; +insert into t1 values(null, null), (1, "hello"); +checksum table t1; +checksum table t1 quick; +checksum table t1 extended; +drop table t1; + +create table t1 (a int null, v varchar(100)) engine=maria checksum=0; +insert into t1 values(null, null), (1, "hello"); +checksum table t1; +checksum table t1 quick; +checksum table t1 extended; +drop table t1; +create table t1 (a int null, v varchar(100)) engine=maria checksum=1; +insert into t1 values(null, null), (1, "hello"); +checksum table t1; +checksum table t1 quick; +checksum table t1 extended; +drop table t1; + + +# +# These checksums will be different prefixes fixed sizes rows with one extra +# flag byte +# +create table t1 (a int null, v varchar(100)) engine=myisam checksum=1 row_format=fixed; +insert into t1 values(null, null), (1, "hello"); +checksum table t1; +checksum table t1 quick; +checksum table t1 extended; +drop table if exists t1; + +create table t1 (a int null, v varchar(100)) engine=innodb checksum=0 row_format=fixed; +insert into t1 values(null, null), (1, "hello"); +checksum table t1; +checksum table t1 quick; +checksum table t1 extended; +drop table t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index db08aad0df0..1139e7acc60 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -4087,5 +4087,38 @@ EXPLAIN SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci; DROP TABLE t1; +--echo # +--echo # Bug #702310: usage of 2 join buffers after ref access to an empty table +--echo # + +CREATE TABLE t1 (f1 int) ; +INSERT INTO t1 VALUES (9); + +CREATE TABLE t2 (f1 int); +INSERT INTO t2 VALUES (3),(7),(18); +INSERT INTO t2 VALUES (3),(7),(18); +INSERT INTO t2 VALUES (3),(7),(18); +INSERT INTO t2 VALUES (3),(7),(18); + +CREATE TABLE t3 (f1 int); +INSERT INTO t3 VALUES (17); + +CREATE TABLE t4 (f1 int PRIMARY KEY, f2 varchar(1024)) ; + +CREATE TABLE t5 (f1 int) ; +INSERT INTO t5 VALUES (20),(5); + +CREATE TABLE t6(f1 int); +INSERT INTO t6 VALUES (9),(7); + +SET SESSION join_buffer_size = 9000; + +EXPLAIN +SELECT STRAIGHT_JOIN * FROM t2, (t1 LEFT JOIN (t3,t4) ON t1.f1 = t4.f1), t5, t6; +SELECT STRAIGHT_JOIN * FROM t2, (t1 LEFT JOIN (t3,t4) ON t1.f1 = t4.f1), t5, t6; + +SET SESSION join_buffer_size = DEFAULT; + +DROP TABLE t1,t2,t3,t4,t5,t6; --echo End of 5.1 tests diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test index e4bc54a5538..e043ec4d143 100644 --- a/mysql-test/t/select_found.test +++ b/mysql-test/t/select_found.test @@ -54,7 +54,8 @@ CREATE TABLE t2 ( UNIQUE KEY e_n (email,name) ); -disable_query_log; +--disable_query_log +begin; let $1=200; let $2=0; while ($1) @@ -63,7 +64,8 @@ while ($1) eval INSERT INTO t2 VALUES ($2,'name$2','email$2'); dec $1; } -enable_query_log; +commit; +--enable_query_log EXPLAIN SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10; SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10; diff --git a/mysql-test/t/show_check-master.opt b/mysql-test/t/show_check-master.opt index aab832e2848..b6118d7db9f 100644 --- a/mysql-test/t/show_check-master.opt +++ b/mysql-test/t/show_check-master.opt @@ -1 +1 @@ ---log-output=table,file --log-slow-queries --log-long-format --log-queries-not-using-indexes --myisam-recover="" +--log-output=file --slow-query-log --log-long-format --log-queries-not-using-indexes --myisam-recover="" --general-log --general-log-file="foo" --slow-query-log-file="" --long_query_time=20 diff --git a/mysql-test/t/sp-big.test b/mysql-test/t/sp-big.test index 90a3a79dd53..6541e546e43 100644 --- a/mysql-test/t/sp-big.test +++ b/mysql-test/t/sp-big.test @@ -43,11 +43,13 @@ create table t2 like t1; let $1=8; --disable_query_log --disable_result_log +begin; while ($1) { eval insert into t1 select * from t1; dec $1; } +commit; --enable_result_log --enable_query_log select count(*) from t1; diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test index b006a36b8fd..3fe487808b3 100644 --- a/mysql-test/t/sp-destruct.test +++ b/mysql-test/t/sp-destruct.test @@ -18,6 +18,7 @@ call mtr.add_suppression("Stored routine .test...bug14233_[123].: invalid value # Backup proc table let $MYSQLD_DATADIR= `select @@datadir`; +flush table mysql.proc; --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 diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test index 326cc22f1cd..e4b6a5deefe 100644 --- a/mysql-test/t/sp_notembedded.test +++ b/mysql-test/t/sp_notembedded.test @@ -56,52 +56,6 @@ show warnings| drop procedure bug4902_2| # -# 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 -)| ---disable_warnings -drop procedure if exists bug3583| ---enable_warnings ---disable_warnings -drop procedure if exists bug3583| ---enable_warnings -create procedure bug3583() -begin - declare c int; - - select * from t1; - select count(*) into c from t1; - select c; -end| - -insert into t1 values ("x", 3), ("y", 5)| -set @x = @@query_cache_size| -set global query_cache_size = 10*1024*1024| - -flush status| -flush query cache| -show status like 'Qcache_hits'| -call bug3583()| -show status like 'Qcache_hits'| -call bug3583()| -call bug3583()| -show status like 'Qcache_hits'| - -set global query_cache_size = @x| -flush status| -flush query cache| -delete from t1| -drop procedure bug3583| -drop table t1| - - -# # Bug#6807 Stored procedure crash if CREATE PROCEDURE ... KILL QUERY # --disable_warnings diff --git a/mysql-test/t/sp_trans_log.test b/mysql-test/t/sp_trans_log.test index 5eccbf81fef..ed054a0ebc6 100644 --- a/mysql-test/t/sp_trans_log.test +++ b/mysql-test/t/sp_trans_log.test @@ -3,7 +3,7 @@ # 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 +--source include/have_binlog_format_mixed.inc delimiter |; diff --git a/mysql-test/t/ssl.test b/mysql-test/t/ssl.test index 936652eaa3d..f3f43bd6746 100644 --- a/mysql-test/t/ssl.test +++ b/mysql-test/t/ssl.test @@ -2,6 +2,8 @@ # and run a number of tests -- source include/have_ssl.inc +# Slow test, don't run during staging part +-- source include/not_staging.inc # Save the initial number of concurrent sessions --source include/count_sessions.inc diff --git a/mysql-test/t/ssl_compress.test b/mysql-test/t/ssl_compress.test index b6e11621bf6..3f0b6ddecbf 100644 --- a/mysql-test/t/ssl_compress.test +++ b/mysql-test/t/ssl_compress.test @@ -3,6 +3,7 @@ -- source include/have_ssl.inc -- source include/have_compress.inc +-- source include/not_staging.inc # Save the initial number of concurrent sessions --source include/count_sessions.inc diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 4c5ecbd9ee6..7ccc1390d41 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -337,8 +337,8 @@ select * from t12; drop table t11, t12, t2; #insert with subselects -CREATE TABLE t1 (x int); -create table t2 (a int); +CREATE TABLE t1 (x int) ENGINE=MyISAM; +create table t2 (a int) ENGINE=MyISAM; create table t3 (b int); insert into t2 values (1); insert into t3 values (1),(2); @@ -373,7 +373,7 @@ select * from t1; drop table t1, t2, t3; #replace with subselects -CREATE TABLE t1 (x int not null, y int, primary key (x)); +CREATE TABLE t1 (x int not null, y int, primary key (x)) ENGINE=MyISAM; create table t2 (a int); create table t3 (a int); insert into t2 values (1); @@ -811,7 +811,8 @@ create table t1 (a int, b int, index a (a,b)); create table t2 (a int, index a (a)); create table t3 (a int, b int, index a (a)); insert into t1 values (1,10), (2,20), (3,30), (4,40); -disable_query_log; +--disable_query_log +begin; # making table large enough let $1 = 10000; while ($1) @@ -819,7 +820,8 @@ while ($1) eval insert into t1 values (rand()*100000+200,rand()*100000); dec $1; } -enable_query_log; +commit; +--enable_query_log insert into t2 values (2), (3), (4), (5); insert into t3 values (10,3), (20,4), (30,5); select * from t2 where t2.a in (select a from t1); @@ -2607,7 +2609,8 @@ CREATE TABLE t1 (a int, b int auto_increment, PRIMARY KEY (b)); CREATE TABLE t2 (x int auto_increment, y int, z int, PRIMARY KEY (x), FOREIGN KEY (y) REFERENCES t1 (b)); -disable_query_log; +--disable_query_log +begin; let $1=3000; while ($1) { @@ -2621,7 +2624,8 @@ while ($1) } dec $1; } -enable_query_log; +commit; +--enable_query_log SET SESSION sort_buffer_size = 32 * 1024; SELECT SQL_NO_CACHE COUNT(*) @@ -3222,11 +3226,13 @@ insert into t1 values(1,1),(2,2), (3, 3); let $i=10000; --disable_query_log --disable_warnings +begin; while ($i) { eval insert into t2 values (-1 , $i/5000 + 1, '$i'); dec $i; } +commit; --enable_warnings --enable_query_log set session sort_buffer_size= 33*1024; @@ -3556,7 +3562,11 @@ 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); + +# disabled for now as this refers to old content of t2 +--disable_parsing INSERT INTO v2(a,b) VALUES (1,2); +--enable_parsing SELECT * FROM v1; CREATE VIEW v3 AS @@ -3758,6 +3768,45 @@ SELECT * FROM t2 UNION SELECT * FROM t2 DROP TABLE t1,t2; --enable_result_log +--echo # LP BUG#675248 - select->prep_where references on freed memory + +CREATE TABLE t1 (a int, b int); +insert into t1 values (1,1),(0,0); + +CREATE TABLE t2 (c int); +insert into t2 values (1),(2); + +prepare stmt1 from "select sum(a),(select sum(c) from t2 where table1.b) as sub +from t1 as table1 group by sub"; + +execute stmt1; + +deallocate prepare stmt1; + +prepare stmt1 from "select sum(a),(select sum(c) from t2 having table1.b) as sub +from t1 as table1"; + +execute stmt1; + +deallocate prepare stmt1; + +drop table t1,t2; + +--echo # +--echo # Bug LP#693935/#58727: Assertion failure with +--echo # a single row subquery returning more than one row +--echo # + +create table t1 (a char(1) charset utf8); +insert into t1 values ('a'), ('b'); +create table t2 (a binary(1)); +insert into t2 values ('x'), ('y'); + +-- error ER_SUBQUERY_NO_1_ROW +select * from t2 where a=(select a from t1) and a='x'; + +drop table t1,t2; + --echo End of 5.1 tests --echo # diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test index fab0a462157..8d403279a48 100644 --- a/mysql-test/t/subselect3.test +++ b/mysql-test/t/subselect3.test @@ -672,6 +672,8 @@ SELECT ROW(1,2) = (SELECT 1, 2), ROW(1,2) IN (SELECT 1, 2); # # Bug #37362 Crash in do_field_eq # +# Note that currently this test produces wrong output, see MBug#430669. +# CREATE TABLE t1 (a INT, b INT, c INT); INSERT INTO t1 VALUES (1,1,1), (1,1,1); diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test index b8ab655da42..bb97f246488 100644 --- a/mysql-test/t/subselect4.test +++ b/mysql-test/t/subselect4.test @@ -63,6 +63,30 @@ DROP TABLE t1,t2,t3; --echo End of 5.0 tests. +# +# Fix for LP#612894 +# Some aggregate functions (such as MIN MAX) work incorrectly in subqueries +# after getting NULL value +# + +CREATE TABLE t1 (col_int_nokey int(11) NOT NULL, col_varchar_nokey varchar(1) NOT NULL) engine=myisam; +INSERT INTO t1 VALUES (2,'s'),(0,'v'),(2,'s'); +CREATE TABLE t2 ( + pk int(11) NOT NULL AUTO_INCREMENT, + `col_int_key` int(11) NOT NULL, + col_varchar_key varchar(1) NOT NULL, + PRIMARY KEY (pk), + KEY `col_int_key` (`col_int_key`), + KEY `col_varchar_key` (`col_varchar_key`) +) ENGINE=MyISAM; +INSERT INTO t2 VALUES (4,10,'g'), (5,20,'v'); + +SELECT t1.col_int_nokey,(SELECT MIN( t2_a.col_int_key ) FROM t2 t2_a, t2 t2_b, t1 t1_a WHERE t1_a.col_varchar_nokey = t2_b.col_varchar_key and t1.col_int_nokey ) as sub FROM t1; + +SELECT t1.col_int_nokey,(SELECT MIN( t2_a.col_int_key ) +1 FROM t2 t2_a, t2 t2_b, t1 t1_a WHERE t1_a.col_varchar_nokey = t2_b.col_varchar_key and t1.col_int_nokey ) as sub FROM t1; + +DROP TABLE t1,t2; + --echo # --echo # Bug#54568: create view cause Assertion failed: 0, --echo # file .\item_subselect.cc, line 836 @@ -146,7 +170,6 @@ INSERT INTO t VALUES (''),(''),(''),(''),(''),(''),(''),(''),(''),(''),(''); SELECT * FROM (SELECT default(a) FROM t GROUP BY a) d; DROP TABLE t; - --echo # --echo # End of 5.1 tests. --echo # diff --git a/mysql-test/t/subselect_debug.test b/mysql-test/t/subselect_debug.test index 358705da4f2..ee515733afa 100644 --- a/mysql-test/t/subselect_debug.test +++ b/mysql-test/t/subselect_debug.test @@ -9,8 +9,9 @@ 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"; +SET @orig_debug=@@debug; +SET GLOBAL 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; +SET GLOBAL debug=@orig_debug; DROP TABLE t1; diff --git a/mysql-test/t/table_elim.test b/mysql-test/t/table_elim.test new file mode 100644 index 00000000000..5576362b396 --- /dev/null +++ b/mysql-test/t/table_elim.test @@ -0,0 +1,501 @@ +# +# Table elimination (MWL#17) tests +# +--disable_warnings +drop table if exists t0, t1, t2, t3, t4, t5, t6; +drop view if exists v1, v2; +--enable_warnings + +create table t1 (a int); +insert into t1 values (0),(1),(2),(3); +create table t0 as select * from t1; + +create table t2 (a int primary key, b int) + as select a, a as b from t1 where a in (1,2); + +create table t3 (a int primary key, b int) + as select a, a as b from t1 where a in (1,3); + +--echo # This will be eliminated: +explain select t1.a from t1 left join t2 on t2.a=t1.a; +explain extended select t1.a from t1 left join t2 on t2.a=t1.a; + +select t1.a from t1 left join t2 on t2.a=t1.a; + +--echo # This will not be eliminated as t2.b is in in select list: +explain select * from t1 left join t2 on t2.a=t1.a; + +--echo # This will not be eliminated as t2.b is in in order list: +explain select t1.a from t1 left join t2 on t2.a=t1.a order by t2.b; + +--echo # This will not be eliminated as t2.b is in group list: +explain select t1.a from t1 left join t2 on t2.a=t1.a group by t2.b; + +--echo # This will not be eliminated as t2.b is in the WHERE +explain select t1.a from t1 left join t2 on t2.a=t1.a where t2.b < 3 or t2.b is null; + +--echo # Elimination of multiple tables: +explain select t1.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a; + +--echo # Elimination of multiple tables (2): +explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and t3.a=t1.a; + +--echo # Elimination when done within an outer join nest: +explain extended +select t0.* +from + t0 left join (t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and + t3.a=t1.a) on t0.a=t1.a; + +--echo # Elimination with aggregate functions +explain select count(*) from t1 left join t2 on t2.a=t1.a; +explain select count(1) from t1 left join t2 on t2.a=t1.a; +explain select count(1) from t1 left join t2 on t2.a=t1.a group by t1.a; + +--echo This must not use elimination: +explain select count(1) from t1 left join t2 on t2.a=t1.a group by t2.a; + +drop table t0, t1, t2, t3; + +# This will stand for elim_facts +create table t0 ( id integer, primary key (id)); + +# Attribute1, non-versioned +create table t1 ( + id integer, + attr1 integer, + primary key (id), + key (attr1) +); + +# Attribute2, time-versioned +create table t2 ( + id integer, + attr2 integer, + fromdate date, + primary key (id, fromdate), + key (attr2,fromdate) +); + +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t0 select A.id + 10*B.id from t0 A, t0 B where B.id > 0; + +insert into t1 select id, id from t0; +insert into t2 select id, id, date_add('2009-06-22', interval id day) from t0; +insert into t2 select id, id+1, date_add('2008-06-22', interval id day) from t0; + +create view v1 as +select + f.id, a1.attr1, a2.attr2 +from + t0 f + left join t1 a1 on a1.id=f.id + left join t2 a2 on a2.id=f.id and + a2.fromdate=(select MAX(fromdate) from + t2 where id=a2.id); +create view v2 as +select + f.id, a1.attr1, a2.attr2 +from + t0 f + left join t1 a1 on a1.id=f.id + left join t2 a2 on a2.id=f.id and + a2.fromdate=(select MAX(fromdate) from + t2 where id=f.id); + +--echo This should use one table: +explain select id from v1 where id=2; +--echo This should use one table: +explain extended select id from v1 where id in (1,2,3,4); +--echo This should use facts and a1 tables: +explain extended select id from v1 where attr1 between 12 and 14; +--echo This should use facts, a2 and its subquery: +explain extended select id from v1 where attr2 between 12 and 14; + +# Repeat for v2: + +--echo This should use one table: +explain select id from v2 where id=2; +--echo This should use one table: +explain extended select id from v2 where id in (1,2,3,4); +--echo This should use facts and a1 tables: +explain extended select id from v2 where attr1 between 12 and 14; +--echo This should use facts, a2 and its subquery: +explain extended select id from v2 where attr2 between 12 and 14; + +drop view v1, v2; +drop table t0, t1, t2; + +# +# Tests for the code that uses t.keypartX=func(t.keypartY) equalities to +# make table elimination inferences +# +create table t1 (a int); +insert into t1 values (0),(1),(2),(3); + +create table t2 (pk1 int, pk2 int, pk3 int, col int, primary key(pk1, pk2, pk3)); +insert into t2 select a,a,a,a from t1; + +--echo This must use only t1: +explain select t1.* from t1 left join t2 on t2.pk1=t1.a and + t2.pk2=t2.pk1+1 and + t2.pk3=t2.pk2+1; + +--echo This must use only t1: +explain select t1.* from t1 left join t2 on t2.pk1=t1.a and + t2.pk3=t2.pk1+1 and + t2.pk2=t2.pk3+1; + +--echo This must use both: +explain select t1.* from t1 left join t2 on t2.pk1=t1.a and + t2.pk3=t2.pk1+1 and + t2.pk2=t2.pk3+t2.col; + +--echo This must use only t1: +explain select t1.* from t1 left join t2 on t2.pk2=t1.a and + t2.pk1=t2.pk2+1 and + t2.pk3=t2.pk1; + +drop table t1, t2; +# +# Check that equality propagation is taken into account +# +create table t1 (pk int primary key, col int); +insert into t1 values (1,1),(2,2); + +create table t2 like t1; +insert into t2 select * from t1; + +create table t3 like t1; +insert into t3 select * from t1; + +explain +select t1.* from t1 left join ( t2 left join t3 on t3.pk=t2.col) on t2.col=t1.col; + +explain +select t1.*, t2.* from t1 left join (t2 left join t3 on t3.pk=t2.col) on t2.pk=t1.col; + +explain select t1.* +from + t1 left join ( t2 left join t3 on t3.pk=t2.col or t3.pk=t2.col) + on t2.col=t1.col or t2.col=t1.col; + +explain select t1.*, t2.* +from + t1 left join + (t2 left join t3 on t3.pk=t2.col or t3.pk=t2.col) + on t2.pk=t1.col or t2.pk=t1.col; + +drop table t1, t2, t3; + +--echo # +--echo # Check things that look like functional dependencies but really are not +--echo # + +create table t1 (a char(10) character set latin1 collate latin1_general_ci primary key); +insert into t1 values ('foo'); +insert into t1 values ('bar'); + +create table t2 (a char(10) character set latin1 collate latin1_general_cs primary key); +insert into t2 values ('foo'); +insert into t2 values ('FOO'); + +-- echo this must not use table elimination: +explain select t1.* from t1 left join t2 on t2.a='foo' collate latin1_general_ci; + +-- echo this must not use table elimination: +explain select t1.* from t1 left join t2 on t2.a=t1.a collate latin1_general_ci; +drop table t1,t2; + +create table t1 (a int primary key); +insert into t1 values (1),(2); +create table t2 (a char(10) primary key); +insert into t2 values ('1'),('1.0'); +-- echo this must not use table elimination: +explain select t1.* from t1 left join t2 on t2.a=1; +-- echo this must not use table elimination: +explain select t1.* from t1 left join t2 on t2.a=t1.a; + +drop table t1, t2; +# partial unique keys do not work at the moment, although they are able to +# provide one-match guarantees: +create table t1 (a char(10) primary key); +insert into t1 values ('foo'),('bar'); + +create table t2 (a char(10), unique key(a(2))); +insert into t2 values ('foo'),('bar'); + +explain select t1.* from t1 left join t2 on t2.a=t1.a; + +drop table t1, t2; + +--echo # +--echo # check UPDATE/DELETE that look like they could be eliminated +--echo # +create table t1 (a int primary key, b int); +insert into t1 values (1,1),(2,2),(3,3); + +create table t2 like t1; +insert into t2 select * from t1; +update t1 left join t2 using (a) set t2.a=t2.a+100; +select * from t1; +select * from t2; + +delete from t2; +insert into t2 select * from t1; + +delete t2 from t1 left join t2 using (a); +select * from t1; +select * from t2; +drop table t1, t2; + +--echo # +--echo # Tests with various edge-case ON expressions +--echo # +create table t1 (a int, b int, c int, d int); +insert into t1 values (0,0,0,0),(1,1,1,1),(2,2,2,2),(3,3,3,3); + +create table t2 (pk int primary key, b int) + as select a as pk, a as b from t1 where a in (1,2); + +create table t3 (pk1 int, pk2 int, b int, unique(pk1,pk2)); +insert into t3 select a as pk1, a as pk2, a as b from t1 where a in (1,3); + +explain select t1.a from t1 left join t2 on t2.pk=t1.a and t2.b<t1.b; +explain select t1.a from t1 left join t2 on t2.pk=t1.a or t2.b<t1.b; +explain select t1.a from t1 left join t2 on t2.b<t1.b or t2.pk=t1.a; + +explain select t1.a from t1 left join t2 on t2.pk between 10 and 20; +explain select t1.a from t1 left join t2 on t2.pk between 0.5 and 1.5; +explain select t1.a from t1 left join t2 on t2.pk between 10 and 10; + +explain select t1.a from t1 left join t2 on t2.pk in (10); +explain select t1.a from t1 left join t2 on t2.pk in (t1.a); + +explain select t1.a from t1 left join t2 on TRUE; + +explain select t1.a from t1 left join t3 on t3.pk1=t1.a and t3.pk2 IS NULL; + +drop table t1,t2,t3; + +--echo # +--echo # Multi-equality tests +--echo # +create table t1 (a int, b int, c int, d int); +insert into t1 values (0,0,0,0),(1,1,1,1),(2,2,2,2),(3,3,3,3); + +create table t2 (pk int primary key, b int, c int); +insert into t2 select a,a,a from t1 where a in (1,2); + +explain +select t1.* +from t1 left join t2 on t2.pk=t2.c and t2.b=t1.a and t1.a=t1.b and t2.c=t2.b +where t1.d=1; + +explain +select t1.* +from + t1 + left join + t2 + on (t2.pk=t2.c and t2.b=t1.a and t1.a=t1.b and t2.c=t2.b) or + (t2.pk=t2.c and t2.b=t1.a and t1.a=t1.b and t2.c=t2.b) +where t1.d=1; + +--echo #This can't be eliminated: +explain +select t1.* +from + t1 + left join + t2 + on (t2.pk=t2.c and t2.b=t1.a and t2.c=t1.b) or + (t2.pk=t2.c and t1.a=t1.b and t2.c=t1.b) +where t1.d=1; + +explain +select t1.* +from + t1 + left join + t2 + on (t2.pk=t2.c and t2.b=t1.a and t2.c=t1.b) or + (t2.pk=t2.c and t2.c=t1.b) +; + +explain +select t1.* +from t1 left join t2 on t2.pk=3 or t2.pk= 4; + +explain +select t1.* +from t1 left join t2 on t2.pk=3 or t2.pk= 3; + +explain +select t1.* +from t1 left join t2 on (t2.pk=3 and t2.b=3) or (t2.pk= 4 and t2.b=3); + +drop table t1, t2; + +--echo # +--echo # LPBUG#523593: Running RQG optimizer_no_subquery crashes MariaDB +--echo # + +CREATE TABLE t1 ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + `col_int_nokey` int(11) DEFAULT NULL, + `col_int_key` int(11) DEFAULT NULL, + `col_date_key` date DEFAULT NULL, + `col_date_nokey` date DEFAULT NULL, + `col_time_key` time DEFAULT NULL, + `col_time_nokey` time DEFAULT NULL, + `col_datetime_key` datetime DEFAULT NULL, + `col_datetime_nokey` datetime DEFAULT NULL, + `col_varchar_key` varchar(1) DEFAULT NULL, + `col_varchar_nokey` varchar(1) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `col_int_key` (`col_int_key`), + KEY `col_date_key` (`col_date_key`), + KEY `col_time_key` (`col_time_key`), + KEY `col_datetime_key` (`col_datetime_key`), + KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`) +); +CREATE TABLE t2 LIKE t1; + +INSERT INTO t1 VALUES + (10,7,8,NULL,NULL,'01:27:35','01:27:35','2002-02-26 06:14:37','2002-02-26 06:14:37','v','v'), + (11,1,9,'2006-06-14','2006-06-14','19:48:31','19:48:31','1900-01-01 00:00:00','1900-01-01 00:00:00','r','r'); +INSERT INTO t2 SELECT * FROM t1; + +SELECT table2.col_int_key AS field1 +FROM ( + t2 AS table1 + RIGHT OUTER JOIN + ( + ( t1 AS table2 STRAIGHT_JOIN + t1 AS table3 ON ( + (table3.col_varchar_nokey = table2.col_varchar_key ) AND + (table3.pk = table2.col_int_key)) + ) + ) ON + ( + (table3.col_varchar_key = table2.col_varchar_key) OR + (table3.col_int_key = table2.pk) + ) +) +HAVING field1 < 216; + +DROP TABLE t1, t2; + + +--echo # +--echo # LPBUG#524025 Running RQG outer_join test leads to crash +--echo # + +CREATE TABLE t0 ( + pk int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (pk) +); + +CREATE TABLE t1 ( + col_int int(11) DEFAULT NULL, + col_int_key int(11) DEFAULT NULL, + pk int(11) NOT NULL AUTO_INCREMENT, + col_varchar_10_latin1 varchar(10) DEFAULT NULL, + PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (5,5,1,'t'), (NULL,NULL,2,'y'); + +CREATE TABLE t2 ( + col_int int(11) DEFAULT NULL +); +INSERT INTO t2 VALUES (8), (4); + +CREATE TABLE t3 ( + pk int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (pk) +); +INSERT INTO t3 VALUES (1),(8); + +CREATE TABLE t4 ( + pk int(11) NOT NULL AUTO_INCREMENT, + col_varchar_1024_latin1_key varchar(1024) DEFAULT NULL, + col_int int(11) DEFAULT NULL, + PRIMARY KEY (pk) +); +INSERT INTO t4 VALUES (1,'o',1), (2,'w',2); + +CREATE TABLE t5 ( + col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, + col_varchar_1024_latin1_key varchar(1024) DEFAULT NULL, + col_varchar_10_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, + pk int(11) NOT NULL AUTO_INCREMENT, + col_int_key int(11) DEFAULT NULL, + PRIMARY KEY (pk) +); +INSERT INTO t5 VALUES ('k','a','z',1,2),('x','a','w',2,7); + +CREATE TABLE t6 ( + col_int int(11) DEFAULT NULL, + col_int_key int(11) DEFAULT NULL +); +INSERT INTO t6 VALUES (6,1),(8,3); + +SELECT + table3.col_int AS field1, + table1.col_int AS field2, + table1.col_int_key AS field3, + table1.pk AS field4, + table1.col_int AS field5, + table2.col_int AS field6 +FROM + t1 AS table1 + LEFT OUTER JOIN + t4 AS table2 + LEFT JOIN t6 AS table3 + RIGHT JOIN t3 AS table4 + LEFT JOIN t5 AS table5 ON table4.pk = table5.pk + LEFT JOIN t0 AS table6 ON table5.col_int_key = table6.pk + ON table3.col_int_key = table5.pk + ON table2.col_varchar_1024_latin1_key = table5.col_varchar_10_utf8_key + LEFT JOIN t6 AS table7 ON table2.pk = table7.col_int + ON table1.col_varchar_10_latin1 = table5.col_varchar_1024_latin1_key + LEFT JOIN t2 AS table8 ON table3.col_int = table8.col_int +WHERE + table1.col_int_key < table2.pk +HAVING + field4 != 6; + +drop table t0,t1,t2,t3,t4,t5,t6; + +--echo # +--echo # BUG#675118: Elimination of a table results in an invalid execution plan +--echo # +CREATE TABLE t1 (f1 int(11), PRIMARY KEY (f1)) ; + +CREATE TABLE t2 (f4 varchar(1024), KEY (f4)) ; +INSERT IGNORE INTO t2 VALUES ('xcddwntkbxyorzdv'), + ('cnxxcddwntkbxyor'),('r'),('r'), ('did'),('I'),('when'), + ('hczkfqjeggivdvac'),('e'),('okay'),('up'); + +CREATE TABLE t3 (f4 varchar(1024), f1 int(11), f2 int(11)) ; +INSERT IGNORE INTO t3 VALUES ('f','4','0'),('n','5','-996540416'); + +CREATE TABLE t4 (f1 int(11), f3 varchar(10)) ; +INSERT IGNORE INTO t4 VALUES ('8','n'),('9','nwzcerzsgx'),('10','c'); + +CREATE TABLE t5 (f5 int(11), KEY (f5)) ; + +EXPLAIN +SELECT t3.f2 +FROM t2 +LEFT JOIN t3 +LEFT JOIN t4 +LEFT JOIN t1 ON t4.f1 = t1.f1 +JOIN t5 ON t4.f3 ON t3.f1 = t5.f5 ON t2.f4 = t3.f4 +WHERE t3.f2 ; +--echo # ^^ The above must not produce a QEP of t3,t5,t2,t4 +--echo # as that violates the "no interleaving of outer join nests" rule. + +DROP TABLE t1,t2,t3,t4,t5; + diff --git a/mysql-test/t/table_elim_debug.test b/mysql-test/t/table_elim_debug.test new file mode 100644 index 00000000000..9f793169e4f --- /dev/null +++ b/mysql-test/t/table_elim_debug.test @@ -0,0 +1,27 @@ +# +# Table elimination (MWL#17) tests that need debug build +# +--source include/have_debug.inc + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +# Check if optimizer_switch works + +create table t1 (a int); +insert into t1 values (0),(1),(2),(3); + +create table t2 (a int primary key, b int) + as select a, a as b from t1 where a in (1,2); + +explain select t1.a from t1 left join t2 on t2.a=t1.a; + +set optimizer_switch='table_elimination=off'; +explain select t1.a from t1 left join t2 on t2.a=t1.a; +set optimizer_switch='table_elimination=on'; +explain select t1.a from t1 left join t2 on t2.a=t1.a; +set optimizer_switch='table_elimination=default'; +explain select t1.a from t1 left join t2 on t2.a=t1.a; + +drop table t1, t2; diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index bcbca4d2139..a968e146d20 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1767,68 +1767,6 @@ drop table t1, t2, t3; disconnect addconroot1; disconnect addconroot2; disconnect addconwithoutdb; -# -# Bug #26162: Trigger DML ignores low_priority_updates setting -# -CREATE TABLE t1 (id INTEGER); -CREATE TABLE t2 (id INTEGER); - -INSERT INTO t2 VALUES (1),(2); - -# trigger that produces the high priority insert, but should be low, adding -# LOW_PRIORITY fixes this -CREATE TRIGGER t1_test AFTER INSERT ON t1 FOR EACH ROW - INSERT INTO t2 VALUES (new.id); - -CONNECT (rl_holder, localhost, root,,); -CONNECT (rl_acquirer, localhost, root,,); -CONNECT (wl_acquirer, localhost, root,,); -CONNECT (rl_contender, localhost, root,,); - -CONNECTION rl_holder; -SELECT GET_LOCK('B26162',120); - -CONNECTION rl_acquirer; ---send -SELECT 'rl_acquirer', GET_LOCK('B26162',120), id FROM t2 WHERE id = 1; - -CONNECTION wl_acquirer; -SET SESSION LOW_PRIORITY_UPDATES=1; -SET GLOBAL LOW_PRIORITY_UPDATES=1; -#need to wait for rl_acquirer to lock on the B26162 lock -sleep 2; ---send -INSERT INTO t1 VALUES (5); - -CONNECTION rl_contender; -# must not "see" the row inserted by the INSERT (as it must run before the -# INSERT) ---send -SELECT 'rl_contender', id FROM t2 WHERE id > 1; - -CONNECTION rl_holder; -#need to wait for wl_acquirer and rl_contender to lock on t2 -sleep 2; -SELECT RELEASE_LOCK('B26162'); - -CONNECTION rl_acquirer; ---reap -SELECT RELEASE_LOCK('B26162'); -CONNECTION wl_acquirer; ---reap -CONNECTION rl_contender; ---reap - -CONNECTION default; -DISCONNECT rl_acquirer; -DISCONNECT wl_acquirer; -DISCONNECT rl_contender; -DISCONNECT rl_holder; - -DROP TRIGGER t1_test; -DROP TABLE t1,t2; -SET SESSION LOW_PRIORITY_UPDATES=DEFAULT; -SET GLOBAL LOW_PRIORITY_UPDATES=DEFAULT; --echo --echo Bug#28502 Triggers that update another innodb table will block --echo on X lock unnecessarily diff --git a/mysql-test/t/trigger_notembedded.test b/mysql-test/t/trigger_notembedded.test index 387944ffb47..f595f195dcc 100644 --- a/mysql-test/t/trigger_notembedded.test +++ b/mysql-test/t/trigger_notembedded.test @@ -875,6 +875,79 @@ DROP TABLE t1; DROP DATABASE mysqltest_db1; USE test; +# +# Bug #26162: Trigger DML ignores low_priority_updates setting +# +CREATE TABLE t1 (id INTEGER); +CREATE TABLE t2 (id INTEGER); + +INSERT INTO t2 VALUES (1),(2); + +# trigger that produces the high priority insert, but should be low, adding +# LOW_PRIORITY fixes this +CREATE TRIGGER t1_test AFTER INSERT ON t1 FOR EACH ROW + INSERT INTO t2 VALUES (new.id); + +CONNECT (rl_holder, localhost, root,,); +CONNECT (rl_acquirer, localhost, root,,); +CONNECT (wl_acquirer, localhost, root,,); +CONNECT (rl_contender, localhost, root,,); + +CONNECTION rl_holder; +SELECT GET_LOCK('B26162',120); + +CONNECTION rl_acquirer; +let $rl_acquirer_thread_id = `SELECT @@pseudo_thread_id`; +--send +SELECT 'rl_acquirer', GET_LOCK('B26162',120), id FROM t2 WHERE id = 1; + +CONNECTION wl_acquirer; +let $wl_acquirer_thread_id = `SELECT @@pseudo_thread_id`; +SET SESSION LOW_PRIORITY_UPDATES=1; +SET GLOBAL LOW_PRIORITY_UPDATES=1; +#need to wait for rl_acquirer to lock on the B26162 lock +let $wait_condition= + SELECT STATE = 'User lock' FROM INFORMATION_SCHEMA.PROCESSLIST + WHERE ID = $rl_acquirer_thread_id; +--source include/wait_condition.inc +--send +INSERT INTO t1 VALUES (5); + +CONNECTION rl_contender; +# Wait until wl_acquirer is waiting for the read lock on t2 to be released. +let $wait_condition= + SELECT STATE = 'Locked' FROM INFORMATION_SCHEMA.PROCESSLIST + WHERE ID = $wl_acquirer_thread_id; +--source include/wait_condition.inc +# must not "see" the row inserted by the INSERT (as it must run before the +# INSERT) +--send +SELECT 'rl_contender', id FROM t2 WHERE id > 1; + +CONNECTION rl_holder; +#need to wait for wl_acquirer and rl_contender to lock on t2 +sleep 2; +SELECT RELEASE_LOCK('B26162'); + +CONNECTION rl_acquirer; +--reap +SELECT RELEASE_LOCK('B26162'); +CONNECTION wl_acquirer; +--reap +CONNECTION rl_contender; +--reap + +CONNECTION default; +DISCONNECT rl_acquirer; +DISCONNECT wl_acquirer; +DISCONNECT rl_contender; +DISCONNECT rl_holder; + +DROP TRIGGER t1_test; +DROP TABLE t1,t2; +SET SESSION LOW_PRIORITY_UPDATES=DEFAULT; +SET GLOBAL LOW_PRIORITY_UPDATES=DEFAULT; + --echo End of 5.0 tests. # diff --git a/mysql-test/t/type_bit_innodb.test b/mysql-test/t/type_bit_innodb.test index e7e66da8927..dc5947e25e1 100644 --- a/mysql-test/t/type_bit_innodb.test +++ b/mysql-test/t/type_bit_innodb.test @@ -41,7 +41,7 @@ create table t1 (a bit) engine=innodb; insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001'); select hex(a) from t1; # It is not deterministic which duplicate will be seen first ---replace_regex /(.*Duplicate entry )'.*'( for key.*)/\1''\2/ +--replace_regex /entry '(.*)' for/entry '' for/ --error ER_DUP_ENTRY alter table t1 add unique (a); drop table t1; diff --git a/mysql-test/t/udf-master.opt b/mysql-test/t/udf-master.opt deleted file mode 100644 index 7d8786c156a..00000000000 --- a/mysql-test/t/udf-master.opt +++ /dev/null @@ -1 +0,0 @@ -$UDF_EXAMPLE_LIB_OPT diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 9295969c05f..eff35d9805f 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -14,26 +14,26 @@ drop table if exists t1; # Create the example functions from udf_example # ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION myfunc_double RETURNS REAL SONAME "$UDF_EXAMPLE_LIB"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION myfunc_double RETURNS REAL SONAME "$UDF_EXAMPLE_SO"; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB --error ER_CANT_FIND_DL_ENTRY -eval CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB"; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB"; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION sequence RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB"; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION lookup RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION sequence RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION lookup RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB eval CREATE FUNCTION reverse_lookup - RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB + RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB eval CREATE AGGREGATE FUNCTION avgcost - RETURNS REAL SONAME "$UDF_EXAMPLE_LIB"; + RETURNS REAL SONAME "$UDF_EXAMPLE_SO"; --error ER_CANT_INITIALIZE_UDF select myfunc_double(); @@ -210,14 +210,14 @@ 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"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; DROP FUNCTION metaphon; DROP FUNCTION metaphon; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; --error ER_UDF_EXISTS CREATE FUNCTION metaphon(a int) RETURNS int @@ -248,8 +248,8 @@ DROP FUNCTION avgcost; # the UDF # select * from mysql.func; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION is_const RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION is_const RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; select IS_const(3); @@ -263,8 +263,8 @@ select is_const(3); # # Bug#18761: constant expression as UDF parameters not passed in as constant # ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION is_const RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION is_const RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; select is_const(3) as const, @@ -303,14 +303,14 @@ drop function if exists is_const; # Bug #25382: Passing NULL to an UDF called from stored procedures # crashes server # ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION myfunc_double RETURNS REAL SONAME "$UDF_EXAMPLE_LIB"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION myfunc_double RETURNS REAL SONAME "$UDF_EXAMPLE_SO"; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO"; delimiter //; create function f1(p1 varchar(255)) @@ -345,29 +345,6 @@ drop function myfunc_double; drop function myfunc_int; # -# Bug #28921: Queries containing UDF functions are cached -# - ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; -create table t1 (a char); - -set GLOBAL query_cache_size=1355776; -reset query cache; - -select metaphon('MySQL') from t1; -show status like "Qcache_hits"; -show status like "Qcache_queries_in_cache"; - -select metaphon('MySQL') from t1; -show status like "Qcache_hits"; -show status like "Qcache_queries_in_cache"; - -drop table t1; -drop function metaphon; -set GLOBAL query_cache_size=default; - -# # Bug#28318 CREATE FUNCTION (UDF) requires a schema # @@ -377,8 +354,8 @@ DROP DATABASE IF EXISTS mysqltest; CREATE DATABASE mysqltest; USE mysqltest; DROP DATABASE mysqltest; ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; DROP FUNCTION metaphon; USE test; @@ -406,8 +383,8 @@ insert into const_len_bug values(str_const, result, ""); END | DELIMITER ;| ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION check_const_len RETURNS string SONAME "$UDF_EXAMPLE_LIB"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION check_const_len RETURNS string SONAME "$UDF_EXAMPLE_SO"; CALL check_const_len_sp("foo"); @@ -423,8 +400,8 @@ DROP TABLE const_len_bug; # Bug #30355: Incorrect ordering of UDF results # ---replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB -eval CREATE FUNCTION sequence RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB"; +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION sequence RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO"; CREATE TABLE t1 (a INT); CREATE TABLE t2 (a INT PRIMARY KEY); INSERT INTO t1 VALUES (4),(3),(2),(1); diff --git a/mysql-test/t/udf_query_cache.test b/mysql-test/t/udf_query_cache.test new file mode 100644 index 00000000000..b0037973631 --- /dev/null +++ b/mysql-test/t/udf_query_cache.test @@ -0,0 +1,36 @@ +--source include/have_udf.inc +--source include/have_query_cache.inc +# +# To run this tests the "sql/udf_example.c" need to be compiled into +# udf_example.so and LD_LIBRARY_PATH should be setup to point out where +# the library are. +# + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Bug #28921: Queries containing UDF functions are cached +# + +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; +create table t1 (a char); + +set GLOBAL query_cache_size=1355776; +reset query cache; +flush status; + +select metaphon('MySQL') from t1; +show status like "Qcache_hits"; +show status like "Qcache_queries_in_cache"; + +select metaphon('MySQL') from t1; +show status like "Qcache_hits"; +show status like "Qcache_queries_in_cache"; + +drop table t1; +drop function metaphon; +set GLOBAL query_cache_size=default; + diff --git a/mysql-test/t/union-master.opt b/mysql-test/t/union-master.opt index 3eb98fc3d6b..4ddf5c3734a 100644 --- a/mysql-test/t/union-master.opt +++ b/mysql-test/t/union-master.opt @@ -1 +1 @@ ---log-slow-queries --log-long-format --log-queries-not-using-indexes +--slow-query-log --log-long-format --log-queries-not-using-indexes diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index c8d5ea0f8e5..34bb4afc41c 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -1155,5 +1155,13 @@ SELECT * FROM t2 UNION SELECT * FROM t2 DROP TABLE t1,t2; +# +# lp:732124 union + limit returns wrong result +# +create table t1 (a int); +insert into t1 values (10),(10),(10),(2),(3),(4),(5),(6),(7),(8),(9),(1),(10); +--sorted_result +select a from t1 where false UNION select a from t1 limit 8; +drop table t1; --echo End of 5.1 tests diff --git a/mysql-test/t/unsafe_binlog_innodb-master.opt b/mysql-test/t/unsafe_binlog_innodb-master.opt index 9581c225d6d..d5ecd2ed9a5 100644 --- a/mysql-test/t/unsafe_binlog_innodb-master.opt +++ b/mysql-test/t/unsafe_binlog_innodb-master.opt @@ -1 +1 @@ ---innodb_locks_unsafe_for_binlog=true --innodb_lock_wait_timeout=1 +--loose-innodb_locks_unsafe_for_binlog=true --loose-innodb_lock_wait_timeout=1 diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index a7b9a1531ff..a8c875ef764 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -41,11 +41,9 @@ create table `txu#p#p1` (s1 int); insert into `txu#p#p1` values (1); --error 1146 select * from `txu@0023p@0023p1`; +--error ER_TABLE_EXISTS_ERROR 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 # @@ -169,5 +167,16 @@ USE `#mysql50#.`; --error ER_WRONG_DB_NAME USE `#mysql50#../blablabla`; +# +# Test of Bug #56441: mysql_upgrade 5.0->5.1 fails for tables with long names +# +copy_file $MYSQL_TEST_DIR/std_data/long_table_name.MYI $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres#9120761097220077376#cio_com.MYI; +copy_file $MYSQL_TEST_DIR/std_data/long_table_name.MYD $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres#9120761097220077376#cio_com.MYD; +copy_file $MYSQL_TEST_DIR/std_data/long_table_name.frm $MYSQLD_DATADIR/test/ltoriaeinnovacionendesarrolloempres#9120761097220077376#cio_com.frm; +show full tables; +rename table `#mysql50#ltoriaeinnovacionendesarrolloempres#9120761097220077376#cio_com` to `ltoriaeinnovacionendesarrolloempres#9120761097220077376#cio_com`; +show full tables; +drop table `ltoriaeinnovacionendesarrolloempres#9120761097220077376#cio_com`; + --echo # End of 5.1 tests diff --git a/mysql-test/t/variables-big.test b/mysql-test/t/variables-big.test index 6c357bb6e54..85121fd8f6d 100644 --- a/mysql-test/t/variables-big.test +++ b/mysql-test/t/variables-big.test @@ -3,6 +3,10 @@ # --source include/big_test.inc +# The test would allocate and initialize 5GB of memory +# if compiled with debug. It can take a lot of time +# of for paging/swapping. +--source include/not_debug.inc # # Bug#27322 failure to allocate transaction_prealloc_size causes crash @@ -38,18 +42,24 @@ --disable_warnings SET SESSION transaction_prealloc_size=1024*1024*1024*1; --replace_column 1 <Id> 3 <Host> 6 <Time> +# Embedded server is hardcoded to show "Writing to net" as STATE. +--replace_result "Writing to net" "NULL" SHOW PROCESSLIST; SET SESSION transaction_prealloc_size=1024*1024*1024*2; --replace_column 1 <Id> 3 <Host> 6 <Time> +--replace_result "Writing to net" "NULL" SHOW PROCESSLIST; SET SESSION transaction_prealloc_size=1024*1024*1024*3; --replace_column 1 <Id> 3 <Host> 6 <Time> +--replace_result "Writing to net" "NULL" SHOW PROCESSLIST; SET SESSION transaction_prealloc_size=1024*1024*1024*4; --replace_column 1 <Id> 3 <Host> 6 <Time> +--replace_result "Writing to net" "NULL" SHOW PROCESSLIST; SET SESSION transaction_prealloc_size=1024*1024*1024*5; --replace_column 1 <Id> 3 <Host> 6 <Time> +--replace_result "Writing to net" "NULL" SHOW PROCESSLIST; --enable_warnings diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index d00b77e64c0..ec6ed5702ee 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -28,14 +28,13 @@ 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; -set @my_query_cache_limit =@@global.query_cache_limit; -set @my_query_cache_type =@@global.query_cache_type; set @my_rpl_recovery_rank =@@global.rpl_recovery_rank; 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_delay_key_write =@@global.delay_key_write; set @my_join_buffer_size =@@global.join_buffer_size; # case insensitivity tests (new in 5.0) set @`test`=1; @@ -137,7 +136,6 @@ 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'; @@ -254,8 +252,6 @@ set storage_engine=UNKNOWN_TABLE_TYPE; --error ER_WRONG_VALUE_FOR_VAR set storage_engine=MERGE, big_tables=2; show local variables like 'storage_engine'; ---error ER_GLOBAL_VARIABLE -set SESSION query_cache_size=10000; --error ER_NO_DEFAULT set GLOBAL storage_engine=DEFAULT; --error ER_UNKNOWN_CHARACTER_SET @@ -333,9 +329,6 @@ set myisam_sort_buffer_size=100; set global net_buffer_length=100; set net_read_timeout=100; set net_write_timeout=100; -set global query_cache_limit=100; -set global query_cache_size=100; -set global query_cache_type=demand; set read_buffer_size=100; set read_rnd_buffer_size=100; set global rpl_recovery_rank=100; @@ -369,7 +362,7 @@ set global table_open_cache=100; set storage_engine=myisam; set global thread_cache_size=100; set timestamp=1, timestamp=default; -set tmp_table_size=100; +set tmp_table_size=1024; set tx_isolation="READ-COMMITTED"; set wait_timeout=100; set log_warnings=1; @@ -842,14 +835,13 @@ 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; -set global query_cache_limit =@my_query_cache_limit; -set global query_cache_type =@my_query_cache_type; set global rpl_recovery_rank =@my_rpl_recovery_rank; 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 max_allowed_packet = default; +set global delay_key_write =@my_delay_key_write; set global join_buffer_size =@my_join_buffer_size; # diff --git a/mysql-test/t/variables_debug_notembedded.test b/mysql-test/t/variables_debug_notembedded.test new file mode 100644 index 00000000000..2d6b53b16ab --- /dev/null +++ b/mysql-test/t/variables_debug_notembedded.test @@ -0,0 +1,34 @@ +# +# Checks that assigning variable 'debug' in one session has no influence on +# other session. (BUG#45632 of bugs.mysql.com) +# +# (this will not work with embedded server because mysqltest_embedded uses the +# same thread for all connections) +# +--source include/have_debug.inc +--source include/not_embedded.inc + +connect(con1,localhost,root,,test,,); +connect(con2,localhost,root,,test,,); + +# makes output independant of current debug status +connection con1; +set session debug="t"; +show session variables like 'debug'; +connection con2; +set session debug="t"; +show session variables like 'debug'; + +# checks influence one session debug variable on another +connection con1; +set session debug="d:t"; +show session variables like 'debug'; +connection con2; +show session variables like 'debug'; + +disconnect con1; +disconnect con2; + +connection default; + + diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 1543924a7ad..644fbe0443f 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -87,7 +87,7 @@ explain extended select c from v6; # show table/table status test show tables; show full tables; ---replace_column 8 # 12 # 13 # +--replace_column 8 # 12 # 13 # 14 # show table status; drop view v1,v2,v3,v4,v5,v6; @@ -3953,6 +3953,26 @@ SELECT * FROM v1; DROP VIEW v1; DROP TABLE t1; +--echo # +--echo # LP BUG#777809 (a retrograded condition for view ON) +--echo # + +CREATE TABLE t1 ( f1 int NOT NULL , f6 int NOT NULL ) ; +INSERT IGNORE INTO t1 VALUES (20, 2); + +CREATE TABLE t2 ( f3 int NOT NULL ) ; +INSERT IGNORE INTO t2 VALUES (7); + +CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2; + +PREPARE prep_stmt FROM 'SELECT t1.f6 FROM t1 RIGHT JOIN v2 ON v2.f3 WHERE t1.f1 != 0'; + +EXECUTE prep_stmt; +EXECUTE prep_stmt; + +drop view v2; +drop table t1,t2; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.1 tests. --echo # ----------------------------------------------------------------- diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test index 176f320e390..508fc35d02c 100644 --- a/mysql-test/t/warnings.test +++ b/mysql-test/t/warnings.test @@ -82,13 +82,15 @@ drop table t1, t2; create table t1(a char(10)); let $1=50; -disable_query_log; +--disable_query_log +begin; while ($1) { eval insert into t1 values('mysql ab'); dec $1; } -enable_query_log; +commit; +--enable_query_log alter table t1 add b char; set max_error_count=10; update t1 set b=a; @@ -192,7 +194,6 @@ DROP PROCEDURE sp1; DROP PROCEDURE sp2; DROP PROCEDURE sp3; - # # Bug#30059: End-space truncation warnings are inconsistent or incorrect # @@ -233,3 +234,15 @@ DROP TABLE t1; SHOW ERRORS; --echo End of 5.0 tests + +# +# Test warning with row numbers +# + +set sql_mode = default; +select CAST(a AS DECIMAL(13,5)) FROM (SELECT '' as a) t; +create table t1 (a integer unsigned); +insert into t1 values (1),(-1),(0),(-2); +drop table t1; + +--echo End of 5.1 tests diff --git a/mysql-test/t/warnings_debug.test b/mysql-test/t/warnings_debug.test new file mode 100644 index 00000000000..99d02330960 --- /dev/null +++ b/mysql-test/t/warnings_debug.test @@ -0,0 +1,19 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (a int primary key) engine=innodb; + +# Test that warnings produced during autocommit (after calling +# set_ok_status()) are still reported to the client. +SET SESSION debug="+d,warn_during_ha_commit_trans"; +INSERT INTO t1 VALUES (1); +# The warning will be shown automatically by mysqltest; there was a bug where +# this didn't happen because the warning was not counted when sending result +# packet. Show the warnings manually also. +SHOW WARNINGS; + +drop table t1; diff --git a/mysql-test/t/warnings_engine_disabled.test b/mysql-test/t/warnings_engine_disabled.test index b8751a062b7..07a7e54c46c 100644 --- a/mysql-test/t/warnings_engine_disabled.test +++ b/mysql-test/t/warnings_engine_disabled.test @@ -2,23 +2,22 @@ # 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; +if (!`SELECT count(*) FROM information_schema.engines WHERE + support = 'NO' AND engine = 'innodb'`){ + skip Needs innodb engine; +} # # Test for handler type, will select MyISAM and print a warning -# about that - since NDB is disabled +# about that - since InnoDB is disabled # -create table t1 (id int) engine=NDB; -alter table t1 engine=NDB; +create table t1 (id int) engine=InnoDB; +alter table t1 engine=InnoDB; 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'; +SELECT ENGINE, SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE='InnoDB'; +SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME='InnoDB'; |