mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +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:
committed by
Sergei Golubchik
parent
0515577d12
commit
259fb1cbed
@ -2253,6 +2253,14 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list,
|
||||
|
||||
}
|
||||
|
||||
if (period.name)
|
||||
{
|
||||
append_period(thd, packet,
|
||||
period.start_field(share)->field_name,
|
||||
period.end_field(share)->field_name,
|
||||
period.name, true);
|
||||
}
|
||||
|
||||
key_info= table->s->key_info;
|
||||
primary_key= share->primary_key;
|
||||
|
||||
@ -2287,7 +2295,11 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list,
|
||||
|
||||
packet->append(STRING_WITH_LEN(" ("));
|
||||
|
||||
for (uint j=0 ; j < key_info->user_defined_key_parts ; j++,key_part++)
|
||||
uint key_parts= key_info->user_defined_key_parts;
|
||||
if (key_info->without_overlaps)
|
||||
key_parts-= 2;
|
||||
|
||||
for (uint j=0 ; j < key_parts ; j++,key_part++)
|
||||
{
|
||||
Field *field= key_part->field;
|
||||
if (field->invisible > INVISIBLE_USER)
|
||||
@ -2307,6 +2319,14 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list,
|
||||
key_part->field->charset()->mbmaxlen);
|
||||
}
|
||||
}
|
||||
|
||||
if (key_info->without_overlaps)
|
||||
{
|
||||
packet->append(',');
|
||||
append_identifier(thd, packet, &share->period.name);
|
||||
packet->append(STRING_WITH_LEN(" WITHOUT OVERLAPS"));
|
||||
}
|
||||
|
||||
packet->append(')');
|
||||
store_key_options(thd, packet, table, &table->key_info[i]);
|
||||
if (key_info->parser)
|
||||
@ -2340,15 +2360,6 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list,
|
||||
}
|
||||
}
|
||||
|
||||
if (period.name)
|
||||
{
|
||||
append_period(thd, packet,
|
||||
period.start_field(share)->field_name,
|
||||
period.end_field(share)->field_name,
|
||||
period.name, true);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Get possible foreign key definitions stored in InnoDB and append them
|
||||
to the CREATE TABLE statement
|
||||
|
Reference in New Issue
Block a user