ERROR: could not find function - Mailing list pgsql-general

From vishal saberwal
Subject ERROR: could not find function
Date
Msg-id 3e74dc250512121008t1c7939fel72319bc18ed0fbbc@mail.gmail.com
Whole thread Raw
Responses Re: ERROR: could not find function
Re: ERROR: could not find function
List pgsql-general
hi all,
I am having problems creating functions. Though i can still replace the already existing functions that i had created a while back in postgres 7.4.5 .Now I am running postgres 8.0.1.

The code below compiles without errrors.
gcc -Wall -I /root/postgresql-8.0.1/src/include -shared -Wl,-soname,resource_test.so.1 -o resource_test.so resource_test.c

The error is:
xy_db=# create or replace function Export_Resource_Select(text,text,text) returns text as
xy_db-# '/root/resource_test.so' language 'c';
ERROR:  could not find function "export_resource_select" in file "/root/resource_test.so"

Code:

/*
gcc -Wall -I /root/postgresql-8.0.1/src/include -shared -Wl,-soname,resource_test.so.1 -o resource_test.so resource_test.c
*/
                                                                                                                                                            
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "/usr/include/pgsql/server/postgres.h"
#include "/usr/include/pgsql/server/fmgr.h"
#include "/usr/include/pgsql/server/libpq/pqformat.h"
                                                                                                                                                            
text* Export_Resource_Select(PG_FUNCTION_ARGS);
                                                                                                                                                            
PG_FUNCTION_INFO_V1(Export_Resource_Select);
                                                                                                                                                            
text* Export_Resource_Select(PG_FUNCTION_ARGS)
{
        char *g=(char*) PG_GETARG_POINTER(0);
        char *Resource_Category=(char*) PG_GETARG_POINTER(1);
        char *Resource_Type=(char*) PG_GETARG_POINTER(2);
        char *filepath; int filelength=0;
        struct stat stat_buf;
        text* new_t;
                                                                                                                                                            
        filepath=(char *) palloc(100);
        filepath="\0";
        sprintf(filepath,"/ResourceFS/%sFS/%s/%s",Resource_Category,Resource_Type,g);
        if(!access(filepath,R_OK))
        {
                stat(filepath, &stat_buf );
                filelength=stat_buf.st_size;
        }
                                                                                                                                                            
        new_t=(text*) palloc(VARHDRSZ+strlen(filepath)+1);
        VARATT_SIZEP(new_t)=VARHDRSZ+strlen(filepath)+1;
        memcpy(VARDATA(new_t),filepath,strlen(filepath)+1);
                                                                                                                                                            
        return new_t;
}
                                                                                                                                                            
/*
create function Export_Resource_Select(varchar,varchar,varchar) returns text as
'/root/resource_test.so' language 'c';
*/

thanks,
vish

pgsql-general by date:

Previous
From: David Rysdam
Date:
Subject: Re: missing something obvious about intervals?
Next
From: Volkan YAZICI
Date:
Subject: Re: missing something obvious about intervals?