[MDEV-26044] FOR SYSTEM_TIME HISTORY syntax extension Created: 2021-06-29  Updated: 2021-06-29

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

Type: Task Priority: Major
Reporter: Aleksey Midenkov Assignee: Aleksey Midenkov
Resolution: Unresolved Votes: 0
Labels: None


 Description   

If you find this useful please vote.

FOR SYSTEM_TIME HISTORY is similar to FOR SYSTEM_TIME ALL except the current data is not included.

Currently there is no obvious way to select all history. The workarounds are:

SELECT *, row_start, row_end FOR SYSTEM_TIME ALL WHERE row_end < '2038-01-01';

or even

set @@session.time_zone='+00:00';
set @MAX_TIMESTAMP= TIMESTAMP'2038-01-19 03:14:07.999999';
SELECT *, row_start, row_end FROM t1 FOR SYSTEM_TIME ALL WHERE row_end < @MAX_TIMESTAMP;

Which is non-friendly because it depends on some constant knowledge which is about to change in the future.

The another way is

SELECT *, row_start, row_end FROM t1 FOR SYSTEM_TIME ALL WHERE row_end < NOW(6);

Which is somehow non-unversal as it doesn't work correctly with modified current_timestamp. This is not user-friendly as well because of the need to type additional WHERE-condition (row_end is the arbitrary name specific to the table).

The suggested way for doing that is:

SELECT *, row_start, row_end FROM t1 FOR SYSTEM_TIME HISTORY;

The use-case for such kind of query might be to search whole history for the certain criteria (by specifying WHERE conditions, etc).


Generated at Thu Feb 08 09:42:19 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.