You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
315 lines
9.7 KiB
315 lines
9.7 KiB
|
|
--echo Tests of synchronization of stored procedure execution.
|
|
|
|
--source include/have_debug_sync.inc
|
|
|
|
# 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
|
|
--echo #
|
|
--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.
|
|
--echo #
|
|
|
|
connect (con2, localhost, root);
|
|
|
|
--echo # Connection default
|
|
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()
|
|
|
|
--echo # Connection 2
|
|
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 # Connection default
|
|
--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';
|
|
|
|
--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 #
|
|
|
|
--disable_warnings
|
|
DROP FUNCTION IF EXISTS f1;
|
|
--enable_warnings
|
|
|
|
connect (con2, localhost, root);
|
|
connect (con3, localhost, root);
|
|
|
|
--echo # Connection default
|
|
connection default;
|
|
CREATE FUNCTION f1() RETURNS INT RETURN 0;
|
|
|
|
--echo # Connection con2
|
|
connection con2;
|
|
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'
|
|
|
|
--echo # Connection default
|
|
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
|
|
|
|
--echo # Connection con3
|
|
connection con3;
|
|
let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
|
|
WHERE state= 'Waiting for stored function metadata lock'
|
|
AND info='SHOW OPEN TABLES WHERE f1()=0';
|
|
--source include/wait_condition.inc
|
|
--echo # Check that the IS query is blocked before releasing the x-lock
|
|
SET DEBUG_SYNC= 'now SIGNAL issued';
|
|
|
|
--echo # Connection default
|
|
connection default;
|
|
--echo # Reaping: ALTER FUNCTION f1 COMMENT 'comment'
|
|
--reap
|
|
--enable_result_log
|
|
DROP FUNCTION f1;
|
|
SET DEBUG_SYNC= 'RESET';
|
|
disconnect con2;
|
|
disconnect con3;
|
|
|
|
|
|
--echo #
|
|
--echo # Bug #48246 assert in close_thread_table
|
|
--echo #
|
|
|
|
CREATE TABLE t0 (b INTEGER);
|
|
CREATE TABLE t1 (a INTEGER);
|
|
CREATE FUNCTION f1(b INTEGER) RETURNS INTEGER RETURN 1;
|
|
CREATE PROCEDURE p1() SELECT COUNT(f1(a)) FROM t1, t0;
|
|
|
|
INSERT INTO t0 VALUES(1);
|
|
INSERT INTO t1 VALUES(1), (2);
|
|
|
|
--echo # Connection 2
|
|
connect (con2, localhost, root);
|
|
CALL p1();
|
|
|
|
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.
|
|
--echo # Sending:
|
|
--send CALL p1()
|
|
|
|
--echo # Connection default
|
|
connection default;
|
|
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;
|
|
|
|
--echo # Connection 2
|
|
connection con2;
|
|
--echo # Reaping: CALL p1()
|
|
--reap;
|
|
|
|
--echo # Connection default
|
|
connection default;
|
|
disconnect con2;
|
|
DROP PROCEDURE p1;
|
|
DROP FUNCTION f1;
|
|
DROP TABLES t0, t1;
|
|
|
|
#
|
|
# Bug#22700385 - MDL ON STORED ROUTINES IS CASE SENSITIVE EVEN IF ROUTINE NAMES
|
|
# ARE INSENSITIVE
|
|
#
|
|
|
|
--enable_connect_log
|
|
|
|
--echo # Case 1: Test case to verify MDL locking from concurrent SELECT and
|
|
--echo # DROP FUNCTION operation with case & access insensitive routine
|
|
--echo # name.
|
|
|
|
CREATE FUNCTION mIxEdCaSe() RETURNS INT RETURN 1;
|
|
SET DEBUG_SYNC='after_shared_lock_pname SIGNAL locked WAIT_FOR continue';
|
|
--SEND SELECT mIxEdCaSé()
|
|
--echo # At this point we have a shared lock on 'mIxEdCaSé'
|
|
|
|
--CONNECT (con1, localhost, root)
|
|
SET DEBUG_SYNC='now WAIT_FOR locked';
|
|
--SEND DROP FUNCTION mixedcase;
|
|
--echo # Without fix the shared lock does not prevent us from dropping the SF
|
|
--echo # since the case used in this statement is different. This statement
|
|
--echo # takes exclusive metadata lock on 'mixedcase', not 'mIxEdCaSe'.
|
|
--echo # Drop function mIxEdCaSe will be blocked properly.
|
|
|
|
--CONNECT (con2, localhost, root)
|
|
let $wait_condition= SELECT COUNT(*) > 0 FROM information_schema.processlist
|
|
WHERE info LIKE 'DROP FUNCTION mixedcase' AND
|
|
state='Waiting for stored function metadata lock';
|
|
source include/wait_condition.inc;
|
|
SET DEBUG_SYNC='now SIGNAL continue';
|
|
|
|
--CONNECTION default
|
|
--REAP
|
|
|
|
--CONNECTION con1
|
|
--REAP
|
|
|
|
--echo # Case 2: Test case to verify MDL locking from concurrent SHOW FUNCTION
|
|
--echo # and DROP FUNCTION operation with case and accent insensitive
|
|
--echo # function name.
|
|
|
|
--CONNECTION default
|
|
CREATE FUNCTION mIxEdCaSe() RETURNS INT RETURN 1;
|
|
SET DEBUG_SYNC='after_acquiring_mdl_lock_on_routine SIGNAL locked WAIT_FOR continue';
|
|
--SEND DROP FUNCTION mIxEdCaSé;
|
|
--echo # At this point we have a exclusive lock on 'mIxEdCaSé'
|
|
|
|
--CONNECTION con1
|
|
SET DEBUG_SYNC='now WAIT_FOR locked';
|
|
--SEND SHOW CREATE FUNCTION MiXéDcAsE
|
|
--echo # This statement request for shared lock and it is blocked till DROP
|
|
--echo # statement releases lock.
|
|
|
|
--CONNECTION con2
|
|
let $wait_condition= SELECT COUNT(*) > 0 FROM information_schema.processlist
|
|
WHERE info LIKE 'SHOW CREATE FUNCTION%' AND
|
|
state='Waiting for stored function metadata lock';
|
|
source include/wait_condition.inc;
|
|
SET DEBUG_SYNC='now SIGNAL continue';
|
|
|
|
--CONNECTION default
|
|
--REAP
|
|
|
|
--CONNECTION con1
|
|
--error ER_SP_DOES_NOT_EXIST
|
|
--REAP
|
|
|
|
--echo # Case 3: Test case to verify MDL locking from concurrent DDL operations
|
|
--echo # with case and accent insensitive function name.
|
|
|
|
--CONNECTION default
|
|
CREATE FUNCTION mIxEdCaSe() RETURNS INT RETURN 1;
|
|
SET DEBUG_SYNC='after_acquiring_mdl_lock_on_routine SIGNAL locked WAIT_FOR continue';
|
|
--SEND DROP FUNCTION miXEDCAsé
|
|
--echo # At this point we have a exclusive lock on 'miXEDCAsé'
|
|
|
|
--CONNECTION con1
|
|
SET DEBUG_SYNC='now WAIT_FOR locked';
|
|
--SEND ALTER FUNCTION mixedcase COMMENT "comment_string";
|
|
--echo # This statement request for exclusive lock and it is blocked till DROP
|
|
--echo # statement releases lock.
|
|
|
|
--CONNECTION con2
|
|
let $wait_condition= SELECT COUNT(*) > 0 FROM information_schema.processlist
|
|
WHERE info LIKE 'ALTER FUNCTION mixedcase%' AND
|
|
state='Waiting for stored function metadata lock';
|
|
source include/wait_condition.inc;
|
|
SET DEBUG_SYNC='now SIGNAL continue';
|
|
|
|
--CONNECTION default
|
|
--REAP
|
|
|
|
--CONNECTION con1
|
|
--error ER_SP_DOES_NOT_EXIST
|
|
--REAP
|
|
|
|
--echo # Case 4: Test case to verify MDL locking from concurrent SHOW PROCEDURE
|
|
--echo # and DROP PROCEDURE operation with case and accent insensitive
|
|
--echo # procedure name.
|
|
|
|
--CONNECTION default
|
|
CREATE PROCEDURE mIxEdCaSe() BEGIN END;
|
|
SET DEBUG_SYNC='after_acquiring_mdl_lock_on_routine SIGNAL locked WAIT_FOR continue';
|
|
--SEND DROP PROCEDURE mIxEdCaSé;
|
|
--echo # At this point we have a exclusive lock on 'mIxEdCaSé'
|
|
|
|
--CONNECTION con1
|
|
SET DEBUG_SYNC='now WAIT_FOR locked';
|
|
--SEND SHOW CREATE PROCEDURE MiXéDcAsE
|
|
--echo # This statement request for shared lock and it is blocked till DROP
|
|
--echo # statement releases lock.
|
|
|
|
--CONNECTION con2
|
|
let $wait_condition= SELECT COUNT(*) > 0 FROM information_schema.processlist
|
|
WHERE info LIKE 'SHOW CREATE PROCEDURE%' AND
|
|
state='Waiting for stored procedure metadata lock';
|
|
source include/wait_condition.inc;
|
|
SET DEBUG_SYNC='now SIGNAL continue';
|
|
|
|
--CONNECTION default
|
|
--REAP
|
|
|
|
--CONNECTION con1
|
|
--error ER_SP_DOES_NOT_EXIST
|
|
--REAP
|
|
|
|
--echo # Case 5: Test case to verify MDL locking from concurrent DDL operations
|
|
--echo # with case & accent insensitive procedure name.
|
|
|
|
--CONNECTION default
|
|
CREATE PROCEDURE mIxEdCaSe() BEGIN END;
|
|
SET DEBUG_SYNC='after_acquiring_mdl_lock_on_routine SIGNAL locked WAIT_FOR continue';
|
|
--SEND DROP PROCEDURE miXEDCAsé
|
|
--echo # At this point we have a exclusive lock on 'miXEDCAsé'
|
|
|
|
--CONNECTION con1
|
|
SET DEBUG_SYNC='now WAIT_FOR locked';
|
|
--SEND ALTER PROCEDURE mixedcase COMMENT "comment_string";
|
|
--echo # This statement request for exclusive lock and it is blocked till DROP
|
|
--echo # statement releases lock.
|
|
|
|
--CONNECTION con2
|
|
let $wait_condition= SELECT COUNT(*) > 0 FROM information_schema.processlist
|
|
WHERE info LIKE 'ALTER PROCEDURE mixedcase%' AND
|
|
state='Waiting for stored procedure metadata lock';
|
|
source include/wait_condition.inc;
|
|
SET DEBUG_SYNC='now SIGNAL continue';
|
|
|
|
--CONNECTION default
|
|
--REAP
|
|
|
|
--CONNECTION con1
|
|
--error ER_SP_DOES_NOT_EXIST
|
|
--REAP
|
|
|
|
# Cleanup
|
|
--CONNECTION default
|
|
SET DEBUG_SYNC='RESET';
|
|
DISCONNECT con1;
|
|
DISCONNECT con2;
|
|
--disable_connect_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
|
|
|