Re: [BUGS] BUG #14771: "Logical decoding" does not cover the impactof "TRUNCATE TABLE" command - Mailing list pgsql-bugs

From Euler Taveira
Subject Re: [BUGS] BUG #14771: "Logical decoding" does not cover the impactof "TRUNCATE TABLE" command
Date
Msg-id CAHE3wgiZArC5kPNt3CVRGYA7H5O_WnvjosbFnTxrp+aYCTxtxg@mail.gmail.com
Whole thread Raw
In response to [BUGS] BUG #14771: "Logical decoding" does not cover the impact of "TRUNCATETABLE" command  (hillel.eilat@attunity.com)
Responses Re: [BUGS] BUG #14771: "Logical decoding" does not cover the impactof "TRUNCATE TABLE" command
List pgsql-bugs
2017-08-07 9:20 GMT-03:00  <hillel.eilat@attunity.com>:
> PostgreSQL version: 9.4.4
> Operating system:   Windows 7
> Description:
>
I advise you to use a recent version (10?) because logical decoding
has been improved in the last years.

> I work on a mission of synchronizing data between PostgreSQL database and a
> "foreign" target database of choice.
>
This is not a bug.

> From "Logical Decoding" perspective - "TRUNCATE TABLE" is logically
> equivalent to "DELETE FROM TABLE".
> 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!!.
>
TRUNCATE is a DDL command. DDL commands are not supported (yet) by
logical decoding.

> "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?
> How can one cope with this deficiency?
>
You have at least 4 options:

(i) block TRUNCATE statement (via REVOKE);
(ii) write a plugin using ProcessUtility_hook to block TRUNCATE statement;
(iii) write a plugin using ProcessUtility_hook to convert it into
DELETE FROM table;
(iv) modify postgres to support TRUNCATE (logical) replication.


--   Euler Taveira                                   Timbira -
http://www.timbira.com.br/  PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

pgsql-bugs by date:

Previous
From: hillel.eilat@attunity.com
Date:
Subject: [BUGS] BUG #14771: "Logical decoding" does not cover the impact of "TRUNCATETABLE" command
Next
From: Tom Lane
Date:
Subject: Re: [BUGS] Error of insert Foreign table with postgres_fdw