Re: [HACKERS] query log corrupted-looking entries

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "George Pavlov" <gpavlov(at)mynewplace(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] query log corrupted-looking entries
Date: 2006-10-18 12:06:10
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCEA0FC5E@algol.sollentuna.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

> >> Hmm. If the messages are less than PIPE_BUF bytes long
> (4096 bytes
> >> on
> >> Linux) then the writes are supposed to be atomic.
>
> > Some of them involve long messages (>4K), but there are
> many that do
> > not (like the ones I had posted at the start of this thread).
>
> I checked around with some kernel/glibc gurus in Red Hat, and
> the consensus seemed to be that we'd be better off to bypass
> fprintf() and just send message strings to stderr using
> write() --- ie, instead of elog.c doing
>
> fprintf(stderr, "%s", buf.data);
>
> do
>
> write(fileno(stderr), buf.data, strlen(buf.data));
>
> Anyone have any comments on possible portability risks? In
> particular, will this work on Windows?

Should work fine on Windows. fileno() is deprecated however, with the
following comment:
C:\Program Files\Microsoft Visual Studio
8\VC\INCLUDE\stdio.h(688) : see
declaration of 'fileno'
Message: 'The POSIX name for this item is deprecated. Instead,
use the ISO C++ conformant name: _fileno. See online help for details.'

It still works, and there is a define to get around that warning though,
so it's definitly not critical.

//Magnus

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shane Ambler 2006-10-18 12:06:16 Re: COPY FROM STDIN instead of INSERT
Previous Message Ron Johnson 2006-10-18 10:21:01 Re: Fixed-point scalars?

Browse pgsql-hackers by date

  From Date Subject
Next Message Csaba Nagy 2006-10-18 12:15:11 Re: bug or feature, || -operator and NULLs
Previous Message Shane Ambler 2006-10-18 11:55:01 Re: Mirror problems for download