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 1nL9Xt-0004PZ-RU for pgsql-general@arkaria.postgresql.org; Fri, 18 Feb 2022 20:08:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nL9Xs-0002u5-AS for pgsql-general@arkaria.postgresql.org; Fri, 18 Feb 2022 20:08:00 +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 1nL9Xr-0002tw-Vy for pgsql-general@lists.postgresql.org; Fri, 18 Feb 2022 20:08:00 +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 1nL9Xl-0007dT-Bb for pgsql-general@lists.postgresql.org; Fri, 18 Feb 2022 20:07:59 +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 21IK7lIN4137024; Fri, 18 Feb 2022 15:07:47 -0500 From: Tom Lane To: Carsten Klein cc: Peter Eisentraut , pgsql-general@lists.postgresql.org Subject: Re: Strange results when casting string to double In-reply-to: <6593fee3-477b-6069-f91e-79f91075808f@datagis.com> References: <0d711ac6-6975-ae07-8963-aa91c6500776@datagis.com> <4592fac1-05b2-f775-3332-c5a7d4c65b9d@datagis.com> <3950189.1645198347@sss.pgh.pa.us> <6593fee3-477b-6069-f91e-79f91075808f@datagis.com> Comments: In-reply-to Carsten Klein message dated "Fri, 18 Feb 2022 18:07:35 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4137022.1645214867.1@sss.pgh.pa.us> Date: Fri, 18 Feb 2022 15:07:47 -0500 Message-ID: <4137023.1645214867@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Carsten Klein writes: > So, you're not aware of any ways this behavior could be achieved from > within PostgreSQL? Something like a custom cast (actually, there is > none) or something that could intercept string to double conversion? Well, you asserted that these installations are all alike ... but sure, it's conceivable that somebody could've replaced the default numeric -> float8 cast (i.e., numeric_float8()) with some other code that does it a bit inaccurately. There's only a pg_cast entry connecting that function to those types. Have you tried stepping through things with a debugger, to see if numeric_float8 and float8in are actually reached on the problematic system? > That would be something to look at closer. The question is: how would > you implement such an evil database wide text to double conversion (just > to kid users) if you had to? At the SQL level, your example does not involve text -> double. The literal 1.56 is of type numeric. regards, tom lane