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 1f5uJE-000719-A1 for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Apr 2018 14:31:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f5uJD-0006Xe-26 for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Apr 2018 14:31:43 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f5uJC-0006XS-Nu for pgsql-hackers@lists.postgresql.org; Tue, 10 Apr 2018 14:31:42 +0000 Received: from ping.uio.no ([2001:700:100:570::196]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f5uJ8-0001EK-B4 for pgsql-hackers@lists.postgresql.org; Tue, 10 Apr 2018 14:31:41 +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 1f5uIy-0004bh-OW; Tue, 10 Apr 2018 16:31:31 +0200 Received: from ilmari by dalvik.ping.uio.no with local (Exim 4.84_2) (envelope-from ) id 1f5uIy-0004Bq-Ip; Tue, 10 Apr 2018 16:31:28 +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:31:28 +0100 In-Reply-To: ("Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker=22's?= message of "Tue, 10 Apr 2018 15:07:26 +0100") 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 ilmari@ilmari.org (Dagfinn Ilmari Mannsåker) writes: > 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 […] > =# create or replace function jsonbnan() returns jsonb immutable language plperlu transform for type jsonb as '0+"NaN"'; > CREATE FUNCTION […] > =# select jsonbnan()::json; > ERROR: invalid input syntax for type json > DETAIL: Token "NaN" is invalid. > CONTEXT: JSON data, line 1: NaN Also, it doesn't parse back in as jsonb either: =# select jsonbnan()::text::json; ERROR: invalid input syntax for type json DETAIL: Token "NaN" is invalid. CONTEXT: JSON data, line 1: NaN And it's inconsistent with to_jsonb(): =# select to_jsonb('nan'::numeric); ┌──────────┐ │ to_jsonb │ ├──────────┤ │ "NaN" │ └──────────┘ It would be highly weird if PL transforms (jsonb_plpython does the same thing) let you create spec-violating jsonb values that don't round-trip via jsonb_out/in. - 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