Re: BUG #18977: Unexpected result of function to_char

Laurenz Albe <laurenz.albe@cybertec.at>

From: Laurenz Albe <laurenz.albe@cybertec.at>
To: 798604270@qq.com, pgsql-bugs@lists.postgresql.org
Date: 2025-07-03T14:40:53Z
Lists: pgsql-bugs
On Thu, 2025-07-03 at 13:23 +0000, PG Bug reporting form wrote:
> 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

This is the same as bug report #18976.
For user guidance, please write to the pgsql-general mailing list.
This list is for bug reports.

Yours,
Laurenz Albe