Proposal - Support for 'OR REPLACE' in 'CREATE TRIGGER' command

From: "Prabakaran, Vaishnavi" <vaishnavip(at)fast(dot)au(dot)fujitsu(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Cc: "Arulappan, Arul Shaji" <arul(at)fast(dot)au(dot)fujitsu(dot)com>, "Boguk, Maksym" <maksymb(at)fast(dot)au(dot)fujitsu(dot)com>
Subject: Proposal - Support for 'OR REPLACE' in 'CREATE TRIGGER' command
Date: 2013-09-10 06:09:11
Message-ID: A09FCFD6831B314F9793FEE2D9615B81138E19@ack0102.au.fjanz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

This is a proposal to implement support for 'OR REPLACE' in 'CREATE
TRIGGER' command as an optional clause.

The aim of this proposal is to present a way to support replace trigger
functionality.

Adding the optional clause 'OR REPLACE' in CREATE TRIGGER syntax gives
users the option of redefining the trigger in single command.

And such support will be helpful for customers when they are migrating
from other RDBMs, which already has this support in-built.

As PostgreSQL supports 'OR REPLACE' in various commands such as CREATE
VIEW, CREATE FUNCTION, CREATE LANGUAGE, CREATE RULE, implementing this
support to 'CREATE TRIGGER' command also will be useful for different
migration/schema upgrade scripts.

[Brief Design]

Brief design of 'OR REPLACE' support in 'CREATE TRIGGER' implementation
is presented below:

- Updating parser rules to support 'OR REPLACE' as an optional clause in
the syntax of 'CREATE TRIGGER' command.

- Support to update existing trigger's system table(pg_trigger) record
with new definition.

- Support to update existing trigger's dependencies(which the trigger
depends on)based on new trigger definition.

- Following the existing system behaviour of other commands that
supports 'OR REPLACE' functionality, any dependent object should not be
dropped while replacing the trigger.

Only identified dependent object is the constraint object, created for
constraint trigger. When the constraint trigger is replaced by regular
trigger, to avoid having constraint object still tagged to regular
trigger, a new condition will be enforced to restrict replacing
constraint trigger with regular trigger and vice-versa. Any attempt to
replace between regular and constraint triggers displays new error
messages.

I can start working on a patch based on the above.

Thanks & Regards,

Vaishnavi

Browse pgsql-hackers by date

  From Date Subject
Next Message Satoshi Nagayasu 2013-09-10 07:37:58 Re: New statistics for WAL buffer dirty writes
Previous Message Amit Kapila 2013-09-10 05:09:08 Re: [PERFORM] encouraging index-only scans