agora inbox for postgres@postgres.berkeley.edu  
help / color / mirror / Atom feed
From: SRIRAMK@charlie.usd.edu
To: postgres@postgres.Berkeley.EDU
Cc: SRIRAMK@charlie.usd.edu
Subject: Problem in passing parameters to Postgres C functions
Date: Sun, 30 Apr 1995 16:31:25 -0500 (CDT)
Message-ID: <950430163125.12c25@charlie.usd.edu> (raw)

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/



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: postgres@postgres.berkeley.edu
  Cc: SRIRAMK@charlie.usd.edu
  Subject: Re: Problem in passing parameters to Postgres C functions
  In-Reply-To: <950430163125.12c25@charlie.usd.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox