From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: pgsql-general@lists.postgresql.org, Carsten Klein <c.klein@datagis.com>
Subject: Re: Strange results when casting string to double
Date: Fri, 18 Feb 2022 16:58:06 -0500
Message-ID: <4159419.1645221486@sss.pgh.pa.us> (raw)
In-Reply-To: <20220218214249.su6x5hi6ixauggku@hjp.at>
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>
"Peter J. Holzer" <hjp-pgsql@hjp.at> writes:
> Another idea: It could be the case that something (maybe a bug in
> postgres, maybe an extension, maybe even a random bit flip in memory)
> changed the FP rounding mode within the postgres process, which would
> affect all FP computations until the rounding mode is reset. That would
> have to have happened in the master to affect the worker processes as
> consistently as you are seeing. I don't know if it is even possible for
> a non-standard rounding mode to persist for any length of time, but if
> it is it would certainly account for weird rounding errors.
Hmm, that is a pretty interesting theory. On a RHEL8 box, I find
that fesetround(FE_DOWNWARD) causes strtod("1.56", NULL) to return
1.55999999999999983124
rather than the usual
1.56000000000000005329
which seems to square with Carsten's symptom.
Postgres itself contains no fesetround calls, but if you want
to believe a random bit flip changed that mode, maybe that'd
account for it. It'd certainly be interesting to find out
whether the problem persists after a postmaster restart.
[ wanders away wondering if the troublesome machine has ECC
memory ... ]
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, hjp-pgsql@hjp.at, c.klein@datagis.com
Subject: Re: Strange results when casting string to double
In-Reply-To: <4159419.1645221486@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> <4159419.1645221486@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