Re: How to get a notification

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Igor Korot <ikorot01(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How to get a notification
Date: 2025-02-07 17:07:35
Message-ID: bf759988-5f40-4280-855e-2d0cbe2f41b0@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/5/25 23:21, Igor Korot wrote:
> Hi, ALL,
> In my code I'm running following:
>
> queries.push_back( L"CREATE FUNCTION
> __watch_schema_changes() RETURNS event_trigger LANGUAGE plpgsql AS $$
> BEGIN NOTIFY tg_tag; END; $$;" );
> queries.push_back( L"CREATE EVENT TRIGGER
> schema_change_notify ON ddl_command_end WHEN TAG IN(\'CREATE TABLE\',
> \'ALTER TABLE\', \'DROP TABLE\', \'CREATE INDEX\', \'DROP INDEX\')
> EXECUTE PROCEDURE __watch_schema_changes();" );
>
> My questions are:
> 1 Is there a better way to get notification about CREATE/ALTER/DROP TABLE?

An alternate solution:

https://www.pgaudit.org/

Whether it is better or not is something you will need to decide.

> 2. How do I receive notification abut the event with the object name?

Use information from here?:

https://www.postgresql.org/docs/current/functions-event-triggers.html#PG-EVENT-TRIGGER-DDL-COMMAND-END-FUNCTIONS

>
> Thank you.
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert Leach 2025-02-07 18:20:16 Re: How to perform a long running dry run transaction without blocking
Previous Message Adrian Klaver 2025-02-07 17:00:52 Re: How to perform a long running dry run transaction without blocking