Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f5tvx-0005Mj-DZ for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Apr 2018 14:07:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f5tvw-0007Qi-AI for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Apr 2018 14:07:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f5tvw-0007QY-3F for pgsql-hackers@lists.postgresql.org; Tue, 10 Apr 2018 14:07:40 +0000 Received: from ping.uio.no ([2001:700:100:570::196]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f5tvq-0007Pt-6l for pgsql-hackers@lists.postgresql.org; Tue, 10 Apr 2018 14:07:39 +0000 Received: from [2001:700:100:570::211] (helo=dalvik.ping.uio.no ident=Debian-exim) by ping.uio.no with esmtp (Exim 4.72 #1 (Debian)) id 1f5tvi-0001qv-Tm; Tue, 10 Apr 2018 16:07:29 +0200 Received: from ilmari by dalvik.ping.uio.no with local (Exim 4.84_2) (envelope-from ) id 1f5tvi-0004AY-Nu; Tue, 10 Apr 2018 16:07:26 +0200 From: ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) To: Tom Lane Cc: Peter Eisentraut , Pavel Stehule , Nikita Glukhov , PostgreSQL Hackers Subject: Re: Transform for pl/perl References: <20171127132439.23dc26ef@anthony-24-g082ur> <20171201184921.27he6vbp62yegpvm@alvherre.pgsql> <20171207125455.39067aa7@anthony-24-g082ur> <20171207125602.5326f103@anthony-24-g082ur> <20180112114739.6a9f0d4c@anthony-24-g082ur> <20180131103621.GA19345@zakirov.localdomain> <20180215125313.290468ae@anthony-24-g082ur> <20180312110821.29c80420@anthony-24-g082ur> <505345c5-0159-077d-f64e-60afb01e5fbe@postgrespro.ru> <26a0840a-6b09-44fc-9e4e-8200c1887882@2ndquadrant.com> <15075.1523287460@sss.pgh.pa.us> <17423.1523368349@sss.pgh.pa.us> Date: Tue, 10 Apr 2018 15:07:26 +0100 In-Reply-To: <17423.1523368349@sss.pgh.pa.us> (Tom Lane's message of "Tue, 10 Apr 2018 09:52:29 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Exiscan-Spam-Score: -3.7 (---) X-Exiscan-Spam-Report: SpamAssassin 3.3.1 (2010-03-16) on pike.ping.uio.no Score Rule * -5.0 PING_UIO_MAIL_IS_INTERNAL Message has never been outside * 129.240.0.0/16 or 193.157.115.0/24 * 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tom Lane writes: > ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes: >> While playing around some more with the extension, I discoverered a few >> more issues: >> ... >> 4) SV_to_JsonbValue() throws an error for infinite NVs, but not NaNs > > The others sound like bugs, but that one's intentional, since type > numeric does have a concept of NaN. If you're arguing that we should > disallow that value in the context of jsonb, maybe so, but it'd likely > take changes in quite a few more places than here. The numeric type that's used internally to represent numbers in jsonb might have the concept of NaN, but JSON itself does not: Numeric values that cannot be represented in the grammar below (such as Infinity and NaN) are not permitted. - https://tools.ietf.org/html/rfc7159#section-6 And it cannot be cast to json: =# create or replace function jsonbnan() returns jsonb immutable language plperlu transform for type jsonb as '0+"NaN"'; CREATE FUNCTION =# select jsonbnan(); ┌──────────┐ │ jsonbnan │ ├──────────┤ │ NaN │ └──────────┘ =# select jsonb_typeof(jsonbnan()); ┌──────────────┐ │ jsonb_typeof │ ├──────────────┤ │ number │ └──────────────┘ =# select jsonbnan()::json; ERROR: invalid input syntax for type json DETAIL: Token "NaN" is invalid. CONTEXT: JSON data, line 1: NaN - ilmari -- "The surreality of the universe tends towards a maximum" -- Skud's Law "Never formulate a law or axiom that you're not prepared to live with the consequences of." -- Skud's Meta-Law