]> granicus.if.org Git - postgresql/commitdiff
Avoid integer overflow when LIMIT + OFFSET >= 2^63.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 2 Aug 2011 07:47:17 +0000 (10:47 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 2 Aug 2011 07:47:17 +0000 (10:47 +0300)
This fixes bug #6139 reported by Hitoshi Harada.

src/backend/executor/nodeLimit.c

index 85d1a6e27f110df00e6b2ad405ab1624bd56b16d..f2d356d1f182ddff861b95ed3d59bd561408b92b 100644 (file)
@@ -127,7 +127,7 @@ ExecLimit(LimitState *node)
                                 * the state machine state to record having done so.
                                 */
                                if (!node->noCount &&
-                                       node->position >= node->offset + node->count)
+                                       node->position - node->offset >= node->count)
                                {
                                        node->lstate = LIMIT_WINDOWEND;
                                        return NULL;