Small fixes for Add ALTER TABLE ... ALTER CONSTRAINT ... SET [NO] INHERIT
authorPeter Eisentraut <[email protected]>
Tue, 25 Mar 2025 12:40:24 +0000 (13:40 +0100)
committerPeter Eisentraut <[email protected]>
Tue, 25 Mar 2025 12:40:24 +0000 (13:40 +0100)
Small fixes for commit f4e53e10b6c: Add missing calls to
InvokeObjectPostAlterHook() and also CacheInvalidateRelcache().  The
former change could have a user-visible effect.  The latter omission
might have caused other bugs, but it is not clear whether one actually
existed.  With these changes, the code is now more consistent with
similar ALTER CONSTRAINT variants, especially the ones that set the
deferrability.

Reviewed-by: Álvaro Herrera <[email protected]>
Discussion: https://postgr.es/m/CAF1DzPVfOW6Kk=7SSh7LbneQDJWh=PbJrEC_Wkzc24tHOyQWGg@mail.gmail.com

src/backend/commands/tablecmds.c

index 1202544ebd02d91aa6010b50c3939cea461c3b29..4974536e084e49a3c4065b0cf00c3fa819b39a38 100644 (file)
@@ -12151,10 +12151,16 @@ ATExecAlterConstraintInternal(List **wqueue, ATAlterConstraint *cmdcon,
        copy_con->connoinherit = cmdcon->noinherit;
 
        CatalogTupleUpdate(conrel, &copyTuple->t_self, copyTuple);
+
+       InvokeObjectPostAlterHook(ConstraintRelationId, currcon->oid, 0);
+
        CommandCounterIncrement();
        heap_freetuple(copyTuple);
        changed = true;
 
+       /* Make new constraint flags visible to others */
+       CacheInvalidateRelcache(rel);
+
        /* Fetch the column number and name */
        colNum = extractNotNullColumn(contuple);
        colName = get_attname(currcon->conrelid, colNum, false);