Re: Add %z support to elog/ereport? - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Add %z support to elog/ereport?
Date
Msg-id 20131111174055.GI2401@awork2.anarazel.de
Whole thread Raw
In response to Re: Add %z support to elog/ereport?  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Add %z support to elog/ereport?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2013-11-11 12:31:55 -0500, Robert Haas wrote:
> On Mon, Nov 11, 2013 at 10:50 AM, Andres Freund <andres@2ndquadrant.com> wrote:
> > Hi,
> >
> > I'd like to add support for the length modifier %z. Linux' manpages
> > describes it as:
> >  z      A  following  integer conversion corresponds to a size_t or ssize_t argument.
> >
> > Since gcc's printf format checks understand it, we can add support for
> > it similar to the way we added %m support.
> 
> I seem to recall that our %m support involves rewriting the error
> string twice, which I think is actually kind of expensive if, for
> example, you've got a loop around a PL/pgsql EXCEPTION block.

Yes, it does that. Is that actually where a significant amount of time
is spent? I have a somewhat hard time believing that.

> I'd
> actually like to find a way to get rid of the existing %m support,
> maybe by having a flag that says "oh, and by the way append the system
> error to my format string"; or by changing %m to %s and having the
> caller pass system_error_string() or similar for that format position.

I'd rather get our own printf implementation from somewhere before doing
that which would quite likely result in a bigger speedup besides the
significant portability improvments.

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Add %z support to elog/ereport?
Next
From: Jim Nasby
Date:
Subject: Re: regclass error reports improperly downcased