Re: [PATCH] Generalized JSON output functions

From: Ryan Pedela <rpedela(at)datalanche(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "Shulgin, Oleksandr" <oleksandr(dot)shulgin(at)zalando(dot)de>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, hlinnaka <hlinnaka(at)iki(dot)fi>
Subject: Re: [PATCH] Generalized JSON output functions
Date: 2015-07-16 22:23:08
Message-ID: CACu89FSW6UNezeEbKU6gsPHo42wFEnCHGU7JO4Hspb=O6jA5uA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 16, 2015 at 11:51 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
> I don't understand these issues in great technical depth, but if
> somebody is arguing that it's OK for PostgreSQL to be difficult to use
> for a certain category of user for several years until the next
> language rev becomes mainstream, then I disagree. The fact that
> somebody wrote a patch to try to solve a problem means that the thing
> in question is a problem for at least that one user. If he's the only
> one, maybe we don't need to care all that much. If his needs are
> representative of a significant user community, we should not turn our
> backs on that community, regardless of whether we like the patch he
> wrote, and regardless of how well we are meeting the needs of other
> communities (like node.js users).

I completely agree. However we aren't talking about a usability problem
with Postgres. We are actually talking about a usability problem with
Javascript, and trying to implement a band-aid for it with Postgres.
Javascript doesn't support large numbers, it just doesn't. There is nothing
the Postgres community can do about that. Only the ECMAscript standards
committee and implementers can fix Javascript.

Here is the current user flow of reading numerics from Postgres and then
doing some math with them in Javascript.

1. SELECT json
2. Use json-bignum [1] module or custom JSON parser to correctly parse
numerics.
3. Perform addition, subtraction, etc of numerics using either custom
numeric math library or an existing library such as bigdecimal.js [2].

Here is the user flow if this patch is accepted.

1. SELECT json with quoting flags set
2. Custom parser to find numeric strings within JSON and convert them into
numerics. This is easy if JSON is simple, but may be difficult with a very
complex JSON.
3. Perform addition, subtraction, etc of numerics using either custom
numeric math library or an existing library such as bigdecimal.js [2].

It is almost the exact same user flow so what is the point? This patch
makes Postgres core more complex while not really solving the problem in
Javascript. If this would help other languages, domains, etc then maybe it
is worth implementing, but Javascript can't be fixed by the Postgres
community. It just can't.

To me the question is: does this help anyone besides Javascript users?

References
1. https://github.com/datalanche/json-bignum
2. https://github.com/iriscouch/bigdecimal.js

Thanks,
Ryan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vignesh Raghunathan 2015-07-16 22:36:54 Size of TOAST pointer
Previous Message dinesh kumar 2015-07-16 22:03:57 Re: proposal: multiple psql option -c