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 EC4419DC946 for ; Mon, 27 Mar 2006 06:41:24 -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 24309-05 for ; Mon, 27 Mar 2006 06:41:26 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (unknown [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 203159DC863 for ; Mon, 27 Mar 2006 06:41:21 -0400 (AST) Received: from kingfisher.intern.logix-tt.com (T938b.t.pppool.de [89.55.147.139]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 8FE37656CD; Mon, 27 Mar 2006 12:42:01 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id C00D1184ED71E; Mon, 27 Mar 2006 12:41:32 +0200 (CEST) Message-ID: <4427C15C.5070905@logix-tt.com> Date: Mon, 27 Mar 2006 12:41:32 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: PostGIS Users Discussion , PostgreSQL SQL List Subject: Problem using set-returning functions References: <20060324200036.ED8E52C1503@netnation.refractions.net> <1143278826.44250cea7eccc@web-mail1.uibk.ac.at> <4427BFE4.8050500@logix-tt.com> In-Reply-To: <4427BFE4.8050500@logix-tt.com> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] X-Spam-Score: 0.103 X-Spam-Level: X-Archive-Number: 200603/411 X-Sequence-Number: 24757 Hi, I'm cross-posting this to the plpgsql list: We've run into a small problem creating a set-returning function for PostGIS in PostgreSQL 8.1.0: CREATE OR REPLACE FUNCTION generate_x (geom geometry) RETURNS SETOF double precision AS 'DECLARE index integer; BEGIN FOR index IN 1 .. npoints(geom) LOOP RETURN NEXT X(geometryn(geom,index)); END LOOP; END ' LANGUAGE 'plpgsql' IMMUTABLE STRICT; Now, trying to use this function yields the following error: 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 However, it is fine to call other set returning functions in the same context: navteq=# select foo,dump(bar) from test; foo | dump -----+-------------------------------------------------- 42 | ({1},0101000000000000000000F03F0000000000000040) 42 | ({2},010100000000000000000008400000000000001040) 42 | ({3},010100000000000000000014400000000000001840) 23 | ({1},01010000000000000000001C400000000000002040) (4 rows) navteq=# select foo,x(geometryn(bar,generate_series(1,npoints(bar)))) FROM test; foo | x -----+--- 42 | 1 42 | 3 42 | 5 23 | 7 (4 rows) (This third query is equal to what I expected the failing query to do.) The table "test" looks as follows; navteq=# \d test Table "public.test" Column | Type | Modifiers --------+----------+----------- foo | integer | bar | geometry | navteq=# select foo,asText(bar) from test; foo | astext -----+------------------------- 42 | MULTIPOINT(1 2,3 4,5 6) 23 | MULTIPOINT(7 8) (2 rows) I'm shure its a small detail I've blindly ignored, but I'm stuck ATM. Thanks, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org