Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xIbRE-00000003mmP-3GCj for pgsql-bugs@arkaria.postgresql.org; Mon, 19 Oct 2026 00:41:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xIbRD-00000004flW-3Xt5 for pgsql-bugs@arkaria.postgresql.org; Mon, 19 Oct 2026 00:41:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xIbRD-00000004flK-2UbM for pgsql-bugs@lists.postgresql.org; Mon, 19 Oct 2026 00:41:15 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xIbR7-00000002svS-4BVz for pgsql-bugs@lists.postgresql.org; Mon, 19 Oct 2026 00:41:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 69J0f5Fq347654; Sun, 18 Oct 2026 20:41:05 -0400 From: Tom Lane To: Gowtham Reddy 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) In-reply-to: References: <19771-4f173b891525020c@postgresql.org> Comments: In-reply-to Gowtham Reddy message dated "Mon, 19 Oct 2026 02:17:07 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <347652.1792370465.1@sss.pgh.pa.us> Date: Sun, 18 Oct 2026 20:41:05 -0400 Message-ID: <347653.1792370465@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Gowtham Reddy 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