From: Heikki Linnakangas Date: Tue, 2 Aug 2011 07:47:17 +0000 (+0300) Subject: Avoid integer overflow when LIMIT + OFFSET >= 2^63. X-Git-Tag: REL9_2_BETA1~1338 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=89df948ec26679e09f71baf6bbb9b06f9d329712;p=postgresql Avoid integer overflow when LIMIT + OFFSET >= 2^63. This fixes bug #6139 reported by Hitoshi Harada. --- diff --git a/src/backend/executor/nodeLimit.c b/src/backend/executor/nodeLimit.c index 85d1a6e27f..f2d356d1f1 100644 --- a/src/backend/executor/nodeLimit.c +++ b/src/backend/executor/nodeLimit.c @@ -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;