Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Robert Haas <robertmhaas@gmail.com>
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Adjust errcode in checkPartition()
- d51a5d8e5692 19 (unreleased) landed
-
Fix usage of palloc() in MERGE/SPLIT PARTITION(s) code
- c5ae07a90a0f 19 (unreleased) landed
-
Implement ALTER TABLE ... SPLIT PARTITION ... command
- 4b3d173629f4 19 (unreleased) landed
- 87c21bb9412c 17.0 landed
-
Implement ALTER TABLE ... MERGE PARTITIONS ... command
- f2e4cc427951 19 (unreleased) landed
- 1adf16b8fba4 17.0 landed
-
Calculate agglevelsup correctly when Aggref contains a CTE.
- b0cc0a71e0a0 19 (unreleased) cited
-
Use PqMsg_* macros in applyparallelworker.c.
- 989b2e4d5c95 19 (unreleased) cited
-
Restrict psql meta-commands in plain-text dumps.
- 71ea0d679543 19 (unreleased) cited
-
Ensure we have a snapshot when updating various system catalogs.
- 706054b11b95 18.0 cited
-
Use specific collation where needed in new test
- 17bcf4f54504 18.0 cited
-
Expand virtual generated columns in the planner
- 1e4351af329f 18.0 cited
-
Virtual generated columns
- 83ea6c54025b 18.0 cited
-
Define PG_LOGICAL_DIR for path pg_logical/ in data folder
- c39afc38cfec 18.0 cited
-
Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands
- 84f594da3588 17.0 landed
- 3890d90c1508 18.0 landed
-
Avoid repeated table name lookups in createPartitionTable()
- f636ab41aba2 17.0 landed
- 04158e7fa37c 18.0 landed
-
Provide deterministic order for catalog queries in partition_split.sql
- d53a4286d772 17.0 landed
-
Don't copy extended statistics during MERGE/SPLIT partition operations
- fbd4321fd5b4 17.0 landed
-
Fix the name collision detection in MERGE/SPLIT partition operations
- 3a82c689fd1b 17.0 landed
-
Fix regression tests conflict in 3ca43dbbb6
- 2a679ae94e46 17.0 landed
-
Add permission check for MERGE/SPLIT partition operations
- 3ca43dbbb67f 17.0 landed
-
Fix one more portability shortcoming in new test_pg_dump test.
- d12b4ba1bd3e 17.0 cited
-
Inherit parent's AM for partition MERGE/SPLIT operations
- 259c96fa8f78 17.0 landed
-
Add tab completion for partition MERGE/SPLIT operations
- 60ae37a8bc02 17.0 landed
-
Rename tables in tests of partition MERGE/SPLIT operations
- f4fc7cb54b6a 17.0 landed
-
Make new partitions with parent's persistence during MERGE/SPLIT
- fcf80c5d5f0f 17.0 landed
-
Document the way partition MERGE/SPLIT operations create new partitions
- 842c9b27057e 17.0 landed
-
Change the way ATExecMergePartitions() handles the name collision
- 885742b9f88b 17.0 landed
-
Grammar fixes for split/merge partitions code
- 9dfcac8e15ac 17.0 landed
-
Checks for ALTER TABLE ... SPLIT/MERGE PARTITIONS ... commands
- c99ef1811a06 17.0 landed
-
Fix some grammer errors from error messages and codes comments
- df64c81ca9cb 17.0 landed
-
Support TZ and OF format codes in to_timestamp().
- 8ba6fdf905d0 17.0 cited
-
Support identity columns in partitioned tables
- 699586315704 17.0 cited
-
Fix indentation in twophase.c
- 4e465aac36ce 17.0 cited
-
Fix corner-case planner failure for MERGE.
- 326a33a289c7 16.0 cited
-
Doc: fix documentation example for bytea hex output format.
- 4f46f870fa56 16.0 cited
-
Avoid repeated name lookups during table and index DDL.
- 5f173040e324 9.4.0 cited
On Thu, Aug 22, 2024 at 12:43 PM Alexander Korotkov <aekorotkov@gmail.com> wrote: > Thank you for your feedback. Yes, it seems that there is not enough > time to even carefully analyze all the issues in these features. The > rule of thumb I can get from this experience is "think multiple times > before accessing something already opened by its name". I'm going to > revert these features during next couple days. Thanks, and sorry about that. I would say even "think multiple times" is possibly not strong enough -- it might almost be "just don't ever do it". Even if (in some particular case) the invalidation mechanism seems to protect you from getting wrong answers, there are often holes in that, specifically around search_path = foo, bar and you're operating on an object in schema bar and an identically-named object is created in schema foo at just the wrong time. Sometimes there are problems even when search_path is not involved, but when it is, there are more. Here, aside from the name lookup issues, there are also problems with expression evaluation: we can't split partitions without reindexing rows that those partitions contain, and it is critical to think through which is going to do the evaluation and make sure it's properly sandboxed. I think we might need SECURITY_RESTRICTED_OPERATION here. Another thing I want to highlight if you do have another go at this patch is that it's really critical to think about where every single property of the newly-created tables comes from. The original patch didn't consider relpersistence or tableam, and here I just discovered that owner is also an issue that probably needs more consideration, but it goes way beyond that. For example, I was surprised to discover that if I put per-partition constraints or triggers on a partition and then split it, they were not duplicated to the new partitions. Now, maybe that's actually the behavior we want -- I'm not 100% positive -- but it sure wasn't what I was expecting. If we did duplicate them when splitting, then what's supposed to happen when merging occurs? That is not at all obvious, at least to me, but it needs careful thought. ACLs and rules and default values and foreign keys (both outbond and inbound) all need to be considered too, along with 27 other things that I'm sure I'm not thinking about right now. Some of this behavior should probably be explicitly documented, but all of it should be considered carefully enough before commit to avoid surprises later. I say that both from a security point of view and also just from a user experience point of view. Even if things aren't insecure, they can still be annoying, but it's not uncommon in cases like this for annoying things to turn out to also be insecure. Finally, if you do revisit this, I believe it would be a good idea to think a bit harder about how data is moved around. My impression (and please correct me if I am mistaken) is that currently, any split or merge operation rewrites all the data in the source partition(s). If a large partition is being split nearly equally, I think that has a good chance of being optimal, but I think that might be the only case. If we're merging partitions, wouldn't it be better to adjust the constraints on the first partition -- or perhaps the largest partition if we want to be clever -- and insert the data from all of the others into it? Maybe that would even have syntax that puts the user in control of which partition survives, e.g. ALTER TABLE tab1 MERGE PARTITION part1 WITH part2, part3, .... That would also make it really obvious to the user what all of the properties of part1 will be after the merge: they will be exactly the same as they were before the merge, except that the partition constraint will have been adjusted. You basically dodge everything in the previous paragraph in one shot, and it seems like it would also be faster. Splitting there's no similar get-out-of-jail free card, at least not that I can see. Even if you add syntax that splits a partition by using INSERT/DELETE to move some rows to a newly-created partition, you still have to make at least one new partition. But possibly that syntax is worth having anyway, because it would be a lot quicker in the case of a highly asymmetric split. On the other hand, maybe even splits are much more likely and we don't really need it. I don't know. -- Robert Haas EDB: http://www.enterprisedb.com