diff --git a/mysql-test/suite/versioning/r/create.result b/mysql-test/suite/versioning/r/create.result index 0238d189690ee..ea3c791cc23b9 100644 --- a/mysql-test/suite/versioning/r/create.result +++ b/mysql-test/suite/versioning/r/create.result @@ -32,14 +32,14 @@ Sys_start2 timestamp(6) generated always as row start, Sys_end timestamp(6) generated always as row end, period for system_time (Sys_start, Sys_end) ) with system versioning; -ERROR HY000: 'Generated as row start' specified more than once +ERROR HY000: Wrong parameters for versioned table `t1`: multiple 'GENERATED ALWAYS AS ROW START' create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, Sys_end2 timestamp(6) generated always as row end, period for system_time (Sys_start, Sys_end) ) with system versioning; -ERROR HY000: Second column in 'period for system time' must be equal to 'generated as row end' column +ERROR HY000: Wrong parameters for versioned table `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW END' mismatch create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, @@ -47,12 +47,12 @@ Sys_end timestamp(6) generated always as row end, Sys_end2 timestamp(6) generated always as row end, period for system_time (Sys_start, Sys_end) ) with system versioning; -ERROR HY000: Generated as row end specified more than once +ERROR HY000: Wrong parameters for versioned table `t1`: multiple 'GENERATED ALWAYS AS ROW END' create or replace table t1 ( XNo int unsigned, period for system_time (Sys_start, Sys_end) ) with system versioning; -ERROR HY000: 'Generated as row start' not specified +ERROR HY000: Wrong parameters for versioned table `t1`: 'GENERATED AS ROW START' column missing create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, @@ -60,63 +60,63 @@ Sys_end timestamp(6) generated always as row end, Sys_end2 timestamp(6) generated always as row end, period for system_time (Sys_start, Sys_end) ); -ERROR HY000: Generated as row end specified more than once +ERROR HY000: Wrong parameters for versioned table `t1`: multiple 'GENERATED ALWAYS AS ROW END' create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, Sys_end timestamp(6) generated always as row end, period for system_time (sys_insert, sys_remove) ) with system versioning; -ERROR HY000: First column in 'period for system time' must be equal to 'generated as row start' column +ERROR HY000: Wrong parameters for versioned table `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW START' mismatch create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, Sys_end timestamp(6) generated always as row end, period for system_time (Sys_start, Sys_end) ); -ERROR HY000: 'With system versioning' is missing +ERROR HY000: Wrong parameters for versioned table `t1`: 'WITH SYSTEM VERSIONING' missing create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, Sys_end timestamp(6) generated always as row end, period for system_time (Sys_start, Sys_start) ); -ERROR HY000: 'Period for system_time' must contain two different columns +ERROR HY000: Wrong parameters for versioned table `t1`: 'PERIOD FOR SYSTEM_TIME' columns must be different create or replace table t1 ( XNo int unsigned, Sys_start int generated always as row start, Sys_end timestamp(6) generated always as row end, period for system_time (Sys_start, Sys_end) ) with system versioning; -ERROR HY000: System start field must be of type TIMESTAMP +ERROR HY000: `Sys_start` must be of type `TIMESTAMP` for versioned table `t1` create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, Sys_end int generated always as row end, period for system_time (Sys_start, Sys_end) ) with system versioning; -ERROR HY000: System end field must be of type TIMESTAMP +ERROR HY000: `Sys_end` must be of type `TIMESTAMP` for versioned table `t1` create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, Sys_end bigint generated always as row end, period for system_time (Sys_start, Sys_end) ) with system versioning engine innodb; -ERROR HY000: System start field must be of type BIGINT UNSIGNED +ERROR HY000: `Sys_start` must be of type `BIGINT UNSIGNED` for versioned table `t1` create or replace table t1 ( XNo int unsigned, Sys_start bigint generated always as row start, Sys_end bigint generated always as row end, period for system_time (Sys_start, Sys_end) ) with system versioning engine innodb; -ERROR HY000: System start field must be of type BIGINT UNSIGNED +ERROR HY000: `Sys_start` must be of type `BIGINT UNSIGNED` for versioned table `t1` create or replace table t1 ( XNo int unsigned, Sys_start bigint unsigned generated always as row start, Sys_end bigint generated always as row end, period for system_time (Sys_start, Sys_end) ) with system versioning engine innodb; -ERROR HY000: System end field must be of type BIGINT UNSIGNED +ERROR HY000: `Sys_end` must be of type `BIGINT UNSIGNED` for versioned table `t1` create or replace table t1 ( A int with system versioning, B int @@ -147,7 +147,7 @@ create or replace table t1 ( A int, B int without system versioning ); -ERROR HY000: Every field specified unversioned in versioned table +ERROR HY000: Wrong parameters for versioned table `t1`: 'WITH SYSTEM VERSIONING' missing create or replace table t1 ( A int, B int without system versioning @@ -190,9 +190,9 @@ t1 CREATE TABLE `t1` ( create or replace table t1 ( A int without system versioning ); -ERROR HY000: Every field specified unversioned in versioned table +ERROR HY000: Wrong parameters for versioned table `t1`: 'WITH SYSTEM VERSIONING' missing create or replace table t1 ( A int without system versioning ) with system versioning; -ERROR HY000: Every field specified unversioned in versioned table +ERROR HY000: Wrong parameters for versioned table `t1`: versioned fields missing drop table t1; diff --git a/mysql-test/suite/versioning/r/optimized_fields.result b/mysql-test/suite/versioning/r/optimized_fields.result index aa1f1d3696b40..3fbc8017931fb 100644 --- a/mysql-test/suite/versioning/r/optimized_fields.result +++ b/mysql-test/suite/versioning/r/optimized_fields.result @@ -17,50 +17,50 @@ a b b+0 1 NULL NULL 3 NULL NULL Warnings: -Warning 4067 Attempt to read unversioned field 'b' in historical query +Warning 4055 Attempt to read unversioned field 'b' in historical query select * from t for system_time as of timestamp now(6); a b 1 NULL 3 NULL Warnings: -Warning 4067 Attempt to read unversioned field 'b' in historical query +Warning 4055 Attempt to read unversioned field 'b' in historical query select count(*) from t group by b for system_time as of timestamp now(6); count(*) 2 Warnings: -Warning 4067 Attempt to read unversioned field 'b' in historical query +Warning 4055 Attempt to read unversioned field 'b' in historical query select * from t for system_time as of timestamp now(6) order by b asc; a b 1 NULL 3 NULL Warnings: -Warning 4067 Attempt to read unversioned field 'b' in historical query +Warning 4055 Attempt to read unversioned field 'b' in historical query select * from t for system_time as of timestamp now(6) order by b desc; a b 1 NULL 3 NULL Warnings: -Warning 4067 Attempt to read unversioned field 'b' in historical query +Warning 4055 Attempt to read unversioned field 'b' in historical query select * from t group by a having a=2 for system_time as of timestamp now(6); a b Warnings: -Warning 4067 Attempt to read unversioned field 'b' in historical query +Warning 4055 Attempt to read unversioned field 'b' in historical query select * from t group by b having b=2 for system_time as of timestamp now(6); a b Warnings: -Warning 4067 Attempt to read unversioned field 'b' in historical query +Warning 4055 Attempt to read unversioned field 'b' in historical query select a from t where b=2 for system_time as of timestamp now(6); a Warnings: -Warning 4067 Attempt to read unversioned field 'b' in historical query +Warning 4055 Attempt to read unversioned field 'b' in historical query select a from t where b=NULL for system_time as of timestamp now(6); a Warnings: -Warning 4067 Attempt to read unversioned field 'b' in historical query +Warning 4055 Attempt to read unversioned field 'b' in historical query select count(*), b from t group by b having b=NULL for system_time as of timestamp now(6); count(*) b Warnings: -Warning 4067 Attempt to read unversioned field 'b' in historical query +Warning 4055 Attempt to read unversioned field 'b' in historical query select a, b from t; a b 1 2 diff --git a/mysql-test/suite/versioning/t/create.test b/mysql-test/suite/versioning/t/create.test index 098f71087dcda..4310b57d90b55 100644 --- a/mysql-test/suite/versioning/t/create.test +++ b/mysql-test/suite/versioning/t/create.test @@ -18,7 +18,7 @@ create or replace table t1 ( ) with system versioning; show create table t1; ---error ER_SYS_START_MORE_THAN_ONCE +--error ER_VERS_WRONG_PARAMS create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, @@ -27,7 +27,7 @@ create or replace table t1 ( period for system_time (Sys_start, Sys_end) ) with system versioning; ---error ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_END_COLUMN +--error ER_VERS_WRONG_PARAMS create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, @@ -35,7 +35,7 @@ create or replace table t1 ( period for system_time (Sys_start, Sys_end) ) with system versioning; ---error ER_SYS_END_MORE_THAN_ONCE +--error ER_VERS_WRONG_PARAMS create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, @@ -44,13 +44,13 @@ create or replace table t1 ( period for system_time (Sys_start, Sys_end) ) with system versioning; ---error ER_SYS_START_NOT_SPECIFIED +--error ER_VERS_WRONG_PARAMS create or replace table t1 ( XNo int unsigned, period for system_time (Sys_start, Sys_end) ) with system versioning; ---error ER_SYS_END_MORE_THAN_ONCE +--error ER_VERS_WRONG_PARAMS create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, @@ -59,7 +59,7 @@ create or replace table t1 ( period for system_time (Sys_start, Sys_end) ); ---error ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_START_COLUMN +--error ER_VERS_WRONG_PARAMS create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, @@ -67,7 +67,7 @@ create or replace table t1 ( period for system_time (sys_insert, sys_remove) ) with system versioning; ---error ER_MISSING_WITH_SYSTEM_VERSIONING +--error ER_VERS_WRONG_PARAMS create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, @@ -75,7 +75,7 @@ create or replace table t1 ( period for system_time (Sys_start, Sys_end) ); ---error ER_SYS_START_AND_SYS_END_SAME +--error ER_VERS_WRONG_PARAMS create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, @@ -83,7 +83,7 @@ create or replace table t1 ( period for system_time (Sys_start, Sys_start) ); ---error ER_SYS_START_FIELD_MUST_BE_TIMESTAMP +--error ER_VERS_FIELD_WRONG_TYPE create or replace table t1 ( XNo int unsigned, Sys_start int generated always as row start, @@ -91,7 +91,7 @@ create or replace table t1 ( period for system_time (Sys_start, Sys_end) ) with system versioning; ---error ER_SYS_END_FIELD_MUST_BE_TIMESTAMP +--error ER_VERS_FIELD_WRONG_TYPE create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, @@ -99,7 +99,7 @@ create or replace table t1 ( period for system_time (Sys_start, Sys_end) ) with system versioning; ---error ER_SYS_START_FIELD_MUST_BE_BIGINT +--error ER_VERS_FIELD_WRONG_TYPE create or replace table t1 ( XNo int unsigned, Sys_start timestamp(6) generated always as row start, @@ -107,7 +107,7 @@ create or replace table t1 ( period for system_time (Sys_start, Sys_end) ) with system versioning engine innodb; ---error ER_SYS_START_FIELD_MUST_BE_BIGINT +--error ER_VERS_FIELD_WRONG_TYPE create or replace table t1 ( XNo int unsigned, Sys_start bigint generated always as row start, @@ -115,7 +115,7 @@ create or replace table t1 ( period for system_time (Sys_start, Sys_end) ) with system versioning engine innodb; ---error ER_SYS_END_FIELD_MUST_BE_BIGINT +--error ER_VERS_FIELD_WRONG_TYPE create or replace table t1 ( XNo int unsigned, Sys_start bigint unsigned generated always as row start, @@ -135,7 +135,7 @@ create or replace table t1 ( ) with system versioning; show create table t1; ---error ER_NO_VERSIONED_FIELDS_IN_VERSIONED_TABLE +--error ER_VERS_WRONG_PARAMS create or replace table t1 ( A int, B int without system versioning @@ -159,12 +159,12 @@ create or replace table t1 ( ) with system versioning; show create table t1; ---error ER_NO_VERSIONED_FIELDS_IN_VERSIONED_TABLE +--error ER_VERS_WRONG_PARAMS create or replace table t1 ( A int without system versioning ); ---error ER_NO_VERSIONED_FIELDS_IN_VERSIONED_TABLE +--error ER_VERS_WRONG_PARAMS create or replace table t1 ( A int without system versioning ) with system versioning; diff --git a/sql/handler.cc b/sql/handler.cc index 0badaa3fa2473..c62dcb067be46 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6593,15 +6593,11 @@ static bool create_sys_trx_field(THD *thd, const char *field_name, return false; } -bool Vers_parse_info::add_versioning_info( +bool Vers_parse_info::fix_implicit( THD *thd, Alter_info *alter_info, bool integer_fields) { - if (!declared_system_versioning && !has_versioned_fields) - return false; - - bool without_system_versioning_by_default= !declared_system_versioning; List_iterator it(alter_info->create_list); while (Create_field *f= it++) { @@ -6615,11 +6611,11 @@ bool Vers_parse_info::add_versioning_info( continue; if (f->versioning == Column_definition::VERSIONING_NOT_SET && - without_system_versioning_by_default) - f->flags|= VERS_OPTIMIZED_UPDATE_FLAG; - - else if (f->versioning == Column_definition::WITHOUT_VERSIONING) + !declared_system_versioning || + f->versioning == Column_definition::WITHOUT_VERSIONING) + { f->flags|= VERS_OPTIMIZED_UPDATE_FLAG; + } } // If user specified some of these he must specify the others too. Do nothing. @@ -6637,7 +6633,11 @@ bool Vers_parse_info::add_versioning_info( "sys_trx_end"); } -bool Vers_parse_info::check(THD *thd, Alter_info *alter_info, bool integer_fields) +bool Vers_parse_info::check_and_fix_implicit( + THD *thd, + Alter_info *alter_info, + bool integer_fields, + const char* table_name) { if (!( has_versioned_fields || @@ -6651,10 +6651,14 @@ bool Vers_parse_info::check(THD *thd, Alter_info *alter_info, bool integer_field return false; } - if (add_versioning_info(thd, alter_info, integer_fields)) + if (!declared_system_versioning && !has_versioned_fields) + { + my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name, "'WITH SYSTEM VERSIONING' missing"); return true; + } - bool r= false; + if (fix_implicit(thd, alter_info, integer_fields)) + return true; { int not_set= 0; @@ -6685,51 +6689,42 @@ bool Vers_parse_info::check(THD *thd, Alter_info *alter_info, bool integer_field if ((table_with_system_versioning && not_set == 0 && with == 0) || (!table_with_system_versioning && with == 0)) { - r= true; - my_error(ER_NO_VERSIONED_FIELDS_IN_VERSIONED_TABLE, MYF(0)); + my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name, "versioned fields missing"); + return true; } } - if (!declared_system_versioning && !has_versioned_fields) - { - r= true; - my_error(ER_MISSING_WITH_SYSTEM_VERSIONING, MYF(0)); - } - if (!generated_as_row.start) { - r= true; - my_error(ER_SYS_START_NOT_SPECIFIED, MYF(0)); + my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name, "'GENERATED AS ROW START' column missing"); + return true; } if (!generated_as_row.end) { - r= true; - my_error(ER_SYS_END_NOT_SPECIFIED, MYF(0)); + my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name, "'GENERATED AS ROW END' column missing"); + return true; } if (!period_for_system_time.start || !period_for_system_time.end) { - r= true; - my_error(ER_MISSING_PERIOD_FOR_SYSTEM_TIME, MYF(0)); + my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name, "'PERIOD FOR SYSTEM_TIME' missing"); + return true; } - if (!r) + if (my_strcasecmp(system_charset_info, generated_as_row.start->c_ptr(), + period_for_system_time.start->c_ptr())) { - if (my_strcasecmp(system_charset_info, generated_as_row.start->c_ptr(), - period_for_system_time.start->c_ptr())) - { - r= true; - my_error(ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_START_COLUMN, MYF(0)); - } + my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name, "'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW START' mismatch"); + return true; + } - if (my_strcasecmp(system_charset_info, generated_as_row.end->c_ptr(), - period_for_system_time.end->c_ptr())) - { - r= true; - my_error(ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_END_COLUMN, MYF(0)); - } + if (my_strcasecmp(system_charset_info, generated_as_row.end->c_ptr(), + period_for_system_time.end->c_ptr())) + { + my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name, "'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW END' mismatch"); + return true; } - return r; // false means no error + return false; } diff --git a/sql/handler.h b/sql/handler.h index 964880b0b62d6..394d6276e4fe8 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1697,8 +1697,10 @@ struct Vers_parse_info period_for_system_time.end = end; } - bool add_versioning_info(THD *thd, Alter_info *alter_info, bool integer_fields); - bool check(THD *thd, Alter_info *alter_info, bool integer_fields); +private: + bool fix_implicit(THD *thd, Alter_info *alter_info, bool integer_fields); +public: + bool check_and_fix_implicit(THD *thd, Alter_info *alter_info, bool integer_fields, const char* table_name); /** User has added 'WITH SYSTEM VERSIONING' to table definition */ bool declared_system_versioning : 1; diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index e39677765a214..c8615943ff2f7 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7487,56 +7487,20 @@ ER_UNKNOWN_VIEW 42S02 # MariaDB error numbers related to System Versioning -ER_SYS_START_NOT_SPECIFIED - eng "'Generated as row start' not specified" - -ER_SYS_END_NOT_SPECIFIED - eng "'Generated as row end' not specified" - -ER_SYS_START_MORE_THAN_ONCE - eng "'Generated as row start' specified more than once" - -ER_SYS_END_MORE_THAN_ONCE - eng "Generated as row end specified more than once" - -ER_MISSING_PERIOD_FOR_SYSTEM_TIME - eng "'Period for system time' is missing" - ER_TABLE_DOESNT_SUPPORT_SYSTEM_VERSIONING eng "Table '%s' doesn't support system versioning" -ER_MISSING_WITH_SYSTEM_VERSIONING - eng "'With system versioning' is missing" - -ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_START_COLUMN - eng "First column in 'period for system time' must be equal to 'generated as row start' column" - -ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_END_COLUMN - eng "Second column in 'period for system time' must be equal to 'generated as row end' column" - -ER_SYS_START_AND_SYS_END_SAME - eng "'Period for system_time' must contain two different columns" - ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER eng "Generated field for System Versioning cannot be set by user" ER_UPDATE_INFO_WITH_SYSTEM_VERSIONING eng "Rows matched: %ld Changed: %ld Inserted: %ld Warnings: %ld" -ER_SYS_START_FIELD_MUST_BE_TIMESTAMP - eng "System start field must be of type TIMESTAMP" - -ER_SYS_END_FIELD_MUST_BE_TIMESTAMP - eng "System end field must be of type TIMESTAMP" - -ER_SYS_START_FIELD_MUST_BE_BIGINT - eng "System start field must be of type BIGINT UNSIGNED" - -ER_SYS_END_FIELD_MUST_BE_BIGINT - eng "System end field must be of type BIGINT UNSIGNED" +ER_VERS_FIELD_WRONG_TYPE + eng "%`s must be of type %`s for versioned table %`s" -ER_NO_VERSIONED_FIELDS_IN_VERSIONED_TABLE - eng "Every field specified unversioned in versioned table" +ER_VERS_WRONG_PARAMS + eng "Wrong parameters for versioned table %`s: %s" ER_VERS_TRX_ID_UNSUPPORTED eng "Engine does not support versioned TRX_ID" diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 611e1c1a0216c..75e608a0377e3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3877,8 +3877,13 @@ mysql_execute_command(THD *thd) create_info.use_default_db_type(thd); DBUG_ASSERT(create_info.db_type); - if (create_info.vers_info.check(thd, &alter_info, create_info.db_type->versioned())) + if (create_info.vers_info.check_and_fix_implicit(thd, + &alter_info, + create_info.db_type->flags & HTON_SUPPORTS_SYS_VERSIONING, + create_table->table_name)) + { goto end_with_restore_list; + } /* If we are using SET CHARSET without DEFAULT, add an implicit diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ae697b61eb195..288c36ee7ab0b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3470,23 +3470,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, */ if (sql_field->stored_in_db()) record_offset+= sql_field->pack_length; - - if (create_info->versioned()) - { - const bool is_generated_as_row_start = - !my_strcasecmp(system_charset_info, - create_info->vers_info.generated_as_row.start->c_ptr(), - sql_field->field_name); - const bool is_generated_as_row_end = - !my_strcasecmp(system_charset_info, - create_info->vers_info.generated_as_row.end->c_ptr(), - sql_field->field_name); - if (is_generated_as_row_start && is_generated_as_row_end) - { - my_error(ER_SYS_START_AND_SYS_END_SAME, MYF(0), sql_field->field_name); - DBUG_RETURN(TRUE); - } - } } /* Update virtual fields' offset*/ it.rewind(); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 0f810d72f6658..6b55582be0bab 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -6065,7 +6065,9 @@ period_for_system_time: Vers_parse_info &info= Lex->vers_get_info(); if (!my_strcasecmp(system_charset_info, $4->c_ptr(), $6->c_ptr())) { - my_error(ER_SYS_START_AND_SYS_END_SAME, MYF(0), $4->c_ptr()); + my_error(ER_VERS_WRONG_PARAMS, MYF(0), + Lex->create_last_non_select_table->table_name, + "'PERIOD FOR SYSTEM_TIME' columns must be different"); MYSQL_YYABORT; } info.set_period_for_system_time($4, $6); @@ -6174,17 +6176,19 @@ field_def: if (!field_name) MYSQL_YYABORT; + const char *table_name= Lex->create_last_non_select_table->table_name; + String **p= NULL; - int err_nr= 0; + const char* err; switch ($4) { case 1: p= &info.generated_as_row.start; - err_nr= ER_SYS_START_MORE_THAN_ONCE; + err= "multiple 'GENERATED ALWAYS AS ROW START'"; break; case 0: p= &info.generated_as_row.end; - err_nr= ER_SYS_END_MORE_THAN_ONCE; + err= "multiple 'GENERATED ALWAYS AS ROW END'"; break; default: /* Not Reachable */ @@ -6193,7 +6197,7 @@ field_def: } if (*p) { - my_error(err_nr, MYF(0), field_name->c_ptr()); + my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name, err); MYSQL_YYABORT; } *p= field_name; diff --git a/sql/table.cc b/sql/table.cc index 622ced5f60fb1..1bda4607dcf6f 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2566,13 +2566,13 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, if (vers_start_field()->type() != MYSQL_TYPE_LONGLONG || !(vers_start_field()->flags & UNSIGNED_FLAG)) { - my_error(ER_SYS_START_FIELD_MUST_BE_BIGINT, MYF(0), share->table_name); + my_error(ER_VERS_FIELD_WRONG_TYPE, MYF(0), vers_start_field()->field_name, "BIGINT UNSIGNED", share->table_name); goto err; } if (vers_end_field()->type() != MYSQL_TYPE_LONGLONG || !(vers_end_field()->flags & UNSIGNED_FLAG)) { - my_error(ER_SYS_END_FIELD_MUST_BE_BIGINT, MYF(0), share->table_name); + my_error(ER_VERS_FIELD_WRONG_TYPE, MYF(0), vers_end_field()->field_name, "BIGINT UNSIGNED", share->table_name); goto err; } } @@ -2580,12 +2580,12 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, { if (vers_start_field()->type() != MYSQL_TYPE_TIMESTAMP) { - my_error(ER_SYS_START_FIELD_MUST_BE_TIMESTAMP, MYF(0), share->table_name); + my_error(ER_VERS_FIELD_WRONG_TYPE, MYF(0), vers_start_field()->field_name, "TIMESTAMP", share->table_name); goto err; } if (vers_end_field()->type() != MYSQL_TYPE_TIMESTAMP) { - my_error(ER_SYS_END_FIELD_MUST_BE_TIMESTAMP, MYF(0), share->table_name); + my_error(ER_VERS_FIELD_WRONG_TYPE, MYF(0), vers_end_field()->field_name, "TIMESTAMP", share->table_name); goto err; } } // if (db_type()->versioned())