pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aleksander Alekseev <a.alekseev@postgrespro.ru>
To: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: 10.0: Logical replication doesn't execute BEFORE UPDATE OF <columns> trigger
Date: Tue, 10 Oct 2017 18:22:51 +0300
Message-ID: <20171010152250.GA30140@e733.localdomain> (raw)
In-Reply-To: <da37a748-0d72-617c-92bd-aa4299dab096@2ndquadrant.com>
References: <20171009141341.GA16999@e733.localdomain>
	<CAD21AoCZg1FLa3vqS3=+HB-j3PCq6Z02DCDm19vSufONd4Wvaw@mail.gmail.com>
	<CAD21AoA_LHYD06qTLjGbE2_L8vp-LDdV1d97WLw=DWf3p=3SLw@mail.gmail.com>
	<da37a748-0d72-617c-92bd-aa4299dab096@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Hi Petr,

> let me start by saying that my view is that this is simply a
> documentation bug. Meaning that I didn't document that it does not work,
> but I also never intended it to work. Main reason is that we can't
> support the semantics of "UPDATE OF" correctly (see bellow). And I think
> it's better to not support something at all rather than making it behave
> differently in different cases.
> 
> Now about the proposed patch, I don't think this is correct way to
> support this as it will only work when either PRIMARY KEY column was
> changed or when REPLICA IDENTITY is set to FULL for the table. And even
> then it will have very different semantics from how it works when the
> row is updated by SQL statement (all non-toasted columns will be
> reported as changed regardless of actually being changed or not).
> 
> The more proper way to do this would be to run data comparison of the
> new tuple and the existing tuple values which a) will have different
> behavior than normal "UPDATE OF" triggers have because we still can't
> tell what columns were mentioned in the original query and b) will not
> exactly help performance (and perhaps c) one can write the trigger to
> behave this way already without impacting all other use-cases).

I personally think that solution proposed by Masahiko is much better
than current behavior. We could document current limitations you've
mentioned and probably add a corresponding warning during execution of
ALTER TABLE ... ENABLE REPLICA TRIGGER. I don't insist on this
particular approach though.

What I really don't like is that PostgreSQL allows to create something
that supposedly should work but in fact doesn't. Such behavior is
obviously a bug. So as an alternative we could just return an error in
response to ALTER TABLE ... ENABLE REPLICA TRIGGER query for triggers
that we know will never be executed.

-- 
Best regards,
Aleksander Alekseev

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (7+ messages)  latest in thread

Message-ID: <20171010152250.GA30140@e733.localdomain>
Permalink:  ../20171010152250.GA30140@e733.localdomain/
Also on:    postgresql.org/message-id/20171010152250.GA30140@e733.localdomain

 · 

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-bugs@postgresql.org
  Cc: a.alekseev@postgrespro.ru, petr.jelinek@2ndquadrant.com, sawada.mshk@gmail.com, pgsql-hackers@postgresql.org
  Subject: Re: 10.0: Logical replication doesn't execute BEFORE UPDATE OF <columns> trigger
  In-Reply-To: <20171010152250.GA30140@e733.localdomain>
  References: <20171009141341.GA16999@e733.localdomain> <CAD21AoCZg1FLa3vqS3=+HB-j3PCq6Z02DCDm19vSufONd4Wvaw@mail.gmail.com> <CAD21AoA_LHYD06qTLjGbE2_L8vp-LDdV1d97WLw=DWf3p=3SLw@mail.gmail.com> <da37a748-0d72-617c-92bd-aa4299dab096@2ndquadrant.com> <20171010152250.GA30140@e733.localdomain>

* 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