Confused comment about drop replica identity index
Wei Wang (Fujitsu) <wangw.fnst@fujitsu.com>
From: "wangw.fnst@fujitsu.com" <wangw.fnst@fujitsu.com>
To: "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2021-12-14T12:38:28Z
Lists: pgsql-hackers
Hi hackers, When I doing development based by PG, I found the following comment have a little problem in file src/include/catalog/pg_class.h. /* * an explicitly chosen candidate key's columns are used as replica identity. * Note this will still be set if the index has been dropped; in that case it * has the same meaning as 'd'. */ #define REPLICA_IDENTITY_INDEX 'i' The last sentence makes me a little confused : [......in that case it as the same meaning as 'd'.] Now, pg-doc didn't have a clear style to describe this. But if I drop relation's replica identity index like the comment, the action is not as same as default. For example: Execute the following SQL: create table tbl (col1 int primary key, col2 int not null); create unique INDEX ON tbl(col2); alter table tbl replica identity using INDEX tbl_col2_idx; drop index tbl_col2_idx; create publication pub for table tbl; delete from tbl; Actual result: ERROR: cannot delete from table "tbl" because it does not have a replica identity and publishes deletes HINT: To enable deleting from the table, set REPLICA IDENTITY using ALTER TABLE. Expected result in comment: DELETE 0 I found that in the function CheckCmdReplicaIdentity, the operation described in the comment is not considered, When relation's replica identity index is found to be InvalidOid, an error is reported. Are the comment here not accurate enough? Or we need to adjust the code according to the comments? Regards, Wang wei
Commits
-
Correct comment and some documentation about REPLICA_IDENTITY_INDEX
- 9edca4cb57d2 10.20 landed
- 1a0ef5e2cc63 11.15 landed
- 861095a40987 12.10 landed
- 28e1e5c2a91c 13.6 landed
- 420f9ac1b77c 14.2 landed
- fc95d35b9429 15.0 landed
-
Add regression tests for REPLICA IDENTITY with dropped indexes
- fe7fd4e9613f 14.0 cited