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 1oE8p9-0001eT-Ln for pgsql-general@arkaria.postgresql.org; Wed, 20 Jul 2022 12:29:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oE8p8-0007sr-EY for pgsql-general@arkaria.postgresql.org; Wed, 20 Jul 2022 12:29:06 +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 1oE8p8-0007nV-3R for pgsql-general@lists.postgresql.org; Wed, 20 Jul 2022 12:29:06 +0000 Received: from hermes.gatewaynet.com ([193.92.121.98]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oE8p4-0005lR-Px for pgsql-general@lists.postgresql.org; Wed, 20 Jul 2022 12:29:05 +0000 Received: from smadev.internal.net (pc131.internal.net [10.9.200.131]) by hermes.gatewaynet.com (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 26KCSndt005280 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Jul 2022 15:28:54 +0300 Received: from [10.9.200.131] (smadev [10.9.200.131]) by smadev.internal.net (8.16.1/8.16.1) with ESMTP id 26KCSm9I063706; Wed, 20 Jul 2022 15:28:49 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) Message-ID: <6302af7a-a8f2-4bc4-78ce-3770bf266f5b@matrix.gatewaynet.com> Date: Wed, 20 Jul 2022 15:28:48 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: pgsql 10.19 : "ERROR: cannot convert infinity to numeric" except there is no infinity Content-Language: en-US To: Adrian Klaver , 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> From: Achilleas Mantzios In-Reply-To: <0d1a9696-db2d-ace7-5879-16fed625386a@aklaver.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.4 at hermes X-Virus-Status: Clean X-Spam-Status: No, score=-28.9 required=5.0 tests=ALL_TRUSTED,DYN_HAM_COORD, DYN_HAM_IT,DYN_HAM_NAUTICAL,NICE_REPLY_A,TW_PG,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on hermes.gatewaynet.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 19/7/22 20:32, Adrian Klaver wrote: > On 7/19/22 10:26 AM, Achilleas Mantzios wrote: >> Thank you Adrian! > > Actually thank: > > https://sqlformat.darold.net/ > >> >> Στις 19/7/22 18:36, ο/η Adrian Klaver έγραψε: >>> On 7/19/22 03:38, Achilleas Mantzios wrote: >>> >>> I reformatted queries to see thing better. >>> >>>> > >>> 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. >>> > > Have you tried: > > NULLIF(cept.value, 'inf')::numeric no, cause the CTE version worked. Will keep in mind for similar future problems. > >>>> -- >>>> Achilleas Mantzios >>>> DBA, Analyst, IT Lead >>>> IT DEPT >>>> Dynacom Tankers Mgmt >>>> >>> >>> >> >> > > -- Achilleas Mantzios DBA, Analyst, IT Lead IT DEPT Dynacom Tankers Mgmt