| 1 |
# This test attempts to show that OPTIMIZE on a child table does NOT |
| 2 |
# acquire MDL locks on the parent table. # |
| 3 |
# param: $table_admin_command |
| 4 |
# DDL table command to test, script will build full SQL statement: |
| 5 |
# $table_admin_command TABLE c; |
| 6 |
# |
| 7 |
# param: $FK_constraint |
| 8 |
# Foreign key constraint to use when creating the child table. |
| 9 |
# |
| 10 |
|
| 11 |
CREATE TABLE parent (pk INTEGER PRIMARY KEY); |
| 12 |
--eval CREATE TABLE child (pk INTEGER PRIMARY KEY, parent_id INTEGER, FOREIGN KEY(parent_id) REFERENCES parent(pk) $fk_constraint) |
| 13 |
|
| 14 |
INSERT INTO parent VALUES (1), (2), (3), (4); |
| 15 |
INSERT INTO child VALUES (1,1), (2,2), (3,3), (4,4); |
| 16 |
|
| 17 |
--connection node_1 |
| 18 |
# Start a transaction that uses the parent table, |
| 19 |
# so that we acquire MDL lock on parent. |
| 20 |
START TRANSACTION; |
| 21 |
SELECT * FROM parent FOR UPDATE; |
| 22 |
|
| 23 |
# In a different connection, execute the table |
| 24 |
# admin command (OPTIMIZE / REPAIR ...) on the child table. |
| 25 |
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 |
| 26 |
--eval $table_admin_command TABLE child; |
| 27 |
|
| 28 |
# Expect no conflict. |
| 29 |
--connection node_1 |
| 30 |
COMMIT; |
| 31 |
|
| 32 |
DROP TABLE child, parent; |
| 33 |
|
| 34 |
--disconnect node_1a |