Re: Adding the optional clause 'AS' in CREATE TRIGGER

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: "Okano, Naoki" <okano(dot)naoki(at)jp(dot)fujitsu(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Adding the optional clause 'AS' in CREATE TRIGGER
Date: 2017-02-08 19:40:42
Message-ID: CA+TgmoZJASE+Tz5L8sru6=Y0zY-p1GmaBUgptsdQVKsZDYxz1Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 7, 2017 at 3:11 AM, Okano, Naoki <okano(dot)naoki(at)jp(dot)fujitsu(dot)com> wrote:
> On Wednesday, November 16, 2016 4:31 PM Okano Naoki wrote:
>> > But in any case it would be a serious mistake to do this without first
>> > implementing CREATE OR REPLACE TRIGGER. I think that's an entirely separate
>> > proposal and you would be well advised to treat it as such.
>> I see. There are more problems than I expected...
>> Let me start with 'OR REPLACE' clause.
> I tried to cretae a patch for CREATE OR REPLACE TRIGGER.
> An example of execution is shown below.
>
> example)
> 1.define a new trigger
> CREATE TRIGGER regular_trigger
> AFTER UPDATE ON table_name
> REFERENCING OLD TABLE AS oldtable_1 NEW TABLE AS newtable_1
> FOR EACH STATEMENT
> EXECUTE PROCEDURE func_1();
> 2.redinfe a trigger in single command
> CREATE OR REPLACE TRIGGER regular_trigger
> AFTER UPDATE OR DELETE ON table_name
> REFERENCING OLD TABLE AS oldtable_2 NEW TABLE AS newtable_2
> FOR EACH ROW
> EXECUTE PROCEDURE func_2();
>
> If the named trigger does not exist.
> a new trigger is also created by using OR REPLACE clause.
> A regular trigger cannot be replaced by a constraint trigger and vice varsa.
> because a constraint trigger has a different role from regular triger.
>
> Please give me feedback.

You should add this to the next CommitFest so it doesn't get missed.

https://commitfest.postgresql.org/

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-02-08 19:54:17 Re: Backport of pg_statistics typos fix
Previous Message Alvaro Herrera 2017-02-08 19:17:38 Re: Press Release Draft - 2016-02-09 Cumulative Update