Commit 689f83d0 authored by Aleksey Midenkov's avatar Aleksey Midenkov Committed by Sergei Golubchik

MDEV-14790 System versioning for system tables does not work as expected

disallow system versioning for tables in mysql database
parent dba43f4b
...@@ -517,5 +517,14 @@ alter table t drop column sys_trx_end, drop period for system_time; ...@@ -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`' 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); alter table t add period for system_time(sys_trx_start, sys_trx_end);
ERROR HY000: Table `t` is already system-versioned 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; drop database test;
create database test; create database test;
...@@ -439,5 +439,15 @@ alter table t drop column sys_trx_end, drop period for system_time; ...@@ -439,5 +439,15 @@ alter table t drop column sys_trx_end, drop period for system_time;
--error ER_VERS_ALREADY_VERSIONED --error ER_VERS_ALREADY_VERSIONED
alter table t add period for system_time(sys_trx_start, sys_trx_end); 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; drop database test;
create database test; create database test;
...@@ -7108,7 +7108,7 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields( ...@@ -7108,7 +7108,7 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
return true; 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; return true;
bool native= vers_native(thd); bool native= vers_native(thd);
...@@ -7221,7 +7221,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, ...@@ -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 (alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING)
{ {
if (check_with_conditions(table_name)) if (check_conditions(table_name, share->db))
return true; return true;
bool native= create_info->vers_native(thd); bool native= create_info->vers_native(thd);
if (check_sys_fields(table_name, alter_info, native)) 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 ...@@ -7298,7 +7298,8 @@ bool Vers_parse_info::need_check(const Alter_info *alter_info) const
alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING || *this; 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) if (!as_row.start || !as_row.end)
{ {
...@@ -7320,6 +7321,11 @@ bool Vers_parse_info::check_with_conditions(const char *table_name) const ...@@ -7320,6 +7321,11 @@ bool Vers_parse_info::check_with_conditions(const char *table_name) const
return true; 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; return false;
} }
......
...@@ -1955,7 +1955,7 @@ struct Vers_parse_info ...@@ -1955,7 +1955,7 @@ struct Vers_parse_info
return as_row.start || as_row.end || system_time.start || system_time.end; return as_row.start || as_row.end || system_time.start || system_time.end;
} }
bool need_check(const Alter_info *alter_info) const; 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 check_sys_fields(const char *table_name, Alter_info *alter_info,
bool native); bool native);
......
...@@ -7889,8 +7889,8 @@ ER_VERS_ALTER_SYSTEM_FIELD ...@@ -7889,8 +7889,8 @@ ER_VERS_ALTER_SYSTEM_FIELD
ER_DROP_VERSIONING_SYSTEM_TIME_PARTITION ER_DROP_VERSIONING_SYSTEM_TIME_PARTITION
eng "Can not DROP SYSTEM VERSIONING for table %`s partitioned BY SYSTEM_TIME" eng "Can not DROP SYSTEM VERSIONING for table %`s partitioned BY SYSTEM_TIME"
ER_UNUSED_27 ER_VERS_DB_NOT_SUPPORTED
eng "You should never see it" eng "System versioning tables in the %`s database are not suported"
ER_VERS_TRT_IS_DISABLED ER_VERS_TRT_IS_DISABLED
eng "Transaction registry is disabled" eng "Transaction registry is disabled"
......
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