Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit de1dfc1

Browse files
committed
Rearrange code in ExecInitBitmapHeapScan so that we don't initialize the
child plan nodes until we have acquired lock on the relation to scan. The relative order of initialization of plan nodes isn't real important in other cases, but it's critical here because one is supposed to lock a relation before its indexes, not vice versa. The original coding was at least vulnerable to deadlock against DROP INDEX, and perhaps worse things.
1 parent 113ece8 commit de1dfc1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/backend/executor/nodeBitmapHeapscan.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
*
2323
* IDENTIFICATION
24-
* $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.6 2005/11/26 03:03:07 tgl Exp $
24+
* $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.7 2005/12/02 01:29:55 tgl Exp $
2525
*
2626
*-------------------------------------------------------------------------
2727
*/
@@ -508,11 +508,6 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate)
508508
ExecInitExpr((Expr *) node->bitmapqualorig,
509509
(PlanState *) scanstate);
510510

511-
/*
512-
* initialize child nodes
513-
*/
514-
outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate);
515-
516511
#define BITMAPHEAPSCAN_NSLOTS 2
517512

518513
/*
@@ -562,6 +557,15 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate)
562557
ExecAssignResultTypeFromTL(&scanstate->ss.ps);
563558
ExecAssignScanProjectionInfo(&scanstate->ss);
564559

560+
/*
561+
* initialize child nodes
562+
*
563+
* We do this last because the child nodes will open indexscans on our
564+
* relation's indexes, and we want to be sure we have acquired a lock
565+
* on the relation first.
566+
*/
567+
outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate);
568+
565569
/*
566570
* all done.
567571
*/

0 commit comments

Comments
 (0)