In a pgsql event trigger on tag ALTER TABLE, I wish to know which table is being altered.
The pg variables do not cover this, nor do the variables exposed by GET STACKED DIAGNOSTICS.
With variables available, is there any way within the trigger function itself to see the text of the SQL command responsible for initiating the function.
for example, if
ALTER TABLE base1 ADD COLUMN col1 int;
were responsible for calling the event trigger, is there any way within the event trigger to see then ALTER TABLE base1 ADD COLUMN col1 int
text itself?
SELECT current_query()
. But it'll only show the top level query, which isn't necessarily what fired the event trigger - say, if you did anALTER TABLE
with a PL/PgSQL function. Event triggers will be extended to add much more information about the command, but are currently very limited in 9.3/9.4 .