hi all,
I have read through the fmgr's readme but havent been able to solve my problem with accessing the file.
I gave the permissions: [root@localhost /]# chmod 777-r
/ResourceFS" and have made sure the file i am trying to access
does exist.
I am not sure where i am going wrong.
/*
gcc -Wall -I /root/postgresql-7.4.5/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"
Datum file_check(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(file_check);
Datum file_check(PG_FUNCTION_ARGS)
{
char *filecmd = (char*) PG_GETARG_VARCHAR_P(0);
int filelength=0;
struct stat stat_buf;
if(!access(filecmd,R_OK))
{
stat(filecmd, &stat_buf );
filelength=stat_buf.st_size;
}
return filelength;
}
xy_db=# create or replace function file_check(varchar) returns varchar as
xy_db-# '/root/resource_test.so','file_check' language 'c';
CREATE FUNCTION
k2_db=# select file_check('/ResourceFS/IconFS/Alarm/My.gif');
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> \q
thanks,
vish