Adding the optional clause 'AS' in CREATE TRIGGER

Поиск
Список
Период
Сортировка
От Okano, Naoki
Тема Adding the optional clause 'AS' in CREATE TRIGGER
Дата
Msg-id 0B4917A40C80E34BBEC4BE1A7A9AB7E276EEDF@g01jpexmbkw05
обсуждение исходный текст
Ответы Re: Adding the optional clause 'AS' in CREATE TRIGGER
Список pgsql-hackers
Hi, 

I would like to add the following support for a trigger. 
This implementation enables to create a trigger efficiently 
in single command. 

It had been discussed before. The link is as shown below.
https://www.postgresql.org/message-id/CAA-aLv4m%3Df9cc1zcUzM49pE8%2B2NpytUDraTgfBmkTOkMN_wO2w%40mail.gmail.com

Currently, PostgreSQL requires two steps to create a trigger.
1. to create a function.
2. to define a trigger with action specified via already created function.

Supporting 'AS' clause in CREATE TRIGGER syntax will enable the option of 
defining the trigger in single command.
As a bonus, it will be compatible with oracle.

Also, the optional clause 'OR REPLACE' is required as below.
https://www.postgresql.org/message-id/CAA-aLv6KYgVt2CwaRdcnptzWVngEm72Cp4mUFnF-MfeH0gS91g%40mail.gmail.com

Currently, to change the definition of a trigger, trigger needs to 
be dropped first before creating it again with new definition.
To change the definition of a function in CREATE TRIGGER syntax,
trigger needs to be dropped first before creating it again with new definition, too! 
So, we need to add the optional clause 'OR REPLACE'.

Adding the optional clauses 'AS' and 'OR REPLACE' in CREATE TRIGGER syntax gives
the comfort of defining the trigger or redefining the trigger definition 
which contains the function definition in single command. 

Here is the syntax based on the previous discussion.  

CREATE [ OR REPLACE ] [ CONSTRAINT ]  TRIGGER name { BEFORE | AFTER | INSTEAD OF }    { event [ OR ... ] }   ON
table_name  [ FROM referenced_table_name ]   [ NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | INITIALLY
DEFERRED} ]   [ FOR [ EACH ] { ROW | STATEMENT } ]   [ WHEN ( condition ) ]   { EXECUTE PROCEDURE function_name (
arguments)     | AS 'trigger function definition' [ LANGUAGE lang_name ]       [ SET configuration_parameter { TO value
|= value | FROM CURRENT }]   }
 

If you have your opinion on this concept, please give me it. 

Regards, 
Okano Naoki 
Fujitsu  



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Tsunakawa, Takayuki"
Дата:
Сообщение: Re: Patch: Implement failover on libpq connect level.
Следующее
От: "Tsunakawa, Takayuki"
Дата:
Сообщение: Re: Remove the comment on the countereffectiveness of large shared_buffers on Windows