Re: PG 7.2b4 bug?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Don Baccus <dhogaza(at)pacifier(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PG 7.2b4 bug?
Date: 2001-12-17 21:36:19
Message-ID: 20011217132948.T53618-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Mon, 17 Dec 2001, Tom Lane wrote:

> Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)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.

I figured that, but I'm not sure whether or not that's a bug of
over-optimizing since I think that it probably *should* give you
different results since it is different each time it's evaluated.
Without checking spec, I'd expect that conceptually the select list
entries are evaluated per row, even if we can avoid that when the
value is certain to be the same, which would mean the result is
incorrect since if it was evaluated per row it would give different
results each time.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-12-17 21:44:47 Re: PG 7.2b4 bug?
Previous Message Philip Warner 2001-12-17 21:25:21 Re: Potential bug in pg_dump ...