Re: relcache not invalidated when ADD PRIMARY KEY USING INDEX
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Euler Taveira" <euler@eulerto.com>
Cc: "houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-01-22T18:38:04Z
Lists: pgsql-hackers
"Euler Taveira" <euler@eulerto.com> writes: > On Mon, Dec 20, 2021, at 3:45 AM, houzj.fnst@fujitsu.com wrote: >> When reviewing some replica identity related patches, I found that when adding >> primary key using an existing unique index on not null columns, the >> target table's relcache won't be invalidated. > Good catch. Indeed. > It seems you can simplify your checking indexForm->indisprimary directly, no? The logic seems fine to me --- it avoids an unnecessary cache flush if the index was already the pkey. (Whether we actually reach this code in such a case, I dunno, but it's not costing much to be smart if we are.) > Why did you add new tests for test_decoding? I think the TAP tests alone are > fine. BTW, this test is similar to publisher3/subscriber3. Isn't it better to > use the same pub/sub to reduce the test execution time? I agree, the proposed test cases are expensive overkill. The repro shown in the original message is sufficient and much cheaper. Moreover, we already have some test cases very much like that in regress/sql/publication.sql, so that's where I put it. Pushed with some minor cosmetic adjustments. regards, tom lane
Commits
-
Flush table's relcache during ALTER TABLE ADD PRIMARY KEY USING INDEX.
- e2d53c8767da 12.10 landed
- d8fbbb925bdb 15.0 landed
- 3839e29c58b4 14.2 landed
- 31b7b4d26e10 13.6 landed
- 26c841ed1b2d 11.15 landed