Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fzMoh-0004yW-IN for pgsql-general@arkaria.postgresql.org; Mon, 10 Sep 2018 14:05:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fzMoe-0003Zt-Rl for pgsql-general@arkaria.postgresql.org; Mon, 10 Sep 2018 14:05:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fzMoe-0003Ze-K8 for pgsql-general@lists.postgresql.org; Mon, 10 Sep 2018 14:05:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fzMoX-0000Da-OG for pgsql-general@lists.postgresql.org; Mon, 10 Sep 2018 14:05:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w8AE5623009972; Mon, 10 Sep 2018 10:05:07 -0400 From: Tom Lane To: "Peter J. Holzer" cc: pgsql-general@lists.postgresql.org, Csaba Ragasits Subject: Re: PG8.3->10 migration data differences In-reply-to: <20180910100040.wzglexkarz57w3ts@hjp.at> References: <20180910100040.wzglexkarz57w3ts@hjp.at> Comments: In-reply-to "Peter J. Holzer" message dated "Mon, 10 Sep 2018 12:00:40 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9970.1536588306.1@sss.pgh.pa.us> Date: Mon, 10 Sep 2018 10:05:06 -0400 Message-ID: <9971.1536588306@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Peter J. Holzer" 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