Browse Source
MDEV-17082 Application-time periods: CREATE
MDEV-17082 Application-time periods: CREATE
* add syntax `CREATE TABLE ... PERIOD FOR <apptime>` * add table period entitybb-10.4-elenst-no-mdev371
committed by
Sergei Golubchik
18 changed files with 617 additions and 189 deletions
-
92mysql-test/suite/period/r/create.result
-
73mysql-test/suite/period/t/create.test
-
4sql/field.h
-
109sql/handler.cc
-
70sql/handler.h
-
8sql/share/errmsg-utf8.txt
-
21sql/sql_lex.h
-
4sql/sql_parse.cc
-
33sql/sql_show.cc
-
4sql/sql_table.cc
-
7sql/sql_yacc.yy
-
7sql/sql_yacc_ora.yy
-
261sql/table.cc
-
33sql/table.h
-
47sql/unireg.cc
-
1sql/unireg.h
-
4storage/innobase/handler/ha_innodb.cc
-
8storage/innobase/handler/handler0alter.cc
@ -0,0 +1,92 @@ |
|||||
|
create or replace table t (id int primary key, s date, e date, |
||||
|
period for mytime(s,e)); |
||||
|
show create table t; |
||||
|
Table Create Table |
||||
|
t CREATE TABLE `t` ( |
||||
|
`id` int(11) NOT NULL, |
||||
|
`s` date NOT NULL, |
||||
|
`e` date NOT NULL, |
||||
|
PRIMARY KEY (`id`), |
||||
|
PERIOD FOR `mytime` (`s`, `e`), |
||||
|
CONSTRAINT `CONSTRAINT_1` CHECK (`s` < `e`) |
||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
||||
|
create or replace table t (id int primary key, s timestamp(6), e timestamp(6), |
||||
|
period for mytime(s,e)); |
||||
|
show create table t; |
||||
|
Table Create Table |
||||
|
t CREATE TABLE `t` ( |
||||
|
`id` int(11) NOT NULL, |
||||
|
`s` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', |
||||
|
`e` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', |
||||
|
PRIMARY KEY (`id`), |
||||
|
PERIOD FOR `mytime` (`s`, `e`), |
||||
|
CONSTRAINT `CONSTRAINT_1` CHECK (`s` < `e`) |
||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
||||
|
# SQL16, Part 2, 11.3 <table definition>, Syntax Rules, 2)a) |
||||
|
# 2) If a <table period definition> TPD is specified, then: |
||||
|
# a) <table scope> shall not be specified. |
||||
|
create or replace temporary table t (s date, e date, period for mytime(s,e)); |
||||
|
ERROR HY000: Application-time period table cannot be temporary |
||||
|
# SQL16, Part 2, 11.3 <table definition>, Syntax Rules, 2)e)iii) |
||||
|
# The <data type or domain name> contained in CD1 is either DATE or a |
||||
|
# timestamp type and it is equivalent to the <data type or domain name> |
||||
|
# contained in CD2. |
||||
|
create or replace table t (id int primary key, s datetime, e date, |
||||
|
period for mytime(s,e)); |
||||
|
ERROR HY000: Fields of PERIOD FOR `mytime` have different types |
||||
|
create or replace table t (s timestamp(2), e timestamp(6), |
||||
|
period for mytime(s,e)); |
||||
|
ERROR HY000: Fields of PERIOD FOR `mytime` have different types |
||||
|
create or replace table t (id int primary key, s int, e date, |
||||
|
period for mytime(s,e)); |
||||
|
ERROR 42000: Incorrect column specifier for column 's' |
||||
|
create or replace table t (id int primary key, s date, e date, |
||||
|
period for mytime(s,x)); |
||||
|
ERROR 42S22: Unknown column 'x' in 'mytime' |
||||
|
create or replace table t (id int primary key, s date, e date, |
||||
|
period for mytime(s,e), |
||||
|
period for mytime2(s,e)); |
||||
|
ERROR HY000: Cannot specify more than one application-time period |
||||
|
# SQL16, Part 2, 11.3 <table definition>, Syntax Rules, 2)d) |
||||
|
# No <column name> in any <column definition> shall be equivalent to PN. |
||||
|
create or replace table t (mytime int, s date, e date, |
||||
|
period for mytime(s,e)); |
||||
|
ERROR 42S21: Duplicate column name 'mytime' |
||||
|
# SQL16, Part 2, 11.3 <table definition>, Syntax Rules, 2)e)v)2)A) |
||||
|
# Neither CD1 nor CD2 shall contain an <identity column specification>, a |
||||
|
# <generation clause>, a <system time period start column specification>, |
||||
|
# or a <system time period end column specification>. |
||||
|
create or replace table t (id int primary key, |
||||
|
s date, |
||||
|
e date generated always as (s+1), |
||||
|
period for mytime(s,e)); |
||||
|
ERROR HY000: Period field `e` cannot be GENERATED ALWAYS AS |
||||
|
create or replace table t (id int primary key, |
||||
|
s date, |
||||
|
e date as (s+1) VIRTUAL, |
||||
|
period for mytime(s,e)); |
||||
|
ERROR HY000: Period field `e` cannot be GENERATED ALWAYS AS |
||||
|
create or replace table t (id int primary key, s timestamp(6), e timestamp(6), |
||||
|
st timestamp(6) as row start, |
||||
|
en timestamp(6) as row end, |
||||
|
period for system_time (st, en), |
||||
|
period for mytime(st,e)) with system versioning; |
||||
|
ERROR HY000: Period field `st` cannot be GENERATED ALWAYS AS |
||||
|
# SQL16, Part 2, 11.3 <table definition>, Syntax Rules, 2) |
||||
|
# Let IDCN be an implementation-dependent <constraint name> that is not |
||||
|
# equivalent to the <constraint name> of any table constraint descriptor |
||||
|
# included in S. |
||||
|
create or replace table t (x int, s date, e date, |
||||
|
period for mytime(s, e), |
||||
|
constraint mytime check (x > 1)); |
||||
|
show create table t; |
||||
|
Table Create Table |
||||
|
t CREATE TABLE `t` ( |
||||
|
`x` int(11) DEFAULT NULL, |
||||
|
`s` date NOT NULL, |
||||
|
`e` date NOT NULL, |
||||
|
PERIOD FOR `mytime` (`s`, `e`), |
||||
|
CONSTRAINT `CONSTRAINT_1` CHECK (`s` < `e`), |
||||
|
CONSTRAINT `mytime` CHECK (`x` > 1) |
||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
||||
|
create or replace database test; |
||||
@ -0,0 +1,73 @@ |
|||||
|
create or replace table t (id int primary key, s date, e date, |
||||
|
period for mytime(s,e)); |
||||
|
show create table t; |
||||
|
create or replace table t (id int primary key, s timestamp(6), e timestamp(6), |
||||
|
period for mytime(s,e)); |
||||
|
show create table t; |
||||
|
|
||||
|
--echo # SQL16, Part 2, 11.3 <table definition>, Syntax Rules, 2)a) |
||||
|
--echo # 2) If a <table period definition> TPD is specified, then: |
||||
|
--echo # a) <table scope> shall not be specified. |
||||
|
--error ER_PERIOD_TEMPORARY_NOT_ALLOWED |
||||
|
create or replace temporary table t (s date, e date, period for mytime(s,e)); |
||||
|
|
||||
|
--echo # SQL16, Part 2, 11.3 <table definition>, Syntax Rules, 2)e)iii) |
||||
|
--echo # The <data type or domain name> contained in CD1 is either DATE or a |
||||
|
--echo # timestamp type and it is equivalent to the <data type or domain name> |
||||
|
--echo # contained in CD2. |
||||
|
--error ER_PERIOD_TYPES_MISMATCH |
||||
|
create or replace table t (id int primary key, s datetime, e date, |
||||
|
period for mytime(s,e)); |
||||
|
--error ER_PERIOD_TYPES_MISMATCH |
||||
|
create or replace table t (s timestamp(2), e timestamp(6), |
||||
|
period for mytime(s,e)); |
||||
|
--error ER_WRONG_FIELD_SPEC |
||||
|
create or replace table t (id int primary key, s int, e date, |
||||
|
period for mytime(s,e)); |
||||
|
--error ER_BAD_FIELD_ERROR |
||||
|
create or replace table t (id int primary key, s date, e date, |
||||
|
period for mytime(s,x)); |
||||
|
--error ER_MORE_THAN_ONE_PERIOD |
||||
|
create or replace table t (id int primary key, s date, e date, |
||||
|
period for mytime(s,e), |
||||
|
period for mytime2(s,e)); |
||||
|
|
||||
|
--echo # SQL16, Part 2, 11.3 <table definition>, Syntax Rules, 2)d) |
||||
|
--echo # No <column name> in any <column definition> shall be equivalent to PN. |
||||
|
--error ER_DUP_FIELDNAME |
||||
|
create or replace table t (mytime int, s date, e date, |
||||
|
period for mytime(s,e)); |
||||
|
|
||||
|
--echo # SQL16, Part 2, 11.3 <table definition>, Syntax Rules, 2)e)v)2)A) |
||||
|
--echo # Neither CD1 nor CD2 shall contain an <identity column specification>, a |
||||
|
--echo # <generation clause>, a <system time period start column specification>, |
||||
|
--echo # or a <system time period end column specification>. |
||||
|
--error ER_PERIOD_FIELD_WRONG_ATTRIBUTES |
||||
|
create or replace table t (id int primary key, |
||||
|
s date, |
||||
|
e date generated always as (s+1), |
||||
|
period for mytime(s,e)); |
||||
|
|
||||
|
--error ER_PERIOD_FIELD_WRONG_ATTRIBUTES |
||||
|
create or replace table t (id int primary key, |
||||
|
s date, |
||||
|
e date as (s+1) VIRTUAL, |
||||
|
period for mytime(s,e)); |
||||
|
|
||||
|
--error ER_PERIOD_FIELD_WRONG_ATTRIBUTES |
||||
|
create or replace table t (id int primary key, s timestamp(6), e timestamp(6), |
||||
|
st timestamp(6) as row start, |
||||
|
en timestamp(6) as row end, |
||||
|
period for system_time (st, en), |
||||
|
period for mytime(st,e)) with system versioning; |
||||
|
|
||||
|
--echo # SQL16, Part 2, 11.3 <table definition>, Syntax Rules, 2) |
||||
|
--echo # Let IDCN be an implementation-dependent <constraint name> that is not |
||||
|
--echo # equivalent to the <constraint name> of any table constraint descriptor |
||||
|
--echo # included in S. |
||||
|
create or replace table t (x int, s date, e date, |
||||
|
period for mytime(s, e), |
||||
|
constraint mytime check (x > 1)); |
||||
|
show create table t; |
||||
|
|
||||
|
create or replace database test; |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue