Skip to content
Permalink
Browse files
MDEV-14790 System versioning for system tables does not work as expected
disallow system versioning for tables in mysql database
  • Loading branch information
midenok authored and vuvova committed Apr 10, 2018
1 parent dba43f4 commit 689f83d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
@@ -517,5 +517,14 @@ alter table t drop column sys_trx_end, drop period for system_time;
ERROR HY000: Wrong parameters for `t`: missing 'DROP COLUMN `row_start`, DROP COLUMN `row_end`'
alter table t add period for system_time(sys_trx_start, sys_trx_end);
ERROR HY000: Table `t` is already system-versioned
#
# MDEV-14790 System versioning for system tables does not work as expected
#
use mysql;
create or replace table t (x int) with system versioning;
ERROR HY000: System versioning tables in the `mysql` database are not suported
alter table user add system versioning;
ERROR HY000: System versioning tables in the `mysql` database are not suported
use test;
drop database test;
create database test;
@@ -439,5 +439,15 @@ alter table t drop column sys_trx_end, drop period for system_time;
--error ER_VERS_ALREADY_VERSIONED
alter table t add period for system_time(sys_trx_start, sys_trx_end);

--echo #
--echo # MDEV-14790 System versioning for system tables does not work as expected
--echo #
use mysql;
--error ER_VERS_DB_NOT_SUPPORTED
create or replace table t (x int) with system versioning;
--error ER_VERS_DB_NOT_SUPPORTED
alter table user add system versioning;
use test;

drop database test;
create database test;
@@ -7108,7 +7108,7 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
return true;
}

if (vers_info.check_with_conditions(create_table.table_name.str))
if (vers_info.check_conditions(create_table.table_name.str, create_table.db))
return true;

bool native= vers_native(thd);
@@ -7221,7 +7221,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,

if (alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING)
{
if (check_with_conditions(table_name))
if (check_conditions(table_name, share->db))
return true;
bool native= create_info->vers_native(thd);
if (check_sys_fields(table_name, alter_info, native))
@@ -7298,7 +7298,8 @@ bool Vers_parse_info::need_check(const Alter_info *alter_info) const
alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING || *this;
}

bool Vers_parse_info::check_with_conditions(const char *table_name) const
bool Vers_parse_info::check_conditions(const char *table_name,
const LString &db) const
{
if (!as_row.start || !as_row.end)
{
@@ -7320,6 +7321,11 @@ bool Vers_parse_info::check_with_conditions(const char *table_name) const
return true;
}

if (db.streq(MYSQL_SCHEMA_NAME))
{
my_error(ER_VERS_DB_NOT_SUPPORTED, MYF(0), MYSQL_SCHEMA_NAME.str);
return true;
}
return false;
}

@@ -1955,7 +1955,7 @@ struct Vers_parse_info
return as_row.start || as_row.end || system_time.start || system_time.end;
}
bool need_check(const Alter_info *alter_info) const;
bool check_with_conditions(const char *table_name) const;
bool check_conditions(const char *table_name, const LString &db) const;
bool check_sys_fields(const char *table_name, Alter_info *alter_info,
bool native);

@@ -7889,8 +7889,8 @@ ER_VERS_ALTER_SYSTEM_FIELD
ER_DROP_VERSIONING_SYSTEM_TIME_PARTITION
eng "Can not DROP SYSTEM VERSIONING for table %`s partitioned BY SYSTEM_TIME"

ER_UNUSED_27
eng "You should never see it"
ER_VERS_DB_NOT_SUPPORTED
eng "System versioning tables in the %`s database are not suported"

ER_VERS_TRT_IS_DISABLED
eng "Transaction registry is disabled"

0 comments on commit 689f83d

Please sign in to comment.