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

From Tom Lane
Subject Re: Variable LIMIT and OFFSET in SELECTs
Date
Msg-id 5387.1195147554@sss.pgh.pa.us
Whole thread Raw
In response to Re: Variable LIMIT and OFFSET in SELECTs  (Sam Mason <sam@samason.me.uk>)
Responses Re: Variable LIMIT and OFFSET in SELECTs  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-general
Sam Mason <sam@samason.me.uk> writes:
> In relational algebra terms, try thinking about what would happen if you
> did something like:

>   SELECT * FROM foo LIMIT val;

> Where the table foo has more than one row (and val had different values
> for each row).  Which row would the database use?  I believe these are
> the semantics Trevor was referring to.

Exactly: if the numbers are coming from within the query then there is
no guarantee that there's a unique value to use.  The numbers can be
variable so long as they come from "outside" the query and so are fixed
over any one query execution.  That includes the case of a subselect
getting its limit from the outer query, for instance ... but not what
the OP was trying to do.

            regards, tom lane

pgsql-general by date:

Previous
From: Steve Atkins
Date:
Subject: Re: PLpgsql debugger question
Next
From: Alvaro Herrera
Date:
Subject: Re: [ADMIN] "global/pg_control": Permission denied