Re: [PATCH] Logical decoding of TRUNCATE

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>
Cc: Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Logical decoding of TRUNCATE
Date: 2018-01-18 16:48:37
Message-ID: CANP8+jJzf-K0AnN2X=xpoaFq+Ncdjzbk6b4=JrMJoiMbgO39YQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On 17 January 2018 at 17:07, Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com> wrote:

> Things I am less convinced about:
>
> The patch will cascade truncation on downstream if cascade was specified
> on the upstream, that can potentially be dangerous and we either should
> not do it and only truncate the tables which were truncated upstream
> (but without restricting because of FKs), leaving the data inconsistent
> on downstream (like we do already with DELETE or UPDATE). Or maybe make
> it into either subscription or publication option so that user can chose
> the behaviour here as I am sure some people will want it to cascade (but
> the default should still IMHO be to not cascade as that's safer).

I agree the default should be to NOT cascade.

If someone wants cascading as a publication option, that can be added later.

>> + /* logicalrep_rel_close call not needed, because ExecuteTruncateGuts
>> + * already closes the relations. Setting localrel to NULL in the map entry
>> + * is still needed.
>> + */
>> + rel->localrel = NULL;
>
> This is somewhat ugly. Perhaps the ExecuteTruncateGuts should track
> which relations it opened and only close those and the rest should be
> closed by caller? That should also remove the other ugly part which is
> that the ExecuteTruncateGuts modifies the input list. What if caller
> wanted to use those relations it sent as parameter later?

Agreed

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paul Jones 2018-01-18 19:00:46 Possible hang in 10.1 with JSON query over partially indexed partitions
Previous Message Enrico Pirozzi 2018-01-18 16:34:26 Re: Connection type

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-01-18 16:53:01 Re: master make check fails on Solaris 10
Previous Message Simon Riggs 2018-01-18 16:43:39 Re: Logical decoding fast-forward and slot advance