diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-11-26 17:30:39 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-11-26 17:32:57 +0200 |
commit | 861038f2e8e68574ef3d9e2e250ac71fdd7a4c53 (patch) | |
tree | 966a7f5e75171320ad7d3e181c661741807a2508 | |
parent | 971e1d8677be58cd51e558ef80042c76a5c21e1a (diff) | |
download | mariadb-git-861038f2e8e68574ef3d9e2e250ac71fdd7a4c53.tar.gz |
MDEV-17816: Follow-up fix
When dropping a partially created table due to failure,
use SQLCOM_TRUNCATE instead of SQLCOM_DROP_DB, so that
no foreign key constraints will be touched. If any
constraints were added as part of the creation, they would
be reverted as part of the transaction rollback.
We need an explicit call to row_drop_table_for_mysql(),
because InnoDB does not do proper undo logging for CREATE TABLE,
but would only drop the table at the end of the rollback.
This would not work if the transaction combines both
RENAME and CREATE, like TRUNCATE now does.
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 2a73afafcb4..00672bf91bd 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -12613,7 +12613,7 @@ int create_table_info_t::create_table(bool create_fk) the failed creation. */ m_trx->error_state = DB_SUCCESS; row_drop_table_for_mysql(m_table_name, m_trx, - SQLCOM_DROP_DB); + SQLCOM_TRUNCATE); trx_rollback_to_savepoint(m_trx, NULL); m_trx->error_state = DB_SUCCESS; @@ -12861,7 +12861,7 @@ ha_innobase::create( that could have been renamed before the failed creation. */ trx->error_state = DB_SUCCESS; row_drop_table_for_mysql(info.table_name(), trx, - SQLCOM_DROP_DB, true); + SQLCOM_TRUNCATE, true); trx_rollback_for_mysql(trx); row_mysql_unlock_data_dictionary(trx); if (own_trx) { |