On 02.08.2011 09:25, Hitoshi Harada wrote:
db1=# select count(*) from test_xy;
count
-------
31
(1 row)
db1=# select * from test_xy order by x LIMIT 9223372036854775807 OFFSET 6;
gid | x | y
-----+--------------------+--------------------
13 | -0.591943957968476 | -0.481611208406305
(1 row)
The bug seems to occur when LIMIT + OFFSET >= 2^63. In ExecLimit
function, we check if current position >= offset + limit, and that
overflows.
I'll commit the attached patch to fix that. Thanks for the report
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
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;
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs