From 69ee2ff9308bbfe0e0a89667555e901fec5e154b Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 19 Jul 2018 08:37:32 +0200 Subject: Apply RI trigger skipping tests also for DELETE The tests added in cfa0f4255bb0f5550d37a01c4d8fe2966d20040c to skip firing an RI trigger if any old key value is NULL can also be applied for DELETE. This should give a performance gain in those cases, and it also saves a lot of duplicate code in the actual RI triggers. (That code was already dead code for the UPDATE cases.) Reviewed-by: Daniel Gustafsson --- src/backend/commands/trigger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/backend/commands/trigger.c') diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 0bd847cd195..ccb5706c162 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -5950,12 +5950,12 @@ AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo, * certain cases where we can skip queueing the event because we can * tell by inspection that the FK constraint will still pass. */ - if (TRIGGER_FIRED_BY_UPDATE(event)) + if (TRIGGER_FIRED_BY_UPDATE(event) || TRIGGER_FIRED_BY_DELETE(event)) { switch (RI_FKey_trigger_type(trigger->tgfoid)) { case RI_TRIGGER_PK: - /* Update on trigger's PK table */ + /* Update or delete on trigger's PK table */ if (!RI_FKey_pk_upd_check_required(trigger, rel, oldtup, newtup)) { -- cgit v1.2.3