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

Re: Negative LIMIT and OFFSET?

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Sullivan <ajs(at)crankycanuck(dot)ca>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Negative LIMIT and OFFSET?
Date: 2007-12-14 14:41:49
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Thu, 2007-12-13 at 22:23 -0800, Neil Conway wrote:
> On Thu, 2007-12-13 at 22:06 -0500, Tom Lane wrote:
> > 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 "LIMIT n" means "emit at most n tuples", then a query that produces 0
> rows with n < 0 is arguably violating its spec, since it has produced
> more tuples than the LIMIT specified (0 > n). Interpreted this way, no
> result set can be consistent with a negative limit, so I'd vote for
> throwing an error.

I even found an existing, unused error message called

so here's a patch.

  Simon Riggs

Attachment: error_if_negative.v1.patch
Description: text/x-patch (1.5 KB)

In response to


pgsql-hackers by date

Next:From: Magnus HaganderDate: 2007-12-14 14:45:09
Subject: Re: pgwin32_open returning EINVAL
Previous:From: Peter EisentrautDate: 2007-12-14 14:11:49
Subject: Re: [HACKERS] Is postgres.gif missing in cvs?

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