Commit 861038f2 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 971e1d86
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment