mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Apply RI trigger skipping tests also for DELETE
The tests added in cfa0f4255b
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 <daniel@yesql.se>
This commit is contained in:
@ -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))
|
||||
{
|
||||
|
Reference in New Issue
Block a user