[MDEV-17122] Multi-update/Multi-delete for portion of time Created: 2018-09-03  Updated: 2019-06-21

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Nikita Malyavin Assignee: Nikita Malyavin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
PartOf
is part of MDEV-18928 Application-time periods support (pha... Closed

 Description   

create or replace table t (id int, s date, e date, period for apptime(s, e));
insert into t values (1, '1999-01-01', '2018-12-12');
create or replace table t1 (z int);
insert into t1 values (1);
update t for portion of apptime from '2000-01-01' to '2018-01-01', set t.id= t.id + 5;
select * from t;

Expected result:

+------+------------+------------+
| id   | s          | e          |
+------+------------+------------+
|    6 | 2000-01-01 | 2018-01-01 |
|    1 | 1999-01-01 | 2000-01-01 |
|    1 | 2018-01-01 | 2018-12-12 |
+------+------------+------------+

create or replace table t (id int, s date, e date, period for apptime(s,e));
insert into t values(1, '1999-01-01', '2018-12-12');
insert into t values(2, '1999-01-01', '2017-01-01');
insert into t values(3, '2002-01-01', '2017-01-01');
insert into t values(4, '1998-01-01', '2018-12-12');
insert into t values(5, '1997-01-01', '2015-01-01');
insert into t values(6, '2016-01-01', '2020-01-01');
create or replace table t1 (id int, s date, e date, period for apptime(s,e));
insert t1 select * from t;
select * from t;
delete t, t1 from t for portion of apptime from '2000-01-01' to '2018-01-01', t1;
select * from t;

Expected result:

delete from t for portion of apptime from '2000-01-01' to '2018-01-01';
+------+------------+------------+
| id   | s          | e          |
+------+------------+------------+
|    1 | 1999-01-01 | 2000-01-01 |
|    2 | 1999-01-01 | 2000-01-01 |
|    4 | 1998-01-01 | 2000-01-01 |
|    5 | 1997-01-01 | 2000-01-01 |
|    6 | 2018-01-01 | 2020-01-01 |
|    1 | 2018-01-01 | 2018-12-12 |
|    4 | 2018-01-01 | 2018-12-12 |
+------+------------+------------+



 Comments   
Comment by Nikita Malyavin [ 2018-09-04 ]

It is possible, that there's no general solution. This needs some investigation

Comment by Nikita Malyavin [ 2019-06-21 ]

This is not the SQL Standard feature

Generated at Thu Feb 08 08:34:04 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.