Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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:31:46 +0000 (11:31 +0300)
This fixes bug #6139 reported by Hitoshi Harada.

src/backend/executor/nodeLimit.c

index 1755268211e16a42774eb2242f835cd40ca69258..7e0b98211f4e8f18defb385cea574536396b2c1b 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;