summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2020-02-25 14:14:17 +0300
committerAleksey Midenkov <midenok@gmail.com>2020-02-25 15:43:23 +0300
commitf707c83fff4fa3f5291684e6226542fdb75bbdeb (patch)
tree1a554d5f3f27e38a7a2d78819207ddd0c6ea8514 /sql/sql_partition.cc
parentc12609dd9ed65b245cee2e8b379b1e1f15aadf6a (diff)
downloadmariadb-git-f707c83fff4fa3f5291684e6226542fdb75bbdeb.tar.gz
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.
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 5885e3715bf..f8ae91114f0 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -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