diff --git a/mysql-test/r/init_connection_query_cache.result b/mysql-test/r/init_connection_query_cache.result new file mode 100644 index 00000000000..5a1e5c5244f --- /dev/null +++ b/mysql-test/r/init_connection_query_cache.result @@ -0,0 +1,19 @@ +# +# MDEV-4520: Assertion `0' fails in Query_cache::end_of_result on +# concurrent drop event and event execution +# +set GLOBAL query_cache_size=1355776; +create user mysqltest1@localhost; +grant SELECT on test.* to mysqltest1@localhost; +create table t1 (a int); +# This explain put here to be sure that init connection query +# has 'Impossible WHERE'. +explain extended select * from test.t1 where 0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0 +revoke all privileges, grant option from mysqltest1@localhost; +drop user mysqltest1@localhost; +drop table t1; +set GLOBAL query_cache_size=default; diff --git a/mysql-test/t/init_connection_query_cache-master.opt b/mysql-test/t/init_connection_query_cache-master.opt new file mode 100644 index 00000000000..7bef2af8d35 --- /dev/null +++ b/mysql-test/t/init_connection_query_cache-master.opt @@ -0,0 +1 @@ +--init_connect="select * from test.t1 where 0" diff --git a/mysql-test/t/init_connection_query_cache.test b/mysql-test/t/init_connection_query_cache.test new file mode 100644 index 00000000000..4d83304163e --- /dev/null +++ b/mysql-test/t/init_connection_query_cache.test @@ -0,0 +1,26 @@ +-- source include/have_query_cache.inc + +--echo # +--echo # MDEV-4520: Assertion `0' fails in Query_cache::end_of_result on +--echo # concurrent drop event and event execution +--echo # +set GLOBAL query_cache_size=1355776; + +create user mysqltest1@localhost; +grant SELECT on test.* to mysqltest1@localhost; + +create table t1 (a int); + +connect (con1,localhost,mysqltest1,,); +connection con1; +--echo # This explain put here to be sure that init connection query +--echo # has 'Impossible WHERE'. +explain extended select * from test.t1 where 0; +connection default; +disconnect con1; +revoke all privileges, grant option from mysqltest1@localhost; +drop user mysqltest1@localhost; + +drop table t1; + +set GLOBAL query_cache_size=default; diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 1e5c99822ff..10cdadd5d95 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -4000,7 +4000,8 @@ Query_cache::is_cacheable(THD *thd, LEX *lex, if (thd->lex->safe_to_cache_query && (thd->variables.query_cache_type == 1 || (thd->variables.query_cache_type == 2 && (lex->select_lex.options & - OPTION_TO_QUERY_CACHE)))) + OPTION_TO_QUERY_CACHE))) && + thd->net.vio) { DBUG_PRINT("qcache", ("options: %lx %lx type: %u", (long) OPTION_TO_QUERY_CACHE, @@ -4022,11 +4023,12 @@ Query_cache::is_cacheable(THD *thd, LEX *lex, } DBUG_PRINT("qcache", - ("not interesting query: %d or not cacheable, options %lx %lx type: %u", + ("not interesting query: %d or not cacheable, options %lx %lx type: %u net->vio present: %u", (int) lex->sql_command, (long) OPTION_TO_QUERY_CACHE, (long) lex->select_lex.options, - (int) thd->variables.query_cache_type)); + (int) thd->variables.query_cache_type, + (uint) test(thd->net.vio))); DBUG_RETURN(0); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 5e0fe8425af..ca17cefff4c 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -4579,7 +4579,7 @@ void xid_cache_delete(XID_STATE *xid_state) int THD::decide_logging_format(TABLE_LIST *tables) { DBUG_ENTER("THD::decide_logging_format"); - DBUG_PRINT("info", ("query: %s", query())); + DBUG_PRINT("info", ("Query: %s", query())); DBUG_PRINT("info", ("variables.binlog_format: %lu", variables.binlog_format)); DBUG_PRINT("info", ("lex->get_stmt_unsafe_flags(): 0x%x",