Subject: Tuple-Functions on variable tables ?

From: [email-masked] (Wolf-D. Ihlenfeldt)
Date: Fri, 30 Sep 94 13:45:19 jst

I need to make some pretty complicated comparisons between
tuples. The tuples may be from the same or different tables.
I defined a user function, which works fine for the tuples
it is defined for, i.e.

   my_func(class1,class2)
  
works fine if the function is defined as

  define function my_func (language = "c", returntype = bool,
   trusted="t", percall_cpu = "costly!!!")
   arg is (class1,class2) as "/path/myfunc.so"

But how to I formulate a query with
   my_func(class1,class1)
   
or

   my_func(class3,class4)

where class3 and 4 may have a slightly different structure, but do
contain the fields used in the function for the comparison.
I have not found a way to pass classes which are different to
those in the prototype htrough the parser. Is there some way
to do this ? And if this is possible, how about using 
different classes with operators bound to the functio, i.e.

  define operator = (arg1=class1,arg2=class2,procedure=my_func,
  restrict=eqsel,join=eqsel)

??

Any help is appreciated.

WDI

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "[email-masked]"

   If this fails, send mail to "[email-masked]" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================

---

From: [email-masked] (Postgres)
Date: Mon, 17 Oct 94 18:37:28 CDT

On 30 Sep 1994, Wolf-D. Ihlenfeldt writes

> to do this ?

You could do something like

 define function my_func (language = "c", returntype = bool,
   trusted="t", percall_cpu = "costly!!!")
   arg is (class1,class1) as "/path/myfunc.so"

where class1 is a bogus class with no data.  It simply has all the
attributes you want to test.  Then, when you create any real class
that you want to test, you just have it inherit class1.  This ought
to work because C functions will take any class that inherits the
one that it is defined to take.

If you want to get real adventurous, you can use parts of the source
code in your C function ( I recommend looking at the source for
GetAttributeByName() ) to pull in the data for attributes that are
not even inherited.

Sean Steiner
[email-masked]