ERROR: could not find function

From: vishal saberwal <vishalsaberwal(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: ERROR: could not find function
Date: 2005-12-12 18:08:12
Message-ID: 3e74dc250512121008t1c7939fel72319bc18ed0fbbc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Volkan YAZICI 2005-12-12 18:09:14 Re: missing something obvious about intervals?
Previous Message David Rysdam 2005-12-12 18:07:04 Re: missing something obvious about intervals?