Skip to content

Commit f00fbad

Browse files
committed
Avoid integer overflow when LIMIT + OFFSET >= 2^63.
This fixes bug #6139 reported by Hitoshi Harada.
1 parent 78e957d commit f00fbad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/executor/nodeLimit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ ExecLimit(LimitState *node)
125125
* the state machine state to record having done so.
126126
*/
127127
if (!node->noCount &&
128-
node->position >= node->offset + node->count)
128+
node->position - node->offset >= node->count)
129129
{
130130
node->lstate = LIMIT_WINDOWEND;
131131
return NULL;

0 commit comments

Comments
 (0)