diff --git a/src/backend/executor/nodeLimit.c b/src/backend/executor/nodeLimit.c
index 85d1a6e..f2d356d 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;
