From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: pgsql-general@lists.postgresql.org
Cc: Csaba Ragasits <ragasits.csaba@gmail.com>
Subject: Re: PG8.3->10 migration data differences
Date: Mon, 10 Sep 2018 10:05:06 -0400
Message-ID: <9971.1536588306@sss.pgh.pa.us> (raw)
In-Reply-To: <20180910100040.wzglexkarz57w3ts@hjp.at>
References: <CANaXbVjw3Y8VmapWuZahtcRhpE61hsSUcjquip3HuXeuN8y4sg@mail.gmail.com>
<b7e21ca6-c795-2cda-4873-ae8cd80383a8@matrix.gatewaynet.com>
<20180910100040.wzglexkarz57w3ts@hjp.at>
"Peter J. Holzer" <hjp-pgsql@hjp.at> writes:
> On 2018-09-10 11:57:42 +0300, Achilleas Mantzios wrote:
>> On 10/09/2018 11:22, Csaba Ragasits wrote:
>>> Field type: REAL
>>> pg93: 2.2
>>> pg10: 2.20000005
>> Those have to do with rounding. Precision for real is 6 decimal
>> digits. Your difference is on the 8-th digit.
> Nitpick: Precision is 24 binary digits which is *about* 6 decimal
> digits. The number which is actually stored (on both pg93 and pg10) is
> actually 2.2000000476837158203125 (1.00011001100110011001101 * 2^1 in
> binary). Apparently Pg9.3 rounds this to "2.2" on output while Pg10
> prints the more precise (but still not exact) "2.20000005".
Well, more specifically:
regression=# set extra_float_digits to 2;
SET
regression=# select 2.2::real;
float4
--------
2.2
(1 row)
regression=# set extra_float_digits to 3;
SET
regression=# select 2.2::real;
float4
------------
2.20000005
(1 row)
8.3 did not let you set extra_float_digits as high as 3, so you couldn't
get the "2.20000005" result there, but given that and a correct
implementation of sprintf you would have.
I surmise that the OP is comparing the output of pg_dump in the two
versions. pg_dump always sets extra_float_digits to the maximum the
server will allow, and the reason is to ensure that the dumped value will
reload as the same binary bit pattern (again, assuming correct float I/O
functionality in libc). We used to think that 2 extra digits beyond the
nominal precision was enough to guarantee that, but there are cases where
you need 3, so it got changed.
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, ragasits.csaba@gmail.com
Subject: Re: PG8.3->10 migration data differences
In-Reply-To: <9971.1536588306@sss.pgh.pa.us>
References: <CANaXbVjw3Y8VmapWuZahtcRhpE61hsSUcjquip3HuXeuN8y4sg@mail.gmail.com> <b7e21ca6-c795-2cda-4873-ae8cd80383a8@matrix.gatewaynet.com> <20180910100040.wzglexkarz57w3ts@hjp.at> <9971.1536588306@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