pgsql: Convert DCH_to_char() to use a StringInfo as destination.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Convert DCH_to_char() to use a StringInfo as destination.
Date: 2026-08-20 17:01:34
Message-ID: E1wx68z-00000001NzO-39eZ@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Heikki Linnakangas <hlinnaka(at)iki(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2026-08-20 19:33:18 pgsql: doc: change "allowed in->on the standby server."
Previous Message Jeff Davis 2026-08-20 16:41:25 pgsql: Ensure all pg_locale.h APIs work with collate_is_c.