On Thu, Feb 15, 2018 at 11:01 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Ken Tanzer <ken.tanzer@gmail.com> writes: > Something like a trigger on the table rename would be ideal for my > purposes. Anything like that possible? Thanks!
Recent PG versions have "event triggers" which would serve the purpose. However, the infrastructure for them isn't very fully built out yet. I'm not sure if you could identify a table rename without resorting to writing some C code.
regards, tom lane
Hi, and thanks for the responses. As a follow-up, I see you can use pg_event_trigger_ddl_commands() to get some info. One of the things it returns is a pg_ddl_command ("A complete representation of the command, in internal format. This cannot be output directly, but it can be passed to other functions to obtain different pieces of information about the command.")
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.
Also, is there a link somewhere that does document the pg_ddl_command, in case I did end up trying to work this in C?