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 A39E6D1B388 for ; Tue, 20 Jul 2004 11:11:30 -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 17231-08 for ; Tue, 20 Jul 2004 14:11:33 +0000 (GMT) Received: from web11.manitu.net (web11.manitu.net [217.11.48.111]) by svr1.postgresql.org (Postfix) with ESMTP id 1EA02D1B387 for ; Tue, 20 Jul 2004 11:11:25 -0300 (ADT) Received: from [62.165.4.166] (dicaprio.akademie1.de [62.165.4.166]) (authenticated) by web11.manitu.net (8.10.2-SOL3/8.10.2) with ESMTP id i6KEBLf19829; Tue, 20 Jul 2004 16:11:21 +0200 Subject: Re: Stored procedures and "pseudo" fields.. From: Markus Bertheau To: Tomasz Myrta Cc: Lars Erik Thorsplass , pgsql-sql@postgresql.org In-Reply-To: <40FD24D1.1090005@klaster.net> References: <7eeb33a040720034319e036c6@mail.gmail.com> <7eeb33a04072006342b5d35a0@mail.gmail.com> <40FD24D1.1090005@klaster.net> Content-Type: text/plain; charset=UTF-8 Message-Id: <1090332676.3241.31.camel@dicaprio.akademie1.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) Date: Tue, 20 Jul 2004 16:11:16 +0200 Content-Transfer-Encoding: quoted-printable 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: 200407/127 X-Sequence-Number: 18379 =D0=92 =D0=92=D1=82=D1=80, 20.07.2004, =D0=B2 15:57, Tomasz Myrta =D0=BF=D0= =B8=D1=88=D0=B5=D1=82: > On 2004-07-20 15:34, U=C5=BCytkownik Lars Erik Thorsplass napisa=C5=82: > > My stored procedure "acl_check()" takes two integers as parameters. > > Param1 is the object id to check acl on, Param 2 is the object id of > > the user currently using the system. The procedure returns a positive > > number (1 or 3 ) if you have some kind of access to the object. As one > > might understand I want the returned value from the acl_check() > > procedure to be a part of the result set. > >=20 > > Kinda like this: > >=20 > > SELECT *, acl_check( objects.obid, ) AS mode FROM objects > > WHERE mode > 0; > >=20 > > This gives me a: ERROR: column "mode" does not exist >=20 > You can't access column output alias in where clause. Instead you have=20 > to use your function twice: >=20 > SELECT *, acl_check( objects.obid, ) AS mode FROM objects > WHERE acl_check( objects.obid, ) > 0; and if you properly marked the function STABLE and I am not mistaken, then PostgreSQL is smart enough to execute the function only once per row. --=20 Markus Bertheau