Re: Stored procedures and "pseudo" fields

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: Lars Erik Thorsplass <thorsplass(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Stored procedures and "pseudo" fields
Date: 2004-08-10 13:44:44
Message-ID: 4118D14C.EA49F8CB@rodos.fzk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Lars Erik Thorsplass wrote:

> On Tue, 20 Jul 2004 09:45:06 -0600, Scott Marlowe <smarlowe(at)qwest(dot)net> wrote:
> > > Kinda like this:
> > >
> > > SELECT *, acl_check( objects.obid, <user_id> ) 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, <user_id> ) AS mode FROM objects
) AS foo WHERE mode > 0;

Regards, Christoph

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff 2004-08-10 14:07:23 Re: Using connection after fork
Previous Message Olivier Guilyardi 2004-08-10 13:44:02 Re: Listing views

Browse pgsql-sql by date

  From Date Subject
Next Message John DeSoi 2004-08-10 14:05:09 sleep function
Previous Message Philippe Lang 2004-08-10 13:09:50 function expression in FROM may not refer to other relations of same query level