Skip site navigation (1) Skip section navigation (2)

Re: BUG #6139: LIMIT doesn't return correct result when the value is huge

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6139: LIMIT doesn't return correct result when the value is huge
Date: 2011-08-02 07:49:05
Message-ID: 4E37ABF1.5080609@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-bugs
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

Attachment: fix-large-limit+offset.patch
Description: text/x-diff (499 bytes)

In response to

pgsql-bugs by date

Next:From: Steve BoydDate: 2011-08-02 12:01:49
Subject: BUG #6140: PostgreSQL Server Service Not Starting
Previous:From: Alex HunsakerDate: 2011-08-02 07:44:26
Subject: Re: BUG #6139: LIMIT doesn't return correct result when the value is huge

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group