pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Wienhold <ewie@ewie.name>
To: Lian Jiang <jiangok2006@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: event trigger should provide more details
Date: Tue, 30 May 2023 23:42:37 +0200 (CEST)
Message-ID: <1154091521.527097.1685482957284@office.mailbox.org> (raw)
In-Reply-To: <CA+aY8X7=FZmg0V-+5HN+FBRJRgZ4j0TFqknJucetd3uaGnKJMA@mail.gmail.com>
References: <CA+aY8X7=FZmg0V-+5HN+FBRJRgZ4j0TFqknJucetd3uaGnKJMA@mail.gmail.com>

> 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





view thread (4+ messages)  latest in thread

Message-ID: <1154091521.527097.1685482957284@office.mailbox.org>
Permalink:  ../1154091521.527097.1685482957284@office.mailbox.org/
Also on:    postgresql.org/message-id/1154091521.527097.1685482957284@office.mailbox.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ewie@ewie.name, jiangok2006@gmail.com
  Subject: Re: event trigger should provide more details
  In-Reply-To: <1154091521.527097.1685482957284@office.mailbox.org>
  References: <CA+aY8X7=FZmg0V-+5HN+FBRJRgZ4j0TFqknJucetd3uaGnKJMA@mail.gmail.com> <1154091521.527097.1685482957284@office.mailbox.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox