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:47:44 +0000 (20:47 +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 3e2e4ad4e6c465afbe6e018d122fceadca2ff8e0..4f0ff79cb49e95be182b8f2ba51a4e4c6af07ac0 100644 (file)
@@ -1290,8 +1290,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);