pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix to_char() for number formats ending in a decimal point.
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix to_char() for number formats ending in a decimal point.
@ 2026-10-20 16:56 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2026-10-20 16:56 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix to_char() for number formats ending in a decimal point.

When a number format has a decimal point with no digit positions
after it (e.g. '9.' or 'FM999.PL'), NUM_numpart_to_char() copied the
terminating '\0' of the number string into the output as if it were a
digit, resulting in apparent truncation of the output; for example,
a sign or literal text following the decimal point would disappear.
Fix it by not copying the '\0'.

This is clearly a bug, but given the lack of field complaints,
people who have run into it may think it's expected behavior,
and may even have written applications that depend on it.
Therefore it seems unwise to change it in stable branches.
I (tgl) think it's not too late to fix it in v19 though.

Bug: #19771
Author: Gowtham Reddy <gowthamdoma18@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19771-4f173b891525020c@postgresql.org
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/776df8a6d7c42282825d658ff631509f033e8f34

Modified Files
--------------
src/backend/utils/adt/formatting.c    | 4 ++--
src/test/regress/expected/numeric.out | 6 ++++++
src/test/regress/sql/numeric.sql      | 1 +
3 files changed, 9 insertions(+), 2 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix to_char() for number formats ending in a decimal point.
@ 2026-10-20 16:56 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2026-10-20 16:56 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix to_char() for number formats ending in a decimal point.

When a number format has a decimal point with no digit positions
after it (e.g. '9.' or 'FM999.PL'), NUM_numpart_to_char() copied the
terminating '\0' of the number string into the output as if it were a
digit, resulting in apparent truncation of the output; for example,
a sign or literal text following the decimal point would disappear.
Fix it by not copying the '\0'.

This is clearly a bug, but given the lack of field complaints,
people who have run into it may think it's expected behavior,
and may even have written applications that depend on it.
Therefore it seems unwise to change it in stable branches.
I (tgl) think it's not too late to fix it in v19 though.

Bug: #19771
Author: Gowtham Reddy <gowthamdoma18@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19771-4f173b891525020c@postgresql.org
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/61bb2214892402083ea581d558320b636e7968ac

Modified Files
--------------
src/backend/utils/adt/formatting.c    | 4 ++--
src/test/regress/expected/numeric.out | 6 ++++++
src/test/regress/sql/numeric.sql      | 1 +
3 files changed, 9 insertions(+), 2 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-10-20 16:56 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20 16:56 pgsql: Fix to_char() for number formats ending in a decimal point. Tom Lane <tgl@sss.pgh.pa.us>
2026-10-20 16:56 pgsql: Fix to_char() for number formats ending in a decimal point. Tom Lane <tgl@sss.pgh.pa.us>

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