Fix OID passed to object-alter hook during ALTER CONSTRAINT
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 4 May 2021 14:09:11 +0000 (10:09 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 4 May 2021 14:09:11 +0000 (10:09 -0400)
The OID of the constraint is used instead of the OID of the trigger --
an easy mistake to make.  Apparently the object-alter hooks are not very
well tested :-(

Backpatch to 12, where this typo was introduced by 578b229718e8

Discussion: https://postgr.es/m/20210503231633.GA6994@alvherre.pgsql

src/backend/commands/tablecmds.c

index 44499ec08b37eef65e0e3abcb205b37bd5023086..022d5e9b2d52751935b317b6bed900902b8f799a 100644 (file)
@@ -9847,7 +9847,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
            copy_tg->tginitdeferred = cmdcon->initdeferred;
            CatalogTupleUpdate(tgrel, &copyTuple->t_self, copyTuple);
 
-           InvokeObjectPostAlterHook(TriggerRelationId, currcon->oid, 0);
+           InvokeObjectPostAlterHook(TriggerRelationId, tgform->oid, 0);
 
            heap_freetuple(copyTuple);
        }