Re: [PATCH] Generalized JSON output functions

Поиск
Список
Период
Сортировка
От Ryan Pedela
Тема Re: [PATCH] Generalized JSON output functions
Дата
Msg-id CACu89FSW6UNezeEbKU6gsPHo42wFEnCHGU7JO4Hspb=O6jA5uA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Generalized JSON output functions  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: [PATCH] Generalized JSON output functions  ("Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>)
Список pgsql-hackers
On Thu, Jul 16, 2015 at 11:51 AM, Robert Haas <robertmhaas@gmail.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

Thanks,
Ryan

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Retrieve the snapshot's LSN
Следующее
От: Vignesh Raghunathan
Дата:
Сообщение: Size of TOAST pointer