mirror of
https://github.com/MariaDB/server.git
synced 2025-07-24 19:42:23 +03:00
The InnoDB background DROP TABLE queue is something that we should really remove, but are unable to until we remove dict_operation_lock so that DDL and DML operations can be combined in a single transaction. Because the queue is not persistent, it is not crash-safe. We should in some way ensure that the deferred-dropped tables will be dropped after server restart. The existence of two separate transactions complicates the error handling of CREATE TABLE...SELECT. We should really not break locks in DROP TABLE. Our solution to these problems is to rename the table to a temporary name, and to drop such-named tables on InnoDB startup. Also, the queue will use table IDs instead of names from now on. check-testcase.test: Ignore #sql-ib*.ibd files, because tables may enter the background DROP TABLE queue shortly before the test finishes. innodb.drop_table_background: Test CREATE...SELECT and the creation of tables whose file name starts with #sql-ib. innodb.alter_crash: Adjust the recovery, now that the #sql-ib tables will be dropped on InnoDB startup. row_mysql_drop_garbage_tables(): New function, to drop all #sql-ib tables on InnoDB startup. row_drop_table_for_mysql_in_background(): Remove an unnecessary and misplaced call to log_buffer_flush_to_disk(). (The call should have been after the transaction commit. We do not care about flushing the redo log here, because the table would be dropped again at server startup.) Remove the entry from the list after the table no longer exists. If server shutdown has been initiated, empty the list without actually dropping any tables. They will be dropped again on startup. row_drop_table_for_mysql(): Do not call lock_remove_all_on_table(). Instead, if locks exist, defer the DROP TABLE until they do not exist. If the table name does not start with #sql-ib, rename it to that prefix before adding it to the background DROP TABLE queue.
25 lines
1015 B
Plaintext
25 lines
1015 B
Plaintext
CREATE TABLE t(c0 SERIAL, c1 INT, c2 INT, c3 INT, c4 INT,
|
|
KEY(c1), KEY(c2), KEY(c2,c1),
|
|
KEY(c3), KEY(c3,c1), KEY(c3,c2), KEY(c3,c2,c1),
|
|
KEY(c4), KEY(c4,c1), KEY(c4,c2), KEY(c4,c2,c1),
|
|
KEY(c4,c3), KEY(c4,c3,c1), KEY(c4,c3,c2), KEY(c4,c3,c2,c1)) ENGINE=InnoDB;
|
|
CREATE TABLE `#mysql50##sql-ib-foo`(a SERIAL) ENGINE=InnoDB;
|
|
INSERT INTO t (c1) VALUES (1),(2),(1);
|
|
SET DEBUG_DBUG='+d,row_drop_table_add_to_background';
|
|
CREATE TABLE target (PRIMARY KEY(c1)) ENGINE=InnoDB SELECT * FROM t;
|
|
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
|
SELECT * from target;
|
|
ERROR 42S02: Table 'test.target' doesn't exist
|
|
DROP TABLE t;
|
|
CREATE TABLE t (a INT) ENGINE=InnoDB;
|
|
DROP TABLE t;
|
|
DROP TABLE target;
|
|
ERROR 42S02: Unknown table 'test.target'
|
|
CREATE TABLE target (a INT) ENGINE=InnoDB;
|
|
DROP TABLE target;
|
|
SELECT * FROM `#mysql50##sql-ib-foo`;
|
|
ERROR 42S02: Table 'test.#mysql50##sql-ib-foo' doesn't exist in engine
|
|
DROP TABLE `#mysql50##sql-ib-foo`;
|
|
Warnings:
|
|
Warning 1932 Table 'test.#mysql50##sql-ib-foo' doesn't exist in engine
|