From: Andres Freund <andres@anarazel.de>
To: hillel.eilat@attunity.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14771: "Logical decoding" does not cover the impact of "TRUNCATE TABLE" command
Date: Mon, 7 Aug 2017 13:34:32 -0700
Message-ID: <20170807203432.zb4wv2hr34s2mya2@alap3.anarazel.de> (raw)
In-Reply-To: <20170807122030.8422.9419@wrigleys.postgresql.org>
References: <20170807122030.8422.9419@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Hi,
On 2017-08-07 12:20:30 +0000, hillel.eilat@attunity.com wrote:
> From "Logical Decoding" perspective - "TRUNCATE TABLE" is logically
> equivalent to "DELETE FROM TABLE".
It's absolutely not. A DELETE FROM TABLE has to include all the deleted
rows (think of concurrency and servers that don't match), whereas a
truncate doesn't include that. So changing TRUNCATE wouldn't be
appropriate.
> Both affect the contents of the PostgreSQL database identically.
> However - "DELETE FROM TABLE" will be reflected at the target database
> properly - as expected - while "TRUNCATE" will NOT!!.
> "Logical Decoding" aims to cover ALL changes made onto data in a coherent
> fashion.
> "TRUNCATE" stands for a case where change in data contents at PostgreSQL are
> not handled by "Logical Decoding", hence synchronization is not achieved.
> Did I miss something?
> Is it the only case?
Others remarked on this.
> How can one cope with this deficiency?
The best solution imo is to have a TRUNCATE trigger that leads to the
truncation being logged. Either by having a 'ddl commands' table, or by
using wal messages.
Greetings,
Andres Freund
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: andres@anarazel.de, hillel.eilat@attunity.com
Subject: Re: BUG #14771: "Logical decoding" does not cover the impact of "TRUNCATE TABLE" command
In-Reply-To: <20170807203432.zb4wv2hr34s2mya2@alap3.anarazel.de>
References: <20170807122030.8422.9419@wrigleys.postgresql.org> <20170807203432.zb4wv2hr34s2mya2@alap3.anarazel.de>
* 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