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

From Michael Paquier
Subject Re: [BUGS] BUG #14771: "Logical decoding" does not cover the impactof "TRUNCATE TABLE" command
Date
Msg-id CAB7nPqS2NSyhbYz6ov5xBt6NincytdeBQ3BWDULPD3R75G_P4Q@mail.gmail.com
Whole thread Raw
In response to Re: [BUGS] BUG #14771: "Logical decoding" does not cover the impactof "TRUNCATE TABLE" command  (Euler Taveira <euler@timbira.com.br>)
List pgsql-bugs
On Mon, Aug 7, 2017 at 3:03 PM, Euler Taveira <euler@timbira.com.br> wrote:
> (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;

You need to be careful with some caveats, for example this extension I
wrote some time ago changes TRUNCATE to DELETE queries on-the-fly with
the utility hook:
https://github.com/michaelpq/pg_plugins/tree/master/pg_trunc2del

However you'd need to do more for:
- TRUNCATE CASCADE
- triggers firing on DELETE and TRUNCATE
Still the idea is funny.
-- 
Michael


-- 
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: Tom Lane
Date:
Subject: Re: [BUGS] Crash report for some ICU-52 (debian8) COLLATE and work_mem values
Next
From: Peter Geoghegan
Date:
Subject: Re: [BUGS] Crash report for some ICU-52 (debian8) COLLATE andwork_mem values