Commit ca12435f authored by unknown's avatar unknown

Fix for "innodb_mysql" and "events" failures: we can disable transactionality

in CREATE SELECT only if the table is not temporary (because
re-enabling causes a commit). In the future we should disable
again for temporary tables; that will probably require changing
ha_enable_transaction().


sql/sql_insert.cc:
  When we disable transactionality in CREATE SELECT, we re-enable it
  at the end and this causes a commit (inside ha_enable_transaction());
  but this is undesired if the created table is temporary (we don't
  want CREATE TEMPORARY TABLE SELECT to commit all previous statements).
  So we disable logging only if the table is not temporary.
  Ideally in the future we would want to lift this restriction which
  sounds stupid, but for Maria it does not matter now (temporary
  tables are not transactional yet).
parent 69c18ca5
...@@ -3460,9 +3460,11 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u) ...@@ -3460,9 +3460,11 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
/* /*
If error during the CREATE SELECT we drop the table, so no need for If error during the CREATE SELECT we drop the table, so no need for
engines to do logging of insertions (optimization). engines to do logging of insertions (optimization). We don't do it for
temporary tables (yet) as re-enabling causes an undesirable commit.
*/ */
if (ha_enable_transaction(thd, FALSE)) if (((thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) == 0) &&
ha_enable_transaction(thd, FALSE))
DBUG_RETURN(-1); 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,
...@@ -3605,11 +3607,12 @@ bool select_create::send_eof() ...@@ -3605,11 +3607,12 @@ bool select_create::send_eof()
nevertheless. nevertheless.
*/ */
if (!table->s->tmp_table) if (!table->s->tmp_table)
{
ha_enable_transaction(thd, TRUE);
ha_commit(thd); // Can fail, but we proceed anyway ha_commit(thd); // Can fail, but we proceed anyway
}
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);
...@@ -3632,6 +3635,9 @@ void select_create::abort() ...@@ -3632,6 +3635,9 @@ void select_create::abort()
select_insert::abort(); select_insert::abort();
reenable_binlog(thd); reenable_binlog(thd);
if (table && !table->s->tmp_table)
ha_enable_transaction(thd, TRUE);
/* /*
We roll back the statement, including truncating the transaction We roll back the statement, including truncating the transaction
cache of the binary log, if the statement failed. cache of the binary log, if the statement failed.
...@@ -3648,8 +3654,6 @@ void select_create::abort() ...@@ -3648,8 +3654,6 @@ 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