Commit f924a94d authored by Aleksey Midenkov's avatar Aleksey Midenkov

SQL: disable versioned DML for transaction_registry=off [closes #364]

parent dcc00d2b
...@@ -355,6 +355,11 @@ rollback to a; ...@@ -355,6 +355,11 @@ rollback to a;
commit; commit;
call verify_vtq; call verify_vtq;
No A B C D No A B C D
set global transaction_registry= off;
insert into t2(x) values (1);
insert into t1(x) values (1);
ERROR HY000: Some versioned DML requires `transaction_registry` to be set to ON.
set global transaction_registry= on;
drop table t1; drop table t1;
drop table t2; drop table t2;
drop procedure test_01; drop procedure test_01;
......
...@@ -185,6 +185,12 @@ rollback to a; ...@@ -185,6 +185,12 @@ rollback to a;
commit; commit;
call verify_vtq; call verify_vtq;
set global transaction_registry= off;
insert into t2(x) values (1);
--error ER_VERS_TRT_IS_DISABLED
insert into t1(x) values (1);
set global transaction_registry= on;
drop table t1; drop table t1;
drop table t2; drop table t2;
......
...@@ -1414,16 +1414,14 @@ int ha_commit_trans(THD *thd, bool all) ...@@ -1414,16 +1414,14 @@ int ha_commit_trans(THD *thd, bool all)
goto err; goto err;
} }
if (rw_trans && use_transaction_registry) if (rw_trans)
{ {
ulonglong trx_start_id= 0, trx_end_id= 0; ulonglong trx_start_id= 0, trx_end_id= 0;
for (Ha_trx_info *ha_info= trans->ha_list; ha_info; for (Ha_trx_info *ha_info= trans->ha_list; ha_info; ha_info= ha_info->next())
ha_info= ha_info->next())
{ {
if (ulonglong (*prepare)(THD*,ulonglong*)= ha_info->ht()-> if (ha_info->ht()->prepare_commit_versioned)
prepare_commit_versioned)
{ {
trx_end_id= prepare(thd, &trx_start_id); trx_end_id= ha_info->ht()->prepare_commit_versioned(thd, &trx_start_id);
if (trx_end_id) if (trx_end_id)
break; // FIXME: use a common ID for cross-engine transactions break; // FIXME: use a common ID for cross-engine transactions
} }
...@@ -1431,6 +1429,11 @@ int ha_commit_trans(THD *thd, bool all) ...@@ -1431,6 +1429,11 @@ int ha_commit_trans(THD *thd, bool all)
if (trx_end_id) if (trx_end_id)
{ {
if (!use_transaction_registry)
{
my_error(ER_VERS_TRT_IS_DISABLED, MYF(0));
goto err;
}
DBUG_ASSERT(trx_start_id); DBUG_ASSERT(trx_start_id);
TR_table trt(thd, true); TR_table trt(thd, true);
if (trt.update(trx_start_id, trx_end_id)) if (trt.update(trx_start_id, trx_end_id))
......
...@@ -7913,3 +7913,6 @@ ER_NOT_LOG_TABLE ...@@ -7913,3 +7913,6 @@ ER_NOT_LOG_TABLE
ER_VERS_GENERATED_ALWAYS_NOT_EMPTY ER_VERS_GENERATED_ALWAYS_NOT_EMPTY
eng "Can not modify column `%s` to GENERATED ALWAYS AS ROW START/END for non-empty table" eng "Can not modify column `%s` to GENERATED ALWAYS AS ROW START/END for non-empty table"
ER_VERS_TRT_IS_DISABLED
eng "Some versioned DML requires `transaction_registry` to be set to ON."
...@@ -7442,17 +7442,23 @@ static bool mysql_inplace_alter_table(THD *thd, ...@@ -7442,17 +7442,23 @@ static bool mysql_inplace_alter_table(THD *thd,
{ {
TR_table trt(thd, true); TR_table trt(thd, true);
if (trt == *table_list || !use_transaction_registry); if (trt != *table_list && table->file->ht->prepare_commit_versioned)
else if (ulonglong (*prepare)(THD*,ulonglong*)= table->file->ht->
prepare_commit_versioned)
{ {
ulonglong trx_start_id, trx_end_id= prepare(thd, &trx_start_id); ulonglong trx_start_id= 0;
if (trx_end_id && trt.update(trx_start_id, trx_end_id)) ulonglong trx_end_id= table->file->ht->prepare_commit_versioned(thd, &trx_start_id);
if (trx_end_id)
{
if (!use_transaction_registry)
{
my_error(ER_VERS_TRT_IS_DISABLED, MYF(0));
goto rollback;
}
if (trt.update(trx_start_id, trx_end_id))
{ {
my_error(ER_UNKNOWN_ERROR, MYF(0));
goto rollback; goto rollback;
} }
} }
}
if (table->file->ha_commit_inplace_alter_table(altered_table, if (table->file->ha_commit_inplace_alter_table(altered_table,
ha_alter_info, ha_alter_info,
......
...@@ -423,11 +423,18 @@ static Sys_var_enum Sys_vers_alter_history( ...@@ -423,11 +423,18 @@ static Sys_var_enum Sys_vers_alter_history(
SESSION_VAR(vers_alter_history), CMD_LINE(REQUIRED_ARG), SESSION_VAR(vers_alter_history), CMD_LINE(REQUIRED_ARG),
vers_alter_history_keywords, DEFAULT(VERS_ALTER_HISTORY_ERROR)); vers_alter_history_keywords, DEFAULT(VERS_ALTER_HISTORY_ERROR));
static bool update_transaction_registry(sys_var *self, THD *thd, enum_var_type type)
{
use_transaction_registry= opt_transaction_registry;
return false;
}
static Sys_var_mybool Sys_transaction_registry( static Sys_var_mybool Sys_transaction_registry(
"transaction_registry", "transaction_registry",
"Enable or disable update of transaction_registry", "Enable or disable update of transaction_registry",
GLOBAL_VAR(opt_transaction_registry), CMD_LINE(OPT_ARG), GLOBAL_VAR(opt_transaction_registry), CMD_LINE(OPT_ARG),
DEFAULT(TRUE)); DEFAULT(TRUE), NO_MUTEX_GUARD, NOT_IN_BINLOG,
0, ON_UPDATE(update_transaction_registry));
static Sys_var_ulonglong Sys_binlog_cache_size( static Sys_var_ulonglong Sys_binlog_cache_size(
"binlog_cache_size", "The size of the transactional cache for " "binlog_cache_size", "The size of the transactional cache for "
......
...@@ -255,12 +255,12 @@ VTMD_table::update(THD *thd, const char* archive_name) ...@@ -255,12 +255,12 @@ VTMD_table::update(THD *thd, const char* archive_name)
} }
quit: quit:
if (result || !use_transaction_registry); if (!result && vtmd.table->file->ht->prepare_commit_versioned)
else if (ulonglong (*prepare)(THD*,ulonglong*)= vtmd.table->file->ht->
prepare_commit_versioned)
{ {
DBUG_ASSERT(use_transaction_registry); // FIXME: disable survival mode while TRT is disabled
TR_table trt(thd, true); TR_table trt(thd, true);
ulonglong trx_start_id, trx_end_id= prepare(thd, &trx_start_id); ulonglong trx_start_id= 0;
ulonglong trx_end_id= vtmd.table->file->ht->prepare_commit_versioned(thd, &trx_start_id);
result= trx_end_id && trt.update(trx_start_id, trx_end_id); result= trx_end_id && trt.update(trx_start_id, trx_end_id);
} }
......
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