Re: Variable LIMIT and OFFSET in SELECTs

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Variable LIMIT and OFFSET in SELECTs
Date: 2007-11-16 06:30:25
Message-ID: 20071116063024.GI1955@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-11-16 06:38:30 Re: Variable LIMIT and OFFSET in SELECTs
Previous Message Tom Lane 2007-11-16 05:57:52 Re: Common criteria evaluation?