What's going wrong? - Mailing list pgsql-interfaces

From Igor Gavriloff
Subject What's going wrong?
Date
Msg-id 39EB8A6B.E1EB3E44@nupes.cefetpr.br
Whole thread Raw
Responses Re: What's going wrong?
List pgsql-interfaces
Hi,
   I'm trying to write a function in C that I can load into postgres,
that basically removes a file from the system (quite unsafe thought, but
it'll be suitable for me here):

#include <postgres.h>
#include <stdio.h>

bool file_remove(text *this)
{       if (remove((char *)this) == 0) return (true);       else return (false);
}
   I compile it and link as instructed for Solaris (where the backend
runs), and load it with:

CREATE FUNCTION file_remove(text) RETURNS bool AS '/path/file_remove.so'
LANGUAGE 'c';
   But it always returns false when I try to remove something. I'm sure
that I'm trying to remove files that the the backend's user owns (have
write access). If I try to make any changes on this code (eg.: the
casts...), when I try to use it the backends terminates abnormally.   Does someone can give me a clue?

Thanks,
Igor.



pgsql-interfaces by date:

Previous
From: "Clark, Joel"
Date:
Subject: RE: 2 computers 1hd 2 postgres daemons. Is it possib le?
Next
From: Alfred Perlstein
Date:
Subject: Re: What's going wrong?