pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Implement %m in src/port/snprintf.c, and teach elog.c to rely on
Date: Wed, 26 Sep 2018 17:32:03 +0000
Message-ID: <E1g5DfP-00060w-DH@gemulon.postgresql.org> (raw)

Implement %m in src/port/snprintf.c, and teach elog.c to rely on that.

I started out with the idea that we needed to detect use of %m format specs
in contexts other than elog/ereport calls, because we couldn't rely on that
working in *printf calls.  But a better answer is to fix things so that it
does work.  Now that we're using snprintf.c all the time, we can implement
%m in that and we've fixed the problem.

This requires also adjusting our various printf-wrapping functions so that
they ensure "errno" is preserved when they call snprintf.c.

Remove elog.c's handmade implementation of %m, and let it rely on
snprintf to support the feature.  That should provide some performance
gain, though I've not attempted to measure it.

There are a lot of places where we could now simplify 'printf("%s",
strerror(errno))' into 'printf("%m")', but I'm not in any big hurry
to make that happen.

Patch by me, reviewed by Michael Paquier

Discussion: https://postgr.es/m/2975.1526862605@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d6c55de1f99a9028540516316b95321a7b12a540

Modified Files
--------------
src/backend/lib/stringinfo.c         |  6 ++++
src/backend/utils/error/elog.c       | 70 +++---------------------------------
src/bin/pg_dump/pg_backup_archiver.c |  4 +++
src/bin/pg_dump/pg_backup_tar.c      |  2 ++
src/common/psprintf.c                |  5 +++
src/interfaces/libpq/pqexpbuffer.c   |  7 ++++
src/pl/plpython/plpy_elog.c          |  2 ++
src/port/snprintf.c                  | 28 ++++++++++++++-
8 files changed, 57 insertions(+), 67 deletions(-)



Message-ID: <E1g5DfP-00060w-DH@gemulon.postgresql.org>
Permalink:  ../E1g5DfP-00060w-DH@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1g5DfP-00060w-DH@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Implement %m in src/port/snprintf.c, and teach elog.c to rely on
  In-Reply-To: <E1g5DfP-00060w-DH@gemulon.postgresql.org>
  References: <E1g5DfP-00060w-DH@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox