diff options
author | Bruce Momjian <bruce@momjian.us> | 2002-11-23 03:59:09 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2002-11-23 03:59:09 +0000 |
commit | 1b7f3cc02d6129b678ab651716c19d2bf8f7f6ab (patch) | |
tree | c9929a24cffcdf4989ca67f3ef42056fe2c2f52e /src/backend/parser | |
parent | ea29b32758bdd293a9b932195db662209bb0ee52 (diff) | |
download | postgresql-1b7f3cc02d6129b678ab651716c19d2bf8f7f6ab.tar.gz postgresql-1b7f3cc02d6129b678ab651716c19d2bf8f7f6ab.zip |
This patch implements FOR EACH STATEMENT triggers, per my email to
-hackers a couple days ago.
Notes/caveats:
- added regression tests for the new functionality, all
regression tests pass on my machine
- added pg_dump support
- updated PL/PgSQL to support per-statement triggers; didn't
look at the other procedural languages.
- there's (even) more code duplication in trigger.c than there
was previously. Any suggestions on how to refactor the
ExecXXXTriggers() functions to reuse more code would be
welcome -- I took a brief look at it, but couldn't see an
easy way to do it (there are several subtly-different
versions of the code in question)
- updated the documentation. I also took the liberty of
removing a big chunk of duplicated syntax documentation in
the Programmer's Guide on triggers, and moving that
information to the CREATE TRIGGER reference page.
- I also included some spelling fixes and similar small
cleanups I noticed while making the changes. If you'd like
me to split those into a separate patch, let me know.
Neil Conway
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/gram.y | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 0b3bb279d57..29cba53f9fc 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.380 2002/11/18 17:12:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.381 2002/11/23 03:59:08 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -1371,7 +1371,7 @@ opt_using: /***************************************************************************** * * QUERY : - * CREATE relname + * CREATE TABLE relname * *****************************************************************************/ @@ -2028,11 +2028,6 @@ CreateTrigStmt: n->before = $4; n->row = $8; memcpy (n->actions, $5, 4); - n->lang = NULL; /* unused */ - n->text = NULL; /* unused */ - n->attr = NULL; /* unused */ - n->when = NULL; /* unused */ - n->isconstraint = FALSE; n->deferrable = FALSE; n->initdeferred = FALSE; @@ -2053,11 +2048,6 @@ CreateTrigStmt: n->before = FALSE; n->row = TRUE; memcpy (n->actions, $6, 4); - n->lang = NULL; /* unused */ - n->text = NULL; /* unused */ - n->attr = NULL; /* unused */ - n->when = NULL; /* unused */ - n->isconstraint = TRUE; n->deferrable = ($10 & 1) != 0; n->initdeferred = ($10 & 2) != 0; @@ -2075,17 +2065,17 @@ TriggerActionTime: TriggerEvents: TriggerOneEvent { - char *e = palloc (4); + char *e = palloc(4); e[0] = $1; e[1] = 0; $$ = e; } | TriggerOneEvent OR TriggerOneEvent { - char *e = palloc (4); + char *e = palloc(4); e[0] = $1; e[1] = $3; e[2] = 0; $$ = e; } | TriggerOneEvent OR TriggerOneEvent OR TriggerOneEvent { - char *e = palloc (4); + char *e = palloc(4); e[0] = $1; e[1] = $3; e[2] = $5; e[3] = 0; $$ = e; } @@ -2102,6 +2092,14 @@ TriggerForSpec: { $$ = $3; } + | /* EMPTY */ + { + /* + * If ROW/STATEMENT not specified, default to + * STATEMENT, per SQL + */ + $$ = FALSE; + } ; TriggerForOpt: @@ -2124,7 +2122,7 @@ TriggerFuncArg: ICONST { char buf[64]; - snprintf (buf, sizeof(buf), "%d", $1); + snprintf(buf, sizeof(buf), "%d", $1); $$ = makeString(pstrdup(buf)); } | FCONST { $$ = makeString($1); } |