pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: pgsql 10.19 : "ERROR: cannot convert infinity to numeric" except there is no infinity
Date: Tue, 19 Jul 2022 10:47:00 -0700
Message-ID: <deb5984f-e293-090a-2fdf-e2b1ae9042e2@aklaver.com> (raw)
In-Reply-To: <be467742-7dd3-23ed-5fb1-4835337ab937@aklaver.com>
References: <1c9f27e7-459e-2e05-7129-e9e14ca503b7@matrix.gatewaynet.com>
	<35ecc7d6-14a6-7898-db04-236504946589@aklaver.com>
	<f9209b36-e840-8c8b-7e3c-270097e6bf98@matrix.gatewaynet.com>
	<0d1a9696-db2d-ace7-5879-16fed625386a@aklaver.com>
	<be467742-7dd3-23ed-5fb1-4835337ab937@aklaver.com>

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





view thread (13+ messages)  latest in thread

Message-ID: <deb5984f-e293-090a-2fdf-e2b1ae9042e2@aklaver.com>
Permalink:  ../deb5984f-e293-090a-2fdf-e2b1ae9042e2@aklaver.com/
Also on:    postgresql.org/message-id/deb5984f-e293-090a-2fdf-e2b1ae9042e2@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, achill@matrix.gatewaynet.com
  Subject: Re: pgsql 10.19 : "ERROR: cannot convert infinity to numeric" except there is no infinity
  In-Reply-To: <deb5984f-e293-090a-2fdf-e2b1ae9042e2@aklaver.com>
  References: <1c9f27e7-459e-2e05-7129-e9e14ca503b7@matrix.gatewaynet.com> <35ecc7d6-14a6-7898-db04-236504946589@aklaver.com> <f9209b36-e840-8c8b-7e3c-270097e6bf98@matrix.gatewaynet.com> <0d1a9696-db2d-ace7-5879-16fed625386a@aklaver.com> <be467742-7dd3-23ed-5fb1-4835337ab937@aklaver.com> <deb5984f-e293-090a-2fdf-e2b1ae9042e2@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox