Search Postgresql Archives

Re: Is there a way to be notified on the CREATE TABLE execution?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 20, 2018 at 1:02 PM, Alvaro Herrera <alvherre@xxxxxxxxxxxxxxx> wrote:
On 2018-Jun-20, Igor Korot wrote:

> [quote]
> In order to create an event trigger, you must first create a function
> with the special return type event_trigger. This function need not
> (and may not) return a value; the return type serves merely as a
> signal that the function is to be invoked as an event trigger.
> [/quote]
>
> So, the function has to be created and compiled.

​The section talking about C-language event triggers leads with:​

​"""
This section describes the low-level details of the interface to an event trigger function. This information is only needed when writing event trigger functions in C. If you are using a higher-level language then these details are handled for you. In most cases you should consider using a procedural language before writing your event triggers in C. The documentation of each procedural language explains how to write an event trigger in that language. 
"""  ​

​In short, I agree that cursory reading of the main event trigger chapter could ​lead one to conclude that they are implemented in "C"; but all of the relevant information is available in the docs and correctly pointed too and accessible if one reads carefully or looks for it explicitly.  I don't see how it can be much improved simply and there doesn't seem to be enough confusion (or use) to warrant significant effort in that area.


Event trigger functions can be written in plpgsql.  You can use
pg_event_trigger_ddl_commands() in the ddl_command_end event to obtain a
few tidbits about the DDL that was just executed.

​There are a number of examples of a pl/pgsql function returning an "event_trigger" ​pseudo-type: but I cannot locate an official statement that doing so is valid.  I was expecting a paragraph at [1] but it is not there.  Adding one and linking it to the overall event trigger chapter as well as the event trigger section of the pl/pgsql chapter seems warranted.



David J.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux