1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

PARTITION BY SYSTEM_TIME INTERVAL ...

Lots of changes:
* calculate the current history partition in ::external_lock(),
  not in ::write_row() or ::update_row()
* remove dynamically collected per-partition row_end stats
* no full table scan in open_table_from_share to calculate these
  stats, no manual MDL/thr_locks in open_table_from_share
* no shared stats in TABLE_SHARE = no mutexes or condition waits when
  calculating current history partition
* always compare timestamps, don't convert them to MYSQL_TIME
  (avoid DST ambiguity, and it's faster too)
* correct interval handling, 1 month = 1 month, not 30 * 24 * 3600 seconds
* save/restore first partition start time, and count intervals from there
* only allow to drop first partitions if INTERVAL
* when adding new history partitions, split the data in the last history
  parition, if it was overflowed
* show partition boundaries in INFORMATION_SCHEMA.PARTITIONS
This commit is contained in:
Sergei Golubchik
2018-02-21 15:16:19 +01:00
parent 7961bc4b89
commit e36c5ec0a5
16 changed files with 463 additions and 974 deletions

View File

@ -7196,11 +7196,8 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table,
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
static int
get_partition_column_description(THD *thd,
partition_info *part_info,
part_elem_value *list_value,
String &tmp_str)
static int get_partition_column_description(THD *thd, partition_info *part_info,
part_elem_value *list_value, String &tmp_str)
{
uint num_elements= part_info->part_field_list.elements;
uint i;
@ -7305,8 +7302,7 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
table->field[7]->store(tmp_res.ptr(), tmp_res.length(), cs);
break;
case VERSIONING_PARTITION:
tmp_res.length(0);
tmp_res.append(STRING_WITH_LEN("SYSTEM_TIME"));
table->field[7]->store(STRING_WITH_LEN("SYSTEM_TIME"), cs);
break;
default:
DBUG_ASSERT(0);
@ -7374,13 +7370,9 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
List_iterator<part_elem_value> list_val_it(part_elem->list_val_list);
part_elem_value *list_value= list_val_it++;
tmp_str.length(0);
if (get_partition_column_description(thd,
part_info,
list_value,
if (get_partition_column_description(thd, part_info, list_value,
tmp_str))
{
DBUG_RETURN(1);
}
table->field[11]->store(tmp_str.ptr(), tmp_str.length(), cs);
}
else
@ -7411,13 +7403,9 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
{
if (part_info->part_field_list.elements > 1U)
tmp_str.append(STRING_WITH_LEN("("));
if (get_partition_column_description(thd,
part_info,
list_value,
if (get_partition_column_description(thd, part_info, list_value,
tmp_str))
{
DBUG_RETURN(1);
}
if (part_info->part_field_list.elements > 1U)
tmp_str.append(")");
}
@ -7435,6 +7423,19 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
table->field[11]->store(tmp_str.ptr(), tmp_str.length(), cs);
table->field[11]->set_notnull();
}
else if (part_info->part_type == VERSIONING_PARTITION)
{
if (part_elem == part_info->vers_info->now_part)
{
table->field[11]->store(STRING_WITH_LEN("CURRENT"), cs);
table->field[11]->set_notnull();
}
else if (part_info->vers_info->interval.is_set())
{
table->field[11]->store_timestamp((my_time_t)part_elem->range_value, 0);
table->field[11]->set_notnull();
}
}
if (part_elem->subpartitions.elements)
{