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 F1B23D1B182 for ; Tue, 20 Jul 2004 19:03:35 -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 53268-09 for ; Tue, 20 Jul 2004 22:03:35 +0000 (GMT) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.207]) by svr1.postgresql.org (Postfix) with SMTP id 1C34CD1B178 for ; Tue, 20 Jul 2004 19:03:31 -0300 (ADT) Received: by mproxy.gmail.com with SMTP id c3so34784rnb for ; Tue, 20 Jul 2004 15:03:32 -0700 (PDT) Received: by 10.38.164.68 with SMTP id m68mr157925rne; Tue, 20 Jul 2004 15:03:32 -0700 (PDT) Message-ID: <7eeb33a040720150320bf5eed@mail.gmail.com> Date: Wed, 21 Jul 2004 00:03:32 +0200 From: Lars Erik Thorsplass To: pgsql-sql@postgresql.org Subject: Re: [GENERAL] Stored procedures and "pseudo" fields.. In-Reply-To: <1090338306.709.25.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <7eeb33a040720034319e036c6@mail.gmail.com> <1090338306.709.25.camel@localhost.localdomain> 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/132 X-Sequence-Number: 18384 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