pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Gowtham Reddy <gowthamdoma18@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19771: to_char(): NUL byte in result for formats with a trailing decimal point (regression from ec352b37d)
Date: Sun, 18 Oct 2026 20:41:05 -0400
Message-ID: <347653.1792370465@sss.pgh.pa.us> (raw)
In-Reply-To: <CAOZ9b+osn=upOQvLYP9uTADw7CqP2nA6Uogsmv9dyQh4EB18ZQ@mail.gmail.com>
References: <19771-4f173b891525020c@postgresql.org>
	<CAOZ9b+osn=upOQvLYP9uTADw7CqP2nA6Uogsmv9dyQh4EB18ZQ@mail.gmail.com>

Gowtham Reddy <gowthamdoma18@gmail.com> writes:
> Please find attached a proposed patch for BUG #NNNNN.
> It stops NUM_numpart_to_char() from emitting the number string's
> terminating '\0' as a digit, and adds a regression test to numeric.sql
> (the test fails without the fix). make check passes (239/239) on
> master 45fc51fcbf45.
> Tom, CCing you since this became visible with ec352b37d.

That's definitely a bug, but on what basis do you say that it
wasn't visible before ec352b37d?  AFAICT it's ancient.
I get this as far back as 9.2, for instance:

regression=# select to_char(7, 'FM99.SG') AS d;
 d 
---
 7
(1 row)

Normally I'd think we should back-patch, but it's possible that
people didn't realize this behavior was unintended --- else we'd
have heard bug reports sooner.  (It's not instantly obvious that
we should drop the decimal point but not the sign, I think.)
So I'm inclined to leave the stable branches alone.  Maybe there's
still room to squeeze the fix into v19, though.

			regards, tom lane






view thread (5+ messages)  latest in thread

Message-ID: <347653.1792370465@sss.pgh.pa.us>
Permalink:  ../347653.1792370465@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/347653.1792370465@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, gowthamdoma18@gmail.com
  Subject: Re: BUG #19771: to_char(): NUL byte in result for formats with a trailing decimal point (regression from ec352b37d)
  In-Reply-To: <347653.1792370465@sss.pgh.pa.us>
  References: <19771-4f173b891525020c@postgresql.org> <CAOZ9b+osn=upOQvLYP9uTADw7CqP2nA6Uogsmv9dyQh4EB18ZQ@mail.gmail.com> <347653.1792370465@sss.pgh.pa.us>

* 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