From 4747f9a7732c490e891c3aa22c3b0687e2520ab9 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Tue, 3 Aug 2010 14:52:20 +0300 Subject: addendum to the fix for bug #54476: fixed a failing test case. --- mysql-test/t/func_gconcat.test | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 693fa7d1c89..54c7291bb5e 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -734,6 +734,9 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1; +--echo End of 5.1 tests + + # # Bug#36785: Wrong error message when group_concat() exceeds max length # -- cgit v1.2.1 From 97057115962d9dfbe989c799cff089aec5cbcc60 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 9 Aug 2010 11:32:50 +0300 Subject: WL#1054: Pluggable authentication support Merged the implementation to a new base tree. --- mysql-test/t/change_user.test | 48 +++++ mysql-test/t/grant.test | 6 +- mysql-test/t/grant2.test | 4 +- mysql-test/t/plugin_auth-master.opt | 2 + mysql-test/t/plugin_auth.test | 298 +++++++++++++++++++++++++++++ mysql-test/t/system_mysql_db_fix40123.test | 2 +- mysql-test/t/system_mysql_db_fix50030.test | 2 +- mysql-test/t/system_mysql_db_fix50117.test | 2 +- 8 files changed, 356 insertions(+), 8 deletions(-) create mode 100644 mysql-test/t/plugin_auth-master.opt create mode 100644 mysql-test/t/plugin_auth.test (limited to 'mysql-test/t') diff --git a/mysql-test/t/change_user.test b/mysql-test/t/change_user.test index 3ed798e8d36..ed2e1d05f86 100644 --- a/mysql-test/t/change_user.test +++ b/mysql-test/t/change_user.test @@ -1,3 +1,51 @@ +# +# functional change user tests +# + +grant select on test.* to test_nopw; +grant select on test.* to test_oldpw identified by password "09301740536db389"; +grant select on test.* to test_newpw identified by "newpw"; + +select user(), current_user(), database(); +# +# massaging the data for tests to pass in the embedded server, +# that has authentication completely disabled. +# + +--replace_result <@> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); + + +change_user test_nopw; +--replace_result <@> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +change_user test_oldpw, oldpw; +--replace_result <@> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +change_user test_newpw, newpw; +--replace_result <@> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +change_user root; +--replace_result <@> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); + +change_user test_nopw,,test; +--replace_result <@> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +change_user test_oldpw,oldpw,test; +--replace_result <@> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +change_user test_newpw,newpw,test; +--replace_result <@> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); +change_user root,,test; +--replace_result <@> @> @localhost> +select concat('<', user(), '>'), concat('<', current_user(), '>'), database(); + +drop user test_nopw; +drop user test_oldpw; +drop user test_newpw; + # # Bug#20023 mysql_change_user() resets the value of SQL_BIG_SELECTS # diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index de43d6a74b4..e73f45a6c53 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -29,7 +29,7 @@ flush privileges; grant select on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA"; show grants for mysqltest_1@localhost; grant delete on mysqltest.* to mysqltest_1@localhost; -select * from mysql.user where user="mysqltest_1"; +query_vertical select * from mysql.user where user="mysqltest_1"; show grants for mysqltest_1@localhost; revoke delete on mysqltest.* from mysqltest_1@localhost; show grants for mysqltest_1@localhost; @@ -48,10 +48,10 @@ flush privileges; delete from mysql.user where user='mysqltest_1'; flush privileges; grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 10; -select * from mysql.user where user="mysqltest_1"; +query_vertical select * from mysql.user where user="mysqltest_1"; show grants for mysqltest_1@localhost; grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 20 max_connections_per_hour 30; -select * from mysql.user where user="mysqltest_1"; +query_vertical select * from mysql.user where user="mysqltest_1"; show grants for mysqltest_1@localhost; # This is just to double check that one won't ignore results of selects flush privileges; diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index 447848013f9..6c2ba0dd6fc 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -31,7 +31,7 @@ create user mysqltest_2@localhost; connect (user_a,localhost,mysqltest_1,,); connection user_a; grant select on `my\_1`.* to mysqltest_2@localhost; ---error ER_PASSWORD_NOT_ALLOWED +--error ER_DBACCESS_DENIED_ERROR grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass'; disconnect user_a; connection default; @@ -405,7 +405,7 @@ drop database mysqltest_1; # But anonymous users can't change their password connect (n5,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK); connection n5; ---error ER_DBACCESS_DENIED_ERROR +--error ER_PASSWORD_NO_MATCH set password = password("changed"); disconnect n5; connection default; diff --git a/mysql-test/t/plugin_auth-master.opt b/mysql-test/t/plugin_auth-master.opt new file mode 100644 index 00000000000..3536d102387 --- /dev/null +++ b/mysql-test/t/plugin_auth-master.opt @@ -0,0 +1,2 @@ +$PLUGIN_AUTH_OPT +$PLUGIN_AUTH_LOAD diff --git a/mysql-test/t/plugin_auth.test b/mysql-test/t/plugin_auth.test new file mode 100644 index 00000000000..f5a8bd416a0 --- /dev/null +++ b/mysql-test/t/plugin_auth.test @@ -0,0 +1,298 @@ +--source include/have_plugin_auth.inc +--source include/not_embedded.inc + +query_vertical SELECT PLUGIN_STATUS, PLUGIN_TYPE, PLUGIN_DESCRIPTION + FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME='test_plugin_server'; + +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; + +SELECT plugin,authentication_string FROM mysql.user WHERE User='plug'; + +--echo ## test plugin auth +--disable_query_log +--error ER_ACCESS_DENIED_ERROR : this should fail : no grant +connect(plug_con,localhost,plug,plug_dest); +--enable_query_log + +GRANT PROXY ON plug_dest TO plug; + +connect(plug_con,localhost,plug,plug_dest); + +connection plug_con; +select USER(),CURRENT_USER(); + +--echo ## test SET PASSWORD +#--error ER_SET_PASSWORD_AUTH_PLUGIN +SET PASSWORD = PASSWORD('plug_dest'); + +connection default; +disconnect plug_con; + +--echo ## test bad credentials +--disable_query_log +--error ER_ACCESS_DENIED_ERROR +connect(plug_con,localhost,plug,bad_credentials); +--enable_query_log + +--echo ## test bad default plugin : should get CR_AUTH_PLUGIN_CANNOT_LOAD +--disable_result_log +--disable_query_log +--error 2059 +connect(plug_con_wrongp,localhost,plug,plug_dest,,,,,wrong_plugin_name); +--enable_query_log +--enable_result_log + +--echo ## test correct default plugin +connect(plug_con_rightp,localhost,plug,plug_dest,,,,,auth_test_plugin); +connection plug_con_rightp; +select USER(),CURRENT_USER(); +connection default; +disconnect plug_con_rightp; + +--echo ## test no_auto_create_user sql mode with plugin users +SET @@sql_mode=no_auto_create_user; +GRANT INSERT ON TEST.* TO grant_user IDENTIFIED WITH 'test_plugin_server'; +SET @@sql_mode=default; +DROP USER grant_user; + +--echo ## test utf-8 user name +CREATE USER `Ÿ` IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; + +GRANT PROXY ON plug_dest TO `Ÿ`; + +connect(non_ascii,localhost,Ÿ,plug_dest); +connection non_ascii; +select USER(),CURRENT_USER(); + +connection default; +disconnect non_ascii; +DROP USER `Ÿ`; + +--echo ## test GRANT ... IDENTIFIED WITH/BY ... + +CREATE DATABASE test_grant_db; + +--echo # create new user via GRANT WITH +GRANT ALL PRIVILEGES ON test_grant_db.* TO new_grant_user + IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; + +GRANT PROXY ON plug_dest TO new_grant_user; + +connect(plug_con_grant,localhost,new_grant_user,plug_dest); +connection plug_con_grant; +select USER(),CURRENT_USER(); +USE test_grant_db; +CREATE TABLE t1 (a INT); +DROP TABLE t1; +connection default; +disconnect plug_con_grant; +REVOKE ALL PRIVILEGES ON test_grant_db.* FROM new_grant_user; + +--echo # try re-create existing user via GRANT IDENTIFIED BY +GRANT ALL PRIVILEGES ON test_grant_db.* TO new_grant_user + IDENTIFIED BY 'unused_password'; + +--echo # make sure password doesn't take precendence +--disable_query_log +--error ER_ACCESS_DENIED_ERROR +connect(plug_con_grant_deny,localhost,new_grant_user,unused_password); +--enable_query_log + +--echo #make sure plugin auth still available +connect(plug_con_grant,localhost,new_grant_user,plug_dest); +connection plug_con_grant; +select USER(),CURRENT_USER(); +USE test_grant_db; +CREATE TABLE t1 (a INT); +DROP TABLE t1; +connection default; +disconnect plug_con_grant; + +DROP USER new_grant_user; + +--echo # try re-create existing user via GRANT IDENTIFIED WITH + +--error ER_GRANT_PLUGIN_USER_EXISTS +GRANT ALL PRIVILEGES ON test_grant_db.* TO plug + IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; + +--error ER_GRANT_PLUGIN_USER_EXISTS +GRANT ALL PRIVILEGES ON test_grant_db.* TO plug_dest + IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; + +--error ER_PARSE_ERROR +REVOKE SELECT on test_grant_db.* FROM joro + INDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; + +--error ER_PARSE_ERROR +REVOKE SELECT on test_grant_db.* FROM joro + INDENTIFIED BY 'plug_dest_passwd'; + +--error ER_PARSE_ERROR +REVOKE SELECT on test_grant_db.* FROM joro + INDENTIFIED BY PASSWORD 'plug_dest_passwd'; + +DROP DATABASE test_grant_db; + +--echo ## GRANT PROXY tests + +CREATE USER grant_plug IDENTIFIED WITH 'test_plugin_server' + AS 'grant_plug_dest'; +CREATE USER grant_plug_dest IDENTIFIED BY 'grant_plug_dest_passwd'; +CREATE USER grant_plug_dest2 IDENTIFIED BY 'grant_plug_dest_passwd2'; + +--echo # ALL PRIVILEGES doesn't include PROXY +GRANT ALL PRIVILEGES ON *.* TO grant_plug; +--disable_query_log +--error ER_ACCESS_DENIED_ERROR : this should fail : no grant +connect(grant_plug_con,localhost,grant_plug,grant_plug_dest); +--enable_query_log + +--error ER_PARSE_ERROR : this should fail : can't combine PROXY +GRANT ALL PRIVILEGES,PROXY ON grant_plug_dest TO grant_plug; + +--echo this should fail : can't combine PROXY +--error ER_PARSE_ERROR +GRANT ALL SELECT,PROXY ON grant_plug_dest TO grant_plug; + +--echo # this should fail : no such grant +--error ER_NONEXISTING_GRANT +REVOKE PROXY ON grant_plug_dest FROM grant_plug; + +connect(grant_plug_dest_con,localhost,grant_plug_dest,grant_plug_dest_passwd); +connection grant_plug_dest_con; +--echo in grant_plug_dest_con + +--echo ## testing what an ordinary user can grant +--echo this should fail : no rights to grant all +--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR +GRANT PROXY ON ''@'' TO grant_plug; + +--echo this should fail : not the same user +--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR +GRANT PROXY ON grant_plug TO grant_plug_dest; + +--echo this should fail : same user, but on a different host +--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR +GRANT PROXY ON grant_plug_dest TO grant_plug; + +--echo this should work : same user +GRANT PROXY ON grant_plug_dest@localhost TO grant_plug_dest2; +REVOKE PROXY ON grant_plug_dest@localhost FROM grant_plug_dest2; + +--echo this should work : same user +GRANT PROXY ON grant_plug_dest@localhost TO grant_plug WITH GRANT OPTION; +REVOKE PROXY ON grant_plug_dest@localhost FROM grant_plug; + +--echo this should fail : can't create users +--error ER_CANT_CREATE_USER_WITH_GRANT +GRANT PROXY ON grant_plug_dest@localhost TO grant_plug@localhost; + +connection default; +--echo in default connection +disconnect grant_plug_dest_con; + +--echo # test what root can grant + +--echo should work : root has PROXY to all users +GRANT PROXY ON ''@'' TO grant_plug; +REVOKE PROXY ON ''@'' FROM grant_plug; + +--echo should work : root has PROXY to all users +GRANT PROXY ON ''@'' TO proxy_admin IDENTIFIED BY 'test' + WITH GRANT OPTION; + +--echo need USAGE : PROXY doesn't contain it. +GRANT USAGE on *.* TO proxy_admin; + +connect (proxy_admin_con,localhost,proxy_admin,test); +connection proxy_admin_con; +--echo in proxy_admin_con; + +--echo should work : proxy_admin has proxy to ''@'' +GRANT PROXY ON future_user TO grant_plug; + +connection default; +--echo in default connection +disconnect proxy_admin_con; + +SHOW GRANTS FOR grant_plug; +REVOKE PROXY ON future_user FROM grant_plug; +SHOW GRANTS FOR grant_plug; + +--echo ## testing drop user +CREATE USER test_drop@localhost; +GRANT PROXY ON future_user TO test_drop@localhost; +SHOW GRANTS FOR test_drop@localhost; +DROP USER test_drop@localhost; +SELECT * FROM mysql.proxy_priv WHERE Host = 'test_drop' AND User = 'localhost'; + +DROP USER proxy_admin; + +DROP USER grant_plug,grant_plug_dest,grant_plug_dest2; + +--echo ## END GRANT PROXY tests + +--echo ## cleanup +DROP USER plug; +DROP USER plug_dest; + +--echo ## @@proxy_user tests +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +GRANT PROXY ON plug_dest TO plug; + +SELECT USER(),CURRENT_USER(),@@LOCAL.proxy_user; + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@GLOBAL.proxy_user; +SELECT @@LOCAL.proxy_user; + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET GLOBAL proxy_user = 'test'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET LOCAL proxy_user = 'test'; +SELECT @@LOCAL.proxy_user; + +connect(plug_con,localhost,plug,plug_dest); +connection plug_con; +--echo # in connection plug_con +SELECT @@LOCAL.proxy_user; +connection default; +--echo # in connection default +disconnect plug_con; + +--echo ## cleanup +DROP USER plug; +DROP USER plug_dest; +--echo ## END @@proxy_user tests + +--echo ## @@external_user tests +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +GRANT PROXY ON plug_dest TO plug; +SELECT USER(),CURRENT_USER(),@@LOCAL.external_user; + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@GLOBAL.external_user; +SELECT @@LOCAL.external_user; + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET GLOBAL external_user = 'test'; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET LOCAL external_user = 'test'; +SELECT @@LOCAL.external_user; + +connect(plug_con,localhost,plug,plug_dest); +connection plug_con; +--echo # in connection plug_con +SELECT @@LOCAL.external_user; +connection default; +--echo # in connection default +disconnect plug_con; + +--echo ## cleanup +DROP USER plug; +DROP USER plug_dest; +--echo ## END @@external_user tests diff --git a/mysql-test/t/system_mysql_db_fix40123.test b/mysql-test/t/system_mysql_db_fix40123.test index 818993e5f27..d069271a02e 100644 --- a/mysql-test/t/system_mysql_db_fix40123.test +++ b/mysql-test/t/system_mysql_db_fix40123.test @@ -72,7 +72,7 @@ CREATE TABLE time_zone_leap_second ( Transition_time bigint signed NOT NULL, -- disable_query_log # Drop all tables created by this test -DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index; +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxy_priv; -- enable_query_log diff --git a/mysql-test/t/system_mysql_db_fix50030.test b/mysql-test/t/system_mysql_db_fix50030.test index 45084177570..53166919f1c 100644 --- a/mysql-test/t/system_mysql_db_fix50030.test +++ b/mysql-test/t/system_mysql_db_fix50030.test @@ -78,7 +78,7 @@ INSERT INTO servers VALUES ('test','localhost','test','root','', 0,'','mysql','r -- disable_query_log # Drop all tables created by this test -DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index; +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxy_priv; -- enable_query_log diff --git a/mysql-test/t/system_mysql_db_fix50117.test b/mysql-test/t/system_mysql_db_fix50117.test index bed00239081..872829ae79d 100644 --- a/mysql-test/t/system_mysql_db_fix50117.test +++ b/mysql-test/t/system_mysql_db_fix50117.test @@ -97,7 +97,7 @@ CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, -- disable_query_log # Drop all tables created by this test -DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index; +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxy_priv; -- enable_query_log -- cgit v1.2.1 From 6d14cae604d064ec5cd8141bfd05408cc41bf134 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Thu, 12 Aug 2010 15:59:02 +0500 Subject: Bug#55146 Assertion `m_part_spec.start_part == m_part_spec.end_part' in index_read_idx_map As we check for the impossible partitions earlier, it's possible that we don't find any suitable partitions at all. So this assertion just has to be corrected for this case. per-file comments: mysql-test/r/partition_innodb.result Bug#55146 Assertion `m_part_spec.start_part == m_part_spec.end_part' in index_read_idx_map test result updated. mysql-test/t/partition_innodb.test Bug#55146 Assertion `m_part_spec.start_part == m_part_spec.end_part' in index_read_idx_map test case added. sql/ha_partition.cc Bug#55146 Assertion `m_part_spec.start_part == m_part_spec.end_part' in index_read_idx_map Assertion changed to '>=' as the prune_partition_set() in the get_partition_set() can do start_part= end_part+1 if no possible partitions were found. --- mysql-test/t/partition_innodb.test | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index e1ac7b4c7eb..cef3540f9a7 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -401,3 +401,16 @@ connection default; SELECT * FROM t1; COMMIT; DROP TABLE t1; + +# +# Bug #55146 Assertion `m_part_spec.start_part == m_part_spec.end_part' in index_read_idx_map +# + +CREATE TABLE t1 (i1 int NOT NULL primary key, f1 int) ENGINE = InnoDB + PARTITION BY HASH(i1) PARTITIONS 2; + +INSERT INTO t1 VALUES (1,1), (2,2); + +SELECT * FROM t1 WHERE i1 = ( SELECT i1 FROM t1 WHERE f1=0 LIMIT 1 ); + +DROP TABLE t1; -- cgit v1.2.1 From 53e0b31e9c97754f9bd147049c70e55b77be8fc5 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 13 Aug 2010 14:20:49 +0300 Subject: merge --- mysql-test/t/user_var.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index fc4bc61f526..06508c43766 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -326,6 +326,24 @@ INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1); DROP TABLE t1; +# +# Bug #55615: debug assertion after using variable in assignment and +# referred to +# Bug #55564: crash with user variables, assignments, joins... +# + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(0); +--echo # BUG#55615 : should not crash +SELECT (@a:=(SELECT @a:=1 FROM t1 LIMIT 1)) AND COUNT(1) FROM t1 GROUP BY @a; +--echo # BUG#55564 : should not crash +SELECT IF( + @v:=LEAST((SELECT 1 FROM t1 t2 LEFT JOIN t1 ON (@v) GROUP BY t1.a), a), + count(*), 1) +FROM t1 GROUP BY a LIMIT 1; + +DROP TABLE t1; + --echo End of 5.1 tests # -- cgit v1.2.1 From 86327002fe29e70f0e29d97e0cf0b1e14806c2f8 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 30 Aug 2010 17:33:55 +0200 Subject: Bug#50036: Inconsistent errors when using TIMESTAMP columns/expressions It was hard to understand what the error really meant. The error checking in partitioning is done in several different parts during the execution of a query which can make it hard to return useful errors. Added a new error for bad VALUES part in the per PARTITION clause. Using the more verbose error that a column is not allowed in the partitioning function instead of just that the function is not allowed. mysql-test/r/partition.result: changed error to be more specific mysql-test/r/partition_error.result: updated result mysql-test/std_data/parts/t1TIMESTAMP.frm: .frm file of CREATE TABLE t1 (a TIMESTAMP) PARTITION BY HASH(TO_DAYS(a)); mysql-test/t/partition.test: changed error to be more specific mysql-test/t/partition_error.test: Added test (also for verifying behaviour of previously created tables which is no longer allowed). Updated expected errors in other places sql/partition_info.cc: Added function report_part_expr_error to be able to return a more specific error. Renamed fix_func_partition to fix_partition_values since the function really fixes/checks the VALUES clause. sql/partition_info.h: removed part_result_type, since it was unused. renamed fix_funk_partition->fix_partition_values added report_part_expr_error sql/share/errmsg-utf8.txt: Added a more specific error. sql/sql_partition.cc: made use of report_part_expr_error to get a more specific error. sql/sql_yacc.yy: Changed error message to be more specific. And return an other error code. --- mysql-test/t/partition.test | 4 +- mysql-test/t/partition_error.test | 102 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 99 insertions(+), 7 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 1224dee24ed..fe2ef8cea1f 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -430,12 +430,12 @@ drop table t1; # # BUG 16002: Handle unsigned integer functions properly # ---error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR create table t1 (a bigint) partition by range (a) (partition p0 values less than (0xFFFFFFFFFFFFFFFF), partition p1 values less than (10)); ---error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR create table t1 (a bigint) partition by list (a) (partition p0 values in (0xFFFFFFFFFFFFFFFF), diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 1496a626796..1afb65d496c 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -5,11 +5,103 @@ -- source include/have_partition.inc --disable_warnings -drop table if exists t1; +drop table if exists t1, t2; --enable_warnings let $MYSQLD_DATADIR= `SELECT @@datadir`; +--echo # +--echo # Bug#50036: Inconsistent errors when using TIMESTAMP +--echo # columns/expressions + +--echo # 1. correct and appropriate errors in light of +--echo # the fix for BUG#42849: +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (TO_DAYS(c)) +(PARTITION p0 VALUES LESS THAN (10000), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); +CREATE TABLE t2 (c TIMESTAMP); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +ALTER TABLE t2 +PARTITION BY RANGE (TO_DAYS(c)) +(PARTITION p0 VALUES LESS THAN (10000), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); + +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE COLUMNS(c) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +ALTER TABLE t2 PARTITION BY RANGE COLUMNS(c) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); +DROP TABLE t2; + +--echo # 2. These errors where questionable before the fix: + +--echo # VALUES clause are checked first, clearified the error message. +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (c) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); + +--echo # TIMESTAMP is not INT (e.g. UNIX_TIMESTAMP). +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (UNIX_TIMESTAMP(c)) +(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); + +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY RANGE (UNIX_TIMESTAMP(c)) +(PARTITION p0 VALUES LESS THAN (UNIX_TIMESTAMP('2000-01-01 00:00:00')), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); +DROP TABLE t1; + +--echo # Changed error from ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD +CREATE TABLE t1 (c TIMESTAMP) +PARTITION BY HASH (c) PARTITIONS 4; + +--echo # Added test with existing TIMESTAMP partitioning (when it was allowed). + +CREATE TABLE t1 (a TIMESTAMP) +PARTITION BY HASH (UNIX_TIMESTAMP(a)); +INSERT INTO t1 VALUES ('2000-01-02 03:04:05'); +--sorted_result +SELECT * FROM t1; +FLUSH TABLES; +--remove_file $MYSQLD_DATADIR/test/t1.frm +--copy_file std_data/parts/t1TIMESTAMP.frm $MYSQLD_DATADIR/test/t1.frm +--sorted_result +SELECT * FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES ('2001-02-03 04:05:06'); +--sorted_result +SELECT * FROM t1; +ALTER TABLE t1 ADD PARTITION PARTITIONS 2; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +ALTER TABLE t1 +PARTITION BY RANGE (TO_DAYS(a)) +(PARTITION p0 VALUES LESS THAN (10000), + PARTITION p1 VALUES LESS THAN (MAXVALUE)); +SHOW CREATE TABLE t1; +CREATE TABLE t2 LIKE t1; +SHOW CREATE TABLE t2; +DROP TABLE t2; +CREATE TABLE t2 SELECT * FROM t1; +DROP TABLE t2; +ALTER TABLE t1 PARTITION BY HASH (UNIX_TIMESTAMP(a)); +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD PARTITION PARTITIONS 2; +SHOW CREATE TABLE t1; +--sorted_result +SELECT * FROM t1; +DROP TABLE t1; + --echo # --echo # Bug#49161: Out of memory; restart server and try again (needed 2 bytes) --echo # @@ -536,7 +628,7 @@ partitions 2 # # Partition by range, inconsistent partition function and constants # ---error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR CREATE TABLE t1 ( a int not null, b int not null, @@ -849,7 +941,7 @@ partitions 2 # # Partition by list, wrong constant result type (not INT) # ---error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR +--error ER_VALUES_IS_NOT_INT_TYPE_ERROR CREATE TABLE t1 ( a int not null, b int not null, @@ -939,13 +1031,13 @@ PARTITION pmax VALUES LESS THAN MAXVALUE); # Check that allowed arithmetic/math functions involving TIMESTAMP values result # in ER_PARTITION_FUNC_NOT_ALLOWED_ERROR when used as a partitioning function ---error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY) PARTITION BY RANGE (a) ( PARTITION p VALUES LESS THAN (20080819), PARTITION pmax VALUES LESS THAN MAXVALUE); ---error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR +--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD ALTER TABLE old PARTITION BY RANGE (a) ( PARTITION p VALUES LESS THAN (20080819), -- cgit v1.2.1 From cddb976f28678bf27d198c68ce39ca80a69a728e Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Tue, 31 Aug 2010 13:04:19 +0400 Subject: Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from 5.1.50 to 5.5.6". Debug builds of the server aborted due to an assertion failure when DROP DATABASE statement was run on an installation which had outdated or corrupt mysql.proc table. Particularly this affected the mysql_upgrade tool which is run as part of 5.1 to 5.5 upgrade. The problem was that sp_drop_db_routines(), which was invoked during dropping of the database, could have returned without closing and unlocking mysql.proc table in cases when this table was not up-to-date with the current server. As a result further attempt to open and lock the mysql.event table, which was necessary to complete dropping of the database, ended up with an assert. This patch solves this problem by ensuring that sp_drop_db_routines() always closes mysql.proc table and releases metadata locks on it. This is achieved by changing open_proc_table_for_update() function to close tables and release metadata locks acquired by it in case of failure. This step also makes behavior of the latter function consistent with behavior of open_proc_table_for_read()/ open_and_lock_tables(). Test case for this bug was added to sp-destruct.test. --- mysql-test/t/sp-destruct.test | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test index b7090c01f1e..a5c287e44a8 100644 --- a/mysql-test/t/sp-destruct.test +++ b/mysql-test/t/sp-destruct.test @@ -222,3 +222,33 @@ SHOW WARNINGS; --echo # Restore the procs_priv table RENAME TABLE procs_priv_backup TO mysql.procs_priv; FLUSH TABLE mysql.procs_priv; + + +--echo # +--echo # Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from +--echo # 5.1.50 to 5.5.6". +--echo # +--disable_warnings +drop database if exists mysqltest; +--enable_warnings +--echo # Backup mysql.proc. +flush table mysql.proc; +let $MYSQLD_DATADIR= `select @@datadir`; +--copy_file $MYSQLD_DATADIR/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/proc.frm +--copy_file $MYSQLD_DATADIR/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/proc.MYD +--copy_file $MYSQLD_DATADIR/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/proc.MYI + +create database mysqltest; +--echo # Corrupt mysql.proc to make it unusable by current version of server. +alter table mysql.proc drop column type; +--echo # The below statement should not cause assertion failure. +drop database mysqltest; + +--echo # Restore mysql.proc. +drop table mysql.proc; +--copy_file $MYSQLTEST_VARDIR/tmp/proc.frm $MYSQLD_DATADIR/mysql/proc.frm +--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYD $MYSQLD_DATADIR/mysql/proc.MYD +--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYI $MYSQLD_DATADIR/mysql/proc.MYI +--remove_file $MYSQLTEST_VARDIR/tmp/proc.frm +--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYD +--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYI -- cgit v1.2.1 From 51a81b6fafac96282fd1b1dd7094f3ad8197cd40 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Wed, 8 Sep 2010 10:25:37 +0200 Subject: Bug #56292 Deadlock with ALTER TABLE and MERGE tables ALTER TABLE on a MERGE table could cause a deadlock with two other connections if we reached a situation where: 1) A connection doing ALTER TABLE can't upgrade to MDL_EXCLUSIVE on the parent table, but holds TL_READ_NO_INSERT on the child tables. 2) A connection doing DELETE on a child table can't get TL_WRITE on it since ALTER TABLE holds TL_READ_NO_INSERT. 3) A connection doing SELECT on the parent table can't get TL_READ on the child tables since TL_WRITE is ahead in the lock queue, but holds MDL_SHARED_READ on the parent table preventing ALTER TABLE from upgrading. For regular tables, this deadlock is avoided by having ALTER TABLE take a MDL_SHARED_NO_WRITE metadata lock on the table. This prevents DELETE from acquiring MDL_SHARED_WRITE on the table before ALTER TABLE tries to upgrade to MDL_EXCLUSIVE. In the example above, SELECT would therefore not be blocked by the pending DELETE as DELETE would not be able to enter TL_WRITE in the table lock queue. This patch fixes the problem for merge tables by using the same metadata lock type for child tables as for the parent table. The child tables will in this case therefore be locked with MDL_SHARED_NO_WRITE, preventing DELETE from acquiring a metadata lock and enter into the table lock queue. Change in behavior: By taking the same metadata lock for child tables as for the parent table, LOCK TABLE on the parent table will now also implicitly lock the child tables. Since LOCK TABLE on the parent table now takes more than one metadata lock, it is possible for LOCK TABLE ... WRITE on the parent table or child tables to give ER_LOCK_DEADLOCK error. Test case added to mdl_sync.test. Merge.test/.result has been updated to reflect the change to LOCK TABLE. --- mysql-test/t/mdl_sync.test | 62 ++++++++++++++++++++++++++++++++++++++++++++++ mysql-test/t/merge.test | 3 +-- 2 files changed, 63 insertions(+), 2 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/mdl_sync.test b/mysql-test/t/mdl_sync.test index 55c04d7870b..f7780d2003a 100644 --- a/mysql-test/t/mdl_sync.test +++ b/mysql-test/t/mdl_sync.test @@ -4532,6 +4532,68 @@ disconnect con2; disconnect con3; +--echo # +--echo # Bug#56292 Deadlock with ALTER TABLE and MERGE tables +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1, t2, m1; +--enable_warnings + +CREATE TABLE t1(a INT) engine=MyISAM; +CREATE TABLE t2(a INT) engine=MyISAM; +CREATE TABLE m1(a INT) engine=MERGE UNION=(t1, t2); + +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES (3), (4); + +connect(con1, localhost, root); +connect(con2, localhost, root); + +--echo # Connection con1 +connection con1; +SET DEBUG_SYNC= 'mdl_upgrade_shared_lock_to_exclusive SIGNAL upgrade WAIT_FOR continue'; +--echo # Sending: +--send ALTER TABLE m1 engine=MERGE UNION=(t2, t1) + +--echo # Connection con2 +connection con2; +--echo # Waiting for ALTER TABLE to try lock upgrade +SET DEBUG_SYNC= 'now WAIT_FOR upgrade'; +--echo # Sending: +--send DELETE FROM t2 WHERE a = 3 + +--echo # Connection default +connection default; +--echo # Check that DELETE is waiting on a metadata lock and not a table lock. +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = "Waiting for table metadata lock" AND + info = "DELETE FROM t2 WHERE a = 3"; +--source include/wait_condition.inc +--echo # Now that DELETE blocks on a metadata lock, we should be able to do +--echo # SELECT * FROM m1 here. SELECT used to be blocked by a DELETE table +--echo # lock request. +SELECT * FROM m1; +--echo # Resuming ALTER TABLE +SET DEBUG_SYNC= 'now SIGNAL continue'; + +--echo # Connection con1 +connection con1; +--echo # Reaping: ALTER TABLE m1 engine=MERGE UNION=(t2, t1) +--reap +--echo # Connection con2 +connection con2; +--echo # Reaping: DELETE FROM t2 WHERE a = 3 +--reap +--echo # Connection default +connection default; +DROP TABLE m1, t1, t2; +SET DEBUG_SYNC= 'RESET'; +disconnect con1; +disconnect con2; + + # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index b6ad3324d19..1553d7f29c5 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -2519,12 +2519,11 @@ UNLOCK TABLES; DROP TABLE m1, t1; --echo # ---echo # If children are to be altered, they need an explicit lock. +--echo # Locking the merge table will implicitly lock children. --echo # CREATE TABLE t1 (c1 INT); CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1); LOCK TABLE m1 WRITE; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE ALTER TABLE t1 ADD INDEX (c1); LOCK TABLE m1 WRITE, t1 WRITE; ALTER TABLE t1 ADD INDEX (c1); -- cgit v1.2.1 From 65a438d87af11f314c5c235cd9e51ebee1852e82 Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Thu, 9 Sep 2010 18:29:14 +0400 Subject: Fix for bug #55273 "FLUSH TABLE tm WITH READ LOCK for Merge table causes assert failure". Attempting to use FLUSH TABLE table_list WITH READ LOCK statement for a MERGE table led to an assertion failure if one of its children was not present in the list of tables to be flushed. The problem was not visible in non-debug builds. The assertion failure was caused by the fact that in such situations FLUSH TABLES table_list WITH READ LOCK implementation tried to use (e.g. lock) such child tables without acquiring metadata lock on them. This happened because when opening tables we assumed metadata locks on all tables were already acquired earlier during statement execution and a such assumption was false for MERGE children. This patch fixes the problem by ensuring at open_tables() time that we try to acquire metadata locks on all tables to be opened. For normal tables such requests are satisfied instantly since locks are already acquired for them. For MERGE children metadata locks are acquired in normal fashion. Note that FLUSH TABLES merge_table WITH READ LOCK will lock for read both the MERGE table and its children but will flush only the MERGE table. To flush children one has to mention them in table list explicitly. This is expected behavior and it is consistent with usage patterns for this statement (e.g. in mysqlhotcopy script). mysql-test/r/flush.result: Added test case for bug #55273 "FLUSH TABLE tm WITH READ LOCK for Merge table causes assert failure". mysql-test/t/flush.test: Added test case for bug #55273 "FLUSH TABLE tm WITH READ LOCK for Merge table causes assert failure". sql/sql_base.cc: Changed lock_table_names() to support newly introduced MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK flag. sql/sql_base.h: Introduced MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK flag for open_tables() and lock_table_names() which allows to skip acquiring of global and schema-scope locks when SNW, SNRW or X metadata locks are acquired. sql/sql_reload.cc: Changed "FLUSH TABLES table_list WITH READ LOCK" code not to cause assert about missing metadata locks when MERGE table is flushed without one of its underlying tables. To achieve this we no longer call open_and_lock_tables() with MYSQL_OPEN_HAS_MDL_LOCK flag so this function automatically acquires metadata locks on MERGE children if such lock has not been already acquired at earlier stage. Instead we call this function with MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK flag to suppress acquiring of global IX lock in order to keep FLUSH TABLES table_list WITH READ LOCK compatible with FLUSH TABLE WITH READ LOCK. Also changed implementation to use lock_table_names() function for pre-acquiring of metadata locks instead of custom code. To implement this change moved setting of open_type member for table list elements to parser. sql/sql_yacc.yy: Now we set acceptable type of table for FLUSH TABLES table_list WITH READ LOCK at parsing time instead of execution time. --- mysql-test/t/flush.test | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index d4c3533847d..1cafbe3e6bd 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -546,3 +546,34 @@ disconnect con2; connection default; drop table t1; + +--echo # +--echo # Test for bug #55273 "FLUSH TABLE tm WITH READ LOCK for Merge table +--echo # causes assert failure". +--echo # +--disable_warnings +drop table if exists t1, t2, tm; +--enable_warnings +create table t1 (i int); +create table t2 (i int); +create table tm (i int) engine=merge union=(t1, t2); +insert into t1 values (1), (2); +insert into t2 values (3), (4); +--echo # The below statement should succeed and lock merge +--echo # table for read. Only merge table gets flushed and +--echo # not underlying tables. +flush tables tm with read lock; +select * from tm; +--echo # Check that underlying tables are locked. +select * from t1; +select * from t2; +unlock tables; +--echo # This statement should succeed as well and flush +--echo # all tables in the list. +flush tables tm, t1, t2 with read lock; +select * from tm; +--echo # Naturally, underlying tables should be locked in this case too. +select * from t1; +select * from t2; +unlock tables; +drop tables tm, t1, t2; -- cgit v1.2.1 From 5f352c28871442f20ae9d0c1a684ef8d7abb7599 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Mon, 13 Sep 2010 13:31:22 +0200 Subject: Bug #56448 Assertion failed: ! is_set() with second xa end The problem was that issuing XA END when the XA transaction was already ended, caused an assertion. This assertion tests that the server does not try to send OK to the client if there has already been an error reported. The bug was only noticeable on debug versions of the server. The reason for the problem was that the trans_xa_end() function reported success if the transaction was at XA_IDLE state at the end regardless of any errors occured during processing of trans_xa_end(). So if the transaction state was XA_IDLE already, reported errors would be ignored. This patch fixes the problem by having trans_xa_end() take into consideration any reported errors. The patch also fixes a similar bug with XA PREPARE. Test case added to xa.test. --- mysql-test/t/xa.test | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test index fe36af60c27..3fd243398a9 100644 --- a/mysql-test/t/xa.test +++ b/mysql-test/t/xa.test @@ -228,6 +228,23 @@ XA ROLLBACK 'xid1'; disconnect con1; DROP TABLE t1; + +--echo # +--echo # Bug#56448 Assertion failed: ! is_set() with second xa end +--echo # + +XA START 'x'; +XA END 'x'; +# Second XA END caused an assertion. +--error ER_XAER_RMFAIL +XA END 'x'; +XA PREPARE 'x'; +# Second XA PREPARE also caused an assertion. +--error ER_XAER_RMFAIL +XA PREPARE 'x'; +XA ROLLBACK 'x'; + + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc -- cgit v1.2.1 From e86bbbda55c12945aed9b141d4442b4dd6c49ea0 Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Wed, 15 Sep 2010 18:15:31 +0400 Subject: Fix for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". Attempting to issue an INSERT DELAYED statement for a MERGE table might have caused a deadlock if it happened as part of a transaction or under LOCK TABLES, and there was a concurrent DDL or LOCK TABLES ... WRITE statement which tried to lock one of its underlying tables. The problem occurred when a delayed insert handler thread tried to open a MERGE table and discovered that to do this it had also to open all underlying tables and hence acquire metadata locks on them. Since metadata locks on the underlying tables were not pre-acquired by the connection thread executing INSERT DELAYED, attempts to do so might lead to waiting. In this case the connection thread had to wait for the delayed insert thread. If the thread which was preventing the lock on the underlying table from being acquired had to wait for the connection thread (due to this or other metadata locks), a deadlock occurred. This deadlock was not detected by the MDL deadlock detector since waiting for the handler thread by the connection thread is not represented in the wait-for graph. This patch solves the problem by ensuring that the delayed insert handler thread never tries to open underlying tables of a MERGE table. Instead open_tables() is aborted right after the parent table is opened and a ER_DELAYED_NOT_SUPPORTED error is emitted (which is passed to the connection thread and ultimately to the user). mysql-test/r/merge.result: Added test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". mysql-test/t/merge.test: Added test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". sql/sql_base.cc: Changed open_n_lock_single_table() to take prelocking strategy as an argument instead of always using DML_prelocking_strategy. sql/sql_base.h: Changed open_n_lock_single_table() to take prelocking strategy as an argument instead of always using DML_prelocking_strategy. Added a version of this function which is compatible with old signature. sql/sql_insert.cc: When opening MERGE table in delayed insert thread stop and emit ER_DELAYED_NOT_SUPPORTED right after opening main table and before opening underlying tables. This ensures that we won't try to acquire metadata lock on underlying tables which might lead to a deadlock. This is achieved by using special prelocking strategy which abort open_tables() process as soon as we discover that we have opened table with engine which doesn't support delayed inserts. --- mysql-test/t/merge.test | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 1553d7f29c5..3633a8b30ad 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -2,6 +2,9 @@ # Test of MERGE TABLES # +# Save the initial number of concurrent sessions. +--source include/count_sessions.inc + # MERGE tables require MyISAM tables let $default=`select @@global.storage_engine`; set global storage_engine=myisam; @@ -2664,6 +2667,55 @@ drop view v1; drop temporary table tmp; drop table t1, t2, t3, m1, m2; + +--echo # +--echo # Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". +--echo # +connect (con1,localhost,root,,); +connection default; +--disable_warnings +drop table if exists t1, t2, tm; +--enable_warnings +create table t1(a int); +create table t2(a int); +create table tm(a int) engine=merge union=(t1, t2); +begin; +select * from t1; + +--echo # Connection 'con1'. +connection con1; +--echo # Sending: +--send alter table t1 comment 'test' + +--echo # Connection 'default'. +connection default; +--echo # Wait until ALTER TABLE blocks and starts waiting +--echo # for connection 'default'. It should wait with a +--echo # pending SNW lock on 't1'. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock" and + info = "alter table t1 comment 'test'"; +--source include/wait_condition.inc +--echo # Attempt to perform delayed insert into 'tm' should not lead +--echo # to a deadlock. Instead error ER_DELAYED_NOT_SUPPORTED should +--echo # be emitted. +--error ER_DELAYED_NOT_SUPPORTED +insert delayed into tm values (1); +--echo # Unblock ALTER TABLE. +commit; + +--echo # Connection 'con1'. +connection con1; +--echo # Reaping ALTER TABLE: +--reap + +--echo # Connection 'default'. +connection default; +disconnect con1; +drop tables tm, t1, t2; + + --echo End of 6.0 tests --disable_result_log @@ -2671,3 +2723,7 @@ drop table t1, t2, t3, m1, m2; eval set global storage_engine=$default; --enable_result_log --enable_query_log + +# Check that all connections opened by test cases in this file are really +# gone so execution of other tests won't be affected by their presence. +--source include/wait_until_count_sessions.inc -- cgit v1.2.1 From 428f0bdefbf866f0a9939e4153393b1e4b8a1a82 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Thu, 16 Sep 2010 11:01:06 +0200 Subject: Bug#56287: mysql5.1.50 crash when using Partition datetime in sub in query When having a sub query in partitioned innodb one could make the partitioning engine to search for a 'index_next_same' on a partition that had not been initialized. Problem was that the subselect function looks at table->status which was not set in the partitioning handler when it skipped scanning due to no matching partitions found. Fixed by setting table->status = STATUS_NOT_FOUND when there was no partitions to scan. (If there are partitions to scan, it will be set in the partitions handler.) mysql-test/r/partition_innodb.result: added result mysql-test/t/partition_innodb.test: added test sql/ha_partition.cc: set table status to not found, if there ar no partitions to scan. --- mysql-test/t/partition_innodb.test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index e1ac7b4c7eb..ca668d77199 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -7,6 +7,30 @@ drop table if exists t1, t2; let $MYSQLD_DATADIR= `SELECT @@datadir`; +--echo # +--echo # Bug#56287: crash when using Partition datetime in sub in query +--echo # +CREATE TABLE t1 +(c1 bigint(20) unsigned NOT NULL AUTO_INCREMENT, + c2 varchar(40) not null default '', + c3 datetime not NULL, + PRIMARY KEY (c1,c3), + KEY partidx(c3)) +ENGINE=InnoDB +PARTITION BY RANGE (TO_DAYS(c3)) +(PARTITION p200912 VALUES LESS THAN (to_days('2010-01-01')), + PARTITION p201103 VALUES LESS THAN (to_days('2011-04-01')), + PARTITION p201912 VALUES LESS THAN MAXVALUE); + +insert into t1(c2,c3) values ("Test row",'2010-01-01 00:00:00'); + +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test'; +SELECT count(*) FROM t1 p where c3 in +(select c3 from t1 t where t.c3 < date '2011-04-26 19:19:44' + and t.c3 > date '2011-04-26 19:18:44') ; + +DROP TABLE t1; + --echo # --echo # Bug#51830: Incorrect partition pruning on range partition (regression) --echo # -- cgit v1.2.1 From a302953bf77cceb0fec5097b7a5a7a937b8157c3 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Thu, 16 Sep 2010 11:11:13 +0200 Subject: Bug #56595 RENAME TABLE causes assert on OS X The problem was that RENAME TABLE caused an assert if the system variable lower_case_table_names was 2 (default on Mac OS X) and the old table name was given in upper case. This caused lowercase_table2.test to fail. The assert checks that an exclusive metadata lock is held by the connection trying to do RENAME TABLE - specificially during updates of table triggers. The assert was triggered since the check is case sensitive and the lock was held on the normalized (lower case) version of the table name. This patch fixes the problem by making sure a normalized version of the table name is used for the metadata lock check, while using a non-normalized version of the table name for the rename of trigger files. The same is done for ALTER TABLE ... RENAME. Regression testing for the bug itself is already covered by lowercase_table2.test. Additional coverage added to lowercase_fs_off.test. --- mysql-test/t/lowercase_fs_off.test | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/lowercase_fs_off.test b/mysql-test/t/lowercase_fs_off.test index 86d1e084c29..1be0351f9bc 100644 --- a/mysql-test/t/lowercase_fs_off.test +++ b/mysql-test/t/lowercase_fs_off.test @@ -91,3 +91,14 @@ DROP DATABASE db1; use test; # End of 5.0 tests + + +--echo # +--echo # Extra test coverage for Bug#56595 RENAME TABLE causes assert on OS X +--echo # + +CREATE TABLE t1(a INT); +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a= 1; +RENAME TABLE t1 TO T1; +ALTER TABLE T1 RENAME t1; +DROP TABLE t1; -- cgit v1.2.1 From be2061c0517af34a482b08af93e5040115d87c7b Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Thu, 16 Sep 2010 18:06:46 +0400 Subject: Fix for merge.test failures in mysql-5.5-runtime tree for embedded server Test case for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables" can't be run against embedded server. Embedded server converts all DELAYED INSERTs into ordinary INSERTs and this test can't work properly if such conversion happens. Moved this test from merge.test to delayed.test which is skipped if test suite is run with --embedded-server option. --- mysql-test/t/delayed.test | 49 +++++++++++++++++++++++++++++++++++++++++++++++ mysql-test/t/merge.test | 48 ---------------------------------------------- 2 files changed, 49 insertions(+), 48 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 5f56cdf54e1..3a2bc982ad3 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -552,3 +552,52 @@ disconnect con1; connection default; DROP TABLE t1, t2, t3; --enable_ps_protocol + + +--echo # +--echo # Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". +--echo # +connect (con1,localhost,root,,); +connection default; +--disable_warnings +drop table if exists t1, t2, tm; +--enable_warnings +create table t1(a int); +create table t2(a int); +create table tm(a int) engine=merge union=(t1, t2); +begin; +select * from t1; + +--echo # Connection 'con1'. +connection con1; +--echo # Sending: +--send alter table t1 comment 'test' + +--echo # Connection 'default'. +connection default; +--echo # Wait until ALTER TABLE blocks and starts waiting +--echo # for connection 'default'. It should wait with a +--echo # pending SNW lock on 't1'. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock" and + info = "alter table t1 comment 'test'"; +--source include/wait_condition.inc +--echo # Attempt to perform delayed insert into 'tm' should not lead +--echo # to a deadlock. Instead error ER_DELAYED_NOT_SUPPORTED should +--echo # be emitted. +--error ER_DELAYED_NOT_SUPPORTED +insert delayed into tm values (1); +--echo # Unblock ALTER TABLE. +commit; + +--echo # Connection 'con1'. +connection con1; +--echo # Reaping ALTER TABLE: +--reap + +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # Connection 'default'. +connection default; +drop tables tm, t1, t2; diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 3633a8b30ad..51c4ca51a29 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -2668,54 +2668,6 @@ drop temporary table tmp; drop table t1, t2, t3, m1, m2; ---echo # ---echo # Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables". ---echo # -connect (con1,localhost,root,,); -connection default; ---disable_warnings -drop table if exists t1, t2, tm; ---enable_warnings -create table t1(a int); -create table t2(a int); -create table tm(a int) engine=merge union=(t1, t2); -begin; -select * from t1; - ---echo # Connection 'con1'. -connection con1; ---echo # Sending: ---send alter table t1 comment 'test' - ---echo # Connection 'default'. -connection default; ---echo # Wait until ALTER TABLE blocks and starts waiting ---echo # for connection 'default'. It should wait with a ---echo # pending SNW lock on 't1'. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table metadata lock" and - info = "alter table t1 comment 'test'"; ---source include/wait_condition.inc ---echo # Attempt to perform delayed insert into 'tm' should not lead ---echo # to a deadlock. Instead error ER_DELAYED_NOT_SUPPORTED should ---echo # be emitted. ---error ER_DELAYED_NOT_SUPPORTED -insert delayed into tm values (1); ---echo # Unblock ALTER TABLE. -commit; - ---echo # Connection 'con1'. -connection con1; ---echo # Reaping ALTER TABLE: ---reap - ---echo # Connection 'default'. -connection default; -disconnect con1; -drop tables tm, t1, t2; - - --echo End of 6.0 tests --disable_result_log -- cgit v1.2.1 From 9fee5866beed47b55c5196acfa1a03503a13a2d7 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 20 Sep 2010 16:51:42 +0300 Subject: Bug #56798 : Wrong credentials assigned when using a proxy user. Fixed incorrect handling of user credentials when authenticating via proxy user. Now the server will use the proxies user's access mask and host to update the security context runtime structure when logging in. Fixed a compilation warning with the embedded library. Fixed a crash when doing a second GRANT PROXY on ''@'' due to incomplete equality check logic. --- mysql-test/t/plugin_auth.test | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/plugin_auth.test b/mysql-test/t/plugin_auth.test index f5a8bd416a0..77dcd7add73 100644 --- a/mysql-test/t/plugin_auth.test +++ b/mysql-test/t/plugin_auth.test @@ -296,3 +296,37 @@ disconnect plug_con; DROP USER plug; DROP USER plug_dest; --echo ## END @@external_user tests + +--echo # +--echo # Bug #56798 : Wrong credentials assigned when using a proxy user. +--echo # + +GRANT ALL PRIVILEGES ON *.* TO power_user; +GRANT USAGE ON anonymous_db.* TO ''@'' + IDENTIFIED WITH 'test_plugin_server' AS 'power_user'; +GRANT PROXY ON power_user TO ''@''; +CREATE DATABASE confidential_db; + +connect(plug_con,localhost, test_login_user, power_user, confidential_db); +SELECT user(),current_user(),@@proxy_user; + +connection default; +disconnect plug_con; + +DROP USER power_user; +DROP USER ''@''; +DROP DATABASE confidential_db; + +--echo # Test case #2 (crash with double grant proxy) + +CREATE USER ''@'' IDENTIFIED WITH 'test_plugin_server' AS 'standard_user'; +CREATE USER standard_user; +CREATE DATABASE shared; +GRANT ALL PRIVILEGES ON shared.* TO standard_user; +GRANT PROXY ON standard_user TO ''@''; +--echo #should not crash +GRANT PROXY ON standard_user TO ''@''; + +DROP USER ''@''; +DROP USER standard_user; +DROP DATABASE shared; -- cgit v1.2.1 From e14934d26d99b6fbe3a44579b87f0a30bfa31529 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Wed, 22 Sep 2010 10:15:41 +0200 Subject: Bug #56494 Segfault in upgrade_shared_lock_to_exclusive() for REPAIR of merge table Bug #56422 CHECK TABLE run when the table is locked reports corruption along with timeout The crash happened if a table maintenance statement (ANALYZE TABLE, REPAIR TABLE, etc.) was executed on a MERGE table and opening and locking a child table failed. This could for example happen if a child table did not exist or if a lock timeout happened while waiting for a conflicting metadata lock to disappear. Since opening and locking the MERGE table and its children failed, the tables would be closed and the metadata locks released. However, TABLE_LIST::table for the MERGE table would still be set, with its value invalid since the tables had been closed. This caused the table maintenance statement to try to continue and upgrade the metadata lock on the MERGE table. But since the lock already had been released, this caused a segfault. This patch fixes the problem by setting TABLE_LIST::table to NULL if open_and_lock_tables() fails. This prevents maintenance statements from continuing and trying to upgrade the metadata lock. The patch includes a 5.5 version of the fix for Bug #46339 crash on REPAIR TABLE merge table USE_FRM. This bug caused REPAIR TABLE ... USE_FRM to give an assert when used on merge tables. The patch also enables the CHECK TABLE statement for log tables. Before, CHECK TABLE for log tables gave ER_CANT_LOCK_LOG_TABLE, yet still counted the statement as successfully executed. With the changes to table maintenance statement error handling in this patch, CHECK TABLE would no longer be considered as successful in this case. This would have caused upgrade scripts to mistakenly think that the general and slow logs are corrupted and have to be repaired. Enabling CHECK TABLES for log tables prevents this from happening. Finally, the patch changes the error message from "Corrupt" to "Operation failed" for a number of issues not related to table corruption. For example "Lock wait timeout exceeded" and "Deadlock found trying to get lock". Test cases added to merge.test and check.test. --- mysql-test/t/check.test | 24 +++++++++++ mysql-test/t/merge.test | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/check.test b/mysql-test/t/check.test index ff23b352b5a..2234d2c680f 100644 --- a/mysql-test/t/check.test +++ b/mysql-test/t/check.test @@ -53,5 +53,29 @@ REPAIR TABLE t1; DROP TABLE t1; +--echo # +--echo # Bug#56422 CHECK TABLE run when the table is locked reports corruption +--echo # along with timeout +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1(a INT); +LOCK TABLE t1 WRITE; + +--echo # Connection con1 +connect(con1, localhost, root); +SET lock_wait_timeout= 1; +CHECK TABLE t1; + +--echo # Connection default +connection default; +UNLOCK TABLES; +DROP TABLE t1; +disconnect con1; + + # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 51c4ca51a29..34d0b5bf237 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -1734,6 +1734,84 @@ t2 WHERE b SOUNDS LIKE e AND d = 1; DROP TABLE t2, t1; +--echo # +--echo # Bug#46339 - crash on REPAIR TABLE merge table USE_FRM +--echo # +--disable_warnings +DROP TABLE IF EXISTS m1, t1; +--enable_warnings +# +# Test derived from a proposal of Shane Bester. +# +CREATE TABLE t1 (c1 INT) ENGINE=MYISAM; +CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST; +# +# REPAIR ... USE_FRM with LOCK TABLES. +# +LOCK TABLE m1 READ; +REPAIR TABLE m1 USE_FRM; +UNLOCK TABLES; +# +# REPAIR ... USE_FRM without LOCK TABLES. +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +DROP TABLE m1,t1; +# +# Test derived from a proposal of Matthias Leich. +# +# Base table is missing. +# +CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Create base table. +# +CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM; +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Normal repair as reference. +# +REPAIR TABLE m1; +# +# Cleanup. +# +DROP TABLE m1, t1; +# +# Same with temporary tables. +# +# Base table is missing. +# +CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Create base table. +# +CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM; +# +# This statement crashed the server (Bug#46339). +# +REPAIR TABLE m1 USE_FRM; +# +# Normal repair as reference. +# +REPAIR TABLE m1; +# +# Cleanup. +# +DROP TABLE m1, t1; + --echo End of 5.1 tests --echo # @@ -2668,6 +2746,36 @@ drop temporary table tmp; drop table t1, t2, t3, m1, m2; +--echo # +--echo # Bug#56494 Segfault in upgrade_shared_lock_to_exclusive() for +--echo # REPAIR of merge table +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1, t2, t_not_exists; +--enable_warnings + +CREATE TABLE t1(a INT); +ALTER TABLE t1 engine= MERGE UNION (t_not_exists); +# This caused the segfault +ANALYZE TABLE t1; +CHECK TABLE t1; +CHECKSUM TABLE t1; +OPTIMIZE TABLE t1; +REPAIR TABLE t1; + +# This caused an assert +REPAIR TABLE t1 USE_FRM; + +DROP TABLE t1; +CREATE TABLE t1(a INT); +CREATE TABLE t2(a INT) engine= MERGE UNION (t1); +# This caused an assert +REPAIR TABLE t2 USE_FRM; + +DROP TABLE t1, t2; + + --echo End of 6.0 tests --disable_result_log -- cgit v1.2.1 From 500cb492959eef3771f03fd516eb1a21fb2924da Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 27 Sep 2010 14:36:16 +0200 Subject: Bug #57036 Add checks in mysqltest that variables treated as ints are in fact ints Adds boolean flag is_int and a separete function to check for int value Added tests to mysqltest.test --- mysql-test/t/mysqltest.test | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index c054b163c0c..45dbb4a5c8d 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1006,16 +1006,13 @@ EOF # ---------------------------------------------------------------------------- # Test inc # ---------------------------------------------------------------------------- -inc $i; -echo $i; +let $i= 0; inc $i; echo $i; let $i=100; inc $i; echo $i; - -let $i=hej; -echo $i; +let $i= -100; inc $i; echo $i; @@ -1024,7 +1021,13 @@ echo $i; --error 1 --exec echo "inc i;" | $MYSQL_TEST 2>&1 --error 1 +--exec echo "inc \$i;" | $MYSQL_TEST 2>&1 +--error 1 --exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1 +--error 1 +--exec echo "let \$i=text; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1 +--error 1 +--exec echo "let \$i=10cc; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1 inc $i; inc $i; inc $i; --echo $i echo $i; @@ -1034,25 +1037,25 @@ echo $i; # Test dec # ---------------------------------------------------------------------------- -dec $d; -echo $d; +let $d= 0; dec $d; echo $d; let $d=100; dec $d; echo $d; -let $d=hej; -echo $d; -dec $d; -echo $d; - --error 1 --exec echo "dec;" | $MYSQL_TEST 2>&1 --error 1 --exec echo "dec i;" | $MYSQL_TEST 2>&1 --error 1 +--exec echo "dec \$i;" | $MYSQL_TEST 2>&1 +--error 1 --exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1 +--error 1 +--exec echo "let \$i=text; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1 +--error 1 +--exec echo "let \$i=10cc; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1 # ---------------------------------------------------------------------------- -- cgit v1.2.1 From 37afe1b34a20ffebe98381629ec615bd5957518a Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Mon, 27 Sep 2010 16:55:09 +0400 Subject: WL#5341 - Sticky plugins This patch implements "permanent" load option for plugins as specified by WL#5341. mysql-test/r/plugin_load_option.result: A test case for WL#5341. mysql-test/t/plugin_load_option-master.opt: A test case for WL#5341. mysql-test/t/plugin_load_option.test: A test case for WL#5341. sql/share/errmsg-utf8.txt: An error message for WL#5341. sql/sql_plugin.cc: Added FORCE_PLUS_PERMANENT plugin load option. sql/sql_plugin.h: Expose and use plugin load option instead of is_mandatory flag. This is a requirement for to-be-implemented WL5496. --- mysql-test/t/plugin_load_option-master.opt | 3 +++ mysql-test/t/plugin_load_option.test | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 mysql-test/t/plugin_load_option-master.opt create mode 100644 mysql-test/t/plugin_load_option.test (limited to 'mysql-test/t') diff --git a/mysql-test/t/plugin_load_option-master.opt b/mysql-test/t/plugin_load_option-master.opt new file mode 100644 index 00000000000..3be53c3b713 --- /dev/null +++ b/mysql-test/t/plugin_load_option-master.opt @@ -0,0 +1,3 @@ +$EXAMPLE_PLUGIN_OPT +$EXAMPLE_PLUGIN_LOAD +--plugin-example=FORCE_PLUS_PERMANENT diff --git a/mysql-test/t/plugin_load_option.test b/mysql-test/t/plugin_load_option.test new file mode 100644 index 00000000000..604be30b561 --- /dev/null +++ b/mysql-test/t/plugin_load_option.test @@ -0,0 +1,5 @@ +--source include/not_windows_embedded.inc +--source include/have_example_plugin.inc + +--error ER_PLUGIN_IS_PERMANENT +UNINSTALL PLUGIN example; -- cgit v1.2.1 From d9aa82154b02ec2e6bccb0048f9e0c94b6b0af6b Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Mon, 27 Sep 2010 17:03:27 +0400 Subject: WL#5496 - Plugin LOAD_OPTION in INFORMATION_SCHEMA.PLUGINS This patch implements I_S.PLUGINS.LOAD_OPTION column as specified by WL#5496. mysql-test/r/plugin_load_option.result: A test case for WL#5496. mysql-test/suite/funcs_1/r/is_columns_is.result: Adjusted a test case according to WL#5496. mysql-test/t/plugin_load_option.test: A test case for WL#5496. sql/sql_show.cc: Added LOAD_OPTION column to I_S.PLUGINS. --- mysql-test/t/plugin_load_option.test | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/plugin_load_option.test b/mysql-test/t/plugin_load_option.test index 604be30b561..e49b693b5be 100644 --- a/mysql-test/t/plugin_load_option.test +++ b/mysql-test/t/plugin_load_option.test @@ -3,3 +3,6 @@ --error ER_PLUGIN_IS_PERMANENT UNINSTALL PLUGIN example; + +SELECT PLUGIN_NAME, PLUGIN_STATUS, LOAD_OPTION FROM INFORMATION_SCHEMA.PLUGINS +WHERE PLUGIN_NAME IN ('MyISAM', 'EXAMPLE'); -- cgit v1.2.1 From 7f80cffa52d20aad308ccf2b2791dde477d5ec22 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Tue, 28 Sep 2010 11:07:58 +0200 Subject: Bug #46165 server crash in dbug This crash occured if the same debug trace file was closed twice, leading to the same memory being free'd twice. This could occur if the "debug" server system variable refered to the same trace file in both global and session scope. Example of an order of events that would lead to a crash: 1) Enable debug tracing to a trace file (global scope) 2) Enable debug tracing to the same trace file (session scope) 3) Reset debug settings (global scope) 4) Reset debug settings (session scope) This caused a crash because the trace file was, by mistake, closed in 3), leading to the same memory being free'd twice when the file was closed again in 4). Internally, the debug settings are stored in a stack, with session settings (if any) on top and the global settings below. Each connection has its own stack. When a set of settings is changed, it must be determined if its debug trace file is to be closed. Before, this was done by only checking below on the settings stack. So if the global settings were changed, an existing debug trace file reference in session settings would be missed. This caused the file to be closed even if it was in use, leading to a crash later when it was closed again. This patch fixes the problem by preventing the trace file from being shared between global and session settings. If session debug settings are set without specifying a new trace file, stderr is used for output. This is a change in behaviour and should be reflected in the documentation. Test case added to variables.test. --- mysql-test/t/variables.test | 75 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 75099523062..0209fb00a77 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1432,3 +1432,78 @@ drop function t1_max; ########################################################################### + + +--echo # +--echo # Bug#46165 server crash in dbug +--echo # + +SET @old_globaldebug = @@global.debug; +SET @old_sessiondebug= @@session.debug; + +--echo # Test 1 - Bug test case, single connection +SET GLOBAL debug= '+O,../../log/bug46165.1.trace'; +SET SESSION debug= '-d:-t:-i'; + +SET GLOBAL debug= ''; +SET SESSION debug= ''; + +--echo # Test 2 - Bug test case, two connections +--echo # Connection default +connection default; +SET GLOBAL debug= '+O,../../log/bug46165.2.trace'; +SET SESSION debug= '-d:-t:-i'; + +--echo # Connection con1 +connect (con1, localhost, root); +SET GLOBAL debug= ''; + +--echo # Connection default +connection default; +SET SESSION debug= ''; +--echo # Connection con1 +connection con1; +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # Connection default +connection default; +SET GLOBAL debug= ''; + +--echo # Test 3 - Active session trace file on disconnect +--echo # Connection con1 +connect (con1, localhost, root); +SET GLOBAL debug= '+O,../../log/bug46165.3.trace'; +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +disconnect con1; +--source include/wait_until_disconnected.inc + +--echo # Test 4 - Active session trace file on two connections +--echo # Connection default +connection default; +SET GLOBAL debug= '+O,../../log/bug46165.4.trace'; +SET SESSION debug= '-d:-t:-i'; + +--echo # Connection con1 +connect (con1, localhost, root); +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +SET SESSION debug= ''; + +--echo # Connection default +connection default; +SET SESSION debug= ''; +--echo # Connection con1 +connection con1; +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # Connection default +connection default; + +--echo # Test 5 - Different trace files +SET SESSION debug= '+O,../../log/bug46165.5.trace'; +SET SESSION debug= '+O,../../log/bug46165.6.trace'; +SET SESSION debug= '-O'; + +SET GLOBAL debug= @old_globaldebug; +SET SESSION debug= @old_sessiondebug; -- cgit v1.2.1 From b72e7f05ffe5e8360a9b91c83db045c1e4618d35 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Wed, 29 Sep 2010 10:07:56 +0200 Subject: Followup to Bug#46165 server crash in dbug This patch moves the regression test from variables.test to variables_debug.test as the debug system variable is not available on release builds. --- mysql-test/t/variables.test | 75 --------------------------------------- mysql-test/t/variables_debug.test | 75 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 75 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 0209fb00a77..75099523062 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1432,78 +1432,3 @@ drop function t1_max; ########################################################################### - - ---echo # ---echo # Bug#46165 server crash in dbug ---echo # - -SET @old_globaldebug = @@global.debug; -SET @old_sessiondebug= @@session.debug; - ---echo # Test 1 - Bug test case, single connection -SET GLOBAL debug= '+O,../../log/bug46165.1.trace'; -SET SESSION debug= '-d:-t:-i'; - -SET GLOBAL debug= ''; -SET SESSION debug= ''; - ---echo # Test 2 - Bug test case, two connections ---echo # Connection default -connection default; -SET GLOBAL debug= '+O,../../log/bug46165.2.trace'; -SET SESSION debug= '-d:-t:-i'; - ---echo # Connection con1 -connect (con1, localhost, root); -SET GLOBAL debug= ''; - ---echo # Connection default -connection default; -SET SESSION debug= ''; ---echo # Connection con1 -connection con1; -disconnect con1; ---source include/wait_until_disconnected.inc ---echo # Connection default -connection default; -SET GLOBAL debug= ''; - ---echo # Test 3 - Active session trace file on disconnect ---echo # Connection con1 -connect (con1, localhost, root); -SET GLOBAL debug= '+O,../../log/bug46165.3.trace'; -SET SESSION debug= '-d:-t:-i'; -SET GLOBAL debug= ''; -disconnect con1; ---source include/wait_until_disconnected.inc - ---echo # Test 4 - Active session trace file on two connections ---echo # Connection default -connection default; -SET GLOBAL debug= '+O,../../log/bug46165.4.trace'; -SET SESSION debug= '-d:-t:-i'; - ---echo # Connection con1 -connect (con1, localhost, root); -SET SESSION debug= '-d:-t:-i'; -SET GLOBAL debug= ''; -SET SESSION debug= ''; - ---echo # Connection default -connection default; -SET SESSION debug= ''; ---echo # Connection con1 -connection con1; -disconnect con1; ---source include/wait_until_disconnected.inc ---echo # Connection default -connection default; - ---echo # Test 5 - Different trace files -SET SESSION debug= '+O,../../log/bug46165.5.trace'; -SET SESSION debug= '+O,../../log/bug46165.6.trace'; -SET SESSION debug= '-O'; - -SET GLOBAL debug= @old_globaldebug; -SET SESSION debug= @old_sessiondebug; diff --git a/mysql-test/t/variables_debug.test b/mysql-test/t/variables_debug.test index 8fa2124137a..63c34acc876 100644 --- a/mysql-test/t/variables_debug.test +++ b/mysql-test/t/variables_debug.test @@ -36,3 +36,78 @@ SELECT @@global.debug; SET GLOBAL debug=@old_debug; --echo End of 5.1 tests + + +--echo # +--echo # Bug#46165 server crash in dbug +--echo # + +SET @old_globaldebug = @@global.debug; +SET @old_sessiondebug= @@session.debug; + +--echo # Test 1 - Bug test case, single connection +SET GLOBAL debug= '+O,../../log/bug46165.1.trace'; +SET SESSION debug= '-d:-t:-i'; + +SET GLOBAL debug= ''; +SET SESSION debug= ''; + +--echo # Test 2 - Bug test case, two connections +--echo # Connection default +connection default; +SET GLOBAL debug= '+O,../../log/bug46165.2.trace'; +SET SESSION debug= '-d:-t:-i'; + +--echo # Connection con1 +connect (con1, localhost, root); +SET GLOBAL debug= ''; + +--echo # Connection default +connection default; +SET SESSION debug= ''; +--echo # Connection con1 +connection con1; +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # Connection default +connection default; +SET GLOBAL debug= ''; + +--echo # Test 3 - Active session trace file on disconnect +--echo # Connection con1 +connect (con1, localhost, root); +SET GLOBAL debug= '+O,../../log/bug46165.3.trace'; +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +disconnect con1; +--source include/wait_until_disconnected.inc + +--echo # Test 4 - Active session trace file on two connections +--echo # Connection default +connection default; +SET GLOBAL debug= '+O,../../log/bug46165.4.trace'; +SET SESSION debug= '-d:-t:-i'; + +--echo # Connection con1 +connect (con1, localhost, root); +SET SESSION debug= '-d:-t:-i'; +SET GLOBAL debug= ''; +SET SESSION debug= ''; + +--echo # Connection default +connection default; +SET SESSION debug= ''; +--echo # Connection con1 +connection con1; +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # Connection default +connection default; + +--echo # Test 5 - Different trace files +SET SESSION debug= '+O,../../log/bug46165.5.trace'; +SET SESSION debug= '+O,../../log/bug46165.6.trace'; +SET SESSION debug= '-O'; + +SET GLOBAL debug= @old_globaldebug; +SET SESSION debug= @old_sessiondebug; -- cgit v1.2.1 From e33e27a6643e426a6143cf725a480ecd5a22899e Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 1 Oct 2010 21:32:40 +0200 Subject: Minor update of test to pass both with and without --ps-protocol --- mysql-test/t/partition_error.test | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 1afb65d496c..73afa9b5216 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -74,10 +74,15 @@ INSERT INTO t1 VALUES ('2000-01-02 03:04:05'); --sorted_result SELECT * FROM t1; FLUSH TABLES; +--echo # replacing t1.frm with TO_DAYS(a) which was allowed earlier. --remove_file $MYSQLD_DATADIR/test/t1.frm --copy_file std_data/parts/t1TIMESTAMP.frm $MYSQLD_DATADIR/test/t1.frm +--echo # Disable warnings, since the result would differ when running with +--echo # --ps-protocol (only for the 'SELECT * FROM t1' statement). +--disable_warnings --sorted_result SELECT * FROM t1; +--enable_warnings SHOW CREATE TABLE t1; INSERT INTO t1 VALUES ('2001-02-03 04:05:06'); --sorted_result -- cgit v1.2.1 From 7a64d43ad091bcc7e140a1c7b5cb49158e25a801 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Mon, 4 Oct 2010 10:25:04 +0200 Subject: Bug #51099 Assertion in mysql_multi_delete_prepare() This assert was triggered if DELETE was done on a view that referenced another view which in turn (directly or indirectly) referenced more than one table. Delete from a view referencing more than one table (a join view) is not supported and is supposed to give ER_VIEW_DELETE_MERGE_VIEW error. Before this error was reported from the multi table delete code, an assert verified that the view from the DELETE statement had more than one underlying table. However, this assert did not take into account that the view could refer to another view which in turn referenced the actual tables. This patch fixes the problem by adjusting the assert to take this possibility into account. This problem was only noticeable on debug builds of the server. On release builds, ER_VIEW_DELETE_MERGE_VIEW was correctly reported. Test case added to delete.test. --- mysql-test/t/delete.test | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 15aade73ab7..6a72ae9c38b 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -554,3 +554,29 @@ DELETE FROM t1.*, test.t2.*, a.* USING t1, t2, t3 AS a; DROP TABLE t1, t2, t3; --echo End of 5.1 tests + + +--echo # +--echo # Bug#51099 Assertion in mysql_multi_delete_prepare() +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +DROP VIEW IF EXISTS v1, v2; +--enable_warnings + +CREATE TABLE t1(a INT); +CREATE TABLE t2(b INT); +CREATE VIEW v1 AS SELECT a, b FROM t1, t2; +CREATE VIEW v2 AS SELECT a FROM v1; + +# This is a normal delete +--error ER_VIEW_DELETE_MERGE_VIEW +DELETE FROM v2; +# This is a multi table delete, check that we get the same error +# This caused the assertion. +--error ER_VIEW_DELETE_MERGE_VIEW +DELETE v2 FROM v2; + +DROP VIEW v2, v1; +DROP TABLE t1, t2; -- cgit v1.2.1 From dd1d7ff161e22d697eec3c40893d380b0c0ef0bb Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 5 Oct 2010 14:57:51 +0200 Subject: Bug#55091: Server crashes on ADD PARTITION after a failed attempt In case of failure in ALTER ... PARTITION under LOCK TABLE the server could crash, due to it had modified the locked table object, which was not reverted in case of failure, resulting in a bad table definition used after the failed command. Solved by always closing the LOCKED TABLE, even in case of error. Note: this is a 5.1-only fix, bug#56172 fixed it in 5.5+ mysql-test/r/partition_innodb_plugin.result: updated result mysql-test/t/disabled.def: Only disabled valgrind instead. mysql-test/t/partition_innodb_plugin.test: Added test sql/sql_partition.cc: close_thread_tables do not close LOCKED TABLEs and destroys the table object (including part_info), so to avoid it to be reused, always close the table regardless of any previous failure. --- mysql-test/t/disabled.def | 1 - mysql-test/t/partition_innodb_plugin.test | 66 +++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index cede26f555a..bb931fb7b14 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -11,6 +11,5 @@ ############################################################################## kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild. query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically -partition_innodb_plugin : Bug#53307 2010-04-30 VasilDimov valgrind warnings main.mysqlhotcopy_myisam : bug#54129 2010-06-04 Horst main.mysqlhotcopy_archive: bug#54129 2010-06-04 Horst diff --git a/mysql-test/t/partition_innodb_plugin.test b/mysql-test/t/partition_innodb_plugin.test index eeb990c0d81..114adf67180 100644 --- a/mysql-test/t/partition_innodb_plugin.test +++ b/mysql-test/t/partition_innodb_plugin.test @@ -1,5 +1,71 @@ --source include/have_partition.inc --source include/have_innodb_plugin.inc +# Remove the line below when bug#53307 is solved. +--source include/not_valgrind.inc + +let $MYSQLD_DATADIR= `SELECT @@datadir`; + +call mtr.add_suppression("nnoDB: Error: table `test`.`t1` .* Partition.* InnoDB internal"); +--echo # +--echo # Bug#55091: Server crashes on ADD PARTITION after a failed attempt +--echo # +SET @old_innodb_file_format_check = @@global.innodb_file_format_check; +SET @old_innodb_file_format = @@global.innodb_file_format; +SET @old_innodb_file_per_table = @@global.innodb_file_per_table; +SET @old_innodb_strict_mode = @@global.innodb_strict_mode; +SET @@global.innodb_file_format = Barracuda, +@@global.innodb_file_per_table = ON, +@@global.innodb_strict_mode = ON; + +--echo # Connection con1 +--connect(con1,localhost,root,,) + +CREATE TABLE t1 (id INT NOT NULL +PRIMARY KEY, +user_num CHAR(10) +) ENGINE = InnoDB +KEY_BLOCK_SIZE=4 +PARTITION BY HASH(id) PARTITIONS 1; + +--list_files $MYSQLD_DATADIR/test +SHOW CREATE TABLE t1; + +SET GLOBAL innodb_file_per_table = OFF; + +--disconnect con1 +--connect(con2,localhost,root,,) +--echo # Connection con2 + +LOCK TABLE t1 WRITE; + +--echo # ALTER fails because COMPRESSED/KEY_BLOCK_SIZE +--echo # are incompatible with innodb_file_per_table = OFF; + +--error ER_GET_ERRNO +ALTER TABLE t1 ADD PARTITION PARTITIONS 1; + +--list_files $MYSQLD_DATADIR/test +--echo # This SET is not needed to reproduce the bug, +--echo # it is here just to make the test case more realistic +SET innodb_strict_mode = OFF; + +ALTER TABLE t1 ADD PARTITION PARTITIONS 2; +--list_files $MYSQLD_DATADIR/test + +# really bug#56172 +ALTER TABLE t1 REBUILD PARTITION p0; + +UNLOCK TABLES; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--disconnect con2 +--connection default +--echo # Connection default +SET @@global.innodb_strict_mode = @old_innodb_strict_mode; +SET @@global.innodb_file_format = @old_innodb_file_format; +SET @@global.innodb_file_per_table = @old_innodb_file_per_table; +SET @@global.innodb_file_format_check = @old_innodb_file_format_check; # # Bug#32430 - show engine innodb status causes errors -- cgit v1.2.1 From 81c78fb6c2fad15589426bfd1fc0488106f2167b Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 5 Oct 2010 18:03:48 +0300 Subject: Enable partition_innodb_plugin after Bug#53307 has been fixed --- mysql-test/t/disabled.def | 1 - 1 file changed, 1 deletion(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index cede26f555a..bb931fb7b14 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -11,6 +11,5 @@ ############################################################################## kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild. query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically -partition_innodb_plugin : Bug#53307 2010-04-30 VasilDimov valgrind warnings main.mysqlhotcopy_myisam : bug#54129 2010-06-04 Horst main.mysqlhotcopy_archive: bug#54129 2010-06-04 Horst -- cgit v1.2.1 From e53e16a885937a902b10d4ab0293f3ec0905e355 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Wed, 6 Oct 2010 09:56:29 +0200 Subject: Bug #57002 Assert in upgrade_shared_lock_to_exclusive() for ALTER TABLE + MERGE tables The patch for Bug#56292 changed how metadata locks are taken for MERGE tables. After the patch, locking the MERGE table will also lock the children tables with the same metadata lock type. This means that LOCK TABLES on a MERGE table also will implicitly do LOCK TABLES on the children tables. A consequence of this change, is that it is possible to do LOCK TABLES on a child table both explicitly and implicitly with the same statement and that these two locks can be of different strength. For example, LOCK TABLES child READ, merge WRITE. In LOCK TABLES mode, we are not allowed to take new locks and each statement must therefore try to find an existing TABLE instance with a suitable lock. The code that searched for a suitable TABLE instance, only considered table level locks. If a child table was locked twice, it was therefore possible for this code to find a TABLE instance with suitable table level locks but without suitable metadata lock. This problem caused the assert in upgrade_shared_lock_to_exclusive() to be triggered as it tried to upgrade a MDL_SHARED lock to EXCLUSIVE. The problem was a regression caused by the patch for Bug#56292. This patch fixes the problem by partially reverting the changes done by Bug#56292. Now, the children tables will only use the same metadata lock as the MERGE table for MDL_SHARED_NO_WRITE when not in locked tables mode. This means that LOCK TABLE on a MERGE table will not implicitly lock the children tables. This still fixes the original problem in Bug#56292 without causing a regression. Test case added to merge.test. --- mysql-test/t/merge.test | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 34d0b5bf237..07839257a15 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -2600,11 +2600,12 @@ UNLOCK TABLES; DROP TABLE m1, t1; --echo # ---echo # Locking the merge table will implicitly lock children. +--echo # Locking the merge table won't implicitly lock children. --echo # CREATE TABLE t1 (c1 INT); CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1); LOCK TABLE m1 WRITE; +--error ER_TABLE_NOT_LOCKED_FOR_WRITE ALTER TABLE t1 ADD INDEX (c1); LOCK TABLE m1 WRITE, t1 WRITE; ALTER TABLE t1 ADD INDEX (c1); @@ -2776,6 +2777,27 @@ REPAIR TABLE t2 USE_FRM; DROP TABLE t1, t2; +--echo # +--echo # Bug#57002 Assert in upgrade_shared_lock_to_exclusive() +--echo # for ALTER TABLE + MERGE tables +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1, m1; +--enable_warnings + +CREATE TABLE t1(a INT) engine=myisam; +CREATE TABLE m1(a INT) engine=merge UNION(t1); +LOCK TABLES t1 READ, m1 WRITE; + +# This caused an assert +--error ER_TABLE_NOT_LOCKED_FOR_WRITE +ALTER TABLE t1 engine=myisam; + +UNLOCK TABLES; +DROP TABLE m1, t1; + + --echo End of 6.0 tests --disable_result_log -- cgit v1.2.1 From 653f14c2659160b1fda7f3fceb0988fa90731d4d Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Wed, 6 Oct 2010 11:01:24 +0200 Subject: Bug#56452 Assertion failed: thd->transaction.stmt.is_empty() || thd->in_sub_stmt In a precursor patch for Bug#52044 (revid:bzr/kostja@stripped), a number of reorganizations of code was made. In addition some assertions were added to ensure the correct transactional state. The reorganization had a small glitch so statements that was active in the query cache was not followed by a statement commit/rollback (this code was removed). A section in the trans_commit_stmt/trans_rollback_stmt code is to clear the thd->transaction.stmt list of affected storage engines. When a new statement is initiated, an assert introduced by the 523044 patch checks if this list is cleared. When the query cache is accessed, this list may be populated, and since it's not committed it will not be cleared. This fix adds explicit statement commit or rollback for statements that is contained in the query cache. --- mysql-test/t/cache_innodb.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/cache_innodb.test b/mysql-test/t/cache_innodb.test index 33a328d1d6c..f7102627506 100644 --- a/mysql-test/t/cache_innodb.test +++ b/mysql-test/t/cache_innodb.test @@ -14,3 +14,18 @@ let $engine_type= InnoDB; let $test_foreign_keys= 1; --source include/query_cache.inc + +# +# Bug#56452 Assertion failed: thd->transaction.stmt.is_empty() || +# thd->in_sub_stmt +# +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +BEGIN; + INSERT INTO t1 VALUES(1); +ROLLBACK WORK AND CHAIN NO RELEASE; +SELECT a FROM t1; +ROLLBACK WORK AND CHAIN NO RELEASE; +SELECT a FROM t1; +ROLLBACK; +DROP TABLE t1; + -- cgit v1.2.1 From a5efb91deaf8a9c3bf53cd82ebd574be0cdabc5d Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Wed, 6 Oct 2010 11:34:28 -0300 Subject: Bug#49938: Failing assertion: inode or deadlock in fsp/fsp0fsp.c Bug#54678: InnoDB, TRUNCATE, ALTER, I_S SELECT, crash or deadlock - Incompatible change: truncate no longer resorts to a row by row delete if the storage engine does not support the truncate method. Consequently, the count of affected rows does not, in any case, reflect the actual number of rows. - Incompatible change: it is no longer possible to truncate a table that participates as a parent in a foreign key constraint, unless it is a self-referencing constraint (both parent and child are in the same table). To work around this incompatible change and still be able to truncate such tables, disable foreign checks with SET foreign_key_checks=0 before truncate. Alternatively, if foreign key checks are necessary, please use a DELETE statement without a WHERE condition. Problem description: The problem was that for storage engines that do not support truncate table via a external drop and recreate, such as InnoDB which implements truncate via a internal drop and recreate, the delete_all_rows method could be invoked with a shared metadata lock, causing problems if the engine needed exclusive access to some internal metadata. This problem originated with the fact that there is no truncate specific handler method, which ended up leading to a abuse of the delete_all_rows method that is primarily used for delete operations without a condition. Solution: The solution is to introduce a truncate handler method that is invoked when the engine does not support truncation via a table drop and recreate. This method is invoked under a exclusive metadata lock, so that there is only a single instance of the table when the method is invoked. Also, the method is not invoked and a error is thrown if the table is a parent in a non-self-referencing foreign key relationship. This was necessary to avoid inconsistency as some integrity checks are bypassed. This is inline with the fact that truncate is primarily a DDL operation that was designed to quickly remove all data from a table. mysql-test/suite/innodb/t/innodb-truncate.test: Add test cases for truncate and foreign key checks. Also test that InnoDB resets auto-increment on truncate. mysql-test/suite/innodb/t/innodb.test: FK is not necessary, test is related to auto-increment. Update error number, truncate is no longer invoked if table is parent in a FK relationship. mysql-test/suite/innodb/t/innodb_mysql.test: Update error number, truncate is no longer invoked if table is parent in a FK relationship. Use delete instead of truncate, test is used to check the interaction of FKs, triggers and delete. mysql-test/suite/parts/inc/partition_check.inc: Fix typo. mysql-test/suite/sys_vars/t/foreign_key_checks_func.test: Update error number, truncate is no longer invoked if table is parent in a FK relationship. mysql-test/t/mdl_sync.test: Modify test case to reflect and ensure that truncate takes a exclusive metadata lock. mysql-test/t/trigger-trans.test: Update error number, truncate is no longer invoked if table is parent in a FK relationship. sql/ha_partition.cc: Reorganize the various truncate methods. delete_all_rows is now passed directly to the underlying engines, so as truncate. The code responsible for truncating individual partitions is moved to ha_partition::truncate_partition, which is invoked when a ALTER TABLE t1 TRUNCATE PARTITION p statement is executed. Since the partition truncate no longer can be invoked via delete, the bitmap operations are not necessary anymore. The explicit reset of the auto-increment value is also removed as the underlying engines are now responsible for reseting the value. sql/handler.cc: Wire up the handler truncate method. sql/handler.h: Introduce and document the truncate handler method. It assumes certain use cases of delete_all_rows. Add method to retrieve the list of foreign keys referencing a table. Method is used to avoid truncating tables that are parent in a foreign key relationship. sql/share/errmsg-utf8.txt: Add error message for truncate and FK. sql/sql_lex.h: Introduce a flag so that the partition engine can detect when a partition is being truncated. Used to give a special error. sql/sql_parse.cc: Function mysql_truncate_table no longer exists. sql/sql_partition_admin.cc: Implement the TRUNCATE PARTITION statement. sql/sql_truncate.cc: Change the truncate table implementation to use the new truncate handler method and to not rely on row-by-row delete anymore. The truncate handler method is always invoked with a exclusive metadata lock. Also, it is no longer possible to truncate a table that is parent in some non-self-referencing foreign key. storage/archive/ha_archive.cc: Rename method as the description indicates that in the future this could be a truncate operation. storage/blackhole/ha_blackhole.cc: Implement truncate as no operation for the blackhole engine in order to remain compatible with older releases. storage/federated/ha_federated.cc: Introduce truncate method that invokes delete_all_rows. This is required to support partition truncate as this form of truncate does not implement the drop and recreate protocol. storage/heap/ha_heap.cc: Introduce truncate method that invokes delete_all_rows. This is required to support partition truncate as this form of truncate does not implement the drop and recreate protocol. storage/ibmdb2i/ha_ibmdb2i.cc: Introduce truncate method that invokes delete_all_rows. This is required to support partition truncate as this form of truncate does not implement the drop and recreate protocol. storage/innobase/handler/ha_innodb.cc: Rename delete_all_rows to truncate. InnoDB now does truncate under a exclusive metadata lock. Introduce and reorganize methods used to retrieve the list of foreign keys referenced by a or referencing a table. storage/myisammrg/ha_myisammrg.cc: Introduce truncate method that invokes delete_all_rows. This is required in order to remain compatible with earlier releases where truncate would resort to a row-by-row delete. --- mysql-test/t/mdl_sync.test | 15 +++++++++------ mysql-test/t/sp_trans.test | 24 ++++++++++++++++++++++++ mysql-test/t/trigger-trans.test | 5 +++++ 3 files changed, 38 insertions(+), 6 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/mdl_sync.test b/mysql-test/t/mdl_sync.test index f7780d2003a..5c4fc20b428 100644 --- a/mysql-test/t/mdl_sync.test +++ b/mysql-test/t/mdl_sync.test @@ -3969,7 +3969,8 @@ INSERT INTO t1 VALUES (1),(2),(3); --echo # Connection: con1 connection con1; -SET debug_sync='lock_table_for_truncate SIGNAL parked_truncate WAIT_FOR go_truncate'; +LOCK TABLES t1 WRITE; +SET debug_sync='upgrade_lock_for_truncate SIGNAL parked_truncate WAIT_FOR go_truncate'; send TRUNCATE TABLE t1; connection default; @@ -3994,15 +3995,17 @@ connection default; --echo # Connection: default SET debug_sync='now WAIT_FOR parked_flush'; SET debug_sync='now SIGNAL go_truncate'; +--echo # Ensure that truncate waits for a exclusive lock +let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist + WHERE state='Waiting for table metadata lock' AND info='TRUNCATE TABLE t1'; +--source include/wait_condition.inc +SET debug_sync= 'now SIGNAL go_show'; connection con1; ---echo # Connection: con1 +--echo # Connection: con1 (TRUNCATE) --echo # Reaping... reap; - -connection default; ---echo # Connection: default -SET debug_sync= 'now SIGNAL go_show'; +UNLOCK TABLES; connection con2; --echo # Connection: con2 (SHOW FIELDS FROM t1) diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index c4915bdb87a..c114d397e43 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -636,6 +636,30 @@ UPDATE t1_aux SET f2 = 2 WHERE f1 = f1_two_inserts()| DROP TABLE t1_aux, t1_not_null| DROP FUNCTION f1_two_inserts| +--echo # +--echo # Bug#49938: Failing assertion: inode or deadlock in fsp/fsp0fsp.c +--echo # + +--disable_warnings +DROP PROCEDURE IF EXISTS p1| +DROP TABLE IF EXISTS t1| +--enable_warnings + +CREATE TABLE t1 (a INT) ENGINE=INNODB| + +CREATE PROCEDURE p1() +BEGIN + TRUNCATE TABLE t1; +END| + +LOCK TABLES t1 WRITE| +CALL p1()| +FLUSH TABLES; +UNLOCK TABLES| +CALL p1()| + +DROP PROCEDURE p1| +DROP TABLE t1| # # BUG#NNNN: New bug synopsis diff --git a/mysql-test/t/trigger-trans.test b/mysql-test/t/trigger-trans.test index 4d6e82dedcb..82bee7aa224 100644 --- a/mysql-test/t/trigger-trans.test +++ b/mysql-test/t/trigger-trans.test @@ -148,10 +148,15 @@ CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW SET @b = 1; SET @a = 0; SET @b = 0; +--error ER_TRUNCATE_ILLEGAL_FK TRUNCATE t1; SELECT @a, @b; +DELETE FROM t1; + +SELECT @a, @b; + INSERT INTO t1 VALUES (1); DELETE FROM t1; -- cgit v1.2.1 From 3c9c7efb3b9f505e3db5b2dc2fdef30893f7d5f0 Mon Sep 17 00:00:00 2001 From: Evgeny Potemkin Date: Thu, 7 Oct 2010 11:07:56 +0400 Subject: Bug#57039: constant subtime expression returns incorrect result. The subtime function wasn't able to produce correct int representation of its result. For constant expressions the Item_datetime_cache is used to speedup evaluation and Item_datetime_cache expects underlying item to return correct int representation of DATETIME value. These two factors combined led to a wrong query result. Now the Item_func_add_time has function val_datetime which performs the calculation and saves result into given MYSQL_TIME struct, it also sets null_value to appropriate value. val_int and val_str member functions convert the result obtained from val_datetime to int or string respectively and returns it. mysql-test/r/func_time.result: Added a test case for the bug#57039. mysql-test/t/func_time.test: Added a test case for the bug#57039. sql/item_timefunc.cc: Bug#57039: constant subtime expression returns incorrect result. Now the Item_func_add_time has function val_datetime which performs the calculation and saves result into given MYSQL_TIME struct, it also sets null_value to appropriate value. val_int and val_str member functions convert the result obtained from val_datetime to int or string respectively and returns it. sql/item_timefunc.h: Bug#57039: constant subtime expression returns incorrect result. --- mysql-test/t/func_time.test | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 1f6001219a3..08c09adb093 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -833,3 +833,14 @@ SELECT 1 FROM t1 ORDER BY @x:=makedate(a,a); DROP TABLE t1; --echo End of 5.1 tests + +--echo # +--echo # Bug#57039: constant subtime expression returns incorrect result. +--echo # +CREATE TABLE t1 (`date_date` datetime NOT NULL); +INSERT INTO t1 VALUES ('2008-01-03 00:00:00'), ('2008-01-03 00:00:00'); +SELECT * FROM t1 WHERE date_date >= subtime(now(), "00:30:00"); +SELECT * FROM t1 WHERE date_date <= addtime(date_add("2000-1-1", INTERVAL "1:1:1" HOUR_SECOND), "00:20:00"); +DROP TABLE t1; +--echo # + -- cgit v1.2.1 From eaae675279435c06974c166b183cc5bd9232eddc Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Thu, 7 Oct 2010 20:01:17 +0400 Subject: Fix for bug#57061 "User without privilege on routine can discover its existence". The problem was that user without any privileges on routine was able to find out whether it existed or not. DROP FUNCTION and DROP PROCEDURE statements were checking if routine being dropped existed and reported ER_SP_DOES_NOT_EXIST error/warning before checking if user had enough privileges to drop it. This patch solves this problem by changing code not to check if routine exists before checking if user has enough privileges to drop it. Moreover we no longer perform this check using a separate call instead we rely on sp_drop_routine() returning SP_KEY_NOT_FOUND if routine doesn't exist. This change also simplifies one of upcoming patches refactoring global read lock implementation. mysql-test/r/grant.result: Updated test case after fixing bug#57061 "User without privilege on routine can discover its existence". Removed DROP PROCEDURE/FUNCTION statements which have started to fail after this fix (correctly). There is no need in dropping routines in freshly created database anyway. mysql-test/r/sp-security.result: Added new test case for bug#57061 "User without privilege on routine can discover its existence". Updated existing tests according to new behaviour. mysql-test/suite/funcs_1/r/innodb_storedproc_06.result: Updated test case after fixing bug#57061 "User without privilege on routine can discover its existence". Now we drop routines under user which has enough privileges to do so. mysql-test/suite/funcs_1/r/memory_storedproc_06.result: Updated test case after fixing bug#57061 "User without privilege on routine can discover its existence". Now we drop routines under user which has enough privileges to do so. mysql-test/suite/funcs_1/r/myisam_storedproc_06.result: Updated test case after fixing bug#57061 "User without privilege on routine can discover its existence". Now we drop routines under user which has enough privileges to do so. mysql-test/suite/funcs_1/storedproc/storedproc_06.inc: Updated test case after fixing bug#57061 "User without privilege on routine can discover its existence". Now we drop routines under user which has enough privileges to do so. mysql-test/t/grant.test: Updated test case after fixing bug#57061 "User without privilege on routine can discover its existence". Removed DROP PROCEDURE/FUNCTION statements which have started to fail after this fix (correctly). There is no need in dropping routines in freshly created database anyway. mysql-test/t/sp-security.test: Added new test case for bug#57061 "User without privilege on routine can discover its existence". Updated existing tests according to new behaviour. sql/sp.cc: Removed sp_routine_exists_in_table() which is no longer used. sql/sp.h: Removed sp_routine_exists_in_table() which is no longer used. sql/sql_parse.cc: When dropping routine we no longer check if routine exists before checking if user has enough privileges to do so. Moreover we no longer perform this check using a separate call instead we rely on sp_drop_routine() returning SP_KEY_NOT_FOUND if routine doesn't exist. --- mysql-test/t/grant.test | 5 ----- mysql-test/t/sp-security.test | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index e73f45a6c53..aad0c42a5b3 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1419,11 +1419,6 @@ GRANT CREATE ROUTINE ON dbbug33464.* TO 'userbug33464'@'localhost'; connect (connbug33464, localhost, userbug33464, , dbbug33464); --source suite/funcs_1/include/show_connection.inc ---disable_warnings -DROP PROCEDURE IF EXISTS sp3; -DROP FUNCTION IF EXISTS fn1; ---enable_warnings - delimiter //; CREATE PROCEDURE sp3(v1 char(20)) BEGIN diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test index 96f82c92248..d7ea829bf50 100644 --- a/mysql-test/t/sp-security.test +++ b/mysql-test/t/sp-security.test @@ -82,7 +82,7 @@ select * from db1_secret.t1; # ...and not this --error ER_DBACCESS_DENIED_ERROR create procedure db1_secret.dummy() begin end; ---error ER_SP_DOES_NOT_EXIST +--error ER_PROCACCESS_DENIED_ERROR drop procedure db1_secret.dummy; --error ER_PROCACCESS_DENIED_ERROR drop procedure db1_secret.stamp; @@ -106,7 +106,7 @@ select * from db1_secret.t1; # ...and not this --error ER_DBACCESS_DENIED_ERROR create procedure db1_secret.dummy() begin end; ---error ER_SP_DOES_NOT_EXIST +--error ER_PROCACCESS_DENIED_ERROR drop procedure db1_secret.dummy; --error ER_PROCACCESS_DENIED_ERROR drop procedure db1_secret.stamp; @@ -926,6 +926,39 @@ DROP DATABASE B48872; --echo End of 5.0 tests. + +--echo # +--echo # Test for bug#57061 "User without privilege on routine can discover +--echo # its existence." +--echo # +--disable_warnings +drop database if exists mysqltest_db; +--enable_warnings +create database mysqltest_db; +--echo # Create user with no privileges on mysqltest_db database. +create user bug57061_user@localhost; +create function mysqltest_db.f1() returns int return 0; +create procedure mysqltest_db.p1() begin end; +--echo # Connect as user 'bug57061_user@localhost' +connect (conn1, localhost, bug57061_user,,); +--echo # Attempt to drop routine on which user doesn't have privileges +--echo # should result in the same 'access denied' type of error whether +--echo # routine exists or not. +--error ER_PROCACCESS_DENIED_ERROR +drop function if exists mysqltest_db.f_does_not_exist; +--error ER_PROCACCESS_DENIED_ERROR +drop procedure if exists mysqltest_db.p_does_not_exist; +--error ER_PROCACCESS_DENIED_ERROR +drop function if exists mysqltest_db.f1; +--error ER_PROCACCESS_DENIED_ERROR +drop procedure if exists mysqltest_db.p1; +--echo # Connection 'default'. +connection default; +disconnect conn1; +drop user bug57061_user@localhost; +drop database mysqltest_db; + + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc -- cgit v1.2.1 From 731dcfc7ff5f787f391553f31ea5bcdca3ed13e5 Mon Sep 17 00:00:00 2001 From: Evgeny Potemkin Date: Thu, 7 Oct 2010 20:16:30 +0400 Subject: Bug#57095: Wrongly chosen expression cache type led to a wrong result. The coalesce function returned DATETIME type due to a DATETIME argument, but since it's not a date/time function it can't return correct int value for it. Nevertheless Item_datetime_cache was chosen to cache coalesce's result and that led to a wrong result. Now Item_datetime_cache is used only for those function that could return correct int representation of DATETIME values. mysql-test/r/type_datetime.result: Added a test case for the bug#57095. mysql-test/t/type_datetime.test: Added a test case for the bug#57095. sql/item.cc: Bug#57095: Wrongly chosen expression cache type led to a wrong result. Now Item_datetime_cache is used only for those function that could return correct int representation of DATETIME values. --- mysql-test/t/type_datetime.test | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index 6e40c9ccfa0..ca2a7804907 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -484,6 +484,16 @@ explain select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y'); DROP TABLE t1,t2; +--echo # +--echo # Bug#57095: Wrongly chosen expression cache type led to a wrong +--echo # result. +--echo # +CREATE TABLE t1 (`b` datetime ); +INSERT INTO t1 VALUES ('2010-01-01 00:00:00'), ('2010-01-01 00:00:00'); +SELECT * FROM t1 WHERE b <= coalesce(NULL, now()); +DROP TABLE t1; +--echo # + --echo # --echo # End of 5.5 tests --echo # -- cgit v1.2.1 From 36051b0106544a5650326cf69895b61163ad72c2 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Thu, 7 Oct 2010 19:51:37 -0300 Subject: Bug#56822: Add a thread state for sessions waiting on the query cache lock The problem was that threads waiting on the query cache lock are not easily seen due to the lack of a state indicating that the thread is waiting on the said lock. This made it difficult for users to quickly spot (for example, via SHOW PROCESSLIST) a query cache contention problem. The solution is to update the thread state when the query cache lock needs to be acquired. Whenever the lock is to be acquired, the thread state is updated to "Waiting for query cache lock" and is reset once the lock is granted or the wait is interrupted. The intention is to make query cache related hangs more evident. To further investigate query cache related locking problems, one may use PERFORMANCE_SCHEMA to track the overhead associated with the locking bits and determine which particular lock is being a contention point. sql/sql_cache.cc: Set and reset the thread state whenever a attempt to lock the query cache is made. Use DEBUG_SYNC instead of the now unnecessary wait_for_kill hack. --- mysql-test/t/query_cache_debug.test | 126 +++++++++++++++++++++++++----------- 1 file changed, 89 insertions(+), 37 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/query_cache_debug.test b/mysql-test/t/query_cache_debug.test index ce62b931a93..77e714aa6f5 100644 --- a/mysql-test/t/query_cache_debug.test +++ b/mysql-test/t/query_cache_debug.test @@ -1,6 +1,6 @@ --source include/not_embedded.inc --source include/have_query_cache.inc ---source include/have_debug.inc +--source include/have_debug_sync.inc # # Bug #30887 Server crashes on SET GLOBAL query_cache_size=0 @@ -18,12 +18,11 @@ connect (bug30887con2, localhost, root, ,test); connection bug30887con1; --echo Activate debug hook and attempt to retrieve the statement from the cache. -set session debug='+d,wait_in_query_cache_insert'; +set debug_sync="wait_in_query_cache_insert SIGNAL parked WAIT_FOR go"; --send select SQL_CACHE * from t1; connection default; -let $wait_condition= select count(*)= 1 from information_schema.processlist where state= 'wait_in_query_cache_insert'; ---source include/wait_condition.inc +set debug_sync="now WAIT_FOR parked"; connection bug30887con2; --echo On a second connection; clear the query cache. @@ -32,14 +31,18 @@ set global query_cache_size= 0; connection default; --echo Signal the debug hook to release the lock. -select id from information_schema.processlist where state='wait_in_query_cache_insert' into @thread_id; -kill query @thread_id; +set debug_sync="now SIGNAL go"; --echo Show query cache status. show status like 'Qcache_queries_in_cache'; +connection bug30887con1; +--reap + disconnect bug30887con1; disconnect bug30887con2; +connection default; +set debug_sync= 'RESET'; set global query_cache_size= 0; use test; drop table t1; @@ -67,18 +70,14 @@ connect(con2,localhost,root,,test,,); connection con1; --echo # Switch to connection con1 -SET SESSION debug='+d,wait_after_query_cache_invalidate'; +SET DEBUG_SYNC = "wait_after_query_cache_invalidate SIGNAL parked WAIT_FOR go"; --echo # Send concurrent insert, will wait in the query cache table invalidate --send INSERT INTO t1 VALUES (4) connection default; --echo # Switch to connection default --echo # Wait for concurrent insert to reach the debug point -let $wait_condition= - SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST - WHERE STATE = "wait_after_query_cache_invalidate" AND - INFO = "INSERT INTO t1 VALUES (4)"; ---source include/wait_condition.inc +SET DEBUG_SYNC = "now WAIT_FOR parked"; connection con2; --echo # Switch to connection con2 @@ -88,9 +87,7 @@ SELECT * FROM t1; connection default; --echo # Switch to connection default --echo # Notify the concurrent insert to proceed -SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST - WHERE STATE = 'wait_after_query_cache_invalidate' INTO @thread_id; -KILL QUERY @thread_id; +SET DEBUG_SYNC = "now SIGNAL go"; connection con1; --echo # Switch to connection con1 @@ -107,6 +104,7 @@ disconnect con2; connection default; --echo # Restore defaults +SET DEBUG_SYNC= 'RESET'; RESET QUERY CACHE; DROP TABLE t1,t2; SET GLOBAL concurrent_insert= DEFAULT; @@ -157,15 +155,14 @@ SELECT SQL_CACHE * FROM t1; --echo ** before the mutex lock in invalidate_table_internal. --echo ** This will allow new result sets to be written into the QC. --echo ** -SET SESSION debug='+d,wait_in_query_cache_invalidate1'; -SET SESSION debug='+d,wait_in_query_cache_invalidate2'; +SET DEBUG_SYNC="wait_in_query_cache_invalidate1 SIGNAL parked1_1 WAIT_FOR go1_1"; +SET DEBUG_SYNC="wait_in_query_cache_invalidate2 SIGNAL parked1_2 WAIT_FOR go1_2"; --send DELETE FROM t1 WHERE a like '%a%'; connection default; --echo =================================== Connection default --echo ** Assert that the expect process status is obtained. -LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 1 FROM information_schema.processlist WHERE state= 'wait_in_query_cache_invalidate1'; ---source include/wait_condition.inc +SET DEBUG_SYNC="now WAIT_FOR parked1_1"; -- echo ** connection thd2; @@ -173,32 +170,30 @@ connection thd2; --echo ** On THD2: Insert a result into the cache. This attempt will be blocked --echo ** because of a debug hook placed just before the mutex lock after which --echo ** the first part of the result set is written. -SET SESSION debug='+d,wait_in_query_cache_insert'; +SET DEBUG_SYNC="wait_in_query_cache_insert SIGNAL parked2 WAIT_FOR go2"; --send SELECT SQL_CACHE * FROM t2 UNION SELECT * FROM t3 connection thd3; --echo =================================== Connection thd3 --echo ** On THD3: Insert another result into the cache and block on the same --echo ** debug hook. -SET SESSION debug='+d,wait_in_query_cache_insert'; +SET DEBUG_SYNC="wait_in_query_cache_insert SIGNAL parked3 WAIT_FOR go3"; --send SELECT SQL_CACHE * FROM t4 UNION SELECT * FROM t5; connection default; --echo =================================== Connection default --echo ** Assert that the two SELECT-stmt threads to reach the hook. -LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 2 FROM information_schema.processlist WHERE state='wait_in_query_cache_insert'; ---source include/wait_condition.inc +SET DEBUG_SYNC="now WAIT_FOR parked2"; +SET DEBUG_SYNC="now WAIT_FOR parked3"; --echo ** --echo ** --echo ** Signal the DELETE thread, THD1, to continue. It will enter the mutex --echo ** lock and set query cache status to TABLE_FLUSH_IN_PROGRESS and then --echo ** unlock the mutex before stopping on the next debug hook. -SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate1' LIMIT 1 INTO @flush_thread_id; -KILL QUERY @flush_thread_id; +SET DEBUG_SYNC="now SIGNAL go1_1"; --echo ** Assert that we reach the next debug hook. -LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 1 FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate2'; ---source include/wait_condition.inc +SET DEBUG_SYNC="now WAIT_FOR parked1_2"; --echo ** --echo ** Signal the remaining debug hooks blocking THD2 and THD3. @@ -206,10 +201,8 @@ LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 1 FROM information_schema.pro --echo ** and finally release the mutex. The threads will continue to wait --echo ** until a broadcast signal reaches them causing both threads to --echo ** come alive and check the condition. -SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id ASC LIMIT 1 INTO @thread_id; -KILL QUERY @thread_id; -SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id DESC LIMIT 1 INTO @thread_id; -KILL QUERY @thread_id; +SET DEBUG_SYNC="now SIGNAL go2"; +SET DEBUG_SYNC="now SIGNAL go3"; --echo ** --echo ** Finally signal the DELETE statement on THD1 one last time. @@ -218,11 +211,7 @@ KILL QUERY @thread_id; --echo ** One signal will be sent to the thread group waiting for executing --echo ** invalidations and a broadcast signal will be sent to the thread --echo ** group holding result set writers. -SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate2' LIMIT 1 INTO @flush_thread_id; -KILL QUERY @flush_thread_id; - -LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE Id = @flush_thread_id AND Command = 'Sleep'; ---source include/wait_condition.inc +SET DEBUG_SYNC="now SIGNAL go1_2"; --echo ** --echo ************************************************************************* @@ -250,6 +239,7 @@ connection default; disconnect thd1; disconnect thd2; disconnect thd3; +SET DEBUG_SYNC= 'RESET'; SET GLOBAL query_cache_size= 0; connection default; @@ -259,4 +249,66 @@ FLUSH STATUS; DROP TABLE t1,t2,t3,t4,t5; SET GLOBAL query_cache_size= DEFAULT; SET GLOBAL query_cache_type= DEFAULT; -exit; + +--echo # +--echo # Bug#56822: Add a thread state for sessions waiting on the query cache lock +--echo # + +SET @old_query_cache_size= @@GLOBAL.query_cache_size; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); + +SET GLOBAL concurrent_insert= 1; +SET GLOBAL query_cache_size= 1024*512; +SET GLOBAL query_cache_type= ON; + +connect(con1,localhost,root,,test,,); +connect(con2,localhost,root,,test,,); + +connection con1; +--echo # Switch to connection con1 +SET DEBUG_SYNC = "wait_in_query_cache_invalidate2 SIGNAL parked WAIT_FOR go"; +--echo # Send INSERT, will wait in the query cache table invalidation +--send INSERT INTO t1 VALUES (4); + +connection default; +--echo # Switch to connection default +--echo # Wait for insert to reach the debug point +SET DEBUG_SYNC = "now WAIT_FOR parked"; + +connection con2; +--echo # Switch to connection con2 +--echo # Send a query that should wait on the query cache lock +--send RESET QUERY CACHE + +connection default; +--echo # Switch to connection default +--echo # Wait for the state to be reflected in the processlist +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = "Waiting for query cache lock" AND info = "RESET QUERY CACHE"; +--source include/wait_condition.inc +--echo # Signal that the query cache can be unlocked +SET DEBUG_SYNC="now SIGNAL go"; + +connection con1; +--echo # Reap con1 and disconnect +--reap +disconnect con1; + +connection con2; +--echo # Reap con2 and disconnect +--reap +disconnect con2; + +connection default; +--echo # Restore defaults +SET DEBUG_SYNC= 'RESET'; +RESET QUERY CACHE; +DROP TABLE t1; +SET GLOBAL query_cache_size= DEFAULT; +SET GLOBAL query_cache_type= DEFAULT; -- cgit v1.2.1 From 42dc7264c009fb8f32bce88b80f74bcaae6f63b4 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Fri, 8 Oct 2010 12:09:47 +0500 Subject: Bug#35269 mysqlcheck behaves different depending on order of parameters Issue an error if user specifies multiple commands to run. Also there was an unnoticed bug that DO_CHECK was actually 0 which lead to wrong actions in some cases. The mysqlcheck.test contained commands with the suspicious meaning for the above reason. Extra commands removed from there. per-file commands: client/mysqlcheck.c Bug#35269 mysqlcheck behaves different depending on order of parameters Drop with an error if multiple commands. mysql-test/r/mysqlcheck.result Bug#35269 mysqlcheck behaves different depending on order of parameters result completed. mysql-test/t/mysqlcheck.test Bug#35269 mysqlcheck behaves different depending on order of parameters testcase added. not-working commands removed from some mysqlcheck calls. --- mysql-test/t/mysqlcheck.test | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test index 831aba72fb5..dd113cb4e74 100644 --- a/mysql-test/t/mysqlcheck.test +++ b/mysql-test/t/mysqlcheck.test @@ -23,10 +23,13 @@ drop database if exists client_test_db; # Bug #13783 mysqlcheck tries to optimize and analyze information_schema # --replace_result 'Table is already up to date' OK ---exec $MYSQL_CHECK --all-databases --analyze --optimize +--exec $MYSQL_CHECK --all-databases --analyze +--exec $MYSQL_CHECK --all-databases --optimize --replace_result 'Table is already up to date' OK ---exec $MYSQL_CHECK --analyze --optimize --databases test information_schema mysql ---exec $MYSQL_CHECK --analyze --optimize information_schema schemata +--exec $MYSQL_CHECK --analyze --databases test information_schema mysql +--exec $MYSQL_CHECK --optimize --databases test information_schema mysql +--exec $MYSQL_CHECK --analyze information_schema schemata +--exec $MYSQL_CHECK --optimize information_schema schemata # # Bug #16502: mysqlcheck tries to check views @@ -34,9 +37,11 @@ drop database if exists client_test_db; create table t1 (a int); create view v1 as select * from t1; --replace_result 'Table is already up to date' OK ---exec $MYSQL_CHECK --analyze --optimize --databases test +--exec $MYSQL_CHECK --analyze --databases test +--exec $MYSQL_CHECK --optimize --databases test --replace_result 'Table is already up to date' OK ---exec $MYSQL_CHECK --all-in-1 --analyze --optimize --databases test +--exec $MYSQL_CHECK --all-in-1 --analyze --databases test +--exec $MYSQL_CHECK --all-in-1 --optimize --databases test drop view v1; drop table t1; @@ -113,7 +118,8 @@ show tables; let $MYSQLD_DATADIR= `select @@datadir`; --copy_file $MYSQLD_DATADIR/test/v1.frm $MYSQLD_DATADIR/test/v-1.frm show tables; ---exec $MYSQL_CHECK --check-upgrade --fix-table-names --databases test +--exec $MYSQL_CHECK --check-upgrade --databases test +--exec $MYSQL_CHECK --fix-table-names --databases test show tables; drop view v1, `v-1`; drop table t1; @@ -212,3 +218,14 @@ show tables like 't1-1'; drop table `t1-1`; --echo End of 5.1 tests + + +--echo # +--echo # Bug #35269: mysqlcheck behaves different depending on order of parameters +--echo # + +--error 13 +--exec $MYSQL_CHECK -a --fix-table-names test "#mysql50#t1-1" +--error 1 +--exec $MYSQL_CHECK -aoc test "#mysql50#t1-1" + -- cgit v1.2.1 From 8284a3786d92158fcd5cc4fe5a305a87816562b5 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 8 Oct 2010 13:20:42 +0400 Subject: Fixed plugin_load_option failure, when example storage engine is not available. We need to add loose prefix to example load option. --- mysql-test/t/plugin_load_option-master.opt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/plugin_load_option-master.opt b/mysql-test/t/plugin_load_option-master.opt index 3be53c3b713..e22ecb4ff3a 100644 --- a/mysql-test/t/plugin_load_option-master.opt +++ b/mysql-test/t/plugin_load_option-master.opt @@ -1,3 +1,3 @@ $EXAMPLE_PLUGIN_OPT $EXAMPLE_PLUGIN_LOAD ---plugin-example=FORCE_PLUS_PERMANENT +--loose-plugin-example=FORCE_PLUS_PERMANENT -- cgit v1.2.1 From c8d7a31f35bc988362ec07c2e2520a0dc511eebe Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Fri, 8 Oct 2010 11:52:09 +0200 Subject: Bug#57209 valgrind + Assertion failed: dst > buf Buffer overrun when trying to format DBL_MAX mysql-test/r/func_math.result: Add test case for Bug#57209 mysql-test/t/func_math.test: Add test case for Bug#57209 sql/item_strfunc.cc: Allocate a larger buffer for the result. --- mysql-test/t/func_math.test | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 44af2f5ad3f..efdf7201a40 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -458,3 +458,9 @@ SELECT 2 DIV -2; SELECT -(1 DIV 0); # Crashed the server with SIGFPE before the bugfix SELECT -9223372036854775808 MOD -1; + +--echo # +--echo # Bug #57209 valgrind + Assertion failed: dst > buf +--echo # +SELECT floor(log10(format(concat_ws(5445796E25, 5306463, 30837), -358821))) +as foo; -- cgit v1.2.1 From 15ccca1d5520eca44fd63925fdd2020428965985 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 8 Oct 2010 09:16:20 -0300 Subject: Bug#56822: Add a thread state for sessions waiting on the query cache lock Only wait for a single debug signal at a time as the signal state is global. Also, do not activate the query cache debug sync points if the thread has no associated THD session. mysql-test/t/query_cache_debug.test: Only wait for a single debug signal at a time as the signal state is global. sql/sql_cache.cc: Do not execute the debug sync point if the thread has no associated THD session. This scenario happens for federated threads. --- mysql-test/t/query_cache_debug.test | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/query_cache_debug.test b/mysql-test/t/query_cache_debug.test index 77e714aa6f5..2f85813d1ef 100644 --- a/mysql-test/t/query_cache_debug.test +++ b/mysql-test/t/query_cache_debug.test @@ -170,20 +170,26 @@ connection thd2; --echo ** On THD2: Insert a result into the cache. This attempt will be blocked --echo ** because of a debug hook placed just before the mutex lock after which --echo ** the first part of the result set is written. -SET DEBUG_SYNC="wait_in_query_cache_insert SIGNAL parked2 WAIT_FOR go2"; +SET DEBUG_SYNC="wait_in_query_cache_insert SIGNAL parked2 WAIT_FOR go2 EXECUTE 1"; --send SELECT SQL_CACHE * FROM t2 UNION SELECT * FROM t3 +connection default; +--echo =================================== Connection default +--echo ** Assert that the SELECT-stmt thread reaches the sync point. +SET DEBUG_SYNC="now WAIT_FOR parked2"; +--echo ** +--echo ** + connection thd3; --echo =================================== Connection thd3 --echo ** On THD3: Insert another result into the cache and block on the same --echo ** debug hook. -SET DEBUG_SYNC="wait_in_query_cache_insert SIGNAL parked3 WAIT_FOR go3"; ---send SELECT SQL_CACHE * FROM t4 UNION SELECT * FROM t5; +SET DEBUG_SYNC="wait_in_query_cache_insert SIGNAL parked3 WAIT_FOR go3 EXECUTE 1"; +--send SELECT SQL_CACHE * FROM t4 UNION SELECT * FROM t5 connection default; --echo =================================== Connection default ---echo ** Assert that the two SELECT-stmt threads to reach the hook. -SET DEBUG_SYNC="now WAIT_FOR parked2"; +--echo ** Assert that the SELECT-stmt thread reaches the sync point. SET DEBUG_SYNC="now WAIT_FOR parked3"; --echo ** --echo ** -- cgit v1.2.1 From 42550e21e85904877714a3215a220e471597c3e2 Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Tue, 12 Oct 2010 23:25:40 +0400 Subject: Fix for bug#57272: crash in rpad() when using utf8 Problem: if multibyte and binary string arguments passed to RPAD(), LPAD() or INSERT() functions, they might return wrong results or even lead to a server crash due to missed character set convertion. Fix: perform the convertion if necessary. mysql-test/r/ctype_utf8.result: Fix for bug#57272: crash in rpad() when using utf8 - test result. mysql-test/t/ctype_utf8.test: Fix for bug#57272: crash in rpad() when using utf8 - test case. sql/item_strfunc.cc: Fix for bug#57272: crash in rpad() when using utf8 - convert multibyte argument's character set to binary in case of FUNCTION(MULTIBYTE_ARG, .., BINARY_ARG,..) for RPAD(), LPAD() and INSERT() functions. --- mysql-test/t/ctype_utf8.test | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 23c83310886..8e9f09d1e56 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1466,3 +1466,23 @@ SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b; DROP TABLE t1; --echo End of 5.0 tests + + +# +# Bug #57272: crash in rpad() when using utf8 +# +SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'яэюя')); +SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'йцуя')); +SELECT HEX(RPAD(0x20, 2, _utf8 0xD18F)); +SELECT HEX(RPAD(0x20, 4, _utf8 0xD18F)); +SELECT HEX(LPAD(0x20, 2, _utf8 0xD18F)); +SELECT HEX(LPAD(0x20, 4, _utf8 0xD18F)); + +SELECT HEX(RPAD(_utf8 0xD18F, 3, 0x20)); +SELECT HEX(LPAD(_utf8 0xD18F, 3, 0x20)); + +SELECT HEX(INSERT(_utf8 0xD18F, 2, 1, 0x20)); +SELECT HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20)); + + +--echo End of 5.1 tests -- cgit v1.2.1 From b001a5224d8b26e9706a386ca2c26320d152ee1c Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Tue, 12 Oct 2010 23:28:03 +0400 Subject: Fix for bug#57283: inet_ntoa() crashes Problem: some call of INET_NTOA() function may lead to a crash due to missing its character set initialization. Fix: explicitly set the character set. mysql-test/r/func_misc.result: Fix for bug#57283: inet_ntoa() crashes - test result. mysql-test/t/func_misc.test: Fix for bug#57283: inet_ntoa() crashes - test case. sql/item_strfunc.cc: Fix for bug#57283: inet_ntoa() crashes - explicitly set buffer's character set. --- mysql-test/t/func_misc.test | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index c6b5ffd5a3f..f47418fa773 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -479,4 +479,12 @@ SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; DROP TABLE t1; + +# +# Bug #57283: inet_ntoa() crashes +# +SELECT INET_NTOA(0); +SELECT '1' IN ('1', INET_NTOA(0)); + + --echo End of tests -- cgit v1.2.1 From 8169faec2797511e649bd98329c69a6cb0c9a857 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 13 Oct 2010 12:28:58 +0700 Subject: Fixed bug#36742 - GRANT hostname case handling inconsistent. mysql-test/r/grant.result: It was added result for test case for bug#36742. mysql-test/t/grant.test: It was added test case for bug#36742. sql/sql_yacc.yy: It was added convertation of host name part of user name to lowercase. --- mysql-test/t/grant.test | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index cb8d3c63be8..2fafeb7d264 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1550,5 +1550,15 @@ DROP TABLE db2.t1; DROP DATABASE db1; DROP DATABASE db2; +--echo # +--echo # Bug #36742 +--echo # +grant usage on Foo.* to myuser@Localhost identified by 'foo'; +grant select on Foo.* to myuser@localhost; +select host,user from mysql.user where User='myuser'; +revoke select on Foo.* from myuser@localhost; +delete from mysql.user where User='myuser'; +flush privileges; + # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc -- cgit v1.2.1 From b5be2fbc8df3c8e7131d88adb06bad408e446df7 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Wed, 13 Oct 2010 16:15:28 +0200 Subject: Bug #55930 Assertion `thd->transaction.stmt.is_empty() || thd->in_sub_stmt || (thd->state.. OPTIMIZE TABLE is not directly supported by InnoDB. Instead, recreate and analyze of the table is done. After recreate, the table is closed and locks are released before the table is reopened and locks re-acquired for the analyze phase. This assertion was triggered if OPTIMIZE TABLE failed to acquire thr_lock locks before starting the analyze phase. The assertion tests (among other things) that there no active statement transaction. However, as part of acquiring the thr_lock lock, external_lock() is called for InnoDB tables and this causes a statement transaction to be started. If thr_multi_lock() later fails (e.g. due to timeout), the failure handling code causes this assert to be triggered. This patch fixes the problem by doing rollback of the current statement transaction in case open_ltable (used by OPTIMIZE TABLE) fails to acquire thr_lock locks. Test case added to lock_sync.test. --- mysql-test/t/lock_sync.test | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/lock_sync.test b/mysql-test/t/lock_sync.test index 49f8f59ec5a..7131e2cde31 100644 --- a/mysql-test/t/lock_sync.test +++ b/mysql-test/t/lock_sync.test @@ -1023,6 +1023,61 @@ DROP EVENT e2; SET DEBUG_SYNC="RESET"; +--echo # +--echo # Bug#55930 Assertion `thd->transaction.stmt.is_empty() || +--echo # thd->in_sub_stmt || (thd->state.. +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1(a INT) engine=InnoDB; +INSERT INTO t1 VALUES (1), (2); + +connect (con1, localhost, root); +connect (con2, localhost, root); + +--echo # Connection con1 +connection con1; +SET SESSION lock_wait_timeout= 1; +SET DEBUG_SYNC= 'ha_admin_open_ltable SIGNAL opti_recreate WAIT_FOR opti_analyze'; +--echo # Sending: +--send OPTIMIZE TABLE t1 + +--echo # Connection con2 +connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR opti_recreate'; +SET DEBUG_SYNC= 'after_lock_tables_takes_lock SIGNAL thrlock WAIT_FOR release_thrlock'; +--echo # Sending: +--send INSERT INTO t1 VALUES (3) + +--echo # Connection default +connection default; +SET DEBUG_SYNC= 'now WAIT_FOR thrlock'; +SET DEBUG_SYNC= 'now SIGNAL opti_analyze'; + +--echo # Connection con1 +connection con1; +--echo # Reaping: OPTIMIZE TABLE t1 +--reap +SET DEBUG_SYNC= 'now SIGNAL release_thrlock'; +disconnect con1; +--source include/wait_until_disconnected.inc + +--echo # Connection con2 +connection con2; +--echo # Reaping: INSERT INTO t1 VALUES (3) +--reap +disconnect con2; +--source include/wait_until_disconnected.inc + +--echo # Connection default +connection default; +DROP TABLE t1; +SET DEBUG_SYNC= 'RESET'; + + # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc -- cgit v1.2.1 From 248625d910dda9848c99f28c5c73c4e4a9bfc4ae Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Thu, 14 Oct 2010 20:56:56 +0400 Subject: A fix and a test case for Bug#56540 "Exception (crash) in sql_show.cc during rqg_info_schema test on Windows". Ensure we do not access freed memory when filling information_schema.views when one of the views could not be properly opened. mysql-test/r/information_schema.result: Update results - a fix for Bug#56540. mysql-test/t/information_schema.test: Add a test case for Bug#56540 sql/sql_base.cc: Push an error into the Diagnostics area when we return an error. This directs get_all_tables() to the execution branch which doesn't involve 'process_table()' when no table/view was opened. sql/sql_show.cc: Do not try to access underlying table fields when opening of a view failed. The underlying table is closed in that case, and accessing its fields may lead to dereferencing a damaged pointer. --- mysql-test/t/information_schema.test | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index f5fab966bdd..bc73e8411ca 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1555,3 +1555,56 @@ WHERE COLUMNS.TABLE_SCHEMA = 'test' AND COLUMNS.TABLE_NAME = 't1'; +--echo # +--echo # A test case for Bug#56540 "Exception (crash) in sql_show.cc +--echo # during rqg_info_schema test on Windows" +--echo # Ensure that we never access memory of a closed table, +--echo # in particular, never access table->field[] array. +--echo # Before the fix, the below test case, produced +--echo # valgrind errors. +--echo # + +--disable_warnings +drop table if exists t1; +drop view if exists v1; +--enable_warnings + +create table t1 (a int, b int); +create view v1 as select t1.a, t1.b from t1; +alter table t1 change b c int; +lock table t1 read; +connect(con1, localhost, root,,); +--echo # --> connection con1 +connection con1; +send flush tables; +--echo # --> connection default +connection default; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table flush" and + info = "flush tables"; +--source include/wait_condition.inc +--vertical_results +select * from information_schema.views; +--horizontal_results +unlock tables; + +--echo # +--echo # Cleanup. +--echo # + +--echo # --> connection con1 +connection con1; +--echo # Reaping 'flush tables' +reap; +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # --> connection default +connection default; +drop table t1; +drop view v1; + + +--echo # +--echo # End of 5.5 tests +--echo # -- cgit v1.2.1 From 127c721cef2c1b248af79a386c174a5e7addd556 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Mon, 18 Oct 2010 14:47:26 +0400 Subject: Bug#54484 explain + prepared statement: crash and Got error -1 from storage engine Subquery executes twice, at top level JOIN::optimize and ::execute stages. At first execution create_sort_index() function is called and FT_SELECT object is created and destroyed. HANDLER::ft_handler is cleaned up in the object destructor and at second execution FT_SELECT::get_next() method returns error. The fix is to reinit HANDLER::ft_handler field before re-execution of subquery. mysql-test/r/fulltext.result: test case mysql-test/t/fulltext.test: test case sql/item_func.cc: reinit ft_handler before re-execution of subquery sql/item_func.h: Fixed method name sql/sql_select.cc: reinit ft_handler before re-execution of subquery --- mysql-test/t/fulltext.test | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index ec64728a8c9..6de8b87197c 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -585,4 +585,40 @@ REPAIR TABLE t1; SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; DROP TABLE t1; +--echo # +--echo # Bug#54484 explain + prepared statement: crash and Got error -1 from storage engine +--echo # + +CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, FULLTEXT KEY(f1), UNIQUE(f1)); +INSERT INTO t1 VALUES ('test'); + +SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1)) xor f1; + +PREPARE stmt FROM +'SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1)) xor f1'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +PREPARE stmt FROM +'SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1))'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +DROP TABLE t1; + --echo End of 5.1 tests -- cgit v1.2.1 From d0ac4e2c5ade16d6d0833137aa67071b34e66964 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Mon, 18 Oct 2010 16:12:27 +0400 Subject: Bug#56814 Explain + subselect + fulltext crashes server create_sort_index() function overwrites original JOIN_TAB::type field. At re-execution of subquery overwritten JOIN_TAB::type(JT_ALL) is used instead of JT_FT. It misleads test_if_skip_sort_order() and the function tries to find suitable key for the order that should not be allowed for FULLTEXT(JT_FT) table. The fix is to restore JOIN_TAB strucures for subselect on re-execution for EXPLAIN. Additional fix: Update TABLE::maybe_null field which affects list_contains_unique_index() behaviour as it could have the value(maybe_null==TRUE) based on the assumption that this join is outer (see setup_table_map() func). mysql-test/r/explain.result: test case mysql-test/t/explain.test: test case sql/item_subselect.cc: Make subquery uncacheable in case of EXPLAIN. It allows to keep original JOIN_TAB::type(see JOIN::save_join_tab) and restore it on re-execution. sql/sql_select.cc: -restore JOIN_TAB strucures for subselect on re-execution for EXPLAIN -Update TABLE::maybe_null field as it could have the value(maybe_null==TRUE) based on the assumption that this join is outer(see setup_table_map() func). This change is not related to the crash problem but affects EXPLAIN results in the test case. --- mysql-test/t/explain.test | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index b635a1b2968..c6c30b58341 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -228,4 +228,40 @@ EXPLAIN SELECT c1 FROM t1 WHERE c2 = 1 AND c4 = 1 AND c5 = 1; DROP TABLE t1; +--echo # +--echo # Bug#56814 Explain + subselect + fulltext crashes server +--echo # + +CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, +FULLTEXT KEY(f1),UNIQUE(f1)); +INSERT INTO t1 VALUES ('test'); + +EXPLAIN SELECT 1 FROM t1 +WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a ON (MATCH(t1.f1) AGAINST ("")) +WHERE t1.f1 GROUP BY t1.f1)); + +PREPARE stmt FROM +'EXPLAIN SELECT 1 FROM t1 + WHERE 1 > ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a + ON (MATCH(t1.f1) AGAINST ("")) + WHERE t1.f1 GROUP BY t1.f1))'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +PREPARE stmt FROM +'EXPLAIN SELECT 1 FROM t1 + WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) AGAINST ("")) + WHERE t1.f1 GROUP BY t1.f1))'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +DROP TABLE t1; + --echo End of 5.1 tests. -- cgit v1.2.1 From cdddc7bfd58f900d63b21a811ad768849311c7b7 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Mon, 18 Oct 2010 21:03:53 +0700 Subject: Follow up for bug#36742. Changed test case for bug#19828 because currently hostname stored in db in lowercase. --- mysql-test/t/grant3.test | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/grant3.test b/mysql-test/t/grant3.test index 437fc9a278f..d24b2de17eb 100644 --- a/mysql-test/t/grant3.test +++ b/mysql-test/t/grant3.test @@ -64,6 +64,7 @@ SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser' order by 1,2; DROP USER CUser@localhost; +--error ER_CANNOT_USER DROP USER CUser@LOCALHOST; #### table grants @@ -88,6 +89,7 @@ SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; DROP USER CUser@localhost; +--error ER_CANNOT_USER DROP USER CUser@LOCALHOST; ### column grants @@ -112,6 +114,7 @@ SELECT user, host FROM mysql.user where user = 'CUser' order by 1,2; SELECT user, host, db, Table_name, Table_priv, Column_priv FROM mysql.tables_priv where user = 'CUser' order by 1,2; DROP USER CUser@localhost; +--error ER_CANNOT_USER DROP USER CUser@LOCALHOST; drop table t1; @@ -131,6 +134,7 @@ flush privileges; SELECT user, host FROM mysql.user where user = 'CUser2' order by 1,2; SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser2' order by 1,2; +--error ER_NONEXISTING_GRANT REVOKE SELECT ON test.* FROM 'CUser2'@'localhost'; flush privileges; @@ -138,6 +142,7 @@ SELECT user, host FROM mysql.user where user = 'CUser2' order by 1,2; SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser2' order by 1,2; DROP USER CUser2@localhost; +--error ER_CANNOT_USER DROP USER CUser2@LOCALHOST; -- cgit v1.2.1 From a6df37dbbf2ba51b6785576a946f664b0996c03c Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Tue, 19 Oct 2010 08:45:18 +0200 Subject: Bug #57203 Assertion `field_length <= 255' failed. After the fix for Bug #55077 Assertion failed: width > 0 && to != ((void *)0), file .\dtoa.c we no longer try to allocate a string of length 'field_length' so the asserts are relevant only for ZEROFILL columns. mysql-test/r/select.result: Add test case for Bug#57203 mysql-test/t/select.test: Add test case for Bug#57203 sql/field.cc: Rewrite the DBUG_ASSERTS on field_length. --- mysql-test/t/select.test | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 87f36c452f2..3ed7213e8d7 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -4147,3 +4147,22 @@ DROP VIEW view_t1; DROP TABLE t1; --echo # End of test BUG#54515 + +--echo # +--echo # Bug #57203 Assertion `field_length <= 255' failed. +--echo # + +SELECT coalesce((avg(distinct (geomfromtext("point(25379 -22010)"))))) +UNION ALL +SELECT coalesce((avg(distinct (geomfromtext("point(25379 -22010)"))))) +AS foo +; + +CREATE table t1(a text); +INSERT INTO t1 VALUES (''), (''); +SELECT avg(distinct(t1.a)) FROM t1, t1 t2 +GROUP BY t2.a ORDER BY t1.a; + +DROP TABLE t1; + +--echo # End of test BUG#57203 -- cgit v1.2.1 From 95d91c0f575fc490ac9e3d36a7d65980d9347489 Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Tue, 19 Oct 2010 12:27:09 +0200 Subject: Bug #46941 crash with lower_case_table_names=2 and foreign key data dictionary confusion On file systems with case insensitive file names, and lower_case_table_names set to '2', the server could crash due to a table definition cache inconsistency. This is the default setting on MacOSX, but may also be set and used on MS Windows. The bug is caused by using two different strategies for creating the hash key for the table definition cache, resulting in failure to look up an entry which is present in the cache, or failure to delete an existing entry. One strategy was to use the real table name (with case preserved), and the other to use a normalized table name (i.e a lower case version). This is manifested in two cases. One is during 'DROP DATABASE', where all known files are removed. The removal from the table definition cache is done via a generated list of TABLE_LIST with keys (wrongly) created using the case preserved name. The other is during CREATE TABLE, where the cache lookup is also (wrongly) based on the case preserved name. The fix was to use only the normalized table name when creating hash keys. sql/sql_db.cc: Normalize table name (i.e lower case it) sql/sql_table.cc: table_name contains the normalized name alias contains the real table name --- mysql-test/t/lowercase_table4-master.opt | 1 + mysql-test/t/lowercase_table4.test | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100755 mysql-test/t/lowercase_table4-master.opt create mode 100755 mysql-test/t/lowercase_table4.test (limited to 'mysql-test/t') diff --git a/mysql-test/t/lowercase_table4-master.opt b/mysql-test/t/lowercase_table4-master.opt new file mode 100755 index 00000000000..c0a1981fa7c --- /dev/null +++ b/mysql-test/t/lowercase_table4-master.opt @@ -0,0 +1 @@ +--lower-case-table-names=2 diff --git a/mysql-test/t/lowercase_table4.test b/mysql-test/t/lowercase_table4.test new file mode 100755 index 00000000000..93956047145 --- /dev/null +++ b/mysql-test/t/lowercase_table4.test @@ -0,0 +1,56 @@ +--source include/have_case_insensitive_file_system.inc +--source include/have_innodb.inc + +--echo # +--echo # Bug#46941 crash with lower_case_table_names=2 and +--echo # foreign data dictionary confusion +--echo # + +CREATE DATABASE XY; +USE XY; + +# +# Logs are disabled, since the number of creates tables +# and subsequent select statements may vary between +# versions +# +--disable_query_log +--disable_result_log + +let $tcs = `SELECT @@table_open_cache + 1`; + +let $i = $tcs; + +while ($i) +{ + eval CREATE TABLE XY.T_$i (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT, + primary key(a, b), unique(b)) ENGINE=InnoDB; + dec $i; +} + +eval ALTER TABLE XY.T_$tcs ADD INDEX I1 (c, b), + ADD CONSTRAINT C1 FOREIGN KEY (c, b) REFERENCES XY.T_1 (a, b); + +eval ALTER TABLE XY.T_$tcs ADD INDEX I2 (b), + ADD CONSTRAINT C2 FOREIGN KEY (b) REFERENCES XY.T_1(a); + +let $i = $tcs; +while ($i) +{ + eval SELECT * FROM XY.T_$i LIMIT 1; + dec $i; +} + +DROP DATABASE XY; +CREATE DATABASE XY; +USE XY; +eval CREATE TABLE XY.T_$tcs (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT, + PRIMARY KEY(a, b), UNIQUE(b)) ENGINE=InnoDB; +# +# The bug causes this SELECT to err +eval SELECT * FROM XY.T_$tcs LIMIT 1; + +--enable_query_log +--enable_result_log +DROP DATABASE XY; + -- cgit v1.2.1 From 8a67fc8c8246f5d7290b7e572fa092cf0cadb25d Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Tue, 19 Oct 2010 13:54:28 +0200 Subject: Test wait_timeout: do not fail by SQL syntax error, use die --- mysql-test/t/wait_timeout.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/wait_timeout.test b/mysql-test/t/wait_timeout.test index 6947e346675..eb86cf17ebb 100644 --- a/mysql-test/t/wait_timeout.test +++ b/mysql-test/t/wait_timeout.test @@ -53,7 +53,7 @@ while (!`select @aborted_clients`) dec $retries; if (!$retries) { - Failed to detect that client has been aborted; + die Failed to detect that client has been aborted; } } --enable_query_log @@ -108,7 +108,7 @@ while (!`select @aborted_clients`) dec $retries; if (!$retries) { - Failed to detect that client has been aborted; + die Failed to detect that client has been aborted; } } --enable_query_log -- cgit v1.2.1 From 84c57a5e278bbaa976c8d2961fd554e078c9b714 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Tue, 19 Oct 2010 13:56:30 +0200 Subject: Bug #52828 Tests that use perl fail when perl is not in path main.mysqltest skipped on Windows because a perl intentionally does exit(1) Use exit(2), as exit(1) on Windows is indistinguishable from failing to execute perl. --- mysql-test/t/mysqltest.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index caadce44dcf..d6bdbc2b3c1 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -331,7 +331,7 @@ eval select $mysql_errno as "after_!errno_masked_error" ; --exec illegal_command --cat_file does_not_exist --perl - exit(1); + exit(2); EOF # ---------------------------------------------------------------------------- -- cgit v1.2.1 From 7a8515cc200bc867bb1d0f24bc8b51ea237ef8dd Mon Sep 17 00:00:00 2001 From: Oystein Grovlen Date: Wed, 20 Oct 2010 15:17:29 +0200 Subject: Bug#57512 str_to_date crash... str_to_date function should only try to generate a warning for invalid input strings, not when input value is NULL. In latter case, val_str() of input argument will return a nil pointer. Trying to generate a warning using this pointer lead to a segmentation fault. Solution: Only generate warning when pointer to input string is non-nil. mysql-test/r/func_time.result: Added test case for Bug#57512 mysql-test/t/func_time.test: Added test case for Bug#57512 sql/item_timefunc.cc: Skip generating warning when pointer to input string is nil since this implies that input argument was NULL. --- mysql-test/t/func_time.test | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 08c09adb093..901c55f4ad3 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -842,5 +842,13 @@ INSERT INTO t1 VALUES ('2008-01-03 00:00:00'), ('2008-01-03 00:00:00'); SELECT * FROM t1 WHERE date_date >= subtime(now(), "00:30:00"); SELECT * FROM t1 WHERE date_date <= addtime(date_add("2000-1-1", INTERVAL "1:1:1" HOUR_SECOND), "00:20:00"); DROP TABLE t1; + +--echo # +--echo # Bug#57512 str_to_date crash... +--echo # + +SELECT WEEK(STR_TO_DATE(NULL,0)); +SELECT SUBDATE(STR_TO_DATE(NULL,0), INTERVAL 1 HOUR); + --echo # -- cgit v1.2.1 From d6af9bef7a72f24b05a88b6cd4fd3a69b14cc82d Mon Sep 17 00:00:00 2001 From: "Horst.Hunger" Date: Wed, 20 Oct 2010 16:56:09 +0200 Subject: due to merge --- mysql-test/t/plugin_auth_qa-master.opt | 2 + mysql-test/t/plugin_auth_qa.test | 338 +++++++++++++++++++++++++++++++ mysql-test/t/plugin_auth_qa_1-master.opt | 2 + mysql-test/t/plugin_auth_qa_1.test | 334 ++++++++++++++++++++++++++++++ mysql-test/t/plugin_auth_qa_2-master.opt | 2 + mysql-test/t/plugin_auth_qa_2.test | 148 ++++++++++++++ mysql-test/t/plugin_auth_qa_3-master.opt | 2 + mysql-test/t/plugin_auth_qa_3.test | 25 +++ 8 files changed, 853 insertions(+) create mode 100644 mysql-test/t/plugin_auth_qa-master.opt create mode 100644 mysql-test/t/plugin_auth_qa.test create mode 100644 mysql-test/t/plugin_auth_qa_1-master.opt create mode 100644 mysql-test/t/plugin_auth_qa_1.test create mode 100644 mysql-test/t/plugin_auth_qa_2-master.opt create mode 100644 mysql-test/t/plugin_auth_qa_2.test create mode 100644 mysql-test/t/plugin_auth_qa_3-master.opt create mode 100644 mysql-test/t/plugin_auth_qa_3.test (limited to 'mysql-test/t') diff --git a/mysql-test/t/plugin_auth_qa-master.opt b/mysql-test/t/plugin_auth_qa-master.opt new file mode 100644 index 00000000000..3536d102387 --- /dev/null +++ b/mysql-test/t/plugin_auth_qa-master.opt @@ -0,0 +1,2 @@ +$PLUGIN_AUTH_OPT +$PLUGIN_AUTH_LOAD diff --git a/mysql-test/t/plugin_auth_qa.test b/mysql-test/t/plugin_auth_qa.test new file mode 100644 index 00000000000..0961c1dfef5 --- /dev/null +++ b/mysql-test/t/plugin_auth_qa.test @@ -0,0 +1,338 @@ +# The numbers represent test cases of the test plan. + +--source include/have_plugin_auth.inc +--source include/not_embedded.inc + +CREATE DATABASE test_user_db; + +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +--echo ========== test 1.1 ====================================================== +# without '', without AS part +CREATE USER plug IDENTIFIED WITH test_plugin_server; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug; +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +REVOKE ALL PRIVILEGES ON test_user_db.* FROM plug; +DROP USER plug; +# with '', without AS part +CREATE USER plug IDENTIFIED WITH 'test_plugin_server'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug; +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +REVOKE ALL PRIVILEGES ON test_user_db.* FROM plug; +DROP USER plug; +# without '', AS part empty +CREATE USER plug IDENTIFIED WITH test_plugin_server AS ''; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug; +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS ''; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +REVOKE ALL PRIVILEGES ON test_user_db.* FROM plug; +DROP USER plug; +# with '', AS part empty without '' +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS ; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS; +# without '', AS part without '' +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH test_plugin_server AS plug_dest; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS plug_dest; +--echo ========== test 1.1 syntax errors ======================================== +# without auth_name +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH AS plug_dest; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH AS plug_dest; +# without auth_name and AS part +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH; +# without auth_name but AS part +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED AS ''; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED AS ''; +# with 2 auth_name parts +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' IDENTIFIED WITH 'test_plugin_server'; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug + IDENTIFIED WITH 'test_plugin_server' IDENTIFIED WITH 'test_plugin_server'; +# with 2 AS parts +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS '' AS 'plug_dest'; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug AS '' AS 'plug_dest'; +# with 2 complete WITH parts +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS '' + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS '' + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +# with BY and WITH part +--error ER_PARSE_ERROR +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd' + IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED BY 'plug_dest_passwd' + IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +# with WITH part and BY part +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest' + USER plug_dest IDENTIFIED by 'plug_dest_pwd'; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest' + USER plug_dest IDENTIFIED by 'plug_dest_pwd'; +# with WITH part and BY part +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest' + plug_dest IDENTIFIED by 'plug_dest_pwd'; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest' + plug_dest IDENTIFIED by 'plug_dest_pwd'; +# with WITH part and BY part +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest' + IDENTIFIED by 'plug_dest_pwd'; +--error ER_PARSE_ERROR +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest' + IDENTIFIED by 'plug_dest_pwd'; + +--echo ========== test 1.1 combinations ========================== +# CREATE...WITH/CREATE...BY +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--echo ========== test 1.1.1.6/1.1.2.5 ============================ +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug, plug_dest; +# +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug_dest; +# GRANT...WITH/CREATE...BY +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug, plug_dest; +# +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug_dest; +# CREATE...WITH/GRANT...BY +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug, plug_dest; +# +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug; +GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug_dest; +# +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--error 1700 +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--error 1700 +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server'; +DROP USER plug; +# +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +--error ER_CANNOT_USER +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--error ER_CANNOT_USER +CREATE USER plug IDENTIFIED WITH 'test_plugin_server'; +DROP USER plug; +# +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root'; +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root'; +DROP USER plug; +# +GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +--error ER_CANNOT_USER +CREATE USER plug IDENTIFIED BY 'plug_dest_passwd'; +DROP USER plug; +# +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root'; +DROP USER plug,plug_dest; +# +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root'; +GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root'; +DROP USER plug,plug_dest; +# + +--echo ========== test 1.1.1.1/1.1.2.1/1.1.1.5 ==================== + +SET NAMES utf8; +# +CREATE USER plüg IDENTIFIED WITH 'test_plugin_server' AS 'plüg_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plüg; +CREATE USER plüg_dest IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plüg_dest; + +SET NAMES ascii; +# +CREATE USER 'plüg' IDENTIFIED WITH 'test_plugin_server' AS 'plüg_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER 'plüg'; +CREATE USER 'plüg_dest' IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER 'plüg_dest'; + +SET NAMES latin1; +# +--echo ========== test 1.1.1.5 ==================================== +--error ER_PLUGIN_IS_NOT_LOADED +CREATE USER 'plüg' IDENTIFIED WITH 'test_plügin_server' AS 'plüg_dest'; +CREATE USER 'plug' IDENTIFIED WITH 'test_plugin_server' AS 'plüg_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER 'plug'; +CREATE USER 'plüg_dest' IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER 'plüg_dest'; + +SET NAMES utf8; +# +--error ER_PLUGIN_IS_NOT_LOADED +CREATE USER plüg IDENTIFIED WITH 'test_plügin_server' AS 'plüg_dest'; +CREATE USER 'plüg' IDENTIFIED WITH 'test_plugin_server' AS 'plüg_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER 'plüg'; +CREATE USER 'plüg_dest' IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER 'plüg_dest'; + +CREATE USER plüg IDENTIFIED WITH test_plugin_server AS 'plüg_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plüg; +CREATE USER plüg_dest IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plüg_dest; + +--echo ========== test 1.1.1.2/1.1.2.2============================= + +SET @auth_name= 'test_plugin_server'; +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH @auth_name AS 'plug_dest'; + +SET @auth_string= 'plug_dest'; +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH test_plugin_server AS @auth_string; + +--echo ========== test 1.1.1.3/1.1.2.3============================= + +--error ER_PLUGIN_IS_NOT_LOADED +CREATE USER plug IDENTIFIED WITH 'hh''s_test_plugin_server' AS 'plug_dest'; + +CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'hh''s_plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug; +CREATE USER 'hh''s_plug_dest' IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER 'hh''s_plug_dest'; + +--echo ========== test 1.1.1.4 ==================================== + +--error ER_PARSE_ERROR +CREATE USER plug IDENTIFIED WITH hh''s_test_plugin_server AS 'plug_dest'; + +--echo ========== test 1.1.3.1 ==================================== + +GRANT INSERT ON test_user_db.* TO grant_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +CREATE USER plug_dest; +DROP USER plug_dest; +GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER grant_user,plug_dest; +# +set @save_sql_mode= @@sql_mode; +SET @@sql_mode=no_auto_create_user; +GRANT INSERT ON test_user_db.* TO grant_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +CREATE USER plug_dest; +DROP USER plug_dest; +--error ER_PASSWORD_NO_MATCH +GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest; +DROP USER grant_user; +# +GRANT INSERT ON test_user_db.* TO grant_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root'; +DROP USER plug_dest; +GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_user_passwd'; +--sorted_result +SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root'; +DROP USER grant_user,plug_dest; +set @@sql_mode= @save_sql_mode; +# +DROP DATABASE test_user_db; +--exit + diff --git a/mysql-test/t/plugin_auth_qa_1-master.opt b/mysql-test/t/plugin_auth_qa_1-master.opt new file mode 100644 index 00000000000..3536d102387 --- /dev/null +++ b/mysql-test/t/plugin_auth_qa_1-master.opt @@ -0,0 +1,2 @@ +$PLUGIN_AUTH_OPT +$PLUGIN_AUTH_LOAD diff --git a/mysql-test/t/plugin_auth_qa_1.test b/mysql-test/t/plugin_auth_qa_1.test new file mode 100644 index 00000000000..d7a7afe9407 --- /dev/null +++ b/mysql-test/t/plugin_auth_qa_1.test @@ -0,0 +1,334 @@ +# The numbers represent test cases of the test plan. + +--source include/have_plugin_auth.inc +--source include/not_embedded.inc + +CREATE DATABASE test_user_db; + +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; + +--echo ========== test 1.1.3.2 ==================================== + +# CREATE...WITH/CREATE...BY/GRANT +CREATE USER plug_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +GRANT PROXY ON plug_dest TO plug_user; +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +REVOKE PROXY ON plug_dest FROM plug_user; +--error 1 +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +DROP USER plug_user,plug_dest; +# +# GRANT...WITH +GRANT ALL PRIVILEGES ON test_user_db.* TO plug_user + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_dest_passwd'; +GRANT PROXY ON plug_dest TO plug_user; + +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +--echo 1) +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +REVOKE ALL PRIVILEGES ON test_user_db.* FROM 'plug_user' + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +--echo 2) +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +REVOKE PROXY ON plug_dest FROM plug_user; +--echo 3) +--error 1 +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +DROP USER plug_user,plug_dest; +# +# GRANT...WITH/CREATE...BY +GRANT ALL PRIVILEGES ON test_user_db.* TO plug_user + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +--echo 1) +--error 1 +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +GRANT PROXY ON plug_dest TO plug_user; +--echo 2) +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +REVOKE ALL PRIVILEGES ON test_user_db.* FROM 'plug_user' + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +#REVOKE ALL PRIVILEGES ON test_user_db.* FROM 'plug_dest' +# IDENTIFIED BY 'plug_dest_passwd'; +DROP USER plug_user,plug_dest; + +--echo ========== test 1.2 ======================================== + +# GRANT...WITH/CREATE...BY +GRANT ALL PRIVILEGES ON test_user_db.* TO plug_user + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +GRANT PROXY ON plug_dest TO plug_user; +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 +RENAME USER plug_dest TO new_dest; +--error 1 +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 +GRANT PROXY ON new_dest TO plug_user; +--error 1 +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=new_dest -e "SELECT current_user();SELECT user();" 2>&1 +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug_user,new_dest; + +# CREATE...WITH/CREATE...BY +CREATE USER plug_user + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +--error 1 +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 +GRANT PROXY ON plug_dest TO plug_user; +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 +RENAME USER plug_dest TO new_dest; +--error 1 +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 +GRANT PROXY ON new_dest TO plug_user; +--error 1 +--exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=new_dest -e "SELECT current_user();SELECT user();" 2>&1 +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug_user,new_dest; +# CREATE...WITH +CREATE USER plug_user + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +GRANT PROXY ON plug_dest TO plug_user; +--echo connect(plug_user,localhost,plug_user,plug_dest); +connect(plug_user,localhost,plug_user,plug_dest); +select USER(),CURRENT_USER(); +--echo connection default; +connection default; +--echo disconnect plug_user; +disconnect plug_user; +RENAME USER plug_user TO new_user; +--echo connect(plug_user,localhost,new_user,plug_dest); +connect(plug_user,localhost,new_user,plug_dest); +select USER(),CURRENT_USER(); +--echo connection default; +connection default; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +--echo disconnect plug_user; +disconnect plug_user; +UPDATE mysql.user SET user='plug_user' WHERE user='new_user'; +FLUSH PRIVILEGES; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +DROP USER plug_dest,plug_user; +--echo ========== test 1.3 ======================================== + +# +CREATE USER plug_user + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +GRANT PROXY ON plug_dest TO plug_user; +--echo connect(plug_user,localhost,plug_user,plug_dest); +connect(plug_user,localhost,plug_user,plug_dest); +select USER(),CURRENT_USER(); +--echo connection default; +connection default; +--echo disconnect plug_user; +disconnect plug_user; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +UPDATE mysql.user SET user='new_user' WHERE user='plug_user'; +FLUSH PRIVILEGES; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +UPDATE mysql.user SET authentication_string='new_dest' WHERE user='new_user'; +FLUSH PRIVILEGES; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +UPDATE mysql.user SET plugin='new_plugin_server' WHERE user='new_user'; +FLUSH PRIVILEGES; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +--echo connect(plug_user,localhost,new_user,new_dest); +--disable_query_log +--error ER_PLUGIN_IS_NOT_LOADED +connect(plug_user,localhost,new_user,new_dest); +--enable_query_log +UPDATE mysql.user SET plugin='test_plugin_server' WHERE user='new_user'; +UPDATE mysql.user SET USER='new_dest' WHERE user='plug_dest'; +FLUSH PRIVILEGES; +GRANT PROXY ON new_dest TO new_user; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +--echo connect(plug_user,localhost,new_user,new_dest); +connect(plug_user,localhost,new_user,new_dest); +select USER(),CURRENT_USER(); +--echo connection default; +connection default; +--echo disconnect plug_user; +disconnect plug_user; +UPDATE mysql.user SET USER='plug_dest' WHERE user='new_dest'; +FLUSH PRIVILEGES; +CREATE USER new_dest IDENTIFIED BY 'new_dest_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +GRANT ALL PRIVILEGES ON test.* TO new_user; +--echo connect(plug_user,localhost,new_dest,new_dest_passwd); +connect(plug_user,localhost,new_dest,new_dest_passwd); +select USER(),CURRENT_USER(); +--echo connection default; +connection default; +--echo disconnect plug_user; +disconnect plug_user; +DROP USER new_user,new_dest,plug_dest; + +--echo ========== test 2, 2.1, 2.2 ================================ + +CREATE USER ''@'' IDENTIFIED WITH test_plugin_server AS 'proxied_user'; +CREATE USER proxied_user IDENTIFIED BY 'proxied_user_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +--echo connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +SELECT USER(),CURRENT_USER(); +--echo ========== test 2.2.1 ====================================== +SELECT @@proxy_user; +--echo connection default; +connection default; +--echo disconnect proxy_con; +disconnect proxy_con; +--echo connect(proxy_con,localhost,proxy_user,proxied_user); +--disable_query_log +--error ER_ACCESS_DENIED_ERROR : this should fail : no grant +connect(proxy_con,localhost,proxy_user,proxied_user); +--enable_query_log +GRANT PROXY ON proxied_user TO ''@''; +--echo connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +SELECT USER(),CURRENT_USER(); +--echo connection default; +connection default; +--echo disconnect proxy_con; +disconnect proxy_con; +--echo connect(proxy_con,localhost,proxy_user,proxied_user); +connect(proxy_con,localhost,proxy_user,proxied_user); +SELECT USER(),CURRENT_USER(); +--echo ========== test 2.2.1 ====================================== +SELECT @@proxy_user; +--echo connection default; +connection default; +--echo disconnect proxy_con; +disconnect proxy_con; +DROP USER ''@'',proxied_user; +# +GRANT ALL PRIVILEGES ON test_user_db.* TO ''@'' + IDENTIFIED WITH test_plugin_server AS 'proxied_user'; +CREATE USER proxied_user IDENTIFIED BY 'proxied_user_passwd'; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +--echo connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +SELECT USER(),CURRENT_USER(); +SELECT @@proxy_user; +--echo connection default; +connection default; +--echo disconnect proxy_con; +disconnect proxy_con; +--echo connect(proxy_con,localhost,proxy_user,proxied_user); +--disable_query_log +--error ER_ACCESS_DENIED_ERROR : this should fail : no grant +connect(proxy_con,localhost,proxy_user,proxied_user); +--enable_query_log +GRANT PROXY ON proxied_user TO ''@''; +--echo connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +connect(proxy_con,localhost,proxied_user,proxied_user_passwd); +SELECT USER(),CURRENT_USER(); +--echo connection default; +connection default; +--echo disconnect proxy_con; +disconnect proxy_con; +--echo connect(proxy_con,localhost,proxy_user,proxied_user); +connect(proxy_con,localhost,proxy_user,proxied_user); +SELECT USER(),CURRENT_USER(); +SELECT @@proxy_user; +--echo connection default; +connection default; +--echo disconnect proxy_con; +disconnect proxy_con; +DROP USER ''@'',proxied_user; +# +CREATE USER ''@'' IDENTIFIED WITH test_plugin_server AS 'proxied_user'; +CREATE USER proxied_user_1 IDENTIFIED BY 'proxied_user_1_pwd'; +CREATE USER proxied_user_2 IDENTIFIED BY 'proxied_user_2_pwd'; +CREATE USER proxied_user_3 IDENTIFIED BY 'proxied_user_3_pwd'; +CREATE USER proxied_user_4 IDENTIFIED BY 'proxied_user_4_pwd'; +CREATE USER proxied_user_5 IDENTIFIED BY 'proxied_user_5_pwd'; +GRANT PROXY ON proxied_user_1 TO ''@''; +GRANT PROXY ON proxied_user_2 TO ''@''; +GRANT PROXY ON proxied_user_3 TO ''@''; +GRANT PROXY ON proxied_user_4 TO ''@''; +GRANT PROXY ON proxied_user_5 TO ''@''; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +--echo connect(proxy_con_1,localhost,proxied_user_1,'proxied_user_1_pwd'); +connect(proxy_con_1,localhost,proxied_user_1,'proxied_user_1_pwd'); +--echo connect(proxy_con_2,localhost,proxied_user_2,proxied_user_2_pwd); +connect(proxy_con_2,localhost,proxied_user_2,proxied_user_2_pwd); +--echo connect(proxy_con_3,localhost,proxied_user_3,proxied_user_3_pwd); +connect(proxy_con_3,localhost,proxied_user_3,proxied_user_3_pwd); +--echo connect(proxy_con_4,localhost,proxied_user_4,proxied_user_4_pwd); +connect(proxy_con_4,localhost,proxied_user_4,proxied_user_4_pwd); +--echo connect(proxy_con_5,localhost,proxied_user_5,proxied_user_5_pwd); +connect(proxy_con_5,localhost,proxied_user_5,proxied_user_5_pwd); +--echo connection proxy_con_1; +connection proxy_con_1; +SELECT USER(),CURRENT_USER(); +SELECT @@proxy_user; +--echo connection proxy_con_2; +connection proxy_con_2; +SELECT USER(),CURRENT_USER(); +SELECT @@proxy_user; +--echo connection proxy_con_3; +connection proxy_con_3; +SELECT USER(),CURRENT_USER(); +SELECT @@proxy_user; +--echo connection proxy_con_4; +connection proxy_con_4; +SELECT USER(),CURRENT_USER(); +SELECT @@proxy_user; +--echo connection proxy_con_5; +connection proxy_con_5; +SELECT USER(),CURRENT_USER(); +SELECT @@proxy_user; +--echo connection default; +connection default; +--echo disconnect proxy_con_1; +disconnect proxy_con_1; +--echo disconnect proxy_con_2; +disconnect proxy_con_2; +--echo disconnect proxy_con_3; +disconnect proxy_con_3; +--echo disconnect proxy_con_4; +disconnect proxy_con_4; +--echo disconnect proxy_con_5; +disconnect proxy_con_5; +DROP USER ''@'',proxied_user_1,proxied_user_2,proxied_user_3,proxied_user_4,proxied_user_5; + +--echo ========== test 3 ========================================== + +GRANT ALL PRIVILEGES ON *.* TO plug_user + IDENTIFIED WITH test_plugin_server AS 'plug_dest'; +CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; +GRANT PROXY ON plug_dest TO plug_user; +FLUSH PRIVILEGES; + +# Not working with the patch. + +#--replace_result $MYSQLADMIN MYSQLADMIN $MASTER_MYPORT MYPORT $MASTER_MYSOCK MYSOCK +#--exec $MYSQLADMIN $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -S $MASTER_MYSOCK -u plug_user --password=plug_dest ping 2>&1 +#--replace_result $MYSQL_CHECK MYSQL_CHECK $MASTER_MYPORT MYPORT +#--exec $MYSQL_CHECK $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u plug_user --password=plug_dest test +#--replace_result $MYSQL_DUMP MYSQL_DUMP $MASTER_MYPORT MYPORT +#--exec $MYSQL_DUMP -h localhost -P $MASTER_MYPORT $PLUGIN_AUTH_OPT -u plug_user --password=plug_dest test +#--replace_result $MYSQL_SHOW MYSQL_SHOW $MASTER_MYPORT MYPORT +#--exec $MYSQL_SHOW $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --plugin_dir=../plugin/auth -u plug_user --password=plug_dest 2>&1 +DROP USER plug_user, plug_dest; +DROP DATABASE test_user_db; +--exit diff --git a/mysql-test/t/plugin_auth_qa_2-master.opt b/mysql-test/t/plugin_auth_qa_2-master.opt new file mode 100644 index 00000000000..c29153ac95b --- /dev/null +++ b/mysql-test/t/plugin_auth_qa_2-master.opt @@ -0,0 +1,2 @@ +$PLUGIN_AUTH_OPT +$PLUGIN_AUTH_INTERFACE diff --git a/mysql-test/t/plugin_auth_qa_2.test b/mysql-test/t/plugin_auth_qa_2.test new file mode 100644 index 00000000000..053e89166b7 --- /dev/null +++ b/mysql-test/t/plugin_auth_qa_2.test @@ -0,0 +1,148 @@ +# Horst Hunger +# Created: 2010-10-06 +# +# Test of the authentification interface. The plugin checks the expected values set +# by this application and the application checks the values set the the plugin. +--source include/have_plugin_interface.inc +--source include/not_embedded.inc + +CREATE DATABASE test_user_db; + +--echo ========== test 1.1.3.2 ==================================== +--echo === check contens of components of info ==================== + +CREATE USER qa_test_1_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_1_dest'; +CREATE USER qa_test_1_dest IDENTIFIED BY 'dest_passwd'; +GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_1_dest identified by 'dest_passwd'; +GRANT PROXY ON qa_test_1_dest TO qa_test_1_user; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +SELECT @@proxy_user; +SELECT @@external_user; + +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_1_user --password=qa_test_1_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_1_user --password=qa_test_1_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 + +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; + +DROP USER qa_test_1_user; +DROP USER qa_test_1_dest; + +--echo === Assign values to components of info ==================== + +CREATE USER qa_test_2_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_2_dest'; +CREATE USER qa_test_2_dest IDENTIFIED BY 'dest_passwd'; +CREATE USER authenticated_as IDENTIFIED BY 'dest_passwd'; +GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_2_dest identified by 'dest_passwd'; +GRANT PROXY ON qa_test_2_dest TO qa_test_2_user; +GRANT PROXY ON authenticated_as TO qa_test_2_user; +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; +SELECT @@proxy_user; +SELECT @@external_user; + +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_2_user --password=qa_test_2_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_2_user --password=qa_test_2_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 + +--sorted_result +SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; + +DROP USER qa_test_2_user; +DROP USER qa_test_2_dest; +DROP USER authenticated_as; + +--echo === Assign too high values for *length, which should have no effect ==== + +CREATE USER qa_test_3_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_3_dest'; +CREATE USER qa_test_3_dest IDENTIFIED BY 'dest_passwd'; +GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_3_dest identified by 'dest_passwd'; +GRANT PROXY ON qa_test_3_dest TO qa_test_3_user; + +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_3_user --password=qa_test_3_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_3_user --password=qa_test_3_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 + +DROP USER qa_test_3_user; +DROP USER qa_test_3_dest; + +--echo === Assign too low values for *length, which should have no effect ==== + +CREATE USER qa_test_4_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_4_dest'; +CREATE USER qa_test_4_dest IDENTIFIED BY 'dest_passwd'; +GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_4_dest identified by 'dest_passwd'; +GRANT PROXY ON qa_test_4_dest TO qa_test_4_user; + +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_4_user --password=qa_test_4_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_4_user --password=qa_test_4_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 + +DROP USER qa_test_4_user; +DROP USER qa_test_4_dest; + +--echo === Assign empty string especially to authenticated_as (in plugin) ==== + +CREATE USER qa_test_5_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_5_dest'; +CREATE USER qa_test_5_dest IDENTIFIED BY 'dest_passwd'; +CREATE USER ''@'localhost' IDENTIFIED BY 'dest_passwd'; +GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_5_dest identified by 'dest_passwd'; +GRANT ALL PRIVILEGES ON test_user_db.* TO ''@'localhost' identified by 'dest_passwd'; +GRANT PROXY ON qa_test_5_dest TO qa_test_5_user; +GRANT PROXY ON qa_test_5_dest TO ''@'localhost'; + +SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root'; + +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=qa_test_5_user --password=qa_test_5_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--error 1 +--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=qa_test_5_user --password=qa_test_5_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 + +DROP USER qa_test_5_user; +DROP USER qa_test_5_dest; +DROP USER ''@'localhost'; + +--echo === Assign 'root' especially to authenticated_as (in plugin) ==== + +CREATE USER qa_test_6_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_6_dest'; +CREATE USER qa_test_6_dest IDENTIFIED BY 'dest_passwd'; +GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_6_dest identified by 'dest_passwd'; +GRANT PROXY ON qa_test_6_dest TO qa_test_6_user; + +SELECT user,plugin,authentication_string,password FROM mysql.user; + +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=qa_test_6_user --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--error 1 +--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=qa_test_6_user --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 + +GRANT PROXY ON qa_test_6_dest TO root IDENTIFIED WITH qa_auth_interface AS 'qa_test_6_dest'; +SELECT user,plugin,authentication_string,password FROM mysql.user; + +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--error 1 +--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 + +REVOKE PROXY ON qa_test_6_dest FROM root; +SELECT user,plugin,authentication_string FROM mysql.user; + +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--error 1 +--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 + +DROP USER qa_test_6_user; +DROP USER qa_test_6_dest; +DELETE FROM mysql.user WHERE user='root' AND plugin='qa_auth_interface'; +SELECT user,plugin,authentication_string,password FROM mysql.user; + + +--echo === Test of the --default_auth option for clients ==== + +CREATE USER qa_test_11_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_11_dest'; +CREATE USER qa_test_11_dest IDENTIFIED BY 'dest_passwd'; +GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_11_dest identified by 'dest_passwd'; +GRANT PROXY ON qa_test_11_dest TO qa_test_11_user; + +--echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--error 1 +--exec $MYSQL $PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 + +DROP USER qa_test_11_user, qa_test_11_dest; +DROP DATABASE test_user_db; + +--exit diff --git a/mysql-test/t/plugin_auth_qa_3-master.opt b/mysql-test/t/plugin_auth_qa_3-master.opt new file mode 100644 index 00000000000..5cc2af0a358 --- /dev/null +++ b/mysql-test/t/plugin_auth_qa_3-master.opt @@ -0,0 +1,2 @@ +$PLUGIN_AUTH_OPT +$PLUGIN_AUTH_SERVER diff --git a/mysql-test/t/plugin_auth_qa_3.test b/mysql-test/t/plugin_auth_qa_3.test new file mode 100644 index 00000000000..4fe02f10ba6 --- /dev/null +++ b/mysql-test/t/plugin_auth_qa_3.test @@ -0,0 +1,25 @@ +# Horst Hunger +# Created: 2010-10-06 +# +# Test of the authentification interface. The plugin checks the expected values set +# by this application and the application checks the values set the the plugin. +--source include/have_plugin_server.inc +--source include/not_embedded.inc + +CREATE DATABASE test_user_db; + +CREATE USER qa_test_11_user IDENTIFIED WITH qa_auth_server AS 'qa_test_11_dest'; +GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_11_dest identified by 'dest_passwd'; +GRANT PROXY ON qa_test_11_dest TO qa_test_11_user; + +--echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--exec $MYSQL $PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 + +--echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_2_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--error 1 +--exec $MYSQL $PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_2_user --password=qa_test_2_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 + +DROP USER qa_test_11_user, qa_test_11_dest; +DROP DATABASE test_user_db; + +--exit -- cgit v1.2.1 From d63cbdde8e55399c1a5e677aab1cc22a35519a42 Mon Sep 17 00:00:00 2001 From: "Horst.Hunger" Date: Fri, 22 Oct 2010 10:20:17 +0200 Subject: Due to issues with merge. --- mysql-test/t/plugin_auth_qa_1.test | 18 ++++++++++++------ mysql-test/t/plugin_auth_qa_2.test | 18 +++++++++--------- mysql-test/t/plugin_auth_qa_3.test | 4 ++-- 3 files changed, 23 insertions(+), 17 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/plugin_auth_qa_1.test b/mysql-test/t/plugin_auth_qa_1.test index d7a7afe9407..c33c4c22893 100644 --- a/mysql-test/t/plugin_auth_qa_1.test +++ b/mysql-test/t/plugin_auth_qa_1.test @@ -14,7 +14,8 @@ SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; CREATE USER plug_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; GRANT PROXY ON plug_dest TO plug_user; ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 REVOKE PROXY ON plug_dest FROM plug_user; --error 1 --exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 @@ -29,11 +30,13 @@ GRANT PROXY ON plug_dest TO plug_user; --sorted_result SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; --echo 1) ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 REVOKE ALL PRIVILEGES ON test_user_db.* FROM 'plug_user' IDENTIFIED WITH test_plugin_server AS 'plug_dest'; --echo 2) ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 REVOKE PROXY ON plug_dest FROM plug_user; --echo 3) --error 1 @@ -49,7 +52,8 @@ CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; --exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 GRANT PROXY ON plug_dest TO plug_user; --echo 2) ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 REVOKE ALL PRIVILEGES ON test_user_db.* FROM 'plug_user' IDENTIFIED WITH test_plugin_server AS 'plug_dest'; #REVOKE ALL PRIVILEGES ON test_user_db.* FROM 'plug_dest' @@ -63,7 +67,8 @@ GRANT ALL PRIVILEGES ON test_user_db.* TO plug_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; GRANT PROXY ON plug_dest TO plug_user; ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 +--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 RENAME USER plug_dest TO new_dest; --error 1 --exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 @@ -81,7 +86,8 @@ CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; --error 1 --exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 GRANT PROXY ON plug_dest TO plug_user; ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 +--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 RENAME USER plug_dest TO new_dest; --error 1 --exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 diff --git a/mysql-test/t/plugin_auth_qa_2.test b/mysql-test/t/plugin_auth_qa_2.test index 053e89166b7..135b187f6ee 100644 --- a/mysql-test/t/plugin_auth_qa_2.test +++ b/mysql-test/t/plugin_auth_qa_2.test @@ -20,7 +20,7 @@ SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; SELECT @@proxy_user; SELECT @@external_user; ---echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_1_user --password=qa_test_1_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_1_user --password=qa_test_1_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_1_user --password=qa_test_1_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --sorted_result @@ -42,7 +42,7 @@ SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; SELECT @@proxy_user; SELECT @@external_user; ---echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_2_user --password=qa_test_2_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_2_user --password=qa_test_2_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_2_user --password=qa_test_2_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --sorted_result @@ -59,7 +59,7 @@ CREATE USER qa_test_3_dest IDENTIFIED BY 'dest_passwd'; GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_3_dest identified by 'dest_passwd'; GRANT PROXY ON qa_test_3_dest TO qa_test_3_user; ---echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_3_user --password=qa_test_3_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_3_user --password=qa_test_3_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_3_user --password=qa_test_3_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 DROP USER qa_test_3_user; @@ -72,7 +72,7 @@ CREATE USER qa_test_4_dest IDENTIFIED BY 'dest_passwd'; GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_4_dest identified by 'dest_passwd'; GRANT PROXY ON qa_test_4_dest TO qa_test_4_user; ---echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_4_user --password=qa_test_4_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_4_user --password=qa_test_4_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_4_user --password=qa_test_4_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 DROP USER qa_test_4_user; @@ -90,7 +90,7 @@ GRANT PROXY ON qa_test_5_dest TO ''@'localhost'; SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root'; ---echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=qa_test_5_user --password=qa_test_5_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=qa_test_5_user --password=qa_test_5_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --error 1 --exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=qa_test_5_user --password=qa_test_5_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 @@ -107,21 +107,21 @@ GRANT PROXY ON qa_test_6_dest TO qa_test_6_user; SELECT user,plugin,authentication_string,password FROM mysql.user; ---echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=qa_test_6_user --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=qa_test_6_user --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --error 1 --exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=qa_test_6_user --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 GRANT PROXY ON qa_test_6_dest TO root IDENTIFIED WITH qa_auth_interface AS 'qa_test_6_dest'; SELECT user,plugin,authentication_string,password FROM mysql.user; ---echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --error 1 --exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 REVOKE PROXY ON qa_test_6_dest FROM root; SELECT user,plugin,authentication_string FROM mysql.user; ---echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --error 1 --exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 @@ -138,7 +138,7 @@ CREATE USER qa_test_11_dest IDENTIFIED BY 'dest_passwd'; GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_11_dest identified by 'dest_passwd'; GRANT PROXY ON qa_test_11_dest TO qa_test_11_user; ---echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --error 1 --exec $MYSQL $PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 diff --git a/mysql-test/t/plugin_auth_qa_3.test b/mysql-test/t/plugin_auth_qa_3.test index 4fe02f10ba6..f7d90226332 100644 --- a/mysql-test/t/plugin_auth_qa_3.test +++ b/mysql-test/t/plugin_auth_qa_3.test @@ -12,10 +12,10 @@ CREATE USER qa_test_11_user IDENTIFIED WITH qa_auth_server AS 'qa_test_11_dest'; GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_11_dest identified by 'dest_passwd'; GRANT PROXY ON qa_test_11_dest TO qa_test_11_user; ---echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --exec $MYSQL $PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 ---echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_2_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 +--echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P MASTER_MYPORT -u qa_test_2_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 --error 1 --exec $MYSQL $PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_2_user --password=qa_test_2_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 -- cgit v1.2.1 From 2881b8014ca7101684358b25aaf54784c7f43613 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 22 Oct 2010 09:58:09 -0200 Subject: Bug#37780: Make KILL reliable (main.kill fails randomly) - A prerequisite cleanup patch for making KILL reliable. The test case main.kill did not work reliably. The following problems have been identified: 1. A kill signal could go lost if it came in, short before a thread went reading on the client connection. 2. A kill signal could go lost if it came in, short before a thread went waiting on a condition variable. These problems have been solved as follows. Please see also added code comments for more details. 1. There is no safe way to detect, when a thread enters the blocking state of a read(2) or recv(2) system call, where it can be interrupted by a signal. Hence it is not possible to wait for the right moment to send a kill signal. It has been decided, not to fix it in the code. Instead, the test case repeats the KILL statement until the connection terminates. 2. Before waiting on a condition variable, we register it together with a synchronizating mutex in THD::mysys_var. After this, we need to test THD::killed again. At some places we did only test it in a loop condition before the registration. When THD::killed had been set between this test and the registration, we entered waiting without noticing the killed flag. Additional checks ahve been introduced where required. In addition to the above, a re-write of the main.kill test case has been done. All sleeps have been replaced by Debug Sync Facility synchronization. A couple of sync points have been added to the server code. To avoid further problems, if the test case fails in spite of the fixes, the test case has been added to the "experimental" list for now. - Most of the work on this patch is authored by Ingo Struewing mysql-test/t/kill.test: Re-wrote test case to use Debug Sync points instead of sleeps sql/event_queue.cc: Fixed kill detection in Event_queue::cond_wait() by adding a check after enter_cond(). sql/lock.cc: Moved Debug Sync points behind enter_cond(). Fixed comments. sql/slave.cc: Fixed kill detection in start_slave_thread() by adding a check after enter_cond(). sql/sql_class.cc: Swapped order of kill and close in THD::awake(). Added comments. sql/sql_class.h: Added a comment to THD::killed. sql/sql_parse.cc: Added a sync point in do_command(). sql/sql_select.cc: Added a sync point in JOIN::optimize(). --- mysql-test/t/disabled.def | 1 - mysql-test/t/kill.test | 456 ++++++++++++++++++++++++---------------------- 2 files changed, 242 insertions(+), 215 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 5bd53ec568e..b14342fbb3b 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -9,7 +9,6 @@ # Do not use any TAB characters for whitespace. # ############################################################################## -kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild. lowercase_table3 : Bug#54845 2010-06-30 alik main.lowercase_table3 on Mac OSX mysqlhotcopy_myisam : Bug#54129 2010-08-31 alik mysqlhotcopy* fails mysqlhotcopy_archive : Bug#54129 2010-08-31 alik mysqlhotcopy* fails diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index 706c2514d92..701d4083f86 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -1,307 +1,326 @@ -# This test doesn't work with the embedded version as this code -# assumes that one query is running while we are doing queries on -# a second connection. -# This would work if mysqltest run would be threaded and handle each -# connection in a separate thread. # +# Test KILL and KILL QUERY statements. +# +# Killing a connection in an embedded server does not work like in a normal +# server, if it is waiting for a new statement. In an embedded server, the +# connection does not read() from a socket, but returns control to the +# application. 'mysqltest' does not handle the kill request. +# + -- source include/not_embedded.inc +-- source include/have_debug_sync.inc -# Disable concurrent inserts to avoid test failures when reading the -# connection id which was inserted into a table by another thread. -set @old_concurrent_insert= @@global.concurrent_insert; -set @@global.concurrent_insert= 0; +--disable_warnings +SET DEBUG_SYNC = 'RESET'; +DROP TABLE IF EXISTS t1, t2, t3; +DROP FUNCTION IF EXISTS MY_KILL; +--enable_warnings + +delimiter |; +# Helper function used to repeatedly kill a session. +CREATE FUNCTION MY_KILL(tid INT) RETURNS INT +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + KILL tid; + RETURN (SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE ID = tid); +END| +delimiter ;| connect (con1, localhost, root,,); connect (con2, localhost, root,,); -#remember id of con1 +# Save id of con1 connection con1; ---disable_warnings -drop table if exists t1, t2, t3; ---enable_warnings - --disable_reconnect -create table t1 (kill_id int); -insert into t1 values(connection_id()); +let $ID= `SELECT @id := CONNECTION_ID()`; +connection con2; +let $ignore= `SELECT @id := $ID`; +connection con1; +# Signal when this connection is terminating. +SET DEBUG_SYNC= 'thread_end SIGNAL con1_end'; +# See if we can kill read(). +# Run into read() immediately after hitting 'before_do_command_net_read'. +SET DEBUG_SYNC= 'before_do_command_net_read SIGNAL con1_read'; -#kill con1 +# Kill con1 connection con2; -select ((@id := kill_id) - kill_id) from t1; -kill @id; +SET DEBUG_SYNC='now WAIT_FOR con1_read'; +# At this point we have no way to figure out, when con1 is blocked in +# reading from the socket. Sending KILL to early would not terminate +# con1. So we repeat KILL until con1 terminates. +let $wait_condition= SELECT MY_KILL(@id); +--source include/wait_condition.inc +# If KILL missed the read(), sync point wait will time out. +SET DEBUG_SYNC= 'now WAIT_FOR con1_end'; +SET DEBUG_SYNC = 'RESET'; connection con1; ---sleep 2 - ---disable_query_log ---disable_result_log -# One of the following statements should fail ---error 0,2006,2013 -select 1; ---error 0,2006,2013 -select 1; ---enable_query_log ---enable_result_log +--error 1053,2006,2013 +SELECT 1; --enable_reconnect # this should work, and we should have a new connection_id() -select ((@id := kill_id) - kill_id) from t1; -select @id != connection_id(); +SELECT 1; +let $ignore= `SELECT @id := $ID`; +SELECT @id != CONNECTION_ID(); #make sure the server is still alive connection con2; -select 4; -drop table t1; +SELECT 4; connection default; --error ER_NOT_SUPPORTED_YET -kill (select count(*) from mysql.user); +KILL (SELECT COUNT(*) FROM mysql.user); + +connection con1; +let $ID= `SELECT @id := CONNECTION_ID()`; +connection con2; +let $ignore= `SELECT @id := $ID`; +connection con1; +disable_reconnect; +# Signal when this connection is terminating. +SET DEBUG_SYNC= 'thread_end SIGNAL con1_end'; +# See if we can kill the sync point itself. +# Wait in 'before_do_command_net_read' until killed. +# It doesn't wait for a signal 'kill' but for to be killed. +# The signal name doesn't matter here. +SET DEBUG_SYNC= 'before_do_command_net_read SIGNAL con1_read WAIT_FOR kill'; +connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR con1_read'; +# Repeat KILL until con1 terminates. +let $wait_condition= SELECT MY_KILL(@id); +--source include/wait_condition.inc +SET DEBUG_SYNC= 'now WAIT_FOR con1_end'; +SET DEBUG_SYNC = 'RESET'; + +connection con1; +--error 1053,2006,2013 +SELECT 1; +enable_reconnect; +SELECT 1; +let $ignore= `SELECT @id := $ID`; +SELECT @id != CONNECTION_ID(); +connection con2; +SELECT 4; +connection default; # # BUG#14851: killing long running subquery processed via a temporary table. # -create table t1 (id int primary key); -create table t2 (id int unsigned not null); -connect (conn1, localhost, root,,); -connection conn1; +CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT); +CREATE TABLE t2 (id INT UNSIGNED NOT NULL); --- disable_result_log --- disable_query_log -let $1 = 4096; -while ($1) -{ - eval insert into t1 values ($1); - dec $1; -} --- enable_query_log --- enable_result_log +INSERT INTO t1 VALUES +(0),(0),(0),(0),(0),(0),(0),(0), (0),(0),(0),(0),(0),(0),(0),(0), +(0),(0),(0),(0),(0),(0),(0),(0), (0),(0),(0),(0),(0),(0),(0),(0), +(0),(0),(0),(0),(0),(0),(0),(0), (0),(0),(0),(0),(0),(0),(0),(0), +(0),(0),(0),(0),(0),(0),(0),(0), (0),(0),(0),(0),(0),(0),(0),(0); +INSERT t1 SELECT 0 FROM t1 AS a1, t1 AS a2 LIMIT 4032; -insert into t2 select id from t1; +INSERT INTO t2 SELECT id FROM t1; -create table t3 (kill_id int); -insert into t3 values(connection_id()); - -connect (conn2, localhost, root,,); -connection conn2; +connection con1; +let $ID= `SELECT @id := CONNECTION_ID()`; +connection con2; +let $ignore= `SELECT @id := $ID`; -connection conn1; --- disable_result_log -# This is a very long running query. If this test start failing, it may -# be necessary to change to an even longer query. -send select id from t1 where id in (select distinct a.id from t2 a, t2 b, t2 c, t2 d group by a.id, b.id, c.id, d.id having a.id between 10 and 20); --- enable_result_log +connection con1; +SET DEBUG_SYNC= 'thread_end SIGNAL con1_end'; +SET DEBUG_SYNC= 'before_acos_function SIGNAL in_sync'; +# This is a very long running query. If this test start failing, +# it may be necessary to change to an even longer query. +send SELECT id FROM t1 WHERE id IN + (SELECT DISTINCT a.id FROM t2 a, t2 b, t2 c, t2 d + GROUP BY ACOS(1/a.id), b.id, c.id, d.id + HAVING a.id BETWEEN 10 AND 20); -connection conn2; -select ((@id := kill_id) - kill_id) from t3; --- sleep 1 -kill @id; +connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +KILL @id; +SET DEBUG_SYNC= 'now WAIT_FOR con1_end'; -connection conn1; --- error 1317,2013 +connection con1; +--error 1053,2006,2013 reap; +SELECT 1; connection default; - -drop table t1, t2, t3; - -# End of 4.1 tests +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1, t2; # -# test of blocking of sending ERROR after OK or EOF +# Test of blocking of sending ERROR after OK or EOF # connection con1; -select get_lock("a", 10); +let $ID= `SELECT @id := CONNECTION_ID()`; connection con2; -let $ID= `select connection_id()`; -send select get_lock("a", 10); -real_sleep 2; +let $ignore= `SELECT @id := $ID`; connection con1; -disable_query_log; -eval kill query $ID; -enable_query_log; +SET DEBUG_SYNC= 'before_acos_function SIGNAL in_sync WAIT_FOR kill'; +send SELECT ACOS(0); connection con2; -reap; -select 1; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +KILL QUERY @id; connection con1; -select RELEASE_LOCK("a"); +reap; +SELECT 1; +SELECT @id = CONNECTION_ID(); +connection default; +SET DEBUG_SYNC = 'RESET'; # # Bug#27563: Stored functions and triggers wasn't throwing an error when killed. # -create table t1(f1 int); +CREATE TABLE t1 (f1 INT); delimiter |; -create function bug27563() returns int(11) -deterministic -begin - declare continue handler for sqlstate '70100' set @a:= 'killed'; - declare continue handler for sqlexception set @a:= 'exception'; - set @a= get_lock("lock27563", 10); - return 1; -end| +CREATE FUNCTION bug27563() RETURNS INT(11) +DETERMINISTIC +BEGIN + DECLARE CONTINUE HANDLER FOR SQLSTATE '70100' SET @a:= 'killed'; + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @a:= 'exception'; + SET DEBUG_SYNC= 'now SIGNAL in_sync WAIT_FOR kill'; + RETURN 1; +END| delimiter ;| # Test stored functions # Test INSERT connection con1; -select get_lock("lock27563",10); +let $ID= `SELECT @id := CONNECTION_ID()`; connection con2; -let $ID= `select connection_id()`; -send insert into t1 values (bug27563()); -real_sleep 2; +let $ignore= `SELECT @id := $ID`; connection con1; -disable_query_log; -eval kill query $ID; -enable_query_log; +send INSERT INTO t1 VALUES (bug27563()); connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +KILL QUERY @id; +connection con1; --error 1317 reap; -select @a; -connection con1; -select * from t1; +SELECT * FROM t1; +connection default; +SET DEBUG_SYNC = 'RESET'; # Test UPDATE -insert into t1 values(0); -connection con2; -send update t1 set f1= bug27563(); -real_sleep 2; +INSERT INTO t1 VALUES(0); connection con1; -disable_query_log; -eval kill query $ID; -enable_query_log; +send UPDATE t1 SET f1= bug27563(); connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +KILL QUERY @id; +connection con1; --error 1317 reap; -select @a; -connection con1; -select * from t1; +SELECT * FROM t1; +connection default; +SET DEBUG_SYNC = 'RESET'; # Test DELETE -insert into t1 values(1); -connection con2; -send delete from t1 where bug27563() is null; -real_sleep 2; +INSERT INTO t1 VALUES(1); connection con1; -disable_query_log; -eval kill query $ID; -enable_query_log; +send DELETE FROM t1 WHERE bug27563() IS NULL; connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +KILL QUERY @id; +connection con1; --error 1317 reap; -select @a; -connection con1; -select * from t1; +SELECT * FROM t1; +connection default; +SET DEBUG_SYNC = 'RESET'; # Test SELECT -connection con2; -send select * from t1 where f1= bug27563(); -real_sleep 2; connection con1; -disable_query_log; -eval kill query $ID; -enable_query_log; +send SELECT * FROM t1 WHERE f1= bug27563(); connection con2; ---error 1317 -reap; -select @a; - -# Test PROCEDURE -connection con2; -delimiter |; -create procedure proc27563() -begin - declare continue handler for sqlstate '70100' set @a:= 'killed'; - declare continue handler for sqlexception set @a:= 'exception'; - select get_lock("lock27563",10); - select "shouldn't be selected"; -end| -delimiter ;| -send call proc27563(); -real_sleep 2; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +KILL QUERY @id; connection con1; -disable_query_log; -eval kill query $ID; -enable_query_log; -connection con2; --error 1317 reap; -select @a; +SELECT * FROM t1; +connection default; +SET DEBUG_SYNC = 'RESET'; +DROP FUNCTION bug27563; # Test TRIGGERS -connection con2; -create table t2 (f2 int); +CREATE TABLE t2 (f2 INT); delimiter |; -create trigger trg27563 before insert on t1 for each row -begin - declare continue handler for sqlstate '70100' set @a:= 'killed'; - declare continue handler for sqlexception set @a:= 'exception'; - set @a:= get_lock("lock27563",10); - insert into t2 values(1); -end| +CREATE TRIGGER trg27563 BEFORE INSERT ON t1 FOR EACH ROW +BEGIN + DECLARE CONTINUE HANDLER FOR SQLSTATE '70100' SET @a:= 'killed'; + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @a:= 'exception'; + INSERT INTO t2 VALUES(0); + SET DEBUG_SYNC= 'now SIGNAL in_sync WAIT_FOR kill'; + INSERT INTO t2 VALUES(1); +END| delimiter ;| -send insert into t1 values(2),(3); -real_sleep 2; connection con1; -disable_query_log; -eval kill query $ID; -enable_query_log; +send INSERT INTO t1 VALUES(2),(3); connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +KILL QUERY @id; +connection con1; --error 1317 reap; -select @a; -connection con1; -select * from t1; -select * from t2; - -# Cleanup -select release_lock("lock27563"); -drop table t1, t2; -drop function bug27563; -drop procedure proc27563; +SELECT * FROM t1; +SELECT * FROM t2; +connection default; +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1, t2; # # Bug#28598: mysqld crash when killing a long-running explain query. # ---disable_query_log connection con1; -let $ID= `select connection_id()`; +let $ID= `SELECT @id := CONNECTION_ID()`; +connection con2; +let $ignore= `SELECT @id := $ID`; +connection con1; +--disable_query_log let $tab_count= 40; let $i= $tab_count; while ($i) { - eval CREATE TABLE t$i (a$i int, KEY(a$i)); + eval CREATE TABLE t$i (a$i INT, KEY(a$i)); eval INSERT INTO t$i VALUES (1),(2),(3),(4),(5),(6),(7); dec $i ; } -set session optimizer_search_depth=0; +SET SESSION optimizer_search_depth=0; let $i=$tab_count; while ($i) { - let $a= a$i; - let $t= t$i; - dec $i; - if ($i) - { - let $comma=,; - let $from=$comma$t$from; - let $where=a$i=$a $and $where; - } - if (!$i) - { - let $from=FROM $t$from; - let $where=WHERE $where; - } - let $and=AND; + let $a= a$i; + let $t= t$i; + dec $i; + if ($i) + { + let $comma=,; + let $from=$comma$t$from; + let $where=a$i=$a $and $where; + } + if (!$i) + { + let $from=FROM $t$from; + let $where=WHERE $where; + } + let $and=AND; } --enable_query_log +SET DEBUG_SYNC= 'before_join_optimize SIGNAL in_sync'; eval PREPARE stmt FROM 'EXPLAIN SELECT * $from $where'; send EXECUTE stmt; ---disable_query_log connection con2; -real_sleep 2; -eval kill query $ID; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +KILL QUERY @id; +connection con1; +--error 1317 +reap; +--disable_query_log let $i= $tab_count; while ($i) { @@ -309,8 +328,8 @@ while ($i) dec $i ; } --enable_query_log - -########################################################################### +connection default; +SET DEBUG_SYNC = 'RESET'; --echo # --echo # Bug#19723: kill of active connection yields different error code @@ -318,16 +337,27 @@ while ($i) --echo # --echo ---echo # Connection: con2. ---connection con2 - -KILL CONNECTION_ID(); +--echo # Connection: con1. +--connection con1 +let $ID= `SELECT @id := CONNECTION_ID()`; +SET DEBUG_SYNC= 'thread_end SIGNAL con1_end'; +--disable_reconnect +--error ER_QUERY_INTERRUPTED +KILL @id; ---echo # CR_SERVER_LOST, CR_SERVER_GONE_ERROR, depending on the timing ---echo # of close of the connection socket ---error 2013, 2006 +connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR con1_end'; +connection con1; +--echo # ER_SERVER_SHUTDOWN, CR_SERVER_GONE_ERROR, CR_SERVER_LOST, +--echo # depending on the timing of close of the connection socket +--error 1053,2006,2013 +SELECT 1; +--enable_reconnect SELECT 1; ---connection default +let $ignore= `SELECT @id := $ID`; +SELECT @id != CONNECTION_ID(); +connection default; +SET DEBUG_SYNC = 'RESET'; --echo # --echo # Additional test for WL#3726 "DDL locking for all metadata objects" @@ -489,28 +519,26 @@ connection ddl; --echo # Switching to connection 'blocker' connection blocker; unlock tables; -drop table t2; -create table t2 (k int); lock tables t1 read; --echo # Switching to connection 'ddl' connection ddl; # Let us add pending exclusive metadata lock on t2 ---send rename tables t1 to t3, t2 to t1 +--send truncate table t1 --echo # Switching to connection 'dml' connection dml; let $wait_condition= select count(*) = 1 from information_schema.processlist where state = "Waiting for table metadata lock" and - info = "rename tables t1 to t3, t2 to t1"; + info = "truncate table t1"; --source include/wait_condition.inc let $ID2= `select connection_id()`; ---send insert into t2 values (1) +--send insert into t1 values (1) --echo # Switching to 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 t2 values (1)"; + info = "insert into t1 values (1)"; --source include/wait_condition.inc --replace_result $ID2 ID2 eval kill query $ID2; @@ -564,10 +592,10 @@ connection ddl; --echo # Cleanup. --echo # Switching to connection 'default' connection default; -drop table t3; drop table t1; +drop table t2; ########################################################################### -# Restore global concurrent_insert value. Keep in the end of the test file. -set @@global.concurrent_insert= @old_concurrent_insert; +SET DEBUG_SYNC = 'RESET'; +DROP FUNCTION MY_KILL; -- cgit v1.2.1 From 06a263e2b32bd6b5440933b4cec3eff37053cef7 Mon Sep 17 00:00:00 2001 From: "Horst.Hunger" Date: Mon, 25 Oct 2010 12:24:26 +0200 Subject: Due to failing on Freebsd. --- mysql-test/t/plugin_auth_qa_1.test | 16 ++++++++-------- mysql-test/t/plugin_auth_qa_2.test | 5 +++++ 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/plugin_auth_qa_1.test b/mysql-test/t/plugin_auth_qa_1.test index c33c4c22893..06908935b01 100644 --- a/mysql-test/t/plugin_auth_qa_1.test +++ b/mysql-test/t/plugin_auth_qa_1.test @@ -18,7 +18,7 @@ GRANT PROXY ON plug_dest TO plug_user; --exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 REVOKE PROXY ON plug_dest FROM plug_user; --error 1 ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 DROP USER plug_user,plug_dest; # # GRANT...WITH @@ -40,7 +40,7 @@ REVOKE ALL PRIVILEGES ON test_user_db.* FROM 'plug_user' REVOKE PROXY ON plug_dest FROM plug_user; --echo 3) --error 1 ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 DROP USER plug_user,plug_dest; # # GRANT...WITH/CREATE...BY @@ -49,7 +49,7 @@ GRANT ALL PRIVILEGES ON test_user_db.* TO plug_user CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; --echo 1) --error 1 ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1 GRANT PROXY ON plug_dest TO plug_user; --echo 2) --replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT @@ -71,10 +71,10 @@ GRANT PROXY ON plug_dest TO plug_user; --exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 RENAME USER plug_dest TO new_dest; --error 1 ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 GRANT PROXY ON new_dest TO plug_user; --error 1 ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=new_dest -e "SELECT current_user();SELECT user();" 2>&1 +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=new_dest -e "SELECT current_user();SELECT user();" 2>&1 --sorted_result SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; DROP USER plug_user,new_dest; @@ -84,16 +84,16 @@ CREATE USER plug_user IDENTIFIED WITH test_plugin_server AS 'plug_dest'; CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'; --error 1 ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 GRANT PROXY ON plug_dest TO plug_user; --replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT --exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 RENAME USER plug_dest TO new_dest; --error 1 ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1 GRANT PROXY ON new_dest TO plug_user; --error 1 ---exec $MYSQL -S var/tmp/mysqld.1.sock -u plug_user $PLUGIN_AUTH_OPT --password=new_dest -e "SELECT current_user();SELECT user();" 2>&1 +--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=new_dest -e "SELECT current_user();SELECT user();" 2>&1 --sorted_result SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root'; DROP USER plug_user,new_dest; diff --git a/mysql-test/t/plugin_auth_qa_2.test b/mysql-test/t/plugin_auth_qa_2.test index 135b187f6ee..e265690dc7d 100644 --- a/mysql-test/t/plugin_auth_qa_2.test +++ b/mysql-test/t/plugin_auth_qa_2.test @@ -88,6 +88,7 @@ GRANT ALL PRIVILEGES ON test_user_db.* TO ''@'localhost' identified by 'dest_pas GRANT PROXY ON qa_test_5_dest TO qa_test_5_user; GRANT PROXY ON qa_test_5_dest TO ''@'localhost'; +--sorted_result SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root'; --echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=qa_test_5_user --password=qa_test_5_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 @@ -105,6 +106,7 @@ CREATE USER qa_test_6_dest IDENTIFIED BY 'dest_passwd'; GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_6_dest identified by 'dest_passwd'; GRANT PROXY ON qa_test_6_dest TO qa_test_6_user; +--sorted_result SELECT user,plugin,authentication_string,password FROM mysql.user; --echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=qa_test_6_user --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 @@ -112,6 +114,7 @@ SELECT user,plugin,authentication_string,password FROM mysql.user; --exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=qa_test_6_user --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 GRANT PROXY ON qa_test_6_dest TO root IDENTIFIED WITH qa_auth_interface AS 'qa_test_6_dest'; +--sorted_result SELECT user,plugin,authentication_string,password FROM mysql.user; --echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 @@ -119,6 +122,7 @@ SELECT user,plugin,authentication_string,password FROM mysql.user; --exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 REVOKE PROXY ON qa_test_6_dest FROM root; +--sorted_result SELECT user,plugin,authentication_string FROM mysql.user; --echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1 @@ -128,6 +132,7 @@ SELECT user,plugin,authentication_string FROM mysql.user; DROP USER qa_test_6_user; DROP USER qa_test_6_dest; DELETE FROM mysql.user WHERE user='root' AND plugin='qa_auth_interface'; +--sorted_result SELECT user,plugin,authentication_string,password FROM mysql.user; -- cgit v1.2.1 From e86b6c0db40116cb0dc223999e45712e1b1908ef Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 26 Oct 2010 15:48:08 +0400 Subject: Patch for Bug#55850 (Trigger warnings not cleared). The problem was that the warnings risen by a trigger were not cleared upon successful completion. The warnings should be cleared if the trigger completes successfully. The fix is to skip merging warnings into caller's Warning Info for triggers. --- mysql-test/t/sp-error.test | 114 +++++++++++++++++++++++++++++++-------------- 1 file changed, 80 insertions(+), 34 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 13ca55a0127..6175fc53adf 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -2719,10 +2719,6 @@ DROP PROCEDURE p1; --echo # Bug#5889: Exit handler for a warning doesn't hide the warning in trigger --echo # ---echo ---echo # - Case 1 ---echo - CREATE TABLE t1(a INT, b INT); INSERT INTO t1 VALUES (1, 2); @@ -2747,36 +2743,6 @@ SELECT * FROM t1; DROP TRIGGER t1_bu; DROP TABLE t1; ---echo ---echo # - Case 2 ---echo - -CREATE TABLE t1(a INT); -CREATE TABLE t2(b CHAR(1)); - -delimiter |; - -CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW -BEGIN - INSERT INTO t2 VALUES('ab'); # Produces a warning. - - INSERT INTO t2 VALUES('b'); # Does not produce a warning, - # previous warning should be cleared. -END| - -delimiter ;| - -INSERT INTO t1 VALUES(0); - -SHOW WARNINGS; - -SELECT * FROM t1; -SELECT * FROM t2; - -DROP TRIGGER t1_bi; -DROP TABLE t1; -DROP TABLE t2; - --echo # --echo # Bug#9857: Stored procedures: handler for sqlwarning ignored --echo # @@ -2813,3 +2779,83 @@ SHOW WARNINGS; DROP PROCEDURE p1; DROP PROCEDURE p2; SET sql_mode = @sql_mode_saved; + +--echo # +--echo # Bug#55850: Trigger warnings not cleared. +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP PROCEDURE IF EXISTS p1; +--enable_warnings + +CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT); +CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT, + d SMALLINT, e SMALLINT, f SMALLINT); + +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW + INSERT INTO t2(a, b, c) VALUES(99999, 99999, 99999); + +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW + INSERT INTO t2(d, e, f) VALUES(99999, 99999, 99999); + +CREATE PROCEDURE p1() + INSERT INTO t1 VALUES(99999, 99999, 99999); + +# What happened before the patch was: +# - INSERT INTO t1 added 3 warnings about overflow in 'x', 'y' and 'z' columns; +# - t1_bi run and added 3 warnings about overflow in 'a', 'b' and 'c' columns; +# - t1_ai run and added 3 warnings about overflow in 'd', 'e' and 'f' columns; +# => we had 9 warnings. +# +# Now what happens is: +# - INSERT INTO t1 adds 3 warnings about overflow in 'x', 'y' and 'z' columns; +# - t1_bi adds 3 warnings about overflow in 'a', 'b' and 'c' columns; +# - The warnings added by triggers are cleared; +# - t1_ai run and added 3 warnings about overflow in 'd', 'e' and 'f' columns; +# - The warnings added by triggers are cleared; +# => we have 3 warnings. + +--echo +CALL p1(); + +--echo +SHOW WARNINGS; + +--echo +DROP TABLE t1; +DROP TABLE t2; +DROP PROCEDURE p1; + +--echo # ---------------------------------------------------------------------- + +CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT); +CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT NOT NULL); + +delimiter |; + +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW +BEGIN + INSERT INTO t2 VALUES( + CAST('111111 ' AS SIGNED), + CAST('222222 ' AS SIGNED), + NULL); +END| + +delimiter ;| + +CREATE PROCEDURE p1() + INSERT INTO t1 VALUES(99999, 99999, 99999); + +--echo +--error ER_BAD_NULL_ERROR +CALL p1(); + +--echo +SHOW WARNINGS; + +--echo +DROP TABLE t1; +DROP TABLE t2; +DROP PROCEDURE p1; -- cgit v1.2.1 From fcfda43ca3b60266429c6deb78489f82f9686e67 Mon Sep 17 00:00:00 2001 From: Anitha Gopi Date: Wed, 27 Oct 2010 09:54:04 +0530 Subject: Fixed bug numbers in disabled.def files --- mysql-test/t/disabled.def | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index cede26f555a..fb07cb2c7e4 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -12,5 +12,6 @@ kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild. query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically partition_innodb_plugin : Bug#53307 2010-04-30 VasilDimov valgrind warnings -main.mysqlhotcopy_myisam : bug#54129 2010-06-04 Horst -main.mysqlhotcopy_archive: bug#54129 2010-06-04 Horst +main.mysqlhotcopy_myisam : Bug#56817 2010-10-21 anitha mysqlhotcopy* fails +main.mysqlhotcopy_archive: Bug#56817 2010-10-21 anitha mysqlhotcopy* fails + -- cgit v1.2.1 From c7371c9e757e72cdeef3991b28f0980030d52ca5 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 27 Oct 2010 18:12:10 +0400 Subject: Bug#57477 SIGFPE when dividing a huge number a negative number The problem is dividing by const value when the result is out of supported range. The fix: -return LONGLONG_MIN if the result is out of supported range for DIV operator. -return 0 if divisor is -1 for MOD operator. mysql-test/r/func_math.result: test case mysql-test/t/func_math.test: test case sql/item_func.cc: -return LONGLONG_MIN if the result is out of supported range for DIV operator. -return 0 if divisor is -1 for MOD operator. --- mysql-test/t/func_math.test | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 91fdce8addb..b0c92c9d6ab 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -308,5 +308,11 @@ SELECT RAND(i) FROM t1; DROP TABLE t1; --echo # +--echo # Bug#57477 SIGFPE when dividing a huge number a negative number +--echo # +SELECT -9999999999999999991 DIV -1; +SELECT -9223372036854775808 DIV -1; +SELECT -9223372036854775808 MOD -1; +SELECT -9223372036854775808999 MOD -1; --echo End of 5.1 tests -- cgit v1.2.1 From c04bf683fe2582753e8d575e508902245efdd47c Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 29 Oct 2010 11:44:32 +0400 Subject: Bug#57194 group_concat cause crash and/or invalid memory reads with type errors The problem is caused by bug49487 fix and became visible after after bug56679 fix. Items are cleaned up and set to unfixed state after filling derived table. So we can not rely on item::fixed state in Item_func_group_concat::print and we can not use 'args' array as items there may be cleaned up. The fix is always to use orig_args array of items as it always should contain the correct data. mysql-test/r/func_gconcat.result: test case mysql-test/t/func_gconcat.test: test case sql/item_sum.cc: The fix is always to use orig_args array of items. --- mysql-test/t/func_gconcat.test | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 926c1f92855..29fc8a9dc3c 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -734,4 +734,14 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1; +--echo # +--echo # Bug#57194 group_concat cause crash and/or invalid memory reads with type errors +--echo # + +CREATE TABLE t1(f1 int); +INSERT INTO t1 values (0),(0); +--error ER_ILLEGAL_VALUE_FOR_TYPE +SELECT POLYGON((SELECT 1 FROM (SELECT 1 IN (GROUP_CONCAT(t1.f1)) FROM t1, t1 t GROUP BY t.f1 ) d)); +DROP TABLE t1; + --echo End of 5.1 tests -- cgit v1.2.1 From 4a23ac20d99118b2127d0e6adae0d8a95655e32e Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 29 Oct 2010 12:23:06 +0400 Subject: Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field Lines below which were added in the patch for Bug#56814 cause this crash: + if (table->table) + table->table->maybe_null= FALSE; Consider following test case: -- CREATE TABLE t1(f1 INT NOT NULL); INSERT INTO t1 VALUES (16777214),(0); SELECT COUNT(*) FROM t1 LEFT JOIN t1 t2 ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1; DROP TABLE t1; -- We set TABLE::maybe_null to FALSE for t2 table and in create_tmp_field() we create appropriate tmp table field using create_tmp_field_from_item() function instead of create_tmp_field_from_field. As a result we have LONGLONG field. As we have GROUP BY clause we calculate group buffer length, see calc_group_buffer(). Item from group list which is used for calculation refer to the field from real tables and have LONG type. So group buffer length become insufficient for storing of LONGLONG value. It leads to overwriting of wrong memory area in do_field_int() function which is called from end_update(). After some investigation I found out that create_tmp_field_from_item() is used only for OLAP grouping and can not be used for common grouping as it could be an incompatibility between tmp table fields and group buffer length. We can not remove create_tmp_field_from_item() call from create_tmp_field as OLAP needs it and we can not use this function for common grouping. So we should remove setting TABLE::maybe_null to FALSE from simplify_joins(). In this case we'll get wrong behaviour of list_contains_unique_index() back. To fix it we could use Field::real_maybe_null() check instead of Field::maybe_null() and add addition check of TABLE_LIST::outer_join. mysql-test/r/group_by.result: test case mysql-test/r/join_outer.result: test case mysql-test/t/group_by.test: test case mysql-test/t/join_outer.test: test case sql/sql_select.cc: --remove wrong code --use Field::real_maybe_null() check instead of Field::maybe_null() and add addition check of TABLE_LIST::outer_join --- mysql-test/t/group_by.test | 11 +++++++++++ mysql-test/t/join_outer.test | 29 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 75ec1d82b02..580c2e5091c 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1235,5 +1235,16 @@ SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; SELECT SUBSTRING(a,1,10), LENGTH(a) FROM t1 GROUP BY a; DROP TABLE t1; +--echo # +--echo # Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +--echo # + +CREATE TABLE t1(f1 INT NOT NULL); +INSERT INTO t1 VALUES (16777214),(0); + +SELECT COUNT(*) FROM t1 LEFT JOIN t1 t2 +ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1; + +DROP TABLE t1; --echo # End of 5.1 tests diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index cf881e6aaa2..3251ff292b6 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -981,4 +981,33 @@ EXPLAIN EXTENDED SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 DROP TABLE t1; +--echo # +--echo # Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field +--echo # + +CREATE TABLE t1 (f1 INT NOT NULL, PRIMARY KEY (f1)); +CREATE TABLE t2 (f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY (f1, f2)); + +INSERT INTO t1 VALUES (4); +INSERT INTO t2 VALUES (3, 3); +INSERT INTO t2 VALUES (7, 7); + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; + +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 +GROUP BY t2.f1, t2.f2; + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; + +SELECT * FROM t1 LEFT JOIN t2 ON t2.f1 = t1.f1 +WHERE t1.f1 = 4 AND t2.f1 IS NOT NULL AND t2.f2 IS NOT NULL +GROUP BY t2.f1, t2.f2; + +DROP TABLE t1,t2; + --echo End of 5.1 tests -- cgit v1.2.1 From 75d59ff9672856f8e18394e822e69cd611700594 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Fri, 29 Oct 2010 16:10:53 +0200 Subject: Bug #57659 Segfault in Query_cache::invalidate_data for TRUNCATE TABLE This crash could happen if TRUNCATE TABLE indirectly failed to open a merge table due to failures to open underlying tables. Even if opening failed, the TRUNCATE TABLE code would try to invalidate the table in the query cache. Since this table had been closed and memory released, this could lead to a crash. This bug was introduced by a combination of the changes introduced by the patch for Bug#52044, where failing to open a table will cause opened tables to be closed. And the changes in patch for Bug#49938, where TRUNCATE TABLE uses the standard open tables function. This patch fixes the problem by setting the TABLE pointer to NULL before invalidating the query cache. Test case added to truncate_coverage.test. --- mysql-test/t/truncate_coverage.test | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/truncate_coverage.test b/mysql-test/t/truncate_coverage.test index c9c4bd90ca4..135935b53b3 100644 --- a/mysql-test/t/truncate_coverage.test +++ b/mysql-test/t/truncate_coverage.test @@ -172,3 +172,57 @@ UNLOCK TABLES; DROP TABLE t1; SET DEBUG_SYNC='RESET'; +--echo # +--echo # Bug#57659 Segfault in Query_cache::invalidate_data for TRUNCATE TABLE +--echo # + +--echo # Note that this test case only reproduces the problem +--echo # when it is run with valgrind. + +--disable_warnings +DROP TABLE IF EXISTS t1, m1; +--enable_warnings + +CREATE TABLE t1(a INT) engine=memory; +CREATE TABLE m1(a INT) engine=merge UNION(t1); +connect(con2, localhost, root); + +--echo # Connection con1 +connect(con1, localhost, root); +SET DEBUG_SYNC= 'open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR dropped'; +--echo # Sending: +--send TRUNCATE TABLE m1 + +--echo # Connection con2 +connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +--echo # Sending: +--send FLUSH TABLES + +--echo # Connection default +connection default; +--echo # Waiting for FLUSH TABLES to be blocked. +let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist + WHERE state= 'Waiting for table flush' AND info= 'FLUSH TABLES'; +--source include/wait_condition.inc +SET DEBUG_SYNC= 'now SIGNAL dropped'; + +--echo # Connection con1 +connection con1; +--echo # Reaping: TRUNCATE TABLE m1 +--error ER_WRONG_MRG_TABLE +--reap +disconnect con1; +--source include/wait_until_disconnected.inc + +--echo # Connection con2 +connection con2; +--echo # Reaping: FLUSH TABLES +--reap +disconnect con2; +--source include/wait_until_disconnected.inc + +--echo # Connection default +connection default; +SET DEBUG_SYNC= 'RESET'; +DROP TABLE m1, t1; -- cgit v1.2.1 From c4a4119829756aef666f2244f2e71d09a3bfd885 Mon Sep 17 00:00:00 2001 From: Sven Sandberg Date: Fri, 29 Oct 2010 16:56:58 +0200 Subject: wL#5625: Deprecate mysqlbinlog options --base64-output=always and --base64-output Adds deprecation warning for the mysqlbinlog options --base64-output=always and --base64-output. A warning is printed when the flags are used, and also when running mysqlbinlog --help. client/mysqlbinlog.cc: Give a warning for --base64-output=always and --base64-output, and print warning in mysqlbinlog --help. mysql-test/r/mysqlbinlog.result: updated result file mysql-test/t/mysqlbinlog.test: Test that mysqlbinlog --base64-output=always gives a warning. --- mysql-test/t/mysqlbinlog.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 3a9dae35476..76f6c63fc1d 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -487,3 +487,18 @@ diff_files $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn $MYSQLTEST_VARDIR/tmp/mysqlbin # Cleanup for this part of test remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty; remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn; + +# +# WL#5625: Deprecate mysqlbinlog options --base64-output=always and --base64-output +# + +--echo # Expect deprecation warning. +--exec $MYSQL_BINLOG --base64-output=always std_data/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn +--cat_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn + +--echo # Expect deprecation warning again. +--exec $MYSQL_BINLOG --base64-output std_data/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn +--cat_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn + +# Clean up this part of the test. +--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn -- cgit v1.2.1 From 20d704978ddb14dee414f40f28bd58f82b21711c Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Sun, 31 Oct 2010 19:04:38 +0300 Subject: Bug #52160: crash and inconsistent results when grouping by a function and column The bugreport reveals two different bugs about grouping on a function: 1) grouping by the TIME_TO_SEC function result caused a server crash or wrong results and 2) grouping by the function returning a blob caused an unexpected "Duplicate entry" error and wrong result. Details for the 1st bug: TIME_TO_SEC() returns NULL if its argument is invalid (empty string for example). Thus its nullability depends not only on the nullability of its arguments but also on their values. Fixed by (overoptimistically) setting TIME_TO_SEC() to be nullable despite the nullability of its arguments. Details for the 2nd bug: The server is unable to create indices on blobs without explicit blob key part length. However, this fact was ignored for blob function result fields of GROUP BY intermediate tables. Fixed by disabling GROUP BY index creation for blob function result fields like regular blob fields. mysql-test/r/func_time.result: Test case for bug #52160. mysql-test/r/type_blob.result: Test case for bug #52160. mysql-test/t/func_time.test: Test case for bug #52160. mysql-test/t/type_blob.test: Test case for bug #52160. sql/item_timefunc.h: Bug #52160: crash and inconsistent results when grouping by a function and column TIME_TO_SEC() returns NULL if its argument is invalid (empty string for example). Thus its nullability depends not only Fixed by (overoptimistically) setting TIME_TO_SEC() to be nullable despite the nullability of its arguments. sql/sql_select.cc: Bug #52160: crash and inconsistent results when grouping by a function and column The server is unable to create indices on blobs without explicit blob key part length. However, this fact was ignored for blob function result fields of GROUP BY intermediate tables. Fixed by disabling GROUP BY index creation for blob function result fields like regular blob fields. --- mysql-test/t/func_time.test | 10 ++++++++++ mysql-test/t/type_blob.test | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index e764906c374..8fce7072319 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -849,4 +849,14 @@ INSERT INTO t1 VALUES (0),(9.216e-096); SELECT 1 FROM t1 ORDER BY @x:=makedate(a,a); DROP TABLE t1; +--echo # +--echo # Bug #52160: crash and inconsistent results when grouping +--echo # by a function and column +--echo # + +CREATE TABLE t1(a CHAR(10) NOT NULL); +INSERT INTO t1 VALUES (''),(''); +SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a); +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index 460da1c1614..4e097edf73d 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -612,3 +612,19 @@ explain select convert(1, binary(4294967296)); explain select convert(1, binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); --echo End of 5.0 tests + +--echo # Bug #52160: crash and inconsistent results when grouping +--echo # by a function and column + +CREATE FUNCTION f1() RETURNS TINYBLOB RETURN 1; + +CREATE TABLE t1(a CHAR(1)); +INSERT INTO t1 VALUES ('0'), ('0'); + +SELECT COUNT(*) FROM t1 GROUP BY f1(), a; + +DROP FUNCTION f1; +DROP TABLE t1; + +--echo End of 5.1 tests + -- cgit v1.2.1 From 930cf09ec7bb1dc73caf12c3af05da0e490f37d9 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Mon, 1 Nov 2010 09:47:57 +0300 Subject: test case fix --- mysql-test/t/func_gconcat.test | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 29fc8a9dc3c..a7072362759 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -740,8 +740,10 @@ DROP TABLE t1; CREATE TABLE t1(f1 int); INSERT INTO t1 values (0),(0); +--disable_ps_protocol --error ER_ILLEGAL_VALUE_FOR_TYPE SELECT POLYGON((SELECT 1 FROM (SELECT 1 IN (GROUP_CONCAT(t1.f1)) FROM t1, t1 t GROUP BY t.f1 ) d)); +--enable_ps_protocol DROP TABLE t1; --echo End of 5.1 tests -- cgit v1.2.1 From 00f1e71d9ab02ca4b7b47b194a122afd88bad7f3 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Tue, 2 Nov 2010 17:45:26 +0200 Subject: Bug #57916: Fix the naming of the proxy_priv table 1. Fixed the name of the table to proxies_priv 2. Fixed the column names to be of the form Capitalized_lowecarse instead of Capitalized_Capitalized 3. Added Timestamp and Grantor columns 4. Added tests to plugin_auth to check the table structure 5. Updated the existing tests --- mysql-test/t/plugin_auth.test | 7 ++++++- mysql-test/t/system_mysql_db_fix40123.test | 2 +- mysql-test/t/system_mysql_db_fix50030.test | 2 +- mysql-test/t/system_mysql_db_fix50117.test | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/plugin_auth.test b/mysql-test/t/plugin_auth.test index 77dcd7add73..ebbaf389632 100644 --- a/mysql-test/t/plugin_auth.test +++ b/mysql-test/t/plugin_auth.test @@ -16,6 +16,11 @@ connect(plug_con,localhost,plug,plug_dest); --enable_query_log GRANT PROXY ON plug_dest TO plug; +--echo test proxies_priv columns +--replace_column 7 xx +SELECT * FROM mysql.proxies_priv; +--echo test mysql.proxies_priv; +SHOW CREATE TABLE mysql.proxies_priv; connect(plug_con,localhost,plug,plug_dest); @@ -226,7 +231,7 @@ CREATE USER test_drop@localhost; GRANT PROXY ON future_user TO test_drop@localhost; SHOW GRANTS FOR test_drop@localhost; DROP USER test_drop@localhost; -SELECT * FROM mysql.proxy_priv WHERE Host = 'test_drop' AND User = 'localhost'; +SELECT * FROM mysql.proxies_priv WHERE Host = 'test_drop' AND User = 'localhost'; DROP USER proxy_admin; diff --git a/mysql-test/t/system_mysql_db_fix40123.test b/mysql-test/t/system_mysql_db_fix40123.test index d069271a02e..8c2060d76ba 100644 --- a/mysql-test/t/system_mysql_db_fix40123.test +++ b/mysql-test/t/system_mysql_db_fix40123.test @@ -72,7 +72,7 @@ CREATE TABLE time_zone_leap_second ( Transition_time bigint signed NOT NULL, -- disable_query_log # Drop all tables created by this test -DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxy_priv; +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv; -- enable_query_log diff --git a/mysql-test/t/system_mysql_db_fix50030.test b/mysql-test/t/system_mysql_db_fix50030.test index 53166919f1c..7d55a091b6d 100644 --- a/mysql-test/t/system_mysql_db_fix50030.test +++ b/mysql-test/t/system_mysql_db_fix50030.test @@ -78,7 +78,7 @@ INSERT INTO servers VALUES ('test','localhost','test','root','', 0,'','mysql','r -- disable_query_log # Drop all tables created by this test -DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxy_priv; +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv; -- enable_query_log diff --git a/mysql-test/t/system_mysql_db_fix50117.test b/mysql-test/t/system_mysql_db_fix50117.test index 872829ae79d..260400b9c8a 100644 --- a/mysql-test/t/system_mysql_db_fix50117.test +++ b/mysql-test/t/system_mysql_db_fix50117.test @@ -97,7 +97,7 @@ CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, -- disable_query_log # Drop all tables created by this test -DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxy_priv; +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv; -- enable_query_log -- cgit v1.2.1 From 74328892e0f28c1b1a410df1889225639cb9152b Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 3 Nov 2010 13:47:22 +0200 Subject: Addendum to bug #57916 : fixed the test suite to be less environment dependent. --- mysql-test/t/plugin_auth.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/plugin_auth.test b/mysql-test/t/plugin_auth.test index ebbaf389632..439cabaef18 100644 --- a/mysql-test/t/plugin_auth.test +++ b/mysql-test/t/plugin_auth.test @@ -17,7 +17,7 @@ connect(plug_con,localhost,plug,plug_dest); GRANT PROXY ON plug_dest TO plug; --echo test proxies_priv columns ---replace_column 7 xx +--replace_column 1 xx 7 xx SELECT * FROM mysql.proxies_priv; --echo test mysql.proxies_priv; SHOW CREATE TABLE mysql.proxies_priv; -- cgit v1.2.1 From 1602ffb8ab4e04d17db995a22bb6c33a5a638881 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Wed, 3 Nov 2010 14:51:52 +0000 Subject: BUG#57899: Certain reserved words should not be reserved In MySQL 5.5 the new reserved words include: SLOW as in FLUSH SLOW LOGS GENERAL as in FLUSH GENERAL LOGS IGNORE_SERVER_IDS as in CHANGE MASTER ... IGNORE_SERVER_IDS MASTER_HEARTBEAT_PERIOD as in CHANGE MASTER ... MASTER_HEARTBEAT_PERIOD These are not reserved words in standard SQL, or in Oracle 11g, and as such, may affect existing applications. We fix this by adding the new words to the list of keywords that are allowed for labels in SPs. mysql-test/t/keywords.test: Test case that checks that the target words can be used for naming fields in a table or as local routine variable names. --- mysql-test/t/keywords.test | 100 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/keywords.test b/mysql-test/t/keywords.test index 3080c4847b4..2681f786f40 100644 --- a/mysql-test/t/keywords.test +++ b/mysql-test/t/keywords.test @@ -62,5 +62,103 @@ call p1(); drop procedure p1; drop table t1; - # End of 5.0 tests + +# +# BUG#57899: Certain reserved words should not be reserved +# + +# +# We are looking for SYNTAX ERRORS here, so no need to +# log the queries +# + +CREATE TABLE slow (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT); +INSERT INTO slow(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8); +INSERT INTO slow(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7); +INSERT INTO slow(slow, general) VALUES (1,2), (5,6); +INSERT INTO slow(slow) VALUES (1), (5); +SELECT slow, general, master_heartbeat_period, slow FROM slow ORDER BY slow; +SELECT slow, general, master_heartbeat_period FROM slow ORDER BY slow; +SELECT slow, master_heartbeat_period FROM slow ORDER BY slow; +SELECT slow FROM slow ORDER BY slow; +DROP TABLE slow; +CREATE TABLE general (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT); +INSERT INTO general(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8); +INSERT INTO general(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7); +INSERT INTO general(slow, general) VALUES (1,2), (5,6); +INSERT INTO general(slow) VALUES (1), (5); +SELECT slow, general, master_heartbeat_period, slow FROM general ORDER BY slow; +SELECT slow, general, master_heartbeat_period FROM general ORDER BY slow; +SELECT slow, master_heartbeat_period FROM general ORDER BY slow; +SELECT slow FROM general ORDER BY slow; +DROP TABLE general; +CREATE TABLE master_heartbeat_period (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT); +INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8); +INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7); +INSERT INTO master_heartbeat_period(slow, general) VALUES (1,2), (5,6); +INSERT INTO master_heartbeat_period(slow) VALUES (1), (5); +SELECT slow, general, master_heartbeat_period, slow FROM master_heartbeat_period ORDER BY slow; +SELECT slow, general, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow; +SELECT slow, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow; +SELECT slow FROM master_heartbeat_period ORDER BY slow; +DROP TABLE master_heartbeat_period; +CREATE TABLE ignore_server_ids (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT); +INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8); +INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7); +INSERT INTO ignore_server_ids(slow, general) VALUES (1,2), (5,6); +INSERT INTO ignore_server_ids(slow) VALUES (1), (5); +SELECT slow, general, master_heartbeat_period, slow FROM ignore_server_ids ORDER BY slow; +SELECT slow, general, master_heartbeat_period FROM ignore_server_ids ORDER BY slow; +SELECT slow, master_heartbeat_period FROM ignore_server_ids ORDER BY slow; +SELECT slow FROM ignore_server_ids ORDER BY slow; +DROP TABLE ignore_server_ids; + +CREATE TABLE t1 (slow INT, general INT, ignore_server_ids INT, master_heartbeat_period INT); +INSERT INTO t1 VALUES (1,2,3,4); +DELIMITER |; +CREATE PROCEDURE p1() +BEGIN + DECLARE slow INT; + DECLARE general INT; + DECLARE ignore_server_ids INT; + DECLARE master_heartbeat_period INT; + + SELECT max(t1.slow) INTO slow FROM t1; + SELECT max(t1.general) INTO general FROM t1; + SELECT max(t1.ignore_server_ids) INTO ignore_server_ids FROM t1; + SELECT max(t1.master_heartbeat_period) INTO master_heartbeat_period FROM t1; + + SELECT slow, general, ignore_server_ids, master_heartbeat_period; +END| + +CREATE PROCEDURE p2() +BEGIN + + DECLARE n INT DEFAULT 2; + general: WHILE n > 0 DO + SET n = n -1; + END WHILE general; + + SET n = 2; + slow: WHILE n > 0 DO + SET n = n -1; + END WHILE slow; + + SET n = 2; + ignore_server_ids: WHILE n > 0 DO + SET n = n -1; + END WHILE ignore_server_ids; + + SET n = 2; + master_heartbeat_period: WHILE n > 0 DO + SET n = n -1; + END WHILE master_heartbeat_period; + +END| +DELIMITER ;| +CALL p1(); +call p2(); +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP TABLE t1; -- cgit v1.2.1 From c1b2d729002fa28bf29957436c0ed1926e9c45a6 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Wed, 3 Nov 2010 16:47:32 +0100 Subject: Bug #57130 crash in Item_field::print during SHOW CREATE TABLE or VIEW This crash could happen if SHOW CREATE VIEW indirectly failed to open a view due to failures to open underlying tables (or functions). Several such errors were hidden and converted to ER_VIEW_INVALID warnings to prevent exposing details of underlying tables for which the user have no privileges. However, with the changes introduced by the patch for Bug#52044, failing to open a view will cause opened tables, views and functions to be closed. Since the errors causing these failures were converted to warnings, SHOW CREATE VIEW would try to continue. This made it possible to try to access memory that had been freed, causing a crash. This patch fixes the problem by not closing opened tables, views and functions in these cases. This allows SHOW CREATE VIEW to continue and also prevents it from accessing freed memory. Test case added to lock_sync.test. --- mysql-test/t/lock_sync.test | 59 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/lock_sync.test b/mysql-test/t/lock_sync.test index 7131e2cde31..d5ad7becd7d 100644 --- a/mysql-test/t/lock_sync.test +++ b/mysql-test/t/lock_sync.test @@ -1078,6 +1078,65 @@ DROP TABLE t1; SET DEBUG_SYNC= 'RESET'; +--echo # +--echo # Bug#57130 crash in Item_field::print during SHOW CREATE TABLE or VIEW +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +DROP FUNCTION IF EXISTS f1; +--enable_warnings + +CREATE TABLE t1(a INT); +CREATE FUNCTION f1() RETURNS INTEGER RETURN 1; +CREATE VIEW v1 AS SELECT * FROM t1 WHERE f1() = 1; +DROP FUNCTION f1; +connect(con2, localhost, root); + +--echo # Connection con1 +connect (con1, localhost, root); +# Need to trigger this sync point at least twice in order to +# get valgrind test failures without the patch +SET DEBUG_SYNC= 'open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR dropped EXECUTE 2'; +--echo # Sending: +--send SHOW CREATE VIEW v1 + +--echo # Connection con2 +connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +SET DEBUG_SYNC= 'now SIGNAL dropped'; +SET DEBUG_SYNC= 'now WAIT_FOR opened'; +--echo # Sending: +--send FLUSH TABLES + +--echo # Connection default +connection default; +--echo # Waiting for FLUSH TABLES to be blocked. +let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist + WHERE state= 'Waiting for table flush' AND info= 'FLUSH TABLES'; +--source include/wait_condition.inc +SET DEBUG_SYNC= 'now SIGNAL dropped'; + +--echo # Connection con1 +connection con1; +--echo # Reaping: SHOW CREATE VIEW v1 +--reap + +--echo # Connection con2 +connection con2; +--echo # Reaping: FLUSH TABLES +--reap + +--echo # Connection default +connection default; +SET DEBUG_SYNC= 'RESET'; +DROP VIEW v1; +DROP TABLE t1; +disconnect con1; +disconnect con2; + + # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc -- cgit v1.2.1 From 64bee6fdc5a16bacc6e290e586038ac338b1ed69 Mon Sep 17 00:00:00 2001 From: Jorgen Loland Date: Thu, 4 Nov 2010 09:36:04 +0100 Subject: Bug#57882 - Item_func_conv_charset::val_str(String*): Assertion `fixed == 1' failed (also fixes duplicate bug 57515) agg_item_set_converter() (item.cc) handles conversion of character sets by creating a new Item. fix_fields() is then called on this newly created item. Prior to this patch, it was not checked whether fix_fields() was successful or not. Thus, agg_item_set_converter() would return success even when an error occured. This patch makes it return error (TRUE) if fix_fields() fails. mysql-test/r/errors.result: Add test for BUG#57882 mysql-test/t/errors.test: Add test for BUG#57882 sql/item.cc: Make agg_item_set_converter() return with error if fix_fields() on the newly created converted item fails. --- mysql-test/t/errors.test | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/errors.test b/mysql-test/t/errors.test index f308c340645..8de5889f1c6 100644 --- a/mysql-test/t/errors.test +++ b/mysql-test/t/errors.test @@ -155,3 +155,19 @@ INSERT INTO t1 VALUES ('abc\0\0'); --error ER_DUP_ENTRY INSERT INTO t1 VALUES ('abc\0\0'); DROP TABLE t1; + +--echo # +--echo # Bug#57882: Item_func_conv_charset::val_str(String*): +--echo # Assertion `fixed == 1' failed +--echo # + +--error ER_DATA_OUT_OF_RANGE +SELECT (CONVERT('0' USING latin1) IN (CHAR(COT('v') USING utf8),'')); + +SET NAMES utf8 COLLATE utf8_latvian_ci ; +--error ER_DATA_OUT_OF_RANGE +SELECT UPDATEXML(-73 * -2465717823867977728,@@global.slave_net_timeout,null); + +--echo # +--echo # End Bug#57882 +--echo # -- cgit v1.2.1 From f0ce67873cd2eb2b6eb30ba1ecb0d3df5206d5a0 Mon Sep 17 00:00:00 2001 From: Jorgen Loland Date: Thu, 4 Nov 2010 13:36:36 +0100 Subject: Bug#57882 - Item_func_conv_charset::val_str(String*): Assertion `fixed == 1' failed Followup patch. Test case relied on system variable that is only available if replication is compiled in. Replaced with variable available in all builds. mysql-test/r/errors.result: Test case relied on system variable that is only available if replication is compiled in. Replaced with variable available in all builds. mysql-test/t/errors.test: Test case relied on system variable that is only available if replication is compiled in. Replaced with variable available in all builds. --- mysql-test/t/errors.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/errors.test b/mysql-test/t/errors.test index 8de5889f1c6..82822c87e89 100644 --- a/mysql-test/t/errors.test +++ b/mysql-test/t/errors.test @@ -166,7 +166,7 @@ SELECT (CONVERT('0' USING latin1) IN (CHAR(COT('v') USING utf8),'')); SET NAMES utf8 COLLATE utf8_latvian_ci ; --error ER_DATA_OUT_OF_RANGE -SELECT UPDATEXML(-73 * -2465717823867977728,@@global.slave_net_timeout,null); +SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,null); --echo # --echo # End Bug#57882 -- cgit v1.2.1 From 368ac9f03ef9c1f0c9d02985c13708ac52cfbfaf Mon Sep 17 00:00:00 2001 From: Evgeny Potemkin Date: Thu, 4 Nov 2010 16:18:27 +0300 Subject: Bug#57278: Crash on min/max + with date out of range. MySQL officially supports DATE values starting from 1000-01-01. This is enforced for int values, but not for string values, thus one could easily insert '0001-01-01' value. Int values are checked by number_to_datetime function and Item_cache_datetime::val_str uses it to fill MYSQL_TIME struct out of cached int value. This leads to the scenario where Item_cache_datetime caches a non-null datetime value and when it tries to convert it from int to string number_to_datetime function treats the value as out-of-range and returns an error and Item_cache_datetime::val_str returns NULL for a non-null value. Due to this inconsistency server crashes. Now number_to_datetime allows DATE values below 1000-01-01 if the TIME_FUZZY_DATE flag is set. Better NULL handling for Item_cache_datetime. Added the Item_cache_datetime::store function to reset str_value_cached flag when an item is stored. mysql-test/r/type_date.result: Added a test case for the bug#57278. mysql-test/t/type_date.test: Added a test case for the bug#57278. sql-common/my_time.c: Bug#57278: Crash on min/max + with date out of range. Now number_to_datetime allows DATE values below 1000-01-01 if the TIME_FUZZY_DATE flag is set. sql/item.cc: Bug#57278: Crash on min/max + with date out of range. Item_cache_datetime::val_str now better handles null_value. --- mysql-test/t/type_date.test | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index 11f2b68804a..6dec86dacab 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -284,4 +284,12 @@ DROP TABLE t1; --echo # +--echo # +--echo # Bug#57278: Crash on min/max + with date out of range. +--echo # +set @a=(select min(makedate('111','1'))) ; +select @a; +--echo # + + --echo End of 6.0 tests -- cgit v1.2.1 From aafb35d09975170b6162a9bcd3b2c35cdb78579d Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Fri, 5 Nov 2010 08:23:39 +0000 Subject: BUG#57899: Certain reserved words should not be reserved Small fix for the test case. The column named "slow" was used twice in the SELECTs. As a consequence, the column named "ignore_server_ids" was not used. To fix this we simply replace the second column selected named "slow" with a column named "ignore_server_ids". --- mysql-test/t/keywords.test | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/keywords.test b/mysql-test/t/keywords.test index 2681f786f40..08016313ca7 100644 --- a/mysql-test/t/keywords.test +++ b/mysql-test/t/keywords.test @@ -78,7 +78,7 @@ INSERT INTO slow(slow, general, master_heartbeat_period, ignore_server_ids) VALU INSERT INTO slow(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7); INSERT INTO slow(slow, general) VALUES (1,2), (5,6); INSERT INTO slow(slow) VALUES (1), (5); -SELECT slow, general, master_heartbeat_period, slow FROM slow ORDER BY slow; +SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM slow ORDER BY slow; SELECT slow, general, master_heartbeat_period FROM slow ORDER BY slow; SELECT slow, master_heartbeat_period FROM slow ORDER BY slow; SELECT slow FROM slow ORDER BY slow; @@ -88,7 +88,7 @@ INSERT INTO general(slow, general, master_heartbeat_period, ignore_server_ids) V INSERT INTO general(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7); INSERT INTO general(slow, general) VALUES (1,2), (5,6); INSERT INTO general(slow) VALUES (1), (5); -SELECT slow, general, master_heartbeat_period, slow FROM general ORDER BY slow; +SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM general ORDER BY slow; SELECT slow, general, master_heartbeat_period FROM general ORDER BY slow; SELECT slow, master_heartbeat_period FROM general ORDER BY slow; SELECT slow FROM general ORDER BY slow; @@ -98,7 +98,7 @@ INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period, igno INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7); INSERT INTO master_heartbeat_period(slow, general) VALUES (1,2), (5,6); INSERT INTO master_heartbeat_period(slow) VALUES (1), (5); -SELECT slow, general, master_heartbeat_period, slow FROM master_heartbeat_period ORDER BY slow; +SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM master_heartbeat_period ORDER BY slow; SELECT slow, general, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow; SELECT slow, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow; SELECT slow FROM master_heartbeat_period ORDER BY slow; @@ -108,7 +108,7 @@ INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period, ignore_ser INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7); INSERT INTO ignore_server_ids(slow, general) VALUES (1,2), (5,6); INSERT INTO ignore_server_ids(slow) VALUES (1), (5); -SELECT slow, general, master_heartbeat_period, slow FROM ignore_server_ids ORDER BY slow; +SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM ignore_server_ids ORDER BY slow; SELECT slow, general, master_heartbeat_period FROM ignore_server_ids ORDER BY slow; SELECT slow, master_heartbeat_period FROM ignore_server_ids ORDER BY slow; SELECT slow FROM ignore_server_ids ORDER BY slow; -- cgit v1.2.1 From c04318ed243fd85eeb7256399516a9189e12a0b0 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 5 Nov 2010 12:01:10 +0100 Subject: Bug#57778: failed primary key add to partitioned innodb table inconsistent and crashes It was possible to issue an ALTER TABLE ADD PRIMARY KEY on an partitioned InnoDB table that failed and crashed the server. The problem was that it succeeded to create the PK on at least one partition, and then failed on a subsequent partition, due to duplicate key violation. Since the partitions that already had added the PK was not reverted all partitions was not consistent with the table definition, which caused the crash. The solution was to add a revert step to ha_partition::add_index() that dropped the index for the already succeeded partitions, on failure. mysql-test/r/partition.result: updated result mysql-test/t/partition.test: Added test sql/ha_partition.cc: Only allow ADD/DROP flags in pairs, so that they can be reverted on failures. If add_index() fails for a partition, revert (drop the index) for the previous partitions. sql/handler.h: Added some extra info in a comment. --- mysql-test/t/partition.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 68239c06660..cf3dcfadb27 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -14,6 +14,24 @@ drop table if exists t1, t2; --enable_warnings +--echo # +--echo # Bug#57778: failed primary key add to partitioned innodb table +--echo # inconsistent and crashes +--echo # +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) +PARTITION BY KEY (a) PARTITIONS 2; +INSERT INTO t1 VALUES (0,1), (0,2); +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD PRIMARY KEY (a); +SHOW CREATE TABLE t1; +SELECT * FROM t1; +UPDATE t1 SET a = 1, b = 1 WHERE a = 0 AND b = 2; +ALTER TABLE t1 ADD PRIMARY KEY (a); +SELECT * FROM t1; +ALTER TABLE t1 DROP PRIMARY KEY; +SELECT * FROM t1; +DROP TABLE t1; + --echo # --echo # Bug#57113: ha_partition::extra(ha_extra_function): --echo # Assertion `m_extra_cache' failed -- cgit v1.2.1 From 866cec611a369be344bafed0d4691ad6b83e4086 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Fri, 5 Nov 2010 15:26:38 +0100 Subject: Bug #57840 MTR: parallel execution breaks with smart ordering of test cases There were actually more problems in this area: Slaves (if any) were unconditionally restarted, this appears unnecessary. Sort criteria were suboptimal, included the test name. Added logic to "reserve" a sequence of tests with same config for one thread Got rid of sort_criteria hash, put it into the test case itself Adds little sanity check that expected worker picks up test Fixed some tests that may fail if starting on running server Some of these fail only if *same* test is repeated. Finally, special sorting of tests that do --force-restart --- mysql-test/t/key_cache-master.opt | 1 + mysql-test/t/mysqlbinlog-master.opt | 1 + 2 files changed, 2 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/key_cache-master.opt b/mysql-test/t/key_cache-master.opt index 66e19c18a8a..6398e3e0a26 100644 --- a/mysql-test/t/key_cache-master.opt +++ b/mysql-test/t/key_cache-master.opt @@ -1 +1,2 @@ --key_buffer_size=2M --small.key_buffer_size=256K --small.key_buffer_size=128K +--force-restart diff --git a/mysql-test/t/mysqlbinlog-master.opt b/mysql-test/t/mysqlbinlog-master.opt index ac1a87c73b3..a9f4a6010d8 100644 --- a/mysql-test/t/mysqlbinlog-master.opt +++ b/mysql-test/t/mysqlbinlog-master.opt @@ -1 +1,2 @@ --max-binlog-size=4096 +--force-restart -- cgit v1.2.1 From e0678e2ca624395a447dd8898583c13e31ec2f6a Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Sat, 6 Nov 2010 19:21:12 +0100 Subject: some test fixes after merging 57840 --- mysql-test/t/union.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 93dc4cad50c..596fc5f41ef 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -1062,7 +1062,7 @@ SELECT ( SELECT a UNION SELECT a ) INTO OUTFILE 'union.out.file3' FROM t1; SELECT ( SELECT a UNION SELECT a ) INTO DUMPFILE 'union.out.file4' FROM t1; DROP TABLE t1; - +remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.1/data/test union.out.fil*; --echo # --echo # Bug #49734: Crash on EXPLAIN EXTENDED UNION ... ORDER BY -- cgit v1.2.1 From 8f237f5874a814daaa7431748849997d1a2aa8ea Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Sun, 7 Nov 2010 23:42:54 +0600 Subject: A fix and a test case for Bug#47924 -main.log_tables times out sporadically. The cause of the sporadic time out was a leaking protection against the global read lock, taken by the RENAME statement, and not released in case of an error occurred during RENAME. The leaking protection counter would lead to the value of protect_against_global_read never dropping to 0. Consequently FLUSH TABLES in all connections, including the one that leaked the protection, could not proceed. The fix is to ensure that all branchesin RENAME code properly release GRL protection. mysql-test/r/log_tables.result: Added results for test for bug#47924. mysql-test/t/log_tables.test: Added test for bug#47924. sql/sql_rename.cc: mysql_rename_tables() modified: replaced return from function to goto to clean up code block in case of error. --- mysql-test/t/log_tables.test | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test index 076f2e8bc3b..af6c34dec37 100644 --- a/mysql-test/t/log_tables.test +++ b/mysql-test/t/log_tables.test @@ -1027,6 +1027,25 @@ DROP TABLE t1; TRUNCATE TABLE mysql.slow_log; +# +# Bug #47924 main.log_tables times out sporadically +# + +use mysql; +# Should result in error +--disable_warnings +drop table if exists renamed_general_log; +drop table if exists renamed_slow_log; +--enable_warnings +--error ER_CANT_RENAME_LOG_TABLE +RENAME TABLE general_log TO renamed_general_log; +--error ER_CANT_RENAME_LOG_TABLE +RENAME TABLE slow_log TO renamed_slow_log; + +use test; +flush tables with read lock; +unlock tables; + SET @@session.long_query_time= @old_long_query_time; SET @@global.log_output= @old_log_output; -- cgit v1.2.1 From 0a29baba4bae36b947aba9001956f3c800f4205f Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Mon, 8 Nov 2010 13:34:27 +0300 Subject: Fix for bug #54575: crash when joining tables with unique set column(backport from 5.1) Problem: a flaw (derefencing a NULL pointer) in the LIKE optimization code may lead to a server crash in some rare cases. Fix: check the pointer before its dereferencing. mysql-test/r/func_like.result: Fix for bug #54575: crash when joining tables with unique set column - test result. mysql-test/t/func_like.test: Fix for bug #54575: crash when joining tables with unique set column - test case. sql/item_cmpfunc.cc: Fix for bug #54575: crash when joining tables with unique set column - check res2 buffer pointer before its dereferencing as it may be NULL in some cases. --- mysql-test/t/func_like.test | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test index 4e1183afeff..50ebb2b2782 100644 --- a/mysql-test/t/func_like.test +++ b/mysql-test/t/func_like.test @@ -112,5 +112,19 @@ select 'andre%' like 'andre # select _cp1251'andre%' like convert('andre%' using cp1251) escape ''; -# -# End of 4.1 tests + +--echo End of 4.1 tests + + +--echo # +--echo # Bug #54575: crash when joining tables with unique set column +--echo # +CREATE TABLE t1(a SET('a') NOT NULL, UNIQUE KEY(a)); +CREATE TABLE t2(b INT PRIMARY KEY); +INSERT INTO t1 VALUES (); +INSERT INTO t2 VALUES (1), (2), (3); +SELECT 1 FROM t2 JOIN t1 ON 1 LIKE a GROUP BY a; +DROP TABLE t1, t2; + + +--echo End of 5.1 tests -- cgit v1.2.1 From 50a3c55ee7e378b36bca5940e382fb18674dbd9b Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Mon, 8 Nov 2010 13:51:39 +0300 Subject: Bug#52711 Segfault when doing EXPLAIN SELECT with union...order by (select... where...) backport from 5.1 mysql-test/r/subselect.result: backport from 5.1 mysql-test/t/subselect.test: backport from 5.1 sql/sql_select.cc: backport from 5.1 --- mysql-test/t/subselect.test | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index bd12742f0f1..0956f91619d 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -3506,5 +3506,26 @@ ORDER BY outr.pk; DROP TABLE t1,t2; +--echo # +--echo # Bug #52711: Segfault when doing EXPLAIN SELECT with +--echo # union...order by (select... where...) +--echo # + +CREATE TABLE t1 (a VARCHAR(10), FULLTEXT KEY a (a)); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1),(2); + +--echo # Should not crash +--disable_result_log +EXPLAIN +SELECT * FROM t2 UNION SELECT * FROM t2 + ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); + +--echo # Should not crash +SELECT * FROM t2 UNION SELECT * FROM t2 + ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); +DROP TABLE t1,t2; +--enable_result_log --echo End of 5.0 tests. -- cgit v1.2.1 From f91c6de21188613220cef7cee8935510f6b5cc99 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 9 Nov 2010 11:08:02 +0300 Subject: Postfix for Bug#26474 Add Sinhala script (Sri Lanka) collation to MySQL --- mysql-test/t/ctype_utf8.test | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 5b665e24958..c7586c71229 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1477,6 +1477,15 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682'); SELECT predicted_order, hex(utf8_encoding) FROM t1 ORDER BY utf8_encoding COLLATE utf8_sinhala_ci; DROP TABLE t1; +# +# Postfix for Bug#26474 +# +SET NAMES utf8 COLLATE utf8_sinhala_ci; +CREATE TABLE t1 (s1 VARCHAR(10) COLLATE utf8_sinhala_ci); +INSERT INTO t1 VALUES ('a'),('ae'),('af'); +SELECT s1,hex(s1) FROM t1 ORDER BY s1; +SELECT * FROM t1 ORDER BY s1; +DROP TABLE t1; --echo End of 5.4 tests -- cgit v1.2.1 From 3fab29461661f677fd5ca0be75fab8bcf84eadff Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 10 Nov 2010 09:42:14 +0100 Subject: Bug #57276 mysqltest: add support for simple compares in if/while conditions Added more parsing in do_block() Limitation: left operand must be variable Also changed var_set_int from 57036 to var_check_int Added tests to mysqltest.test Some tests can now be simplified but will take this later Updated after comments, now white space around operator not needed --- mysql-test/t/mysqltest.test | 202 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 178 insertions(+), 24 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 8fb05e52cdc..9b8a45d6a87 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1163,10 +1163,11 @@ if ($counter) { echo oops, -0 is true; } -if (beta) -{ - echo Beta is true; -} +# This is no longer allowed, as a precaution against mistyped conditionals +# if (beta) +# { +# echo Beta is true; +# } let $counter=gamma; while ($counter) { @@ -1174,6 +1175,179 @@ while ($counter) let $counter=000; } +# ---------------------------------------------------------------------------- +# Test if with compare conditions +# ---------------------------------------------------------------------------- + +let $ifvar= 5; +let $ifvar2= 6; + +if ($ifvar < 7) +{ + echo 5<7; +} +if ($ifvar< 7) +{ + echo 5<7 again; +} +if ($ifvar<7) +{ + echo 5<7 still; +} +if ($ifvar < $ifvar2) +{ + echo 5<6; +} +if ($ifvar <= 4) +{ + echo 5<=4; +} +if ($ifvar >= 5) +{ + echo 5>=5; +} +if ($ifvar>=5) +{ + echo 5>=5 again; +} +if ($ifvar > 3) +{ + echo 5>3; +} +if ($ifvar == 4) +{ + echo 5==4; +} +if ($ifvar == 5) +{ + echo 5==5; +} +if ($ifvar != 8) +{ + echo 5!=8; +} +# Any number should compare unequal to any string +if ($ifvar != five) +{ + echo 5!=five; +} +if ($ifvar == `SELECT 3+2`) +{ + echo 5==3+2; +} +if ($ifvar == 5) +{ + echo 5 == 5; +} +let $ifvar= hello; +if ($ifvar == hello there) +{ + echo hello == hello there; +} +if ($ifvar == hello) +{ + echo hello == hello; +} +if ($ifvar == hell) +{ + echo hello == hell; +} +if ($ifvar == hello) +{ + echo hello == hello; +} +if ($ifvar != goodbye) +{ + echo hello != goodbye; +} + +let $ifvar= two words; +if ($ifvar == two words) +{ + echo two words; +} +if ($ifvar == `SELECT 'two words'`) +{ + echo two words are two words; +} +if (42) +{ + echo right answer; +} +if (0) +{ + echo wrong answer; +} +# Non-empty string treated as 'true' +if (`SELECT 'something'`) +{ + echo anything goes; +} +# Make sure 0 and string compare right +let $ifvar= 0; +if ($ifvar == string) +{ + echo 0 == string; +} +if ($ifvar != string) +{ + echo 0 != string; +} +--write_file $MYSQL_TMP_DIR/mysqltest.sql +let $var= 5; +if ($var >= four) +{ + echo 5>=four; +} +EOF +--error 1 +--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1 +remove_file $MYSQL_TMP_DIR/mysqltest.sql; + +--write_file $MYSQL_TMP_DIR/mysqltest.sql +let $var= 5; +if ($var ~= 6) +{ + echo 5~=6; +} +EOF +--error 1 +--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1 +remove_file $MYSQL_TMP_DIR/mysqltest.sql; + +--write_file $MYSQL_TMP_DIR/mysqltest.sql +let $var= text; +if (var == text) +{ + echo Oops I forgot the $; +} +EOF +--error 1 +--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1 +remove_file $MYSQL_TMP_DIR/mysqltest.sql; + +# ---------------------------------------------------------------------------- +# Test while with compare conditions +# ---------------------------------------------------------------------------- + +let $counter= 2; + +while ($counter < 5) +{ + echo counter is $counter; + inc $counter; +} +let $ifvar=; +while ($ifvar != stop) +{ + if ($counter >= 7) + { + let $ifvar= stop; + } + echo counter is $counter; + inc $counter; +} + # ---------------------------------------------------------------------------- # Test while, { and } # ---------------------------------------------------------------------------- @@ -2529,26 +2703,6 @@ rmdir $MYSQLTEST_VARDIR/tmp/testdir; --replace_result c:\\a.txt z SELECT 'c:\\a.txt' AS col; -# -# Bug#32307 mysqltest - does not detect illegal if syntax -# - -let $test= 1; -if ($test){ - echo hej; -} - ---write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql -if ($mysql_errno != 1436) -{ - echo ^ Should not be allowed! -} -EOF ---error 1 ---exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 -remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql; - - # ---------------------------------------------------------------------------- # Test that -- is not allowed as comment, only as mysqltest builtin command # ---------------------------------------------------------------------------- -- cgit v1.2.1 From bb356127a3f2095cebec63f50205682bdf765e64 Mon Sep 17 00:00:00 2001 From: Oystein Grovlen Date: Wed, 10 Nov 2010 15:48:29 +0100 Subject: Bug#57704 Cleanup code dies with void TABLE::set_keyread(bool): Assertion `file' failed. This bug was introduced in this revision: kostja@sun.com-20100727102553-b4n2ojcyfj79l2x7 ("A pre-requisite patch for the fix for Bug#52044.") It happens because close_thread_tables() is now called in open_and_lock_tables upon failure. Hence, table is no longer open when optimizer tries to do cleanup. Fix: Make sure to do cleanup in st_select_lex_unit::prepare() upon failure. This way, cleanup() is called before tables are released. mysql-test/r/subselect.result: Added test case for Bug#57704. mysql-test/t/subselect.test: Added test case for Bug#57704. sql/sql_union.cc: st_select_lex_unit::prepare(): On failure, make sure cleanup() is called. --- mysql-test/t/subselect.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 2e442e7f897..d4a995ee181 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -3946,3 +3946,21 @@ DROP TABLE t1,t2; --enable_result_log --echo End of 5.1 tests + +--echo # +--echo # Bug #57704: Cleanup code dies with void TABLE::set_keyread(bool): +--echo # Assertion `file' failed. +--echo # + +CREATE TABLE t1 (a INT); + +--error ER_OPERAND_COLUMNS +SELECT 1 FROM + (SELECT ROW( + (SELECT 1 FROM t1 RIGHT JOIN + (SELECT 1 FROM t1, t1 t2) AS d ON 1), + 1) FROM t1) AS e; + +DROP TABLE t1; + + -- cgit v1.2.1 From 871f36357e696d12cc4a360a8c36d7be61516ac6 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 11 Nov 2010 10:52:51 +0600 Subject: Fixed bug#54375 - Error in stored procedure leaves connection in different default schema. In strict mode, when data truncation or conversion happens, THD::killed is set to THD::KILL_BAD_DATA. This is abuse of KILL mechanism to guarantee that execution of statement is aborted. The stored procedures execution, on the other hand, upon detection that a connection was killed, would terminate immediately, without trying to restore the caller's context, in particular, restore the caller's current schema. The fix is, when terminating a stored procedure execution, to only bypass cleanup if the entire connection was killed, not in case of other forms of KILL. mysql-test/r/sp-bugs.result: Added result for a test case for bug#54375. mysql-test/t/sp-bugs.test: Added test case for bug#54375. sql/sp_head.cc: sp_head::execute modified: restore saved current db if connection is not killed. --- mysql-test/t/sp-bugs.test | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/sp-bugs.test b/mysql-test/t/sp-bugs.test index 8aa0791e265..fe52632c784 100644 --- a/mysql-test/t/sp-bugs.test +++ b/mysql-test/t/sp-bugs.test @@ -101,4 +101,41 @@ CALL p1 (); DROP TABLE t1; DROP PROCEDURE p1; +--echo # +--echo # Bug#54375: Error in stored procedure leaves connection +--echo # in different default schema +--echo # + +--disable_warnings +SET @@SQL_MODE = 'STRICT_ALL_TABLES'; +DROP DATABASE IF EXISTS db1; +CREATE DATABASE db1; +USE db1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 int NOT NULL PRIMARY KEY); +INSERT INTO t1 VALUES (1); +DELIMITER $$; +CREATE FUNCTION f1 ( + some_value int +) +RETURNS smallint +DETERMINISTIC +BEGIN + INSERT INTO t1 SET c1 = some_value; + RETURN(LAST_INSERT_ID()); +END$$ +DELIMITER ;$$ +DROP DATABASE IF EXISTS db2; +CREATE DATABASE db2; +--enable_warnings +USE db2; +SELECT DATABASE(); +--error ER_DUP_ENTRY +SELECT db1.f1(1); +SELECT DATABASE(); +USE test; +DROP FUNCTION db1.f1; +DROP TABLE db1.t1; +DROP DATABASE db1; +DROP DATABASE db2; --echo End of 5.1 tests -- cgit v1.2.1 From 1c37eaaabfca518fe9f39d477f3dbe572cd63dde Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Thu, 11 Nov 2010 07:34:14 +0000 Subject: Bug #49752: 2469.126.2 unintentionally breaks authentication against MySQL 5.1 server Server used to clip overly long user-names. This was presumably lost when code was made UTF8-clean. Now we emulate the behaviour for backward compatibility, but UTF8-ly correct. mysql-test/r/connect.result: Show that user-names that are too long get clipped now. mysql-test/t/connect.test: Show that user-names that are too long get clipped now. sql/sql_connect.cc: Clip user-name to 16 characters (not bytes). strings/CHARSET_INFO.txt: Clarify in docs. --- mysql-test/t/connect.test | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index 9a29e4ff861..d0b79ab6bd3 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -293,6 +293,34 @@ SET GLOBAL event_scheduler = OFF; --echo # -- End of Bug#35074. --echo + +########################################################################### + +--echo # +--echo # -- Bug#49752: 2469.126.2 unintentionally breaks authentication +--echo # against MySQL 5.1 server +--echo # + +GRANT ALL ON test.* TO 'Azundris12345678'@'localhost' IDENTIFIED BY 'test123'; + +FLUSH PRIVILEGES; + +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +connect (con1,localhost,Azundris123456789,test123,test); +disconnect con1; + +connection default; + +DROP USER 'Azundris12345678'@'localhost'; + +FLUSH PRIVILEGES; + +--echo # +--echo # -- End of Bug#49752 +--echo # + + + --echo # ------------------------------------------------------------------ --echo # -- End of 5.1 tests --echo # ------------------------------------------------------------------ -- cgit v1.2.1 From ddd6fbe553709c91d7d6b08620f45d789a046897 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 11 Nov 2010 11:08:53 +0300 Subject: Bug#57687 crash when reporting duplicate group_key error and utf8 Fixing DoS regression problem. Using "key_part->fieldnr - 1" to access the desired field is only correct in real INSERT queries. In case of inserting records into a temporary table when performing GROUP BY queries this expression does not work. Fix: Instead of accessing field_length and comparing it to key_part->length, there is an easier way to check if we're dealing with a prefix key: check key_part_flag against HA_PART_KEY_SEG flag. --- mysql-test/t/ctype_utf8.test | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 318bbdca0c7..5ce83a05f61 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1529,6 +1529,18 @@ DROP TABLE t1, t2; SET NAMES utf8; --source include/ctype_numconv.inc +--echo # +--echo # Bug#57687 crash when reporting duplicate group_key error and utf8 +--echo # Make sure to modify this when Bug#58081 is fixed. +--echo # +SET NAMES utf8; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0), (0), (1), (0), (0); +--error ER_DUP_ENTRY +SELECT COUNT(*) FROM t1, t1 t2 +GROUP BY INSERT('', t2.a, t1.a, (@@global.max_binlog_size)); +DROP TABLE t1; + --echo # --echo # End of 5.5 tests -- cgit v1.2.1 From ccbc24b45a79b6407487550fa19b40752d22fa7f Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Thu, 11 Nov 2010 09:46:49 +0000 Subject: Bug#55436: buffer overflow in debug binary of dbug_buff in Field_new_decimal::store_value There were some misunderstandings about parameters pertaining to buffer-size. Patches fixes the reported off by one and clarifies the documentation. mysql-test/r/type_newdecimal.result: add test mysql-test/t/type_newdecimal.test: add test sql/field.cc: adjust buffer size by one to account for terminator. sql/my_decimal.cc: adjust buffer size by one to account for terminator. clarify needs in comments. sql/my_decimal.h: clarify buffer-size needs to prevent future off-by-one bugs. strings/decimal.c: clarify buffer-size needs and parameters to prevent future off-by-one bugs --- mysql-test/t/type_newdecimal.test | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 2cf7ab8fbdf..31a8808da55 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -1510,5 +1510,19 @@ group by PAY.id + 1; DROP TABLE currencies, payments, sub_tasks; +--echo # +--echo # Bug#55436: buffer overflow in debug binary of dbug_buff in +--echo # Field_new_decimal::store_value +--echo # + +# this threw memory warnings on Windows. Also make sure future changes +# don't change these results, as per usual. +SET SQL_MODE=''; +CREATE TABLE t1(f1 DECIMAL(44,24)) ENGINE=MYISAM; +INSERT INTO t1 SET f1 = -64878E-85; +SELECT f1 FROM t1; +DROP TABLE IF EXISTS t1; + + --echo End of 5.1 tests -- cgit v1.2.1 From aa668865e271694e9b3ebbfe518cb4d0c2ad0c38 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 11 Nov 2010 13:25:23 +0300 Subject: Bug#57257 Replace(ExtractValue(...)) causes MySQL crash Bug#57820 extractvalue crashes Problem: ExtractValue and Replace crashed in some cases due to invalid handling of empty and NULL arguments. Per file comments: @mysql-test/r/ctype_ujis.result @mysql-test/r/xml.result @mysql-test/t/ctype_ujis.test @mysql-test/t/xml.test Adding tests @sql/item_strfunc.cc Make sure Item_func_replace::val_str safely handles empty strings. @sql/item_xmlfunc.cc set null_value if nodeset_func returned NULL, which is possible when the second argument is an unset user variable. --- mysql-test/t/ctype_ujis.test | 7 +++++++ mysql-test/t/xml.test | 11 +++++++++++ 2 files changed, 18 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test index 400f1301dd3..4c29a2e11a0 100644 --- a/mysql-test/t/ctype_ujis.test +++ b/mysql-test/t/ctype_ujis.test @@ -1209,6 +1209,13 @@ DROP PROCEDURE sp1; DROP TABLE t1; DROP TABLE t2; +--echo # +--echo # Bug#57257 Replace(ExtractValue(...)) causes MySQL crash +--echo # +SET NAMES utf8; +SELECT CONVERT(REPLACE(EXPORT_SET('a','a','a','','a'),'00','') USING ujis); + + set names default; set character_set_database=default; set character_set_server=default; diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test index 6e7d38cdfca..a8917fc9fe7 100644 --- a/mysql-test/t/xml.test +++ b/mysql-test/t/xml.test @@ -617,4 +617,15 @@ FROM t1 ORDER BY t1.id; DROP TABLE t1; +--echo # +--echo # Bug#57257 Replace(ExtractValue(...)) causes MySQL crash +--echo # +SET NAMES utf8; +SELECT REPLACE(EXTRACTVALUE('1', '/a'),'ds',''); + +--echo # +--echo # Bug #57820 extractvalue crashes +--echo # +SELECT AVG(DISTINCT EXTRACTVALUE((''),('$@k'))); + --echo End of 5.1 tests -- cgit v1.2.1 From c4fa6a3862dbb8009effc89997701e01de705411 Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Thu, 11 Nov 2010 11:35:48 +0000 Subject: Bug#43233: Some server variables are clipped during "update," not "check" stage Bug#55794: ulonglong options of mysqld show wrong values. Port the few remaining system variables to the correct mechanism -- range-check in check-stage (and throw error or warning at that point as needed and depending on STRICTness), update in update stage. Fix some signedness errors when retrieving sysvar values for display. mysql-test/r/variables.result: Show that we throw warnings or errors depending on strictness even for "special" variables now. mysql-test/t/variables.test: Show that we throw warnings or errors depending on strictness even for "special" variables now. sql/item_func.cc: show sys_var_ulonglong_ptr and SHOW_LONGLONG type variables as unsigned. sql/set_var.cc: move range-checking from update stage to check stage for the remaining few sys-vars that broke the pattern sql/set_var.h: add check functions. --- mysql-test/t/variables.test | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index d5929041e8a..1b411d9420c 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1255,4 +1255,45 @@ SET GLOBAL max_binlog_cache_size = @old_max_binlog_cache_size; SELECT @@skip_name_resolve; SHOW VARIABLES LIKE 'skip_name_resolve'; +--echo # +--echo # Bug #43233 : Some server variables are clipped during "update," +--echo # not "check" stage +--echo # + +SET @kbs=@@global.key_buffer_size; +SET @kcbs=@@global.key_cache_block_size; + +--echo throw errors in STRICT mode +SET SQL_MODE=STRICT_ALL_TABLES; + +# sys_var_ulonglong_ptr: sys_max_binlog_cache_size +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.max_binlog_cache_size=-1; + +# sys_var_thd_ha_rows: "max_join_size" et al. +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.max_join_size=0; + +# sys_var_key_buffer_size: "key_buffer_size" +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.key_buffer_size=0; + +# sys_var_key_cache_long: "key_cache_block_size" et al. +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.key_cache_block_size=0; + +--echo throw warnings in default mode +SET SQL_MODE=DEFAULT; + +SET @@global.max_binlog_cache_size=-1; +SET @@global.max_join_size=0; +SET @@global.key_buffer_size=0; +SET @@global.key_cache_block_size=0; + +# cleanup +SET @@global.max_binlog_cache_size=DEFAULT; +SET @@global.max_join_size=DEFAULT; +SET @@global.key_buffer_size=@kbs; +SET @@global.key_cache_block_size=@kcbs; + --echo End of 5.1 tests -- cgit v1.2.1 From 6bf6272fdabf78e62f04fbcafb1d1e7dee2b27c2 Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Thu, 11 Nov 2010 20:11:05 +0300 Subject: Patch that refactors global read lock implementation and fixes bug #57006 "Deadlock between HANDLER and FLUSH TABLES WITH READ LOCK" and bug #54673 "It takes too long to get readlock for 'FLUSH TABLES WITH READ LOCK'". The first bug manifested itself as a deadlock which occurred when a connection, which had some table open through HANDLER statement, tried to update some data through DML statement while another connection tried to execute FLUSH TABLES WITH READ LOCK concurrently. What happened was that FTWRL in the second connection managed to perform first step of GRL acquisition and thus blocked all upcoming DML. After that it started to wait for table open through HANDLER statement to be flushed. When the first connection tried to execute DML it has started to wait for GRL/the second connection creating deadlock. The second bug manifested itself as starvation of FLUSH TABLES WITH READ LOCK statements in cases when there was a constant stream of concurrent DML statements (in two or more connections). This has happened because requests for protection against GRL which were acquired by DML statements were ignoring presence of pending GRL and thus the latter was starved. This patch solves both these problems by re-implementing GRL using metadata locks. Similar to the old implementation acquisition of GRL in new implementation is two-step. During the first step we block all concurrent DML and DDL statements by acquiring global S metadata lock (each DML and DDL statement acquires global IX lock for its duration). During the second step we block commits by acquiring global S lock in COMMIT namespace (commit code acquires global IX lock in this namespace). Note that unlike in old implementation acquisition of protection against GRL in DML and DDL is semi-automatic. We assume that any statement which should be blocked by GRL will either open and acquires write-lock on tables or acquires metadata locks on objects it is going to modify. For any such statement global IX metadata lock is automatically acquired for its duration. The first problem is solved because waits for GRL become visible to deadlock detector in metadata locking subsystem and thus deadlocks like one in the first bug become impossible. The second problem is solved because global S locks which are used for GRL implementation are given preference over IX locks which are acquired by concurrent DML (and we can switch to fair scheduling in future if needed). Important change: FTWRL/GRL no longer blocks DML and DDL on temporary tables. Before this patch behavior was not consistent in this respect: in some cases DML/DDL statements on temporary tables were blocked while in others they were not. Since the main use cases for FTWRL are various forms of backups and temporary tables are not preserved during backups we have opted for consistently allowing DML/DDL on temporary tables during FTWRL/GRL. Important change: This patch changes thread state names which are used when DML/DDL of FTWRL is waiting for global read lock. It is now either "Waiting for global read lock" or "Waiting for commit lock" depending on the stage on which FTWRL is. Incompatible change: To solve deadlock in events code which was exposed by this patch we have to replace LOCK_event_metadata mutex with metadata locks on events. As result we have to prohibit DDL on events under LOCK TABLES. This patch also adds extensive test coverage for interaction of DML/DDL and FTWRL. Performance of new and old global read lock implementations in sysbench tests were compared. There were no significant difference between new and old implementations. mysql-test/include/check_ftwrl_compatible.inc: Added helper script which allows to check that a statement is compatible with FLUSH TABLES WITH READ LOCK. mysql-test/include/check_ftwrl_incompatible.inc: Added helper script which allows to check that a statement is incompatible with FLUSH TABLES WITH READ LOCK. mysql-test/include/handler.inc: Adjusted test case to the fact that now DROP TABLE closes open HANDLERs for the table to be dropped before checking if there active FTWRL in this connection. mysql-test/include/wait_show_condition.inc: Fixed small error in the timeout message. The correct name of variable used as parameter for this script is "$condition" and not "$wait_condition". mysql-test/r/delayed.result: Added test coverage for scenario which triggered assert in metadata locking subsystem. mysql-test/r/events_2.result: Updated test results after prohibiting event DDL operations under LOCK TABLES. mysql-test/r/flush.result: Added test coverage for bug #57006 "Deadlock between HANDLER and FLUSH TABLES WITH READ LOCK". mysql-test/r/flush_read_lock.result: Added test coverage for various aspects of FLUSH TABLES WITH READ LOCK functionality. mysql-test/r/flush_read_lock_kill.result: Adjusted test case after replacing custom global read lock implementation with one based on metadata locks. Use new debug_sync point. Do not disable concurrent inserts as now InnoDB we always use InnoDB table. mysql-test/r/handler_innodb.result: Adjusted test case to the fact that now DROP TABLE closes open HANDLERs for the table to be dropped before checking if there active FTWRL in this connection. mysql-test/r/handler_myisam.result: Adjusted test case to the fact that now DROP TABLE closes open HANDLERs for the table to be dropped before checking if there active FTWRL in this connection. mysql-test/r/mdl_sync.result: Adjusted test case after replacing custom global read lock implementation with one based on metadata locks. Replaced usage of GRL-specific debug_sync's with appropriate sync points in MDL subsystem. mysql-test/suite/perfschema/r/dml_setup_instruments.result: Updated test results after removing global COND_global_read_lock condition variable. mysql-test/suite/perfschema/r/func_file_io.result: Ensure that this test doesn't affect subsequent tests. At the end of its execution enable back P_S instrumentation which this test disables at some point. mysql-test/suite/perfschema/r/func_mutex.result: Ensure that this test doesn't affect subsequent tests. At the end of its execution enable back P_S instrumentation which this test disables at some point. mysql-test/suite/perfschema/r/global_read_lock.result: Adjusted test case to take into account that new GRL implementation is based on MDL. mysql-test/suite/perfschema/r/server_init.result: Adjusted test case after replacing custom global read lock implementation with one based on MDL and replacing LOCK_event_metadata mutex with metadata lock. mysql-test/suite/perfschema/t/func_file_io.test: Ensure that this test doesn't affect subsequent tests. At the end of its execution enable back P_S instrumentation which this test disables at some point. mysql-test/suite/perfschema/t/func_mutex.test: Ensure that this test doesn't affect subsequent tests. At the end of its execution enable back P_S instrumentation which this test disables at some point. mysql-test/suite/perfschema/t/global_read_lock.test: Adjusted test case to take into account that new GRL implementation is based on MDL. mysql-test/suite/perfschema/t/server_init.test: Adjusted test case after replacing custom global read lock implementation with one based on MDL and replacing LOCK_event_metadata mutex with metadata lock. mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result: Updated test results after prohibiting event DDL under LOCK TABLES. mysql-test/t/delayed.test: Added test coverage for scenario which triggered assert in metadata locking subsystem. mysql-test/t/events_2.test: Updated test case after prohibiting event DDL operations under LOCK TABLES. mysql-test/t/flush.test: Added test coverage for bug #57006 "Deadlock between HANDLER and FLUSH TABLES WITH READ LOCK". mysql-test/t/flush_block_commit.test: Adjusted test case after changing thread state name which is used when COMMIT waits for FLUSH TABLES WITH READ LOCK from "Waiting for release of readlock" to "Waiting for commit lock". mysql-test/t/flush_block_commit_notembedded.test: Adjusted test case after changing thread state name which is used when DML waits for FLUSH TABLES WITH READ LOCK. Now we use "Waiting for global read lock" in this case. mysql-test/t/flush_read_lock.test: Added test coverage for various aspects of FLUSH TABLES WITH READ LOCK functionality. mysql-test/t/flush_read_lock_kill-master.opt: We no longer need to use make_global_read_lock_block_commit_loop debug tag in this test. Instead we rely on an appropriate debug_sync point in MDL code. mysql-test/t/flush_read_lock_kill.test: Adjusted test case after replacing custom global read lock implementation with one based on metadata locks. Use new debug_sync point. Do not disable concurrent inserts as now InnoDB we always use InnoDB table. mysql-test/t/lock_multi.test: Adjusted test case after changing thread state names which are used when DML or DDL waits for FLUSH TABLES WITH READ LOCK to "Waiting for global read lock". mysql-test/t/mdl_sync.test: Adjusted test case after replacing custom global read lock implementation with one based on metadata locks. Replaced usage of GRL-specific debug_sync's with appropriate sync points in MDL subsystem. Updated thread state names which are used when DDL waits for FTWRL. mysql-test/t/trigger_notembedded.test: Adjusted test case after changing thread state names which are used when DML or DDL waits for FLUSH TABLES WITH READ LOCK to "Waiting for global read lock". sql/event_data_objects.cc: Removed Event_queue_element::status/last_executed_changed members and Event_queue_element::update_timing_fields() method. We no longer use this class for updating mysql.events once event is chosen for execution. Accesses to instances of this class in scheduler thread require protection by Event_queue::LOCK_event_queue mutex and we try to avoid updating table while holding this lock. sql/event_data_objects.h: Removed Event_queue_element::status/last_executed_changed members and Event_queue_element::update_timing_fields() method. We no longer use this class for updating mysql.events once event is chosen for execution. Accesses to instances of this class in scheduler thread require protection by Event_queue::LOCK_event_queue mutex and we try to avoid updating table while holding this lock. sql/event_db_repository.cc: - Changed Event_db_repository methods to not release all metadata locks once they are done updating mysql.events table. This allows to keep metadata lock protecting against GRL and lock protecting particular event around until corresponding DDL statement is written to the binary log. - Removed logic for conditional update of "status" and "last_executed" fields from update_timing_fields_for_event() method. In the only case when this method is called now "last_executed" is always modified and tracking change of "status" is too much hassle. sql/event_db_repository.h: Removed logic for conditional update of "status" and "last_executed" fields from Event_db_repository:: update_timing_fields_for_event() method. In the only case when this method is called now "last_executed" is always modified and tracking change of "status" field is too much hassle. sql/event_queue.cc: Changed event scheduler code not to update mysql.events table while holding Event_queue::LOCK_event_queue mutex. Doing so led to a deadlock with a new GRL implementation. This deadlock didn't occur with old implementation due to fact that code acquiring protection against GRL ignored pending GRL requests (which lead to GRL starvation). One of goals of new implementation is to disallow GRL starvation and so we have to solve problem with this deadlock in a different way. sql/events.cc: Changed methods of Events class to acquire protection against GRL while perfoming DDL statement and keep it until statement is written to the binary log. Unfortunately this step together with new GRL implementation exposed deadlock involving Events::LOCK_event_metadata and GRL. To solve it Events::LOCK_event_metadata mutex was replaced with a metadata lock on event. As a side-effect events DDL has to be prohibited under LOCK TABLES even in cases when mysql.events table was explicitly locked for write. sql/events.h: Replaced Events::LOCK_event_metadata mutex with a metadata lock on event. sql/ha_ndbcluster.cc: Updated code after replacing custom global read lock implementation with one based on MDL. Since MDL subsystem should now be able to detect deadlocks involving metadata locks and GRL there is no need for special handling of active GRL. sql/handler.cc: Replaced custom implementation of global read lock with one based on metadata locks. Consequently when doing commit instead of calling method of Global_read_lock class to acquire protection against GRL we simply acquire IX in COMMIT namespace. sql/lock.cc: Replaced custom implementation of global read lock with one based on metadata locks. This step allows to expose wait for GRL to deadlock detector of MDL subsystem and thus succesfully resolve deadlocks similar to one behind bug #57006 "Deadlock between HANDLER and FLUSH TABLES WITH READ LOCK". It also solves problem with GRL starvation described in bug #54673 "It takes too long to get readlock for 'FLUSH TABLES WITH READ LOCK'" since metadata locks used by GRL give preference to FTWRL statement instead of DML statements (if needed in future this can be changed to fair scheduling). Similar to old implementation of acquisition of GRL is two-step. During the first step we block all concurrent DML and DDL statements by acquiring global S metadata lock (each DML and DDL statement acquires global IX lock for its duration). During the second step we block commits by acquiring global S lock in COMMIT namespace (commit code acquires global IX lock in this namespace). Note that unlike in old implementation acquisition of protection against GRL in DML and DDL is semi-automatic. We assume that any statement which should be blocked by GRL will either open and acquires write-lock on tables or acquires metadata locks on objects it is going to modify. For any such statement global IX metadata lock is automatically acquired for its duration. To support this change: - Global_read_lock::lock/unlock_global_read_lock and make_global_read_lock_block_commit methods were changed accordingly. - Global_read_lock::wait_if_global_read_lock() and start_waiting_global_read_lock() methods were dropped. It is now responsibility of code acquiring metadata locks opening tables to acquire protection against GRL by explicitly taking global IX lock with statement duration. - Global variables, mutex and condition variable used by old implementation was removed. - lock_routine_name() was changed to use statement duration for its global IX lock. It was also renamed to lock_object_name() as it now also used to take metadata locks on events. - Global_read_lock::set_explicit_lock_duration() was added which allows not to release locks used for GRL when leaving prelocked mode. sql/lock.h: - Renamed lock_routine_name() to lock_object_name() and changed its signature to allow its usage for events. - Removed broadcast_refresh() function. It is no longer needed with new GRL implementation. sql/log_event.cc: Release metadata locks with statement duration at the end of processing legacy event for LOAD DATA. This ensures that replication thread processing such event properly releases its protection against global read lock. sql/mdl.cc: Changed MDL subsystem to support new MDL-based implementation of global read lock. Added COMMIT and EVENTS namespaces for metadata locks. Changed thread state name for GLOBAL namespace to "Waiting for global read lock". Optimized MDL_map::find_or_insert() method to avoid taking m_mutex mutex when looking up MDL_lock objects for GLOBAL or COMMIT namespaces. We keep pre-created MDL_lock objects for these namespaces around and simply return pointers to these global objects when needed. Changed MDL_lock/MDL_scoped_lock to properly handle notification of insert delayed handler threads when FTWRL takes global S lock. Introduced concept of lock duration. In addition to locks with transaction duration which work in the way which is similar to how locks worked before (i.e. they are released at the end of transaction), locks with statement and explicit duration were introduced. Locks with statement duration are automatically released at the end of statement. Locks with explicit duration require explicit release and obsolete concept of transactional sentinel. * Changed MDL_request and MDL_ticket classes to support notion of duration. * Changed MDL_context to keep locks with different duration in different lists. Changed code handling ticket list to take this into account. * Changed methods responsible for releasing locks to take into account duration of tickets. Particularly public MDL_context::release_lock() method now only can release tickets with explicit duration (there is still internal method which allows to specify duration). To release locks with statement or transaction duration one have to use release_statement/transactional_locks() methods. * Concept of savepoint for MDL subsystem now has to take into account locks with statement duration. Consequently MDL_savepoint class was introduced and methods working with savepoints were updated accordingly. * Added methods which allow to set duration for one or all locks in the context. sql/mdl.h: Changed MDL subsystem to support new MDL-based implementation of global read lock. Added COMMIT and EVENTS namespaces for metadata locks. Introduced concept of lock duration. In addition to locks with transaction duration which work in the way which is similar to how locks worked before (i.e. they are released at the end of transaction), locks with statement and explicit duration were introduced. Locks with statement duration are automatically released at the end of statement. Locks with explicit duration require explicit release and obsolete concept of transactional sentinel. * Changed MDL_request and MDL_ticket classes to support notion of duration. * Changed MDL_context to keep locks with different duration in different lists. Changed code handling ticket list to take this into account. * Changed methods responsible for releasing locks to take into account duration of tickets. Particularly public MDL_context::release_lock() method now only can release tickets with explicit duration (there is still internal method which allows to specify duration). To release locks with statement or transaction duration one have to use release_statement/transactional_locks() methods. * Concept of savepoint for MDL subsystem now has to take into account locks with statement duration. Consequently MDL_savepoint class was introduced and methods working with savepoints were updated accordingly. * Added methods which allow to set duration for one or all locks in the context. sql/mysqld.cc: Removed global mutex and condition variables which were used by old implementation of GRL. Also we no longer need to initialize Events::LOCK_event_metadata mutex as it was replaced with metadata locks on events. sql/mysqld.h: Removed global variable, mutex and condition variables which were used by old implementation of GRL. sql/rpl_rli.cc: When slave thread closes tables which were open for handling of RBR events ensure that it releases global IX lock which was acquired as protection against GRL. sql/sp.cc: Adjusted code to the new signature of lock_object/routine_name(), to the fact that one now needs specify duration of lock when initializing MDL_request and to the fact that savepoints for MDL subsystem are now represented by MDL_savepoint class. sql/sp_head.cc: Ensure that statements in stored procedures release statement metadata locks and thus release their protectiong against GRL in proper moment in time. Adjusted code to the fact that one now needs specify duration of lock when initializing MDL_request. sql/sql_admin.cc: Adjusted code to the fact that one now needs specify duration of lock when initializing MDL_request. sql/sql_base.cc: - Implemented support for new approach to acquiring protection against global read lock. We no longer acquire such protection explicitly on the basis of statement flags. Instead we always rely on code which is responsible for acquiring metadata locks on object to be changed acquiring this protection. This is achieved by acquiring global IX metadata lock with statement duration. Code doing this also responsible for checking that current connection has no active GRL by calling an Global_read_lock::can_acquire_protection() method. Changed code in open_table() and lock_table_names() accordingly. Note that as result of this change DDL and DML on temporary tables is always compatible with GRL (before it was incompatible in some cases and compatible in other cases). - To speed-up code acquiring protection against GRL introduced m_has_protection_against_grl member in Open_table_context class. It indicates that protection was already acquired sometime during open_tables() execution and new attempts can be skipped. - Thanks to new GRL implementation calls to broadcast_refresh() became unnecessary and were removed. - Adjusted code to the fact that one now needs specify duration of lock when initializing MDL_request and to the fact that savepoints for MDL subsystem are now represented by MDL_savepoint class. sql/sql_base.h: Adjusted code to the fact that savepoints for MDL subsystem are now represented by MDL_savepoint class. Also introduced Open_table_context::m_has_protection_against_grl member which allows to avoid acquiring protection against GRL while opening tables if such protection was already acquired. sql/sql_class.cc: Changed THD::leave_locked_tables_mode() after transactional sentinel for metadata locks was obsoleted by introduction of locks with explicit duration. sql/sql_class.h: - Adjusted code to the fact that savepoints for MDL subsystem are now represented by MDL_savepoint class. - Changed Global_read_lock class according to changes in global read lock implementation: * wait_if_global_read_lock and start_waiting_global_read_lock are now gone. Instead code needing protection against GRL has to acquire global IX metadata lock with statement duration itself. To help it new can_acquire_protection() was introduced. Also as result of the above change m_protection_count member is gone too. * Added m_mdl_blocks_commits_lock member to store metadata lock blocking commits. * Adjusted code to the fact that concept of transactional sentinel was obsoleted by concept of lock duration. - Removed CF_PROTECT_AGAINST_GRL flag as it is no longer necessary. New GRL implementation acquires protection against global read lock automagically when statement acquires metadata locks on tables or other objects it is going to change. sql/sql_db.cc: Adjusted code to the fact that one now needs specify duration of lock when initializing MDL_request. sql/sql_handler.cc: Removed call to broadcast_refresh() function. It is no longer needed with new GRL implementation. Adjusted code after introducing duration concept for metadata locks. Particularly to the fact transactional sentinel was replaced with explicit duration. sql/sql_handler.h: Renamed mysql_ha_move_tickets_after_trans_sentinel() to mysql_ha_set_explicit_lock_duration() after transactional sentinel was obsoleted by locks with explicit duration. sql/sql_insert.cc: Adjusted code handling delaying inserts after switching to new GRL implementation. Now connection thread initiating delayed insert has to acquire global IX lock in addition to metadata lock on table being inserted into. This IX lock protects against GRL and similarly to SW lock on table being inserted into has to be passed to handler thread in order to avoid deadlocks. sql/sql_lex.cc: LEX::protect_against_global_read_lock member is no longer necessary since protection against GRL is automatically taken by code acquiring metadata locks/opening tables. sql/sql_lex.h: LEX::protect_against_global_read_lock member is no longer necessary since protection against GRL is automatically taken by code acquiring metadata locks/opening tables. sql/sql_parse.cc: - Implemented support for new approach to acquiring protection against global read lock. We no longer acquire such protection explicitly on the basis of statement flags. Instead we always rely on code which is responsible for acquiring metadata locks on object to be changed acquiring this protection. This is achieved by acquiring global IX metadata lock with statement duration. This lock is automatically released at the end of statement execution. - Changed implementation of CREATE/DROP PROCEDURE/FUNCTION not to release metadata locks and thus protection against of GRL in the middle of statement execution. - Adjusted code to the fact that one now needs specify duration of lock when initializing MDL_request and to the fact that savepoints for MDL subsystem are now represented by MDL_savepoint class. sql/sql_prepare.cc: Adjusted code to the to the fact that savepoints for MDL subsystem are now represented by MDL_savepoint class. sql/sql_rename.cc: With new GRL implementation there is no need to explicitly acquire protection against GRL before renaming tables. This happens automatically in code which acquires metadata locks on tables being renamed. sql/sql_show.cc: Adjusted code to the fact that one now needs specify duration of lock when initializing MDL_request and to the fact that savepoints for MDL subsystem are now represented by MDL_savepoint class. sql/sql_table.cc: - With new GRL implementation there is no need to explicitly acquire protection against GRL before dropping tables. This happens automatically in code which acquires metadata locks on tables being dropped. - Changed mysql_alter_table() not to release lock on new table name explicitly and to rely on automatic release of locks at the end of statement instead. This was necessary since now MDL_context::release_lock() is supported only for locks for explicit duration. sql/sql_trigger.cc: With new GRL implementation there is no need to explicitly acquire protection against GRL before changing table triggers. This happens automatically in code which acquires metadata locks on tables which triggers are to be changed. sql/sql_update.cc: Fix bug exposed by GRL testing. During prepare phase acquire only S metadata locks instead of SW locks to keep prepare of multi-UPDATE compatible with concurrent LOCK TABLES WRITE and global read lock. sql/sql_view.cc: With new GRL implementation there is no need to explicitly acquire protection against GRL before creating view. This happens automatically in code which acquires metadata lock on view to be created. sql/sql_yacc.yy: LEX::protect_against_global_read_lock member is no longer necessary since protection against GRL is automatically taken by code acquiring metadata locks/opening tables. sql/table.cc: Adjusted code to the fact that one now needs specify duration of lock when initializing MDL_request. sql/table.h: Adjusted code to the fact that one now needs specify duration of lock when initializing MDL_request. sql/transaction.cc: Replaced custom implementation of global read lock with one based on metadata locks. Consequently when doing commit instead of calling method of Global_read_lock class to acquire protection against GRL we simply acquire IX in COMMIT namespace. Also adjusted code to the fact that MDL savepoint is now represented by MDL_savepoint class. --- mysql-test/t/delayed.test | 15 + mysql-test/t/events_2.test | 46 +- mysql-test/t/flush.test | 67 + mysql-test/t/flush_block_commit.test | 2 +- mysql-test/t/flush_block_commit_notembedded.test | 2 +- mysql-test/t/flush_read_lock.test | 2187 ++++++++++++++++++++++ mysql-test/t/flush_read_lock_kill-master.opt | 1 - mysql-test/t/flush_read_lock_kill.test | 68 +- mysql-test/t/lock_multi.test | 58 +- mysql-test/t/mdl_sync.test | 15 +- mysql-test/t/trigger_notembedded.test | 2 +- 11 files changed, 2382 insertions(+), 81 deletions(-) create mode 100644 mysql-test/t/flush_read_lock.test delete mode 100644 mysql-test/t/flush_read_lock_kill-master.opt (limited to 'mysql-test/t') diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 3a2bc982ad3..c47db78a11b 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -539,6 +539,21 @@ connection con1; --echo # Reaping: INSERT DELAYED INTO t1 VALUES (5) --reap +--echo # Connection default +connection default; + +--echo # Test 5: LOCK TABLES + INSERT DELAYED in one connection. +--echo # This test has triggered some asserts in metadata locking +--echo # subsystem at some point in time.. +LOCK TABLE t1 WRITE; +INSERT DELAYED INTO t2 VALUES (7); +UNLOCK TABLES; +SET AUTOCOMMIT= 0; +LOCK TABLE t1 WRITE; +INSERT DELAYED INTO t2 VALUES (8); +UNLOCK TABLES; +SET AUTOCOMMIT= 1; + --echo # Connection con2 connection con2; disconnect con2; diff --git a/mysql-test/t/events_2.test b/mysql-test/t/events_2.test index 08412d2f5b0..3d609654b21 100644 --- a/mysql-test/t/events_2.test +++ b/mysql-test/t/events_2.test @@ -212,15 +212,15 @@ lock table t1 read; --replace_regex /STARTS '[^']+'/STARTS '#'/ show create event e1; select event_name from information_schema.events; ---error ER_TABLE_NOT_LOCKED +--error ER_LOCK_OR_ACTIVE_TRANSACTION create event e2 on schedule every 10 hour do select 1; ---error ER_TABLE_NOT_LOCKED +--error ER_LOCK_OR_ACTIVE_TRANSACTION alter event e2 disable; ---error ER_TABLE_NOT_LOCKED +--error ER_LOCK_OR_ACTIVE_TRANSACTION alter event e2 rename to e3; ---error ER_TABLE_NOT_LOCKED +--error ER_LOCK_OR_ACTIVE_TRANSACTION drop event e2; ---error ER_TABLE_NOT_LOCKED +--error ER_LOCK_OR_ACTIVE_TRANSACTION drop event e1; unlock tables; # @@ -229,15 +229,15 @@ lock table t1 write; --replace_regex /STARTS '[^']+'/STARTS '#'/ show create event e1; select event_name from information_schema.events; ---error ER_TABLE_NOT_LOCKED +--error ER_LOCK_OR_ACTIVE_TRANSACTION create event e2 on schedule every 10 hour do select 1; ---error ER_TABLE_NOT_LOCKED +--error ER_LOCK_OR_ACTIVE_TRANSACTION alter event e2 disable; ---error ER_TABLE_NOT_LOCKED +--error ER_LOCK_OR_ACTIVE_TRANSACTION alter event e2 rename to e3; ---error ER_TABLE_NOT_LOCKED +--error ER_LOCK_OR_ACTIVE_TRANSACTION drop event e2; ---error ER_TABLE_NOT_LOCKED +--error ER_LOCK_OR_ACTIVE_TRANSACTION drop event e1; unlock tables; # @@ -246,15 +246,15 @@ lock table t1 read, mysql.event read; --replace_regex /STARTS '[^']+'/STARTS '#'/ show create event e1; select event_name from information_schema.events; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE +--error ER_LOCK_OR_ACTIVE_TRANSACTION create event e2 on schedule every 10 hour do select 1; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE +--error ER_LOCK_OR_ACTIVE_TRANSACTION alter event e2 disable; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE +--error ER_LOCK_OR_ACTIVE_TRANSACTION alter event e2 rename to e3; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE +--error ER_LOCK_OR_ACTIVE_TRANSACTION drop event e2; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE +--error ER_LOCK_OR_ACTIVE_TRANSACTION drop event e1; unlock tables; # @@ -263,15 +263,15 @@ lock table t1 write, mysql.event read; --replace_regex /STARTS '[^']+'/STARTS '#'/ show create event e1; select event_name from information_schema.events; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE +--error ER_LOCK_OR_ACTIVE_TRANSACTION create event e2 on schedule every 10 hour do select 1; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE +--error ER_LOCK_OR_ACTIVE_TRANSACTION alter event e2 disable; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE +--error ER_LOCK_OR_ACTIVE_TRANSACTION alter event e2 rename to e3; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE +--error ER_LOCK_OR_ACTIVE_TRANSACTION drop event e2; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE +--error ER_LOCK_OR_ACTIVE_TRANSACTION drop event e1; unlock tables; # @@ -285,12 +285,18 @@ lock table mysql.event write; --replace_regex /STARTS '[^']+'/STARTS '#'/ show create event e1; select event_name from information_schema.events; +--error ER_LOCK_OR_ACTIVE_TRANSACTION create event e2 on schedule every 10 hour do select 1; +--error ER_LOCK_OR_ACTIVE_TRANSACTION alter event e2 disable; +--error ER_LOCK_OR_ACTIVE_TRANSACTION alter event e2 rename to e3; +--error ER_LOCK_OR_ACTIVE_TRANSACTION drop event e3; +--error ER_LOCK_OR_ACTIVE_TRANSACTION drop event e1; unlock tables; +drop event e1; --echo Make sure we have left no events select event_name from information_schema.events; --echo diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index 1cafbe3e6bd..944c9c43019 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -577,3 +577,70 @@ select * from t1; select * from t2; unlock tables; drop tables tm, t1, t2; + + +--echo # +--echo # Test for bug #57006 "Deadlock between HANDLER and +--echo # FLUSH TABLES WITH READ LOCK". +--echo # +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +connection default; +create table t1 (i int); +create table t2 (i int); +handler t1 open; + +--echo # Switching to connection 'con1'. +connection con1; +--echo # Sending: +--send flush tables with read lock + +--echo # Switching to connection 'con2'. +connection con2; +--echo # Wait until FTWRL starts waiting for 't1' to be closed. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table flush" + and info = "flush tables with read lock"; +--source include/wait_condition.inc + +--echo # Switching to connection 'default'. +connection default; +--echo # The below statement should not cause deadlock. +--echo # Sending: +--send insert into t2 values (1) + +--echo # Switching to connection 'con2'. +connection con2; +--echo # Wait until INSERT starts to wait for FTWRL to go away. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for global read lock" + and info = "insert into t2 values (1)"; +--source include/wait_condition.inc + +--echo # Switching to connection 'con1'. +connection con1; +--echo # FTWRL should be able to continue now. +--echo # Reap FTWRL. +--reap +unlock tables; + +--echo # Switching to connection 'default'. +connection default; +--echo # Reap INSERT. +--reap +handler t1 close; + +--echo # Cleanup. +connection con1; +disconnect con1; +--source include/wait_until_disconnected.inc +connection con2; +disconnect con2; +--source include/wait_until_disconnected.inc +connection default; +drop tables t1, t2; diff --git a/mysql-test/t/flush_block_commit.test b/mysql-test/t/flush_block_commit.test index 0b3bede1684..90443dc9242 100644 --- a/mysql-test/t/flush_block_commit.test +++ b/mysql-test/t/flush_block_commit.test @@ -39,7 +39,7 @@ connection con2; --echo # Wait until COMMIT gets blocked. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for release of readlock" and info = "COMMIT"; + where state = "Waiting for commit lock" and info = "COMMIT"; --source include/wait_condition.inc --echo # Verify that 'con1' was blocked and data did not move. SELECT * FROM t1; diff --git a/mysql-test/t/flush_block_commit_notembedded.test b/mysql-test/t/flush_block_commit_notembedded.test index 7e3f4838ffb..fe9dbf7c19e 100644 --- a/mysql-test/t/flush_block_commit_notembedded.test +++ b/mysql-test/t/flush_block_commit_notembedded.test @@ -53,7 +53,7 @@ begin; connection con1; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for release of readlock" and + where state = "Waiting for global read lock" and info = "insert into t1 values (1)"; --source include/wait_condition.inc unlock tables; diff --git a/mysql-test/t/flush_read_lock.test b/mysql-test/t/flush_read_lock.test new file mode 100644 index 00000000000..b234d941e6e --- /dev/null +++ b/mysql-test/t/flush_read_lock.test @@ -0,0 +1,2187 @@ +# +# Test coverage for various aspects of FLUSH TABLES WITH READ LOCK +# functionality. +# + +# We need InnoDB for COMMIT/ROLLBACK related tests. +--source include/have_innodb.inc +# We need the Debug Sync Facility. +--source include/have_debug_sync.inc +# Save the initial number of concurrent sessions. +--source include/count_sessions.inc + +--echo # FTWRL takes two global metadata locks -- a global shared +--echo # metadata lock and the commit blocker lock. +--echo # The first lock prevents DDL from taking place. +--echo # Let's say that all DDL statements that take metadata +--echo # locks form class #1 -- incompatible with FTWRL because +--echo # take incompatible MDL table locks. +--echo # The first global lock doesn't, however, prevent standalone +--echo # COMMITs (or implicit COMMITs) from taking place, since a +--echo # COMMIT doesn't take table locks. It doesn't prevent +--echo # DDL on temporary tables either, since they don't +--echo # take any table locks either. +--echo # Most DDL statements do not perform an implicit commit +--echo # if operate on a temporary table. Examples are CREATE +--echo # TEMPORARY TABLE and DROP TEMPORARY TABLE. +--echo # Thus, these DDL statements can go through in presence +--echo # of FTWRL. This is class #2 -- compatible because +--echo # do not take incompatible MDL locks and do not issue +--echo # implicit commit.. +--echo # (Although these operations do not commit, their effects +--echo # cannot be rolled back either.) +--echo # ALTER TABLE, ANALYZE, OPTIMIZE and some others always +--echo # issue an implicit commit, even if its argument is a +--echo # temporary table. +--echo # *Howewer* an implicit commit is a no-op if all engines +--echo # used since the start of transactiona are non- +--echo # transactional. Thus, for non-transactional engines, +--echo # these operations are not blocked by FTWRL. +--echo # This is class #3 -- compatible because do not take +--echo # MDL table locks and are non-transactional. +--echo # On the contrary, for transactional engines, there +--echo # is always a commit, regardless of whether a table +--echo # is temporary or not. Thus, for example, ALTER TABLE +--echo # for a transactional engine will wait for FTWRL, +--echo # even if the subject table is temporary. +--echo # Thus ALTER TABLE is incompatible +--echo # with FTWRL. This is class #4 -- incompatible +--echo # becuase issue implicit COMMIT which is not a no-op. +--echo # Finally, there are administrative statements (such as +--echo # RESET SLAVE) that do not take any locks and do not +--echo # issue COMMIT. +--echo # This is class #5. +--echo # The goal of this coverage is to test statements +--echo # of all classes. +--echo # @todo: documents the effects of @@autocommit, +--echo # DML and temporary transactional tables. + +--echo # Use MyISAM engine for the most of the tables +--echo # used in this test in order to be able to +--echo # check that DDL statements on temporary tables +--echo # are compatible with FTRWL. +--disable_warnings +drop tables if exists t1_base, t2_base, t3_trans; +drop tables if exists tm_base, tm_base_temp; +drop database if exists mysqltest1; +--echo # We're going to test ALTER DATABASE UPGRADE +drop database if exists `#mysql50#mysqltest-2`; +drop procedure if exists p1; +drop function if exists f1; +drop view if exists v1; +drop procedure if exists p2; +drop function if exists f2_base; +drop function if exists f2_temp; +drop event if exists e1; +drop event if exists e2; +--enable_warnings +create table t1_base(i int) engine=myisam; +create table t2_base(j int) engine=myisam; +create table t3_trans(i int) engine=innodb; +create temporary table t1_temp(i int) engine=myisam; +create temporary table t2_temp(j int) engine=myisam; +create temporary table t3_temp_trans(i int) engine=innodb; +create database mysqltest1; +create database `#mysql50#mysqltest-2`; +create procedure p1() begin end; +create function f1() returns int return 0; +create view v1 as select 1 as i; +create procedure p2(i int) begin end; +delimiter |; +create function f2_base() returns int +begin + insert into t1_base values (1); + return 0; +end| +create function f2_temp() returns int +begin + insert into t1_temp values (1); + return 0; +end| +delimiter ;| +create event e1 on schedule every 1 minute do begin end; + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +connect (con3,localhost,root,,); +connection default; + +--echo # +--echo # Test compatibility of FLUSH TABLES WITH READ LOCK +--echo # with various statements. +--echo # +--echo # These tests don't cover some classes of statements: +--echo # - Replication-related - CHANGE MASTER TO, START/STOP SLAVE and etc +--echo # (all compatible with FTWRL). +--echo # - Plugin-related - INSTALL/UNINSTALL (incompatible with FTWRL, +--echo # require plugin support). + +let $con_aux1=con1; +let $con_aux2=con2; +let $cleanup_stmt2= ; +let $skip_3rd_check= ; + +--echo # +--echo # 1) ALTER variants. +--echo # +--echo # 1.1) ALTER TABLE +--echo # +--echo # 1.1.a) For base table should be incompatible with FTWRL. +--echo # +let $statement= alter table t1_base add column c1 int; +let $cleanup_stmt1= alter table t1_base drop column c1; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 1.1.b) For a temporary table should be compatible with FTWRL. +--echo # +let $statement= alter table t1_temp add column c1 int; +let $cleanup_stmt= alter table t1_temp drop column c1; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 1.2) ALTER DATABASE should be incompatible with FTWRL. +--echo # +let $statement= alter database mysqltest1 default character set utf8; +let $cleanup_stmt1= alter database mysqltest1 default character set latin1; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 1.3) ALTER DATABASE UPGRADE DATA DIRECTORY NAME should be +--echo # incompatible with FTWRL. +--echo # +let $statement= alter database `#mysql50#mysqltest-2` upgrade data directory name; +let $cleanup_stmt1= drop database `mysqltest-2`; +let $cleanup_stmt2= create database `#mysql50#mysqltest-2`; +--source include/check_ftwrl_incompatible.inc +let $cleanup_stmt2= ; + +--echo # +--echo # 1.4) ALTER PROCEDURE should be incompatible with FTWRL. +--echo # +let $statement= alter procedure p1 comment 'a'; +let $cleanup_stmt1= alter procedure p1 comment ''; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 1.5) ALTER FUNCTION should be incompatible with FTWRL. +--echo # +let $statement= alter function f1 comment 'a'; +let $cleanup_stmt1= alter function f1 comment ''; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 1.6) ALTER VIEW should be incompatible with FTWRL. +--echo # +let $statement= alter view v1 as select 2 as j; +let $cleanup_stmt1= alter view v1 as select 1 as i; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 1.7) ALTER EVENT should be incompatible with FTWRL. +--echo # +let $statement= alter event e1 comment 'test'; +let $cleanup_stmt1= alter event e1 comment ''; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 1.x) The rest of ALTER statements (ALTER TABLESPACE, +--echo # ALTER LOGFILE GROUP and ALTER SERVER) are too +--echo # special to be tested here. +--echo # + + +--echo # +--echo # 2) ANALYZE TABLE statement is compatible with FTWRL. +--echo # See Bug#43336 ANALYZE and OPTIMIZE do not honour +--echo # --read-only for a discussion why. +--echo # +let $statement= analyze table t1_base; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 3) BEGIN, ROLLBACK and COMMIT statements. +--echo # BEGIN and ROLLBACK are compatible with FTWRL. +--echo # COMMIT is not. +--echo # +--echo # We need a special test for these statements as +--echo # FTWRL commits a transaction and because COMMIT +--echo # is handled in a special way. +flush tables with read lock; +begin; +--echo # ROLLBACK is allowed under FTWRL although there +--echo # no much sense in it. FTWRL commits any previous +--echo # changes and doesn't allows any DML after it. +--echo # So such a ROLLBACK is always a no-op. +rollback; +--echo # Although COMMIT is incompatible with FTWRL in +--echo # other senses it is still allowed under FTWRL. +--echo # This fact relied upon by some versions of +--echo # innobackup tool. +--echo # Similarly to ROLLBACK it is a no-op in this situation. +commit; +unlock tables; +--echo # Check that BEGIN/ROLLBACK are not blocked and +--echo # COMMIT is blocked by active FTWRL in another +--echo # connection. +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +begin; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Do some work so ROLLBACK is not a no-op. +insert into t3_trans values (1); +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +rollback; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +begin; +--echo # Do some work so COMMIT is not a no-op. +insert into t3_trans values (1); +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--echo # Send: +--send commit +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Wait until COMMIT is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for commit lock" and + info = "commit"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap COMMIT. +--reap +delete from t3_trans; +--echo # +--echo # Check that COMMIT blocks FTWRL in another connection. +begin; +insert into t3_trans values (1); +set debug_sync='RESET'; +set debug_sync='ha_commit_trans_after_acquire_commit_lock SIGNAL parked WAIT_FOR go'; +--send commit +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +set debug_sync='now WAIT_FOR parked'; +--send flush tables with read lock +--echo # Switching to connection '$con_aux2'. +connection $con_aux2; +--echo # Wait until FTWRL is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for commit lock" and + info = "flush tables with read lock"; +--source include/wait_condition.inc +set debug_sync='now SIGNAL go'; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap COMMIT. +--reap +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Reap FTWRL. +--reap +unlock tables; +--echo # Switching to connection 'default'. +connection default; +delete from t3_trans; +set debug_sync= "RESET"; +--echo # We don't run similar test for BEGIN and ROLLBACK as +--echo # they release metadata locks in non-standard place. + + +--echo # +--echo # 4) BINLOG statement should be incompatible with FTWRL. +--echo # +--echo # +--echo # Provide format description BINLOG statement first. +BINLOG ' +MfmqTA8BAAAAZwAAAGsAAAABAAQANS41LjctbTMtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAx+apMEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA== +'; +--echo # Now test compatibility for BINLOG statement which is +--echo # equivalent to INSERT INTO t1_base VALUES (1). +let $statement= BINLOG ' +MfmqTBMBAAAALgAAAN0AAAAAACgAAAAAAAEABHRlc3QAB3QxX2Jhc2UAAQMAAQ== +MfmqTBcBAAAAIgAAAP8AAAAAACgAAAAAAAEAAf/+AQAAAA== +'; +let $cleanup_stmt1= delete from t1_base where i = 1 limit 1; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_incompatible.inc +let $skip_3rd_check= ; + + +--echo # +--echo # 5) CALL statement. This statement uses resources in two +--echo # ways: through expressions used as parameters and through +--echo # sub-statements. This test covers only usage through +--echo # parameters as sub-statements do locking individually. +--echo # +--echo # 5.a) In simple cases a parameter expression should be +--echo # compatible with FTWRL. +let $statement= call p2((select count(*) from t1_base)); +let $cleanup_stmt1= ; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + +--echo # +--echo # 5.b) In case when an expression uses function which updates +--echo # base tables CALL should be incompatible with FTWRL. +--echo # +let $statement= call p2(f2_base()); +let $cleanup_stmt1= ; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_incompatible.inc +let $skip_3rd_check= ; + +--echo # +--echo # 5.c) If function used as argument updates temporary tables +--echo # CALL statement should be compatible with FTWRL. +--echo # +let $statement= call p2(f2_temp()); +let $cleanup_stmt1= ; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + + +--echo # +--echo # 6) CHECK TABLE statement is compatible with FTWRL. +--echo # +let $statement= check table t1_base; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 7) CHECKSUM TABLE statement is compatible with FTWRL. +--echo # +let $statement= checksum table t1_base; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 8) CREATE variants. +--echo # +--echo # 8.1) CREATE TABLE statement. +--echo # +--echo # 8.1.a) CREATE TABLE is incompatible with FTWRL when +--echo # base table is created. +let $statement= create table t3_base(i int); +let $cleanup_stmt1= drop table t3_base; +--source include/check_ftwrl_incompatible.inc + +--echo # 8.1.b) CREATE TABLE is compatible with FTWRL when +--echo # temporary table is created. +let $statement= create temporary table t3_temp(i int); +let $cleanup_stmt= drop temporary tables t3_temp; +--source include/check_ftwrl_compatible.inc + +--echo # 8.1.c) CREATE TABLE LIKE is incompatible with FTWRL when +--echo # base table is created. +let $statement= create table t3_base like t1_temp; +let $cleanup_stmt1= drop table t3_base; +--source include/check_ftwrl_incompatible.inc + +--echo # 8.1.d) CREATE TABLE LIKE is compatible with FTWRL when +--echo # temporary table is created. +let $statement= create temporary table t3_temp like t1_base; +let $cleanup_stmt= drop temporary table t3_temp; +--source include/check_ftwrl_compatible.inc + +--echo # 8.1.e) CREATE TABLE SELECT is incompatible with FTWRL when +--echo # base table is created. +let $statement= create table t3_base select 1 as i; +let $cleanup_stmt1= drop table t3_base; +--source include/check_ftwrl_incompatible.inc + +--echo # 8.1.f) CREATE TABLE SELECT is compatible with FTWRL when +--echo # temporary table is created. +let $statement= create temporary table t3_temp select 1 as i; +let $cleanup_stmt= drop temporary table t3_temp; +--source include/check_ftwrl_compatible.inc + +--echo # 8.2) CREATE INDEX statement. +--echo # +--echo # 8.2.a) CREATE INDEX is incompatible with FTWRL when +--echo # applied to base table. +let $statement= create index i on t1_base (i); +let $cleanup_stmt1= drop index i on t1_base; +--source include/check_ftwrl_incompatible.inc + +--echo # 8.2.b) CREATE INDEX is compatible with FTWRL when +--echo # applied to temporary table. +let $statement= create index i on t1_temp (i); +let $cleanup_stmt= drop index i on t1_temp; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 8.3) CREATE DATABASE is incompatible with FTWRL. +--echo # +let $statement= create database mysqltest2; +let $cleanup_stmt1= drop database mysqltest2; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 8.4) CREATE VIEW is incompatible with FTWRL. +--echo # +let $statement= create view v2 as select 1 as j; +let $cleanup_stmt1= drop view v2; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 8.5) CREATE TRIGGER is incompatible with FTWRL. +--echo # +let $statement= create trigger t1_bi before insert on t1_base for each row begin end; +let $cleanup_stmt1= drop trigger t1_bi; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 8.6) CREATE FUNCTION is incompatible with FTWRL. +--echo # +let $statement= create function f2() returns int return 0; +let $cleanup_stmt1= drop function f2; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 8.7) CREATE PROCEDURE is incompatible with FTWRL. +--echo # +let $statement= create procedure p3() begin end; +let $cleanup_stmt1= drop procedure p3; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 8.8) CREATE EVENT should be incompatible with FTWRL. +--echo # +let $statement= create event e2 on schedule every 1 minute do begin end; +let $cleanup_stmt1= drop event e2; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 8.9) CREATE USER should be incompatible with FTWRL. +--echo # +let $statement= create user mysqltest_u1; +let $cleanup_stmt1= drop user mysqltest_u1; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 8.x) The rest of CREATE variants (CREATE LOGFILE GROUP, +--echo # CREATE TABLESPACE and CREATE SERVER) are too special +--echo # to test here. +--echo # + + +--echo # +--echo # 9) PREPARE, EXECUTE and DEALLOCATE PREPARE statements. +--echo # +--echo # 9.1) PREPARE statement is compatible with FTWRL as it +--echo # doesn't change any data. +--echo # +--echo # 9.1.a) Prepare of simple INSERT statement. +--echo # +let $statement= prepare stmt1 from 'insert into t1_base values (1)'; +let $cleanup_stmt= deallocate prepare stmt1; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + +--echo # +--echo # 9.1.b) Prepare of multi-UPDATE. At some point such statements +--echo # tried to acquire thr_lock.c locks during prepare phase. +--echo # This no longer happens and thus it is compatible with +--echo # FTWRL. +let $statement= prepare stmt1 from 'update t1_base, t2_base set t1_base.i= 1 where t1_base.i = t2_base.j'; +let $cleanup_stmt= deallocate prepare stmt1; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + +--echo # +--echo # 9.1.c) Prepare of multi-DELETE. Again PREPARE of such +--echo # statement should be compatible with FTWRL. +let $statement= prepare stmt1 from 'delete t1_base from t1_base, t2_base where t1_base.i = t2_base.j'; +let $cleanup_stmt= deallocate prepare stmt1; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + +--echo # +--echo # 9.2) Compatibility of EXECUTE statement depends on statement +--echo # to be executed. +--echo # +--echo # 9.2.a) EXECUTE for statement which is itself compatible with +--echo # FTWRL should be compatible. +prepare stmt1 from 'select * from t1_base'; +let $statement= execute stmt1; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc +deallocate prepare stmt1; + +--echo # +--echo # 9.2.b) EXECUTE for statement which is incompatible with FTWRL +--echo # should be also incompatible. +--echo # +--echo # Check that EXECUTE is not allowed under FTWRL. +prepare stmt1 from 'insert into t1_base values (1)'; +flush tables with read lock; +--error ER_CANT_UPDATE_WITH_READLOCK +execute stmt1; +unlock tables; +--echo # Check that active FTWRL in another connection +--echo # blocks EXECUTE which changes data. +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--send execute stmt1 +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Check that EXECUTE is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for global read lock" and + info = "insert into t1_base values (1)"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap EXECUTE. +--reap +set debug_sync='RESET'; +set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go'; +--send execute stmt1; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +set debug_sync='now WAIT_FOR parked'; +--send flush tables with read lock +--echo # Switching to connection '$con_aux2'. +connection $con_aux2; +--echo # Wait until FTWRL is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for global read lock" and + info = "flush tables with read lock"; +--source include/wait_condition.inc +set debug_sync='now SIGNAL go'; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap EXECUTE. +--reap +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Reap FTWRL. +--reap +unlock tables; +--echo # Switching to connection 'default'. +connection default; +set debug_sync= "RESET"; +delete from t1_base; +deallocate prepare stmt1; + +--echo # +--echo # 9.3) DEALLOCATE PREPARE is compatible with FTWRL. +--echo # +prepare stmt1 from 'insert into t1_base values (1)'; +let $statement= deallocate prepare stmt1; +let $cleanup_stmt= prepare stmt1 from 'insert into t1_base values (1)'; +--source include/check_ftwrl_compatible.inc +deallocate prepare stmt1; + + +--echo # +--echo # 10) DELETE variations. +--echo # +--echo # 10.1) Simple DELETE. +--echo # +--echo # 10.1.a) Simple DELETE on base table is incompatible with FTWRL. +let $statement= delete from t1_base; +let $cleanup_stmt1= ; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 10.1.b) Simple DELETE on temporary table is compatible with FTWRL. +let $statement= delete from t1_temp; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 10.2) Multi DELETE. +--echo # +--echo # 10.2.a) Multi DELETE on base tables is incompatible with FTWRL. +let $statement= delete t1_base from t1_base, t2_base where t1_base.i = t2_base.j; +let $cleanup_stmt1= ; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 10.2.b) Multi DELETE on temporary tables is compatible with FTWRL. +let $statement= delete t1_temp from t1_temp, t2_temp where t1_temp.i = t2_temp.j; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 11) DESCRIBE should be compatible with FTWRL. +--echo # +let $statement= describe t1_base; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 12) Compatibility of DO statement with FTWRL depends on its +--echo # expression. +--echo # +--echo # 12.a) DO with expression which does not change base table +--echo # should be compatible with FTWRL. +let $statement= do (select count(*) from t1_base); +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 12.b) DO which calls SF updating base table should be +--echo # incompatible with FTWRL. +let $statement= do f2_base(); +let $cleanup_stmt1= delete from t1_base limit 1; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 12.c) DO which calls SF updating temporary table should be +--echo # compatible with FTWRL. +let $statement= do f2_temp(); +let $cleanup_stmt= delete from t1_temp limit 1; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 13) DROP variants. +--echo # +--echo # 13.1) DROP TABLES. +--echo # +--echo # 13.1.a) DROP TABLES which affects base tables is incompatible +--echo # with FTWRL. +let $statement= drop table t2_base; +let $cleanup_stmt1= create table t2_base(j int); +--source include/check_ftwrl_incompatible.inc + +--echo # 13.1.b) DROP TABLES which affects only temporary tables +--echo # in theory can be compatible with FTWRL. +--echo # In practice it is not yet. +let $statement= drop table t2_temp; +let $cleanup_stmt1= create temporary table t2_temp(j int); +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 13.1.c) DROP TEMPORARY TABLES should be compatible with FTWRL. +let $statement= drop temporary table t2_temp; +let $cleanup_stmt= create temporary table t2_temp(j int); +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 13.2) DROP INDEX. +--echo # +--echo # 13.2.a) DROP INDEX on a base table is incompatible with FTWRL. +create index i on t1_base (i); +let $statement= drop index i on t1_base; +let $cleanup_stmt1= create index i on t1_base (i); +--source include/check_ftwrl_incompatible.inc +drop index i on t1_base; + +--echo # +--echo # 13.2.b) DROP INDEX on a temporary table is compatible with FTWRL. +create index i on t1_temp (i); +let $statement= drop index i on t1_temp; +let $cleanup_stmt= create index i on t1_temp (i); +--source include/check_ftwrl_compatible.inc +drop index i on t1_temp; + +--echo # +--echo # 13.3) DROP DATABASE is incompatible with FTWRL +--echo # +let $statement= drop database mysqltest1; +let $cleanup_stmt1= create database mysqltest1; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 13.4) DROP FUNCTION is incompatible with FTWRL. +--echo # +let $statement= drop function f1; +let $cleanup_stmt1= create function f1() returns int return 0; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 13.5) DROP PROCEDURE is incompatible with FTWRL. +--echo # +let $statement= drop procedure p1; +let $cleanup_stmt1= create procedure p1() begin end; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 13.6) DROP USER should be incompatible with FTWRL. +--echo # +create user mysqltest_u1; +let $statement= drop user mysqltest_u1; +let $cleanup_stmt1= create user mysqltest_u1; +--source include/check_ftwrl_incompatible.inc +drop user mysqltest_u1; + +--echo # +--echo # 13.7) DROP VIEW should be incompatible with FTWRL. +--echo # +let $statement= drop view v1; +let $cleanup_stmt1= create view v1 as select 1 as i; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 13.8) DROP EVENT should be incompatible with FTWRL. +--echo # +let $statement= drop event e1; +let $cleanup_stmt1= create event e1 on schedule every 1 minute do begin end; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 13.9) DROP TRIGGER is incompatible with FTWRL. +--echo # +create trigger t1_bi before insert on t1_base for each row begin end; +let $statement= drop trigger t1_bi; +let $cleanup_stmt1= create trigger t1_bi before insert on t1_base for each row begin end; +--source include/check_ftwrl_incompatible.inc +drop trigger t1_bi; + +--echo # +--echo # 13.x) The rest of DROP variants (DROP TABLESPACE, DROP LOGFILE +--echo # GROUP and DROP SERVER) are too special to test here. +--echo # + + +--echo # +--echo # 14) FLUSH variants. +--echo # +--echo # Test compatibility of _some_ important FLUSH variants with FTWRL. +--echo # +--echo # 14.1) FLUSH TABLES WITH READ LOCK is compatible with itself. +--echo # +--echo # Check that FTWRL statements can be run while FTWRL +--echo # is active in another connection. +--echo # +--echo # Switching to connection '$con_aux1'. +flush tables with read lock; +--echo # The second FTWRL in a row is allowed at the moment. +--echo # It does not make much sense as it does only flush. +flush tables with read lock; +unlock tables; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +flush tables with read lock; +unlock tables; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; + +--echo # +--echo # 14.2) FLUSH TABLES WITH READ LOCK is not blocked by +--echo # active FTWRL. But since the latter keeps tables open +--echo # FTWRL is blocked by FLUSH TABLES WITH READ LOCK. +flush tables with read lock; +--echo # FT WRL is allowed under FTWRL at the moment. +--echo # It does not make much sense though. +flush tables t1_base, t2_base with read lock; +unlock tables; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +flush tables t1_base, t2_base with read lock; +unlock tables; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +flush tables t1_base, t2_base with read lock; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--send flush tables with read lock +--echo # Switching to connection '$con_aux2'. +connection $con_aux2; +--echo # Wait until FTWRL is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table flush" and + info = "flush tables with read lock"; +--source include/wait_condition.inc +--echo # Switching to connection 'default'. +connection default; +unlock tables; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Reap FTWRL. +--reap +unlock tables; +--echo # Switching to connection 'default'. +connection default; + + +--echo # +--echo # 14.3) FLUSH TABLES is compatible with FTWRL. +let $statement= flush tables; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 14.4) FLUSH TABLES is compatible with FTWRL. +let $statement= flush table t1_base, t2_base; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 14.5) FLUSH PRIVILEGES is compatible with FTWRL. +let $statement= flush privileges; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 15) GRANT statement should be incompatible with FTWRL. +--echo # +let $statement= grant all privileges on t1_base to mysqltest_u1; +let $cleanup_stmt1= revoke all privileges on t1_base from mysqltest_u1; +--source include/check_ftwrl_incompatible.inc +drop user mysqltest_u1; + + +--echo # +--echo # 16) All HANDLER variants are half-compatible with FTWRL. +--echo # I.e. they are not blocked by active FTWRL. But since open +--echo # HANDLER means open table instance FTWRL is blocked while +--echo # HANDLER is not closed. +--echo # +--echo # Check that HANDLER statements succeed under FTWRL. +flush tables with read lock; +handler t1_base open; +handler t1_base read first; +handler t1_base close; +unlock tables; +--echo # Check that HANDLER statements can be run while FTWRL +--echo # is active in another connection. +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +handler t1_base open; +handler t1_base read first; +handler t1_base close; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; + + +--echo # +--echo # 17) HELP statement is compatible with FTWRL. +--echo # +let $statement= help no_such_topic; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 18) INSERT statement. +--echo # +--echo # 18.a) Ordinary INSERT into base table is incompatible with FTWRL. +let $statement= insert into t1_base values (1); +let $cleanup_stmt1= delete from t1_base limit 1; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 18.b) Ordinary INSERT into temp table is compatible with FTWRL. +let $statement= insert into t1_temp values (1); +let $cleanup_stmt= delete from t1_temp limit 1; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 18.c) INSERT DELAYED is incompatible with FTWRL. +let $statement= insert delayed into t1_base values (1); +let $cleanup_stmt1= ; +--source include/check_ftwrl_incompatible.inc +delete from t1_base; + +--echo # +--echo # 18.d) INSERT SELECT into base table is incompatible with FTWRL. +let $statement= insert into t1_base select * from t1_temp; +let $cleanup_stmt1= ; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 18.e) INSERT SELECT into temp table is compatible with FTWRL. +let $statement= insert into t1_temp select * from t1_base; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 19) KILL statement is compatible with FTWRL. +--echo # +--echo # Check that KILL can be run under FTWRL. +flush tables with read lock; +set @id:= connection_id(); +--error ER_QUERY_INTERRUPTED +kill query @id; +unlock tables; +--echo # Check that KILL statements can be run while FTWRL +--echo # is active in another connection. +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--error ER_QUERY_INTERRUPTED +kill query @id; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Finally check that KILL doesn't block FTWRL +set debug_sync='RESET'; +set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go'; +--send kill query @id +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +set debug_sync='now WAIT_FOR parked'; +flush tables with read lock; +unlock tables; +set debug_sync='now SIGNAL go'; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap KILL. +--error ER_QUERY_INTERRUPTED +--reap +set debug_sync='RESET'; + + +--echo # +--echo # 20) LOAD DATA statement. +--echo # +--echo # 20.a) LOAD DATA into base table is incompatible with FTWRL. +let $statement= load data infile '../../std_data/rpl_loaddata.dat' into table t1_base (@dummy, i); +let $cleanup_stmt1= delete from t1_base; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 20.b) LOAD DATA into temporary table is compatible with FTWRL. +let $statement= load data infile '../../std_data/rpl_loaddata.dat' into table t1_temp (@dummy, i); +let $cleanup_stmt= delete from t1_temp; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 21) LOCK/UNLOCK TABLES statements. +--echo # +--echo # LOCK TABLES statement always (almost) blocks FTWRL as it +--echo # keeps tables open until UNLOCK TABLES. +--echo # Active FTWRL on the other hand blocks only those +--echo # LOCK TABLES which allow updating of base tables. +--echo # +--echo # 21.a) LOCK TABLES READ is allowed under FTWRL and +--echo # is not blocked by active FTWRL. +flush tables with read lock; +lock tables t1_base read; +unlock tables; +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +lock tables t1_base read; +unlock tables; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; + +--echo # +--echo # 21.b) LOCK TABLES WRITE on a base table is disallowed +--echo # under FTWRL and should be blocked by active FTWRL. +flush tables with read lock; +--error ER_CANT_UPDATE_WITH_READLOCK +lock tables t1_base write; +unlock tables; +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--send lock tables t1_base write +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Check that LOCK TABLES WRITE is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for global read lock" and + info = "lock tables t1_base write"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap LOCK TABLES WRITE +--reap +unlock tables; + +--echo # +--echo # 21.c) LOCK TABLES WRITE on temporary table doesn't +--echo # make much sense but is allowed under FTWRL +--echo # and should not be blocked by active FTWRL. +flush tables with read lock; +lock tables t1_temp write; +unlock tables; +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +lock tables t1_temp write; +unlock tables; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; + + +--echo # +--echo # 22) OPTIMIZE TABLE statement. +--echo # +--echo # 22.a) OPTIMIZE TABLE of base table is incompatible with FTWRL. +flush tables with read lock; +--echo # OPTIMIZE statement returns errors as part of result-set. +optimize table t1_base; +unlock tables; +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--send optimize table t1_base +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Check that OPTIMIZE TABLE is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for global read lock" and + info = "optimize table t1_base"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap OPTIMIZE TABLE +--reap +--echo # We don't check that active OPTIMIZE TABLE blocks +--echo # FTWRL as this one of statements releasing metadata +--echo # locks in non-standard place. + +--echo # +--echo # 22.b) OPTIMIZE TABLE of temporary table is compatible with FTWRL. +let $statement= optimize table t1_temp; +let $cleanup_stmt= ; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + + +--echo # +--echo # 23) CACHE statement is compatible with FTWRL. +--echo # +let $statement= cache index t1_base in default; +let $cleanup_stmt= ; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + + +--echo # +--echo # 24) LOAD INDEX statement is compatible with FTWRL. +--echo # +let $statement= load index into cache t1_base; +let $cleanup_stmt= ; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + + +--echo # +--echo # 25) SAVEPOINT/RELEASE SAVEPOINT/ROLLBACK TO SAVEPOINT are +--echo # compatible with FTWRL. +--echo # +--echo # Since manipulations on savepoint have to be done +--echo # inside transaction and FTWRL commits transaction we +--echo # need a special test for these statements. +flush tables with read lock; +begin; +savepoint sv1; +rollback to savepoint sv1; +release savepoint sv1; +unlock tables; +commit; +--echo # Check that these statements are not blocked by +--echo # active FTWRL in another connection. +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +begin; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Do some changes to avoid SAVEPOINT and friends +--echo # being almost no-ops. +insert into t3_trans values (1); +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +savepoint sv1; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +insert into t3_trans values (2); +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +rollback to savepoint sv1; +release savepoint sv1; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +rollback; +--echo # Check that these statements don't block FTWRL in +--echo # another connection. +begin; +--echo # Do some changes to avoid SAVEPOINT and friends +--echo # being almost no-ops. +insert into t3_trans values (1); +set debug_sync='RESET'; +set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go'; +--send savepoint sv1 +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +set debug_sync='now WAIT_FOR parked'; +flush tables with read lock; +unlock tables; +set debug_sync='now SIGNAL go'; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap SAVEPOINT +--reap +insert into t3_trans values (2); +set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go'; +--send rollback to savepoint sv1 +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +set debug_sync='now WAIT_FOR parked'; +flush tables with read lock; +unlock tables; +set debug_sync='now SIGNAL go'; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap ROLLBACK TO SAVEPOINT +--reap +set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go'; +--send release savepoint sv1 +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +set debug_sync='now WAIT_FOR parked'; +flush tables with read lock; +unlock tables; +set debug_sync='now SIGNAL go'; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap RELEASE SAVEPOINT +--reap +rollback; +set debug_sync= "RESET"; + + +--echo # +--echo # 26) RENAME variants. +--echo # +--echo # 26.1) RENAME TABLES is incompatible with FTWRL. +let $statement= rename table t1_base to t3_base; +let $cleanup_stmt1= rename table t3_base to t1_base; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 26.2) RENAME USER is incompatible with FTWRL. +create user mysqltest_u1; +let $statement= rename user mysqltest_u1 to mysqltest_u2; +let $cleanup_stmt1= rename user mysqltest_u2 to mysqltest_u1; +--source include/check_ftwrl_incompatible.inc +drop user mysqltest_u1; + + +--echo # +--echo # 27) REPAIR TABLE statement. +--echo # +--echo # 27.a) REPAIR TABLE of base table is incompatible with FTWRL. +flush tables with read lock; +--echo # REPAIR statement returns errors as part of result-set. +repair table t1_base; +unlock tables; +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--send repair table t1_base +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Check that REPAIR TABLE is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for global read lock" and + info = "repair table t1_base"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap REPAIR TABLE +--reap +--echo # We don't check that active REPAIR TABLE blocks +--echo # FTWRL as this one of statements releasing metadata +--echo # locks in non-standard place. + +--echo # +--echo # 27.b) REPAIR TABLE of temporary table is compatible with FTWRL. +let $statement= repair table t1_temp; +let $cleanup_stmt= ; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + + +--echo # +--echo # 28) REPLACE statement. +--echo # +--echo # 28.a) Ordinary REPLACE into base table is incompatible with FTWRL. +let $statement= replace into t1_base values (1); +let $cleanup_stmt1= delete from t1_base limit 1; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 28.b) Ordinary REPLACE into temp table is compatible with FTWRL. +let $statement= replace into t1_temp values (1); +let $cleanup_stmt= delete from t1_temp limit 1; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 28.c) REPLACE SELECT into base table is incompatible with FTWRL. +let $statement= replace into t1_base select * from t1_temp; +let $cleanup_stmt1= ; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 28.d) REPLACE SELECT into temp table is compatible with FTWRL. +let $statement= replace into t1_temp select * from t1_base; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 29) REVOKE variants. +--echo # +--echo # 29.1) REVOKE privileges is incompatible with FTWRL. +grant all privileges on t1_base to mysqltest_u1; +let $statement= revoke all privileges on t1_base from mysqltest_u1; +let $cleanup_stmt1= grant all privileges on t1_base to mysqltest_u1; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 29.2) REVOKE ALL PRIVILEGES, GRANT OPTION is incompatible with FTWRL. +let $statement= revoke all privileges, grant option from mysqltest_u1; +let $cleanup_stmt1= grant all privileges on t1_base to mysqltest_u1; +--source include/check_ftwrl_incompatible.inc +drop user mysqltest_u1; + + +--echo # +--echo # 30) Compatibility of SELECT statement with FTWRL depends on +--echo # locking mode used and on functions being invoked by it. +--echo # +--echo # 30.a) Simple SELECT which does not change tables should be +--echo # compatible with FTWRL. +let $statement= select count(*) from t1_base; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # 30.b) SELECT ... FOR UPDATE is incompatible with FTWRL. +let $statement= select count(*) from t1_base for update; +let $cleanup_stmt1= ; +--source include/check_ftwrl_incompatible.inc + +--echo # 30.c) SELECT ... LOCK IN SHARE MODE is compatible with FTWRL. +let $statement= select count(*) from t1_base lock in share mode; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 30.d) SELECT which calls SF updating base table should be +--echo # incompatible with FTWRL. +let $statement= select f2_base(); +let $cleanup_stmt1= delete from t1_base limit 1; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 30.e) SELECT which calls SF updating temporary table should be +--echo # compatible with FTWRL. +let $statement= select f2_temp(); +let $cleanup_stmt= delete from t1_temp limit 1; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 31) Compatibility of SET statement with FTWRL depends on its +--echo # expression and on whether it is a special SET statement. +--echo # +--echo # 31.a) Ordinary SET with expression which does not +--echo # changes base table should be compatible with FTWRL. +let $statement= set @a:= (select count(*) from t1_base); +let $cleanup_stmt= ; +--echo # Skip last part of compatibility testing as our helper debug +--echo # sync-point doesn't work for SET statements. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + +--echo # +--echo # 31.b) Ordinary SET which calls SF updating base table should +--echo # be incompatible with FTWRL. +let $statement= set @a:= f2_base(); +let $cleanup_stmt1= delete from t1_base limit 1; +--echo # Skip last part of compatibility testing as our helper debug +--echo # sync-point doesn't work for SET statements. +let $skip_3rd_check= 1; +--source include/check_ftwrl_incompatible.inc +let $skip_3rd_check= ; + +--echo # +--echo # 31.c) Ordinary SET which calls SF updating temporary table +--echo # should be compatible with FTWRL. +let $statement= set @a:= f2_temp(); +let $cleanup_stmt= delete from t1_temp limit 1; +--echo # Skip last part of compatibility testing as our helper debug +--echo # sync-point doesn't work for SET statements. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + +--echo # +--echo # 31.d) Special SET variants have different compatibility with FTWRL. +--echo # +--echo # 31.d.I) SET PASSWORD is incompatible with FTWRL as it changes data. +create user mysqltest_u1; +let $statement= set password for 'mysqltest_u1' = password(''); +let $cleanup_stmt1= ; +--echo # Skip last part of compatibility testing as our helper debug +--echo # sync-point doesn't work for SET statements. +let $skip_3rd_check= 1; +--source include/check_ftwrl_incompatible.inc +let $skip_3rd_check= ; +drop user mysqltest_u1; +--echo # +--echo # 31.d.II) SET READ_ONLY is compatible with FTWRL (but has no +--echo # effect when executed under it). +let $statement= set global read_only= 1; +let $cleanup_stmt= set global read_only= 0; +--echo # Skip last part of compatibility testing as our helper debug +--echo # sync-point doesn't work for SET statements. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; +--echo # +--echo # 31.d.III) Situation with SET AUTOCOMMIT is complex. +--echo # Turning auto-commit off is always compatible with FTWRL. +--echo # Turning auto-commit on causes implicit commit and so +--echo # is incompatible with FTWRL if there are changes to be +--echo # committed. +flush tables with read lock; +set autocommit= 0; +--echo # Turning auto-commit on causes implicit commit so can +--echo # be incompatible with FTWRL if there is something to +--echo # commit. But since even in this case we allow commits +--echo # under active FTWRL such statement should always succeed. +insert into t3_temp_trans values (1); +set autocommit= 1; +unlock tables; +delete from t3_temp_trans; +--echo # Check that SET AUTOCOMMIT=0 is not blocked and +--echo # SET AUTOCOMMIT=1 is blocked by active FTWRL in +--echo # another connection. +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +set autocommit= 0; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Do some work so implicit commit in SET AUTOCOMMIT=1 +--echo # is not a no-op. +insert into t3_trans values (1); +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--echo # Send: +--send set autocommit= 1 +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Wait until SET AUTOCOMMIT=1 is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for commit lock" and + info = "set autocommit= 1"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap SET AUTOCOMMIT=1. +--reap +delete from t3_trans; +--echo # +--echo # Check that SET AUTOCOMMIT=1 blocks FTWRL in another connection. +set autocommit= 0; +insert into t3_trans values (1); +set debug_sync='RESET'; +set debug_sync='ha_commit_trans_after_acquire_commit_lock SIGNAL parked WAIT_FOR go'; +--send set autocommit= 1 +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +set debug_sync='now WAIT_FOR parked'; +--send flush tables with read lock +--echo # Switching to connection '$con_aux2'. +connection $con_aux2; +--echo # Wait until FTWRL is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for commit lock" and + info = "flush tables with read lock"; +--source include/wait_condition.inc +set debug_sync='now SIGNAL go'; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap SET AUTOCOMMIT=1. +--reap +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Reap FTWRL. +--reap +unlock tables; +--echo # Switching to connection 'default'. +connection default; +delete from t3_trans; +set debug_sync= "RESET"; + + +--echo # +--echo # 32) SHOW statements are compatible with FTWRL. +--echo # Let us test _some_ of them. +--echo # +--echo # 32.1) SHOW TABLES. +let $statement= show tables from test; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 32.1) SHOW TABLES. +let $statement= show tables from test; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 32.2) SHOW EVENTS. +let $statement= show events from test; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 32.3) SHOW GRANTS. +create user mysqltest_u1; +let $statement= show grants for mysqltest_u1; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc +drop user mysqltest_u1; + +--echo # +--echo # 32.4) SHOW CREATE TABLE. +let $statement= show create table t1_base; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 32.5) SHOW CREATE FUNCTION. +let $statement= show create function f1; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 33) SIGNAL statement is compatible with FTWRL. +--echo # +--echo # Note that we don't cover RESIGNAL as it requires +--echo # active handler context. +let $statement= signal sqlstate '01000'; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 34) TRUNCATE TABLE statement. +--echo # +--echo # 34.a) TRUNCATE of base table is incompatible with FTWRL. +let $statement= truncate table t1_base; +let $cleanup_stmt1= ; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 34.b) TRUNCATE of temporary table is compatible with FTWRL. +let $statement= truncate table t1_temp; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 35) UPDATE variants. +--echo # +--echo # 35.1) Simple UPDATE. +--echo # +--echo # 35.1.a) Simple UPDATE on base table is incompatible with FTWRL. +let $statement= update t1_base set i= 1 where i = 0; +let $cleanup_stmt1= ; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 35.1.b) Simple UPDATE on temporary table is compatible with FTWRL. +let $statement= update t1_temp set i= 1 where i = 0; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 35.2) Multi UPDATE. +--echo # +--echo # 35.2.a) Multi UPDATE on base tables is incompatible with FTWRL. +let $statement= update t1_base, t2_base set t1_base.i= 1 where t1_base.i = t2_base.j; +let $cleanup_stmt1= ; +--source include/check_ftwrl_incompatible.inc + +--echo # +--echo # 35.2.b) Multi UPDATE on temporary tables is compatible with FTWRL. +let $statement= update t1_temp, t2_temp set t1_temp.i= 1 where t1_temp.i = t2_temp.j; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 36) USE statement is compatible with FTWRL. +--echo # +let $statement= use mysqltest1; +let $cleanup_stmt= use test; +--source include/check_ftwrl_compatible.inc + + +--echo # +--echo # 37) XA statements. +--echo # +--echo # XA statements are similar to BEGIN/COMMIT/ROLLBACK. +--echo # +--echo # XA BEGIN, END, PREPARE, ROLLBACK and RECOVER are compatible +--echo # with FTWRL. XA COMMIT is not. +flush tables with read lock; +--echo # Although all below statements are allowed under FTWRL they +--echo # are almost no-ops as FTWRL does commit and does not allows +--echo # any non-temporary DML under it. +xa start 'test1'; +xa end 'test1'; +xa prepare 'test1'; +xa rollback 'test1'; +xa start 'test1'; +xa end 'test1'; +xa prepare 'test1'; +xa commit 'test1'; +--disable_result_log +xa recover; +--enable_result_log +unlock tables; +--echo # Check that XA non-COMMIT statements are not and COMMIT is +--echo # blocked by active FTWRL in another connection +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +xa start 'test1'; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +insert into t3_trans values (1); +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +xa end 'test1'; +xa prepare 'test1'; +xa rollback 'test1'; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +xa start 'test1'; +insert into t3_trans values (1); +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +connection default; +xa end 'test1'; +xa prepare 'test1'; +--echo # Send: +--send xa commit 'test1'; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Wait until XA COMMIT is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for commit lock" and + info = "xa commit 'test1'"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap XA COMMIT. +--reap +delete from t3_trans; +--echo # +--echo # Check that XA COMMIT blocks FTWRL in another connection. +xa start 'test1'; +insert into t3_trans values (1); +xa end 'test1'; +xa prepare 'test1'; +set debug_sync='RESET'; +set debug_sync='trans_xa_commit_after_acquire_commit_lock SIGNAL parked WAIT_FOR go'; +--send xa commit 'test1' +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +set debug_sync='now WAIT_FOR parked'; +--send flush tables with read lock +--echo # Switching to connection '$con_aux2'. +connection $con_aux2; +--echo # Wait until FTWRL is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for commit lock" and + info = "flush tables with read lock"; +--source include/wait_condition.inc +set debug_sync='now SIGNAL go'; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap XA COMMIT. +--reap +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Reap FTWRL. +--reap +unlock tables; +--echo # Switching to connection 'default'. +connection default; +delete from t3_trans; +set debug_sync= "RESET"; + + +--echo # +--echo # 38) Test effect of auto-commit mode for DML on transactional +--echo # temporary tables. +--echo # +--echo # 38.1) When auto-commit is on each such a statement ends with commit +--echo # of changes to temporary tables. But since transactions doing +--echo # such changes are considered read only [sic!/QQ] this commit +--echo # is compatible with FTWRL. +--echo # +--echo # Let us demostrate this fact for some common DML statements. +let $statement= delete from t3_temp_trans; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +let $statement= insert into t3_temp_trans values (1); +let $cleanup_stmt= delete from t3_temp_trans limit 1; +--source include/check_ftwrl_compatible.inc + +let $statement= update t3_temp_trans, t2_temp set t3_temp_trans.i= 1 where t3_temp_trans.i = t2_temp.j; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +--echo # +--echo # 38.2) When auto-commit is off DML on transaction temporary tables +--echo # is compatible with FTWRL. +--echo # +set autocommit= 0; +let $statement= delete from t3_temp_trans; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc + +let $statement= insert into t3_temp_trans values (1); +let $cleanup_stmt= delete from t3_temp_trans limit 1; +--source include/check_ftwrl_compatible.inc + +let $statement= update t3_temp_trans, t2_temp set t3_temp_trans.i= 1 where t3_temp_trans.i = t2_temp.j; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc +set autocommit= 1; + + +--echo # +--echo # 39) Test effect of DDL on transactional tables. +--echo # +--echo # 39.1) Due to implicit commit at the end of statement some of DDL +--echo # statements which are compatible with FTWRL in non-transactional +--echo # case are not compatible in case of transactional tables. +--echo # +--echo # 39.1.a) ANALYZE TABLE for transactional table is incompatible with +--echo # FTWRL. +flush tables with read lock; +--echo # Implicit commits are allowed under FTWRL. +analyze table t3_trans; +unlock tables; +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--send analyze table t3_trans +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Check that ANALYZE TABLE is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for commit lock" and + info = "analyze table t3_trans"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap ANALYZE TABLE +--reap + +--echo # +--echo # 39.1.b) CHECK TABLE for transactional table is compatible with FTWRL. +--echo # Although it does implicit commit at the end of statement it +--echo # is considered to be read-only operation. +let $statement= check table t3_trans; +let $cleanup_stmt= ; +--echo # Skip last part of compatibility testing as this statement +--echo # releases metadata locks in non-standard place. +let $skip_3rd_check= 1; +--source include/check_ftwrl_compatible.inc +let $skip_3rd_check= ; + +--echo # +--echo # 39.2) Situation with DDL on temporary transactional tables is +--echo # complex. +--echo # +--echo # 39.2.a) Some statements compatible with FTWRL since they don't +--echo # do implicit commit. +--echo # +--echo # For example, CREATE TEMPORARY TABLE: +let $statement= create temporary table t4_temp_trans(i int) engine=innodb; +let $cleanup_stmt= drop temporary tables t4_temp_trans; +--source include/check_ftwrl_compatible.inc +--echo # +--echo # Or DROP TEMPORARY TABLE: +let $statement= drop temporary tables t3_temp_trans; +let $cleanup_stmt= create temporary table t3_temp_trans(i int) engine=innodb; +--source include/check_ftwrl_compatible.inc +--echo # +--echo # 39.2.b) Some statements do implicit commit but are considered +--echo # read-only and so are compatible with FTWRL. +--echo # +--echo # For example, REPAIR TABLE: +let $statement= repair table t3_temp_trans; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc +--echo # +--echo # And ANALYZE TABLE: +let $statement= analyze table t3_temp_trans; +let $cleanup_stmt= ; +--source include/check_ftwrl_compatible.inc +--echo # +--echo # 39.2.c) Some statements do implicit commit and not +--echo # considered read-only. As result they are +--echo # not compatible with FTWRL. +--echo # +flush tables with read lock; +--echo # Implicit commits are allowed under FTWRL. +alter table t3_temp_trans add column c1 int; +unlock tables; +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--send alter table t3_temp_trans drop column c1 +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Check that ALTER TABLE is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for commit lock" and + info = "alter table t3_temp_trans drop column c1"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap ALTER TABLE +--reap + + +--echo # +--echo # 40) Test effect of implicit commit for DDL which is otherwise +--echo # compatible with FTWRL. Implicit commit at the start of DDL +--echo # statement can make it incompatible with FTWRL if there are +--echo # some changes to be commited even in case when DDL statement +--echo # itself is compatible with FTWRL. +--echo # +--echo # For example CHECK TABLE for base non-transactional tables and +--echo # ALTER TABLE for temporary non-transactional tables are affected. +begin; +insert into t3_trans values (1); +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--send check table t1_base +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Check that CHECK TABLE is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for commit lock" and + info = "check table t1_base"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap CHECK TABLE +--reap +begin; +delete from t3_trans; +--echo # +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--send alter table t1_temp add column c1 int +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Check that ALTER TABLE is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for commit lock" and + info = "alter table t1_temp add column c1 int"; +--source include/wait_condition.inc +unlock tables; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap ALTER TABLE +--reap +alter table t1_temp drop column c1; + + +--echo # +--echo # Check that FLUSH TABLES WITH READ LOCK is blocked by individual +--echo # statements and is not blocked in the presence of transaction which +--echo # has done some changes earlier but is idle now (or does only reads). +--echo # This allows to use this statement even on systems which has long +--echo # running transactions. +--echo # +begin; +insert into t1_base values (1); +insert into t3_trans values (1); +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # The below FTWRL should not be blocked by transaction in 'default'. +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +--echo # Transaction still is able to read even with FTWRL active in another +--echo # connection. +select * from t1_base; +select * from t2_base; +select * from t3_trans; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +commit; +delete from t1_base; +delete from t3_trans; + + +--echo # +--echo # Check that impending FTWRL blocks new DML statements and +--echo # so can't be starved by a constant flow of DML. +--echo # (a.k.a. test for bug #54673 "It takes too long to get +--echo # readlock for 'FLUSH TABLES WITH READ LOCK'"). +--echo # +set debug_sync='RESET'; +set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go'; +--send insert into t1_base values (1) +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +set debug_sync='now WAIT_FOR parked'; +--send flush tables with read lock +--echo # Switching to connection '$con_aux2'. +connection $con_aux2; +--echo # Wait until FTWRL is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for global read lock" and + info = "flush tables with read lock"; +--source include/wait_condition.inc +--echo # Try to run another INSERT and see that it is blocked. +--send insert into t2_base values (1); +--echo # Switching to connection 'con3'. +connection con3; +--echo # Wait until new INSERT is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for global read lock" and + info = "insert into t2_base values (1)"; +--echo # Unblock INSERT in the first connection. +set debug_sync='now SIGNAL go'; +--echo # Switching to connection 'default'. +connection default; +--echo # Reap first INSERT. +--reap +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # Reap FTWRL. +--reap +unlock tables; +--echo # Switching to connection '$con_aux2'. +connection $con_aux2; +--echo # Reap second INSERT. +--reap +--echo # Switching to connection 'default'. +connection default; +set debug_sync= "RESET"; +delete from t1_base; +delete from t2_base; + +--echo +--echo # Check that COMMIT thas is issued after +--echo # FLUSH TABLES WITH READ LOCK is not blocked by +--echo # FLUSH TABLES WITH READ LOCK from another connection. +--echo # This scenario is used in innobackup.pl. The COMMIT goes +--echo # through because the transaction started by FTWRL does +--echo # not modify any tables, and the commit blocker lock is +--echo # only taken when there were such modifications. +--echo +flush tables with read lock; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +--echo # The below FTWRL should not be blocked by transaction in 'default'. +flush tables with read lock; +--echo # Switching to connection 'default'. +connection default; +select * from t1_base; +select * from t3_trans; +commit; +--echo # Switching to connection '$con_aux1'. +connection $con_aux1; +select * from t1_base; +select * from t3_trans; +commit; +unlock tables; +--echo # Switching to connection 'default'. +connection default; +unlock tables; + + +--echo # +--echo # Check how FLUSH TABLE WITH READ LOCK is handled for MERGE tables. +--echo # As usual there are tricky cases related to this type of tables. +--echo # +--echo # +--echo # 1) Most typical case - base MERGE table with base underlying tables. +--echo # +--echo # 1.a) DML statements which change data should be incompatible with FTWRL. +create table tm_base (i int) engine=merge union=(t1_base) insert_method=last; +let $statement= insert into tm_base values (1); +let $cleanup_stmt1= delete from tm_base; +--source include/check_ftwrl_incompatible.inc +--echo # +--echo # 1.b) DDL statement on such table should be incompatible with FTWRL as well. +let $statement= alter table tm_base insert_method=first; +let $cleanup_stmt1= alter table tm_base insert_method=last; +--source include/check_ftwrl_incompatible.inc +drop table tm_base; + +--echo # +--echo # 2) Temporary MERGE table with base underlying tables. +--echo # +--echo # 2.a) DML statements which change data should be incompatible with FTWRL +--echo # as they affect base tables. +create temporary table tm_temp_base (i int) engine=merge union=(t1_base) insert_method=last; +let $statement= insert into tm_temp_base values (1); +let $cleanup_stmt1= delete from tm_temp_base; +--source include/check_ftwrl_incompatible.inc +--echo # +--echo # 2.b) Some of DDL statements on such table can be compatible with FTWRL +--echo # as they don't affect base tables. +let $statement= drop temporary tables tm_temp_base; +let $cleanup_stmt= create temporary table tm_temp_base (i int) engine=merge union=(t1_base) insert_method=last; +--source include/check_ftwrl_compatible.inc +--echo # +--echo # 2.c) ALTER statement is incompatible with FTWRL. Even though it does +--echo # not change data in base table it still acquires strong metadata +--echo # locks on them. +let $statement= alter table tm_temp_base insert_method=first; +let $cleanup_stmt1= alter table tm_temp_base insert_method=last; +--source include/check_ftwrl_incompatible.inc +drop table tm_temp_base; + +--echo # +--echo # 3) Temporary MERGE table with temporary underlying tables. +--echo # +--echo # 3.a) DML statements should be compatible with FTWRL as +--echo # no base table is going to be affected. +create temporary table tm_temp_temp (i int) engine=merge union=(t1_temp) insert_method=last; +let $statement= insert into tm_temp_temp values (1); +let $cleanup_stmt= delete from tm_temp_temp; +--source include/check_ftwrl_compatible.inc +--echo # +--echo # 3.b) DDL statements should be compatible with FTWRL as well +--echo # as no base table is going to be affected too. +let $statement= alter table tm_temp_temp union=(t1_temp) insert_method=first; +let $cleanup_stmt= alter table tm_temp_temp union=(t1_temp) insert_method=last; +--source include/check_ftwrl_compatible.inc +drop table tm_temp_temp; + +--echo # +--echo # 4) For the sake of completeness let us check that base MERGE tables +--echo # with temporary underlying tables are not functional. +create table tm_base_temp (i int) engine=merge union=(t1_temp) insert_method=last; +--error ER_WRONG_MRG_TABLE +select * from tm_base_temp; +drop table tm_base_temp; + + +--echo # +--echo # Clean-up. +--echo # +drop event e1; +drop function f2_temp; +drop function f2_base; +drop procedure p2; +drop view v1; +drop function f1; +drop procedure p1; +drop database `#mysql50#mysqltest-2`; +drop database mysqltest1; +drop temporary tables t1_temp, t2_temp; +drop tables t1_base, t2_base, t3_trans; +disconnect con1; +disconnect con2; +disconnect con3; + +# Check that all connections opened by test cases in this file are really +# gone so execution of other tests won't be affected by their presence. +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/flush_read_lock_kill-master.opt b/mysql-test/t/flush_read_lock_kill-master.opt deleted file mode 100644 index 61e2b242351..00000000000 --- a/mysql-test/t/flush_read_lock_kill-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-debug=+d,make_global_read_lock_block_commit_loop diff --git a/mysql-test/t/flush_read_lock_kill.test b/mysql-test/t/flush_read_lock_kill.test index 2d359383949..a672fa5dfc5 100644 --- a/mysql-test/t/flush_read_lock_kill.test +++ b/mysql-test/t/flush_read_lock_kill.test @@ -2,24 +2,19 @@ # for running commits to finish (in the past it could not) # This will not be a meaningful test on non-debug servers so will be # skipped. -# If running mysql-test-run --debug, the --debug added by -# mysql-test-run to the mysqld command line will override the one of -# -master.opt. But this test is designed to still pass then (though it -# won't test anything interesting). # This also won't work with the embedded server test --source include/not_embedded.inc --source include/have_debug.inc +# This test needs transactional engine as otherwise COMMIT +# won't block FLUSH TABLES WITH GLOBAL READ LOCK. +--source include/have_innodb.inc + # Save the initial number of concurrent sessions --source include/count_sessions.inc -# Disable concurrent inserts to avoid test failures when reading the -# connection id which was inserted into a table by another thread. -SET @old_concurrent_insert= @@global.concurrent_insert; -SET @@global.concurrent_insert= 0; - connect (con1,localhost,root,,); connect (con2,localhost,root,,); connection con1; @@ -27,47 +22,64 @@ connection con1; --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings -CREATE TABLE t1 (kill_id INT); +SET DEBUG_SYNC= 'RESET'; +CREATE TABLE t1 (kill_id INT) engine = InnoDB; +INSERT INTO t1 VALUES(connection_id()); + +--echo # Switching to connection 'default'. +connection default; +--echo # Start transaction. +BEGIN; INSERT INTO t1 VALUES(connection_id()); +--echo # Ensure that COMMIT will pause once it acquires protection +--echo # against its global read lock. +SET DEBUG_SYNC='ha_commit_trans_after_acquire_commit_lock SIGNAL acquired WAIT_FOR go'; -# Thanks to the parameter we passed to --debug, this FLUSH will -# block on a debug build running with our --debug=make_global... It -# will block until killed. In other cases (non-debug build or other -# --debug) it will succeed immediately +--echo # Sending: +--send COMMIT +--echo # Switching to 'con1'. connection con1; +--echo # Wait till COMMIT acquires protection against global read +--echo # lock and pauses. +SET DEBUG_SYNC='now WAIT_FOR acquired'; +--echo # Sending: send FLUSH TABLES WITH READ LOCK; -# kill con1 +--echo # Switching to 'con2'. connection con2; -SELECT ((@id := kill_id) - kill_id) FROM t1; +SELECT ((@id := kill_id) - kill_id) FROM t1 LIMIT 1; -# Wait for the debug sync point, test won't run on non-debug -# builds anyway. +--echo # Wait till FLUSH TABLES WITH READ LOCK blocks due +--echo # to active COMMIT let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for all running commits to finish" + where state = "Waiting for commit lock" and info = "flush tables with read lock"; --source include/wait_condition.inc +--echo # Kill connection 'con1'. KILL CONNECTION @id; +--echo # Switching to 'con1'. connection con1; -# On debug builds it will be error 1053 (killed); on non-debug, or -# debug build running without our --debug=make_global..., will be -# error 0 (no error). The only important thing to test is that on -# debug builds with our --debug=make_global... we don't hang forever. ---error 0,1317,2013 +--echo # Try to reap FLUSH TABLES WITH READ LOCK, +--echo # it fail due to killed statement and connection. +--error 1317,2013 reap; +--echo # Switching to 'con2'. connection con2; -DROP TABLE t1; +--echo # Resume COMMIT. +SET DEBUG_SYNC='now SIGNAL go'; +--echo # Switching to 'default'. connection default; +--echo # Reaping COMMIT. +--reap disconnect con2; - -# Restore global concurrent_insert value -SET @@global.concurrent_insert= @old_concurrent_insert; +DROP TABLE t1; +SET DEBUG_SYNC= 'RESET'; # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index 6bdb235903d..5bab5e647ab 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -228,7 +228,7 @@ connection writer; # Sleep a bit till the flush of connection locker is in work and hangs let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global metadata lock" and + where state = "Waiting for global read lock" and info = "FLUSH TABLES WITH READ LOCK"; --source include/wait_condition.inc # This must not block. @@ -260,7 +260,7 @@ connection writer; # Sleep a bit till the flush of connection locker is in work and hangs let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global metadata lock" and + where state = "Waiting for global read lock" and info = "FLUSH TABLES WITH READ LOCK"; --source include/wait_condition.inc --error ER_TABLE_NOT_LOCKED @@ -296,10 +296,11 @@ DROP DATABASE mysqltest_1; # With bug in place: try to acquire LOCK_mysql_create_table... # When fixed: Reject dropping db because of the read lock. connection con1; -# Wait a bit so that the session con2 is in state "Waiting for release of readlock" +# Wait a bit so that the session con2 is in state +# "Waiting for global read lock" let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for release of readlock" + where state = "Waiting for global read lock" and info = "DROP DATABASE mysqltest_1"; --source include/wait_condition.inc --error ER_CANT_UPDATE_WITH_READLOCK @@ -376,7 +377,7 @@ connection con5; --echo # con5 let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global metadata lock" and + where state = "Waiting for global read lock" and info = "flush tables with read lock"; --source include/wait_condition.inc --echo # global read lock is taken @@ -384,10 +385,11 @@ connection con3; --echo # con3 send select * from t2 for update; connection con5; -let $show_statement= SHOW PROCESSLIST; -let $field= State; -let $condition= = 'Waiting for release of readlock'; ---source include/wait_show_condition.inc +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for global read lock" and + info = "select * from t2 for update"; +--source include/wait_condition.inc --echo # waiting for release of read lock connection con4; --echo # con4 @@ -433,10 +435,11 @@ connection con1; send update t2 set a = 1; connection default; --echo # default -let $show_statement= SHOW PROCESSLIST; -let $field= State; -let $condition= = 'Waiting for release of readlock'; ---source include/wait_show_condition.inc +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for global read lock" and + info = "update t2 set a = 1"; +--source include/wait_condition.inc --echo # statement is waiting for release of read lock connection con2; --echo # con2 @@ -460,10 +463,11 @@ connection con1; send lock tables t2 write; connection default; --echo # default -let $show_statement= SHOW PROCESSLIST; -let $field= State; -let $condition= = 'Waiting for release of readlock'; ---source include/wait_show_condition.inc +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for global read lock" and + info = "lock tables t2 write"; +--source include/wait_condition.inc --echo # statement is waiting for release of read lock connection con2; --echo # con2 @@ -571,7 +575,8 @@ connection default; --echo connection: default let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global metadata lock"; + where state = "Waiting for global read lock" and + info = "flush tables with read lock"; --source include/wait_condition.inc alter table t1 add column j int; connect (insert,localhost,root,,test,,); @@ -579,14 +584,16 @@ connection insert; --echo connection: insert let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global metadata lock"; + where state = "Waiting for global read lock" and + info = "flush tables with read lock"; --source include/wait_condition.inc --send insert into t1 values (1,2); --echo connection: default connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for release of readlock"; + where state = "Waiting for global read lock" and + info = "insert into t1 values (1,2)"; --source include/wait_condition.inc unlock tables; connection flush; @@ -594,7 +601,8 @@ connection flush; --reap let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for release of readlock"; + where state = "Waiting for global read lock" and + info = "insert into t1 values (1,2)"; --source include/wait_condition.inc select * from t1; unlock tables; @@ -629,12 +637,12 @@ connection default; --echo connection: default let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global metadata lock"; + where state = "Waiting for global read lock"; --source include/wait_condition.inc flush tables; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global metadata lock"; + where state = "Waiting for global read lock"; --source include/wait_condition.inc unlock tables; connection flush; @@ -698,12 +706,12 @@ connection default; --echo connection: default let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global metadata lock"; + where state = "Waiting for global read lock"; --source include/wait_condition.inc flush tables; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global metadata lock"; + where state = "Waiting for global read lock"; --source include/wait_condition.inc drop table t1; connection flush; diff --git a/mysql-test/t/mdl_sync.test b/mysql-test/t/mdl_sync.test index 5c4fc20b428..197cad536e4 100644 --- a/mysql-test/t/mdl_sync.test +++ b/mysql-test/t/mdl_sync.test @@ -3661,7 +3661,7 @@ connection con2; SET DEBUG_SYNC= 'now WAIT_FOR table_opened'; --echo # Check that FLUSH must wait to get the GRL --echo # and let CREATE PROCEDURE continue -SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL grlwait'; +SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait'; --send FLUSH TABLES WITH READ LOCK --echo # Connection 1 @@ -3689,15 +3689,22 @@ connection con2; SET DEBUG_SYNC= 'now WAIT_FOR table_opened'; --echo # Check that FLUSH must wait to get the GRL --echo # and let DROP PROCEDURE continue -SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL grlwait'; +SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait'; --send FLUSH TABLES WITH READ LOCK --echo # Connection 1 connection default; +--echo # Once FLUSH TABLES WITH READ LOCK starts waiting +--echo # DROP PROCEDURE will be waked up and will drop +--echo # procedure. Global read lock will be granted after +--echo # this statement ends. +--echo # +--echo # Reaping DROP PROCEDURE. --reap --echo # Connection 2 connection con2; +--echo # Reaping FTWRL. --reap UNLOCK TABLES; @@ -4485,7 +4492,7 @@ connection con2; --echo # Connection default connection default; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for release of readlock' + WHERE state='Waiting for global read lock' AND info='CREATE TABLE db1.t2(a INT)'; --source include/wait_condition.inc UNLOCK TABLES; @@ -4507,7 +4514,7 @@ connection con2; --echo # Connection default connection default; let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state='Waiting for release of readlock' + WHERE state='Waiting for global read lock' AND info='ALTER DATABASE db1 DEFAULT CHARACTER SET utf8'; --source include/wait_condition.inc UNLOCK TABLES; diff --git a/mysql-test/t/trigger_notembedded.test b/mysql-test/t/trigger_notembedded.test index 89857063ebd..536b00308ab 100644 --- a/mysql-test/t/trigger_notembedded.test +++ b/mysql-test/t/trigger_notembedded.test @@ -896,7 +896,7 @@ connection default; --echo connection: default let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for global metadata lock"; + where state = "Waiting for global read lock"; --source include/wait_condition.inc create trigger t1_bi before insert on t1 for each row begin end; unlock tables; -- cgit v1.2.1 From 1b583fa5da71a764dd66ad8b3668d7c75b122444 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 12 Nov 2010 13:12:15 +0300 Subject: Bug#58005 utf8 + get_format causes failed assertion: !str || str != Ptr' Problem: When GET_FORMAT() is called two times from the upper level function (e.g. LEAST in the bug report), on the second call "res= args[0]->val_str(...)" and str point to the same String object. 1. Fix: changing the order from - get val_str into tmp_value then convert to str to - get val_str into str then convert to tmp_value The new order is more correct: the purpose of "str" parameter is exactly to call val_str() for arguments. The purpose of String class members (like tmp_value) is to do further actions on the result. Doing it in the other way around give unexpected surprises. 2. Using str_value instead of str to do padding, for the same reason. --- mysql-test/t/date_formats.test | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index e5dc7ffa53e..2a5de8ca9ba 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -359,3 +359,19 @@ SELECT DATE_FORMAT("0000-02-28",'%W %d %M %Y') as valid_date; SELECT DATE_FORMAT("2009-01-01",'%W %d %M %Y') as valid_date; --echo "End of 5.0 tests" + + +--echo # +--echo # Start of 5.1 tests +--echo # + +--echo # +--echo # Bug#58005 utf8 + get_format causes failed assertion: !str || str != Ptr' +--echo # +SET NAMES utf8; +SELECT LEAST('%', GET_FORMAT(datetime, 'eur'), CAST(GET_FORMAT(datetime, 'eur') AS CHAR(65535))); +SET NAMES latin1; + +--echo # +--echo # End of 5.1 tests +--echo # -- cgit v1.2.1 From 2f5b308f3b073444f45a3739f0fada20d71cc2d8 Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Fri, 12 Nov 2010 16:57:08 +0300 Subject: Follow-up for patch fixing bug #57006 "Deadlock between HANDLER and FLUSH TABLES WITH READ LOCK" and bug #54673 "It takes too long to get readlock for 'FLUSH TABLES WITH READ LOCK'". Disable execution of flush_read_lock.test on embedded server. This test uses too many statements which are not supported by embedded server. --- mysql-test/t/flush_read_lock.test | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/flush_read_lock.test b/mysql-test/t/flush_read_lock.test index b234d941e6e..dbb1dd7cb49 100644 --- a/mysql-test/t/flush_read_lock.test +++ b/mysql-test/t/flush_read_lock.test @@ -7,6 +7,9 @@ --source include/have_innodb.inc # We need the Debug Sync Facility. --source include/have_debug_sync.inc +# Parts of this test use DDL on events, BINLOG statement and +# other statements which are not supported in embedded server. +-- source include/not_embedded.inc # Save the initial number of concurrent sessions. --source include/count_sessions.inc -- cgit v1.2.1 From 3fa437cf4061c20f2995e859b89a6898d3b646b4 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Sat, 13 Nov 2010 18:05:02 +0300 Subject: Fix for Bug#56934 (mysql_stmt_fetch() incorrectly fills MYSQL_TIME structure buffer). This is a follow-up for WL#4435. The bug actually existed not only MYSQL_TYPE_DATETIME type. The problem was that Item_param::set_value() was written in an assumption that it's working with expressions, i.e. with basic data types. There are two different quick fixes here: a) Change Item_param::make_field() -- remove setting of Send_field::length, Send_field::charsetnr, Send_field::flags and Send_field::type. That would lead to marshalling all data using basic types to the client (MYSQL_TYPE_LONGLONG, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_STRING and MYSQL_TYPE_NEWDECIMAL). In particular, that means, DATETIME would be sent as MYSQL_TYPE_STRING, TINYINT -- as MYSQL_TYPE_LONGLONG, etc. That could be Ok for the client, because the client library does reverse conversion automatically (the client program would see DATETIME as MYSQL_TIME object). However, there is a problem with metadata -- the metadata would be wrong (misleading): it would say that DATETIME is marshaled as MYSQL_TYPE_DATETIME, not as MYSQL_TYPE_STRING. b) Set Item_param::param_type properly to actual underlying field type. That would lead to double conversion inside the server: for example, MYSQL_TIME-object would be converted into STRING-object (in Item_param::set_value()), and then converted back to MYSQL_TIME-object (in Item_param::send()). The data however would be marshalled more properly, and also metadata would be correct. This patch implements b). There is also a possibility to avoid double conversion either by clonning the data field, or by storing a reference to it and using it on Item::send() time. That requires more work and might be done later. --- mysql-test/t/ps.test | 6 + mysql-test/t/wl4435_generated.inc | 588 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 594 insertions(+) create mode 100644 mysql-test/t/wl4435_generated.inc (limited to 'mysql-test/t') diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index bf15648951b..eaef1cf3000 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -3296,6 +3296,12 @@ SELECT @a; DROP PROCEDURE p1; DROP PROCEDURE p2; +########################################################################### + +--source t/wl4435_generated.inc + +########################################################################### + --echo --echo # End of WL#4435. diff --git a/mysql-test/t/wl4435_generated.inc b/mysql-test/t/wl4435_generated.inc new file mode 100644 index 00000000000..5ea05a89402 --- /dev/null +++ b/mysql-test/t/wl4435_generated.inc @@ -0,0 +1,588 @@ + +########################################################################### + +--echo +--echo TINYINT +--echo + +CREATE PROCEDURE p1(OUT v TINYINT) + SET v = 127; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = 127; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo SMALLINT +--echo + +CREATE PROCEDURE p1(OUT v SMALLINT) + SET v = 32767; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = 32767; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo MEDIUMINT +--echo + +CREATE PROCEDURE p1(OUT v MEDIUMINT) + SET v = 8388607; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = 8388607; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo INT +--echo + +CREATE PROCEDURE p1(OUT v INT) + SET v = 2147483647; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = 2147483647; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo BIGINT +--echo + +CREATE PROCEDURE p1(OUT v BIGINT) + SET v = 9223372036854775807; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = 9223372036854775807; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo BIT(11) +--echo + +CREATE PROCEDURE p1(OUT v BIT(11)) + SET v = b'10100100101'; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = b'10100100101'; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo TIMESTAMP +--echo + +CREATE PROCEDURE p1(OUT v TIMESTAMP) + SET v = '2007-11-18 15:01:02'; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = '2007-11-18 15:01:02'; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo DATETIME +--echo + +CREATE PROCEDURE p1(OUT v DATETIME) + SET v = '1234-11-12 12:34:59'; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = '1234-11-12 12:34:59'; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo TIME +--echo + +CREATE PROCEDURE p1(OUT v TIME) + SET v = '123:45:01'; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = '123:45:01'; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo DATE +--echo + +CREATE PROCEDURE p1(OUT v DATE) + SET v = '1234-11-12'; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = '1234-11-12'; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo YEAR +--echo + +CREATE PROCEDURE p1(OUT v YEAR) + SET v = 2010; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = 2010; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo FLOAT(7, 4) +--echo + +CREATE PROCEDURE p1(OUT v FLOAT(7, 4)) + SET v = 123.4567; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a - 123.4567 < 0.00001; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo DOUBLE(8, 5) +--echo + +CREATE PROCEDURE p1(OUT v DOUBLE(8, 5)) + SET v = 123.45678; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a - 123.45678 < 0.000001; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo DECIMAL(9, 6) +--echo + +CREATE PROCEDURE p1(OUT v DECIMAL(9, 6)) + SET v = 123.456789; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = 123.456789; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo CHAR(32) +--echo + +CREATE PROCEDURE p1(OUT v CHAR(32)) + SET v = REPEAT('a', 16); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('a', 16); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo VARCHAR(32) +--echo + +CREATE PROCEDURE p1(OUT v VARCHAR(32)) + SET v = REPEAT('b', 16); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('b', 16); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo TINYTEXT +--echo + +CREATE PROCEDURE p1(OUT v TINYTEXT) + SET v = REPEAT('c', 16); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('c', 16); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo TEXT +--echo + +CREATE PROCEDURE p1(OUT v TEXT) + SET v = REPEAT('d', 16); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('d', 16); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo MEDIUMTEXT +--echo + +CREATE PROCEDURE p1(OUT v MEDIUMTEXT) + SET v = REPEAT('e', 16); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('e', 16); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo LONGTEXT +--echo + +CREATE PROCEDURE p1(OUT v LONGTEXT) + SET v = REPEAT('f', 16); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('f', 16); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo BINARY(32) +--echo + +CREATE PROCEDURE p1(OUT v BINARY(32)) + SET v = REPEAT('g', 32); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('g', 32); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo VARBINARY(32) +--echo + +CREATE PROCEDURE p1(OUT v VARBINARY(32)) + SET v = REPEAT('h', 16); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('h', 16); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo TINYBLOB +--echo + +CREATE PROCEDURE p1(OUT v TINYBLOB) + SET v = REPEAT('i', 16); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('i', 16); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo BLOB +--echo + +CREATE PROCEDURE p1(OUT v BLOB) + SET v = REPEAT('j', 16); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('j', 16); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo MEDIUMBLOB +--echo + +CREATE PROCEDURE p1(OUT v MEDIUMBLOB) + SET v = REPEAT('k', 16); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('k', 16); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo LONGBLOB +--echo + +CREATE PROCEDURE p1(OUT v LONGBLOB) + SET v = REPEAT('l', 16); + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = REPEAT('l', 16); + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo SET('aaa', 'bbb') +--echo + +CREATE PROCEDURE p1(OUT v SET('aaa', 'bbb')) + SET v = 'aaa'; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = 'aaa'; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; + +########################################################################### + +--echo +--echo ENUM('aaa', 'bbb') +--echo + +CREATE PROCEDURE p1(OUT v ENUM('aaa', 'bbb')) + SET v = 'aaa'; + +PREPARE stmt1 FROM 'CALL p1(?)'; +EXECUTE stmt1 USING @a; + +CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; + +SHOW CREATE TABLE tmp1; + +SELECT @a, @a = 'aaa'; + +DROP TEMPORARY TABLE tmp1; +DROP PROCEDURE p1; -- cgit v1.2.1 From 92a1a112030452b375684e2b8633de0a32dc0912 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 15 Nov 2010 14:23:02 +0100 Subject: Bug #58087 mysqltest re-evaluates 'let' expressions infinitely Results from query is sent for evaluation Break recursion by asking for ` to be ignored --- mysql-test/t/mysqltest.test | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mysql-test/t') diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index d6bdbc2b3c1..59ff70e1591 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -854,6 +854,13 @@ let $var2= `failing query`; echo $var2; EOF +create table t1 (a varchar(100)); +insert into t1 values ('`select 42`'); +let $a= `select * from t1`; +# This should output `select 42`, not evaluate it again to 42 +echo $a; +drop table t1; + --error 1 --exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/let.sql 2>&1 -- cgit v1.2.1 From 47b514ffce0c5b1bdda27f745d1129496dff037f Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 15 Nov 2010 16:17:38 +0100 Subject: Bug#58197: main.variables-big fails on windows The test result differs on windows, since it writes out 'localhost:' instead of only 'localhost', since it uses tcp/ip instead of unix sockets on windows. Fixed by replacing that column. Also requires --big-test from some long running tests and added a weekly run of all test requiring --big-test. mysql-test/collections/default.weekly: Added a run of big-test (already exists in 5.5). mysql-test/r/variables-big.result: Updated results mysql-test/suite/parts/t/part_supported_sql_func_innodb.test: requiring --big-test since the test takes long time mysql-test/suite/parts/t/partition_alter1_1_2_innodb.test: requiring --big-test since the test takes long time mysql-test/suite/parts/t/partition_alter1_2_innodb.test: requiring --big-test since the test takes long time mysql-test/suite/parts/t/partition_alter4_innodb.test: requiring --big-test since the test takes long time mysql-test/t/disabled.def: Disabled two tests since they fail and was already reported as bugs (but was never run since they requires --big-test flag). mysql-test/t/variables-big.test: Replacing column 3 in process list since it is not the same on windows as in unix. --- mysql-test/t/disabled.def | 2 ++ mysql-test/t/variables-big.test | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'mysql-test/t') diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 9c5e091e03b..4510652b03f 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -13,3 +13,5 @@ kill : Bug#37780 2008-12-03 HHunger need some changes to be query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically main.mysqlhotcopy_myisam : Bug#56817 2010-10-21 anitha mysqlhotcopy* fails main.mysqlhotcopy_archive: Bug#56817 2010-10-21 anitha mysqlhotcopy* fails +log_tables-big : Bug#48646 2010-11-15 mattiasj report already exists +read_many_rows_innodb : Bug#37635 2010-11-15 mattiasj report already exists diff --git a/mysql-test/t/variables-big.test b/mysql-test/t/variables-big.test index fdb11ffa907..6c357bb6e54 100644 --- a/mysql-test/t/variables-big.test +++ b/mysql-test/t/variables-big.test @@ -37,19 +37,19 @@ --disable_warnings SET SESSION transaction_prealloc_size=1024*1024*1024*1; ---replace_column 1 6