Re: Statement-level Triggers For Uniqueness Checks

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Statement-level Triggers For Uniqueness Checks
Date: 2018-12-25 08:04:11
Message-ID: CAEZATCWYhOFEBA+2P3pMnWhjE4xvUO85yt+1XZUHnsD8NLX0sA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 24 Dec 2018 at 23:57, Corey Huinker <corey(dot)huinker(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-12-25 08:08:52 Re: [PATCH] pg_hba.conf : new auth option : clientcert=verify-full
Previous Message Imai, Yoshikazu 2018-12-25 07:47:24 RE: speeding up planning with partitions