Re: [HACKERS] UPDATE of partition key
Amit Khandekar <amitdkhan.pg@gmail.com>
Attachments
- update-partition-key_v36.patch (application/octet-stream) patch v36
On 10 January 2018 at 02:30, Robert Haas <robertmhaas@gmail.com> wrote: > On Fri, Jan 5, 2018 at 3:25 PM, Robert Haas <robertmhaas@gmail.com> wrote: >> On Fri, Jan 5, 2018 at 7:12 AM, Amit Khandekar <amitdkhan.pg@gmail.com> wrote: >>> The above patch is to be applied over the last remaining preparatory >>> patch, now named (and attached) : >>> 0001-Refactor-CheckConstraint-related-code.patch >> >> Committed that one, too. > > Some more comments on the main patch: > > I don't really like the fact that ExecCleanupTupleRouting() now takes > a ModifyTableState as an argument, particularly because of the way > that is using that argument. To figure out whether a ResultRelInfo > was pre-existing or one it created, it checks whether the pointer > address of the ResultRelInfo is >= mtstate->resultRelInfo and < > mtstate->resultRelInfo + mtstate->mt_nplans. However, that means that > ExecCleanupTupleRouting() ends up knowing about the memory allocation > pattern used by ExecInitModifyTable(), which seems like a slightly > dangerous amount of action at a distance. I think it would be better > for the PartitionTupleRouting structure to explicitly indicate which > ResultRelInfos should be closed, for example by storing a Bitmapset > *input_partitions. (Here, by "input", I mean "provided from the > mtstate rather than created by the PartitionTupleRouting structure; > other naming suggestions welcome.) When > ExecSetupPartitionTupleRouting latches onto a partition, it can do > proute->input_partitions = bms_add_member(proute->input_partitons, i). > In ExecCleanupTupleRouting, it can do if > (bms_is_member(proute->input_partitions, i)) continue. Did the changes. But, instead of a new bitmapet, I used the offset array for the purpose. As per our parallel discussion on tup-conversion maps, it is almost finalized that the subplan-partition offset map is good to have. So I have used that offset array to determine whether a partition is present in the subplan. I used the assumption that subplan and partition array have their partitions in the same order. > > We have a test, in the regression test suite for file_fdw, which > generates the message "cannot route inserted tuples to a foreign > table". I think we should have a similar test for the case where an > UPDATE tries to move a tuple from a regular partition to a foreign > table partition. Added an UPDATE scenario in contrib/file_fdw/input/file_fdw.source. > I'm not sure if it should fail with the same error > or a different one, but I think we should have a test that it fails > cleanly and with a nice error message of some sort. The update-tuple-routing goes through the same ExecInsert() code, so it fails at the same place with the same error message. > > The comment for get_partitioned_child_rels() claims that it sets > is_partition_key_update, but it really sets *is_partition_key_update. > And I think instead of "is a partition key" it should say "is used in > the partition key either of the relation whose RTI is specified or of > any child relation." I propose "used in" instead of "is" because > there can be partition expressions, and the rest is to clarify that > child partition keys matter. Fixed. > > create_modifytable_path uses partColsUpdated rather than > partKeyUpdated, which actually seems like better terminology. I > propose partKeyUpdated -> partColsUpdated everywhere. Also, why use > is_partition_key_update for basically the same thing in some other > places? I propose changing that to partColsUpdated as well. Done. > > The capitalization of the first comment hunk in execPartition.h is strange. I think you are referring to : * subplan_partition_offsets int Array ordered by UPDATE subplans. Each Changed Array to array. Didn't change UPDATE. Attached v36 patch.
Commits
-
Avoid referencing off the end of subplan_partition_offsets.
- 945f71db8452 11.0 landed
-
Allow UPDATE to move rows between partitions.
- 2f178441044b 11.0 landed
-
Remove useless lookup of root partitioned rel in ExecInitModifyTable().
- dca48d145e0e 11.0 cited
-
Factor error generation out of ExecPartitionCheck.
- 19c47e7c8202 11.0 landed
-
Minor preparatory refactoring for UPDATE row movement.
- ef6087ee5fa8 11.0 landed
-
Simplify and encapsulate tuple routing support code.
- cc6337d2fed5 11.0 landed
-
Avoid coercing a whole-row variable that is already coerced.
- 1c497fa72df7 11.0 landed
-
Use ResultRelInfo ** rather than ResultRelInfo * for tuple routing.
- 60f7c0abef03 11.0 landed
-
Make RelationGetPartitionDispatchInfo expand depth-first.
- 77b6b5e9ceca 11.0 cited
-
Expand partitioned tables in PartDesc order.
- 30833ba154e0 11.0 cited
-
Use a real RT index when setting up partition tuple routing.
- f81a91db4d1c 10.0 cited
-
Fix transition tables for partition/inheritance.
- 501ed02cf6f4 10.0 cited
-
Fix confusion about number of subplans in partitioned INSERT setup.
- 78a030a44196 10.0 cited
-
Prevent BEFORE triggers from violating partitioning constraints.
- 15ce775faa42 10.0 cited
-
Fire per-statement triggers on partitioned tables.
- e180c8aa8caf 10.0 cited
-
Fix reporting of violations in ExecConstraints, again.
- c0a8ae7be392 10.0 cited
-
Don't scan partitioned tables.
- d3cc37f1d801 10.0 cited
-
Allow FDWs to push down quals without breaking EvalPlanQual rechecks.
- 5fc4c26db512 9.6.0 cited