On Tue, 24 Apr 2007 11:14:43 +1200
"Andrej Ricnik-Bay" <[EMAIL PROTECTED]> wrote:

> On 4/24/07, Felix Kater <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > the messages returned by PQerrorMessage() contain a trailing new
> > line. So, they doesn't nicely integrate into strings formatted by
> > printf.
> >
> > Is there a way to suppress the trailing new line (except for
> > alloc/copy to a new string)?
> The alloc kind of suggests that you're using C ... is that
> correct?  Either way - please be a bit more specific as to what you're
> trying to achieve by which means.

Sorry (was deep in thoughs while coding...). A bit more detailed:

I am using libpq, the C language pg library. There is a useful function
to return the last error message as human readable text: PQerrorMessage.

While the returned text message is static memory which is good (you
simply print it and don't have to free the memory) there is a trailing
new line character at each text message like this:
<message text><newline><0-byte-terminator>

I find this newline a lot uncommon--since it is easy to add manually if
you really want it, and, however, it is not so easy to get rid of it.

Getting rid of it means: Copying the whole string without the newline,
pass it to the user, who has to free the copied memory after printing
it...

I wanted to know if there is a switch or similar somewhere to get the
messages without newline character.

Thank You
Felix

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to