Re: Variable LIMIT and OFFSET in SELECTs - Mailing list pgsql-general

From Sam Mason
Subject Re: Variable LIMIT and OFFSET in SELECTs
Date
Msg-id 20071116063024.GI1955@frubble.xen.chris-lamb.co.uk
Whole thread Raw
In response to Re: Variable LIMIT and OFFSET in SELECTs  (Richard Huxton <dev@archonet.com>)
Responses Re: Variable LIMIT and OFFSET in SELECTs  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Thu, Nov 15, 2007 at 07:28:17PM +0000, Richard Huxton wrote:
> Reg Me Please wrote:
> >As Sam says I should be able to "put an IMMUTABLE expression into
> >a LIMIT or OFFSET". And under some circumstances (SQL function
> >body) it's true even with VARIABLE expressions like function call
> >arguments.
>
> And you can.
>
> CREATE FUNCTION limfunc() RETURNS integer AS 'SELECT 2' LANGUAGE SQL
> IMMUTABLE;
>
> SELECT * FROM fit LIMIT limfunc();
>  a | b
> ---+----
>  1 | 43
>  2 | 43
> (2 rows)

wow, that's kind of fun isn't it.  I only thought you could put a
constant in there.  Maybe I should have had a look in the grammar/tested
it first!


  Sam

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Common criteria evaluation?
Next
From: Tom Lane
Date:
Subject: Re: Variable LIMIT and OFFSET in SELECTs