X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B1A4014B291A for ; Thu, 12 Aug 2004 04:35:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02254-01 for ; Thu, 12 Aug 2004 07:35:13 +0000 (GMT) Received: from poweredge.attiksystem.ch (adsl-soholight-4-c59-p029.vtx.ch [212.147.59.29]) by svr1.postgresql.org (Postfix) with ESMTP id 40A5214B291F for ; Thu, 12 Aug 2004 04:35:01 -0300 (ADT) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: function expression in FROM may not refer to other relations of same query level X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Date: Thu, 12 Aug 2004 09:35:01 +0200 content-class: urn:content-classes:message Message-ID: <6C0CF58A187DA5479245E0830AF84F420803B7@poweredge.attiksystem.ch> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] function expression in FROM may not refer to other relations of same query level Thread-Index: AcR/vKzA876/qSP7SVGn8U06yFYykQAgRzkw From: "Philippe Lang" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/105 X-Sequence-Number: 18602 > > The problem now is that get_lines is being called twice per line. >=20 > Is get_lines() defined as IMMUTABLE? Should it be? I have tried defining get_lines as "IMMUTABLE", or "WITH (iscachable)", but it keeps on getting called twice per line in the following query... select id, usr, code, (get_lines(code)).line1, (get_lines(code)).line2 from tbl; I wish there was a way to run the query like this: select id, usr, code, CAST(get_lines(code) as lines) from tbl;