pgsql: Fix formatting of to_char's EEEE output for numeric and bigint.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix formatting of to_char's EEEE output for numeric and bigint.
Date: 2026-11-18 17:45:44
Message-ID: E1xTjj5-00000000Gtb-3Knv@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix formatting of to_char's EEEE output for numeric and bigint.

The integer and float code paths for EEEE format always produce a
single digit before the decimal point. However, the numeric code
path (shared by bigint) was careless about rounding: if rounding
increased the value from, say, 9.999 to 10.00, it got printed
that way. Fix that. Given the precedent of the other code paths,
this seems incontestably a bug, so back-patch.

While at it, provide some actual documentation about what this
format code is supposed to do, rather than leaving it to the
reader's imagination.

Author: Jianqiao Han <hanjianqiao(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CAPOa_Zkc1QROJwB_JcB+f=6s1bUPRh7qr_H_=B_S-KZPa0V1DA@mail.gmail.com
Backpatch-through: 15

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a355dde4df2b6360bbe1292c22061e948d9d0ee0

Modified Files
--------------
doc/src/sgml/func.sgml | 12 +++++++++---
src/backend/utils/adt/numeric.c | 16 ++++++++++++++++
src/test/regress/expected/numeric.out | 24 ++++++++++++++++++++++++
src/test/regress/sql/numeric.sql | 13 +++++++++++++
4 files changed, 62 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Melanie Plageman 2026-11-18 18:18:49 Re: pgsql: Fix pgstattuple_approx handling of unknown tuple estimates
Previous Message Dean Rasheed 2026-11-18 16:05:53 pgsql: Fix transition tables for MERGE with cross-partition UPDATEs.