Return-Path: joey
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA02003; Mon, 3 Aug 92 10:18:03 -0700
Message-Id: <9208031718.AA02003@postgres.Berkeley.EDU>
From: joey@postgres.Berkeley.EDU
Subject: Re: Postquel functions in Ver 4
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
In-Reply-To: Your message of "Mon, 03 Aug 92 09:01:15 PDT."
             <9208031601.AA00886@postgres.Berkeley.EDU> 
Date: Mon, 03 Aug 92 10:27:04 -0700
From: joey@postgres.Berkeley.EDU
X-Mts: smtp

>> However the apparently very similar query where you
>> specify hobbies name or children name (set of instance function)
>> in a where clause and you get no instances returned.
>> 
>> retrieve(EMP.name,hobby=EMP.hobbies.name,kid=EMP.children.name,boss=EMP.manager.name)
>> where EMP.children.name="calvin"\g
>> ---------------------------------------------------------
>> | name        | hobby       | kid         | boss        |
>> ---------------------------------------------------------

Using a function returning "setof" in a where clause is not a
wonderful idea right now.  The current semantics of this query is that
a setof function in a where clause will return an arbitrary member of
the set, which produces the behavior you see above (EMP.children.name
is returning "matthew" for EMP mike, not "calvin").  I agree that this
is unintuitive, although note that SQL has similar confusions with
subqueries.  We're designing a cleaner and (hopefully) more intuitive
implementation of sets for V4.1.  Meantime your point is well taken:
beware of using functions returning setof, especially in the where
clause!

>> 
>> retrieve(EMP.name,hobby=EMP.hobbies.name,kid=EMP.children.name,boss=EMP.manager.name)
>> where EMP.hobbies.name="basketball"\g
>> ---------------------------------------------------------
>> | name        | hobby       | kid         | boss        |
>> ---------------------------------------------------------
>> 

This query should have returned a tuple for EMP wei.  This seems to be
a bug.

>> Ive even got some bizarre results out.
>> 
>>  retrieve(EMP.name,hobby=EMP.hobbies.name) where EMP.hobbies.name = 
>> "jamming"\g
>> -----------------------------
>> | name        | hobby       |
>> -----------------------------
>> | jeff        | biking      |
>> -----------------------------
>> 

This is decidedly a bug!!

>> This distinction between the types of postquel functions may be what
>> was intended and I know the functions have plural names,
>> hobbies and children rather than hobby and child, but Im worried that
>> users could be confused by this situation.
>> 

Again, point well taken.  Postquel function users be warned!  And
thanks for pointing out the bugs.

Joe Hellerstein
