From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Igor Korot <ikorot01@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: How to watch for schema changes
Date: Mon, 9 Jul 2018 14:38:05 -0700
Message-ID: <7faddf4c-3a58-d7f6-cef8-c65098fc16f5@aklaver.com> (raw)
In-Reply-To: <CA+FnnTyz5j=k_csZKr+NnHYgFN8HUaZo3Of_8eX1fYqW-B55LA@mail.gmail.com>
References: <CA+FnnTxqScf6mDw_7HLMfu7YTagPrsYUw-bc=OKsBQ0TqprvEA@mail.gmail.com>
<d17c5c84-2988-8536-21c4-17ce9a9ef18c@aklaver.com>
<CA+FnnTyNceWUR7+rDdOgbNfzM-ZyY-YQiBG8f9ATiceBCOs8qw@mail.gmail.com>
<7fc929ec-8e34-5824-6511-d1dd1188434f@aklaver.com>
<CA+FnnTyz5j=k_csZKr+NnHYgFN8HUaZo3Of_8eX1fYqW-B55LA@mail.gmail.com>
On 07/09/2018 01:49 PM, Igor Korot wrote:
> Hi, Adrian
>
> On Tue, Jul 3, 2018 at 1:24 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
>> On 07/03/2018 11:15 AM, Igor Korot wrote:
>>>
>>> Adrian,
>>>
>>> On Tue, Jul 3, 2018 at 12:32 PM, Adrian Klaver
>>> <adrian.klaver@aklaver.com> wrote:
>>>>
>>>> On 07/03/2018 10:21 AM, Igor Korot wrote:
>>>>>
>>>>>
>>>>> Hi, ALL,
>>>>> Is there any trigger or some other means I can do on the server
>>>>> which will watch for CREATE/ALTER/DROP TABLE command and after
>>>>> successful
>>>>> execution of those will issue a NOTIFY statement?
>>>>
>>>>
>>>>
>>>> https://www.postgresql.org/docs/10/static/event-triggers.html
>>>
>>>
>>> According to the documentation the lowest version it supports is 9.3.
>>> Anything prior to that?
>>>
>>> I'm working with OX 10.8 and it has 9.1 installed.
>>
>> 9.1 went EOL almost two years ago. The oldest supported version is 9.3,
>> though it will go EOL this September:
>>
>> https://www.postgresql.org/support/versioning/
>>
>> Are you forced to work with 9.1 or can you use something from here:
>>
>> https://www.postgresql.org/download/macosx/
>>
>> to get a newer version? FYI that will be a major upgrade so will require a
>> dump/restore or use of pg_upgrade.
>
> Just a thought...
> Is it possible to create a trigger for a system table? Or this
> operation is restricted
Easy enough to test. As postgres super user:
test_(postgres)# create trigger info_test before insert on pg_class
execute procedure ts_update();
ERROR: permission denied: "pg_class" is a system catalog
> for when the server is actually being set-up?
>
> Successful "CREATE TABLE..." statement creates a row inside the
> information_schema.tables
> so if I can create a trigger after this record is inserted or deleted
> that should be fine.
>
> Thank you.
>
>>
>>>
>>> And a second question - how do I work with it?
>>> I presume that function will have to be compiled in its own module
>>> (either dll, so or dylib).
>>> But then from the libpq interface how do I call it?
>>
>>
>> It can use functions written in PL languages. See below:
>>
>> https://www.postgresql.org/docs/10/static/sql-createeventtrigger.html
>>
>> for an example written in plpgsql.
>>
>>
>>
>>
>>
>>>
>>> Thank you.
>>>
>>>>
>>>>>
>>>>> Thank you.
>>>>>
>>>>
>>>>
>>>> --
>>>> Adrian Klaver
>>>> adrian.klaver@aklaver.com
>>
>>
>>
>> --
>> Adrian Klaver
>> adrian.klaver@aklaver.com
--
Adrian Klaver
adrian.klaver@aklaver.com
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: adrian.klaver@aklaver.com, ikorot01@gmail.com
Subject: Re: How to watch for schema changes
In-Reply-To: <7faddf4c-3a58-d7f6-cef8-c65098fc16f5@aklaver.com>
References: <CA+FnnTxqScf6mDw_7HLMfu7YTagPrsYUw-bc=OKsBQ0TqprvEA@mail.gmail.com> <d17c5c84-2988-8536-21c4-17ce9a9ef18c@aklaver.com> <CA+FnnTyNceWUR7+rDdOgbNfzM-ZyY-YQiBG8f9ATiceBCOs8qw@mail.gmail.com> <7fc929ec-8e34-5824-6511-d1dd1188434f@aklaver.com> <CA+FnnTyz5j=k_csZKr+NnHYgFN8HUaZo3Of_8eX1fYqW-B55LA@mail.gmail.com> <7faddf4c-3a58-d7f6-cef8-c65098fc16f5@aklaver.com>
* 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