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: Tue, 19 Jul 2022 20:26:24 +0300
Message-ID: <f9209b36-e840-8c8b-7e3c-270097e6bf98@matrix.gatewaynet.com> (raw)
In-Reply-To: <35ecc7d6-14a6-7898-db04-236504946589@aklaver.com>
References: <1c9f27e7-459e-2e05-7129-e9e14ca503b7@matrix.gatewaynet.com>
	<35ecc7d6-14a6-7898-db04-236504946589@aklaver.com>

Thank you Adrian!

Στις 19/7/22 18:36, ο/η Adrian Klaver έγραψε:
> On 7/19/22 03:38, Achilleas Mantzios wrote:
>
> I reformatted queries to see thing better.
>
>>
>> -- still has problem testing the range
>>
>> select 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=cept.id AND md.defid=ceptl.defid AND it.defid=md.defid AND 
>> it.vslwhid=vsl.id AND vsl.vslstatus='Acti
>> ve' and md.application = 'Critical Equipment Performance Test' AND 
>> cept.systemdate>= (now()-'1 year'::interval
>> ) AND 
>>  numrange(ceptl.min_alarm::numeric,ceptl.max_alarm::numeric,'()') @> 
>> cept.value::numeric ORDER BY 1;
>> ERROR:  cannot convert infinity to numeric
>
> SELECT
>     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 = cept.id
>     AND md.defid = ceptl.defid
>     AND it.defid = md.defid
>     AND it.vslwhid = vsl.id
>     AND vsl.vslstatus = 'Acti
> ve' and md.application = 'Critical Equipment Performance Test' AND
> cept.systemdate>= (now()-'1 year'::interval)
> AND numrange(ceptl.min_alarm::numeric, ceptl.max_alarm::numeric, '()') 
> @> cept.value::numeric
> ORDER BY
>     1;
>
> So the above fails. In your title when you say there is no infinity 
> that means the cept.value, ceptl.min_alarm or ceptl.max_alarm  fields 
> do not have any '-infinity' or 'infinity' values, correct?
There is infinity in cept.value , just not in this result set.
I got confused and wrongly assumed that since the result set (without 
the filter in the WHERE clause including cept.value::numeric) did not 
contain any infinity it should also work with the filter in the WHERE 
clause. Apparently a subplan executes this conversion in the WHERE 
before the other filters. I did not do any analyze to prove this.
>
>>
>>
>> -- no problem if the query goes into its barrier and the test done 
>> outside
>> with bar as (select it.id ,cept.value::numeric as val, 
>> numrange(ceptl.min_alarm::numeric,ceptl.max_a
>> larm::numeric,'()') as range from items it, cept_report cept , 
>> dynacom.vessels vsl, machdefs md, cept_reportli
>> mits ceptl where it.id=cept.id AND md.defid=ceptl.defid AND 
>> it.defid=md.defid AND it.vslwhid=vsl.id AND vsl.vs
>> lstatus='Active' and md.application = 'Critical Equipment Performance 
>> Test' AND cept.systemdate>= (now()-'1 ye
>> ar'::interval)  ORDER BY 1)
>> select * from bar where NOT range @> val;
>> -- good data here
>
> WITH bar AS (
>     SELECT
>         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_reportli mits ceptl
>     WHERE
>         it.id = cept.id
>         AND md.defid = ceptl.defid
>         AND it.defid = md.defid
>         AND it.vslwhid = vsl.id
>         AND vsl.vs lstatus = 'Active'
>         AND md.application = 'Critical Equipment Performance Test'
>         AND cept.systemdate >= (now() - '1 ye
> ar'::interval)
>     ORDER BY
>         1
> )
> SELECT
>     *
> FROM
>     bar
> WHERE
>     NOT RANGE @> val;
>
> This version succeeds, correct? So breaking the range construction 
> into one step and the @> test into another works. Though I am not sure 
> why <range> @> changed to NOT <range> @>?
Yes this succeeds. The correct is with the NOT, it does not change the 
behavior of the initial query.
>>
>> -- 
>> Achilleas Mantzios
>> DBA, Analyst, IT Lead
>> IT DEPT
>> Dynacom Tankers Mgmt
>>
>
>





view thread (13+ messages)  latest in thread

Message-ID: <f9209b36-e840-8c8b-7e3c-270097e6bf98@matrix.gatewaynet.com>
Permalink:  ../f9209b36-e840-8c8b-7e3c-270097e6bf98@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/f9209b36-e840-8c8b-7e3c-270097e6bf98@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: <f9209b36-e840-8c8b-7e3c-270097e6bf98@matrix.gatewaynet.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>

* 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