From b1e75d290e98a68acb7ebc934a136da192a5dc79 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Tue, 24 Apr 2018 12:10:52 +0300 Subject: [PATCH] MDEV-14823, MDEV-15956 Versioning error messages fixes MDEV-14823 Wrong error message upon selecting from a system_time partition MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column --- mysql-test/suite/versioning/r/alter.result | 4 ++++ mysql-test/suite/versioning/r/partition.result | 4 ++++ mysql-test/suite/versioning/t/alter.test | 5 +++++ mysql-test/suite/versioning/t/partition.test | 5 +++++ sql/handler.cc | 2 +- sql/share/errmsg-utf8.txt | 2 ++ sql/sql_select.cc | 6 +----- 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result index 5919b4d9a6a..fafcf3c30b0 100644 --- a/mysql-test/suite/versioning/r/alter.result +++ b/mysql-test/suite/versioning/r/alter.result @@ -524,5 +524,9 @@ 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; +# MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column +create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning; +alter table t1 modify s timestamp(6) as row start; +ERROR HY000: Can not change system versioning field `s` drop database test; create database test; diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result index e44c5279e60..b1632d1c7a4 100644 --- a/mysql-test/suite/versioning/r/partition.result +++ b/mysql-test/suite/versioning/r/partition.result @@ -479,6 +479,10 @@ insert into t1 values (1),(2),(3); update t1 set a = 4; delete from t1; delete from t1 where a is not null; +# MDEV-14823 Wrong error message upon selecting from a system_time partition +create or replace table t1 (i int) with system versioning partition by system_time limit 10 (partition p0 history, partition pn current); +select * from t1 partition (p0) for system_time all; +ERROR HY000: SYSTEM_TIME partitions in table `t1` does not support historical query # Test cleanup 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 c1c5dcc7bda..d570b6f4259 100644 --- a/mysql-test/suite/versioning/t/alter.test +++ b/mysql-test/suite/versioning/t/alter.test @@ -449,5 +449,10 @@ create or replace table t (x int) with system versioning; alter table user add system versioning; use test; +--echo # MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column +create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning; +--error ER_VERS_ALTER_SYSTEM_FIELD +alter table t1 modify s timestamp(6) as row start; + drop database test; create database test; diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index a9ea928b167..02357f1a7ae 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -425,6 +425,11 @@ update t1 set a = 4; delete from t1; delete from t1 where a is not null; +--echo # MDEV-14823 Wrong error message upon selecting from a system_time partition +create or replace table t1 (i int) with system versioning partition by system_time limit 10 (partition p0 history, partition pn current); +--error ER_VERS_QUERY_IN_PARTITION +select * from t1 partition (p0) for system_time all; + --echo # Test cleanup drop database test; create database test; diff --git a/sql/handler.cc b/sql/handler.cc index 6ae8b76ef5e..77a3faf0b6f 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7055,7 +7055,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, { if (f->change.length && f->flags & VERS_SYSTEM_FIELD) { - my_error(ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN, MYF(0)); + my_error(ER_VERS_ALTER_SYSTEM_FIELD, MYF(0), f->field_name.str); return true; } } diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 4d94e6704ec..4d1d73997af 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7915,3 +7915,5 @@ ER_UPDATED_COLUMN_ONLY_ONCE eng "The column %`s.%`s cannot be changed more than once in a single UPDATE statement" ER_EMPTY_ROW_IN_TVC eng "Row with no elements is not allowed in table value constructor in this context" +ER_VERS_QUERY_IN_PARTITION + eng "SYSTEM_TIME partitions in table %`s does not support historical query" diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7bb019f30ff..dc6f8aedd9b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -793,11 +793,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables) { if (vers_conditions.is_set()) { -#define PART_VERS_ERR_MSG "%s PARTITION (%s)" - char buf[NAME_LEN*2 + sizeof(PART_VERS_ERR_MSG)]; - my_snprintf(buf, sizeof(buf), PART_VERS_ERR_MSG, table->alias.str, - table->partition_names->head()->c_ptr()); - my_error(ER_VERS_NOT_VERSIONED, MYF(0), buf); + my_error(ER_VERS_QUERY_IN_PARTITION, MYF(0), table->alias.str); DBUG_RETURN(-1); } else