Re: Negative LIMIT and OFFSET? - Mailing list pgsql-hackers

From Simon Riggs
Subject Re: Negative LIMIT and OFFSET?
Date
Msg-id 1197624114.15521.26.camel@ebony.site
Whole thread Raw
In response to Re: Negative LIMIT and OFFSET?  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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



pgsql-hackers by date:

Previous
From: Gregory Stark
Date:
Subject: Re: Negative LIMIT and OFFSET?
Next
From: Markus Schiltknecht
Date:
Subject: Re: [GENERAL] Slow PITR restore