summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
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/unireg.cc
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/unireg.cc')
-rw-r--r--sql/unireg.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 2aa46131efb..79403ff339d 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -147,12 +147,6 @@ bool has_extra2_field_flags(List<Create_field> &create_fields)
return false;
}
-static size_t extra2_str_size(size_t len)
-{
- return (len > 255 ? 3 : 1) + len;
-}
-
-
static uint gis_field_options_image(uchar *buff,
List<Create_field> &create_fields)
{
@@ -258,6 +252,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
+ extra2_str_size(create_info->period_info.constr->name.length)
+ 2 * frm_fieldno_size
: 0;
+ size_t without_overlaps_len= frm_keyno_size * (create_info->period_info.unique_keys + 1);
uint e_unique_hash_extra_parts= 0;
uchar fileinfo[FRM_HEADER_SIZE],forminfo[FRM_FORMINFO_SIZE];
const partition_info *part_info= IF_PARTITIONING(thd->work_part_info, 0);
@@ -390,7 +385,8 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
if (create_info->period_info.name)
{
- extra2_size+= 1 + extra2_str_size(period_info_len);
+ extra2_size+= 2 + extra2_str_size(period_info_len)
+ + extra2_str_size(without_overlaps_len);
}
bool has_extra2_field_flags_= has_extra2_field_flags(create_fields);
@@ -485,6 +481,19 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
store_frm_fieldno(pos, get_fieldno_by_name(create_info, create_fields,
create_info->period_info.period.end));
pos+= frm_fieldno_size;
+
+ *pos++= EXTRA2_PERIOD_WITHOUT_OVERLAPS;
+ pos= extra2_write_len(pos, without_overlaps_len);
+ store_frm_keyno(pos, create_info->period_info.unique_keys);
+ pos+= frm_keyno_size;
+ for (uint key= 0; key < keys; key++)
+ {
+ if (key_info[key].without_overlaps)
+ {
+ store_frm_keyno(pos, key);
+ pos+= frm_keyno_size;
+ }
+ }
}
if (create_info->versioned())