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