diff options
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index ebbf4cafb19..0774b5ae42e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3486,6 +3486,15 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u) thd->binlog_start_trans_and_stmt(); } + /* + If error during the CREATE SELECT we drop the table, so no need for + engines to do logging of insertions (optimization). We don't do it for + temporary tables (yet) as re-enabling causes an undesirable commit. + */ + if (((thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) == 0) && + ha_enable_transaction(thd, FALSE)) + DBUG_RETURN(-1); + if (!(table= create_table_from_items(thd, create_info, create_table, alter_info, &values, &thd->extra_lock, hook_ptr))) @@ -3625,8 +3634,10 @@ bool select_create::send_eof() nevertheless. */ if (!table->s->tmp_table) + { + ha_enable_transaction(thd, TRUE); ha_commit(thd); // Can fail, but we proceed anyway - + } table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); if (thd->extra_lock) @@ -3651,6 +3662,9 @@ void select_create::abort() select_insert::abort(); reenable_binlog(thd); + if (table && !table->s->tmp_table) + ha_enable_transaction(thd, TRUE); + /* We roll back the statement, including truncating the transaction cache of the binary log, if the statement failed. |