pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Subject: Revert workarounds for unportability of printf %.*s format?
Date: Sun, 28 Jun 2020 15:48:04 -0400
Message-ID: <279428.1593373684@sss.pgh.pa.us> (raw)

In connection with the discussion at [1], I realized that we could unwind
the hacks we've introduced --- mostly in commit 54cd4f045 --- to avoid
depending on the behavior of %.*s format in printf.  Now that we always
use our own snprintf.c code, we know that it measures field widths in
bytes not characters, and we also know that use of this format won't
cause random encoding-related failures.

Some of the changes are not worth undoing; for example using strlcpy
instead of snprintf to truncate a string is a net win by any measure.
But places where we introduced a temporary buffer, such as the
change in truncate_identifier() in 54cd4f045, would be better off
with the old coding.  In any case we could remove all the comments
warning against using this feature.

Thoughts?

			regards, tom lane

[1] https://www.postgresql.org/message-id/flat/a120087c-4c88-d9d4-1ec5-808d7a7f133d%40gmail.com





Message-ID: <279428.1593373684@sss.pgh.pa.us>
Permalink:  ../279428.1593373684@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/279428.1593373684@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org
  Subject: Re: Revert workarounds for unportability of printf %.*s format?
  In-Reply-To: <279428.1593373684@sss.pgh.pa.us>

* 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