Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hqQlF-00022W-GL for psycopg@arkaria.postgresql.org; Wed, 24 Jul 2019 23:33:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hqQlE-000566-Af for psycopg@arkaria.postgresql.org; Wed, 24 Jul 2019 23:33:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hqQlD-00055t-3o for psycopg@lists.postgresql.org; Wed, 24 Jul 2019 23:33:28 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hqQl4-00052v-MQ for psycopg@postgresql.org; Wed, 24 Jul 2019 23:33:25 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 21BFF21F32; Wed, 24 Jul 2019 19:33:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 24 Jul 2019 19:33:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=f o4+ka+z+etr0aVeE2xaM2+4X7Qww428AUtF6NDfVVo=; b=sGYgivNGIC8aCkFUM U8Y6lj2URg8MTEaq8ZtYB6xtJr1nLqkAuIrYXNKnll0ltMmXKkPdulB/fKssHQI7 c3Iugd64KmJfhHY65QZ8TI6Z6NXWi3gUJC8bXHW8k0g3zIqNELB5ZtxKnLJnqIN+ kAEsxV/8kZQh8YyhIgekwDalWDCw9fWwe2iRtxWzt+g88Q8GWcmtTSw/s8LuNi/c ngc+IFYpmc2ql6nbOGxgnpeSYrdHttePgQBUEUJ1YLyYMlRcTW3HCo0pEKus7H1d kO0rG/YdyV2QKX2aQMtLKzZ1Rq9KcH5TZ1h6Mg8IY9pGG5+pK0UfFHPKBD26Jilu aFs8w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=fo4+ka+z+etr0aVeE2xaM2+4X7Qww428AUtF6NDfV Vo=; b=oVFQdEBu4PvMsfjIAgDj2F0i+xwBOe7VILWF1MMeSUX/4jTkksa2ltCr8 LWRjJGYinswCWZWmC1rLk95GivJ7nNoAYyVC2MyEveAUB4l5SWhTN2CD0OUpnj3H GdgDGEXBsFHNaCxts77wUnRwsppADiooudK2PVOYEtpmWrIUDHIFAvxA1SXHOvTe bcxgeRVKg/QAUzDI0euGTyy8x78aBF+tgFnK3rtT91PP1ixk1HScmC9tnOZVUjTS TUUm/vJh4wAVWWs0arx0tIIWUEv6Nc6i3XFvm/ObY8Smk3YHeSfZigD6X7SeHLW5 VxQ85vfJZCIXUXbkO0QyWmokJRD4w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrkedugddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthekre dttdefheenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhl rghvvghrsegrkhhlrghvvghrrdgtohhmqeenucffohhmrghinhepphhoshhtghhrvghsqh hlrdhorhhgnecukfhppeejuddrvdduvddrudehtddrvddtvdenucfrrghrrghmpehmrghi lhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhenucevlh hushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id 49A20380084; Wed, 24 Jul 2019 19:33:17 -0400 (EDT) Subject: Re: Rounding numbers from copy expert To: John Abraham , psycopg@postgresql.org References: <8DC745DF-DDF9-4697-BAAF-23ABE78A1EB9@hbaspecto.com> From: Adrian Klaver Message-ID: Date: Wed, 24 Jul 2019 16:33:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <8DC745DF-DDF9-4697-BAAF-23ABE78A1EB9@hbaspecto.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/24/19 4:28 PM, John Abraham wrote: > Hmm, I have two machines connecting to the same database running the > same query inside copy_expert. > > Both seem to have psycopg2 2.7.5 (based on pip3 freeze). > > One seems to be rounding the double precision number 696538951.985381 to > 6.96538944E8 whereas the other machine isn't rounding it. First: https://www.postgresql.org/docs/11/datatype-numeric.html#DATATYPE-FLOAT 8.1.3. Floating-Point Types "The data types real and double precision are inexact, variable-precision numeric types. ... Inexact means that some values cannot be converted exactly to the internal format and are stored as approximations, so that storing and retrieving a value might show slight discrepancies. Managing these errors and how they propagate through calculations is the subject of an entire branch of mathematics and computer science and will not be discussed here, except for the following points: ..." Second: Where are you actually 'looking' at the values? > > This is causing auditability/repeatability problems, as the difference > is actually significant in this context. > > Is there some thing about the way psycopg2 connects to the database, or > the way psycopg2 is configured, that could be causing this rounding? Is > there some way to express a preference for scientific notation? > > I'm at a complete loss as to why copy_expert (which basically does a > 'copy to stdin' query) would be different when called from different > machines. My next step in the madness is to see if the locale has an > effect, one is set to en_CA.UTF-8 and the other is set to en_US.UTF-8. >  But, perhaps someone else has a better idea. > > Thanks for any help. > > -- > John Abraham > jea@hbaspecto.com > 403-232-1060 > -- Adrian Klaver adrian.klaver@aklaver.com