Commit 03b54a6b authored by Eugene Kosov's avatar Eugene Kosov Committed by Aleksey Midenkov

SQL: table with duplicate ROW START/END columns [fixes #369]

parent 84b718ae
......@@ -37,11 +37,10 @@ t1 CREATE TABLE `t1` (
create or replace table t1 (
x3 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
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)
period for system_time (x, Sys_end)
) with system versioning;
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start2` and `Sys_end`
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end`
create or replace table t1 (
x4 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
......@@ -53,10 +52,9 @@ create or replace table t1 (
x5 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
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)
period for system_time (Sys_start, x)
) with system versioning;
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end2`
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end`
create or replace table t1 (
x6 int unsigned,
period for system_time (Sys_start, Sys_end)
......@@ -66,7 +64,6 @@ create or replace table t1 (
x7 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
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`: missing 'WITH SYSTEM VERSIONING'
......@@ -302,5 +299,13 @@ alter table t with system versioning;
ERROR 42S21: Duplicate column name 'sys_trx_end'
create or replace temporary table t (x int) with system versioning;
ERROR HY000: Incorrect usage of TEMPORARY and WITH SYSTEM VERSIONING
create or replace table t1 (
x11 int unsigned,
Sys_start0 timestamp(6) generated always as row start,
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)
) with system versioning;
ERROR HY000: Duplicate ROW START column `Sys_start`
drop database test;
create database test;
......@@ -43,9 +43,8 @@ show create table t1;
eval create or replace table t1 (
x3 int unsigned,
Sys_start $sys_datatype generated always as row start,
Sys_start2 $sys_datatype generated always as row start,
Sys_end $sys_datatype generated always as row end,
period for system_time (Sys_start, Sys_end)
period for system_time (x, Sys_end)
) with system versioning;
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
......@@ -63,8 +62,7 @@ eval create or replace table t1 (
x5 int unsigned,
Sys_start $sys_datatype generated always as row start,
Sys_end $sys_datatype generated always as row end,
Sys_end2 $sys_datatype generated always as row end,
period for system_time (Sys_start, Sys_end)
period for system_time (Sys_start, x)
) with system versioning;
--error ER_MISSING
......@@ -79,7 +77,6 @@ eval create or replace table t1 (
x7 int unsigned,
Sys_start $sys_datatype generated always as row start,
Sys_end $sys_datatype generated always as row end,
Sys_end2 $sys_datatype generated always as row end,
period for system_time (Sys_start, Sys_end)
);
......@@ -289,5 +286,14 @@ alter table t with system versioning;
--error ER_WRONG_USAGE
create or replace temporary table t (x int) with system versioning;
--error ER_VERS_DUPLICATE_ROW_START_END
create or replace table t1 (
x11 int unsigned,
Sys_start0 timestamp(6) generated always as row start,
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)
) with system versioning;
drop database test;
create database test;
......@@ -7914,3 +7914,5 @@ ER_VERS_GENERATED_ALWAYS_NOT_EMPTY
ER_VERS_TRT_IS_DISABLED
eng "Some versioned DML requires `transaction_registry` to be set to ON."
ER_VERS_DUPLICATE_ROW_START_END
eng "Duplicate ROW %s column %`s"
......@@ -6404,10 +6404,20 @@ field_def:
{
case 1:
p= &info.as_row.start;
if (*p)
{
my_yyabort_error((ER_VERS_DUPLICATE_ROW_START_END, MYF(0),
"START", field_name.str));
}
lex->last_field->flags|= VERS_SYS_START_FLAG;
break;
case 0:
p= &info.as_row.end;
if (*p)
{
my_yyabort_error((ER_VERS_DUPLICATE_ROW_START_END, MYF(0),
"END", field_name.str));
}
lex->last_field->flags|= VERS_SYS_END_FLAG;
break;
default:
......
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