Re: [HACKERS] Negative LIMIT and OFFSET?

2008-03-09 Thread Tom Lane
Simon Riggs [EMAIL PROTECTED] writes: On Thu, 2007-12-13 at 22:23 -0800, Neil Conway wrote: 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

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-22 Thread Bruce Momjian
This has been saved for the 8.4 release: http://momjian.postgresql.org/cgi-bin/pgpatches_hold --- Andrew Sullivan wrote: On Sun, Dec 16, 2007 at 12:31:11PM -0500, Tom Lane wrote: Well, I wouldn't advocate

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-16 Thread Andrew Sullivan
On Fri, Dec 14, 2007 at 06:42:24PM -0500, Tom Lane wrote: How do people feel about applying this to 8.3, rather than holding it? To me, this is a feature change, and therefore should be held. A ---(end of broadcast)--- TIP 5: don't forget to

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-16 Thread Tom Lane
Andrew Sullivan [EMAIL PROTECTED] writes: On Fri, Dec 14, 2007 at 06:42:24PM -0500, Tom Lane wrote: How do people feel about applying this to 8.3, rather than holding it? To me, this is a feature change, and therefore should be held. Well, I wouldn't advocate making it in a minor release, but

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-16 Thread Bruce Momjian
Gregory Stark wrote: Simon Riggs [EMAIL PROTECTED] writes: I'm fairly surprised these queries work. Is there some reason why we support this? April Fools Day? Jules Verne? I'm all for fast queries, but zero seems like the lowest value we should support... Huh, I was all set to post

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-16 Thread Tom Lane
Bruce Momjian [EMAIL PROTECTED] writes: Since we got LIMIT/OFFSET from MySQL, would someone tell us how MySQL behaves in these cases? Not very well, at least not in mysql 5.0.45: mysql select * from t limit -2; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-16 Thread Gregory Stark
Tom Lane [EMAIL PROTECTED] writes: mysql select * from t limit 2 offset -2; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2' at line 1 This behavior suggests that they can't even

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-16 Thread Tom Lane
Gregory Stark [EMAIL PROTECTED] writes: Tom Lane [EMAIL PROTECTED] writes: This behavior suggests that they can't even deal with LIMIT/OFFSET values that aren't simple integer literals ... I suppose when they added these features I think they didn't have subqueries, so there wasn't really

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-15 Thread Simon Riggs
On Fri, 2007-12-14 at 18:42 -0500, Tom Lane wrote: Simon Riggs [EMAIL PROTECTED] writes: How do people feel about applying this to 8.3, rather than holding it? One possible objection is that we're past string freeze, but I noted Peter doing some message editorializing as recently as today, so

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-15 Thread Gregory Stark
Tom Lane [EMAIL PROTECTED] writes: Gregory Stark [EMAIL PROTECTED] writes: On Dec 14, 2007 6:42 PM, Tom Lane [EMAIL PROTECTED] wrote: How do people feel about applying this to 8.3, rather than holding it? I think it would have been better to apply before beta. We would have found out if

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-14 Thread Simon Riggs
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

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-14 Thread Gregory Stark
Tom Lane [EMAIL PROTECTED] writes: Jonah H. Harris [EMAIL PROTECTED] writes: Don't we have any similar usability cases in the system like this, where negatives are not allowed only for the sake of it being an insane setting? I'm tired, but I thought we did. Yeah, probably. It's the kind

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-14 Thread Simon Riggs
On Fri, 2007-12-14 at 14:41 +, Simon Riggs wrote: On Thu, 2007-12-13 at 22:23 -0800, Neil Conway wrote: so here's a patch. minor correction -- Simon Riggs 2ndQuadrant http://www.2ndQuadrant.com Index: src/backend/executor/nodeLimit.c

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-14 Thread Simon Riggs
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

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-14 Thread Andrew Sullivan
On Fri, Dec 14, 2007 at 09:02:04AM +, Gregory Stark wrote: Oh, and incidentally the problem with WARNING is that this is DML which could potentially be executing hundreds or thousands of times per minute. A WARNING is effectively an ERROR. Good point. Also, the sort of case where you're

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-14 Thread Andrew Sullivan
On Thu, Dec 13, 2007 at 11:31:17PM -0500, Merlin Moncure wrote: for historical record, this comment (subject not directly related to the OP) was probably this: http://www.mail-archive.com/pgsql-hackers@postgresql.org/msg62562.html Bingo. Thanks! A ---(end of

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-14 Thread Tom Lane
Simon Riggs [EMAIL PROTECTED] writes: I even found an existing, unused error message called ERRCODE_INVALID_LIMIT_VALUE That's a bad idea I think. That code is defined by SQL99. I can't find anyplace that they specify what it should be raised for, but we can be pretty confident that it's not

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-14 Thread Jonah H. Harris
On Dec 14, 2007 6:42 PM, Tom Lane [EMAIL PROTECTED] wrote: How do people feel about applying this to 8.3, rather than holding it? One possible objection is that we're past string freeze, but I noted Peter doing some message editorializing as recently as today, so it would seem a slushy freeze

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-14 Thread Gregory Stark
Jonah H. Harris [EMAIL PROTECTED] writes: On Dec 14, 2007 6:42 PM, Tom Lane [EMAIL PROTECTED] wrote: How do people feel about applying this to 8.3, rather than holding it? One possible objection is that we're past string freeze, but I noted Peter doing some message editorializing as recently

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-14 Thread Tom Lane
Gregory Stark [EMAIL PROTECTED] writes: On Dec 14, 2007 6:42 PM, Tom Lane [EMAIL PROTECTED] wrote: How do people feel about applying this to 8.3, rather than holding it? I think it would have been better to apply before beta. We would have found out if users were going to complain about it.

[HACKERS] Negative LIMIT and OFFSET?

2007-12-13 Thread Simon Riggs
I'm fairly surprised these queries work. Is there some reason why we support this? April Fools Day? Jules Verne? I'm all for fast queries, but zero seems like the lowest value we should support... postgres=# select * from accounts limit -9; aid | bid | abalance | filler

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-13 Thread Gregory Stark
Simon Riggs [EMAIL PROTECTED] writes: I'm fairly surprised these queries work. Is there some reason why we support this? April Fools Day? Jules Verne? I'm all for fast queries, but zero seems like the lowest value we should support... Huh, I was all set to post an example of a useful

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-13 Thread Andrew Sullivan
On Fri, Dec 14, 2007 at 01:47:23AM +, 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

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-13 Thread Jonah H. Harris
On Dec 13, 2007 9:43 PM, Andrew Sullivan [EMAIL PROTECTED] wrote: 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

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-13 Thread Andrew Sullivan
On Thu, Dec 13, 2007 at 10:06:35PM -0500, Tom Lane wrote: 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 Should it be a WARNING? A ---(end of

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-13 Thread Andrew Sullivan
On Thu, Dec 13, 2007 at 10:01:43PM -0500, Jonah H. Harris wrote: Man, maybe my mad Google skillz are not as mad as I thought :( Hey, I worked in a library some years ago, when Google was just a googlet, and I couldn't find it either. It's a dim memory, note. Which could mean artifact. I'm

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-13 Thread Tom Lane
Andrew Sullivan [EMAIL PROTECTED] writes: On Fri, Dec 14, 2007 at 01:47:23AM +, 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

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-13 Thread Jonah H. Harris
On Dec 13, 2007 10:06 PM, Tom Lane [EMAIL PROTECTED] 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

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-13 Thread Tom Lane
Jonah H. Harris [EMAIL PROTECTED] writes: Don't we have any similar usability cases in the system like this, where negatives are not allowed only for the sake of it being an insane setting? I'm tired, but I thought we did. Yeah, probably. It's the kind of thing where the call is close enough

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-13 Thread Merlin Moncure
On Dec 13, 2007 10:06 PM, Tom Lane [EMAIL PROTECTED] wrote: Andrew Sullivan [EMAIL PROTECTED] writes: On Fri, Dec 14, 2007 at 01:47:23AM +, 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

Re: [HACKERS] Negative LIMIT and OFFSET?

2007-12-13 Thread Neil Conway
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