|
26 | 26 | *
|
27 | 27 | *
|
28 | 28 | * IDENTIFICATION
|
29 |
| - * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.269 2006/03/05 15:58:25 momjian Exp $ |
| 29 | + * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.270 2006/04/30 18:30:38 tgl Exp $ |
30 | 30 | *
|
31 | 31 | *-------------------------------------------------------------------------
|
32 | 32 | */
|
@@ -452,6 +452,7 @@ InitPlan(QueryDesc *queryDesc, int eflags)
|
452 | 452 | RelationintoRelationDesc;
|
453 | 453 | booldo_select_into;
|
454 | 454 | TupleDesctupType;
|
| 455 | +ListCell*l; |
455 | 456 |
|
456 | 457 | /*
|
457 | 458 | * Do permissions checks. It's sufficient to examine the query's top
|
@@ -486,7 +487,6 @@ InitPlan(QueryDesc *queryDesc, int eflags)
|
486 | 487 | * parseTree->resultRelations identifies them all
|
487 | 488 | */
|
488 | 489 | ResultRelInfo*resultRelInfo;
|
489 |
| -ListCell*l; |
490 | 490 |
|
491 | 491 | numResultRelations=list_length(resultRelations);
|
492 | 492 | resultRelInfos= (ResultRelInfo*)
|
@@ -549,26 +549,21 @@ InitPlan(QueryDesc *queryDesc, int eflags)
|
549 | 549 | * Have to lock relations selected FOR UPDATE/FOR SHARE
|
550 | 550 | */
|
551 | 551 | estate->es_rowMarks=NIL;
|
552 |
| -estate->es_forUpdate=parseTree->forUpdate; |
553 |
| -estate->es_rowNoWait=parseTree->rowNoWait; |
554 |
| -if (parseTree->rowMarks!=NIL) |
| 552 | +foreach(l,parseTree->rowMarks) |
555 | 553 | {
|
556 |
| -ListCell*l; |
557 |
| - |
558 |
| -foreach(l,parseTree->rowMarks) |
559 |
| -{ |
560 |
| -Indexrti=lfirst_int(l); |
561 |
| -Oidrelid=getrelid(rti,rangeTable); |
562 |
| -Relationrelation; |
563 |
| -ExecRowMark*erm; |
564 |
| - |
565 |
| -relation=heap_open(relid,RowShareLock); |
566 |
| -erm= (ExecRowMark*)palloc(sizeof(ExecRowMark)); |
567 |
| -erm->relation=relation; |
568 |
| -erm->rti=rti; |
569 |
| -snprintf(erm->resname,sizeof(erm->resname),"ctid%u",rti); |
570 |
| -estate->es_rowMarks=lappend(estate->es_rowMarks,erm); |
571 |
| -} |
| 554 | +RowMarkClause*rc= (RowMarkClause*)lfirst(l); |
| 555 | +Oidrelid=getrelid(rc->rti,rangeTable); |
| 556 | +Relationrelation; |
| 557 | +ExecRowMark*erm; |
| 558 | + |
| 559 | +relation=heap_open(relid,RowShareLock); |
| 560 | +erm= (ExecRowMark*)palloc(sizeof(ExecRowMark)); |
| 561 | +erm->relation=relation; |
| 562 | +erm->rti=rc->rti; |
| 563 | +erm->forUpdate=rc->forUpdate; |
| 564 | +erm->noWait=rc->noWait; |
| 565 | +snprintf(erm->resname,sizeof(erm->resname),"ctid%u",rc->rti); |
| 566 | +estate->es_rowMarks=lappend(estate->es_rowMarks,erm); |
572 | 567 | }
|
573 | 568 |
|
574 | 569 | /*
|
@@ -1222,15 +1217,15 @@ lnext:;
|
1222 | 1217 |
|
1223 | 1218 | tuple.t_self=*((ItemPointer)DatumGetPointer(datum));
|
1224 | 1219 |
|
1225 |
| -if (estate->es_forUpdate) |
| 1220 | +if (erm->forUpdate) |
1226 | 1221 | lockmode=LockTupleExclusive;
|
1227 | 1222 | else
|
1228 | 1223 | lockmode=LockTupleShared;
|
1229 | 1224 |
|
1230 | 1225 | test=heap_lock_tuple(erm->relation,&tuple,&buffer,
|
1231 | 1226 | &update_ctid,&update_xmax,
|
1232 | 1227 | estate->es_snapshot->curcid,
|
1233 |
| -lockmode,estate->es_rowNoWait); |
| 1228 | +lockmode,erm->noWait); |
1234 | 1229 | ReleaseBuffer(buffer);
|
1235 | 1230 | switch (test)
|
1236 | 1231 | {
|
@@ -2258,8 +2253,6 @@ EvalPlanQualStart(evalPlanQual *epq, EState *estate, evalPlanQual *priorepq)
|
2258 | 2253 | epqstate->es_param_exec_vals= (ParamExecData*)
|
2259 | 2254 | palloc0(estate->es_topPlan->nParamExec*sizeof(ParamExecData));
|
2260 | 2255 | epqstate->es_rowMarks=estate->es_rowMarks;
|
2261 |
| -epqstate->es_forUpdate=estate->es_forUpdate; |
2262 |
| -epqstate->es_rowNoWait=estate->es_rowNoWait; |
2263 | 2256 | epqstate->es_instrument=estate->es_instrument;
|
2264 | 2257 | epqstate->es_select_into=estate->es_select_into;
|
2265 | 2258 | epqstate->es_into_oids=estate->es_into_oids;
|
|