diff options
author | unknown <guilhem@gbichot4.local> | 2007-09-24 10:24:51 +0200 |
---|---|---|
committer | unknown <guilhem@gbichot4.local> | 2007-09-24 10:24:51 +0200 |
commit | e57cccc65ca6d6a7da8f1fa7e7efb9826defebd1 (patch) | |
tree | b4f4c89ae027e7ee85a6caeb6a1cc63237507bfc /sql | |
parent | cfc49fdcb6b8c6519299e69e26aa2f91abf76747 (diff) | |
download | mariadb-git-e57cccc65ca6d6a7da8f1fa7e7efb9826defebd1.tar.gz |
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?
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_insert.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 11db88d8f5e..d7267e6ecf6 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3458,6 +3458,13 @@ 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). + */ + if (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))) @@ -3602,6 +3609,7 @@ bool select_create::send_eof() table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); + ha_enable_transaction(thd, TRUE); if (thd->extra_lock) { mysql_unlock_tables(thd, thd->extra_lock); @@ -3640,6 +3648,8 @@ void select_create::abort() if (thd->current_stmt_binlog_row_based) ha_rollback_stmt(thd); + ha_enable_transaction(thd, TRUE); + if (thd->extra_lock) { mysql_unlock_tables(thd, thd->extra_lock); |