mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Backport of:
------------------------------------------------------------ revno: 2630.22.3 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: 4284-6.0 timestamp: Thu 2008-08-07 22:33:43 -0300 message: WL#4284: Transactional DDL locking Make transaction management more modular through a new interface. The overall objective of this change is to provide groundwork for the design of transactional DDL locking by cleaning up the transaction high level API to better distinguish operations implicit and explicit, and single statement transaction from operations on the normal transaction. Having a a high-level interface for transaction management provides a better base for implementing transactional concepts that are not always tied to storage engines and also makes it easier to interect with other higher level modules of the server.
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
#include "sp_head.h"
|
||||
#include "sql_trigger.h"
|
||||
#include "sql_show.h"
|
||||
#include "transaction.h"
|
||||
|
||||
#ifdef __WIN__
|
||||
#include <io.h>
|
||||
@ -4668,8 +4669,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
DBUG_PRINT("admin", ("calling prepare_func"));
|
||||
switch ((*prepare_func)(thd, table, check_opt)) {
|
||||
case 1: // error, message written to net
|
||||
ha_autocommit_or_rollback(thd, 1);
|
||||
end_trans(thd, ROLLBACK);
|
||||
trans_rollback_stmt(thd);
|
||||
trans_rollback(thd);
|
||||
close_thread_tables(thd);
|
||||
DBUG_PRINT("admin", ("simple error, admin next table"));
|
||||
continue;
|
||||
@ -4740,8 +4741,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
length= my_snprintf(buff, sizeof(buff), ER(ER_OPEN_AS_READONLY),
|
||||
table_name);
|
||||
protocol->store(buff, length, system_charset_info);
|
||||
ha_autocommit_or_rollback(thd, 0);
|
||||
end_trans(thd, COMMIT);
|
||||
trans_commit_stmt(thd);
|
||||
trans_commit(thd);
|
||||
close_thread_tables(thd);
|
||||
lex->reset_query_tables_list(FALSE);
|
||||
table->table=0; // For query cache
|
||||
@ -4790,7 +4791,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
HA_ADMIN_NEEDS_ALTER))
|
||||
{
|
||||
DBUG_PRINT("admin", ("recreating table"));
|
||||
ha_autocommit_or_rollback(thd, 1);
|
||||
trans_rollback_stmt(thd);
|
||||
close_thread_tables(thd);
|
||||
tmp_disable_binlog(thd); // binlogging is done by caller if wanted
|
||||
result_code= mysql_recreate_table(thd, table);
|
||||
@ -4910,7 +4911,7 @@ send_result_message:
|
||||
system_charset_info);
|
||||
if (protocol->write())
|
||||
goto err;
|
||||
ha_autocommit_or_rollback(thd, 0);
|
||||
trans_commit_stmt(thd);
|
||||
close_thread_tables(thd);
|
||||
DBUG_PRINT("info", ("HA_ADMIN_TRY_ALTER, trying analyze..."));
|
||||
TABLE_LIST *save_next_local= table->next_local,
|
||||
@ -4927,7 +4928,7 @@ send_result_message:
|
||||
*/
|
||||
if (thd->stmt_da->is_ok())
|
||||
thd->stmt_da->reset_diagnostics_area();
|
||||
ha_autocommit_or_rollback(thd, 0);
|
||||
trans_commit_stmt(thd);
|
||||
close_thread_tables(thd);
|
||||
if (!result_code) // recreation went ok
|
||||
{
|
||||
@ -5022,8 +5023,8 @@ send_result_message:
|
||||
query_cache_invalidate3(thd, table->table, 0);
|
||||
}
|
||||
}
|
||||
ha_autocommit_or_rollback(thd, 0);
|
||||
end_trans(thd, COMMIT);
|
||||
trans_commit_stmt(thd);
|
||||
trans_commit_implicit(thd);
|
||||
close_thread_tables(thd);
|
||||
table->table=0; // For query cache
|
||||
if (protocol->write())
|
||||
@ -5034,8 +5035,8 @@ send_result_message:
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
err:
|
||||
ha_autocommit_or_rollback(thd, 1);
|
||||
end_trans(thd, ROLLBACK);
|
||||
trans_rollback_stmt(thd);
|
||||
trans_rollback(thd);
|
||||
close_thread_tables(thd); // Shouldn't be needed
|
||||
if (table)
|
||||
table->table=0;
|
||||
@ -5550,15 +5551,15 @@ mysql_discard_or_import_tablespace(THD *thd,
|
||||
query_cache_invalidate3(thd, table_list, 0);
|
||||
|
||||
/* The ALTER TABLE is always in its own transaction */
|
||||
error = ha_autocommit_or_rollback(thd, 0);
|
||||
if (end_active_trans(thd))
|
||||
error= trans_commit_stmt(thd);
|
||||
if (trans_commit_implicit(thd))
|
||||
error=1;
|
||||
if (error)
|
||||
goto err;
|
||||
write_bin_log(thd, FALSE, thd->query(), thd->query_length());
|
||||
|
||||
err:
|
||||
ha_autocommit_or_rollback(thd, error);
|
||||
trans_rollback_stmt(thd);
|
||||
thd->tablespace_op=FALSE;
|
||||
|
||||
if (error == 0)
|
||||
@ -7208,8 +7209,8 @@ view_err:
|
||||
thd_proc_info(thd, "manage keys");
|
||||
alter_table_manage_keys(table, table->file->indexes_are_disabled(),
|
||||
alter_info->keys_onoff);
|
||||
error= ha_autocommit_or_rollback(thd, 0);
|
||||
if (end_active_trans(thd))
|
||||
error= trans_commit_stmt(thd);
|
||||
if (trans_commit_implicit(thd))
|
||||
error= 1;
|
||||
}
|
||||
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
|
||||
@ -7297,7 +7298,7 @@ view_err:
|
||||
|
||||
/* Need to commit before a table is unlocked (NDB requirement). */
|
||||
DBUG_PRINT("info", ("Committing before unlocking table"));
|
||||
if (ha_autocommit_or_rollback(thd, 0) || end_active_trans(thd))
|
||||
if (trans_commit_stmt(thd) || trans_commit_implicit(thd))
|
||||
goto err_new_table_cleanup;
|
||||
committed= 1;
|
||||
}
|
||||
@ -7803,9 +7804,9 @@ copy_data_between_tables(TABLE *from,TABLE *to,
|
||||
Ensure that the new table is saved properly to disk so that we
|
||||
can do a rename
|
||||
*/
|
||||
if (ha_autocommit_or_rollback(thd, 0))
|
||||
if (trans_commit_stmt(thd))
|
||||
error=1;
|
||||
if (end_active_trans(thd))
|
||||
if (trans_commit_implicit(thd))
|
||||
error=1;
|
||||
|
||||
err:
|
||||
|
Reference in New Issue
Block a user