pgsql: Implement ALTER TABLE ... SPLIT PARTITION ... command
pgsql: Implement ALTER TABLE ... SPLIT PARTITION ... command
От:
Alexander Korotkov <akorotkov@postgresql.org>
Дата:
Implement ALTER TABLE ... SPLIT PARTITION ... command This new DDL command splits a single partition into several partitions. Just like the ALTER TABLE ... MERGE PARTITIONS ... command, new partitions are created using the createPartitionTable() function with the parent partition as the template. This commit comprises a quite naive implementation which works in a single process and holds the ACCESS EXCLUSIVE LOCK on the parent table during all the operations, including the tuple routing. This is why the new DDL command can't be recommended for large, partitioned tables under high load. However, this implementation comes in handy in certain cases, even as it is. Also, it could serve as a foundation for future implementations with less locking and possibly parallelism. Discussion: https://postgr.es/m/c73a1746-0cd0-6bdd-6b23-3ae0b7c0c582%40postgrespro.ru Author: Dmitry Koval Co-authored-by: Alexander Korotkov Co-authored-by: Tender Wang Co-authored-by: Richard Guo Co-authored-by: Dagfinn Ilmari Mannsaker Co-authored-by: Fujii Masao Co-authored-by: Jian He Reviewed-by: Matthias van de Meent Reviewed-by: Laurenz Albe Reviewed-by: Zhihong Yu Reviewed-by: Justin Pryzby Reviewed-by: Alvaro Herrera Reviewed-by: Robert Haas Reviewed-by: Stephane Tachoires Reviewed-by: Jian He Reviewed-by: Alexander Korotkov Reviewed-by: Pavel Borisov Reviewed-by: Masahiko Sawada Reviewed-by: Alexander Lakhin Reviewed-by: Kyotaro Horiguchi Reviewed-by: Daniel Gustafsson Reviewed-by: Tom Lane Reviewed-by: Noah Misch Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/4b3d173629f4cd7ab6cd700d1053af5d5c7c9e37 Modified Files -------------- doc/src/sgml/ddl.sgml | 19 + doc/src/sgml/ref/alter_table.sgml | 118 +- src/backend/commands/tablecmds.c | 432 ++++++ src/backend/parser/gram.y | 38 +- src/backend/parser/parse_utilcmd.c | 197 ++- src/backend/partitioning/partbounds.c | 737 ++++++++- src/bin/psql/tab-complete.in.c | 10 +- src/include/nodes/parsenodes.h | 34 +- src/include/parser/kwlist.h | 1 + src/include/partitioning/partbounds.h | 4 + src/test/isolation/expected/partition-split.out | 230 +++ src/test/isolation/isolation_schedule | 1 + src/test/isolation/specs/partition-split.spec | 62 + .../test_ddl_deparse/expected/alter_table.out | 5 + .../modules/test_ddl_deparse/sql/alter_table.sql | 4 + .../modules/test_ddl_deparse/test_ddl_deparse.c | 3 + src/test/regress/expected/partition_split.out | 1592 ++++++++++++++++++++ src/test/regress/parallel_schedule | 2 +- src/test/regress/sql/partition_split.sql | 1134 ++++++++++++++ src/tools/pgindent/typedefs.list | 2 + 20 files changed, 4585 insertions(+), 40 deletions(-)