Restore RI trigger sanity check
authorAlvaro Herrera
Wed, 20 Mar 2019 20:23:26 +0000 (17:23 -0300)
committerAlvaro Herrera
Wed, 20 Mar 2019 20:23:26 +0000 (17:23 -0300)
I unnecessarily removed this check in 3de241dba86f because I
misunderstood what the final representation of constraints across a
partitioning hierarchy was to be.  Put it back (in both branches).

Discussion: https://postgr.es/m/201901222145[email protected]

src/backend/utils/adt/ri_triggers.c

index cfc25c55dfa99070805a27b84c0011aa39b4786c..d3225094c7af0a2887c0b10ba0a41e9f40a90c40 100644 (file)
@@ -2320,6 +2320,13 @@ ri_FetchConstraintInfo(Trigger *trigger, Relation trig_rel, bool rel_is_pk)
            elog(ERROR, "wrong pg_constraint entry for trigger \"%s\" on table \"%s\"",
                 trigger->tgname, RelationGetRelationName(trig_rel));
    }
+   else
+   {
+       if (riinfo->fk_relid != RelationGetRelid(trig_rel) ||
+           riinfo->pk_relid != trigger->tgconstrrelid)
+           elog(ERROR, "wrong pg_constraint entry for trigger \"%s\" on table \"%s\"",
+                trigger->tgname, RelationGetRelationName(trig_rel));
+   }
 
    return riinfo;
 }