Negative LIMIT and OFFSET?

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Negative LIMIT and OFFSET?
Date: 2007-12-14 01:19:01
Message-ID: 1197595141.15521.10.camel@ebony.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm fairly surprised these queries work. Is there some reason why we
support this? April Fools Day? Jules Verne? I'm all for fast queries,
but zero seems like the lowest value we should support...

postgres=# select * from accounts limit -9;
aid | bid | abalance | filler
-----+-----+----------+--------
(0 rows)

Time: 0.330 ms
postgres=# select * from accounts limit -9 offset 45;
aid | bid | abalance | filler
-----+-----+----------+--------
(0 rows)

Time: 0.268 ms
postgres=# select * from accounts limit -9 offset -100000;
aid | bid | abalance | filler
-----+-----+----------+--------
(0 rows)

Time: 0.287 ms

postgres=# select * from accounts limit 0 offset -100000;
aid | bid | abalance | filler
-----+-----+----------+--------
(0 rows)

Time: 0.289 ms

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2007-12-14 01:47:23 Re: Negative LIMIT and OFFSET?
Previous Message Gregory Stark 2007-12-14 01:09:21 Re: [GENERAL] Slow PITR restore