Fix thinkos in BRIN summarization
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 3 Nov 2017 19:36:32 +0000 (20:36 +0100)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 3 Nov 2017 19:45:36 +0000 (20:45 +0100)
The previous commit contained a thinko that made a single-range
summarization request process from there to end of table.  Fix by
setting the correct end range point.  Per buildfarm.

src/backend/access/brin/brin.c

index 8636620f6479bef0062ea6b7ce278a4a61e06557..cafc8fe7bea2a36cc77cf5d840aad20ce4d3da48 100644 (file)
@@ -1292,8 +1292,11 @@ brinsummarize(Relation index, Relation heapRel, BlockNumber pageRange,
        if (pageRange == BRIN_ALL_BLOCKRANGES)
                startBlk = 0;
        else
+       {
                startBlk = (pageRange / pagesPerRange) * pagesPerRange;
-       if (startBlk >= heapNumBlocks)
+               heapNumBlocks = Min(heapNumBlocks, startBlk + pagesPerRange);
+       }
+       if (startBlk > heapNumBlocks)
        {
                /* Nothing to do if start point is beyond end of table */
                brinRevmapTerminate(revmap);