diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2018-03-29 20:24:29 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-04-10 13:12:36 +0200 |
commit | 689f83d0ce2c949718246fc8244f7c6dfa6cc78f (patch) | |
tree | a1595da2a1845090da7827a89cfe64b4961db3dc | |
parent | dba43f4bec72362bbb0959328a5b80847ae97a86 (diff) | |
download | mariadb-git-689f83d0ce2c949718246fc8244f7c6dfa6cc78f.tar.gz |
MDEV-14790 System versioning for system tables does not work as expected
disallow system versioning for tables in mysql database
-rw-r--r-- | mysql-test/suite/versioning/r/alter.result | 9 | ||||
-rw-r--r-- | mysql-test/suite/versioning/t/alter.test | 10 | ||||
-rw-r--r-- | sql/handler.cc | 12 | ||||
-rw-r--r-- | sql/handler.h | 2 | ||||
-rw-r--r-- | sql/share/errmsg-utf8.txt | 4 |
5 files changed, 31 insertions, 6 deletions
diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result index 8693f24591c..233966d72d5 100644 --- a/mysql-test/suite/versioning/r/alter.result +++ b/mysql-test/suite/versioning/r/alter.result @@ -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; diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test index 128397b6cc8..83f8898c672 100644 --- a/mysql-test/suite/versioning/t/alter.test +++ b/mysql-test/suite/versioning/t/alter.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; diff --git a/sql/handler.cc b/sql/handler.cc index a0a2e4f2703..d2a61fee426 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -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; } diff --git a/sql/handler.h b/sql/handler.h index 342ca20f44d..fea38108153 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1955,7 +1955,7 @@ protected: 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); diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 43dc5788798..f82611acaba 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -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" |