]> 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 08:30:38 +0000 (11:30 +0300)
This fixes bug #6139 reported by Hitoshi Harada.

src/backend/executor/nodeLimit.c

index 48fb32d3843c7e3f5d1e62746e30ec822cdf1af8..c1363b4ecf84e8314ca1e3983af0162903d7296f 100644 (file)
@@ -125,7 +125,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;