2010-01-15 09:51:39 +01:00
|
|
|
# This test should work in embedded server after mysqltest is fixed
|
|
|
|
-- source include/not_embedded.inc
|
|
|
|
|
2011-06-23 15:41:04 +02:00
|
|
|
--echo Tests of synchronization of stored procedure execution.
|
2010-01-12 15:16:26 +01:00
|
|
|
|
|
|
|
--source include/have_debug_sync.inc
|
|
|
|
|
2010-04-19 15:35:13 +02:00
|
|
|
# Save the initial number of concurrent sessions.
|
|
|
|
--source include/count_sessions.inc
|
|
|
|
|
|
|
|
# Clean up resources used in this test case.
|
|
|
|
--disable_warnings
|
|
|
|
SET DEBUG_SYNC= 'RESET';
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # Bug #30977 Concurrent statement using stored function and
|
|
|
|
--echo # DROP FUNCTION breaks SBR
|
2010-01-12 15:16:26 +01:00
|
|
|
--echo #
|
2010-04-19 15:35:13 +02:00
|
|
|
--echo # A stored routine could change after dispatch_command()
|
|
|
|
--echo # but before a MDL lock is taken. This must be noticed and the
|
|
|
|
--echo # sp cache flushed so the correct version can be loaded.
|
2010-01-12 15:16:26 +01:00
|
|
|
--echo #
|
|
|
|
|
2010-04-19 15:35:13 +02:00
|
|
|
connect (con2, localhost, root);
|
2010-01-12 15:16:26 +01:00
|
|
|
|
2010-04-19 15:35:13 +02:00
|
|
|
connection default;
|
|
|
|
CREATE FUNCTION f1() RETURNS INT RETURN 1;
|
|
|
|
--echo # Get f1 cached
|
|
|
|
SELECT f1();
|
|
|
|
--echo # Then start executing it again...
|
|
|
|
SET DEBUG_SYNC= 'before_execute_sql_command SIGNAL before WAIT_FOR changed';
|
|
|
|
--echo # Sending:
|
|
|
|
--send SELECT f1()
|
|
|
|
|
|
|
|
connection con2;
|
|
|
|
SET DEBUG_SYNC= 'now WAIT_FOR before';
|
|
|
|
--echo # ... but before f1 is locked, change it.
|
|
|
|
DROP FUNCTION f1;
|
|
|
|
CREATE FUNCTION f1() RETURNS INT RETURN 2;
|
|
|
|
SET DEBUG_SYNC= 'now SIGNAL changed';
|
|
|
|
|
|
|
|
--echo # We should now get '2' and not '1'.
|
|
|
|
connection default;
|
|
|
|
--echo # Reaping: SELECT f1()
|
|
|
|
--reap
|
|
|
|
|
|
|
|
disconnect con2;
|
|
|
|
DROP FUNCTION f1;
|
|
|
|
SET DEBUG_SYNC= 'RESET';
|
2010-01-12 15:16:26 +01:00
|
|
|
|
2010-04-19 15:35:13 +02:00
|
|
|
--echo #
|
|
|
|
--echo # Field translation items must be cleared in case of back-offs
|
|
|
|
--echo # for queries that use Information Schema tables. Otherwise
|
|
|
|
--echo # memory allocated in fix_fields() for views may end up referring
|
|
|
|
--echo # to freed memory.
|
|
|
|
--echo #
|
2010-01-12 15:16:26 +01:00
|
|
|
|
2010-04-19 15:35:13 +02:00
|
|
|
--disable_warnings
|
|
|
|
DROP FUNCTION IF EXISTS f1;
|
|
|
|
--enable_warnings
|
2010-01-12 15:16:26 +01:00
|
|
|
|
2010-04-19 15:35:13 +02:00
|
|
|
connect (con2, localhost, root);
|
|
|
|
connect (con3, localhost, root);
|
2010-01-12 15:16:26 +01:00
|
|
|
|
2010-04-19 15:35:13 +02:00
|
|
|
connection default;
|
|
|
|
CREATE FUNCTION f1() RETURNS INT RETURN 0;
|
2010-01-12 15:16:26 +01:00
|
|
|
|
|
|
|
connection con2;
|
2010-04-19 15:35:13 +02:00
|
|
|
SET DEBUG_SYNC= 'after_wait_locked_pname SIGNAL locked WAIT_FOR issued';
|
|
|
|
--echo # con2 will now have an x-lock on f1
|
|
|
|
--echo # Sending:
|
|
|
|
--send ALTER FUNCTION f1 COMMENT 'comment'
|
2010-01-12 15:16:26 +01:00
|
|
|
|
2010-04-19 15:35:13 +02:00
|
|
|
connection default;
|
|
|
|
SET DEBUG_SYNC= 'now WAIT_FOR locked';
|
|
|
|
--disable_result_log
|
|
|
|
--echo # This query will block due to the x-lock on f1 and back-off
|
|
|
|
--send SHOW OPEN TABLES WHERE f1()=0
|
|
|
|
|
|
|
|
connection con3;
|
|
|
|
let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
|
Part of fix for bug#52044 "FLUSH TABLES WITH READ LOCK and
FLUSH TABLES <list> WITH READ LOCK are incompatible" to
be pushed as separate patch.
Replaced thread state name "Waiting for table", which was
used by threads waiting for a metadata lock or table flush,
with a set of names which better reflect types of resources
being waited for.
Also replaced "Table lock" thread state name, which was used
by threads waiting on thr_lock.c table level lock, with more
elaborate "Waiting for table level lock", to make it
more consistent with other thread state names.
Updated test cases and their results according to these
changes.
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script.
mysql-test/r/query_cache.result:
Added test coverage for query_cache_wlock_invalidate
behavior for implicitly locked tables.
mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result:
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script. Reverted
changes to test which introduced timeout and replaced waiting
condition with a more appropriate one.
Test coverage for query_cache_wlock_invalidate behavior for
implicitly locked tables was added to query_cache.test.
mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test:
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script. Reverted
changes to test which introduced timeout and replaced waiting
condition with a more appropriate one.
Test coverage for query_cache_wlock_invalidate behavior for
implicitly locked tables was added to query_cache.test.
mysql-test/t/query_cache.test:
Added test coverage for query_cache_wlock_invalidate
behavior for implicitly locked tables.
mysys/thr_lock.c:
Replaced "Table lock" thread state name, which was used by
threads waiting on thr_lock.c table level lock, with more
elaborate "Waiting for table level lock", to make it
consistent with thread state names which are used while
waiting for metadata locks and table flush.
sql/mdl.cc:
Replaced thread state name "Waiting for table", which was
used by threads waiting for a metadata lock or table flush,
with a set of names which better reflect types of resources
being waited for.
To implement this:
- Adjusted MDL_wait::timed_wait() to take thread state name
as parameter.
- Introduced method of MDL_key class which allows to get
thread state name to be used while waiting for resource
corresponding to the key and changed code to use it.
Added array translating namespaces to thread state names
as part of this change.
sql/mdl.h:
To implement this:
- Adjusted MDL_wait::timed_wait() to take thread state name
as parameter.
- Introduced method of MDL_key class which allows to get
thread state name to be used while waiting for resource
corresponding to the key and changed code to use it.
Added array translating namespaces to thread state names
as part of this change.
sql/sql_base.cc:
Replaced thread state name "Waiting for table", which was
used by threads waiting for table flush, with a more elaborate
"Waiting for table flush".
2010-08-06 13:29:37 +02:00
|
|
|
WHERE state= 'Waiting for stored function metadata lock'
|
2010-04-19 15:35:13 +02:00
|
|
|
AND info='SHOW OPEN TABLES WHERE f1()=0';
|
2010-01-12 15:16:26 +01:00
|
|
|
--source include/wait_condition.inc
|
2010-04-19 15:35:13 +02:00
|
|
|
--echo # Check that the IS query is blocked before releasing the x-lock
|
|
|
|
SET DEBUG_SYNC= 'now SIGNAL issued';
|
2010-01-12 15:16:26 +01:00
|
|
|
|
2010-04-19 15:35:13 +02:00
|
|
|
connection default;
|
|
|
|
--echo # Reaping: ALTER FUNCTION f1 COMMENT 'comment'
|
2010-01-12 15:16:26 +01:00
|
|
|
--reap
|
2010-04-19 15:35:13 +02:00
|
|
|
--enable_result_log
|
|
|
|
DROP FUNCTION f1;
|
|
|
|
SET DEBUG_SYNC= 'RESET';
|
2010-01-12 15:16:26 +01:00
|
|
|
disconnect con2;
|
2010-04-19 15:35:13 +02:00
|
|
|
disconnect con3;
|
|
|
|
|
|
|
|
|
|
|
|
--echo #
|
|
|
|
--echo # Bug #48246 assert in close_thread_table
|
|
|
|
--echo #
|
|
|
|
|
2010-06-07 09:06:55 +02:00
|
|
|
CREATE TABLE t0 (b INTEGER);
|
2010-04-19 15:35:13 +02:00
|
|
|
CREATE TABLE t1 (a INTEGER);
|
|
|
|
CREATE FUNCTION f1(b INTEGER) RETURNS INTEGER RETURN 1;
|
2010-06-07 09:06:55 +02:00
|
|
|
CREATE PROCEDURE p1() SELECT COUNT(f1(a)) FROM t1, t0;
|
2010-04-19 15:35:13 +02:00
|
|
|
|
2010-06-07 09:06:55 +02:00
|
|
|
INSERT INTO t0 VALUES(1);
|
2010-04-19 15:35:13 +02:00
|
|
|
INSERT INTO t1 VALUES(1), (2);
|
|
|
|
|
|
|
|
connect (con2, localhost, root);
|
|
|
|
CALL p1();
|
|
|
|
|
2010-06-07 09:06:55 +02:00
|
|
|
SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL locked_t1 WAIT_FOR go_for_t0';
|
|
|
|
--echo # This call used to cause an assertion. MDL deadlock with upcoming
|
|
|
|
--echo # LOCK TABLES statement will cause back-off and retry.
|
|
|
|
--echo # A variable indicating if a prelocking list exists, used to be not
|
|
|
|
--echo # reset properly causing an eventual assert.
|
2010-04-19 15:35:13 +02:00
|
|
|
--echo # Sending:
|
|
|
|
--send CALL p1()
|
|
|
|
|
|
|
|
connection default;
|
2010-06-07 09:06:55 +02:00
|
|
|
SET DEBUG_SYNC= 'now WAIT_FOR locked_t1';
|
|
|
|
--echo # Issue LOCK TABLES statement which will enter in MDL deadlock
|
|
|
|
--echo # with CALL statement and as result will cause it to perform
|
|
|
|
--echo # back-off and retry.
|
|
|
|
SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL go_for_t0';
|
|
|
|
LOCK TABLES t0 WRITE, t1 WRITE;
|
|
|
|
UNLOCK TABLES;
|
2010-04-19 15:35:13 +02:00
|
|
|
|
|
|
|
connection con2;
|
|
|
|
--echo # Reaping: CALL p1()
|
|
|
|
--reap;
|
|
|
|
|
|
|
|
connection default;
|
|
|
|
disconnect con2;
|
2010-01-12 15:16:26 +01:00
|
|
|
DROP PROCEDURE p1;
|
2010-04-19 15:35:13 +02:00
|
|
|
DROP FUNCTION f1;
|
2010-06-07 09:06:55 +02:00
|
|
|
DROP TABLES t0, t1;
|
2010-01-12 15:16:26 +01:00
|
|
|
|
|
|
|
|
2011-06-23 15:41:04 +02:00
|
|
|
--echo #
|
|
|
|
--echo # test for bug#11756013
|
|
|
|
--echo #
|
|
|
|
--disable_warnings
|
|
|
|
DROP SCHEMA IF EXISTS s1;
|
|
|
|
--enable_warnings
|
|
|
|
CREATE SCHEMA s1;
|
|
|
|
CREATE PROCEDURE s1.p1() BEGIN END;
|
|
|
|
|
|
|
|
connect (con3, localhost, root);
|
|
|
|
SET DEBUG_SYNC='before_db_dir_check SIGNAL check_db WAIT_FOR dropped_schema';
|
|
|
|
--send CALL s1.p1
|
|
|
|
|
|
|
|
connection default;
|
|
|
|
SET DEBUG_SYNC='now WAIT_FOR check_db';
|
|
|
|
DROP SCHEMA s1;
|
|
|
|
SET DEBUG_SYNC='now SIGNAL dropped_schema';
|
|
|
|
|
|
|
|
connection con3;
|
|
|
|
--error ER_BAD_DB_ERROR
|
|
|
|
--reap
|
|
|
|
connection default;
|
|
|
|
disconnect con3;
|
|
|
|
|
2010-01-12 15:16:26 +01:00
|
|
|
SET DEBUG_SYNC = 'RESET';
|
|
|
|
|
2010-04-19 15:35:13 +02:00
|
|
|
# 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
|