From: Tom Lane <tgl@sss.pgh.pa.us>
To: Carsten Klein <c.klein@datagis.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Strange results when casting string to double
Date: Sun, 20 Feb 2022 14:02:42 -0500
Message-ID: <304015.1645383762@sss.pgh.pa.us> (raw)
In-Reply-To: <e39fe24c-6e3e-9e8a-9024-bf1440387960@datagis.com>
References: <0d711ac6-6975-ae07-8963-aa91c6500776@datagis.com>
<f3575aaf-98a8-6941-7843-ba1a0d78514f@enterprisedb.com>
<4592fac1-05b2-f775-3332-c5a7d4c65b9d@datagis.com>
<3950189.1645198347@sss.pgh.pa.us>
<6593fee3-477b-6069-f91e-79f91075808f@datagis.com>
<20220218214249.su6x5hi6ixauggku@hjp.at>
<8c20dba1-4631-67c1-d317-a5e144acd821@sourcepole.ch>
<99c8bac2-98e1-5315-7bca-d02d867c2b25@datagis.com>
<80849.1645299298@sss.pgh.pa.us>
<e39fe24c-6e3e-9e8a-9024-bf1440387960@datagis.com>
Carsten Klein <c.klein@datagis.com> writes:
> Prior to restarting, I've implemented my own Python based versions of both
> int fegetround(void);
> int fesetround(int rounding_mode integer);
Ah, good idea!
> With those, I was able to proof, that actually the "wrong" rounding mode
> FE_DOWNWARD (0x400)
> was in effect for every new process/connection with all the described
> effects on casting from string or numeric to double precision:
Thanks for confirming that that was the source of the problem.
> We'll likely never know, why ever the postmaster got tainted with that
> FE_DOWNWARD (0x400) rounding mode.
Indeed. It's hard to see any other explanation than "random bit flip"
though. The postmaster is designed to run only a very small amount of
code, almost none of which is user-controllable. Even if there were
somewhere some code that intended to change the rounding mode, explaining
how the postmaster got to that without crashing is a tall order.
> Two official math functions to get and set the session's rounding mode
> provided by PostgreSQL could be a good add-on for any of the next
> versions of the database. Thinking about it again... maybe that's just
> too dangerous :-p
No, we'd absolutely not ever provide a supported function to change
rounding modes. That would require downgrading all float-related
functions from IMMUTABLE to STABLE, which would have severe performance
consequences, even for people with no interest in changing modes.
Thanks for closing out the thread with this info!
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, c.klein@datagis.com
Subject: Re: Strange results when casting string to double
In-Reply-To: <304015.1645383762@sss.pgh.pa.us>
References: <0d711ac6-6975-ae07-8963-aa91c6500776@datagis.com> <f3575aaf-98a8-6941-7843-ba1a0d78514f@enterprisedb.com> <4592fac1-05b2-f775-3332-c5a7d4c65b9d@datagis.com> <3950189.1645198347@sss.pgh.pa.us> <6593fee3-477b-6069-f91e-79f91075808f@datagis.com> <20220218214249.su6x5hi6ixauggku@hjp.at> <8c20dba1-4631-67c1-d317-a5e144acd821@sourcepole.ch> <99c8bac2-98e1-5315-7bca-d02d867c2b25@datagis.com> <80849.1645299298@sss.pgh.pa.us> <e39fe24c-6e3e-9e8a-9024-bf1440387960@datagis.com> <304015.1645383762@sss.pgh.pa.us>
* 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