Skip to content

Commit 3276e91

Browse files
committed
When building a bitmap scan, must copy the bitmapqualorig expression tree
to avoid sharing substructure with the lower-level indexquals. This is currently only an issue if there are SubPlans in the indexquals, which is uncommon but not impossible --- see bug #2218 reported by Nicholas Vinen. We use the same kluge for indexqual vs indexqualorig in the index scans themselves ... would be nice to clean this up someday.
1 parent 3edec38 commit 3276e91

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/backend/optimizer/plan/createplan.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.206 2006/01/25 20:29:23 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.207 2006/01/29 18:55:48 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -963,6 +963,12 @@ create_bitmap_scan_plan(PlannerInfo *root,
963963
*/
964964
bitmapqualorig = list_difference_ptr(bitmapqualorig, qpqual);
965965

966+
/*
967+
* Copy the finished bitmapqualorig to make sure we have an independent
968+
* copy --- needed in case there are subplans in the index quals
969+
*/
970+
bitmapqualorig = copyObject(bitmapqualorig);
971+
966972
/* Finally ready to build the plan node */
967973
scan_plan = make_bitmap_heapscan(tlist,
968974
qpqual,

0 commit comments

Comments
 (0)