remove "Transaction-based system versioning is EXPERIMENTAL" warning

and the system_versioning_transaction_registry variable.
The user enables transaction registry by specifying BIGINT for
row_start/row_end columns.

check mysql.transaction_registry structure on the first open,
not on startup. Avoid warnings unless transaction_registry
is actually used.
This commit is contained in:
Sergei Golubchik 2018-01-10 16:12:24 +01:00
parent 7e1738c3c4
commit a544f920e3
21 changed files with 22 additions and 174 deletions

View File

@ -1227,9 +1227,6 @@ The following options may be given as the first argument:
Use simple algorithm of timestamp handling in InnoDB
instead of TRX_SEES
(Defaults to on; use --skip-system-versioning-innodb-algorithm-simple to disable.)
--system-versioning-transaction-registry
Enable or disable update of
`mysql`.`transaction_registry`
--table-cache=# Deprecated; use --table-open-cache instead.
--table-definition-cache=#
The number of cached table definitions
@ -1660,7 +1657,6 @@ sync-relay-log-info 10000
sysdate-is-now FALSE
system-versioning-alter-history ERROR
system-versioning-innodb-algorithm-simple TRUE
system-versioning-transaction-registry FALSE
table-cache 431
table-definition-cache 400
table-open-cache 431

View File

@ -18,9 +18,6 @@ select a from t for system_time all;
a
2
1
set global system_versioning_transaction_registry=on;
Warnings:
Warning 4143 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
create or replace table t (
a int,
s bigint unsigned as row start invisible,
@ -50,4 +47,3 @@ a
2
1
drop table t;
set global system_versioning_transaction_registry=off;

View File

@ -22,7 +22,6 @@ select a from t for system_time all;
rmdir $targetdir;
set global system_versioning_transaction_registry=on;
create or replace table t (
a int,
s bigint unsigned as row start invisible,
@ -48,5 +47,4 @@ select * from t;
select a from t for system_time all;
drop table t;
set global system_versioning_transaction_registry=off;
rmdir $targetdir;

View File

@ -4100,20 +4100,6 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME SYSTEM_VERSIONING_TRANSACTION_REGISTRY
SESSION_VALUE NULL
GLOBAL_VALUE OFF
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE OFF
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Enable or disable update of `mysql`.`transaction_registry`
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME TABLE_DEFINITION_CACHE
SESSION_VALUE NULL
GLOBAL_VALUE 400

View File

@ -5052,20 +5052,6 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME SYSTEM_VERSIONING_TRANSACTION_REGISTRY
SESSION_VALUE NULL
GLOBAL_VALUE OFF
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE OFF
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Enable or disable update of `mysql`.`transaction_registry`
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME TABLE_DEFINITION_CACHE
SESSION_VALUE NULL
GLOBAL_VALUE 400

View File

@ -1,2 +1 @@
--system-versioning-transaction-registry=1
--plugin-load-add=test_versioning

View File

@ -284,13 +284,7 @@ rollback to a;
commit;
call verify_vtq;
No A B C D
set global system_versioning_transaction_registry= off;
insert into t2(x) values (1);
insert into t1(x) values (1);
ERROR HY000: Temporal operation requires `mysql.transaction_registry` (@@system_versioning_transaction_registry).
set global system_versioning_transaction_registry= on;
Warnings:
Warning 4134 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
create or replace table t1 (
x int,
y int as (x) virtual,

View File

@ -12,9 +12,6 @@ alter table t drop system versioning, lock=none;
ERROR 0A000: LOCK=NONE is not supported. Reason: Not implemented for system-versioned tables. Try LOCK=SHARED
alter table t drop system versioning, algorithm=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Not implemented for system-versioned tables. Try ALGORITHM=COPY
set global system_versioning_transaction_registry=on;
Warnings:
Warning 4134 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
create or replace table t (a int, b int) engine=innodb;
alter table t
add s bigint unsigned as row start,
@ -34,5 +31,4 @@ alter table t add index idx(a), lock=none;
alter table t drop column s, drop column e;
alter table t drop system versioning, lock=none;
ERROR 0A000: LOCK=NONE is not supported. Reason: Not implemented for system-versioned tables. Try LOCK=SHARED
set global system_versioning_transaction_registry=off;
drop table t;

View File

@ -1,16 +1,3 @@
select @@system_versioning_transaction_registry;
@@system_versioning_transaction_registry
0
create or replace table t1 (
x int,
sys_trx_start bigint(20) unsigned as row start invisible,
sys_trx_end bigint(20) unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
ERROR HY000: Temporal operation requires `mysql.transaction_registry` (@@system_versioning_transaction_registry).
set global system_versioning_transaction_registry= 1;
Warnings:
Warning 4134 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
create or replace table t1 (
x int,
sys_trx_start bigint(20) unsigned as row start invisible,
@ -18,21 +5,11 @@ sys_trx_end bigint(20) unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
insert into t1 (x) values (1);
set global system_versioning_transaction_registry= 0;
insert into t1 (x) values (2);
ERROR HY000: Temporal operation requires `mysql.transaction_registry` (@@system_versioning_transaction_registry).
delete from t1;
ERROR HY000: Temporal operation requires `mysql.transaction_registry` (@@system_versioning_transaction_registry).
update t1 set x= 3;
ERROR HY000: Temporal operation requires `mysql.transaction_registry` (@@system_versioning_transaction_registry).
# ALTER ADD SYSTEM VERSIONING should write to mysql.transaction_registry
create function check_result (cond boolean)
returns char(50) deterministic
return if(cond = 1, '[CORRECT]', '[INCORRECT]');
set @@system_versioning_alter_history=keep;
set global system_versioning_transaction_registry=on;
Warnings:
Warning 4134 Transaction-based system versioning is EXPERIMENTAL and is subject to change in future.
create or replace table t1 (x int) engine innodb;
insert into t1 values (1);
alter table t1
@ -92,5 +69,4 @@ select sys_end = 18446744073709551615 as transaction_based from t1 for system_ti
transaction_based
1
drop table t1;
set global system_versioning_transaction_registry=off;
drop function check_result;

View File

@ -188,11 +188,7 @@ rollback to a;
commit;
call verify_vtq;
set global system_versioning_transaction_registry= off;
insert into t2(x) values (1);
--error ER_VERS_TRT_IS_DISABLED
insert into t1(x) values (1);
set global system_versioning_transaction_registry= on;
# virtual columns
create or replace table t1 (

View File

@ -18,7 +18,6 @@ alter table t drop system versioning, lock=none;
alter table t drop system versioning, algorithm=inplace;
set global system_versioning_transaction_registry=on;
create or replace table t (a int, b int) engine=innodb;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
@ -40,6 +39,4 @@ alter table t drop column s, drop column e;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t drop system versioning, lock=none;
set global system_versioning_transaction_registry=off;
drop table t;

View File

@ -1,18 +1,6 @@
-- source include/have_innodb.inc
-- source include/not_embedded.inc
select @@system_versioning_transaction_registry;
--error ER_VERS_TRT_IS_DISABLED
create or replace table t1 (
x int,
sys_trx_start bigint(20) unsigned as row start invisible,
sys_trx_end bigint(20) unsigned as row end invisible,
period for system_time (sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
set global system_versioning_transaction_registry= 1;
create or replace table t1 (
x int,
sys_trx_start bigint(20) unsigned as row start invisible,
@ -22,21 +10,12 @@ create or replace table t1 (
insert into t1 (x) values (1);
set global system_versioning_transaction_registry= 0;
--error ER_VERS_TRT_IS_DISABLED
insert into t1 (x) values (2);
--error ER_VERS_TRT_IS_DISABLED
delete from t1;
--error ER_VERS_TRT_IS_DISABLED
update t1 set x= 3;
--echo # ALTER ADD SYSTEM VERSIONING should write to mysql.transaction_registry
create function check_result (cond boolean)
returns char(50) deterministic
return if(cond = 1, '[CORRECT]', '[INCORRECT]');
set @@system_versioning_alter_history=keep;
set global system_versioning_transaction_registry=on;
create or replace table t1 (x int) engine innodb;
insert into t1 values (1);
@ -93,5 +72,4 @@ alter table t1 drop column sys_start, drop column sys_end;
select sys_end = 18446744073709551615 as transaction_based from t1 for system_time all;
drop table t1;
set global system_versioning_transaction_registry=off;
drop function check_result;

View File

@ -1432,7 +1432,7 @@ int ha_commit_trans(THD *thd, bool all)
if (trx_end_id)
{
if (!use_transaction_registry)
if (!TR_table::use_transaction_registry)
{
my_error(ER_VERS_TRT_IS_DISABLED, MYF(0));
goto err;
@ -7517,7 +7517,7 @@ bool Vers_parse_info::check_sys_fields(const char *table_name,
{
if (found == check_unit)
{
if (found == VERS_TRX_ID && !use_transaction_registry)
if (found == VERS_TRX_ID && !TR_table::use_transaction_registry)
{
my_error(ER_VERS_TRT_IS_DISABLED, MYF(0));
return true;

View File

@ -536,8 +536,6 @@ ulonglong slave_skipped_errors;
ulong feature_files_opened_with_delayed_keys= 0, feature_check_constraint= 0;
ulonglong denied_connections;
my_decimal decimal_zero;
my_bool opt_transaction_registry= 1;
my_bool use_transaction_registry= 1;
/*
Maximum length of parameter value which can be set through
@ -6023,36 +6021,6 @@ int mysqld_main(int argc, char **argv)
if (Events::init((THD*) 0, opt_noacl || opt_bootstrap))
unireg_abort(1);
if (opt_transaction_registry)
{
use_transaction_registry= true;
if (opt_bootstrap)
{
use_transaction_registry= false;
}
else
{
THD *thd = new THD(0);
thd->thread_stack= (char*) &thd;
thd->store_globals();
{
TR_table trt(thd);
if (trt.check())
{
use_transaction_registry= false;
}
}
trans_commit_stmt(thd);
delete thd;
}
}
else
use_transaction_registry= false;
if (opt_transaction_registry && !use_transaction_registry)
sql_print_information("Disabled transaction registry.");
if (WSREP_ON)
{
if (opt_bootstrap)

View File

@ -315,8 +315,6 @@ extern my_bool encrypt_tmp_disk_tables, encrypt_tmp_files;
extern ulong encryption_algorithm;
extern const char *encryption_algorithm_names[];
extern const char *quoted_string;
extern my_bool opt_transaction_registry;
extern my_bool use_transaction_registry;
#ifdef HAVE_PSI_INTERFACE
#ifdef HAVE_MMAP

View File

@ -7889,7 +7889,7 @@ ER_NOT_LOG_TABLE
eng "Table %`s.%`s is not a log table"
ER_VERS_TRT_IS_DISABLED
eng "Temporal operation requires `mysql.transaction_registry` (@@system_versioning_transaction_registry)."
eng "Transaction registry is disabled"
ER_VERS_DUPLICATE_ROW_START_END
eng "Duplicate ROW %s column %`s"
@ -7897,9 +7897,6 @@ ER_VERS_DUPLICATE_ROW_START_END
ER_VERS_ALREADY_VERSIONED
eng "Table %`s is already system-versioned"
WARN_VERS_TRT_EXPERIMENTAL
eng "Transaction-based system versioning is EXPERIMENTAL and is subject to change in future."
ER_VERS_TRUNCATE_VIEW
eng "DELETE HISTORY from VIEW is prohibited"

View File

@ -7609,7 +7609,7 @@ static bool mysql_inplace_alter_table(THD *thd,
ulonglong trx_end_id= table->file->ht->prepare_commit_versioned(thd, &trx_start_id);
if (trx_end_id)
{
if (!use_transaction_registry)
if (!TR_table::use_transaction_registry)
{
my_error(ER_VERS_TRT_IS_DISABLED, MYF(0));
goto rollback;

View File

@ -427,24 +427,6 @@ static Sys_var_enum Sys_vers_alter_history(
SESSION_VAR(vers_alter_history), CMD_LINE(REQUIRED_ARG),
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;
if (use_transaction_registry)
{
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, WARN_VERS_TRT_EXPERIMENTAL,
ER_THD(thd, WARN_VERS_TRT_EXPERIMENTAL));
}
return false;
}
static Sys_var_mybool Sys_vers_transaction_registry(
"system_versioning_transaction_registry",
"Enable or disable update of `mysql`.`transaction_registry`",
GLOBAL_VAR(opt_transaction_registry), CMD_LINE(OPT_ARG),
DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG,
0, ON_UPDATE(update_transaction_registry));
static Sys_var_ulonglong Sys_binlog_cache_size(
"binlog_cache_size", "The size of the transactional cache for "
"updates to transactional engines for the binary log. "

View File

@ -8579,6 +8579,8 @@ void TABLE_SHARE::vers_destroy()
}
}
enum TR_table::enabled TR_table::use_transaction_registry= TR_table::MAYBE;
TR_table::TR_table(THD* _thd, bool rw) :
thd(_thd), open_tables_backup(NULL)
{
@ -8601,6 +8603,11 @@ bool TR_table::open()
bool error= !open_log_table(thd, this, open_tables_backup);
thd->temporary_tables= temporary_tables;
if (use_transaction_registry == MAYBE)
error= check(error);
use_transaction_registry= error ? NO : YES;
return error;
}
@ -8787,27 +8794,21 @@ void TR_table::warn_schema_incorrect(const char *reason)
{
if (MYSQL_VERSION_ID == table->s->mysql_version)
{
sql_print_error("`%s.%s` schema is incorrect: %s.", db, table_name, reason);
sql_print_error("%`s.%`s schema is incorrect: %s.", db, table_name, reason);
}
else
{
sql_print_error("`%s.%s` schema is incorrect: %s. Created with MariaDB %d, "
sql_print_error("%`s.%`s schema is incorrect: %s. Created with MariaDB %d, "
"now running %d.", db, table_name, reason, MYSQL_VERSION_ID,
static_cast<int>(table->s->mysql_version));
}
}
bool TR_table::check()
bool TR_table::check(bool error)
{
if (!ha_resolve_by_legacy_type(thd, DB_TYPE_INNODB))
if (error)
{
sql_print_information("`%s.%s` requires InnoDB storage engine.", db, table_name);
return true;
}
if (open())
{
sql_print_warning("`%s.%s` does not exist (open failed).", db, table_name);
sql_print_warning("%`s.%`s does not exist (open failed).", db, table_name);
return true;
}

View File

@ -2992,6 +2992,10 @@ public:
FLD_ISO_LEVEL,
FIELD_COUNT
};
enum enabled {NO, MAYBE, YES};
static enum enabled use_transaction_registry;
/**
@param[in,out] Thread handle
@param[in] Current transaction is read-write.
@ -3084,7 +3088,7 @@ public:
@retval true if schema is incorrect and false otherwise
*/
bool check();
bool check(bool error);
TABLE * operator-> () const
{

View File

@ -257,7 +257,7 @@ err:
quit:
if (!result && vtmd.table->file->ht->prepare_commit_versioned)
{
DBUG_ASSERT(use_transaction_registry); // FIXME: disable survival mode while TRT is disabled
DBUG_ASSERT(TR_table::use_transaction_registry); // FIXME: disable survival mode while TRT is disabled
TR_table trt(thd, true);
ulonglong trx_start_id= 0;
ulonglong trx_end_id= vtmd.table->file->ht->prepare_commit_versioned(thd, &trx_start_id);