Unix Technical Forum

Re: subselects in the target list

This is a discussion on Re: subselects in the target list within the pgsql Hackers forums, part of the PostgreSQL category; --> On Wed, 2005-02-02 at 23:22 -0500, Tom Lane wrote: > Neil Conway <neilc@samurai.com> writes: > > neilc=# select a, ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 03:35 AM
John Hansen
 
Posts: n/a
Default Re: subselects in the target list

On Wed, 2005-02-02 at 23:22 -0500, Tom Lane wrote:
> Neil Conway <neilc@samurai.com> writes:
> > neilc=# select a, (select * from abc) from abc;
> > ERROR: subquery must return only one column

>
> > Is there a reason we can't treat a subselect in the target list as
> > returning a composite type?

>
> Given the 8.0 infrastructure for unnamed record types it might be
> possible to do that; it was surely never possible before. Whether it's
> a good idea is another question. The syntax you are showing is designed
> to return a scalar. It will (and should) barf on multiple rows as well
> as multiple columns.


Right, the point is, that is does not, if said srf-function is written
in say, C.

However, this is somewhat similar to the WITH LATERAL clause previously
discussed in connection with UNNEST and multisets, so perhaps it's not
such a bad idea after all?

> > For that matter, is this behavior also intentional?

>
> > neilc=# select a, foo_abc2() FROM abc;
> > ERROR: set-valued function called in context that cannot accept a set
> > CONTEXT: PL/pgSQL function "foo_abc2" line 1 at return next

>
> It's an implementation restriction in plpgsql: we didn't make it support
> the old-style SRF API. I'm unconvinced that it's worth fixing
> considering that this whole behavior (SRFs in the targetlist) is
> deprecated.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings

--
John Hansen <john@geeknet.com.au>
GeekNET


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:26 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com