1111 *
1212 *
1313 * IDENTIFICATION
14- * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.664 2009/05/27 20:42:29 tgl Exp $
14+ * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.665 2009/06/18 01:27:02 tgl Exp $
1515 *
1616 * HISTORY
1717 * AUTHOR DATE MAJOR EVENT
5353
5454#include " catalog/index.h"
5555#include " catalog/namespace.h"
56+ #include " catalog/pg_trigger.h"
5657#include " commands/defrem.h"
5758#include " nodes/makefuncs.h"
5859#include " nodes/nodeFuncs.h"
@@ -244,7 +245,7 @@ static TypeName *TableFuncTypeName(List *columns);
244245%type <boolean> TriggerActionTime TriggerForSpec opt_trusted opt_restart_seqs
245246%type <str> opt_lancompiler
246247
247- %type <str> TriggerEvents
248+ %type <ival> TriggerEvents TriggerOneEvent
248249%type <value> TriggerFuncArg
249250
250251%type <str> relation_name copy_file_name
@@ -266,7 +267,6 @@ static TypeName *TableFuncTypeName(List *columns);
266267%type <privtarget> privilege_target
267268%type <funwithargs> function_with_argtypes
268269%type <list> function_with_argtypes_list
269- %type <chr> TriggerOneEvent
270270
271271%type <list> stmtblock stmtmulti
272272 OptTableElementList TableElementList OptInherit definition
@@ -3133,7 +3133,7 @@ CreateTrigStmt:
31333133 n->args = $13 ;
31343134 n->before = $4 ;
31353135 n->row = $8 ;
3136- memcpy ( n->actions, $ 5 , 4 ) ;
3136+ n->events = $5 ;
31373137 n->isconstraint = FALSE ;
31383138 n->deferrable = FALSE ;
31393139 n->initdeferred = FALSE ;
@@ -3153,11 +3153,10 @@ CreateTrigStmt:
31533153 n->args = $18 ;
31543154 n->before = FALSE ;
31553155 n->row = TRUE ;
3156- memcpy ( n->actions, $ 6 , 4 ) ;
3156+ n->events = $6 ;
31573157 n->isconstraint = TRUE ;
31583158 n->deferrable = ($10 & 1 ) != 0 ;
31593159 n->initdeferred = ($10 & 2 ) != 0 ;
3160-
31613160 n->constrrel = $9 ;
31623161 $$ = (Node *)n;
31633162 }
@@ -3170,30 +3169,20 @@ TriggerActionTime:
31703169
31713170TriggerEvents :
31723171 TriggerOneEvent
3172+ { $$ = $1 ; }
3173+ | TriggerEvents OR TriggerOneEvent
31733174 {
3174- char *e = palloc(4 );
3175- e[0 ] = $1 ; e[1 ] = ' \0 ' ;
3176- $$ = e;
3177- }
3178- | TriggerOneEvent OR TriggerOneEvent
3179- {
3180- char *e = palloc(4 );
3181- e[0 ] = $1 ; e[1 ] = $3 ; e[2 ] = ' \0 ' ;
3182- $$ = e;
3183- }
3184- | TriggerOneEvent OR TriggerOneEvent OR TriggerOneEvent
3185- {
3186- char *e = palloc(4 );
3187- e[0 ] = $1 ; e[1 ] = $3 ; e[2 ] = $5 ; e[3 ] = ' \0 ' ;
3188- $$ = e;
3175+ if ($1 & $3 )
3176+ yyerror (" duplicate trigger events specified" );
3177+ $$ = $1 | $3 ;
31893178 }
31903179 ;
31913180
31923181TriggerOneEvent :
3193- INSERT { $$ = ' i ' ; }
3194- | DELETE_P { $$ = ' d ' ; }
3195- | UPDATE { $$ = ' u ' ; }
3196- | TRUNCATE { $$ = ' t ' ; }
3182+ INSERT { $$ = TRIGGER_TYPE_INSERT ; }
3183+ | DELETE_P { $$ = TRIGGER_TYPE_DELETE ; }
3184+ | UPDATE { $$ = TRIGGER_TYPE_UPDATE ; }
3185+ | TRUNCATE { $$ = TRIGGER_TYPE_TRUNCATE ; }
31973186 ;
31983187
31993188TriggerForSpec :
0 commit comments