guess i should have read the documentation more carefully.
Function was created when i did add "link_symbol" to the path.
If this is the real reason, then I believe this is something new as it used to work without using link_symbol before.
vish
On 12/12/05, vishal saberwal <[EMAIL PROTECTED]> wrote:
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