Hi, I tested the patch on my current branch. Before applying the patch i was able to reproduce the reported issue. I created a table containing a NULL value, added a NOT NULL NOT VALID constraint on the column, and created a unique index. PostgreSQL accepted ALTER TABLE REPLICA IDENTITY USING INDEX even though the underlying NOT NULL constraint had not been validated and the column still contained NULL values. The command succeeded and relreplident was set to i, confirming the behavior described in the report.
After applying the patch i repeated the same test. PostgreSQL correctly rejected the operation with ERROR: cannot use index "t_idx" as replica identity DETAIL: The constraint "id_nn" on column "id" is marked NOT VALID. HINT: You might need to validate it using ALTER TABLE ... VALIDATE CONSTRAINT. This matches the expected behavior, since a column with an unvalidated NOT NULL constraint cannot guarantee that all rows are non-null and therefore should not be eligible for use as a replica identity. I also ran the regression tests, and all tests passed successfully. Regards, Solai
