Partition Check not updated when insert into a partition

From: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Partition Check not updated when insert into a partition
Date: 2021-06-23 04:16:10
Message-ID: OS3PR01MB5718DA1C4609A25186D1FBF194089@OS3PR01MB5718.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

When directly INSERT INTO partition, postgres will invoke ExecPartitionCheck
which will execute its parent's and grandparent's partition constraint check.
From the code, the whole constraint check is saved in relcache::rd_partcheck.

For a multi-level partition, for example: table 'A' is partition of table
'B', and 'B' is also partition of table 'C'. After I 'ALTER TABLE C DETACH B',
I thought partition constraint check of table 'C' does not matter anymore if
INSERT INTO table 'A'. But it looks like the relcache of 'A' is not invalidated
after detaching 'B'. And the relcache::rd_partcheck still include the partition
constraint of table 'C'. Note If I invalidate the table 'A''s relcache manually,
then next time the relcache::rd_partcheck will be updated to the expected
one which does not include partition constraint check of table 'C'.
(ATTACH partition has the same behaviour that relcache::rd_partcheck will
not be updated immediately)

Does it work as expected ? I didn't find some explanation from the doc.
(sorry if I missed something).

Best regards,
houzj

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2021-06-23 04:25:18 Re: Assertion failure in HEAD and 13 after calling COMMIT in a stored proc
Previous Message Amit Kapila 2021-06-23 04:12:16 Re: Doc chapter for Hash Indexes