mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
SQL: revisit error messages [closes #217]
This commit is contained in:
@ -726,6 +726,7 @@ extern int my_sync_dir(const char *dir_name, myf my_flags);
|
||||
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
|
||||
extern const char *my_get_err_msg(uint nr);
|
||||
extern void my_error(uint nr,myf MyFlags, ...);
|
||||
extern void my_error_as(uint nr1, uint nr2, myf MyFlags, ...);
|
||||
extern void my_printf_error(uint my_err, const char *format,
|
||||
myf MyFlags, ...)
|
||||
ATTRIBUTE_FORMAT(printf, 2, 4);
|
||||
|
@ -9,7 +9,7 @@ t CREATE TABLE `t` (
|
||||
alter table t without system versioning;
|
||||
ERROR HY000: Wrong parameters for `t`: table is not versioned
|
||||
alter table t with system versioning without system versioning;
|
||||
ERROR HY000: Wrong parameters for `t`: Versioning specified more than once for the same table
|
||||
ERROR HY000: Wrong parameters for `t`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
|
||||
alter table t with system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
@ -224,11 +224,11 @@ t CREATE TABLE `t` (
|
||||
`b` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t modify a int with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t`: Can not change fields versioning mode in a non-versioned table
|
||||
ERROR HY000: Wrong parameters for `t`: table is not versioned
|
||||
alter table t modify a int with system versioning with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t`: Versioning specified more than once for the same field
|
||||
ERROR HY000: Wrong parameters for `t`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `a`
|
||||
alter table t modify a int with system versioning without system versioning;
|
||||
ERROR HY000: Wrong parameters for `t`: Versioning specified more than once for the same field
|
||||
ERROR HY000: Wrong parameters for `t`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `a`
|
||||
alter table t with system versioning;
|
||||
alter table t modify a int without system versioning;
|
||||
show create table t;
|
||||
|
@ -103,14 +103,14 @@ Sys_start2 SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW START'
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'AS ROW START' (`Sys_start2`, `Sys_start`)
|
||||
create or replace table t1 (
|
||||
x4 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end2 SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW END' mismatch
|
||||
ERROR HY000: Wrong parameters for `t1`: mismatch 'PERIOD FOR SYSTEM_TIME' and 'AS ROW END'
|
||||
create or replace table t1 (
|
||||
x5 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
@ -118,12 +118,12 @@ Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
Sys_end2 SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW END'
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'AS ROW END' (`Sys_end2`, `Sys_end`)
|
||||
create or replace table t1 (
|
||||
x6 int unsigned,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: 'GENERATED AS ROW START' column missing
|
||||
ERROR HY000: Wrong parameters for `t1`: missing 'AS ROW START'
|
||||
create or replace table t1 (
|
||||
x7 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
@ -131,28 +131,28 @@ Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
Sys_end2 SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW END'
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'AS ROW END' (`Sys_end2`, `Sys_end`)
|
||||
create or replace table t1 (
|
||||
x8 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (sys_insert, sys_remove)
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW START' mismatch
|
||||
ERROR HY000: Wrong parameters for `t1`: mismatch 'PERIOD FOR SYSTEM_TIME' and 'AS ROW START'
|
||||
create or replace table t1 (
|
||||
x9 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
|
||||
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
|
||||
create or replace table t1 (
|
||||
x10 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_start)
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' columns must be different
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple `Sys_start` for 'PERIOD FOR SYSTEM_TIME'
|
||||
create or replace table t1 (
|
||||
x11 int unsigned,
|
||||
Sys_start bigint unsigned generated always as row start,
|
||||
@ -211,7 +211,7 @@ create or replace table t1 (
|
||||
A3 int,
|
||||
B int without system versioning
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
|
||||
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
|
||||
create or replace table t1 (
|
||||
A4 int,
|
||||
B int without system versioning
|
||||
@ -254,39 +254,39 @@ t1 CREATE TABLE `t1` (
|
||||
create or replace table t1 (
|
||||
A7 int without system versioning
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
|
||||
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
|
||||
create or replace table t1 (
|
||||
A8 int without system versioning
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: no columns defined with system versioning!
|
||||
ERROR HY000: Wrong parameters for `t1`: no columns defined 'WITH SYSTEM VERSIONING'
|
||||
create or replace table t1 (
|
||||
A9 int without system versioning with system versioning
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same field
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `A9`
|
||||
create or replace table t1 (
|
||||
A10 int with system versioning without system versioning
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same field
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `A10`
|
||||
create table t(
|
||||
a11 int
|
||||
) without system versioning;
|
||||
ERROR HY000: Wrong parameters for `t`: 'WITHOUT SYSTEM VERSIONING' is not allowed
|
||||
ERROR HY000: Wrong parameters for `t`: not allowed 'WITHOUT SYSTEM VERSIONING'
|
||||
create or replace table t1 (
|
||||
A12 int
|
||||
) without system versioning with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
|
||||
create or replace table t1 (
|
||||
A13 int
|
||||
) with system versioning without system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
|
||||
create or replace table t1 (
|
||||
A14 int
|
||||
) with system versioning with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
|
||||
create or replace table t1 (
|
||||
A15 int
|
||||
) without system versioning without system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
create temporary table tmp with system versioning select * from t1;
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
|
@ -104,25 +104,25 @@ create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time (
|
||||
partition p0 as of now);
|
||||
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: unexpected number of partitions (expected > 1)
|
||||
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time (
|
||||
partition p0 as of now,
|
||||
partition p1 as of now);
|
||||
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: multiple `AS OF NOW` partitions
|
||||
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time (
|
||||
partition p0 versioning,
|
||||
partition p1 versioning);
|
||||
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: no `AS OF NOW` partition defined
|
||||
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time (
|
||||
partition pn as of now,
|
||||
partition p0 versioning);
|
||||
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: AS OF NOW partition is not last
|
||||
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time (
|
||||
@ -130,7 +130,7 @@ partition p0 versioning,
|
||||
partition pn as of now);
|
||||
alter table t1 add partition (
|
||||
partition p1 as of now);
|
||||
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: AS OF NOW partition can not be added
|
||||
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
|
||||
alter table t1 add partition (
|
||||
partition p1 versioning);
|
||||
Warnings:
|
||||
@ -148,10 +148,10 @@ t1 CREATE TABLE `t1` (
|
||||
PARTITION p1 VERSIONING ENGINE = ${INNODB_OR_MYISAM},
|
||||
PARTITION pn AS OF NOW ENGINE = ${INNODB_OR_MYISAM})
|
||||
alter table t1 drop partition pn;
|
||||
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: `AS OF NOW` partition can not be dropped
|
||||
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
|
||||
alter table t1 drop partition p1;
|
||||
alter table t1 drop partition p0;
|
||||
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: one `AS OF NOW` and at least one `VERSIONING` partition required
|
||||
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
|
||||
set @now= now(6);
|
||||
insert into t1 values (1);
|
||||
set @ts_start= sys_commit_ts('sys_trx_start');
|
||||
@ -226,6 +226,13 @@ select @ts2 = @ts3;
|
||||
1
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time limit 0 (
|
||||
partition p0 versioning,
|
||||
partition p1 versioning,
|
||||
partition pn as of now);
|
||||
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'LIMIT'
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time limit 1 (
|
||||
partition p0 versioning,
|
||||
partition p1 versioning,
|
||||
@ -268,6 +275,13 @@ x
|
||||
3
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time interval 0 second (
|
||||
partition p0 versioning,
|
||||
partition p1 versioning,
|
||||
partition pn as of now);
|
||||
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time interval 1 second (
|
||||
partition p0 versioning,
|
||||
partition p1 versioning,
|
||||
|
@ -337,7 +337,7 @@ ERROR HY000: System Versioning required: `FOR SYSTEM_TIME` query
|
||||
create or replace table t1 (x int) with system versioning;
|
||||
insert into t1 values (1);
|
||||
select * from t1 for system_time all for update;
|
||||
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME query`: write-locking of historic rows
|
||||
ERROR HY000: Versioned SELECT write-locking of history rows
|
||||
create or replace table t1 (a int not null auto_increment primary key) with system versioning;
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
|
||||
a
|
||||
@ -437,7 +437,7 @@ x y
|
||||
2 1
|
||||
3 1
|
||||
select * from t1 for system_time all, t2 for system_time all query for system_time all;
|
||||
ERROR HY000: Wrong versioned query: unused `QUERY FOR SYSTEM_TIME` clause!
|
||||
ERROR HY000: Unused clause: 'QUERY FOR SYSTEM_TIME'
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
call innodb_verify_vtq(27);
|
||||
|
@ -55,11 +55,11 @@ ERROR 42S02: Table 'test.t_vtmd' doesn't exist
|
||||
set versioning_ddl_survival=on;
|
||||
create or replace table t (a int) with system versioning;
|
||||
show create table t for system_time between timestamp @tm1 and timestamp @tm1;
|
||||
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
|
||||
ERROR HY000: SYSTEM_TIME range selector is prohibited
|
||||
show create table t for system_time from timestamp @tm1 to timestamp @tm1;
|
||||
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
|
||||
ERROR HY000: SYSTEM_TIME range selector is prohibited
|
||||
show create table t for system_time before timestamp @tm1;
|
||||
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
|
||||
ERROR HY000: SYSTEM_TIME range selector is prohibited
|
||||
show create table t for system_time as of timestamp '01-01-1990';
|
||||
ERROR HY000: VTMD error: failed to query VTMD table
|
||||
show create table t for system_time as of timestamp '01-01-2020';
|
||||
|
@ -35,27 +35,27 @@ partition by system_time (
|
||||
partition p0 versioning,
|
||||
partition pn as of now);
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
--error ER_VERS_WRONG_PARTS
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time (
|
||||
partition p0 as of now);
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
--error ER_VERS_WRONG_PARTS
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time (
|
||||
partition p0 as of now,
|
||||
partition p1 as of now);
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
--error ER_VERS_WRONG_PARTS
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time (
|
||||
partition p0 versioning,
|
||||
partition p1 versioning);
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
--error ER_VERS_WRONG_PARTS
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time (
|
||||
@ -69,7 +69,7 @@ partition by system_time (
|
||||
partition pn as of now);
|
||||
|
||||
# alter table
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
--error ER_VERS_WRONG_PARTS
|
||||
alter table t1 add partition (
|
||||
partition p1 as of now);
|
||||
|
||||
@ -79,10 +79,10 @@ alter table t1 add partition (
|
||||
--replace_result InnoDB ${INNODB_OR_MYISAM} MyISAM ${INNODB_OR_MYISAM} "bigint(20) unsigned" ${SYS_TRX_TYPE} timestamp(6) ${SYS_TRX_TYPE}
|
||||
show create table t1;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
--error ER_VERS_WRONG_PARTS
|
||||
alter table t1 drop partition pn;
|
||||
alter table t1 drop partition p1;
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
--error ER_VERS_WRONG_PARTS
|
||||
alter table t1 drop partition p0;
|
||||
|
||||
# insert, delete, update
|
||||
@ -138,6 +138,14 @@ select @ts0 = @ts1;
|
||||
select @ts2 = @ts3;
|
||||
|
||||
# rotation by LIMIT
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time limit 0 (
|
||||
partition p0 versioning,
|
||||
partition p1 versioning,
|
||||
partition pn as of now);
|
||||
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time limit 1 (
|
||||
@ -162,6 +170,14 @@ delete from t1;
|
||||
select * from t1 partition (p1) for system_time all;
|
||||
|
||||
# rotation by INTERVAL
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time interval 0 second (
|
||||
partition p0 versioning,
|
||||
partition p1 versioning,
|
||||
partition pn as of now);
|
||||
|
||||
create or replace table t1 (x int)
|
||||
with system versioning
|
||||
partition by system_time interval 1 second (
|
||||
|
@ -127,7 +127,7 @@ select * from t1 for system_time all;
|
||||
|
||||
create or replace table t1 (x int) with system versioning;
|
||||
insert into t1 values (1);
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
--error ER_VERS_HISTORY_LOCK
|
||||
select * from t1 for system_time all for update;
|
||||
|
||||
create or replace table t1 (a int not null auto_increment primary key) with system versioning;
|
||||
@ -197,7 +197,7 @@ delete from t1 where x = 3;
|
||||
insert into t2 values (1);
|
||||
select * from t1, t2 query for system_time all;
|
||||
|
||||
--error ER_VERS_WRONG_QUERY
|
||||
--error ER_VERS_UNUSED_CLAUSE
|
||||
select * from t1 for system_time all, t2 for system_time all query for system_time all;
|
||||
|
||||
drop view v1;
|
||||
|
@ -71,11 +71,11 @@ show create table t for system_time as of now;
|
||||
set versioning_ddl_survival=on;
|
||||
|
||||
create or replace table t (a int) with system versioning;
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
--error ER_VERS_RANGE_PROHIBITED
|
||||
show create table t for system_time between timestamp @tm1 and timestamp @tm1;
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
--error ER_VERS_RANGE_PROHIBITED
|
||||
show create table t for system_time from timestamp @tm1 to timestamp @tm1;
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
--error ER_VERS_RANGE_PROHIBITED
|
||||
show create table t for system_time before timestamp @tm1;
|
||||
--error ER_VERS_VTMD_ERROR
|
||||
show create table t for system_time as of timestamp '01-01-1990';
|
||||
|
@ -327,3 +327,39 @@ void my_error_unregister_all(void)
|
||||
|
||||
my_errmsgs_list= &my_errmsgs_globerrs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Format one error and print out as another error code.
|
||||
|
||||
@note
|
||||
Stacks two error messages and prints as single error message.
|
||||
Like my_error(), but error argument is another formatted error
|
||||
|
||||
@param nr1 error number of printed message. nr1 must have exactly one %s
|
||||
parameter which will be formatted message of error nr2.
|
||||
@param nr2 error number of formatted message
|
||||
@param MyFlags Flags
|
||||
@param ... parameters for error nr2
|
||||
*/
|
||||
|
||||
void my_error_as(uint nr1, uint nr2, myf MyFlags, ...)
|
||||
{
|
||||
const char *format;
|
||||
va_list args;
|
||||
char ebuff[ERRMSGSIZE];
|
||||
DBUG_ENTER("my_suberror");
|
||||
DBUG_PRINT("my", ("nr1: %d nr2: %d MyFlags: %lu errno: %d", nr1, nr2, MyFlags, errno));
|
||||
|
||||
if (!(format = my_get_err_msg(nr2)))
|
||||
(void) my_snprintf(ebuff, sizeof(ebuff), "Unknown error %d", nr2);
|
||||
else
|
||||
{
|
||||
va_start(args,MyFlags);
|
||||
(void) my_vsnprintf_ex(&my_charset_utf8_general_ci, ebuff,
|
||||
sizeof(ebuff), format, args);
|
||||
va_end(args);
|
||||
}
|
||||
my_error(nr1, MyFlags, ebuff);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
@ -6696,24 +6696,24 @@ bool Vers_parse_info::check_and_fix_implicit(
|
||||
// then created table will be versioned.
|
||||
if (thd->variables.vers_force || vers_tables > 0)
|
||||
{
|
||||
declared_with_system_versioning= true;
|
||||
with_system_versioning= true;
|
||||
create_info->options|= HA_VERSIONED_TABLE;
|
||||
}
|
||||
|
||||
if (!need_check())
|
||||
return false;
|
||||
|
||||
if (declared_without_system_versioning)
|
||||
if (without_system_versioning)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"'WITHOUT SYSTEM VERSIONING' is not allowed");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_NOT_ALLOWED, MYF(0), table_name,
|
||||
"WITHOUT SYSTEM VERSIONING");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!declared_with_system_versioning && !has_versioned_fields)
|
||||
if (!with_system_versioning && !versioned_fields)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"'WITH SYSTEM VERSIONING' missing");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MISSING, MYF(0), table_name,
|
||||
"WITH SYSTEM VERSIONING");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6729,8 +6729,7 @@ bool Vers_parse_info::check_and_fix_implicit(
|
||||
if (orig_table && orig_table != f->field->orig_table)
|
||||
{
|
||||
err_different_tables:
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"system fields selected from different tables");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_VERS_DIFFERENT_TABLES, MYF(0), table_name);
|
||||
return true;
|
||||
}
|
||||
orig_table= f->field->orig_table;
|
||||
@ -6756,7 +6755,7 @@ bool Vers_parse_info::check_and_fix_implicit(
|
||||
}
|
||||
|
||||
if ((f->versioning == Column_definition::VERSIONING_NOT_SET &&
|
||||
!declared_with_system_versioning) ||
|
||||
!with_system_versioning) ||
|
||||
f->versioning == Column_definition::WITHOUT_VERSIONING)
|
||||
{
|
||||
f->flags|= VERS_OPTIMIZED_UPDATE_FLAG;
|
||||
@ -6769,14 +6768,14 @@ bool Vers_parse_info::check_and_fix_implicit(
|
||||
{
|
||||
if (!generated_as_row.start && !generated_as_row.end)
|
||||
{
|
||||
declared_with_system_versioning= false;
|
||||
with_system_versioning= false;
|
||||
create_info->options&= ~HA_VERSIONED_TABLE;
|
||||
return false;
|
||||
}
|
||||
if (!generated_as_row.start || !generated_as_row.end)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"both ROW START and ROW END system fields required in SELECT resultset");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MISSING, MYF(0), table_name,
|
||||
generated_as_row.start ? "AS ROW END" : "AS ROW START");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -6807,8 +6806,8 @@ bool Vers_parse_info::check_and_fix_implicit(
|
||||
vers_cols == 0 &&
|
||||
(plain_cols == 0 || !table_with_system_versioning))
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"no columns defined with system versioning!");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_VERS_NO_COLS_DEFINED, MYF(0),
|
||||
table_name, "WITH SYSTEM VERSIONING");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6837,12 +6836,11 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
|
||||
if (!need_check() && !share->versioned)
|
||||
return false;
|
||||
|
||||
if (declared_without_system_versioning)
|
||||
if (without_system_versioning)
|
||||
{
|
||||
if (!share->versioned)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"table is not versioned");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_VERS_NOT_VERSIONED, MYF(0), table_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6854,10 +6852,9 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((has_versioned_fields || has_unversioned_fields) && !share->versioned)
|
||||
if ((versioned_fields || unversioned_fields) && !share->versioned)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"Can not change fields versioning mode in a non-versioned table");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_VERS_NOT_VERSIONED, MYF(0), table_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6928,7 +6925,7 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
|
||||
}
|
||||
|
||||
return fix_implicit(thd, alter_info, integer_fields) ||
|
||||
(declared_with_system_versioning &&
|
||||
(with_system_versioning &&
|
||||
(check_with_conditions(table_name) ||
|
||||
check_generated_type(table_name, alter_info, integer_fields)));
|
||||
}
|
||||
@ -6958,8 +6955,8 @@ bool Vers_parse_info::fix_create_like(THD *thd, Alter_info *alter_info,
|
||||
|
||||
if (!f_start || !f_end)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table->table_name,
|
||||
"Missed one of system versioning fields from source");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MISSING, MYF(0), table->table_name,
|
||||
f_start ? "AS ROW END" : "AS ROW START");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6973,38 +6970,31 @@ bool Vers_parse_info::fix_create_like(THD *thd, Alter_info *alter_info,
|
||||
|
||||
bool Vers_parse_info::check_with_conditions(const char *table_name) const
|
||||
{
|
||||
if (!generated_as_row.start)
|
||||
if (!generated_as_row.start || !generated_as_row.end)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"'GENERATED AS ROW START' column missing");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!generated_as_row.end)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"'GENERATED AS ROW END' column missing");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MISSING, MYF(0), table_name,
|
||||
generated_as_row.start ? "AS ROW END" : "AS ROW START");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!period_for_system_time.start || !period_for_system_time.end)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"'PERIOD FOR SYSTEM_TIME' missing");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MISSING, MYF(0), table_name,
|
||||
"PERIOD FOR SYSTEM_TIME");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (generated_as_row.start != period_for_system_time.start)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW START' mismatch");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MISMATCH, MYF(0), table_name,
|
||||
"PERIOD FOR SYSTEM_TIME", "AS ROW START");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (generated_as_row.end != period_for_system_time.end)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW END' mismatch");
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MISMATCH, MYF(0), table_name,
|
||||
"PERIOD FOR SYSTEM_TIME", "AS ROW END");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1677,10 +1677,10 @@ class Create_field;
|
||||
struct Vers_parse_info
|
||||
{
|
||||
Vers_parse_info() :
|
||||
declared_with_system_versioning(false),
|
||||
declared_without_system_versioning(false),
|
||||
has_versioned_fields(false),
|
||||
has_unversioned_fields(false)
|
||||
with_system_versioning(false),
|
||||
without_system_versioning(false),
|
||||
versioned_fields(false),
|
||||
unversioned_fields(false)
|
||||
{}
|
||||
|
||||
struct start_end_t
|
||||
@ -1712,10 +1712,10 @@ private:
|
||||
bool need_check() const
|
||||
{
|
||||
return
|
||||
has_versioned_fields ||
|
||||
has_unversioned_fields ||
|
||||
declared_with_system_versioning ||
|
||||
declared_without_system_versioning ||
|
||||
versioned_fields ||
|
||||
unversioned_fields ||
|
||||
with_system_versioning ||
|
||||
without_system_versioning ||
|
||||
period_for_system_time.start.str ||
|
||||
period_for_system_time.end.str ||
|
||||
generated_as_row.start.str ||
|
||||
@ -1735,22 +1735,22 @@ public:
|
||||
HA_CREATE_INFO *create_info, TABLE_LIST *table);
|
||||
|
||||
/** User has added 'WITH SYSTEM VERSIONING' to table definition */
|
||||
bool declared_with_system_versioning : 1;
|
||||
bool with_system_versioning : 1;
|
||||
|
||||
/** Use has added 'WITHOUT SYSTEM VERSIONING' to ALTER TABLE */
|
||||
bool declared_without_system_versioning : 1;
|
||||
bool without_system_versioning : 1;
|
||||
|
||||
/**
|
||||
At least one field was specified 'WITH SYSTEM VERSIONING'. Useful for
|
||||
error handling.
|
||||
*/
|
||||
bool has_versioned_fields : 1;
|
||||
bool versioned_fields : 1;
|
||||
|
||||
/**
|
||||
At least one field was specified 'WITHOUT SYSTEM VERSIONING'. Useful for
|
||||
error handling.
|
||||
*/
|
||||
bool has_unversioned_fields : 1;
|
||||
bool unversioned_fields : 1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -851,16 +851,8 @@ bool partition_info::vers_init_info(THD * thd)
|
||||
|
||||
bool partition_info::vers_set_interval(const INTERVAL & i)
|
||||
{
|
||||
if (i.neg)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "negative INTERVAL");
|
||||
if (i.neg || i.second_part)
|
||||
return true;
|
||||
}
|
||||
if (i.second_part)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "second fractions in INTERVAL");
|
||||
return true;
|
||||
}
|
||||
|
||||
DBUG_ASSERT(vers_info);
|
||||
|
||||
@ -874,20 +866,16 @@ bool partition_info::vers_set_interval(const INTERVAL & i)
|
||||
i.year * 365 * 30 * 24 * 60 * 60;
|
||||
|
||||
if (vers_info->interval == 0)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "zero INTERVAL");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool partition_info::vers_set_limit(ulonglong limit)
|
||||
{
|
||||
if (limit < 1)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "non-positive LIMIT");
|
||||
return true;
|
||||
}
|
||||
|
||||
DBUG_ASSERT(vers_info);
|
||||
|
||||
vers_info->limit= limit;
|
||||
@ -1978,15 +1966,11 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
|
||||
|
||||
if (part_type == VERSIONING_PARTITION)
|
||||
{
|
||||
if (num_parts < 2)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "unexpected number of partitions (expected > 1)");
|
||||
goto end;
|
||||
}
|
||||
DBUG_ASSERT(vers_info);
|
||||
if (!vers_info->now_part)
|
||||
if (num_parts < 2 || !vers_info->now_part)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "no `AS OF NOW` partition defined");
|
||||
DBUG_ASSERT(info && info->alias);
|
||||
my_error(ER_VERS_WRONG_PARTS, MYF(0), info->alias);
|
||||
goto end;
|
||||
}
|
||||
DBUG_ASSERT(vers_info->initialized(false));
|
||||
@ -2135,7 +2119,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
|
||||
}
|
||||
if (now_parts > 1)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "multiple `AS OF NOW` partitions");
|
||||
my_error(ER_VERS_WRONG_PARTS, MYF(0), info->alias);
|
||||
goto end;
|
||||
}
|
||||
result= FALSE;
|
||||
|
@ -7500,7 +7500,7 @@ ER_VERS_FIELD_WRONG_TYPE
|
||||
eng "%`s must be of type %`s for versioned table %`s"
|
||||
|
||||
ER_VERS_WRONG_PARAMS
|
||||
eng "Wrong parameters for %`s: %s"
|
||||
eng "Wrong parameters %s"
|
||||
|
||||
ER_VERS_ENGINE_UNSUPPORTED
|
||||
eng "Engine does not support System Versioning for %`s"
|
||||
@ -7532,8 +7532,8 @@ WARN_VERS_PART_NON_HISTORICAL
|
||||
ER_VERS_NOT_ALLOWED
|
||||
eng "%`s is not allowed for versioned table"
|
||||
|
||||
ER_VERS_WRONG_QUERY_TYPE
|
||||
eng "%`s works only with %`s query type"
|
||||
ER_VERS_RANGE_PROHIBITED
|
||||
eng "SYSTEM_TIME range selector is prohibited"
|
||||
|
||||
ER_VERS_VIEW_PROHIBITED
|
||||
eng "Creating VIEW %`s is prohibited!"
|
||||
@ -7541,14 +7541,53 @@ ER_VERS_VIEW_PROHIBITED
|
||||
ER_VERS_DERIVED_PROHIBITED
|
||||
eng "Derived table is prohibited!"
|
||||
|
||||
ER_VERS_WRONG_QUERY
|
||||
eng "Wrong versioned query: %s"
|
||||
ER_VERS_UNUSED_CLAUSE
|
||||
eng "Unused clause: '%s'"
|
||||
|
||||
WARN_VERS_ALIAS_TOO_LONG
|
||||
eng "Auto generated alias for `%s.%s` is too long; using `%s`."
|
||||
eng "Auto generated alias for `%s.%s` is too long; using `%s`"
|
||||
|
||||
ER_VERS_VTMD_ERROR
|
||||
eng "VTMD error: %s"
|
||||
|
||||
ER_MULTIPLE_CLAUSE
|
||||
eng "for %`s: multiple '%s'"
|
||||
|
||||
ER_MULTIPLE_CLAUSE_FOR
|
||||
eng "for %`s: multiple '%s' for %`s"
|
||||
|
||||
ER_MULTIPLE_CLAUSE_2
|
||||
eng "for %`s: multiple '%s' (%`s, %`s)"
|
||||
|
||||
ER_MULTIPLE_IDENTIFIER
|
||||
eng "for %`s: multiple %`s for '%s'"
|
||||
|
||||
ER_NOT_ALLOWED
|
||||
eng "for %`s: not allowed '%s'"
|
||||
|
||||
ER_VERS_DIFFERENT_TABLES
|
||||
eng "for %`s: system fields selected from different tables"
|
||||
|
||||
ER_VERS_NO_COLS_DEFINED
|
||||
eng "for %`s: no columns defined '%s'"
|
||||
|
||||
ER_VERS_NOT_VERSIONED
|
||||
eng "for %`s: table is not versioned"
|
||||
|
||||
ER_MISSING
|
||||
eng "for %`s: missing '%s'"
|
||||
|
||||
ER_MISMATCH
|
||||
eng "for %`s: mismatch '%s' and '%s'"
|
||||
|
||||
ER_PART_WRONG_VALUE
|
||||
eng "for partitioned %`s: wrong value for '%s'"
|
||||
|
||||
ER_VERS_WRONG_PARTS
|
||||
eng "Wrong partitions consistency for %`s: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'"
|
||||
|
||||
ER_VERS_HISTORY_LOCK
|
||||
eng "Versioned SELECT write-locking of history rows"
|
||||
|
||||
ER_WRONG_TABLESPACE_NAME 42000
|
||||
eng "Incorrect tablespace name `%-.192s`"
|
||||
|
@ -5368,7 +5368,8 @@ that are reorganised.
|
||||
{
|
||||
if (num_parts_dropped >= tab_part_info->num_parts - 1)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "one `AS OF NOW` and at least one `VERSIONING` partition required");
|
||||
DBUG_ASSERT(table && table->s && table->s->table_name.str);
|
||||
my_error(ER_VERS_WRONG_PARTS, MYF(0), table->s->table_name.str);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@ -5394,7 +5395,8 @@ that are reorganised.
|
||||
{
|
||||
if (part_elem->type == partition_element::AS_OF_NOW)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "`AS OF NOW` partition can not be dropped");
|
||||
DBUG_ASSERT(table && table->s && table->s->table_name.str);
|
||||
my_error(ER_VERS_WRONG_PARTS, MYF(0), table->s->table_name.str);
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
|
@ -824,7 +824,7 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
|
||||
case TL_WRITE_LOW_PRIORITY:
|
||||
case TL_WRITE:
|
||||
case TL_WRITE_ONLY:
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), "FOR SYSTEM_TIME query", "write-locking of historic rows");
|
||||
my_error(ER_VERS_HISTORY_LOCK, MYF(0));
|
||||
DBUG_RETURN(-1);
|
||||
default:
|
||||
break;
|
||||
@ -1004,7 +1004,7 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
|
||||
|
||||
if (!slex->vers_conditions.used && slex->vers_conditions)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_QUERY, MYF(0), "unused `QUERY FOR SYSTEM_TIME` clause!");
|
||||
my_error(ER_VERS_UNUSED_CLAUSE, MYF(0), "QUERY FOR SYSTEM_TIME");
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
|
128
sql/sql_yacc.yy
128
sql/sql_yacc.yy
@ -67,6 +67,7 @@
|
||||
#include "lex_token.h"
|
||||
#include "sql_lex.h"
|
||||
#include "sql_sequence.h"
|
||||
#include "vers_utils.h"
|
||||
|
||||
/* this is to get the bison compilation windows warnings out */
|
||||
#ifdef _MSC_VER
|
||||
@ -851,6 +852,7 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
|
||||
enum trigger_order_type trigger_action_order_type;
|
||||
DDL_options_st object_ddl_options;
|
||||
enum vers_range_unit_t vers_range_unit;
|
||||
enum Column_definition::enum_column_versioning vers_column_versioning;
|
||||
}
|
||||
|
||||
%{
|
||||
@ -1973,7 +1975,7 @@ END_OF_INPUT
|
||||
|
||||
%type <vers_range_unit> trans_or_timestamp
|
||||
%type <BOOL> opt_for_system_time_clause
|
||||
|
||||
%type <vers_column_versioning> with_or_without_system
|
||||
%%
|
||||
|
||||
|
||||
@ -5206,8 +5208,11 @@ opt_part_values:
|
||||
}
|
||||
else
|
||||
{
|
||||
DBUG_ASSERT(Lex->create_last_non_select_table);
|
||||
DBUG_ASSERT(Lex->create_last_non_select_table->table_name);
|
||||
// FIXME: other ALTER commands?
|
||||
my_yyabort_error((ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "AS OF NOW partition can not be added"));
|
||||
my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0),
|
||||
Lex->create_last_non_select_table->table_name));
|
||||
}
|
||||
elem->type= partition_element::AS_OF_NOW;
|
||||
DBUG_ASSERT(part_info->vers_info);
|
||||
@ -5235,7 +5240,11 @@ opt_part_values:
|
||||
}
|
||||
DBUG_ASSERT(part_info->vers_info);
|
||||
if (part_info->vers_info->now_part)
|
||||
my_yyabort_error((ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "AS OF NOW partition is not last"));
|
||||
{
|
||||
DBUG_ASSERT(Lex->create_last_non_select_table);
|
||||
DBUG_ASSERT(Lex->create_last_non_select_table->table_name);
|
||||
my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0), Lex->create_last_non_select_table->table_name));
|
||||
}
|
||||
elem->type= partition_element::VERSIONING;
|
||||
if (part_info->init_column_part(thd))
|
||||
{
|
||||
@ -5551,10 +5560,13 @@ opt_versioning_interval:
|
||||
partition_info *part_info= Lex->part_info;
|
||||
DBUG_ASSERT(part_info->part_type == VERSIONING_PARTITION);
|
||||
INTERVAL interval;
|
||||
if (get_interval_value($2, $3, &interval))
|
||||
my_yyabort_error((ER_VERS_WRONG_PARAMS, MYF(0), "BY SYSTEM_TIME", "wrong INTERVAL value"));
|
||||
if (part_info->vers_set_interval(interval))
|
||||
if (get_interval_value($2, $3, &interval) ||
|
||||
part_info->vers_set_interval(interval))
|
||||
{
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_PART_WRONG_VALUE, MYF(0),
|
||||
Lex->create_last_non_select_table->table_name, "INTERVAL");
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@ -5565,7 +5577,11 @@ opt_versioning_limit:
|
||||
partition_info *part_info= Lex->part_info;
|
||||
DBUG_ASSERT(part_info->part_type == VERSIONING_PARTITION);
|
||||
if (part_info->vers_set_limit($2))
|
||||
{
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_PART_WRONG_VALUE, MYF(0),
|
||||
Lex->create_last_non_select_table->table_name, "LIMIT");
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@ -5936,32 +5952,28 @@ create_table_option:
|
||||
Lex->create_info.used_fields|= HA_CREATE_USED_SEQUENCE;
|
||||
Lex->create_info.sequence= $3;
|
||||
}
|
||||
| WITH_SYSTEM_SYM VERSIONING_SYM
|
||||
| WITH_SYSTEM_SYM table_versioning
|
||||
{
|
||||
const char *table_name=
|
||||
Lex->create_last_non_select_table->table_name;
|
||||
Vers_parse_info &info= Lex->vers_get_info();
|
||||
if (info.declared_with_system_versioning ||
|
||||
info.declared_without_system_versioning)
|
||||
my_yyabort_error(
|
||||
(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"Versioning specified more than once for the same table"));
|
||||
|
||||
info.declared_with_system_versioning= true;
|
||||
Lex->vers_get_info().with_system_versioning= true;
|
||||
Lex->create_info.options|= HA_VERSIONED_TABLE;
|
||||
}
|
||||
| WITHOUT SYSTEM VERSIONING_SYM
|
||||
| WITHOUT SYSTEM table_versioning
|
||||
{
|
||||
const char *table_name=
|
||||
Lex->create_last_non_select_table->table_name;
|
||||
Vers_parse_info &info= Lex->vers_get_info();
|
||||
if (info.declared_with_system_versioning ||
|
||||
info.declared_without_system_versioning)
|
||||
my_yyabort_error(
|
||||
(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"Versioning specified more than once for the same table"));
|
||||
Lex->vers_get_info().without_system_versioning= true;
|
||||
}
|
||||
;
|
||||
|
||||
info.declared_without_system_versioning= true;
|
||||
table_versioning:
|
||||
VERSIONING_SYM
|
||||
{
|
||||
Vers_parse_info &info= Lex->vers_get_info();
|
||||
if (info.with_system_versioning || info.without_system_versioning)
|
||||
{
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MULTIPLE_CLAUSE, MYF(0),
|
||||
Lex->create_last_non_select_table->table_name,
|
||||
"WITH/WITHOUT SYSTEM VERSIONING");
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@ -6169,9 +6181,10 @@ period_for_system_time:
|
||||
Vers_parse_info &info= Lex->vers_get_info();
|
||||
if (!my_strcasecmp(system_charset_info, $4.str, $6.str))
|
||||
{
|
||||
my_yyabort_error((ER_VERS_WRONG_PARAMS, MYF(0),
|
||||
Lex->create_last_non_select_table->table_name,
|
||||
"'PERIOD FOR SYSTEM_TIME' columns must be different"));
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MULTIPLE_IDENTIFIER, MYF(0),
|
||||
Lex->create_last_non_select_table->table_name, $4.str,
|
||||
"PERIOD FOR SYSTEM_TIME");
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
info.set_period_for_system_time($4, $6);
|
||||
}
|
||||
@ -6288,17 +6301,17 @@ field_def:
|
||||
const char *table_name= lex->create_last_non_select_table->table_name;
|
||||
|
||||
LString_i *p;
|
||||
const char* err;
|
||||
const char* clause;
|
||||
switch ($4)
|
||||
{
|
||||
case 1:
|
||||
p= &info.generated_as_row.start;
|
||||
err= "multiple 'GENERATED ALWAYS AS ROW START'";
|
||||
clause= "AS ROW START";
|
||||
lex->last_field->flags|= VERS_SYS_START_FLAG;
|
||||
break;
|
||||
case 0:
|
||||
p= &info.generated_as_row.end;
|
||||
err= "multiple 'GENERATED ALWAYS AS ROW END'";
|
||||
clause= "AS ROW END";
|
||||
lex->last_field->flags|= VERS_SYS_END_FLAG;
|
||||
break;
|
||||
default:
|
||||
@ -6309,7 +6322,9 @@ field_def:
|
||||
DBUG_ASSERT(p);
|
||||
if (*p)
|
||||
{
|
||||
my_yyabort_error((ER_VERS_WRONG_PARAMS, MYF(0), table_name, err));
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MULTIPLE_CLAUSE_2, MYF(0),
|
||||
table_name, clause, field_name, p->ptr());
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
*p= field_name;
|
||||
if (lex->last_field->implicit_not_null)
|
||||
@ -6805,31 +6820,30 @@ serial_attribute:
|
||||
new (thd->mem_root)
|
||||
engine_option_value($1, &Lex->last_field->option_list, &Lex->option_list_last);
|
||||
}
|
||||
| WITH_SYSTEM_SYM VERSIONING_SYM
|
||||
| with_or_without_system VERSIONING_SYM
|
||||
{
|
||||
if (Lex->last_field->versioning !=
|
||||
Column_definition::VERSIONING_NOT_SET)
|
||||
my_yyabort_error(
|
||||
(ER_VERS_WRONG_PARAMS, MYF(0),
|
||||
if (Lex->last_field->versioning != Column_definition::VERSIONING_NOT_SET)
|
||||
{
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_MULTIPLE_CLAUSE_FOR, MYF(0),
|
||||
Lex->create_last_non_select_table->table_name,
|
||||
"Versioning specified more than once for the same field"));
|
||||
|
||||
Lex->last_field->versioning = Column_definition::WITH_VERSIONING;
|
||||
Lex->create_info.vers_info.has_versioned_fields= true;
|
||||
"WITH/WITHOUT SYSTEM VERSIONING", Lex->last_field->field_name);
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
Lex->last_field->versioning= $1;
|
||||
Lex->create_info.options|= HA_VERSIONED_TABLE;
|
||||
}
|
||||
| WITHOUT SYSTEM VERSIONING_SYM
|
||||
{
|
||||
if (Lex->last_field->versioning !=
|
||||
Column_definition::VERSIONING_NOT_SET)
|
||||
my_yyabort_error(
|
||||
(ER_VERS_WRONG_PARAMS, MYF(0),
|
||||
Lex->create_last_non_select_table->table_name,
|
||||
"Versioning specified more than once for the same field"));
|
||||
;
|
||||
|
||||
Lex->last_field->versioning = Column_definition::WITHOUT_VERSIONING;
|
||||
Lex->create_info.vers_info.has_unversioned_fields= true;
|
||||
Lex->create_info.options|= HA_VERSIONED_TABLE;
|
||||
with_or_without_system:
|
||||
WITH_SYSTEM_SYM
|
||||
{
|
||||
Lex->create_info.vers_info.versioned_fields= true;
|
||||
$$= Column_definition::WITH_VERSIONING;
|
||||
}
|
||||
| WITHOUT SYSTEM
|
||||
{
|
||||
Lex->create_info.vers_info.unversioned_fields= true;
|
||||
$$= Column_definition::WITHOUT_VERSIONING;
|
||||
}
|
||||
;
|
||||
|
||||
@ -13336,9 +13350,9 @@ show_param:
|
||||
lex->create_info.storage_media= HA_SM_DEFAULT;
|
||||
|
||||
if (lex->vers_conditions.type != FOR_SYSTEM_TIME_UNSPECIFIED &&
|
||||
lex->vers_conditions.type != FOR_SYSTEM_TIME_AS_OF) {
|
||||
my_yyabort_error((ER_VERS_WRONG_PARAMS, MYF(0), "FOR SYSTEM_TIME",
|
||||
"only AS OF allowed here"));
|
||||
lex->vers_conditions.type != FOR_SYSTEM_TIME_AS_OF)
|
||||
{
|
||||
my_yyabort_error((ER_VERS_RANGE_PROHIBITED, MYF(0)));
|
||||
}
|
||||
if ($4)
|
||||
Lex->last_table()->vers_conditions= Lex->vers_conditions;
|
||||
|
Reference in New Issue
Block a user