| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix to_char() for number formats ending in a decimal point. |
| Date: | 2026-10-20 16:56:24 |
| Message-ID: | E1xJD8S-000000002SC-0PLo@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-10-20 18:29:22 | pgsql: In deparsing, parenthesize IS DOCUMENT where it is an operand. |
| Previous Message | Fujii Masao | 2026-10-20 06:07:56 | pgsql: Mark GUC-dependent type output functions as STABLE |