X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 2235C9DCB34 for ; Mon, 27 Mar 2006 11:48:30 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93531-04 for ; Mon, 27 Mar 2006 11:48:34 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id EEB799DC873 for ; Mon, 27 Mar 2006 11:48:27 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k2RFmUGY014737; Mon, 27 Mar 2006 10:48:30 -0500 (EST) To: Markus Schaber cc: PostGIS Users Discussion , PostgreSQL SQL List Subject: Re: Problem using set-returning functions In-reply-to: <4427C15C.5070905@logix-tt.com> References: <20060324200036.ED8E52C1503@netnation.refractions.net> <1143278826.44250cea7eccc@web-mail1.uibk.ac.at> <4427BFE4.8050500@logix-tt.com> <4427C15C.5070905@logix-tt.com> Comments: In-reply-to Markus Schaber message dated "Mon, 27 Mar 2006 12:41:32 +0200" Date: Mon, 27 Mar 2006 10:48:30 -0500 Message-ID: <14736.1143474510@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] X-Spam-Score: 0.114 X-Spam-Level: X-Archive-Number: 200603/432 X-Sequence-Number: 24778 Markus Schaber writes: > navteq=# select foo,generate_x(bar) from test; > ERROR: set-valued function called in context that cannot accept a set > CONTEXT: PL/pgSQL function "generate_x" line 5 at return next plpgsql SRFs don't support being called from the SELECT target list, only from a FROM-expression. Your other function is probably written in SQL not plpgsql; SQL functions do support this. plpgsql could probably be fixed if we were really motivated to do so, but I think most people who have looked at it feel we should phase out the capability to call SRFs from a target list, rather than extend it. It's weird and not very semantically sound --- in particular, there's no very sensible definition if there's more than one of them in the target list. See past discussions in the PG archives. regards, tom lane