On 7 June 2017 at 20:19, Amit Khandekar <amitdkhan...@gmail.com> wrote: > On 7 June 2017 at 16:42, Amit Khandekar <amitdkhan...@gmail.com> wrote: >> The column bitmap set returned by GetUpdatedColumns() refer to >> attribute numbers w.r.t. to the root partition. And the >> mstate->resultRelInfo[] have attnos w.r.t. to the leaf partitions. So >> we need to do something similar to map_partition_varattnos() to change >> the updated columns attnos to the leaf partitions > > I was wrong about this. Each of the mtstate->resultRelInfo[] has its > own corresponding RangeTblEntry with its own updatedCols having attnos > accordingly adjusted to refer its own table attributes. So we don't > have to do the mapping; we need to get modifedCols separately for each > of the ResultRelInfo, rather than the root relinfo. > >> and walk down the >> partition constraint expressions to find if the attnos are present >> there. > > But this we will need to do.
Attached is v9 patch. This covers the two parts discussed upthread : 1. Prevent triggers from causing the row movement. 2. Setup the tuple routing in ExecInitModifyTable(), but only if a partition key is modified. Check new function IsPartitionKeyUpdate(). Have rebased the patch to consider changes done in commit 15ce775faa428dc9 to prevent triggers from violating partition constraints. There, for the call to ExecFindPartition() in ExecInsert, we need to fetch the mtstate->rootResultRelInfo in case the operation is part of update row movement. This is because the root partition is not available in the resultRelInfo for UPDATE. Added many more test scenarios in update.sql that cover the above. I am yet to test the concurrency part using isolation tester. -- Thanks, -Amit Khandekar EnterpriseDB Corporation The Postgres Database Company
update-partition-key_v9.patch
Description: Binary data
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers