pgsql: Use improved vsnprintf calling logic in more places.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Use improved vsnprintf calling logic in more places.
Date: 2013-10-25 01:44:20
Message-ID: E1VZWRo-0007aG-K0@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use improved vsnprintf calling logic in more places.

When we are using a C99-compliant vsnprintf implementation (which should be
most places, these days) it is worth the trouble to make use of its report
of how large the buffer needs to be to succeed. This patch adjusts
stringinfo.c and some miscellaneous usages in pg_dump to do that, relying
on the logic recently added in libpgcommon's psprintf.c. Since these
places want to know the number of bytes written once we succeed, modify the
API of pvsnprintf() to report that.

There remains near-duplicate logic in pqexpbuffer.c, but since that code
is in libpq, psprintf.c's approach of exit()-on-error isn't appropriate
for use there. Also note that I didn't bother touching the multitude
of places that call (v)snprintf without any attempt to provide a resizable
buffer.

Release-note-worthy incompatibility: the API of appendStringInfoVA()
changed. If there's any third-party code that's calling that directly,
it will need tweaking along the same lines as in this patch.

David Rowley and Tom Lane

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/3147acd63e0135aff9a6c4b01d861251925d97d9

Modified Files
--------------
src/backend/lib/stringinfo.c | 64 ++++++++++++---------------
src/backend/utils/error/elog.c | 16 +++----
src/bin/pg_dump/pg_backup_archiver.c | 80 +++++++++++++++++++---------------
src/bin/pg_dump/pg_backup_tar.c | 44 +++++++++----------
src/common/psprintf.c | 59 +++++++++++++++----------
src/include/lib/stringinfo.h | 9 ++--
src/include/utils/palloc.h | 10 +++--
src/pl/plpython/plpy_elog.c | 8 ++--
8 files changed, 153 insertions(+), 137 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2013-10-25 01:52:11 pgsql: Ignore SIGSYS during initdb.
Previous Message Heikki Linnakangas 2013-10-24 14:03:56 pgsql: Increase the number of different values used when seeding random