diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-02-04 10:49:44 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-02-04 10:49:44 +0100 |
commit | 5475cc7765aff75dedb2c67f263d22dbbe78c0b5 (patch) | |
tree | aaf573207f5accd08d8982ff79cf90080b5d5657 /mysql-test/t | |
parent | 7dab4d100a9542c64b4b0bfc9feb72ac50aa456f (diff) | |
parent | 3b3a7a524e6a4def53aa98e93bd6e930df60eec3 (diff) | |
download | mariadb-git-5475cc7765aff75dedb2c67f263d22dbbe78c0b5.tar.gz |
merge
Diffstat (limited to 'mysql-test/t')
32 files changed, 1209 insertions, 35 deletions
diff --git a/mysql-test/t/alter_table_autoinc-5574.test b/mysql-test/t/alter_table_autoinc-5574.test new file mode 100644 index 00000000000..95c2b8d81bb --- /dev/null +++ b/mysql-test/t/alter_table_autoinc-5574.test @@ -0,0 +1,12 @@ +# +# MDEV-5574 Set AUTO_INCREMENT below max value of column +# +--source include/have_innodb.inc +create table t1(a int(10)unsigned not null auto_increment primary key, +b varchar(255) not null) engine=innodb default charset=utf8; +insert into t1 values(1,'aaa'),(2,'bbb'); +alter table t1 auto_increment=1; +insert into t1 values(NULL, 'ccc'); +select * from t1; +drop table t1; + diff --git a/mysql-test/t/alter_table_trans.test b/mysql-test/t/alter_table_trans.test index 9096a392af4..29b9b4c212f 100644 --- a/mysql-test/t/alter_table_trans.test +++ b/mysql-test/t/alter_table_trans.test @@ -13,3 +13,23 @@ drop table if exists t1,t2; CREATE TABLE t1 (a INT, INDEX(a)) engine=innodb; ALTER TABLE t1 RENAME TO t2, DISABLE KEYS; DROP TABLE t2; + +# +# MDEV-5406 add index to an innodb table with a uniqueness violation crashes mysqld +# + +CREATE TABLE t1 ( + col4 text NOT NULL, + col2 int(11) NOT NULL DEFAULT '0', + col3 int(11) DEFAULT NULL, + extra int(11) DEFAULT NULL, + KEY idx (col4(10)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +insert t1 values (repeat('1', 8193),3,1,1); +insert t1 values (repeat('3', 8193),3,1,1); +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD PRIMARY KEY (col4(10)) , ADD UNIQUE KEY uidx (col3); +DROP TABLE t1; + + diff --git a/mysql-test/t/assign_key_cache-5405.test b/mysql-test/t/assign_key_cache-5405.test new file mode 100644 index 00000000000..2839e040bd3 --- /dev/null +++ b/mysql-test/t/assign_key_cache-5405.test @@ -0,0 +1,27 @@ +# +# MDEV-5405 RQG induced crash in mi_assign_to_key_cache in safe mutex unlock +# +--source include/have_debug_sync.inc +create table t1 (f int, key(f)) engine=myisam; +set global kc1.key_buffer_size = 65536; + +connect (con1, localhost, root); + +set debug_sync='assign_key_cache_op_unlock wait_for op_locked'; +send cache index t1 in kc1; + +connection default; +sleep 1; +set debug_sync='assign_key_cache_op_lock signal op_locked wait_for assigned'; +send cache index t1 in kc1; + +connection con1; +reap; +set debug_sync='now signal assigned'; +disconnect con1; +connection default; +reap; + +drop table t1; +set global kc1.key_buffer_size = 0; +set debug_sync='reset'; diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 7e6990f4754..972543aefc2 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -32,6 +32,8 @@ ORDER BY variable_name; # SET date_format='%d.%m.%Y'; # SET date_format='%m-%d-%Y'; # +# --error ER_WRONG_VALUE_FOR_VAR +# SET datetime_format= NULL; # set datetime_format= '%Y%m%d%H%i%s'; # set datetime_format= '%Y-%m-%d %H:%i:%s'; # set datetime_format= '%m-%d-%y %H:%i:%s.%f'; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 559a8b76280..4b1d7604b9d 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -394,6 +394,35 @@ WHERE tmp.b; SELECT * FROM ( SELECT 100 a, subsel.b FROM ( SELECT 200 b ) subsel ) tmp WHERE tmp.a; + +--echo # +--echo # MDEV-5356: Server crashes in Item_equal::contains on 2nd +--echo # execution of a PS +--echo # +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,2),(3,4); + +CREATE TABLE t2 (c INT); +INSERT INTO t2 VALUES (5),(6); + +CREATE TABLE t3 (d INT); +INSERT INTO t3 VALUES (7),(8); + +CREATE PROCEDURE pr() + UPDATE t3, + (SELECT c FROM + (SELECT 1 FROM t1 WHERE a=72 AND NOT b) sq, + t2 + ) sq2 + SET d=sq2.c; + +CALL pr(); +CALL pr(); +CALL pr(); + +drop procedure pr; +drop table t1,t2,t3; + --echo # End of 5.3 tests --echo # diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test index 3da58d8ae23..61e11cebad4 100644 --- a/mysql-test/t/derived_view.test +++ b/mysql-test/t/derived_view.test @@ -1591,6 +1591,118 @@ EXPLAIN EXTENDED SELECT a FROM v1 WHERE a > 100 ORDER BY b; DROP VIEW v1; DROP TABLE t1; +# +# MDEV-5414: RAND() in a subselect : different behavior in MariaDB and MySQL +# +CREATE TABLE IF NOT EXISTS `galleries` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `year` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `pictures` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `width` float DEFAULT NULL, + `height` float DEFAULT NULL, + `year` int(4) DEFAULT NULL, + `technique` varchar(50) DEFAULT NULL, + `comment` varchar(2000) DEFAULT NULL, + `gallery_id` int(11) NOT NULL, + `type` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `gallery_id` (`gallery_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; + +ALTER TABLE `pictures` + ADD CONSTRAINT `pictures_ibfk_1` FOREIGN KEY (`gallery_id`) REFERENCES `galleries` (`id`); + +INSERT INTO `galleries` (`id`, `name`, `year`) VALUES +(1, 'Quand le noir et blanc invite le taupe', 2013), +(2, 'Une touche de couleur', 2012), +(3, 'Éclats', 2011), +(4, 'Gris béton', 2010), +(5, 'Expression du spalter', 2010), +(6, 'Zénitude', 2009), +(7, 'La force du rouge', 2008), +(8, 'Sphères', NULL), +(9, 'Centre', 2009), +(10, 'Nébuleuse', NULL); + +INSERT INTO `pictures` (`id`, `name`, `width`, `height`, `year`, `technique`, `comment`, `gallery_id`, `type`) VALUES +(1, 'Éclaircie', 72.5, 100, NULL, NULL, NULL, 1, 1), +(2, 'Architecture', 81, 100, NULL, NULL, NULL, 1, 1), +(3, 'Nouveau souffle', 72.5, 100, NULL, NULL, NULL, 1, 1), +(4, 'Échanges (2)', 89, 116, NULL, NULL, NULL, 1, 1), +(5, 'Échanges', 89, 116, NULL, NULL, NULL, 1, 1), +(6, 'Fenêtre de vie', 81, 116, NULL, NULL, NULL, 1, 1), +(7, 'Architecture', 81, 100, NULL, NULL, NULL, 1, 1), +(8, 'Nouveau souffle (2)', 72.5, 100, NULL, NULL, NULL, 1, 1), +(9, 'Fluidité', 89, 116, NULL, NULL, NULL, 1, 1), +(10, 'Nouveau Monde', 89, 125, NULL, NULL, NULL, 1, 1), +(11, 'Mirage', 73, 100, NULL, NULL, NULL, 1, 1), +(12, 'Équilibre', 72.5, 116, NULL, NULL, NULL, 2, 1), +(13, 'Fusion', 72.5, 116, NULL, NULL, NULL, 2, 1), +(14, 'Étincelles', NULL, NULL, NULL, NULL, NULL, 3, 1), +(15, 'Régénérescence', NULL, NULL, NULL, NULL, NULL, 3, 1), +(16, 'Chaleur', 80, 80, NULL, NULL, NULL, 4, 1), +(17, 'Création', 90, 90, NULL, NULL, NULL, 4, 1), +(18, 'Horizon', 92, 73, NULL, NULL, NULL, 4, 1), +(19, 'Labyrinthe', 81, 100, NULL, NULL, NULL, 4, 1), +(20, 'Miroir', 80, 116, NULL, NULL, NULL, 5, 1), +(21, 'Libération', 81, 116, NULL, NULL, NULL, 5, 1), +(22, 'Éclats', 81, 116, NULL, NULL, NULL, 5, 1), +(23, 'Zénitude', 116, 89, NULL, NULL, NULL, 6, 1), +(24, 'Écritures lointaines', 90, 90, NULL, NULL, NULL, 7, 1), +(25, 'Émergence', 80, 80, NULL, NULL, NULL, 7, 1), +(26, 'Liberté', 50, 50, NULL, NULL, NULL, 7, 1), +(27, 'Silhouettes amérindiennes', 701, 70, NULL, NULL, NULL, 7, 1), +(28, 'Puissance', 81, 100, NULL, NULL, NULL, 8, 1), +(29, 'Source', 73, 116, NULL, NULL, NULL, 8, 1), +(30, 'Comme une ville qui prend vie', 50, 100, 2008, NULL, NULL, 9, 1), +(31, 'Suspension azur', 80, 80, NULL, NULL, NULL, 9, 1), +(32, 'Nébuleuse', 70, 70, NULL, NULL, NULL, 10, 1), +(33, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2), +(34, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2), +(35, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2), +(36, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2), +(37, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2), +(38, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2); + +# Now we only lest explain to be sure that table materialized. If +# in the future merged derived table will be processed in a way that +# rand() can be called only once then other way of testing correctness +# of this query should be put here. +explain +SELECT g.id AS gallery_id, + g.name AS gallery_name, + p.id AS picture_id, + p.name AS picture_name, + g.p_random AS r1, + g.p_random AS r2, + g.p_random AS r3 +FROM +( + SELECT gal.id, + gal.name, + ( + SELECT pi.id + FROM pictures pi + WHERE pi.gallery_id = gal.id + ORDER BY RAND() + LIMIT 1 + ) AS p_random + FROM galleries gal +) g +LEFT JOIN pictures p + ON p.id = g.p_random +ORDER BY gallery_name ASC +; + +drop table galleries, pictures; + --echo # --echo # end of 5.3 tests --echo # diff --git a/mysql-test/t/flush-innodb-notembedded.test b/mysql-test/t/flush-innodb-notembedded.test new file mode 100644 index 00000000000..d08a0647ff5 --- /dev/null +++ b/mysql-test/t/flush-innodb-notembedded.test @@ -0,0 +1,69 @@ +--source include/have_innodb.inc +--source include/not_embedded.inc + +--echo # Test 7: Check privileges required. +--echo # + +CREATE DATABASE db1; +CREATE TABLE db1.t1 (a INT) engine= InnoDB; +GRANT RELOAD, SELECT, LOCK TABLES ON *.* TO user1@localhost; +GRANT CREATE, DROP ON *.* TO user2@localhost; +GRANT RELOAD, SELECT ON *.* TO user3@localhost; +GRANT SELECT, LOCK TABLES ON *.* TO user4@localhost; +GRANT RELOAD, LOCK TABLES ON *.* TO user5@localhost; + +--echo # Connection con1 as user1 +--connect(con1, localhost, user1) +FLUSH TABLE db1.t1 FOR EXPORT; +UNLOCK TABLES; +--disconnect con1 +--source include/wait_until_disconnected.inc + +--echo # Connection default +--connection default + +--echo # Connection con1 as user2 +--connect(con1, localhost, user2) +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +FLUSH TABLE db1.t1 FOR EXPORT; +--disconnect con1 +--source include/wait_until_disconnected.inc + +--echo # Connection default +--connection default + +--echo # Connection con1 as user3 +--connect(con1, localhost, user3) +--error ER_DBACCESS_DENIED_ERROR +FLUSH TABLE db1.t1 FOR EXPORT; +--disconnect con1 +--source include/wait_until_disconnected.inc + +--echo # Connection default +--connection default + +--echo # Connection con1 as user4 +--connect(con1, localhost, user4) +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +FLUSH TABLE db1.t1 FOR EXPORT; +--disconnect con1 +--source include/wait_until_disconnected.inc + +--echo # Connection default +--connection default + +--echo # Connection con1 as user5 +--connect(con1, localhost, user5) +--error ER_TABLEACCESS_DENIED_ERROR +FLUSH TABLE db1.t1 FOR EXPORT; +--disconnect con1 +--source include/wait_until_disconnected.inc + +--echo # Connection default +--connection default +DROP USER user1@localhost, user2@localhost, user3@localhost, + user4@localhost, user5@localhost; +DROP TABLE db1.t1; +DROP DATABASE db1; + +--echo # End of 5.6 tests diff --git a/mysql-test/t/flush-innodb.test b/mysql-test/t/flush-innodb.test index 207032b1acb..7a877b977ce 100644 --- a/mysql-test/t/flush-innodb.test +++ b/mysql-test/t/flush-innodb.test @@ -7,3 +7,472 @@ CREATE TABLE t1 ( m MEDIUMTEXT ) ENGINE=InnoDB; INSERT INTO t1 VALUES ( REPEAT('i',1048576) ); DROP TABLE t1; + +--echo +--echo # +--echo # WL#6168: FLUSH TABLES ... FOR EXPORT -- parser +--echo # +--echo + +--echo # Requires innodb_file_per_table +SET @old_innodb_file_per_table= @@GLOBAL.innodb_file_per_table; +SET GLOBAL innodb_file_per_table= 1; + +--echo # new "EXPORT" keyword is a valid user variable name: + +SET @export = 10; + +--echo # new "EXPORT" keyword is a valid SP parameter name: + +CREATE PROCEDURE p1(export INT) BEGIN END; +DROP PROCEDURE p1; + +--echo # new "EXPORT" keyword is a valid local variable name: + +DELIMITER |; +CREATE PROCEDURE p1() +BEGIN + DECLARE export INT; +END| +DELIMITER ;| +DROP PROCEDURE p1; + +--echo # new "EXPORT" keyword is a valid SP name: + +CREATE PROCEDURE export() BEGIN END; +DROP PROCEDURE export; + +--echo # new FLUSH TABLES ... FOR EXPORT syntax: + +--error ER_PARSE_ERROR +FLUSH TABLES FOR EXPORT; +--error ER_PARSE_ERROR +FLUSH TABLES WITH EXPORT; + + +CREATE TABLE t1 (i INT) engine=InnoDB; +CREATE TABLE t2 LIKE t1; + +--error ER_PARSE_ERROR +FLUSH TABLES t1,t2 WITH EXPORT; + +FLUSH TABLES t1, t2 FOR EXPORT; +UNLOCK TABLES; + +--echo # case check +FLUSH TABLES t1, t2 for ExPoRt; +UNLOCK TABLES; +--echo # With LOCAL keyword +FLUSH LOCAL TABLES t1, t2 FOR EXPORT; +UNLOCK TABLES; +--echo # Tables with fully qualified names +FLUSH LOCAL TABLES test.t1, test.t2 for ExPoRt; +UNLOCK TABLES; + +DROP TABLES t1, t2; + +--echo # new "EXPORT" keyword is a valid table name: + +CREATE TABLE export (i INT) engine=InnoDB; + +--echo # it's ok to lock the "export" table for export: + +FLUSH TABLE export FOR EXPORT; +UNLOCK TABLES; + +DROP TABLE export; + + +--echo # +--echo # WL#6169 FLUSH TABLES ... FOR EXPORT -- runtime +--echo # + +--echo # Test 1: Views, temporary tables, non-existent tables +--echo # + +CREATE VIEW v1 AS SELECT 1; +CREATE TEMPORARY TABLE t1 (a INT); + +--error ER_WRONG_OBJECT +FLUSH TABLES v1 FOR EXPORT; +--error ER_NO_SUCH_TABLE +FLUSH TABLES t1 FOR EXPORT; +--error ER_NO_SUCH_TABLE +FLUSH TABLES non_existent FOR EXPORT; + +DROP TEMPORARY TABLE t1; +DROP VIEW v1; + +--echo # Test 2: Blocked by update transactions, blocks updates. +--echo # + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) engine= InnoDB; +CREATE TABLE t2 (a INT) engine= InnoDB; + +--echo # Connection con1 +--connect (con1, localhost, root) +START TRANSACTION; +INSERT INTO t1 VALUES (1, 1); + +--echo # Connection default +--connection default +--echo # Should be blocked +--echo # Sending: +--send FLUSH TABLES t1 FOR EXPORT + +--echo # Connection con1 +--connection con1 +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = "Waiting for table metadata lock" AND + info = "FLUSH TABLES t1 FOR EXPORT"; +--source include/wait_condition.inc +COMMIT; + +--echo # Connection default +--connection default +--echo # Reaping: FLUSH TABLES t1 FOR EXPORT +--reap + +--echo # Connection con1 +--connection con1 +--echo # Should not be blocked +INSERT INTO t2 VALUES (1); +--echo # Should be blocked +--echo # Sending: +--send INSERT INTO t1 VALUES (2, 2) + +--echo # Connection default +--connection default +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = "Waiting for table metadata lock" AND + info = "INSERT INTO t1 VALUES (2, 2)"; +--source include/wait_condition.inc +UNLOCK TABLES; + +--echo # Connection con1 +--connection con1 +--echo # Reaping: INSERT INTO t1 VALUES (2, 2); +--reap + +--echo # Test 3: Read operations should not be affected. +--echo # + +START TRANSACTION; +SELECT * FROM t1; + +--echo # Connection default +--connection default +--echo # Should not be blocked +FLUSH TABLES t1 FOR EXPORT; + +--echo # Connection con1 +--connection con1 +COMMIT; +--echo # Should not be blocked +SELECT * FROM t1; + +--echo # Connection default +--connection default +UNLOCK TABLES; + +--echo # Test 4: Blocked by DDL, blocks DDL. +--echo # + +START TRANSACTION; +SELECT * FROM t1; + +--echo # Connection con2 +--connect (con2, localhost, root) +--echo # Sending: +--send ALTER TABLE t1 ADD INDEX i1(b) + +--echo # Connection con1 +--connection con1 +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = "Waiting for table metadata lock" AND + info = "ALTER TABLE t1 ADD INDEX i1(b)"; +--source include/wait_condition.inc +--echo # Should be blocked +--send FLUSH TABLE t1 FOR EXPORT + +--echo # Connection default +--connection default +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = "Waiting for table metadata lock" AND + info = "FLUSH TABLE t1 FOR EXPORT"; +--source include/wait_condition.inc +COMMIT; + +--echo # Connection con2 +--connection con2 +--echo # Reaping ALTER TABLE ... +--reap + +--echo # Connection con1 +--connection con1 +--echo # Reaping FLUSH TABLE t1 FOR EXPORT +--reap +UNLOCK TABLES; + +--echo # Connection default +--connection default +FLUSH TABLE t1 FOR EXPORT; + +--echo # Connection con2 +--connection con2 +--echo # Should be blocked +--send DROP TABLE t1 + +--echo # Connection default +--connection default +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = "Waiting for table metadata lock" AND + info = "DROP TABLE t1"; +--source include/wait_condition.inc +UNLOCK TABLES; + +--echo # Connection con2 +--connection con2 +--echo # Reaping DROP TABLE t1 +--reap +--disconnect con2 +--source include/wait_until_disconnected.inc + +--echo # Connection default +--connection default +DROP TABLE t2; + +--echo # Test 5: Compatibilty with FLUSH TABLES WITH READ LOCK +--echo # + +CREATE TABLE t1(a INT) engine= InnoDB; +FLUSH TABLES WITH READ LOCK; + +--echo # Connection con1 +--connection con1 +--echo # This should not block +FLUSH TABLE t1 FOR EXPORT; +UNLOCK TABLES; + +--echo # Connection default +--connection default +UNLOCK TABLES; +DROP TABLE t1; + +--echo # Test 6: Unsupported storage engines. +--echo # + +CREATE TABLE t1(a INT) engine= MEMORY; +--error ER_ILLEGAL_HA +FLUSH TABLE t1 FOR EXPORT; +DROP TABLE t1; + +--echo # Connection con1 +--connection con1 +--disconnect con1 +--source include/wait_until_disconnected.inc + +--echo # Connection defalt +--connection default + +--echo # Test 7: Check privileges required. +--echo # in flush-innodb-notembedded.test + +--echo # Test 8: FLUSH TABLE <table_list> FOR EXPORT is incompatible +--echo # with itself (to avoid race conditions in metadata +--echo # file handling). +--echo # + +CREATE TABLE t1 (a INT) engine= InnoDB; +CREATE TABLE t2 (a INT) engine= InnoDB; + +--echo # Connection con1 +--connect (con1, localhost, root) +FLUSH TABLE t1 FOR EXPORT; + +--echo # Connection default +--connection default +--echo # This should not block +FLUSH TABLE t2 FOR EXPORT; +UNLOCK TABLES; +--echo # This should block +--echo # Sending: +--send FLUSH TABLE t1 FOR EXPORT + +--echo # Connection con1 +--connection con1 +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = "Waiting for table metadata lock" AND + info = "FLUSH TABLE t1 FOR EXPORT"; +--source include/wait_condition.inc +UNLOCK TABLES; + +--echo # Connection default +--connection default +--echo # Reaping: FLUSH TABLE t1 FOR EXPORT +--reap +UNLOCK TABLES; + +--echo # Test 9: LOCK TABLES ... READ is not affected +--echo # + +LOCK TABLE t1 READ; + +--echo # Connection con1 +--connection con1 +--echo # Should not block +FLUSH TABLE t1 FOR EXPORT; +UNLOCK TABLES; + +--echo # Connection default +--connection default +UNLOCK TABLES; +FLUSH TABLE t1 FOR EXPORT; + +--echo # Connection con1 +--connection con1 +--echo # Should not block +LOCK TABLE t1 READ; +UNLOCK TABLES; + +--echo # Connection default +--connection default +UNLOCK TABLES; + +--echo # Connection con1 +--connection con1 +--disconnect con1 +--source include/wait_until_disconnected.inc + +--echo # Connection default +--connection default +DROP TABLE t1, t2; + +--echo # Test 10: Lock is released if transaction is started after doing +--echo # 'flush table..' in same session + +CREATE TABLE t1 ( i INT ) ENGINE = Innodb; +FLUSH TABLE t1 FOR EXPORT; +--echo # error as active locks already exist +--error ER_LOCK_OR_ACTIVE_TRANSACTION +FLUSH TABLE t1 FOR EXPORT; +--echo # active locks will be released due to start transaction +START TRANSACTION; +--echo # passes as start transaction released ealier locks +FLUSH TABLE t1 FOR EXPORT; +UNLOCK TABLES; +DROP TABLE t1; + +--echo # Test 11: Test 'flush table with fully qualified table names +--echo # and with syntax local/NO_WRITE_TO_BINLOG + +--echo # Connection con1 +--connect (con1, localhost, root) + +--echo # Connection default +--connection default +CREATE TABLE t1 ( i INT ) ENGINE = Innodb; +INSERT INTO t1 VALUES (100),(200); +FLUSH LOCAL TABLES test.t1 FOR EXPORT; +--echo # Connection con1 +--connection con1 +--echo # Should be blocked +--echo # Sending: +--send FLUSH LOCAL TABLES t1 FOR EXPORT + +--echo # Connection default +--connection default +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = "Waiting for table metadata lock" AND + info = "FLUSH LOCAL TABLES t1 FOR EXPORT"; +--source include/wait_condition.inc +UNLOCK TABLE; + +--echo # Connection con1 +--connection con1 +--echo # Reaping: FLUSH LOCAL TABLES t1 FOR EXPORT +--reap +SELECT * FROM t1 ORDER BY i; + +--echo # Connection default +--connection default +--echo # Should be blocked +--echo # Sending: +--send FLUSH NO_WRITE_TO_BINLOG TABLES test.t1 FOR EXPORT + +--echo # Connection con1 +--connection con1 +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = "Waiting for table metadata lock" AND + info = "FLUSH NO_WRITE_TO_BINLOG TABLES test.t1 FOR EXPORT"; +--source include/wait_condition.inc +UNLOCK TABLES; + +--echo # Connection default +--connection default +--echo # Reaping: FLUSH NO_WRITE_TO_BINLOG TABLES test.t1 FOR EXPORT +--reap +SELECT * FROM t1 ORDER BY i; +UNLOCK TABLE; +DROP TABLE t1; + +--echo # Test 12: Active transaction get committed if user execute +--echo # "FLUSH TABLE ... FOR EXPORT" or "LOCK TABLE.." + +--echo # Connection default +--connection default +CREATE TABLE t1 ( i INT ) ENGINE = Innodb; +INSERT INTO t1 VALUES (100),(200); +START TRANSACTION; +INSERT INTO t1 VALUES (300); +--echo # 'flush table..' commit active transaction from same session +FLUSH LOCAL TABLES test.t1 FOR EXPORT; +ROLLBACK; +SELECT * FROM t1 ORDER BY i; +START TRANSACTION; +INSERT INTO t1 VALUES (400); +--echo # 'lock table ..' commit active transaction from same session +LOCK TABLES test.t1 READ; +ROLLBACK; +SELECT * FROM t1 ORDER BY i; +UNLOCK TABLES; +DROP TABLE t1; + +--echo # Test 13: Verify "FLUSH TABLE ... FOR EXPORT" and "LOCK TABLE.." +--echo # in same session +--echo # Connection default + +--connection default +CREATE TABLE t1 ( i INT ) ENGINE = Innodb; +--echo # Lock table +LOCK TABLES test.t1 WRITE; +--echo # 'lock table ..' completes even if table lock is acquired +--echo # in same session using 'lock table'. Previous locks are released. +LOCK TABLES test.t1 READ; +--echo # 'flush table ..' gives error if table lock is acquired +--echo # in same session using 'lock table ..' +--error ER_LOCK_OR_ACTIVE_TRANSACTION +FLUSH TABLES test.t1 FOR EXPORT; +--echo # 'lock table ..' completes even if table lock is acquired +--echo # in same session using 'flush table'. Previous locks are released. +LOCK TABLES test.t1 WRITE; +UNLOCK TABLES; +DROP TABLE t1; + +--connection con1 +--disconnect con1 +--source include/wait_until_disconnected.inc +--connection default + +--echo # Reset innodb_file_per_table +SET GLOBAL innodb_file_per_table= @old_innodb_file_per_table; + +--echo # End of 5.6 tests diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 77e3f122529..ee5292a5ba8 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1450,6 +1450,24 @@ SELECT EXTRACT(HOUR FROM TIME'1 02:00:00'), EXTRACT(HOUR FROM TIME'26:00:00'); SELECT EXTRACT(HOUR FROM TIME('1 02:00:00')), EXTRACT(HOUR FROM TIME('26:00:00')); SELECT EXTRACT(DAY FROM TIME('1 02:00:00')), EXTRACT(DAY FROM TIME('26:00:00')); +--echo # +--echo # MDEV-5458 RQG hits 'sql/tztime.cc:799: my_time_t sec_since_epoch(int, int, int, int, int, int): Assertion `mon > 0 && mon < 13' failed.' +--echo # +SET TIMESTAMP=UNIX_TIMESTAMP('2014-01-22 18:19:20'); +CREATE TABLE t1 (t TIME); +INSERT INTO t1 VALUES ('03:22:30'),('18:30:05'); +SELECT CONVERT_TZ(GREATEST(t, CURRENT_DATE()), '+02:00', '+10:00') FROM t1; +SELECT GREATEST(t, CURRENT_DATE()) FROM t1; +DROP TABLE t1; +SET TIMESTAMP=DEFAULT; + +--echo # +--echo # MDEV-5504 Server crashes in String::length on SELECT with MONTHNAME, GROUP BY, ROLLUP +--echo # +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2); +SELECT 1 FROM t1 GROUP BY MONTHNAME(0) WITH ROLLUP; +DROP TABLE t1; --echo # --echo # MDEV-4838 Wrong metadata for DATE_ADD('string', INVERVAL) diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index f88b6fbb2fe..8ee17d2b2d3 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1,5 +1,3 @@ ---source include/have_innodb.inc - # Initialise --disable_warnings drop table if exists t1,t2,t3; @@ -1336,7 +1334,7 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10), (11),(12),(13),(14),(15),(16),(17),(18),(19),(20); let $query0=SELECT col1 AS field1, col1 AS field2 - FROM t1 GROUP BY field1, field2; + FROM t1 GROUP BY field1, field2+0; # Needs to be range to exercise bug --eval EXPLAIN $query0; @@ -1366,7 +1364,9 @@ LIMIT 3; explain select col1 f1, col1 f2 from t1 order by f2, f1; -select col1 f1, col1 f2 from t1 order by f2, f1; +explain +select col1 f1, col1 f2 from t1 order by f2, f1+0; +select col1 f1, col1 f2 from t1 order by f2, f1+0; explain select col1 f1, col1 f2 from t1 group by f2 order by f2, f1; @@ -1386,12 +1386,12 @@ INSERT INTO t2(col1, col2) VALUES (11,10),(12,9),(13,8),(14,7),(15,6),(16,5),(17,4),(18,3),(19,2),(20,1); explain -select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3; -select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3; +select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3+0; +select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3+0; explain -select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3; -select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3; +select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3+0; +select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3+0; DROP VIEW v1; DROP TABLE t1, t2; @@ -1644,30 +1644,6 @@ FROM t1 JOIN t2 ON c = b GROUP BY b WITH ROLLUP; DROP TABLE t1,t2; --echo # ---echo # Test of MDEV-4002 ---echo # - -CREATE TABLE t1 ( - pk INT NOT NULL PRIMARY KEY, - d1 DOUBLE, - d2 DOUBLE, - i INT NOT NULL DEFAULT '0', - KEY (i) -) ENGINE=InnoDB; - -INSERT INTO t1 VALUES (1,1.0,1.1,1),(2,2.0,2.2,2); - -PREPARE stmt FROM " -SELECT DISTINCT i, GROUP_CONCAT( d1, d2 ORDER BY d1, d2 ) -FROM t1 a1 NATURAL JOIN t1 a2 GROUP BY i WITH ROLLUP -"; - -EXECUTE stmt; -EXECUTE stmt; - -DROP TABLE t1; - ---echo # --echo # Bug #58782 --echo # Missing rows with SELECT .. WHERE .. IN subquery --echo # with full GROUP BY and no aggr diff --git a/mysql-test/t/group_by_innodb.test b/mysql-test/t/group_by_innodb.test index 0d5e5e9ae30..df213cc189f 100644 --- a/mysql-test/t/group_by_innodb.test +++ b/mysql-test/t/group_by_innodb.test @@ -4,6 +4,8 @@ --source include/have_innodb.inc +set @save_ext_key_optimizer_switch=@@optimizer_switch; + --echo # --echo # MDEV-3992 Server crash or valgrind errors in test_if_skip_sort_order/test_if_cheaper_ordering --echo # on GROUP BY with indexes on InnoDB table @@ -15,6 +17,8 @@ CREATE TABLE t1 ( KEY (pk) ) ENGINE=InnoDB; +set optimizer_switch='extended_keys=on'; + INSERT INTO t1 VALUES (1,'a'),(2,'b'); EXPLAIN @@ -35,4 +39,31 @@ WHERE a = 'r' OR pk = 183 GROUP BY field1, field1; drop table t1; +set optimizer_switch=@save_ext_key_optimizer_switch; + +--echo # +--echo # MDEV-4002 Server crash or valgrind errors in Item_func_group_concat::setup and Item_func_group_concat::add +--echo # + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY, + d1 DOUBLE, + d2 DOUBLE, + i INT NOT NULL DEFAULT '0', + KEY (i) +) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (1,1.0,1.1,1),(2,2.0,2.2,2); + +PREPARE stmt FROM " +SELECT DISTINCT i, GROUP_CONCAT( d1, d2 ORDER BY d1, d2 ) +FROM t1 a1 NATURAL JOIN t1 a2 GROUP BY i WITH ROLLUP +"; + +EXECUTE stmt; +EXECUTE stmt; + +DROP TABLE t1; + --echo End of 5.5 tests + diff --git a/mysql-test/t/group_by_null.test b/mysql-test/t/group_by_null.test new file mode 100644 index 00000000000..b3fa2a003ec --- /dev/null +++ b/mysql-test/t/group_by_null.test @@ -0,0 +1,7 @@ +# +# MDEV-5461 Assertion `length <= column->length' fails in write_block_record with functions in select list, GROUP BY, ORDER BY +# +create table t1 (a int); +insert into t1 values (1),(2); +select max('foo') from t1 group by values(a), extractvalue('bar','qux') order by "v"; +drop table t1; diff --git a/mysql-test/t/information_schema-big.test b/mysql-test/t/information_schema-big.test index 5e73c867143..717c22f8f6a 100644 --- a/mysql-test/t/information_schema-big.test +++ b/mysql-test/t/information_schema-big.test @@ -14,9 +14,10 @@ DROP VIEW IF EXISTS v1; --echo # ---echo # Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA +--echo # Bug#18925: subqueries with MIN/MAX functions on INFORMATION_SCHEMA --echo # +--sorted_result SELECT t.table_name, c1.column_name FROM information_schema.tables t INNER JOIN @@ -32,6 +33,7 @@ SELECT t.table_name, c1.column_name c2.column_name LIKE '%SCHEMA%' ) AND t.table_name NOT LIKE 'innodb%'; +--sorted_result SELECT t.table_name, c1.column_name FROM information_schema.tables t INNER JOIN diff --git a/mysql-test/t/innodb_ext_key.test b/mysql-test/t/innodb_ext_key.test index d62217dd54f..9f3a89ff948 100644 --- a/mysql-test/t/innodb_ext_key.test +++ b/mysql-test/t/innodb_ext_key.test @@ -663,6 +663,34 @@ ORDER BY rev_timestamp ASC LIMIT 10; DROP TABLE t1,t2,t3; +--echo # +--echo # MDEV-5424 SELECT using ORDER BY DESC and LIMIT produces unexpected +--echo # results (InnoDB/XtraDB) +--echo # + +create table t1 (a bigint not null unique auto_increment, b varchar(10), primary key (a), key (b(2))) engine = myisam default character set utf8; +create table t2 (a bigint not null unique auto_increment, b varchar(10), primary key (a), key (b(2))) engine = innodb default character set utf8; + +insert into t1 (b) values (null), (null), (null); +insert into t2 (b) values (null), (null), (null); + +set optimizer_switch='extended_keys=on'; +explain select a from t1 where b is null order by a desc limit 2; +select a from t1 where b is null order by a desc limit 2; +explain select a from t2 where b is null order by a desc limit 2; +select a from t2 where b is null order by a desc limit 2; +set optimizer_switch='extended_keys=off'; +explain select a from t2 where b is null order by a desc limit 2; +select a from t2 where b is null order by a desc limit 2; + +explain select a from t2 where b is null order by a desc; +select a from t2 where b is null order by a desc; + +explain select a from t2 where b is null order by a desc,a,a; +select a from t2 where b is null order by a desc,a,a; + +drop table t1, t2; + set optimizer_switch=@save_optimizer_switch; set optimizer_switch=@save_ext_key_optimizer_switch; diff --git a/mysql-test/t/innodb_icp.test b/mysql-test/t/innodb_icp.test index d6caa36a88e..acb8238e01f 100644 --- a/mysql-test/t/innodb_icp.test +++ b/mysql-test/t/innodb_icp.test @@ -45,6 +45,34 @@ ORDER BY e; DROP TABLE t1,t2,t3; +--echo # +--echo # MDEV-5337: Wrong result in mariadb 5.5.32 with ORDER BY + LIMIT when index_condition_pushdown=on +--echo # MDEV-5512: Wrong result (WHERE clause ignored) with multiple clauses using Percona-XtraDB engine +--echo # + +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t2 (pk int primary key, + key1 char(32), + key2 char(32), + key(key1), + key(key2) +) engine=innodb; + +insert into t2 select + A.a+10*B.a+100*C.a, + concat('rare-', A.a+10*B.a), + concat('rare-', A.a+10*B.a) +from + t1 A, t1 B, t1 C; +update t2 set key1='frequent-val' where pk between 100 and 350; +select * from t2 ignore key(PRIMARY) +where key1='frequent-val' and key2 between 'rare-400' and 'rare-450' order by pk limit 2; + +drop table t1, t2; + + set optimizer_switch=@innodb_icp_tmp; set storage_engine= @save_storage_engine; diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index f9b9fcf266d..ff8396fd7fd 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -555,3 +555,21 @@ INSERT IGNORE t1 (a, a) SELECT 1,1; INSERT IGNORE t1 (a, a) SELECT 1,1 UNION SELECT 2,2; DROP TABLE t1; + +--echo # +--echo # MDEV-5168: Ensure that we can disable duplicate key warnings +--echo # from INSERT IGNORE +--echo # + +create table t1 (f1 int unique, f2 int unique); +insert into t1 values (1,12); +insert into t1 values (2,13); +--error ER_DUP_ENTRY +insert into t1 values (1,12); +insert ignore into t1 values (1,12); +set @@old_mode="NO_DUP_KEY_WARNINGS_WITH_IGNORE"; +insert ignore into t1 values (1,12); +insert ignore into t1 values (1,12) on duplicate key update f2=13; +set @@old_mode=""; +insert ignore into t1 values (1,12); +DROP TABLE t1; diff --git a/mysql-test/t/myisam_optimize.test b/mysql-test/t/myisam_optimize.test index 2d630f7dbd0..5f0b8fc7666 100644 --- a/mysql-test/t/myisam_optimize.test +++ b/mysql-test/t/myisam_optimize.test @@ -44,4 +44,5 @@ disconnect con2; connection default; drop table t1; +set debug_sync='reset'; diff --git a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test index d29d40f5679..1ba4e91be3c 100644 --- a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test +++ b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test @@ -8,8 +8,32 @@ --exec mkdir $MYSQLTEST_VARDIR/zoneinfo --exec ln -s $MYSQLTEST_VARDIR/zoneinfo $MYSQLTEST_VARDIR/zoneinfo/posix --copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/GMT +--copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/garbage +--copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/ignored.tab +--echo # Verbose run +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL --verbose $MYSQLTEST_VARDIR/zoneinfo 2>&1 + +--echo # Silent run --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1 +--echo # +--echo # Testing with explicit timezonefile +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1 + +--echo # +--echo # Testing --leap +--echo # + +--exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 + +# +# Cleanup +# + --exec rm -rf $MYSQLTEST_VARDIR/zoneinfo diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test index efb1551150f..0261928ac08 100644 --- a/mysql-test/t/mysql_upgrade.test +++ b/mysql-test/t/mysql_upgrade.test @@ -41,6 +41,11 @@ GRANT ALL ON *.* TO mysqltest1@'%'; DROP USER mysqltest1@'%'; +# +# check that we get proper error messages if wrong user + +--error 1 +--exec $MYSQL_UPGRADE --force --user=mysqltest1 --password=sakila 2>&1 # # Bug #26639 mysql_upgrade exits successfully even if external command failed diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index d573c3b5b8a..c4a85e4b111 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -261,6 +261,9 @@ desc,b desc; explain select * from t1 where a = 2 and b > 0 order by a desc,b desc; explain select * from t1 where a = 2 and b < 2 order by a desc,b desc; explain select * from t1 where a = 1 order by b desc; +explain select * from t1 where a = 2 and b > 0 order by a desc,b desc,b,a; +explain select * from t1 where a = 2 and b < 2 order by a desc,a,b desc,a,b; + select * from t1 where a = 1 order by b desc; # # Test things when we don't have NULL keys @@ -1913,6 +1916,35 @@ SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 100; DROP TABLE t1,t2; +--echo # +--echo # MDEV-4974 memory leak in 5.5.32-MariaDB-1~wheezy-log +--echo # +set sort_buffer_size=default; +set max_sort_length=default; +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t2 (b int, + col1 varchar(255), + col2 varchar(255) + ) character set utf8; + +insert into t2 select + A.a+10*B.a, + concat('wow-wow-col1-value-', A.a+10*B.a+100*C.a), + concat('wow-wow-col2-value-', A.a+10*B.a+100*C.a) +from + t1 A, t1 B, t1 C where C.a < 8; + +create table t3 as +select distinct A.col1 as XX, B.col1 as YY +from + t2 A, t2 B +where A.b = B.b +order by A.col2, B.col2 limit 10, 1000000; + +drop table t1,t2,t3; + --echo End of 5.5 tests diff --git a/mysql-test/t/perror.test b/mysql-test/t/perror.test index 2b9907c0542..69f1cb3257e 100644 --- a/mysql-test/t/perror.test +++ b/mysql-test/t/perror.test @@ -27,7 +27,7 @@ enable_query_log; --exec $MY_PERROR 1062 2>&1 # test errors that contain characters to escape in the text. ---exec $MY_PERROR 1076 2>&1 +--exec $MY_PERROR 1408 2>&1 --exec $MY_PERROR 1459 2>&1 --exec $MY_PERROR 1461 2>&1 diff --git a/mysql-test/t/plugin_vars.test b/mysql-test/t/plugin_vars.test new file mode 100644 index 00000000000..8ba8fe2ec0e --- /dev/null +++ b/mysql-test/t/plugin_vars.test @@ -0,0 +1,56 @@ +--echo # +--echo # MDEV-5345 - Deadlock between mysql_change_user(), SHOW VARIABLES and +--echo # INSTALL PLUGIN +--echo # + +# Prepare test +delimiter |; +CREATE PROCEDURE p_install(x INT) +BEGIN + DECLARE CONTINUE HANDLER FOR 1126 BEGIN END; + WHILE x DO + SET x= x - 1; + INSTALL PLUGIN no_such_plugin SONAME 'no_such_object'; + END WHILE; +END| + +CREATE PROCEDURE p_show_vars(x INT) +WHILE x DO + SET x= x - 1; + SHOW VARIABLES; +END WHILE| +delimiter ;| + +connect(con1, localhost, root,,); +connect(con2, localhost, root,,); + +# Start test +connection con1; +--send CALL p_install(100) + +connection con2; +--send CALL p_show_vars(100) + +connection default; + +disable_result_log; +let $i= 100; +while ($i) +{ + change_user; + dec $i; +} + +# Cleanup +connection con1; +reap; +connection con2; +reap; +connection default; +enable_result_log; + +disconnect con1; +disconnect con2; +USE test; +DROP PROCEDURE p_install; +DROP PROCEDURE p_show_vars; diff --git a/mysql-test/t/processlist.test b/mysql-test/t/processlist.test index c7b775cf992..7a2b33699d5 100644 --- a/mysql-test/t/processlist.test +++ b/mysql-test/t/processlist.test @@ -32,4 +32,4 @@ connection default; select command, time < 5 from information_schema.processlist where id != connection_id(); disconnect con1; - +set debug_sync='reset'; diff --git a/mysql-test/t/quick_select_4161.test b/mysql-test/t/quick_select_4161.test index 1e746754b41..87323087622 100644 --- a/mysql-test/t/quick_select_4161.test +++ b/mysql-test/t/quick_select_4161.test @@ -50,4 +50,5 @@ connection default; disconnect killee; drop table t1; +set debug_sync='reset'; diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test index 6536c052019..5b78a352863 100644 --- a/mysql-test/t/repair.test +++ b/mysql-test/t/repair.test @@ -190,3 +190,23 @@ set @@autocommit= 0; repair table t1, t2; set @@autocommit= default; drop tables t1, t2; + +--echo # +--echo # Check that we have decent error messages when using crashed +--echo # .frm file from MySQL 3.23 +--echo # + +--echo # Test with a saved table from 3.23 +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file std_data/host_old.frm $MYSQLD_DATADIR/test/t1.frm +--copy_file std_data/host_old.MYD $MYSQLD_DATADIR/test/t1.MYD +--copy_file std_data/host_old.MYI $MYSQLD_DATADIR/test/t1.MYI + +--error ER_GET_ERRNO +select count(*) from t1; +check table t1; +repair table t1; +repair table t1 use_frm; +select count(*) from t1; +check table t1; +drop table t1; diff --git a/mysql-test/t/repair_symlink-5543.test b/mysql-test/t/repair_symlink-5543.test new file mode 100644 index 00000000000..bad65a4175a --- /dev/null +++ b/mysql-test/t/repair_symlink-5543.test @@ -0,0 +1,26 @@ +# +# MDEV-5543 MyISAM repair unsafe usage of TMD files +# +--source include/have_symlink.inc +--source include/not_windows.inc +--source include/have_maria.inc + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval create table t1 (a int) engine=myisam data directory='$MYSQL_TMP_DIR'; +insert t1 values (1); +--system ln -s $MYSQL_TMP_DIR/foobar5543 $MYSQL_TMP_DIR/t1.TMD +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +repair table t1; +drop table t1; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval create table t2 (a int) engine=aria data directory='$MYSQL_TMP_DIR'; +insert t2 values (1); +--system ln -s $MYSQL_TMP_DIR/foobar5543 $MYSQL_TMP_DIR/t2.TMD +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +repair table t2; +drop table t2; + +--list_files $MYSQL_TMP_DIR foobar5543 +--system rm $MYSQL_TMP_DIR/t1.TMD $MYSQL_TMP_DIR/t2.TMD + diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test index e043ec4d143..d6bca6b19b1 100644 --- a/mysql-test/t/select_found.test +++ b/mysql-test/t/select_found.test @@ -195,3 +195,16 @@ SELECT FOUND_ROWS(); DROP TABLE t1; # End of 4.1 tests + +# +# MDEV-5549 Wrong row counter in found_rows() result +# +create table t1 (f1 int primary key, f2 tinyint) engine=myisam; +insert t1 values (10,3),(11,2),(12,3); +create table t2 (f3 int primary key) engine=myisam; +insert t2 values (11),(12),(13); +#explain select f1 from t1,t2 where f1=f3 and f2=3 order by f1; +select f1 from t1,t2 where f1=f3 and f2=3 order by f1; +select found_rows(); +drop table t1, t2; + diff --git a/mysql-test/t/sp-bugs.test b/mysql-test/t/sp-bugs.test index 1ec154f1c69..8e6a25709aa 100644 --- a/mysql-test/t/sp-bugs.test +++ b/mysql-test/t/sp-bugs.test @@ -238,3 +238,59 @@ DROP FUNCTION testf_bug11763507; --echo #END OF BUG#11763507 test. +--echo # +--echo # MDEV-5531 double call procedure in one session +--echo # + +CREATE TABLE `t1` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `create_ts` int(10) unsigned DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; + +DELIMITER $$; + +CREATE PROCEDURE test_5531 (IN step TINYINT(1)) +BEGIN + DECLARE counts INT DEFAULT 0; + DECLARE cur1 CURSOR FOR + + SELECT ct.id + FROM (SELECT NULL) AS z + JOIN ( + SELECT id + FROM `t1` + LIMIT 10 + ) AS ct + JOIN (SELECT NULL) AS x ON( + EXISTS( + SELECT 1 + FROM `t1` + WHERE id=ct.id + LIMIT 1 + ) + ); + + IF step=1 THEN + TRUNCATE t1; + REPEAT + INSERT INTO `t1` + (create_ts) VALUES + (UNIX_TIMESTAMP()); + + SET counts=counts+1; + UNTIL counts>150 END REPEAT; + + SET max_sp_recursion_depth=1; + + CALL test_5531(2); + SET max_sp_recursion_depth=2; + CALL test_5531(2); + ELSEIF step=2 THEN + OPEN cur1; CLOSE cur1; + END IF; +END $$ +DELIMITER ;$$ +CALL test_5531(1); +DROP PROCEDURE test_5531; +DROP TABLE t1; diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test index 536606175bb..a6ce3f25617 100644 --- a/mysql-test/t/subselect_sj.test +++ b/mysql-test/t/subselect_sj.test @@ -2634,6 +2634,7 @@ INSERT INTO t2 VALUES ('x'); CREATE TABLE t3 (c3 VARCHAR(1)) ENGINE=MyISAM; INSERT INTO t3 VALUES ('x'),('d'); +--sorted_result SELECT * FROM t1, t2 WHERE pk IN ( SELECT pk FROM t1 LEFT JOIN t3 ON (c1 = c3 ) ) ORDER BY c2, c1; --echo # This should show that "t1 left join t3" is still in the semi-join nest: diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test index 58831c4ffb3..52a73d24822 100644 --- a/mysql-test/t/subselect_sj_mat.test +++ b/mysql-test/t/subselect_sj_mat.test @@ -1725,6 +1725,26 @@ INSERT INTO t1 VALUES (1,3,5),(2,4,6); SELECT * FROM t1 WHERE 8 IN (SELECT MIN(pk) FROM t1) AND (pk = a OR pk = b); DROP TABLE t1; +--echo # +--echo # MDEV-5368: Server crashes in Item_in_subselect::optimize on 2nd +--echo # execution of PS with IN subqueries, materialization+semijoin +--echo # +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1),(3); + +CREATE TABLE t2 (b INT) ENGINE=MyISAM; +CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2; +INSERT INTO t2 VALUES (8),(9); + +PREPARE stmt FROM " +SELECT * FROM t1 WHERE 1 IN ( SELECT b FROM v2 WHERE 2 IN ( SELECT MAX(a) FROM t1 ) ) +"; + +EXECUTE stmt; +EXECUTE stmt; +DROP TABLE t1, t2; +DROP VIEW v2; + --echo # End of 5.3 tests @@ -1750,5 +1770,25 @@ WHERE ( alias2.c2, alias1.c1 ) IN ( SELECT c4, c3 FROM t2 ) AND alias1.c1 IN ( S DROP TABLE t1,t2; set join_cache_level=@tmp_mdev5056; +--echo # +--echo # MDEV-5368: Server crashes in Item_in_subselect::optimize on 2nd +--echo # execution of PS with IN subqueries, materialization+semijoin +--echo # +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1),(3); + +CREATE TABLE t2 (b INT) ENGINE=MyISAM; +CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2; +INSERT INTO t2 VALUES (8),(9); + +PREPARE stmt FROM " +SELECT * FROM t1 WHERE 1 IN ( SELECT b FROM v2 WHERE 2 IN ( SELECT MAX(a) FROM t1 ) ) +"; + +EXECUTE stmt; +EXECUTE stmt; +DROP TABLE t1, t2; +DROP VIEW v2; + --echo # End of 5.5 tests diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index 7764b39bf33..2d61c7631f2 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -298,5 +298,11 @@ SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5'); SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5'); --echo # +--echo # MDEV-5506 safe_mutex: Trying to lock unitialized mutex at safemalloc.c on server shutdown after SELECT with CONVERT_TZ +--echo # +SELECT CONVERT_TZ('2001-10-08 00:00:00', MAKE_SET(0,'+01:00'), '+00:00' ); + + +--echo # --echo # End of 5.3 tests --echo # diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 5cb9d920c0c..c7a7e332236 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -4873,6 +4873,51 @@ deallocate prepare stmt; drop view v1; drop table t1,t2; +# +# MDEV-5414: RAND() in a subselect : different behavior in MariaDB and MySQL +# +create table t1 (a int); +insert into t1 values (1),(2); + +create view v1 (a,r) as select a,rand() from t1; + + +create table t2 select a, r as r1, r as r2, r as r3 from v1; + +select a, r1 = r2, r2 = r3 from t2; + +drop view v1; +drop table t1,t2; + +--echo # +--echo # MDEV-5515: 2nd execution of a prepared statement returns wrong results +--echo # +CREATE TABLE t1 (i1 INT, j1 INT NOT NULL, PRIMARY KEY (i1)); + +INSERT INTO t1 VALUES (30,300),(40,400); + +CREATE TABLE t2 (i2 INT); +INSERT INTO t2 VALUES (50),(60); + +CREATE TABLE t3 (c3 VARCHAR(20), i3 INT); +INSERT INTO t3 VALUES ('a',10),('b',2); + +CREATE TABLE t4 (i4 INT); +INSERT INTO t4 VALUES (1),(2); + +DROP VIEW IF EXISTS v1; +CREATE VIEW v1 AS select coalesce(j1,i3) AS v1_field1 from t2 join t3 left join t1 on ( i1 = i2 ); + +CREATE VIEW v2 AS select v1_field1 from t4 join v1; + +prepare my_stmt from "select v1_field1 from v2"; +execute my_stmt; +execute my_stmt; +deallocate prepare my_stmt; + +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3,t4; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.3 tests. --echo # ----------------------------------------------------------------- |