summaryrefslogtreecommitdiff
path: root/storage/innobase/row/row0mysql.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-10-10 12:06:19 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-10-10 12:06:19 +0300
commitf58a0b3afc4277f9ed077d939be135580f116352 (patch)
treeabd7dc2671de7150fe8039011ecef809ea3e0b14 /storage/innobase/row/row0mysql.cc
parentcd081734906cc10253f2e09e3b94a737dab07c82 (diff)
downloadmariadb-git-f58a0b3afc4277f9ed077d939be135580f116352.tar.gz
MDEV-15562: Simplify FOREIGN KEY error handling on DDL
The error handling for ALTER TABLE…ALGORITHM=COPY as well as CREATE TABLE used to commit the CREATE TABLE transaction and then issue DROP TABLE in a separate transaction. This is unnecessarily breaking atomicity during DDL operations. Let us revise it so that the DROP TABLE will be executed within the same transaction, which will finally be rolled back. FIXME: Introduce an undo log record so that the data file would be deleted on rollback and no DROP TABLE would be needed at all. FIXME: Avoid unnecessary access to per-table tablespace during DROP TABLE. If the .ibd file is going to be deleted anyway, we should not bother to mark the pages free. dict_create_add_foreigns_to_dictionary(): Do not commit the transaction. We want simple rollback in case dict_load_foreigns() would fail. create_table_info_t::create_table(), row_create_index_for_mysql(), row_table_add_foreign_constraints(): Before invoking rollback, drop the table. Rollback would invoke trx_t::evict_table(), and after that dropping the table would be a no-op. ha_innobase::create(): Before rollback, drop the table. If the SQL layer invoked ha_innobase::delete_table() later, it would be a no-op because the rollback would have invoked trx_t::evict_table().
Diffstat (limited to 'storage/innobase/row/row0mysql.cc')
-rw-r--r--storage/innobase/row/row0mysql.cc26
1 files changed, 9 insertions, 17 deletions
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index 1d6c6a957dd..e65ca48811d 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -2604,16 +2604,10 @@ error_handling:
trx->error_state = DB_SUCCESS;
if (trx_is_started(trx)) {
-
+ row_drop_table_for_mysql(table->name.m_name, trx,
+ SQLCOM_DROP_TABLE, true);
trx_rollback_to_savepoint(trx, NULL);
- }
-
- row_drop_table_for_mysql(table->name.m_name, trx,
- SQLCOM_DROP_TABLE, true);
-
- if (trx_is_started(trx)) {
-
- trx_commit_for_mysql(trx);
+ ut_ad(!trx_is_started(trx));
}
trx->error_state = DB_SUCCESS;
@@ -2691,15 +2685,13 @@ row_table_add_foreign_constraints(
trx->error_state = DB_SUCCESS;
if (trx_is_started(trx)) {
-
+ /* FIXME: Introduce an undo log record for
+ creating tablespaces and data files, so that
+ they would be deleted on rollback. */
+ row_drop_table_for_mysql(name, trx, SQLCOM_DROP_TABLE,
+ true);
trx_rollback_to_savepoint(trx, NULL);
- }
-
- row_drop_table_for_mysql(name, trx, SQLCOM_DROP_TABLE, true);
-
- if (trx_is_started(trx)) {
-
- trx_commit_for_mysql(trx);
+ ut_ad(!trx_is_started(trx));
}
trx->error_state = DB_SUCCESS;