Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaaef7be

Browse files
committed
Hope that execMain.c good merged.
Fix for BEFORE ROW UPDATE triggers: result tuple may be different(due to concurrent update) from one initially produced by top level plan.
1 parent1d41e88 commitaaef7be

File tree

3 files changed

+51
-43
lines changed

3 files changed

+51
-43
lines changed

‎src/backend/commands/trigger.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ voidFreeTriggerDesc(Relation relation);
4242

4343
staticvoidDescribeTrigger(TriggerDesc*trigdesc,Trigger*trigger);
4444
staticHeapTupleGetTupleForTrigger(EState*estate,ItemPointertid,
45-
boolbefore);
45+
TupleTableSlot**newSlot);
4646

4747
externGlobalMemoryCacheCxt;
4848

@@ -664,9 +664,10 @@ ExecBRDeleteTriggers(EState *estate, ItemPointer tupleid)
664664
Trigger**trigger=rel->trigdesc->tg_before_row[TRIGGER_EVENT_DELETE];
665665
HeapTupletrigtuple;
666666
HeapTuplenewtuple=NULL;
667+
TupleTableSlot*newSlot;
667668
inti;
668669

669-
trigtuple=GetTupleForTrigger(estate,tupleid,true);
670+
trigtuple=GetTupleForTrigger(estate,tupleid,&newSlot);
670671
if (trigtuple==NULL)
671672
return false;
672673

@@ -701,7 +702,7 @@ ExecARDeleteTriggers(EState *estate, ItemPointer tupleid)
701702
HeapTupletrigtuple;
702703
inti;
703704

704-
trigtuple=GetTupleForTrigger(estate,tupleid,false);
705+
trigtuple=GetTupleForTrigger(estate,tupleid,NULL);
705706
Assert(trigtuple!=NULL);
706707

707708
SaveTriggerData= (TriggerData*)palloc(sizeof(TriggerData));
@@ -732,12 +733,20 @@ ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
732733
HeapTupletrigtuple;
733734
HeapTupleoldtuple;
734735
HeapTupleintuple=newtuple;
736+
TupleTableSlot*newSlot;
735737
inti;
736738

737-
trigtuple=GetTupleForTrigger(estate,tupleid,true);
739+
trigtuple=GetTupleForTrigger(estate,tupleid,&newSlot);
738740
if (trigtuple==NULL)
739741
returnNULL;
740742

743+
/*
744+
* In READ COMMITTED isolevel it's possible that newtuple
745+
* was changed due to concurrent update.
746+
*/
747+
if (newSlot!=NULL)
748+
intuple=newtuple=ExecRemoveJunk(estate->es_junkFilter,newSlot);
749+
741750
SaveTriggerData= (TriggerData*)palloc(sizeof(TriggerData));
742751
SaveTriggerData->tg_event=
743752
TRIGGER_EVENT_UPDATE |TRIGGER_EVENT_ROW |TRIGGER_EVENT_BEFORE;
@@ -770,7 +779,7 @@ ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
770779
HeapTupletrigtuple;
771780
inti;
772781

773-
trigtuple=GetTupleForTrigger(estate,tupleid,false);
782+
trigtuple=GetTupleForTrigger(estate,tupleid,NULL);
774783
Assert(trigtuple!=NULL);
775784

776785
SaveTriggerData= (TriggerData*)palloc(sizeof(TriggerData));
@@ -794,20 +803,21 @@ ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
794803
externTupleTableSlot*EvalPlanQual(EState*estate,Indexrti,ItemPointertid);
795804

796805
staticHeapTuple
797-
GetTupleForTrigger(EState*estate,ItemPointertid,boolbefore)
806+
GetTupleForTrigger(EState*estate,ItemPointertid,TupleTableSlot**newSlot)
798807
{
799808
Relationrelation=estate->es_result_relation_info->ri_RelationDesc;
800809
HeapTupleDatatuple;
801810
HeapTupleresult;
802811
Bufferbuffer;
803812

804-
if (before)
813+
if (newSlot!=NULL)
805814
{
806815
inttest;
807816

808817
/*
809818
*mark tuple for update
810819
*/
820+
*newSlot=NULL;
811821
tuple.t_self=*tid;
812822
ltrmark:;
813823
test=heap_mark4update(relation,&tuple,&buffer);
@@ -826,13 +836,14 @@ ltrmark:;
826836
elog(ERROR,"Can't serialize access due to concurrent update");
827837
elseif (!(ItemPointerEquals(&(tuple.t_self),tid)))
828838
{
829-
TupleTableSlot*slot=EvalPlanQual(estate,
839+
TupleTableSlot*epqslot=EvalPlanQual(estate,
830840
estate->es_result_relation_info->ri_RangeTableIndex,
831841
&(tuple.t_self));
832842

833-
if (!(TupIsNull(slot)))
843+
if (!(TupIsNull(epqslot)))
834844
{
835845
*tid=tuple.t_self;
846+
*newSlot=epqslot;
836847
gotoltrmark;
837848
}
838849
}

‎src/backend/executor/execMain.c

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.67 1999/01/2910:15:09 vadim Exp $
29+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.68 1999/01/2911:56:00 vadim Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -66,7 +66,7 @@ static void EndPlan(Plan *plan, EState *estate);
6666
staticTupleTableSlot*ExecutePlan(EState*estate,Plan*plan,
6767
CmdTypeoperation,intnumberTuples,ScanDirectiondirection,
6868
DestReceiver*destfunc);
69-
staticvoidExecRetrieve(TupleTableSlot*slot,
69+
staticvoidExecRetrieve(TupleTableSlot*slot,
7070
DestReceiver*destfunc,
7171
EState*estate);
7272
staticvoidExecAppend(TupleTableSlot*slot,ItemPointertupleid,
@@ -170,11 +170,11 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate)
170170
TupleTableSlot*
171171
ExecutorRun(QueryDesc*queryDesc,EState*estate,intfeature,intcount)
172172
{
173-
CmdTypeoperation;
174-
Plan*plan;
173+
CmdTypeoperation;
174+
Plan*plan;
175175
TupleTableSlot*result;
176-
CommandDestdest;
177-
void(*destination) ();
176+
CommandDestdest;
177+
DestReceiver*destfunc;
178178

179179
/******************
180180
*sanity checks
@@ -190,10 +190,19 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, int count)
190190
operation=queryDesc->operation;
191191
plan=queryDesc->plantree;
192192
dest=queryDesc->dest;
193-
destination= (void (*) ())DestToFunction(dest);
193+
destfunc=DestToFunction(dest);
194194
estate->es_processed=0;
195195
estate->es_lastoid=InvalidOid;
196196

197+
/******************
198+
*FIXME: the dest setup function ought to be handed the tuple desc
199+
* for the tuples to be output, but I'm not quite sure how to get that
200+
* info at this point. For now, passing NULL is OK because no existing
201+
* dest setup function actually uses the pointer.
202+
******************
203+
*/
204+
(*destfunc->setup) (destfunc, (TupleDesc)NULL);
205+
197206
switch (feature)
198207
{
199208

@@ -203,15 +212,15 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, int count)
203212
operation,
204213
ALL_TUPLES,
205214
ForwardScanDirection,
206-
destination);
215+
destfunc);
207216
break;
208217
caseEXEC_FOR:
209218
result=ExecutePlan(estate,
210219
plan,
211220
operation,
212221
count,
213222
ForwardScanDirection,
214-
destination);
223+
destfunc);
215224
break;
216225

217226
/******************
@@ -224,7 +233,7 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, int count)
224233
operation,
225234
count,
226235
BackwardScanDirection,
227-
destination);
236+
destfunc);
228237
break;
229238

230239
/******************
@@ -238,14 +247,16 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, int count)
238247
operation,
239248
ONE_TUPLE,
240249
ForwardScanDirection,
241-
destination);
250+
destfunc);
242251
break;
243252
default:
244253
result=NULL;
245254
elog(DEBUG,"ExecutorRun: Unknown feature %d",feature);
246255
break;
247256
}
248257

258+
(*destfunc->cleanup) (destfunc);
259+
249260
returnresult;
250261
}
251262

@@ -756,7 +767,7 @@ ExecutePlan(EState *estate,
756767
CmdTypeoperation,
757768
intnumberTuples,
758769
ScanDirectiondirection,
759-
DestReceiver*destfunc)
770+
DestReceiver*destfunc)
760771
{
761772
JunkFilter*junkfilter;
762773

@@ -941,7 +952,7 @@ lmark:;
941952
{
942953
caseCMD_SELECT:
943954
ExecRetrieve(slot,/* slot containing tuple */
944-
destfunc,/*print function */
955+
destfunc,/*destination's tuple-receiver obj */
945956
estate);/* */
946957
result=slot;
947958
break;
@@ -1024,7 +1035,7 @@ ExecRetrieve(TupleTableSlot *slot,
10241035
*send the tuple to the front end (or the screen)
10251036
******************
10261037
*/
1027-
(*printfunc) (tuple,attrtype);
1038+
(*destfunc->receiveTuple) (tuple,attrtype,destfunc);
10281039
IncrRetrieved();
10291040
(estate->es_processed)++;
10301041
}

‎src/pl/plpgsql/src/gram.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
* procedural language
6666
*
6767
* IDENTIFICATION
68-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/gram.c,v 1.3 1999/01/28 11:50:41 wieck Exp $
68+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/gram.c,v 1.4 1999/01/29 11:56:01 vadim Exp $
6969
*
7070
* This software is copyrighted by Jan Wieck - Hamburg.
7171
*
@@ -414,7 +414,7 @@ static const short yycheck[] = { 21,
414414
152,62
415415
};
416416
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
417-
#line 3 "/usr/share/bison.simple"
417+
#line 3 "/usr/share/misc/bison.simple"
418418

419419
/* Skeleton output parser for bison,
420420
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
@@ -467,16 +467,6 @@ void *alloca ();
467467
#endif/* not GNU C. */
468468
#endif/* alloca not defined. */
469469

470-
#ifdef__cplusplus
471-
extern"C" {
472-
voidyyerror(char*);
473-
intyylex();
474-
};
475-
#else
476-
externvoidyyerror(char*);
477-
externintyylex();
478-
#endif
479-
480470
/* This is the parser code that is written into each bison parser
481471
when the %semantic_parser declaration is not specified in the grammar.
482472
It was written by Richard Stallman by simplifying the hairy parser
@@ -573,13 +563,9 @@ int yydebug;/* nonzero means print parse trace*/
573563
#defineYYMAXDEPTH 10000
574564
#endif
575565

576-
#ifndefYYPARSE_RETURN_TYPE
577-
#defineYYPARSE_RETURN_TYPE int
578-
#endif
579-
580566
/* Prevent warning if -Wstrict-prototypes. */
581567
#ifdef__GNUC__
582-
YYPARSE_RETURN_TYPEyyparse (void);
568+
intyyparse (void);
583569
#endif
584570

585571
#if__GNUC__>1/* GNU C and GNU C++ define this. */
@@ -621,7 +607,7 @@ __yy_memcpy (char *to, char *from, int count)
621607
#endif
622608
#endif
623609

624-
#line 196 "/usr/share/bison.simple"
610+
#line 196 "/usr/share/misc/bison.simple"
625611

626612
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
627613
into yyparse. The argument should have type void *.
@@ -642,7 +628,7 @@ __yy_memcpy (char *to, char *from, int count)
642628
#defineYYPARSE_PARAM_DECL
643629
#endif/* not YYPARSE_PARAM */
644630

645-
YYPARSE_RETURN_TYPE
631+
int
646632
yyparse(YYPARSE_PARAM_ARG)
647633
YYPARSE_PARAM_DECL
648634
{
@@ -1905,7 +1891,7 @@ case 105:
19051891
break;}
19061892
}
19071893
/* the action file gets copied in in place of this dollarsign */
1908-
#line 498 "/usr/share/bison.simple"
1894+
#line 498 "/usr/share/misc/bison.simple"
19091895

19101896
yyvsp-=yylen;
19111897
yyssp-=yylen;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp