Behavior of "OFFSET -1"
Before 9.3, you got an error from this:
regression=# select * from tenk1 offset -1;
ERROR: OFFSET must not be negative
But 9.3 and up ignore the negative OFFSET. This seems to be a thinko in
my commit 1a1832eb. limit_needed() thinks it can discard the Limit plan
node altogether, which of course prevents nodeLimit.c from complaining:
/* Executor would treat less-than-zero same as zero */
if (offset > 0)
return true; /* OFFSET with a positive value */
I don't recall the reasoning behind that comment for sure, but I imagine
I examined the behavior of ExecLimit() and failed to notice that there
was an error check in recompute_limits().
This seems to me to be a clear bug: we should reinstate the former
behavior by tightening this check so it only discards OFFSET with a
constant value of exactly 0. Anyone think differently?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Tue, Jul 22, 2014 at 12:49 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Before 9.3, you got an error from this:
regression=# select * from tenk1 offset -1;
ERROR: OFFSET must not be negativeBut 9.3 and up ignore the negative OFFSET. This seems to be a thinko in
my commit 1a1832eb. limit_needed() thinks it can discard the Limit plan
node altogether, which of course prevents nodeLimit.c from complaining:/* Executor would treat less-than-zero same as zero */
if (offset > 0)
return true; /* OFFSET with a positive value */I don't recall the reasoning behind that comment for sure, but I imagine
I examined the behavior of ExecLimit() and failed to notice that there
was an error check in recompute_limits().This seems to me to be a clear bug: we should reinstate the former
behavior by tightening this check so it only discards OFFSET with a
constant value of exactly 0. Anyone think differently?
Not I.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Tue, Jul 22, 2014 at 12:49:37PM -0400, Tom Lane wrote:
Before 9.3, you got an error from this:
regression=# select * from tenk1 offset -1;
ERROR: OFFSET must not be negative
That seems eminently sane, and should continue to error out, IM.
The only circumstance I can imagine where this could be argued not to
be is just casuistry, namely LIMIT m OFFSET -n might be argued to mean
LIMIT m-n.
Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers