From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: 798604270@qq.com
Subject: BUG #18977: Unexpected result of function to_char
Date: Thu, 03 Jul 2025 13:23:12 +0000
Message-ID: <18977-b301735f4ecad02f@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 18977
Logged by: Chi Zhang
Email address: 798604270@qq.com
PostgreSQL version: 18beta1
Operating system: ubuntu 24.04 with docker
Description:
hi,
the following two queries are equivalent but return different results:
```
SELECT ((to_char(-1E30, '0.9930824')));
to_char
------------
-#.##3#824
(1 row)
PREPARE prepare_query (float8) AS SELECT ((to_char($1, '0.9930824')));
EXECUTE prepare_query(-1E30::float8);
to_char
---------
-#.
```
furthermore, it seems the second argument of to_chat is formatted, but
according to the document in
https://www.postgresql.org/docs/current/functions-formatting.html, it should
be the first argument to be formatted
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, 798604270@qq.com
Subject: Re: BUG #18977: Unexpected result of function to_char
In-Reply-To: <18977-b301735f4ecad02f@postgresql.org>
* 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