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?
Starting from PostgreSQL 9.5, function
pg_event_trigger_ddl_commands()
is available forddl_command_end
event triggers. Using theTAG
filter, it may be used for processing any ALTERed table.object_identity
(orobjid
) may be used to solve the original problem of knowing which table has been ALTERed. As for getting the complete command, it is available, too, but it is of an internal typepg_ddl_command
.outputs:
NOTICE: caught ALTER TABLE event on public.t