From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | hillel(dot)eilat(at)attunity(dot)com |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #14771: "Logical decoding" does not cover the impact of "TRUNCATE TABLE" command |
Date: | 2017-08-07 20:34:32 |
Message-ID: | 20170807203432.zb4wv2hr34s2mya2@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hi,
On 2017-08-07 12:20:30 +0000, hillel(dot)eilat(at)attunity(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2017-08-07 22:00:23 | Re: Crash report for some ICU-52 (debian8) COLLATE and work_mem values |
Previous Message | Peter Geoghegan | 2017-08-07 20:21:19 | Re: Crash report for some ICU-52 (debian8) COLLATE and work_mem values |