Re: PG 7.2b4 bug? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: PG 7.2b4 bug?
Date
Msg-id 7062.1008623588@sss.pgh.pa.us
Whole thread Raw
In response to Re: PG 7.2b4 bug?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Responses Re: PG 7.2b4 bug?
List pgsql-hackers
Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> However, I'd think:
> "select (select nextval from test_seq) from multiple_rows;"
> should give you different values and doesn't, although
> "select (select nextval from test_seq where i IS NULL or i IS NOT NULL)
>  from multiple_rows;" does give you different values.

In the first case, the subselect is visibly not dependent on the outer
query, so it's evaluated only once; in the second case it has to be
re-evaluated for each row using that row's value of i.  You can see the
difference (InitPlan vs. SubPlan) in the query's EXPLAIN output.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: recursive SQL functions
Next
From: Stephan Szabo
Date:
Subject: Re: PG 7.2b4 bug?