From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ken Tanzer <ken.tanzer@gmail.com>
Cc: PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: Trigger (or something similar) on table rename?
Date: Fri, 16 Feb 2018 19:52:48 -0500
Message-ID: <3385.1518828768@sss.pgh.pa.us> (raw)
In-Reply-To: <CAD3a31VSthX3bW1a9urii1tra1UCd2+9J=zCUW+jj0C9SLVOsQ@mail.gmail.com>
References: <CAD3a31X1VJgH1zE5GuVL0Ws03y7UEHe5mQxar5gv0n3gCJ=Wng@mail.gmail.com>
<28694.1518721313@sss.pgh.pa.us>
<CAD3a31VSthX3bW1a9urii1tra1UCd2+9J=zCUW+jj0C9SLVOsQ@mail.gmail.com>
Ken Tanzer <ken.tanzer@gmail.com> writes:
> Presumably the complete command would let you figure out it's a rename, and
> the old and new tables. But I found this message (
> https://postgrespro.com/list/thread-id/1561932) stating that a
> pg_ddl_command could only be processed in C, not in a procedural language.
> I'm wondering if that just hasn't been implemented yet and is likely to
> change at some point, or if there is some kind of inherent limitation
> involved.
That's basically the missing infrastructure I referred to. The parse tree
data structures are reasonably well-documented internally (look under
src/include/nodes/), but there's not a lot of mechanism in place for
displaying them to high-level code. We do have decent support for
reverse-compiling DML statements (select/insert/update/delete), but not
for utility commands which is what you're interested in.
There's no inherent reason we couldn't get there, it's just that it'd
be a lot of work to get to reasonable coverage, and probably a lot of
code to maintain going forward.
It looks like src/test/modules/test_ddl_deparse/ contains the beginnings
of a facility of this sort ... but it's only test code and doesn't
necessarily have anybody's blessing as to being a good basis for moving
forward.
regards, tom lane
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: tgl@sss.pgh.pa.us, ken.tanzer@gmail.com
Subject: Re: Trigger (or something similar) on table rename?
In-Reply-To: <3385.1518828768@sss.pgh.pa.us>
References: <CAD3a31X1VJgH1zE5GuVL0Ws03y7UEHe5mQxar5gv0n3gCJ=Wng@mail.gmail.com> <28694.1518721313@sss.pgh.pa.us> <CAD3a31VSthX3bW1a9urii1tra1UCd2+9J=zCUW+jj0C9SLVOsQ@mail.gmail.com> <3385.1518828768@sss.pgh.pa.us>
* 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