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

MDEV-17554 Auto-create new partition for system versioned tables with history partitioned by INTERVAL/LIMIT

When there are E empty partitions left, auto-create N new empty
partitions for SYSTEM_TIME partitioning rotated by INTERVAL/LIMIT and
marked by AUTO_INCREMENT keyword. Syntax change: AUTO_INCREMENT
keyword (or shorter AUTO may be used instead) after LIMIT/INTERVAL
clause.

CREATE OR REPLACE TABLE t (x INT) WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME LIMIT 100000 AUTO_INCREMENT;

CREATE OR REPLACE TABLE t (x INT) WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 WEEK AUTO_INCREMENT;

The current revision implements hard-coded values of 1 for E and N. As
well as auto-creation threshold MinInterval = 1 hour, MinLimit = 1000.

The name for newly added partition will be first chosen as "pX", where
X is partition number and "p" is hard-coded name prefix. If this name
is already occupied, the X will be incremented until the resulting
name will be free to use.

ALTER TABLE ADD PARTITION is now always fast. If there some history
partition overflow occurs manual ALTER TABLE REBUILD PARTITION is
needed.
This commit is contained in:
Aleksey Midenkov
2020-02-25 14:14:17 +03:00
parent c12609dd9e
commit f707c83fff
14 changed files with 599 additions and 83 deletions

View File

@ -2584,11 +2584,15 @@ char *generate_partition_syntax(THD *thd, partition_info *part_info,
err+= str.append(ctime, ctime_len);
err+= str.append('\'');
}
if (vers_info->auto_inc)
err+= str.append(STRING_WITH_LEN(" AUTO_INCREMENT"));
}
if (vers_info->limit)
else if (vers_info->limit)
{
err+= str.append(STRING_WITH_LEN("LIMIT "));
err+= str.append_ulonglong(vers_info->limit);
if (vers_info->auto_inc)
err+= str.append(STRING_WITH_LEN(" AUTO_INCREMENT"));
}
}
else if (part_info->part_expr)
@ -5313,12 +5317,6 @@ that are reorganised.
now_part= el;
}
}
if (*fast_alter_table && tab_part_info->vers_info->interval.is_set())
{
partition_element *hist_part= tab_part_info->vers_info->hist_part;
if (hist_part->range_value <= thd->query_start())
hist_part->part_state= PART_CHANGED;
}
}
List_iterator<partition_element> alt_it(alt_part_info->partitions);
uint part_count= 0;
@ -7218,7 +7216,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
}
else if ((alter_info->partition_flags & ALTER_PARTITION_ADD) &&
(part_info->part_type == RANGE_PARTITION ||
part_info->part_type == LIST_PARTITION))
part_info->part_type == LIST_PARTITION ||
part_info->part_type == VERSIONING_PARTITION))
{
/*
ADD RANGE/LIST PARTITIONS