|
27 | 27 | *
|
28 | 28 | *
|
29 | 29 | * IDENTIFICATION
|
30 |
| - * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.107 2000/01/26 05:56:21 momjian Exp $ |
| 30 | + * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.108 2000/02/03 00:02:58 tgl Exp $ |
31 | 31 | *
|
32 | 32 | *-------------------------------------------------------------------------
|
33 | 33 | */
|
@@ -596,19 +596,19 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
|
596 | 596 | estate->es_rowMark = NULL;
|
597 | 597 | if (parseTree->rowMark != NULL)
|
598 | 598 | {
|
599 |
| - Relation relation; |
600 |
| - Oid relid; |
601 |
| - RowMark *rm; |
602 | 599 | List *l;
|
603 |
| - execRowMark *erm; |
604 | 600 |
|
605 | 601 | foreach(l, parseTree->rowMark)
|
606 | 602 | {
|
607 |
| - rm = lfirst(l); |
608 |
| - relid = rt_fetch(rm->rti, rangeTable)->relid; |
609 |
| - relation = heap_open(relid, RowShareLock); |
| 603 | + RowMark *rm = lfirst(l); |
| 604 | + Oid relid; |
| 605 | + Relation relation; |
| 606 | + execRowMark *erm; |
| 607 | + |
610 | 608 | if (!(rm->info & ROW_MARK_FOR_UPDATE))
|
611 | 609 | continue;
|
| 610 | + relid = rt_fetch(rm->rti, rangeTable)->relid; |
| 611 | + relation = heap_open(relid, RowShareLock); |
612 | 612 | erm = (execRowMark *) palloc(sizeof(execRowMark));
|
613 | 613 | erm->relation = relation;
|
614 | 614 | erm->rti = rm->rti;
|
@@ -756,6 +756,7 @@ EndPlan(Plan *plan, EState *estate)
|
756 | 756 | {
|
757 | 757 | RelationInfo *resultRelationInfo;
|
758 | 758 | Relation intoRelationDesc;
|
| 759 | + List *l; |
759 | 760 |
|
760 | 761 | /*
|
761 | 762 | * get information from state
|
@@ -796,10 +797,20 @@ EndPlan(Plan *plan, EState *estate)
|
796 | 797 | }
|
797 | 798 |
|
798 | 799 | /*
|
799 |
| - * close the "into" relation if necessary |
| 800 | + * close the "into" relation if necessary, again keeping lock |
800 | 801 | */
|
801 | 802 | if (intoRelationDesc != NULL)
|
802 | 803 | heap_close(intoRelationDesc, NoLock);
|
| 804 | + |
| 805 | + /* |
| 806 | + * close any relations selected FOR UPDATE, again keeping locks |
| 807 | + */ |
| 808 | + foreach(l, estate->es_rowMark) |
| 809 | + { |
| 810 | + execRowMark *erm = lfirst(l); |
| 811 | + |
| 812 | + heap_close(erm->relation, NoLock); |
| 813 | + } |
803 | 814 | }
|
804 | 815 |
|
805 | 816 | /* ----------------------------------------------------------------
|
@@ -926,16 +937,16 @@ lnext: ;
|
926 | 937 | else if (estate->es_rowMark != NULL)
|
927 | 938 | {
|
928 | 939 | List *l;
|
929 |
| - execRowMark *erm; |
930 |
| - Buffer buffer; |
931 |
| - HeapTupleData tuple; |
932 |
| - TupleTableSlot *newSlot; |
933 |
| - int test; |
934 | 940 |
|
935 | 941 | lmark: ;
|
936 | 942 | foreach(l, estate->es_rowMark)
|
937 | 943 | {
|
938 |
| - erm = lfirst(l); |
| 944 | + execRowMark *erm = lfirst(l); |
| 945 | + Buffer buffer; |
| 946 | + HeapTupleData tuple; |
| 947 | + TupleTableSlot *newSlot; |
| 948 | + int test; |
| 949 | + |
939 | 950 | if (!ExecGetJunkAttribute(junkfilter,
|
940 | 951 | slot,
|
941 | 952 | erm->resname,
|
|
0 commit comments