1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
--source include/have_debug.inc
--source include/have_debug_sync.inc
# Some parts of the test require enabled binary log.
--source include/have_log_bin.inc
--echo #
--echo # Bug#22653180:ASSERT DD::CACHE::SHARED_MULTI_MAP<T>::
--echo # PUT(CONST K*, CONST T*, DD::CACHE::CACHE
--echo #
CREATE TABLE t1(i int);
--echo # Force rename_table to fail after update has been applied to dd cache
SET SESSION debug="+d,abort_rename_after_update";
--echo # rename table will fail with dummy error
--error ER_ERROR_ON_WRITE
RENAME TABLE t1 to t2;
SET SESSION debug="-d,abort_rename_after_update";
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Part of test coverage for WL#9826 "Allow RENAME TABLES under
--echo # LOCK TABLES" which needs debug build and debug_sync facility.
--echo #
--echo # The main part of coverage for this WL resides in rename.test.
--echo # This file only contains subtests which require debug/debug_sync
--echo # facilities, hence their odd numbering.
--enable_connect_log
SET @old_lock_wait_timeout= @@lock_wait_timeout;
connect (con1, localhost, root,,);
SET @old_lock_wait_timeout= @@lock_wait_timeout;
connection default;
--echo #
--echo # 1) Requirements on table locking for tables renamed and
--echo # target table names.
--echo #
--echo #
--echo # 1.2) Locking of target table.
CREATE TABLE t1 (i INT);
CREATE TABLE t2 (j INT);
--echo # RENAME TABLE under LOCK TABLES acquires X metadata
--echo # lock on target table name.
connection con1;
--echo # Ensure that table is cached in Table and Table Definition Caches.
SELECT * FROM t1;
SET DEBUG_SYNC='open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR go';
--send SHOW CREATE TABLE t1
connection default;
--echo # Wait until SHOW CREATE TABLE acquires SH MDL on t1 and
--echo # starts waiting.
SET DEBUG_SYNC='now WAIT_FOR opened';
LOCK TABLES t2 WRITE;
--echo # RENAME TABLE fails due to lock timeout since it tries
--echo # to acquire X metadata lock on t1, on which SH metadata
--echo # lock is held in con1.
SET @@lock_wait_timeout= 1;
--error ER_LOCK_WAIT_TIMEOUT
RENAME TABLE t2 TO t1;
SET @@lock_wait_timeout= @old_lock_wait_timeout;
UNLOCK TABLES;
--echo #
--echo # 2) Failure to acquire/upgrade locks on tables involved.
--echo #
--echo # Failure to upgrade metadata lock on source table to X mode.
--echo # (note that con1 still holds SH lock on it).
LOCK TABLE t1 WRITE;
SET @@lock_wait_timeout= 1;
--error ER_LOCK_WAIT_TIMEOUT
RENAME TABLE t1 TO t3;
SET @@lock_wait_timeout= @old_lock_wait_timeout;
UNLOCK TABLES;
--echo #
--echo # Failure to acquire X metadata lock on target table name.
LOCK TABLES t2 WRITE;
SET @@lock_wait_timeout= 1;
--error ER_LOCK_WAIT_TIMEOUT
RENAME TABLE t2 TO t1;
UNLOCK TABLES;
--echo # Unblock and reap SHOW CREATE TABLE.
SET DEBUG_SYNC='now SIGNAL go';
connection con1;
--reap
connection default;
SET DEBUG_SYNC='RESET';
DROP TABLES t1, t2;
--echo #
--echo # 5) RENAME TABLES under LOCK TABLES and views.
--echo #
--echo # 5.1) Requirements on locking is similar to tables.
CREATE TABLE t1 (i INT);
CREATE TABLE t2 (j INT);
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE VIEW v2 AS SELECT * FROM t2;
--echo #
--echo # RENAME TABLE on view under LOCK TABLES acquires X metadata
--echo # lock on target name.
connection con1;
SET DEBUG_SYNC='open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR go';
--send SHOW CREATE VIEW v2
connection default;
--echo # Wait until SHOW CREATE VIEW acquires SH MDL on v2 and
--echo # starts waiting.
SET DEBUG_SYNC='now WAIT_FOR opened';
LOCK TABLES v1 WRITE;
--echo # RENAME TABLE fails due to lock timeout since it tries
--echo # to acquire X metadata lock on v2, on which SH metadata
--echo # lock is held in con1.
SET @@lock_wait_timeout= 1;
--error ER_LOCK_WAIT_TIMEOUT
RENAME TABLE v1 TO v2;
SET @@lock_wait_timeout= @old_lock_wait_timeout;
UNLOCK TABLES;
--echo # Unblock and reap SHOW CREATE VIEW.
SET DEBUG_SYNC='now SIGNAL go';
connection con1;
--reap
connection default;
SET DEBUG_SYNC='RESET';
DROP VIEW v1;
DROP VIEW v2;
DROP TABLES t1, t2;
--echo # Clean-up.
connection con1;
disconnect con1;
--source include/wait_until_disconnected.inc
connection default;
--disable_connect_log
|