From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Michel Pelletier <pelletier.michel@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Firing an event trigger for ADD COLUMN?
Date: Mon, 11 May 2020 20:23:05 -0400
Message-ID: <20200512002305.GA28510@alvherre.pgsql> (raw)
In-Reply-To: <CACxu=vL+dbVnzUSa=ZhLj9XfTib5+0HWGcHfSJCrAVN-u8CpPg@mail.gmail.com>
On 2020-May-11, Michel Pelletier wrote:
> Is this asymmetry a bug? I realize these event trigger functions are
> typically written in C, but I'd like to keep this idea contained to a
> plpgsql function and cover as many reversible changes as I can.
Sadly, you cannot obtain all the necessary details using only plpgsql.
The only way is to compile a C extension. There's a very rough,
incomplete skeleton to show how to do this in
src/test/modules/test_ddl_deparse. A much more complete approach, which
was not completed, was used to produce JSON output from the C
structures -- see
https://www.postgresql.org/message-id/20150409161419.GC4369@alvh.no-ip.org
Keep in mind ALTER TABLE is a very sophisticated; you can do things like
ALTER TABLE one ADD COLUMN two INT, DROP COLUMN three, ADD COLUMN four text;
(i.e. do several things in one command) so if you were to use a
simplistic approach, you might end up missing things.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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-general@postgresql.org
Cc: alvherre@2ndquadrant.com, pelletier.michel@gmail.com
Subject: Re: Firing an event trigger for ADD COLUMN?
In-Reply-To: <20200512002305.GA28510@alvherre.pgsql>
References: <CACxu=vL+dbVnzUSa=ZhLj9XfTib5+0HWGcHfSJCrAVN-u8CpPg@mail.gmail.com> <20200512002305.GA28510@alvherre.pgsql>
* 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