static void DescribeTrigger(TriggerDesc *trigdesc, Trigger *trigger);
static HeapTuple GetTupleForTrigger(EState *estate, ItemPointer tid,
- bool before);
+ TupleTableSlot **newSlot);
extern GlobalMemory CacheCxt;
Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_DELETE];
HeapTuple trigtuple;
HeapTuple newtuple = NULL;
+ TupleTableSlot *newSlot;
int i;
- trigtuple = GetTupleForTrigger(estate, tupleid, true);
+ trigtuple = GetTupleForTrigger(estate, tupleid, &newSlot);
if (trigtuple == NULL)
return false;
HeapTuple trigtuple;
int i;
- trigtuple = GetTupleForTrigger(estate, tupleid, false);
+ trigtuple = GetTupleForTrigger(estate, tupleid, NULL);
Assert(trigtuple != NULL);
SaveTriggerData = (TriggerData *) palloc(sizeof(TriggerData));
HeapTuple trigtuple;
HeapTuple oldtuple;
HeapTuple intuple = newtuple;
+ TupleTableSlot *newSlot;
int i;
- trigtuple = GetTupleForTrigger(estate, tupleid, true);
+ trigtuple = GetTupleForTrigger(estate, tupleid, &newSlot);
if (trigtuple == NULL)
return NULL;
+ /*
+ * In READ COMMITTED isolevel it's possible that newtuple
+ * was changed due to concurrent update.
+ */
+ if (newSlot != NULL)
+ intuple = newtuple = ExecRemoveJunk(estate->es_junkFilter, newSlot);
+
SaveTriggerData = (TriggerData *) palloc(sizeof(TriggerData));
SaveTriggerData->tg_event =
TRIGGER_EVENT_UPDATE | TRIGGER_EVENT_ROW | TRIGGER_EVENT_BEFORE;
HeapTuple trigtuple;
int i;
- trigtuple = GetTupleForTrigger(estate, tupleid, false);
+ trigtuple = GetTupleForTrigger(estate, tupleid, NULL);
Assert(trigtuple != NULL);
SaveTriggerData = (TriggerData *) palloc(sizeof(TriggerData));
extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti, ItemPointer tid);
static HeapTuple
-GetTupleForTrigger(EState *estate, ItemPointer tid, bool before)
+GetTupleForTrigger(EState *estate, ItemPointer tid, TupleTableSlot **newSlot)
{
Relation relation = estate->es_result_relation_info->ri_RelationDesc;
HeapTupleData tuple;
HeapTuple result;
Buffer buffer;
- if (before)
+ if (newSlot != NULL)
{
int test;
/*
* mark tuple for update
*/
+ *newSlot = NULL;
tuple.t_self = *tid;
ltrmark:;
test = heap_mark4update(relation, &tuple, &buffer);
elog(ERROR, "Can't serialize access due to concurrent update");
else if (!(ItemPointerEquals(&(tuple.t_self), tid)))
{
- TupleTableSlot *slot = EvalPlanQual(estate,
+ TupleTableSlot *epqslot = EvalPlanQual(estate,
estate->es_result_relation_info->ri_RangeTableIndex,
&(tuple.t_self));
- if (!(TupIsNull(slot)))
+ if (!(TupIsNull(epqslot)))
{
*tid = tuple.t_self;
+ *newSlot = epqslot;
goto ltrmark;
}
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.67 1999/01/29 10:15:09 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.68 1999/01/29 11:56:00 vadim Exp $
*
*-------------------------------------------------------------------------
*/
static TupleTableSlot *ExecutePlan(EState *estate, Plan *plan,
CmdType operation, int numberTuples, ScanDirection direction,
DestReceiver *destfunc);
-static void ExecRetrieve(TupleTableSlot *slot,
+static void ExecRetrieve(TupleTableSlot *slot,
DestReceiver *destfunc,
EState *estate);
static void ExecAppend(TupleTableSlot *slot, ItemPointer tupleid,
TupleTableSlot *
ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, int count)
{
- CmdType operation;
- Plan *plan;
+ CmdType operation;
+ Plan *plan;
TupleTableSlot *result;
- CommandDest dest;
- void (*destination) ();
+ CommandDest dest;
+ DestReceiver *destfunc;
/******************
* sanity checks
operation = queryDesc->operation;
plan = queryDesc->plantree;
dest = queryDesc->dest;
- destination = (void (*) ()) DestToFunction(dest);
+ destfunc = DestToFunction(dest);
estate->es_processed = 0;
estate->es_lastoid = InvalidOid;
+ /******************
+ * FIXME: the dest setup function ought to be handed the tuple desc
+ * for the tuples to be output, but I'm not quite sure how to get that
+ * info at this point. For now, passing NULL is OK because no existing
+ * dest setup function actually uses the pointer.
+ ******************
+ */
+ (*destfunc->setup) (destfunc, (TupleDesc) NULL);
+
switch (feature)
{
operation,
ALL_TUPLES,
ForwardScanDirection,
- destination);
+ destfunc);
break;
case EXEC_FOR:
result = ExecutePlan(estate,
operation,
count,
ForwardScanDirection,
- destination);
+ destfunc);
break;
/******************
operation,
count,
BackwardScanDirection,
- destination);
+ destfunc);
break;
/******************
operation,
ONE_TUPLE,
ForwardScanDirection,
- destination);
+ destfunc);
break;
default:
result = NULL;
break;
}
+ (*destfunc->cleanup) (destfunc);
+
return result;
}
CmdType operation,
int numberTuples,
ScanDirection direction,
- DestReceiver *destfunc)
+ DestReceiver* destfunc)
{
JunkFilter *junkfilter;
{
case CMD_SELECT:
ExecRetrieve(slot, /* slot containing tuple */
- destfunc, /* print function */
+ destfunc, /* destination's tuple-receiver obj */
estate); /* */
result = slot;
break;
* send the tuple to the front end (or the screen)
******************
*/
- (*printfunc) (tuple, attrtype);
+ (*destfunc->receiveTuple) (tuple, attrtype, destfunc);
IncrRetrieved();
(estate->es_processed)++;
}
* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/gram.c,v 1.3 1999/01/28 11:50:41 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/gram.c,v 1.4 1999/01/29 11:56:01 vadim Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
152, 62
};
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/usr/share/bison.simple"
+#line 3 "/usr/share/misc/bison.simple"
/* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
#endif /* not GNU C. */
#endif /* alloca not defined. */
-#ifdef __cplusplus
-extern "C" {
- void yyerror(char *);
- int yylex();
-};
-#else
- extern void yyerror(char *);
- extern int yylex();
-#endif
-
/* This is the parser code that is written into each bison parser
when the %semantic_parser declaration is not specified in the grammar.
It was written by Richard Stallman by simplifying the hairy parser
#define YYMAXDEPTH 10000
#endif
-#ifndef YYPARSE_RETURN_TYPE
-#define YYPARSE_RETURN_TYPE int
-#endif
-
/* Prevent warning if -Wstrict-prototypes. */
#ifdef __GNUC__
-YYPARSE_RETURN_TYPE yyparse (void);
+int yyparse (void);
#endif
\f
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
#endif
#endif
\f
-#line 196 "/usr/share/bison.simple"
+#line 196 "/usr/share/misc/bison.simple"
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
into yyparse. The argument should have type void *.
#define YYPARSE_PARAM_DECL
#endif /* not YYPARSE_PARAM */
-YYPARSE_RETURN_TYPE
+int
yyparse(YYPARSE_PARAM_ARG)
YYPARSE_PARAM_DECL
{
break;}
}
/* the action file gets copied in in place of this dollarsign */
-#line 498 "/usr/share/bison.simple"
+#line 498 "/usr/share/misc/bison.simple"
\f
yyvsp -= yylen;
yyssp -= yylen;