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

From: "Hitoshi Harada" <umi(dot)tanuki(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6139: LIMIT doesn't return correct result when the value is huge
Date: 2011-08-02 06:25:35
Message-ID: 201108020625.p726PZr2034481@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 6139
Logged by: Hitoshi Harada
Email address: umi(dot)tanuki(at)gmail(dot)com
PostgreSQL version: 8.2+
Operating system: Any
Description: LIMIT doesn't return correct result when the value is
huge
Details:

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)

db1=# select * from test_xy order by x LIMIT 9223372036854775806 OFFSET 6;
gid | x | y
-----+--------------------+--------------------
13 | -0.591943957968476 | -0.481611208406305
(1 row)

db1=# select * from test_xy order by x LIMIT 9223 OFFSET 6;
gid | x | y
-----+---------------------+---------------------
13 | -0.591943957968476 | -0.481611208406305
12 | -0.577933450087566 | -0.513134851138354
15 | -0.476357267950963 | -0.502626970227671
6 | -0.227670753064799 | 0.32399299474606
8 | -0.220665499124343 | 0.373029772329247
7 | -0.199649737302977 | 0.345008756567426
11 | -0.182136602451839 | 0.281961471103328
10 | -0.115586690017513 | 0.2784588441331
9 | -0.0980735551663747 | 0.197898423817863
16 | 0.0980735551663749 | -0.113835376532399
19 | 0.353765323992995 | 0.180385288966725
18 | 0.413309982486865 | 0.152364273204904
17 | 0.434325744308231 | 0.169877408056042
21 | 0.458844133099825 | 0.145359019264448
20 | 0.486865148861646 | 0.0928196147110332
24 | 1.50963222416813 | -0.0507880910683012
23 | 1.50963222416813 | -0.0928196147110333
27 | 1.55516637478109 | 0.544658493870403
31 | 1.55516637478109 | 0.660245183887916
28 | 1.59369527145359 | 0.737302977232925
29 | 1.64273204903678 | 0.618213660245184
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?

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alex Hunsaker 2011-08-02 07:44:26 Re: BUG #6139: LIMIT doesn't return correct result when the value is huge
Previous Message Craig Ringer 2011-08-01 23:28:32 Re: BUG #6138: Install failed