Re: Declarative partitioning - another take
Amit Langote <langote_amit_f8@lab.ntt.co.jp>
Attachments
On 2017/01/19 5:29, Robert Haas wrote: > On Wed, Jan 18, 2017 at 3:12 PM, Robert Haas <robertmhaas@gmail.com> wrote: >> On Tue, Jan 10, 2017 at 6:06 AM, Amit Langote >> <Langote_Amit_f8@lab.ntt.co.jp> wrote: >>> [ updated patches ] >> >> I committed 0004 and also fixed the related regression test not to >> rely on DROP .. CASCADE, which isn't always stable. The remainder of Thanks! >> this patch set needs a rebase, and perhaps you could also fold in >> other pending partitioning fixes so I have everything to look at it in >> one place. > > Just to be a little more clear, I don't mind multiple threads each > with a patch or patch set so much, but multiple patch sets on the same > thread gets hard for me to track. Sorry for the inconvenience. OK, I agree that having multiple patch sets on the same thread is cumbersome. So, here are all the patches I posted to date (and one new at the bottom) for reported and unreported bugs, excluding the one involving BulkInsertState for which you replied in a new thread. I'll describe the attached patches in brief: 0001-Fix-a-bug-of-insertion-into-an-internal-partition.patch Since implicit partition constraints are not inherited, an internal partition's constraint was not being enforced when targeted directly. So, include such constraint when setting up leaf partition result relations for tuple-routing. 0002-Set-ecxt_scantuple-correctly-for-tuple-routing.patch In 2ac3ef7a01df859c62d0a02333b646d65eaec5ff, we changed things so that it's possible for a different TupleTableSlot to be used for partitioned tables at successively lower levels. If we do end up changing the slot from the original, we must update ecxt_scantuple to point to the new one for partition key of the tuple to be computed correctly. Last posted here: https://www.postgresql.org/message-id/99fbfad6-b89b-9427-a6ca-197aad98c48e%40lab.ntt.co.jp 0003-Fix-RETURNING-to-work-correctly-after-tuple-routing.patch In ExecInsert(), do not switch back to the root partitioned table ResultRelInfo until after we finish ExecProcessReturning(), so that RETURNING projection is done using the partition's descriptor. For the projection to work correctly, we must initialize the same for each leaf partition during ModifyTableState initialization. 0004-Fix-some-issues-with-views-and-partitioned-tables.patch Automatically updatable views failed to handle partitioned tables. Once that's fixed, WITH CHECK OPTIONS wouldn't work correctly without the WCO expressions having been suitably converted for each partition (think applying map_partition_varattnos to Vars in the WCO expressions just like with partition constraint expressions). 0005-Fix-some-wrong-thinking-in-check_new_partition_bound.patch Because a given range bound in the PartitionBoundInfo.datums array is sometimes a range lower bound and upper bound at other times, we must be careful when assuming which, especially when interpreting the result of partition_bound_bsearch which returns the index of the greatest bound that is less than or equal to probe. Due to an error in thinking about the same, the relevant code in check_new_partition_bound() caused invalid partition (index = -1) to be chosen as the partition being overlapped. Last posted here: https://www.postgresql.org/message-id/603acb8b-5dec-31e8-29b0-609a68aac50f%40lab.ntt.co.jp 0006-Avoid-tuple-coversion-in-common-partitioning-cases.patch Currently, the tuple conversion is performed after a tuple is routed, even if the attributes of a target leaf partition map one-to-one with those of the root table, which is wasteful. Avoid that by making convert_tuples_by_name() return a NULL map for such cases. 0007-Avoid-code-duplication-in-map_partition_varattnos.patch Code to map attribute numbers in map_partition_varattnos() duplicates what convert_tuples_by_name_map() does. Avoid that as pointed out by Álvaro Herrera. Last posted here: https://www.postgresql.org/message-id/9ce97382-54c8-deb3-9ee9-a2ec271d866b%40lab.ntt.co.jp 0008-Avoid-DROP-TABLE-.-CASCADE-in-more-partitioning-test.patch This is the new one. There were quite a few commits recently to fix the breakage in regression tests due to not using ORDER BY in queries on system catalogs and using DROP TABLE ... CASCADE. There were still some instances of the latter in create_table.sql and alter_table.sql. Thanks, Amit
Commits
-
Fix typo.
- 03bf59676ea0 10.0 landed
-
Document trigger-firing behavior for inheritance/partitioning.
- e17628145ac3 10.0 landed
-
Fire per-statement triggers on partitioned tables.
- e180c8aa8caf 10.0 landed
-
Set ecxt_scantuple correctly for tuple routing.
- 132488bfee68 10.0 landed
-
Fix interaction of partitioned tables with BulkInsertState.
- b1ecb9b3fcfb 10.0 landed
-
Avoid core dump for empty prepared statement in an aborted transaction.
- ba61a04bc7fe 10.0 cited
-
Fix some problems in check_new_partition_bound().
- 8a8afe2f54c2 10.0 landed
-
Remove unnecessary arguments from partitioning functions.
- 18fc5192a631 10.0 cited
-
Fix reporting of constraint violations for table partitioning.
- f1b4c771ea74 10.0 cited
-
Fix tuple routing in cases where tuple descriptors don't match.
- 2ac3ef7a01df 10.0 cited
-
Invalid parent's relcache after CREATE TABLE .. PARTITION OF.
- 7cd0fd655d68 10.0 landed
-
Doc: improve documentation about inheritance.
- 162477a63d3c 10.0 cited