From b8c3bfb8617066c924f7b74f7cc5e6ad08cd4261 Mon Sep 17 00:00:00 2001 From: "Paul A. Jungwirth" Date: Tue, 28 Jan 2025 20:11:31 -0800 Subject: [PATCH v0] Trigger the RESTRICT build farm failures consistently --- src/backend/utils/adt/ri_triggers.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 3d9985b17c2..8ebdafc9913 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -701,6 +701,8 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS) return ri_restrict((TriggerData *) fcinfo->context, false); } +static Oid lastCachedConstraint = InvalidOid; + /* * ri_restrict - * @@ -753,6 +755,8 @@ ri_restrict(TriggerData *trigdata, bool is_no_action) * query for delete and update cases) */ ri_BuildQueryKey(&qkey, riinfo, RI_PLAN_RESTRICT); + if (!is_no_action) + qkey.constr_id = lastCachedConstraint; if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { @@ -884,6 +888,7 @@ ri_restrict(TriggerData *trigdata, bool is_no_action) /* Prepare and save the plan */ qplan = ri_PlanCheck(querybuf.data, riinfo->nkeys, queryoids, &qkey, fk_rel, pk_rel); + lastCachedConstraint = riinfo->constraint_id; } /* -- 2.42.0