Re: cant write to file within call handler interface

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Sibtay Abbas <sibtay_abbas(at)yahoo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: cant write to file within call handler interface
Date: 2004-12-14 19:02:38
Message-ID: 20041214190238.GA27576@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2004-12-14 19:29:43 Re: possible wierd boolean bug?
Previous Message Bruce Momjian 2004-12-14 18:51:24 Re: V8.0rc1 On AIX.