Re: BUG #14771: "Logical decoding" does not cover the impact of "TRUNCATE TABLE" command

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Euler Taveira <euler(at)timbira(dot)com(dot)br>
Cc: hillel(dot)eilat(at)attunity(dot)com, PostgreSQL mailing lists <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:19:45
Message-ID: CAB7nPqS2NSyhbYz6ov5xBt6NincytdeBQ3BWDULPD3R75G_P4Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Aug 7, 2017 at 3:03 PM, Euler Taveira <euler(at)timbira(dot)com(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2017-08-07 20:21:19 Re: Crash report for some ICU-52 (debian8) COLLATE and work_mem values
Previous Message Tom Lane 2017-08-07 19:29:03 Re: Crash report for some ICU-52 (debian8) COLLATE and work_mem values