Fix possible crash with Parallel Bitmap Heap Scan.
authorRobert Haas <rhaas@postgresql.org>
Fri, 13 Oct 2017 18:53:28 +0000 (14:53 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 13 Oct 2017 19:05:14 +0000 (15:05 -0400)
If a Parallel Bitmap Heap scan's chain of leftmost descendents
includes a BitmapOr whose first child is a BitmapAnd, the prior coding
would mistakenly create a non-shared TIDBitmap and then try to perform
shared iteration.

Report by Tomas Vondra.  Patch by Dilip Kumar.

Discussion: http://postgr.es/m/50e89684-8ad9-dead-8767-c9545bafd3b6@2ndquadrant.com

src/backend/optimizer/plan/createplan.c

index 28216629aa4643c06598897c40be0a024b6fa667..0092f7d6fb2e235e703ae1e321c7c16ad792c9d9 100644 (file)
@@ -4926,7 +4926,11 @@ bitmap_subplan_mark_shared(Plan *plan)
        bitmap_subplan_mark_shared(
                                   linitial(((BitmapAnd *) plan)->bitmapplans));
    else if (IsA(plan, BitmapOr))
+   {
        ((BitmapOr *) plan)->isshared = true;
+       bitmap_subplan_mark_shared(
+                                  linitial(((BitmapOr *) plan)->bitmapplans));
+   }
    else if (IsA(plan, BitmapIndexScan))
        ((BitmapIndexScan *) plan)->isshared = true;
    else