From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Behavior of "OFFSET -1" |
Date: | 2014-07-22 17:26:35 |
Message-ID: | CA+TgmoYYSo_=y8qCQfyp3rKmH1zK04VwGM+N=+U8rXDV5bVO=A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jul 22, 2014 at 12:49 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> 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?
Not I.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | David Fetter | 2014-07-22 17:35:45 | Re: Behavior of "OFFSET -1" |
Previous Message | Robert Haas | 2014-07-22 17:25:50 | Re: Portability issues in TAP tests |