]> granicus.if.org Git - postgresql/commitdiff
When building a bitmap scan, must copy the bitmapqualorig expression tree
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 29 Jan 2006 18:55:55 +0000 (18:55 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 29 Jan 2006 18:55:55 +0000 (18:55 +0000)
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.

src/backend/optimizer/plan/createplan.c

index 0a474fa8ce44ca28d7c2678447516d7172538da6..d5a39d7aa7be4b2ca555816f03295d64d36b3bb3 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.202.2.1 2005/11/22 18:23:10 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.202.2.2 2006/01/29 18:55:55 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -963,6 +963,12 @@ create_bitmap_scan_plan(PlannerInfo *root,
         */
        bitmapqualorig = list_difference_ptr(bitmapqualorig, qpqual);
 
+       /*
+        * Copy the finished bitmapqualorig to make sure we have an independent
+        * copy --- needed in case there are subplans in the index quals
+        */
+       bitmapqualorig = copyObject(bitmapqualorig);
+
        /* Finally ready to build the plan node */
        scan_plan = make_bitmap_heapscan(tlist,
                                                                         qpqual,