On 2015-02-26 10:16:38 -0500, Tom Lane wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
> > On 2015-02-26 11:55:20 +0000, Tim Smith wrote:
> >> As far as I'm aware, JSON has no data types as such, and so why is
> >> Postgres (9.4.1) attempting to impose its own nonsense constraints ?
>
> > "impose its own nonsense constraints" - breathe slowly in, and out, in,
> > and out.
>
> > It looks to me like ab14a73a6ca5cc4750f0e00a48bdc25a2293034a copied too
> > much code from xml.c - including a comment about XSD... Andrew, was that
> > intentional?
>
> Not wanting to put words in Andrew's mouth, but I thought the point of
> those changes was that timestamps emitted into JSON should be formatted
> per some ISO standard or other, and said standard (almost certainly)
> doesn't know what infinity is.
To me it looked more about being able to reuse code: "The output is
slightly different, but still ISO 8601 compliant". The previous commit,
still using to_char, didn't prohibit 'infinity' that way; although I
doubt it produced something useful.
The copied XSD reference (which is about a XML schema description
language) doesn't seem to imply that it really was intended.
> At the same time, there is definitely no such requirement in the JSON
> spec itself, so at least the error message is quoting the wrong
> authority.
To me there seems to be very little point in restricing the output that
way. Sure, it can easily be worked around by casting before the
conversion to json, but it's still somewhat odd to put in restrictions
that don't exist in normal json.
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services