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 1oDrJQ-0003pH-Mg for pgsql-general@arkaria.postgresql.org; Tue, 19 Jul 2022 17:47:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oDrJP-0003yM-6C for pgsql-general@arkaria.postgresql.org; Tue, 19 Jul 2022 17:47: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 1oDrJO-0003wF-S9 for pgsql-general@lists.postgresql.org; Tue, 19 Jul 2022 17:47:10 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDrJI-0005OS-1N for pgsql-general@lists.postgresql.org; Tue, 19 Jul 2022 17:47:09 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id D949D32009C3; Tue, 19 Jul 2022 13:47:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 19 Jul 2022 13:47:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1658252822; x= 1658339222; bh=rv4MB+mZ3TCh1uHyKlj0ERrHWQ4+7wWXl2RUfi0lnGU=; b=B x5oefEbFxudaxI1yUI83KSS5yLWLtKBF6EIp2wdFhVss6qo/Nr0gWiPE4ODKPVKo 2DAzLR3svrbV+n6nBTsappFrkGifz3HpDkUfbCzpolBs+ivQaLBrmPJUrljwYh6z l6WzVRUzsvoyGRJEQXpX6NS05K/8O3cOB1hSOg6XPyQjG4bXYLDrwKIzAZQqvWS+ UUEqxhnRkH7BLBsGsU6SxdFCaxgG+hLl+tz3CXCy34aplNlrzLnQJbfq+ij/i0sI ibcHjTB6TPqzwm3T1oadYqdxezpyZHytvTfqT0m5LEkfzUVaKk2ISHSxc1huscAb NMvcxSv3CfCEmyDoB4euw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1658252822; x=1658339222; bh=r v4MB+mZ3TCh1uHyKlj0ERrHWQ4+7wWXl2RUfi0lnGU=; b=eXUGmomzLQW6S++Ul SJQ0xUandIoy8cBa4pDpxJ10QZkkzIlYjfnVVEJM1HKnB3J2637Pis86MOz/sVhd l4YiWTppqqXkGwce9ptEp4B6yQCS3FLU3+tqp+vbpHBfTRAptKVmt9FKLrM2sglV jTkbB/tH209bxrsLcYyiHkxEleuUPkbZirwDs1r2Jtxh0x4bOjtg59JYbfqqOsrq OTx3hp9wuo8ds3H/+YYtr5BwUAzWTiONgGZlJcU33HVvfswFN4Nk824aBxb9qrm9 S8YzaBnS5BNcvSYVICZ1SaAeDfVsI5Wdbu6ixYdtnrhcSUasvS4Ak3lAd30NGWvp tMsFA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudeltddgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuhffvfhfkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepffekffdufeduffevhfekkeevkeeftddvtedvteei keduvdehvdetheejfeejhfdunecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrgh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughr ihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Jul 2022 13:47:01 -0400 (EDT) Subject: Re: pgsql 10.19 : "ERROR: cannot convert infinity to numeric" except there is no infinity From: Adrian Klaver To: Achilleas Mantzios , pgsql-general@lists.postgresql.org References: <1c9f27e7-459e-2e05-7129-e9e14ca503b7@matrix.gatewaynet.com> <35ecc7d6-14a6-7898-db04-236504946589@aklaver.com> <0d1a9696-db2d-ace7-5879-16fed625386a@aklaver.com> Message-ID: Date: Tue, 19 Jul 2022 10:47:00 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/19/22 10:42 AM, Adrian Klaver wrote: > On 7/19/22 10:32 AM, Adrian Klaver wrote: >> On 7/19/22 10:26 AM, Achilleas Mantzios wrote: > >> >> Have you tried: >> >> NULLIF(cept.value, 'inf')::numeric > > That was a miss. I originally tested this on Postgres 14 and of course > it worked. Trying it on Postgres 12 got: > > select nullif(1.5, 'inf')::numeric; > ERROR:  invalid input syntax for type numeric: "inf" > LINE 1: select nullif(1.5, 'inf')::numeric; > > Due to this: > > https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-NULLIF > > > "The two arguments must be of comparable types. To be specific, they are > compared exactly as if you had written value1 = value2, so there must be > a suitable = operator available." > > So: > > 1.5::numeric = 'inf'::numeric The cheat would be: select version(); version ------------------------------------------------------------------------------------- PostgreSQL 12.10 on x86_64-pc-linux-gnu, compiled by gcc (SUSE Linux) 7.5.0, 64-bit select nullif('inf'::float, 'inf')::numeric; nullif -------- NULL select nullif(1.5::float, 'inf')::numeric; nullif -------- 1.5 (1 row) >> >>>>> -- >>>>> Achilleas Mantzios >>>>> DBA, Analyst, IT Lead >>>>> IT DEPT >>>>> Dynacom Tankers Mgmt > > > -- Adrian Klaver adrian.klaver@aklaver.com