Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group