For some reason we currently support sub-SELECT expressions only
in WHERE and HAVING clauses, not in the target list of a SELECT.
Does anyone know why this is?

There are a number of places in the planner/optimizer that would need
to be fixed to make it happen, but the changes are utterly trivial
(calling certain transformation routines on the targetlist as well as
for WHERE and HAVING ... probably about a dozen lines total ...).
And a quick look at the executor doesn't show any reason why it would
have a problem, either.  Is there something fundamental that I'm
missing?  If not, why wasn't this done to begin with?

			regards, tom lane

Sun, 29 Aug 1999 13:47:55 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Why not sub-selects in targetlists?
Tom Lane wrote:
> 
> For some reason we currently support sub-SELECT expressions only
> in WHERE and HAVING clauses, not in the target list of a SELECT.
> Does anyone know why this is?
> 
> There are a number of places in the planner/optimizer that would need
> to be fixed to make it happen, but the changes are utterly trivial
> (calling certain transformation routines on the targetlist as well as
> for WHERE and HAVING ... probably about a dozen lines total ...).
> And a quick look at the executor doesn't show any reason why it would
> have a problem, either.  Is there something fundamental that I'm
> missing?  If not, why wasn't this done to begin with?

As usual, I just hadn't time to do more than it's done for
6.3.X -:) Subselects were not in my TODO list, I made base
implementation because of there were many requests for them.

BTW, please don't forget subselects in FROM.

Vadim

Mon, 30 Aug 1999 09:39:50 +0800
Vadim Mikheev <vadim@krs.ru>
Re: [HACKERS] Why not sub-selects in targetlists?
Vadim Mikheev <vadim@krs.ru> writes:
> Tom Lane wrote:
>> For some reason we currently support sub-SELECT expressions only
>> in WHERE and HAVING clauses, not in the target list of a SELECT.
>> Does anyone know why this is?

> As usual, I just hadn't time to do more than it's done for
> 6.3.X -:) Subselects were not in my TODO list, I made base
> implementation because of there were many requests for them.

OK, I'll see about adding the missing transformations in the
planner.  Shouldn't be hard.

> BTW, please don't forget subselects in FROM.

That seems to be a considerably bigger task :-(

			regards, tom lane

Mon, 30 Aug 1999 11:04:12 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] Why not sub-selects in targetlists? 