Re: Statement-level Triggers For Uniqueness Checks - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: Statement-level Triggers For Uniqueness Checks
Date
Msg-id CAEZATCWYhOFEBA+2P3pMnWhjE4xvUO85yt+1XZUHnsD8NLX0sA@mail.gmail.com
Whole thread Raw
In response to Re: Statement-level Triggers For Uniqueness Checks  (Corey Huinker <corey.huinker@gmail.com>)
Responses Re: Statement-level Triggers For Uniqueness Checks  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-hackers
On Mon, 24 Dec 2018 at 23:57, Corey Huinker <corey.huinker@gmail.com> wrote:
>
> So I took a first pass at this, and I got stuck.
>
> [snip]
>
> Any idea where I went wrong?

Take a look at this code in AfterTriggerSaveEvent():

        /*
         * If the trigger is a deferred unique constraint check trigger, only
         * queue it if the unique constraint was potentially violated, which
         * we know from index insertion time.
         */
        if (trigger->tgfoid == F_UNIQUE_KEY_RECHECK)
        {
            if (!list_member_oid(recheckIndexes, trigger->tgconstrindid))
                continue;       /* Uniqueness definitely not violated */
        }

If you trace it back, you'll see that for a statement-level trigger,
recheckIndexes will always be empty.

Regards,
Dean


pgsql-hackers by date:

Previous
From: "Imai, Yoshikazu"
Date:
Subject: RE: speeding up planning with partitions
Next
From: Michael Paquier
Date:
Subject: Re: [PATCH] pg_hba.conf : new auth option : clientcert=verify-full