pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: 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: Wed, 20 Jul 2022 15:27:05 +0300
Message-ID: <564af102-059f-d5fe-ae64-08f495bc0a1b@matrix.gatewaynet.com> (raw)
In-Reply-To: <CAKFQuwZ=j3LwE0COninDoc=HM6ToQ_PwmJsKMyzasTEAiOKv1w@mail.gmail.com>
References: <1c9f27e7-459e-2e05-7129-e9e14ca503b7@matrix.gatewaynet.com>
	<CAKFQuwZ6o+ZLKmAsnD2gGj+qxRvtQRs7JOQrn8jW9tP=M2N0MA@mail.gmail.com>
	<eef1d4de-3933-fe03-8e06-12a075a163ae@matrix.gatewaynet.com>
	<CAKFQuwZ=j3LwE0COninDoc=HM6ToQ_PwmJsKMyzasTEAiOKv1w@mail.gmail.com>

On 19/7/22 20:31, David G. Johnston wrote:
> On Tuesday, July 19, 2022, Achilleas Mantzios <achill@matrix.gatewaynet.com> wrote:
>
>     Thanks David
>
>     Στις 19/7/22 17:19, ο/η David G. Johnston έγραψε:
>>     On Tuesday, July 19, 2022, Achilleas Mantzios <achill@matrix.gatewaynet.com> wrote:
>>
>>
>>         ERROR:  cannot convert infinity to numeric
>>
>>         -- has no problem testing against infinity
>>
>>         select it.id <http://it.id; ,cept.value::numeric as val, numrange(ceptl.min_alarm::numeric,ceptl.max_alarm::numeric
>>         ,'()') as range from items it, cept_report cept , dynacom.vessels vsl, machdefs md, cept_reportlimits ceptl wh
>>         ere it.id <http://it.id>=cept.id <http://cept.id; AND md.defid=ceptl.defid AND it.defid=md.defid AND it.vslwhid=vsl.id <http://vsl.id; AND vsl.vslstatus='Acti
>>         ve' and md.application = 'Critical Equipment Performance Test' AND cept.systemdate>= (now()-'1 year'::interval
>>         ) AND  cept.value='inf' ORDER BY 1;
>>         id | val | range
>>         ----+-----+-------
>>         (0 rows)
>>
>>
>>     The column cept.value contains an infinity.  I see nothing unusual in any of these queries given that fact. If you try to cast the infinity to numeric it will fail. If that doesn’t happen the
>>     query won’t fail.
>
>     Sorry I must have been dizzy today with so much support.
>
>     Yep, there are some infinity in there, but not in this result set.
>
>     I think when the casting is in the WHERE filter for some reason some subplan uses this filter (and fails). But when this check is applied to the result, no infinity is found and works correctly.
>
>
> That is what it means for SQL to be a declarative language, the order of execution/evaluation is determined to be efficient and not what is explicitly written.  You do have some control though, but 
> using it also means you might make things worse.
>
> I think you have issues anyway if you are doing equality checks on what seems to be a floating point column, regardless of which way you do the cast.
Thank you, will look into it further when I get the time.
>
> David J.
>


-- 
Achilleas Mantzios
DBA, Analyst, IT Lead
IT DEPT
Dynacom Tankers Mgmt

view thread (13+ messages)  latest in thread

Message-ID: <564af102-059f-d5fe-ae64-08f495bc0a1b@matrix.gatewaynet.com>
Permalink:  ../564af102-059f-d5fe-ae64-08f495bc0a1b@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/564af102-059f-d5fe-ae64-08f495bc0a1b@matrix.gatewaynet.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: achill@matrix.gatewaynet.com
  Subject: Re: pgsql 10.19 : "ERROR: cannot convert infinity to numeric" except there is no infinity
  In-Reply-To: <564af102-059f-d5fe-ae64-08f495bc0a1b@matrix.gatewaynet.com>
  References: <1c9f27e7-459e-2e05-7129-e9e14ca503b7@matrix.gatewaynet.com> <CAKFQuwZ6o+ZLKmAsnD2gGj+qxRvtQRs7JOQrn8jW9tP=M2N0MA@mail.gmail.com> <eef1d4de-3933-fe03-8e06-12a075a163ae@matrix.gatewaynet.com> <CAKFQuwZ=j3LwE0COninDoc=HM6ToQ_PwmJsKMyzasTEAiOKv1w@mail.gmail.com> <564af102-059f-d5fe-ae64-08f495bc0a1b@matrix.gatewaynet.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