summaryrefslogtreecommitdiff
path: root/sql/table.h
diff options
context:
space:
mode:
authorNikita Malyavin <nikitamalyavin@gmail.com>2019-11-26 19:22:04 +1000
committerSergei Golubchik <serg@mariadb.org>2020-03-31 17:42:34 +0200
commit259fb1cbed4470636ff35df83e1c4ca966bb8159 (patch)
treeca82142d15f878ea127f8dbde783cb91a1e13652 /sql/table.h
parent0515577d128318e1b62511846d88d0c56226168d (diff)
downloadmariadb-git-259fb1cbed4470636ff35df83e1c4ca966bb8159.tar.gz
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
Diffstat (limited to 'sql/table.h')
-rw-r--r--sql/table.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/sql/table.h b/sql/table.h
index 2ccc59f9282..310ffb8c704 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -803,7 +803,7 @@ struct TABLE_SHARE
#endif
/**
- System versioning support.
+ System versioning and application-time periods support.
*/
struct period_info_t
{
@@ -811,6 +811,7 @@ struct TABLE_SHARE
uint16 end_fieldno;
Lex_ident name;
Lex_ident constr_name;
+ uint unique_keys;
Field *start_field(TABLE_SHARE *s) const
{
return s->field[start_fieldno];
@@ -1632,7 +1633,7 @@ public:
int insert_portion_of_time(THD *thd, const vers_select_conds_t &period_conds,
ha_rows *rows_inserted);
bool vers_check_update(List<Item> &items);
-
+ static bool check_period_overlaps(const KEY &key, const uchar *lhs, const uchar *rhs);
int delete_row();
void vers_update_fields();
void vers_update_end();
@@ -1770,10 +1771,18 @@ class IS_table_read_plan;
/** number of bytes used by field positional indexes in frm */
constexpr uint frm_fieldno_size= 2;
+/** number of bytes used by key position number in frm */
+constexpr uint frm_keyno_size= 2;
static inline uint16 read_frm_fieldno(const uchar *data)
{ return uint2korr(data); }
static inline void store_frm_fieldno(uchar *data, uint16 fieldno)
{ int2store(data, fieldno); }
+static inline uint16 read_frm_keyno(const uchar *data)
+{ return uint2korr(data); }
+static inline void store_frm_keyno(uchar *data, uint16 fieldno)
+{ int2store(data, fieldno); }
+static inline size_t extra2_str_size(size_t len)
+{ return (len > 255 ? 3 : 1) + len; }
class select_unit;
class TMP_TABLE_PARAM;