Commit 5c760d95 authored by Aleksey Midenkov's avatar Aleksey Midenkov

Parser: default SYSTEM_TIME ALL for DELETE HISTORY

parent 36888cc5
......@@ -7,7 +7,7 @@ update t set a=2;
set @test = 'correct';
create trigger trg_before before delete on t for each row set @test = 'incorrect';
create trigger trg_after after delete on t for each row set @test = 'incorrect';
delete history from t before system_time now(6);
delete history from t;
select @test from t;
@test
correct
......@@ -29,7 +29,7 @@ a
11
22
2
prepare stmt from 'delete history from t before system_time timestamp now(6)';
prepare stmt from 'delete history from t';
execute stmt;
drop prepare stmt;
select * from t for system_time all;
......@@ -52,20 +52,20 @@ engine myisam
partition by system_time (
partition p0 history,
partition pn current);
delete history from t before system_time current_timestamp;
delete history from t;
ERROR 42000: The used command is not allowed with this MariaDB version
create or replace table t (i int) with system versioning;
delete history from t before system_time now();
delete history from t;
create or replace view v as select * from t;
delete history from v before system_time now();
delete history from v;
ERROR HY000: DELETE HISTORY from VIEW is prohibited
create or replace table t (i int);
delete history from t before system_time now();
delete history from t;
ERROR HY000: Table `t` is not system-versioned
create or replace view v as select * from t;
delete history from v before system_time now();
delete history from v;
ERROR HY000: DELETE HISTORY from VIEW is prohibited
prepare stmt from 'delete history from t before system_time now()';
prepare stmt from 'delete history from t';
ERROR HY000: Table `t` is not system-versioned
drop table t;
drop view v;
......@@ -11,7 +11,7 @@ update t set a=2;
set @test = 'correct';
create trigger trg_before before delete on t for each row set @test = 'incorrect';
create trigger trg_after after delete on t for each row set @test = 'incorrect';
delete history from t before system_time now(6);
delete history from t;
select @test from t;
drop table t;
......@@ -25,7 +25,7 @@ update t set a=22 where a=2;
select * from t for system_time all;
delete history from t before system_time timestamp @ts1;
select * from t for system_time all;
prepare stmt from 'delete history from t before system_time timestamp now(6)';
prepare stmt from 'delete history from t';
execute stmt; drop prepare stmt;
select * from t for system_time all;
delete from t;
......@@ -51,22 +51,22 @@ partition by system_time (
partition pn current);
--error ER_NOT_ALLOWED_COMMAND
delete history from t before system_time current_timestamp;
delete history from t;
create or replace table t (i int) with system versioning;
delete history from t before system_time now();
delete history from t;
create or replace view v as select * from t;
--error ER_VERS_TRUNCATE_VIEW
delete history from v before system_time now();
delete history from v;
create or replace table t (i int);
--error ER_VERS_NOT_VERSIONED
delete history from t before system_time now();
delete history from t;
create or replace view v as select * from t;
--error ER_VERS_TRUNCATE_VIEW
delete history from v before system_time now();
delete history from v;
--error ER_VERS_NOT_VERSIONED
prepare stmt from 'delete history from t before system_time now()';
prepare stmt from 'delete history from t';
drop table t;
drop view v;
......@@ -13406,12 +13406,21 @@ delete:
delete_part2
;
opt_delete_system_time:
/* empty */
{
Lex->vers_conditions.init(SYSTEM_TIME_ALL);
}
| BEFORE_SYM SYSTEM_TIME_SYM opt_trans_or_timestamp simple_expr
{
Lex->vers_conditions.init(SYSTEM_TIME_BEFORE, $3, $4);
}
;
delete_part2:
opt_delete_options single_multi {}
| HISTORY_SYM delete_single_table
BEFORE_SYM SYSTEM_TIME_SYM opt_trans_or_timestamp simple_expr
| HISTORY_SYM delete_single_table opt_delete_system_time
{
Lex->vers_conditions.init(SYSTEM_TIME_BEFORE, $5, $6);
Lex->last_table()->vers_conditions= Lex->vers_conditions;
}
;
......
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