mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
SQL: ADD/DROP SYSTEM VERSIONING syntax for ALTER TABLE
This commit is contained in:
parent
67907c699c
commit
f9b8c908a0
6 changed files with 63 additions and 87 deletions
|
@ -6,9 +6,9 @@ Table Create Table
|
|||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
ERROR HY000: Wrong parameters for `t`: table is not versioned
|
||||
alter table t with system versioning;
|
||||
alter table t add system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
|
@ -17,7 +17,7 @@ t CREATE TABLE `t` (
|
|||
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
|
@ -27,26 +27,26 @@ alter table t
|
|||
add column trx_start bigint(20) unsigned generated always as row start,
|
||||
add column trx_end bigint(20) unsigned generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
ERROR HY000: `trx_start` must be of type `TIMESTAMP(6)` for versioned table `t`
|
||||
alter table t
|
||||
add column trx_start timestamp generated always as row start,
|
||||
add column trx_end timestamp generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
ERROR HY000: `trx_start` must be of type `TIMESTAMP(6)` for versioned table `t`
|
||||
alter table t
|
||||
add column trx_start timestamp(6) not null generated always as row start,
|
||||
add column trx_end timestamp(6) not null generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'generated always as row start,
|
||||
add column trx_end timestamp(6) not null generate' at line 2
|
||||
alter table t
|
||||
add column trx_start timestamp(6) generated always as row start,
|
||||
add column trx_end timestamp(6) generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
|
@ -56,13 +56,13 @@ t CREATE TABLE `t` (
|
|||
PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
alter table t drop column trx_start, drop column trx_end;
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t with system versioning;
|
||||
alter table t add system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
|
@ -160,7 +160,7 @@ create or replace table t(
|
|||
a int
|
||||
);
|
||||
insert into t values(1);
|
||||
alter table t with system versioning;
|
||||
alter table t add system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
|
@ -211,7 +211,7 @@ a b
|
|||
3 NULL
|
||||
2 NULL
|
||||
1 NULL
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
select * from t;
|
||||
a b
|
||||
3 NULL
|
||||
|
@ -226,7 +226,7 @@ alter table t modify a int with system versioning;
|
|||
ERROR HY000: Wrong parameters for `t`: table is not versioned
|
||||
alter table t modify a int without system versioning;
|
||||
ERROR HY000: Wrong parameters for `t`: table is not versioned
|
||||
alter table t with system versioning;
|
||||
alter table t add system versioning;
|
||||
alter table t modify a int without system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
|
@ -333,7 +333,7 @@ alter table t
|
|||
add column trx_start timestamp(6) generated always as row start,
|
||||
add column trx_end timestamp(6) generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
ERROR HY000: `trx_start` must be of type `BIGINT(20) UNSIGNED` for versioned table `t`
|
||||
call verify_vtq;
|
||||
No A B C D
|
||||
|
@ -341,7 +341,7 @@ alter table t
|
|||
add column trx_start bigint(20) unsigned generated always as row start,
|
||||
add column trx_end bigint(20) unsigned generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
call verify_vtq;
|
||||
No A B C D
|
||||
1 1 1 1 1
|
||||
|
@ -356,10 +356,10 @@ t CREATE TABLE `t` (
|
|||
alter table t drop column trx_start, drop column trx_end;
|
||||
call verify_vtq;
|
||||
No A B C D
|
||||
alter table t without system versioning, algorithm=copy;
|
||||
alter table t drop system versioning, algorithm=copy;
|
||||
call verify_vtq;
|
||||
No A B C D
|
||||
alter table t with system versioning, algorithm=copy;
|
||||
alter table t add system versioning, algorithm=copy;
|
||||
call verify_vtq;
|
||||
No A B C D
|
||||
1 1 1 1 1
|
||||
|
@ -409,10 +409,10 @@ a
|
|||
1
|
||||
call verify_vtq;
|
||||
No A B C D
|
||||
alter table t without system versioning, algorithm=inplace;
|
||||
alter table t drop system versioning, algorithm=inplace;
|
||||
call verify_vtq;
|
||||
No A B C D
|
||||
alter table t with system versioning, algorithm=inplace;
|
||||
alter table t add system versioning, algorithm=inplace;
|
||||
call verify_vtq;
|
||||
No A B C D
|
||||
1 1 1 1 1
|
||||
|
@ -460,7 +460,7 @@ select * from t for system_time all;
|
|||
a
|
||||
1
|
||||
2
|
||||
alter table t without system versioning, algorithm=copy;
|
||||
alter table t drop system versioning, algorithm=copy;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
|
@ -554,17 +554,17 @@ period for system_time(sys_trx_start, sys_trx_end)
|
|||
) with system versioning;
|
||||
select * from t;
|
||||
a sys_trx_start sys_trx_end
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
ERROR HY000: System versioning field 'sys_trx_start' is not hidden
|
||||
alter table t drop column sys_trx_start;
|
||||
select * from t;
|
||||
a sys_trx_end
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
ERROR HY000: System versioning field 'sys_trx_end' is not hidden
|
||||
alter table t drop column sys_trx_end;
|
||||
select * from t;
|
||||
a
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
|
|
|
@ -270,10 +270,6 @@ 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'
|
||||
create table t(
|
||||
a11 int
|
||||
) without system versioning;
|
||||
ERROR HY000: Wrong parameters for `t`: not allowed '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;
|
||||
|
|
|
@ -3,12 +3,12 @@ create table t(
|
|||
);
|
||||
show create table t;
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
|
||||
alter table t with system versioning;
|
||||
alter table t add system versioning;
|
||||
show create table t;
|
||||
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
show create table t;
|
||||
|
||||
--error ER_VERS_FIELD_WRONG_TYPE
|
||||
|
@ -16,34 +16,34 @@ alter table t
|
|||
add column trx_start bigint(20) unsigned generated always as row start,
|
||||
add column trx_end bigint(20) unsigned generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
|
||||
--error ER_VERS_FIELD_WRONG_TYPE
|
||||
alter table t
|
||||
add column trx_start timestamp generated always as row start,
|
||||
add column trx_end timestamp generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t
|
||||
add column trx_start timestamp(6) not null generated always as row start,
|
||||
add column trx_end timestamp(6) not null generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
|
||||
alter table t
|
||||
add column trx_start timestamp(6) generated always as row start,
|
||||
add column trx_end timestamp(6) generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
show create table t;
|
||||
|
||||
alter table t drop column trx_start, drop column trx_end;
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
show create table t;
|
||||
|
||||
alter table t with system versioning;
|
||||
alter table t add system versioning;
|
||||
show create table t;
|
||||
|
||||
alter table t add column b int;
|
||||
|
@ -93,7 +93,7 @@ create or replace table t(
|
|||
a int
|
||||
);
|
||||
insert into t values(1);
|
||||
alter table t with system versioning;
|
||||
alter table t add system versioning;
|
||||
show create table t;
|
||||
insert into t values(2);
|
||||
select * from t for system_time all;
|
||||
|
@ -109,7 +109,7 @@ show create table t;
|
|||
select * from t;
|
||||
select * from t for system_time all;
|
||||
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
select * from t;
|
||||
show create table t;
|
||||
|
||||
|
@ -118,7 +118,7 @@ alter table t modify a int with system versioning;
|
|||
--error ER_VERS_WRONG_PARAMS
|
||||
alter table t modify a int without system versioning;
|
||||
|
||||
alter table t with system versioning;
|
||||
alter table t add system versioning;
|
||||
|
||||
alter table t modify a int without system versioning;
|
||||
show create table t;
|
||||
|
@ -139,23 +139,23 @@ alter table t
|
|||
add column trx_start timestamp(6) generated always as row start,
|
||||
add column trx_end timestamp(6) generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
|
||||
call verify_vtq;
|
||||
alter table t
|
||||
add column trx_start bigint(20) unsigned generated always as row start,
|
||||
add column trx_end bigint(20) unsigned generated always as row end,
|
||||
add period for system_time(trx_start, trx_end),
|
||||
with system versioning;
|
||||
add system versioning;
|
||||
call verify_vtq;
|
||||
|
||||
show create table t;
|
||||
alter table t drop column trx_start, drop column trx_end;
|
||||
|
||||
call verify_vtq;
|
||||
alter table t without system versioning, algorithm=copy;
|
||||
alter table t drop system versioning, algorithm=copy;
|
||||
call verify_vtq;
|
||||
alter table t with system versioning, algorithm=copy;
|
||||
alter table t add system versioning, algorithm=copy;
|
||||
call verify_vtq;
|
||||
show create table t;
|
||||
|
||||
|
@ -173,9 +173,9 @@ show create table t;
|
|||
select * from t for system_time all;
|
||||
call verify_vtq;
|
||||
|
||||
alter table t without system versioning, algorithm=inplace;
|
||||
alter table t drop system versioning, algorithm=inplace;
|
||||
call verify_vtq;
|
||||
alter table t with system versioning, algorithm=inplace;
|
||||
alter table t add system versioning, algorithm=inplace;
|
||||
call verify_vtq;
|
||||
show create table t;
|
||||
|
||||
|
@ -192,7 +192,7 @@ alter table t drop column b, algorithm=inplace;
|
|||
show create table t;
|
||||
select * from t for system_time all;
|
||||
|
||||
alter table t without system versioning, algorithm=copy;
|
||||
alter table t drop system versioning, algorithm=copy;
|
||||
show create table t;
|
||||
|
||||
create or replace table t (a int) with system versioning engine=innodb;
|
||||
|
@ -254,16 +254,16 @@ create or replace table t (
|
|||
select * from t;
|
||||
|
||||
--error ER_VERS_SYS_FIELD_NOT_HIDDEN
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
alter table t drop column sys_trx_start;
|
||||
select * from t;
|
||||
|
||||
--error ER_VERS_SYS_FIELD_NOT_HIDDEN
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
alter table t drop column sys_trx_end;
|
||||
select * from t;
|
||||
|
||||
alter table t without system versioning;
|
||||
alter table t drop system versioning;
|
||||
show create table t;
|
||||
|
||||
set versioning_alter_history = DROP;
|
||||
|
|
|
@ -194,11 +194,6 @@ create or replace table t1 (
|
|||
|
||||
# table with/without system versioning
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create table t(
|
||||
a11 int
|
||||
) without system versioning;
|
||||
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
create temporary table tmp with system versioning select * from t1;
|
||||
|
||||
|
|
|
@ -6772,6 +6772,8 @@ bool Vers_parse_info::check_and_fix_implicit(
|
|||
HA_CREATE_INFO *create_info,
|
||||
const char* table_name)
|
||||
{
|
||||
DBUG_ASSERT(!without_system_versioning);
|
||||
|
||||
SELECT_LEX &slex= thd->lex->select_lex;
|
||||
int vers_tables= 0;
|
||||
bool from_select= slex.item_list.elements ? true : false;
|
||||
|
@ -6818,13 +6820,6 @@ bool Vers_parse_info::check_and_fix_implicit(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (without_system_versioning)
|
||||
{
|
||||
my_error_as(ER_VERS_WRONG_PARAMS, ER_NOT_ALLOWED, MYF(0), table_name,
|
||||
"WITHOUT SYSTEM VERSIONING");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((system_time.start || system_time.end || as_row.start || as_row.end) &&
|
||||
!with_system_versioning)
|
||||
{
|
||||
|
|
|
@ -890,7 +890,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
|||
INTERNAL : Not a real token, lex optimization
|
||||
OPERATOR : SQL operator
|
||||
FUTURE-USE : Reserved for future use
|
||||
32N2439 : Reserver keywords per ISO/IEC PDTR 19075-2,
|
||||
32N2439 : Reserved keywords per ISO/IEC PDTR 19075-2,
|
||||
http://jtc1sc32.org/doc/N2401-2450/32N2439-text_for_ballot-PDTR_19075-2.pdf
|
||||
System Versioned Tables
|
||||
|
||||
|
@ -2539,7 +2539,7 @@ create:
|
|||
sequence_definition()))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
opt_sequence opt_create_sequence_options
|
||||
opt_sequence opt_create_table_options
|
||||
{
|
||||
LEX *lex= thd->lex;
|
||||
|
||||
|
@ -5774,19 +5774,14 @@ create_or_replace:
|
|||
}
|
||||
;
|
||||
|
||||
opt_create_sequence_options:
|
||||
opt_create_table_options:
|
||||
/* empty */
|
||||
| create_table_options
|
||||
;
|
||||
|
||||
opt_create_table_options:
|
||||
/* empty */
|
||||
| create_table_options_versioning
|
||||
;
|
||||
|
||||
alter_table_options:
|
||||
create_table_option_versioning
|
||||
| create_table_option_versioning alter_table_options
|
||||
create_table_options_space_separated:
|
||||
create_table_option
|
||||
| create_table_option create_table_options_space_separated
|
||||
;
|
||||
|
||||
create_table_options:
|
||||
|
@ -5795,12 +5790,6 @@ create_table_options:
|
|||
| create_table_option ',' create_table_options
|
||||
;
|
||||
|
||||
create_table_options_versioning:
|
||||
create_table_option_versioning
|
||||
| create_table_option_versioning create_table_options_versioning
|
||||
| create_table_option_versioning ',' create_table_options_versioning
|
||||
;
|
||||
|
||||
create_table_option:
|
||||
ENGINE_SYM opt_equal storage_engines
|
||||
{
|
||||
|
@ -6045,10 +6034,6 @@ create_table_option:
|
|||
Lex->create_info.used_fields|= HA_CREATE_USED_SEQUENCE;
|
||||
Lex->create_info.sequence= ($3 == HA_CHOICE_YES);
|
||||
}
|
||||
;
|
||||
|
||||
create_table_option_versioning:
|
||||
create_table_option
|
||||
| versioning_option
|
||||
;
|
||||
|
||||
|
@ -6063,10 +6048,6 @@ versioning_option:
|
|||
Lex->vers_get_info().with_system_versioning= true;
|
||||
Lex->create_info.options|= HA_VERSIONED_TABLE;
|
||||
}
|
||||
| WITHOUT SYSTEM VERSIONING_SYM
|
||||
{
|
||||
Lex->vers_get_info().without_system_versioning= true;
|
||||
}
|
||||
;
|
||||
|
||||
default_charset:
|
||||
|
@ -6904,7 +6885,7 @@ asrow_attribute:
|
|||
{
|
||||
LEX *lex=Lex;
|
||||
lex->last_field->flags|= UNIQUE_KEY_FLAG;
|
||||
lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
|
||||
lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
|
||||
}
|
||||
| COMMENT_SYM TEXT_STRING_sys { Lex->last_field->comment= $2; }
|
||||
;
|
||||
|
@ -8060,7 +8041,7 @@ alter_list_item:
|
|||
MYSQL_YYABORT;
|
||||
Lex->alter_info.flags|= Alter_info::ALTER_OPTIONS;
|
||||
}
|
||||
| alter_table_options
|
||||
| create_table_options_space_separated
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
lex->alter_info.flags|= Alter_info::ALTER_OPTIONS;
|
||||
|
@ -8081,6 +8062,15 @@ alter_list_item:
|
|||
}
|
||||
| alter_algorithm_option
|
||||
| alter_lock_option
|
||||
| ADD SYSTEM VERSIONING_SYM
|
||||
{
|
||||
Lex->vers_get_info().with_system_versioning= true;
|
||||
Lex->create_info.options|= HA_VERSIONED_TABLE;
|
||||
}
|
||||
| DROP SYSTEM VERSIONING_SYM
|
||||
{
|
||||
Lex->vers_get_info().without_system_versioning= true;
|
||||
}
|
||||
;
|
||||
|
||||
opt_index_lock_algorithm:
|
||||
|
|
Loading…
Add table
Reference in a new issue