Return-Path: owner-postman
Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.10/8.6.3) with SMTP id OAA11724 for postgres-redist; Sun, 30 Apr 1995 14:31:31 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199504302131.OAA11724@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost.Berkeley.EDU didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from charlie.usd.edu (charlie.usd.edu [192.55.228.1]) by nobozo.CS.Berkeley.EDU (8.6.10/8.6.3) with SMTP id OAA11714 for <postgres@postgres.berkeley.edu>; Sun, 30 Apr 1995 14:31:29 -0700
From: SRIRAMK@charlie.usd.edu
Date: Sun, 30 Apr 1995 16:31:25 -0500 (CDT)
To: postgres@postgres.Berkeley.EDU
CC: SRIRAMK@charlie.usd.edu
Message-Id: <950430163125.12c25@charlie.usd.edu>
Subject: Problem in passing parameters to Postgres C functions
Resent-To: postgres-redist@postgres.Berkeley.EDU
Resent-Date: Sun, 30 Apr 95 14:31:31 -0700
Resent-XMts: smtp

Hi  Postgressors,

Will very much appreciate if you can help out:

I had defined a  C function called folder_exists . The two parameters
to the function are a classname and a string.

The calling program invokes it as follows: 
------------------------------------------
 
sprintf(buf, "retrieve portal g1(FOLDERS.fldrname) where folder_exists(FOLDERS,
        \"TEST\")");
PQexec(buf);

It led to the following error and core-dumped:

NOTICE:Apr 30 15:40:35:type mismatch in invocation of function folder_exists
WARN:Apr 30 15:40:35:no such attribute or function folder_exists
NOTICE:Apr 30 15:40:35:(transaction aborted): queries ignored until END



The function folder_exists has been defined as follows successfully
------------------------------------------------------------------
define function folder_exists (language = "c", returntype = bool) 
arg is (FOLDERS, char16) as "/home/coyote/postgres/final/folder_exists.o"  \g



The implementation details for the function are as follows:
-------------------------------------------------------------
/* folder_exists.c - A method or function to check the existence
   of a folder */

#include "/home/coyote/postgres/src/backend/tmp/libpq.h"
#include "/home/coyote/postgres/src/backend/utils/builtins.h" 
#include "/home/coyote/postgres/src/backend/tmp/libpq-fe.h" 

bool folder_exists(t,fname)
TUPLE t;
struct varlena *fname;
{
    char   folder_name[100];
    char   msg_id[10];
    bool isnull;
    struct varlena* m;
    struct varlena *v;

    
    v =  (struct varlena *) GetAttributeByName(t,"fldrname",&isnull);
    strcpy(folder_name,v->vl_dat);
    m =  (struct varlena *) GetAttributeByName(t,"msgid",&isnull);
    strcpy(msg_id,m->vl_dat);

    if (!(strcmp(folder_name,fname->vl_dat)) && 
        !(strcmp(msg_id,"0")))
       return (1);
    else
       return (0);
}

Thanks

Sriram Kal

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU".
   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
              URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres/
