BUG #18977: Unexpected result of function to_char - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #18977: Unexpected result of function to_char
Date
Msg-id 18977-b301735f4ecad02f@postgresql.org
Whole thread Raw
Responses Re: BUG #18977: Unexpected result of function to_char
Re: BUG #18977: Unexpected result of function to_char
List pgsql-bugs
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


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18974: Postgresql repeatable crash after pg_upgrade from 15 to 17.5 version in postgresql_fdw queries
Next
From: "ZhangChi"
Date:
Subject: Re: BUG #18976: -0.0 with float8 will be transformed to 0 inpreparestatement but not in normal execution