Re: Partition Check not updated when insert into a partition - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Partition Check not updated when insert into a partition
Date
Msg-id 202107121851.gdf3cqv4v26g@alvherre.pgsql
Whole thread Raw
In response to Partition Check not updated when insert into a partition  ("houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>)
Responses RE: Partition Check not updated when insert into a partition  ("houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>)
List pgsql-hackers
On 2021-Jun-23, houzj.fnst@fujitsu.com wrote:

> 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'.

Hmm, if I understand correctly, this means that we need to invalidate
relcache for all partitions of the partition being detached.  Maybe like
in the attached WIP ("XXX VERY CRUDE XXX DANGER EATS DATA") patch, which
solves what you complained about, but I didn't run any other tests.
(Also, in the concurrent case I think this should be done during the
first transaction, so this patch is wrong for it.)

Did you have a misbehaving test for the ATTACH case?

-- 
Álvaro Herrera           39°49'30"S 73°17'W  —  https://www.EnterpriseDB.com/
"I dream about dreams about dreams", sang the nightingale
under the pale moon (Sandman)

Attachment

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Remove useless int64 range checks on BIGINT sequence MINVALUE/MAXVALUE values
Next
From: Peter Eisentraut
Date:
Subject: Re: [PATCH v3 1/1] Fix detection of preadv/pwritev support for OSX.