diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-12-02 01:29:55 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-12-02 01:29:55 +0000 |
commit | de1dfc12092de69910405a23260761bf58fa2375 (patch) | |
tree | e84c9d2b7eb10df23c15ddb6587b1b0702132d8a /src/backend/executor/nodeBitmapHeapscan.c | |
parent | 113ece8f3d704cdcf20f2865d1ea8964159ee476 (diff) | |
download | postgresql-de1dfc12092de69910405a23260761bf58fa2375.tar.gz postgresql-de1dfc12092de69910405a23260761bf58fa2375.zip |
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.
Diffstat (limited to 'src/backend/executor/nodeBitmapHeapscan.c')
-rw-r--r-- | src/backend/executor/nodeBitmapHeapscan.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 16b0453023f..37bd42d9d73 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.6 2005/11/26 03:03:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.7 2005/12/02 01:29:55 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -508,11 +508,6 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate) ExecInitExpr((Expr *) node->bitmapqualorig, (PlanState *) scanstate); - /* - * initialize child nodes - */ - outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate); - #define BITMAPHEAPSCAN_NSLOTS 2 /* @@ -563,6 +558,15 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate) ExecAssignScanProjectionInfo(&scanstate->ss); /* + * initialize child nodes + * + * We do this last because the child nodes will open indexscans on our + * relation's indexes, and we want to be sure we have acquired a lock + * on the relation first. + */ + outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate); + + /* * all done. */ return scanstate; |