[MDEV-16978] Application period tables: WITHOUT OVERLAPS Created: 2018-08-14  Updated: 2020-04-01  Resolved: 2020-04-01

Status: Closed
Project: MariaDB Server
Component/s: Versioned Tables
Fix Version/s: 10.5.3

Type: Task Priority: Critical
Reporter: Nikita Malyavin Assignee: Nikita Malyavin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-17395 REPLACE/INSERT ODKU: support WITHOUT ... Stalled

 Description   

From sql standard:

<unique constraint definition> ::=
  <unique specification> <left paren> <unique column list> 
  [ <comma> <without overlap specification> ] <right paren>
  | UNIQUE ( VALUE )
<without overlap specification> ::= <application time period name> WITHOUT OVERLAPS

The simplest observed implementation is:
1. Add period start/end to the index at the very end (even after SYSTEM_TIME row_end)
2. On each insert/update, check if there's such a key, with period overlapping the inserting/updating one. `ha_index_*` functions fit this purpose. It is sufficient to fetch a row with `ha_index_read_map` with `HA_READ_KEY_OR_PREV` flag, and fetch another one with `ha_index_next`

Although this check can be done totally on the `sql/` side, the constraint should always be satisfied, so it should be close to engine. It is supposed to be done as `handler::check_overlaps` function called from `ha_write_row` and `ha_update_row`



 Comments   
Comment by Aleksey Midenkov [ 2018-10-16 ]

Review progress

Comment by Nikita Malyavin [ 2019-11-22 ]

Discussion https://lists.launchpad.net/maria-developers/msg11997.html

Comment by Nikita Malyavin [ 2020-01-19 ]

Discussion continues: https://lists.launchpad.net/maria-developers/msg12029.html

Comment by Sergei Golubchik [ 2020-03-19 ]

looks ok as of d3f7b77e3fd

but mroonga/wrapper tests fail

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