Provide the OR REPLACE option for CREATE TRIGGER.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 14 Nov 2020 22:05:34 +0000 (17:05 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 14 Nov 2020 22:05:34 +0000 (17:05 -0500)
commit92bf7e2d027466d750b4ac5b026f6f4ac29be881
tree0ec4fdd45c7bf135e11d446110e5ac5013a63ea6
parentdbca94510c9e564708a10a1259f6f1d8ad09862c
Provide the OR REPLACE option for CREATE TRIGGER.

This is mostly straightforward.  However, we disallow replacing
constraint triggers or changing the is-constraint property; perhaps
that can be added later, but the complexity versus benefit tradeoff
doesn't look very good.

Also, no special thought is taken here for whether replacing an
existing trigger should result in changes to queued-but-not-fired
trigger actions.  We just document that if you're surprised by the
results, too bad, don't do that.  (Note that any such pending trigger
activity would have to be within the current session.)

Takamichi Osumi, reviewed at various times by Surafel Temesgen,
Peter Smith, and myself

Discussion: https://postgr.es/m/0DDF369B45A1B44B8A687ED43F06557C010BC362@G01JPEXMBYT03
doc/src/sgml/ref/create_trigger.sgml
src/backend/catalog/index.c
src/backend/commands/tablecmds.c
src/backend/commands/trigger.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/parser/gram.y
src/include/nodes/parsenodes.h
src/test/regress/expected/triggers.out
src/test/regress/sql/triggers.sql