Re: Trigger (or something similar) on table rename? - Mailing list pgsql-general

From Tom Lane
Subject Re: Trigger (or something similar) on table rename?
Date
Msg-id 3385.1518828768@sss.pgh.pa.us
Whole thread Raw
In response to Re: Trigger (or something similar) on table rename?  (Ken Tanzer <ken.tanzer@gmail.com>)
List pgsql-general
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


pgsql-general by date:

Previous
From: Ken Tanzer
Date:
Subject: Any hope for more specific error message for "value too long..."?
Next
From: "David G. Johnston"
Date:
Subject: Re: Rationale for PUBLIC having CREATE and USAGE privileges on theschema "public" by default