pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Willy-Bas Loos <willybas@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: implicit transaction changes trigger behaviour
Date: Thu, 29 Aug 2019 09:35:35 -0400
Message-ID: <17896.1567085735@sss.pgh.pa.us> (raw)
In-Reply-To: <CAHnozThxLxCanw=UjSnRaefg20SP+HUq_y3-u0+gP3n8yRti_Q@mail.gmail.com>
References: <CAHnozThxLxCanw=UjSnRaefg20SP+HUq_y3-u0+gP3n8yRti_Q@mail.gmail.com>

Willy-Bas Loos <willybas@gmail.com> writes:
> I currently have a fairly complex use case to solve and one thing i tried
> was a deferred constraint trigger. I'm not sure if this solution is the way
> to go, but anyway: As i was testing my code, i noticed that the trigger
> behaves differently depending on whether or not i explicitly use BEGIN and
> COMMIT, even though there is only 1 query in the transaction.
> I am wondering if this is a bug in postgresql?

I think the issue is that you marked the trigger as STABLE.  That causes
it to use the calling query's snapshot so it doesn't see the updates,
if it's fired during the delete query and not during the subsequent
COMMIT.  If I remove the STABLE label then it works as you expect.

This is probably under-documented but I'm not sure that it should be
considered a bug.

The trigger seems a bit broken besides that, in that the comments claim it
has something to do with the OLD row's id field(s) but the query is not in
fact taking that into account.

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <17896.1567085735@sss.pgh.pa.us>
Permalink:  ../17896.1567085735@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17896.1567085735@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, willybas@gmail.com
  Subject: Re: implicit transaction changes trigger behaviour
  In-Reply-To: <17896.1567085735@sss.pgh.pa.us>
  References: <CAHnozThxLxCanw=UjSnRaefg20SP+HUq_y3-u0+gP3n8yRti_Q@mail.gmail.com> <17896.1567085735@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox