1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-16978 Application-time periods: WITHOUT OVERLAPS

* The overlaps check is implemented on a handler level per row command.
  It creates a separate cursor (actually, another handler instance) and
  caches it inside the original handler, when ha_update_row or
  ha_insert_row is issued. Cursor closes on unlocking the handler.

* Containing the same key in index means unique constraint violation
  even in usual terms. So we fetch left and right neighbours and check
  that they have same key prefix, excluding from the key only the period part.
  If it doesnt match, then there's no such neighbour, and the check passes.
  Otherwise, we check if this neighbour intersects with the considered key.

* The check does not introduce new error and fails with ER_DUPP_KEY error.
  This might break REPLACE workflow and should be fixed separately
This commit is contained in:
Nikita Malyavin
2019-11-26 19:22:04 +10:00
committed by Sergei Golubchik
parent 0515577d12
commit 259fb1cbed
20 changed files with 826 additions and 76 deletions

View File

@ -1998,11 +1998,13 @@ struct Table_period_info: Sql_alloc
{
Table_period_info() :
create_if_not_exists(false),
constr(NULL) {}
constr(NULL),
unique_keys(0) {}
Table_period_info(const char *name_arg, size_t size) :
name(name_arg, size),
create_if_not_exists(false),
constr(NULL) {}
constr(NULL),
unique_keys(0){}
Lex_ident name;
@ -2018,6 +2020,7 @@ struct Table_period_info: Sql_alloc
start_end_t period;
bool create_if_not_exists;
Virtual_column_info *constr;
uint unique_keys;
bool is_set() const
{
@ -4677,6 +4680,8 @@ private:
int check_duplicate_long_entries(const uchar *new_rec);
int check_duplicate_long_entries_update(const uchar *new_rec);
int check_duplicate_long_entry_key(const uchar *new_rec, uint key_no);
/** PRIMARY KEY/UNIQUE WITHOUT OVERLAPS check */
int ha_check_overlaps(const uchar *old_data, const uchar* new_data);
protected:
/*