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