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 441B914B280B for ; Tue, 10 Aug 2004 10:45:05 -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 83239-08 for ; Tue, 10 Aug 2004 13:44:56 +0000 (GMT) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by svr1.postgresql.org (Postfix) with SMTP id 2128214B27FC for ; Tue, 10 Aug 2004 10:44:49 -0300 (ADT) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Tue Aug 10 15:44:50 2004 +0200 Received: from rodos.fzk.de (resy6.fzk.de [141.52.68.10]) by resy5.fzk.de (8.12.7/8.12.7/SuSE Linux 0.6) with ESMTP id i7ADiksK011769; Tue, 10 Aug 2004 15:44:46 +0200 Message-ID: <4118D14C.EA49F8CB@rodos.fzk.de> Date: Tue, 10 Aug 2004 15:44:44 +0200 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: Lars Erik Thorsplass , pgsql-sql@postgresql.org Subject: Re: Stored procedures and "pseudo" fields References: <7eeb33a040720034319e036c6@mail.gmail.com> <1090338306.709.25.camel@localhost.localdomain> <7eeb33a040720150320bf5eed@mail.gmail.com> Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS - amavis-milter (http://www.amavis.org/) 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/71 X-Sequence-Number: 18568 Lars Erik Thorsplass wrote: > On Tue, 20 Jul 2004 09:45:06 -0600, Scott Marlowe wrote: > > > Kinda like this: > > > > > > SELECT *, acl_check( objects.obid, ) AS mode FROM objects > > > WHERE mode > 0; > > > > Here's the problem. In order to do the select, the query first needs to > > run the where clause. I.e.: > > > > select a as test from table where a > 50; > > > > works, but > > > > select a as test from table where test > 50; > > > > fails. The reason is that when the where clause fires first, there IS > > no test yet, as it hasn't been materialized. what you need to do is: > > > > select custom_function(a,b) from table where custom_function(a,b) > 0; > > > > > > Thanks for clearing that up. I just hoped there was some magic I could > sprinkle on my query to get away from the extra overhead of running > the procedure twice :) > > Best regards.. > > L.E.Thorsplass > Pretty late, I know, but just for the record, AFAICS there is this magic as SELECT * FROM ( SELECT *, acl_check( objects.obid, ) AS mode FROM objects ) AS foo WHERE mode > 0; Regards, Christoph