Re: event trigger should provide more details - Mailing list pgsql-general

From Erik Wienhold
Subject Re: event trigger should provide more details
Date
Msg-id 1154091521.527097.1685482957284@office.mailbox.org
Whole thread Raw
In response to event trigger should provide more details  (Lian Jiang <jiangok2006@gmail.com>)
Responses Re: event trigger should provide more details
List pgsql-general
> On 30/05/2023 22:23 CEST Lian Jiang <jiangok2006@gmail.com> wrote:
>
> I plan to create an event trigger to detect schema change (e.g. add/remove
> a column, change column type), and write it into a separate table (e.g.
> EVENTS). Then a process periodically reads this table to send schema change
> notification. However, the event trigger (https://www.postgresql.org/docs/current/plpgsql-trigger.html)
> (43.10.2. Triggers on Events) does not provide me info such as which table
> is altered, old and new schema. Am I missing something? Thanks very much for
> any hints.

You must use ddl_command_end event triggers[0] and call function
pg_event_trigger_ddl_commands[1] to get info such as altered table and column.

[0] https://www.postgresql.org/docs/current/event-trigger-definition.html
[1] https://www.postgresql.org/docs/current/functions-event-triggers.html

--
Erik



pgsql-general by date:

Previous
From: David Rowley
Date:
Subject: Re: Pg 16: will pg_dump & pg_restore be faster?
Next
From: Lian Jiang
Date:
Subject: Re: event trigger should provide more details