From: | ZhangChi <798604270(at)qq(dot)com> |
---|---|
To: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #18976: -0.0 with float8 will be transformed to 0 inprepare statement but not in normal execution |
Date: | 2025-07-03 12:30:40 |
Message-ID: | tencent_962FF1EEB65D67CD8B93099B1CC499851E0A@qq.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
hi,
Thank you for your reply!
Iโm wonderingโsince the parameter has already been specified as float8 in the PREPARE statement, why is it still necessary to convert it to float8 again during EXECUTE?
ๅๅง้ฎไปถ
ๅไปถไบบ๏ผLaurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
ๅไปถๆถ้ด๏ผ2025ๅนด7ๆ3ๆฅ 20:23
ๆถไปถไบบ๏ผ798604270 <798604270(at)qq(dot)com>, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
ไธป้ข๏ผRe: BUG #18976: -0.0 with float8 will be transformed to 0 inprepare statement but not in normal execution
On Thu, 2025-07-03 at 03:03 +0000, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference: 18976
> Logged by: Chi Zhang
> Email address: 798604270(at)qq(dot)com
> PostgreSQL version: 18beta1
> Operating system: Ubuntu 24.04 and docker
> Description:
>
> The value -0.0 with float8 is transformed to 0 in prepared statements but
> remains -0 in normal execution. Although 0 and -0 are numerically equal,
> this discrepancy can lead to subtle bugs in certain casesโfor example, when
> the value is cast to a VARCHAR, as illustrated below.
>
> PREPARE prepare_query (float8) AS SELECT CAST($1 AS VARCHAR) =
> CAST(-0.0::float8 AS VARCHAR);
> EXECUTE prepare_query(-0.0); -- f
That's not a bug, but a pilot error. If you feed a "float8", the result ist TRUE:
EXECUTE prepare_query(-0.0::float8);
?column?
โโโโโโโโโโ
t
(1 row)
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2025-07-03 13:23:12 | BUG #18977: Unexpected result of function to_char |
Previous Message | Laurenz Albe | 2025-07-03 12:23:42 | Re: BUG #18976: -0.0 with float8 will be transformed to 0 in prepare statement but not in normal execution |