Subject: define FUNCTION ..

From: [email-masked] (Bruce Taneja.)
Date: Sun, 26 Jun 1994 00:42:43 -0400 (EDT)

Howdy again !, 

.. haven't got any response to my previous query yet , and
here is another one .. :(

-------------
my  test function in circle.c : (compiled ok..)

bool  test(t, char1)
 TUPLE t;
 char *char1;
{

        BCIRCLE * bca = (BCIRCLE*) GetAttributeByName(t, "a");

  return (char1 == "1") ;  /*return +ve if i/p was 1 */
}
-------------
and the postgres reaction to it:

* 
                 define function test
  (language = "c", returntype = bool)
  arg is (tutorial, char16)
  as "/usr/local/postgres/bcircle.o" \g

Query sent to backend is "define function test   (language = "c", returntype = bool)   arg is (tutorial, char16)   as "/usr/local/postgres/bcircle.o" "
DEFINE
Go 
*           retrieve (tutorial.all)
where test(tutorial, "0") \g

Query sent to backend is "retrieve (tutorial.all) where test(tutorial, "0") "
NOTICE:Jun 26 00:33:32:type mismatch in invocation of function test
WARN:Jun 26 00:33:32:no such attribute or function test

---------------------------

I think postgres does not like the "0" string parameter.. 

Is there any way to pass strings in "quotes" to your
defined function ??  (like my "0" ) ??

----------------------------

thanks .. 
Bruce!

==============================================================================
   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] (Paul M. Aoki)
Date: Sat, 25 Jun 94 22:00:49 -0700

> WARN:Jun 26 00:33:32:no such attribute or function test

does it work when you typecast the constant (i.e., "0"::char16)?
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  [email-masked]
                |  Berkeley, CA 94720-1776      |  ...!uunet!ucbvax!aoki

---

From: Mark Costlow <[email-masked]>
Date: Sun, 26 Jun 1994 09:11:39 -0600

On Sun, 26 Jun 1994 00:42:43 -0400 (EDT),
bbx!mimbres!cs.mtu.edu!aataneja (Bruce Taneja.) said:

Bruce> my  test function in circle.c : (compiled ok..)

Bruce> bool  test(t, char1)
Bruce>  TUPLE t;
Bruce>  char *char1;
Bruce> {

Bruce>         BCIRCLE * bca = (BCIRCLE*) GetAttributeByName(t, "a");

Bruce>   return (char1 == "1") ;  /*return +ve if i/p was 1 */
Bruce> }         ^^^^^^^^^^^^
Bruce> -------------

That's a pointer comparison (comparing a parameter to a string constant).
I think what you want to do is compare the data pointed to by those
pointers:

	return(strcmp(char1, "1") == 0);

Or maybe:

	return (*char1 == '1');

>>Chx

--
Mark Costlow
Southwest Cyberport
[email-masked]