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

From: Alex Hunsaker <badalex(at)gmail(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:44:26
Message-ID: CAFaPBrReNVPn7EeZ2yonFuGiC6CU1mC6Et0Pnz7hCQNcw7V0dA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Aug 2, 2011 at 00:25, Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> wrote:

> db1=# select * from test_xy order by x LIMIT 9223372036854775807 OFFSET 6;
[ ...]

> db1=# select * from test_xy order by x LIMIT pow(2, 63);
> ERROR:  bigint out of range
> ERROR:  bigint out of range
>
> Maybe a parser converts literal unexpectedly?

pow(2, 63) != 9223372036854775807, pow(2, 63) - 1 does :-). On top of
that pow(2, 63) seems to default to the double variant of pow() which
causes rounding issues. You probably want LIMIT pow(2, 63::numeric)-1.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2011-08-02 07:49:05 Re: BUG #6139: LIMIT doesn't return correct result when the value is huge
Previous Message Hitoshi Harada 2011-08-02 06:25:35 BUG #6139: LIMIT doesn't return correct result when the value is huge