Re: Negative LIMIT and OFFSET?

From: Simon Riggs <simon(at)2ndquadrant(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 09:21:54
Message-ID: 1197624114.15521.26.camel@ebony.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 2007-12-13 at 22:06 -0500, Tom Lane wrote:

> 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.

Not bothered either way, really, just reporting weirdness as it comes.

A calculated LIMIT value that was negative probably indicates an error
in the calculation that the SQL programmer may wish to know about. I had
previously assumed that we would report such errors.

> 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?

No, thats another feature AT LEAST n, which could also be a useful
thing, like an Assert.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Markus Schiltknecht 2007-12-14 09:39:40 Re: [GENERAL] Slow PITR restore
Previous Message Gregory Stark 2007-12-14 09:02:04 Re: Negative LIMIT and OFFSET?