diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-04-26 14:17:13 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-04-26 14:17:44 -0400 |
commit | 7c85aa39fc08df44e1ce67e651bda4cf7e331580 (patch) | |
tree | 52701e88af63dd95acc3f1d9246929acbab03a5e /src/backend/optimizer/path/indxpath.c | |
parent | ba3e4157a7d0c7e963a8b800a30b9789aea6dd96 (diff) | |
download | postgresql-7c85aa39fc08df44e1ce67e651bda4cf7e331580.tar.gz postgresql-7c85aa39fc08df44e1ce67e651bda4cf7e331580.zip |
Fix oversight in recent parameterized-path patch.
bitmap_scan_cost_est() has to be able to cope with a BitmapOrPath, but
I'd taken a shortcut that didn't work for that case. Noted by Heikki.
Add some regression tests since this area is evidently under-covered.
Diffstat (limited to 'src/backend/optimizer/path/indxpath.c')
-rw-r--r-- | src/backend/optimizer/path/indxpath.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 8f0eaf448c6..05530054e13 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -1317,28 +1317,31 @@ path_usage_comparator(const void *a, const void *b) /* * Estimate the cost of actually executing a bitmap scan with a single - * index path (no BitmapAnd, at least not at this level). + * index path (no BitmapAnd, at least not at this level; but it could be + * a BitmapOr). */ static Cost bitmap_scan_cost_est(PlannerInfo *root, RelOptInfo *rel, Path *ipath) { BitmapHeapPath bpath; + Relids required_outer; - /* Must be a simple IndexPath so that we can just copy its param_info */ - Assert(IsA(ipath, IndexPath)); + /* Identify required outer rels, in case it's a parameterized scan */ + required_outer = get_bitmap_tree_required_outer(ipath); /* Set up a dummy BitmapHeapPath */ bpath.path.type = T_BitmapHeapPath; bpath.path.pathtype = T_BitmapHeapScan; bpath.path.parent = rel; - bpath.path.param_info = ipath->param_info; + bpath.path.param_info = get_baserel_parampathinfo(root, rel, + required_outer); bpath.path.pathkeys = NIL; bpath.bitmapqual = ipath; cost_bitmap_heap_scan(&bpath.path, root, rel, bpath.path.param_info, ipath, - get_loop_count(root, PATH_REQ_OUTER(ipath))); + get_loop_count(root, required_outer)); return bpath.path.total_cost; } |