Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUyJl-0005eh-P5 for pgsql-jdbc@arkaria.postgresql.org; Tue, 20 Oct 2020 20:33:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kUyJj-0005R8-8x for pgsql-jdbc@arkaria.postgresql.org; Tue, 20 Oct 2020 20:33:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUyJj-0005Qy-3Z for pgsql-jdbc@lists.postgresql.org; Tue, 20 Oct 2020 20:33:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUyJg-0004la-Jt for pgsql-jdbc@postgresql.org; Tue, 20 Oct 2020 20:33:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09KKX69U675896; Tue, 20 Oct 2020 16:33:06 -0400 From: Tom Lane To: Vladimir Sitnikov cc: "David G. Johnston" , Andreas Joseph Krogh , "Thangavel, Parameswaran" , "pgsql-jdbc@postgresql.org" Subject: Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue In-reply-to: References: <652597.1603214274@sss.pgh.pa.us> <674136.1603223598@sss.pgh.pa.us> Comments: In-reply-to Vladimir Sitnikov message dated "Tue, 20 Oct 2020 23:06:47 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <675894.1603225986.1@sss.pgh.pa.us> Date: Tue, 20 Oct 2020 16:33:06 -0400 Message-ID: <675895.1603225986@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Vladimir Sitnikov writes: > https://www.postgresql.org/docs/13/datatype-numeric.html#DATATYPE-FLOAT > The documentation says that PostgreSQL implements IEEE Standard 754. Note the waffling immediately after that, though. > 1234567 is exactly representable in IEEE (e.g. see > https://www.exploringbinary.com/floating-point-converter/ ), > so I would expect the database should keep the value intact. You don't really get to have your cake and eat it too. Yeah, we could allow more than six digits to propagate through float4_numeric, but then some cases would result in surprising garbage digits showing up in the result. That would annoy at least as many people as the current behavior. > In case that matters, pgjdbc does send pass extra_float_digits=2 in the > initial packet, then it upgrades to extra_float_digist=3 in case server > version is 9.0+ Hmm, but it's done that for a long while, no? Doesn't seem to explain the behavior change the OP is complaining of. > I did try removing that parameter, and it does not resolve > 1234567::float4::numeric::text issue Of course not, that conversion is happening entirely inside the backend; extra_float_digits isn't involved. (Although it would get involved with 1234567::float4::text::numeric, I bet, since the float4 -> text step would pay attention to it.) regards, tom lane