pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mitar <mmitar@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Relaxing NaN/Infinity restriction in JSON fields
Date: Mon, 06 May 2019 16:21:36 -0400
Message-ID: <6323.1557174096@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKLmikP5pOgB6y_m4mVbpQTuz=Gdkv60s69gYSrA42Mh0oLngw@mail.gmail.com>
References: <CAKLmikP5pOgB6y_m4mVbpQTuz=Gdkv60s69gYSrA42Mh0oLngw@mail.gmail.com>

Mitar <mmitar@gmail.com> writes:
> When migrating from MongoDB to PostgreSQL one thing which just
> surprised me now is that I cannot store NaN/Infinity in JSON fields. I
> know that standard JSON restricts those values, but they are a very
> common (and welcome) relaxation. What are prospects of this
> restriction being lifted?

The JSON RFC is pretty clear on this matter [1]:

   Numeric values that cannot be represented in the grammar below (such
   as Infinity and NaN) are not permitted.

Getting us to deviate from the RFC so blatantly would be a very hard sell.
A large part of the point of the JSON datatype is to be interoperable;
once you give that up you may as well use some not-standard-at-all
representation.

> It is really sad that one cannot stores
> directly all IEEE 754 double precision floating point values.

There is not, and never has been, any claim that JSON numbers correspond
to the IEEE spec.

			regards, tom lane

[1] https://tools.ietf.org/html/rfc7159#page-6





view thread (5+ messages)  latest in thread

Message-ID: <6323.1557174096@sss.pgh.pa.us>
Permalink:  ../6323.1557174096@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6323.1557174096@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, mmitar@gmail.com
  Subject: Re: Relaxing NaN/Infinity restriction in JSON fields
  In-Reply-To: <6323.1557174096@sss.pgh.pa.us>
  References: <CAKLmikP5pOgB6y_m4mVbpQTuz=Gdkv60s69gYSrA42Mh0oLngw@mail.gmail.com> <6323.1557174096@sss.pgh.pa.us>

* 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