Re: cant write to file within call handler interface - Mailing list pgsql-hackers

From Michael Fuhr
Subject Re: cant write to file within call handler interface
Date
Msg-id 20041214190238.GA27576@winnie.fuhr.org
Whole thread Raw
In response to cant write to file within call handler interface  (Sibtay Abbas <sibtay_abbas@yahoo.com>)
List pgsql-hackers
On Tue, Dec 14, 2004 at 10:31:41AM -0800, Sibtay Abbas wrote:

> i am not able to write to file until the pl call
> handler interface.

What are you expecting to happen and what actually does happen?
Saying only "it doesn't work" doesn't give us much to go on.

> this is the template which i am following
> 
> PG_FUNCTION_INFO_V1(my_call_handler);
> 
> Datum
> my_call_handler(PG_FUNCTION_ARGS)
> {
>     ...my code...
> 
>     int fd = open("filename",O_WRONLY);
>     write(fd,buffer,strlen(buffer) + 1);
> 
>     //fsync(fd).......i tried this as well but           
>          did'nt work
> 
> }

A simple but complete example would be helpful so we can see
everything you're doing; the parts of the code that you don't show
could be relevant to the problem.  Reducing the problem to the
smallest possible example can also help you find where the mistake
is by eliminating where it isn't.

You show no error checking.  Check the return value of all functions
that can fail and use ereport() or elog() to report any failures.
You also don't show where buffer comes from, so we don't know if
its contents are a problem or not.  And is "filename" the actual
name in your code?  Where are you expecting that file to be?

Some programming mistakes can be spotted by the compiler.  Turn on
as many compiler warnings as you can.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: V8.0rc1 On AIX.
Next
From: "Merlin Moncure"
Date:
Subject: Re: possible wierd boolean bug?