Partition Check not updated when insert into a partition
Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
From: "houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-06-23T04:16:10Z
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
Commits
-
Invalidate partitions of table being attached/detached
- fe35528a5ed6 13.5 landed
- d6f1e16c8fe2 15.0 landed
- d36bdc4e9d3e 10.19 landed
- b703b7d312a7 11.14 landed
- 8b26be8a32c3 12.9 landed
- 72d064217257 14.1 landed