Commit 751cdc41 authored by unknown's avatar unknown

Optimization (useful at least for the Maria engine): we disable

logging of insertions made by CREATE SELECT.


sql/sql_insert.cc:
  If error during the CREATE SELECT we drop the table, so no need for
  engines to do logging of the insertions (optimization). Engines
  require that disabling is done before locking and re-enabling is done
  before unlocking; as table creation and locking is done as one
  function (create_table_from_items()) we disable before calling
  this function and re-enable before unlocking, in send_eof() (called
  if success) and abort() (called if error).
  Question for reviewer: would it be better to do the disabling between
  creation and locking, so inside create_table_from_items(), given
  that this function is used only by CREATE SELECT?
parent d3c7bf9d
...@@ -3458,6 +3458,13 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u) ...@@ -3458,6 +3458,13 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
thd->binlog_start_trans_and_stmt(); 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).
*/
if (ha_enable_transaction(thd, FALSE))
DBUG_RETURN(-1);
if (!(table= create_table_from_items(thd, create_info, create_table, if (!(table= create_table_from_items(thd, create_info, create_table,
alter_info, &values, alter_info, &values,
&thd->extra_lock, hook_ptr))) &thd->extra_lock, hook_ptr)))
...@@ -3602,6 +3609,7 @@ bool select_create::send_eof() ...@@ -3602,6 +3609,7 @@ bool select_create::send_eof()
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
ha_enable_transaction(thd, TRUE);
if (thd->extra_lock) if (thd->extra_lock)
{ {
mysql_unlock_tables(thd, thd->extra_lock); mysql_unlock_tables(thd, thd->extra_lock);
...@@ -3640,6 +3648,8 @@ void select_create::abort() ...@@ -3640,6 +3648,8 @@ void select_create::abort()
if (thd->current_stmt_binlog_row_based) if (thd->current_stmt_binlog_row_based)
ha_rollback_stmt(thd); ha_rollback_stmt(thd);
ha_enable_transaction(thd, TRUE);
if (thd->extra_lock) if (thd->extra_lock)
{ {
mysql_unlock_tables(thd, thd->extra_lock); mysql_unlock_tables(thd, thd->extra_lock);
......
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