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: Convert DCH_to_char() to use a StringInfo as destination.
Date: Thu, 20 Aug 2026 17:01:34 +0000
Message-ID: <E1wx68z-00000001NzO-39eZ@gemulon.postgresql.org> (raw)

Convert DCH_to_char() to use a StringInfo as destination.

Formerly, we allocated an output char array with 12 bytes per
byte of the format string.  That's usually far more than enough,
and yet we had to add assorted code to defend against cases where
it isn't enough.  Switch to using a StringInfo expansible buffer
instead.  This is considerably more robust, shortens the code
noticeably, and eliminates various edge-case failure conditions.

While at it, const-ify some parameters that can be const.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/3451175.1786641871@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/03d2554638cb5c95819e1e720e15672630a3cbdd

Modified Files
--------------
src/backend/utils/adt/formatting.c | 561 ++++++++++++++-----------------------
1 file changed, 205 insertions(+), 356 deletions(-)



Message-ID: <E1wx68z-00000001NzO-39eZ@gemulon.postgresql.org>
Permalink:  ../E1wx68z-00000001NzO-39eZ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wx68z-00000001NzO-39eZ@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Convert DCH_to_char() to use a StringInfo as destination.
  In-Reply-To: <E1wx68z-00000001NzO-39eZ@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