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