Re: event trigger should provide more details

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: Lian Jiang <jiangok2006(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: event trigger should provide more details
Date: 2023-05-30 21:42:37
Message-ID: 1154091521.527097.1685482957284@office.mailbox.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On 30/05/2023 22:23 CEST Lian Jiang <jiangok2006(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lian Jiang 2023-05-30 22:28:22 Re: event trigger should provide more details
Previous Message David Rowley 2023-05-30 21:14:20 Re: Pg 16: will pg_dump & pg_restore be faster?