Skip to content

Commit 443a44b

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

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
@@ -120,7 +120,7 @@ ExecLimit(LimitState *node)
120120
* the state machine state to record having done so.
121121
*/
122122
if (!node->noCount &&
123-
node->position >= node->offset + node->count)
123+
node->position - node->offset >= node->count)
124124
{
125125
node->lstate = LIMIT_WINDOWEND;
126126
return NULL;

0 commit comments

Comments
 (0)