Re: Negative LIMIT and OFFSET?

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Andrew Sullivan" <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Negative LIMIT and OFFSET?
Date: 2007-12-14 04:31:17
Message-ID: b42b73150712132031x66d15799l2e19580f5d37617@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Dec 13, 2007 10:06 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Andrew Sullivan <ajs(at)crankycanuck(dot)ca> writes:
> > On Fri, Dec 14, 2007 at 01:47:23AM +0000, Gregory Stark wrote:
> >> Huh, I was all set to post an example of a useful application of it but then
> >> apparently I'm wrong and it doesn't work:
>
> > I dimly remember some discussion of this issue once before, maybe a year
> > ago. My memory isn't what it was, and I can't find it by trolling archives,
> > but I recall Tom saying that it was dumb, yes, but don't do that, because
> > there's some reason not to change it. I know, helpful search terms R me.
>
> Hmm ... I don't recall much either. The code in nodeLimit.c just
> silently replaces a negative input value by zero. It'd certainly be
> possible to make it throw an error instead, but what the downsides of
> that might be aren't clear.
>
> I guess that on purely philosophical grounds, it's not an unreasonable
> behavior. For example, "LIMIT n" means "output at most n tuples",
> not "output exactly n tuples". So when it outputs no tuples in the face
> of a negative limit, it's meeting its spec. If you want to throw an
> error for negative limit, shouldn't you logically also throw an error
> for limit larger than the actual number of rows produced by the subplan?

for historical record, this comment (subject not directly related to
the OP) was probably this:
http://www.mail-archive.com/pgsql-hackers(at)postgresql(dot)org/msg62562.html

at least if it happened since 10/2004, which is when i started
tracking -hackers in my gmail account (an amazing search tool, btw).

merlin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Conway 2007-12-14 06:23:28 Re: Negative LIMIT and OFFSET?
Previous Message Tom Lane 2007-12-14 03:56:14 Re: Negative LIMIT and OFFSET?