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 1jtIR5-00026x-Oe for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2020 22:21:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jtIR3-0003Tv-Oi for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2020 22:21:01 +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 1jtIR3-0003Tn-I2 for pgsql-hackers@lists.postgresql.org; Wed, 08 Jul 2020 22:21:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jtIR1-0003id-1i for pgsql-hackers@lists.postgresql.org; Wed, 08 Jul 2020 22:21:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 068MKvND1736149; Wed, 8 Jul 2020 18:20:57 -0400 From: Tom Lane To: Alexander Korotkov cc: PostgreSQL Hackers Subject: Re: jsonpath versus NaN In-reply-to: References: <203949.1591879542@sss.pgh.pa.us> <355114.1591902003@sss.pgh.pa.us> <1446772.1592407984@sss.pgh.pa.us> <1552001.1592496464@sss.pgh.pa.us> <1553461.1592498746@sss.pgh.pa.us> Comments: In-reply-to Alexander Korotkov message dated "Mon, 06 Jul 2020 15:19:21 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1736147.1594246857.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 08 Jul 2020 18:20:57 -0400 Message-ID: <1736148.1594246857@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alexander Korotkov writes: > The patchset is attached, sorry for the delay. > The first patch improves error messages, which appears to be unclear > for me. If one applies .double() method to a numeric value, we > restrict that this numeric value should fit to double precision type. > If it doesn't fit, the current error message just says the following. > ERROR: jsonpath item method .double() can only be applied to a numeric v= alue > But that's confusing, because .double() method is naturally applied to > a numeric value. Patch makes this message explicitly report that > numeric value is out of range for double type. This patch also adds > test exercising this error. When string can't be converted to double > precision, I think it's better to explicitly say that we expected > valid string representation of double precision type. I see your point here, but the English of the replacement error messages could be improved. I suggest respectively numeric argument of jsonpath item method .%s() is out of range for type do= uble precision string argument of jsonpath item method .%s() is not a valid representatio= n of a double precision number As for 0002, I'd rather see the convertJsonbScalar() code changed back to the way it was, ie just case jbvNumeric: numlen =3D VARSIZE_ANY(scalarVal->val.numeric); padlen =3D padBufferToInt(buffer); ... There is no argument for having an its-not-NaN assertion here when there aren't similar assertions throughout the jsonb code. Also, it seems like it'd be smart to reject isinf() and isnan() results from float8in_internal_opt_error in both executeItemOptUnwrapTarget code paths, ie numeric source as well as string source. Yeah, we don't expect to see those cases in a jbvNumeric (so I wouldn't change the error message text), but it's cheap insurance. No other comments. regards, tom lane