From: | "Shulgin, Oleksandr" <oleksandr(dot)shulgin(at)zalando(dot)de> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Ryan Pedela <rpedela(at)datalanche(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, hlinnaka(at)iki(dot)fi, Robert Haas <robertmhaas(at)gmail(dot)com> |
Subject: | Re: [PATCH] Generalized JSON output functions |
Date: | 2015-07-11 17:57:29 |
Message-ID: | CACACo5QyHvnhA-_mZZGqZWEetdp5AuRQj9E5d1r2F6ZORr6AXw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Jul 11, 2015 6:19 PM, "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> wrote:
>
>
>
> 2015-07-11 18:02 GMT+02:00 Shulgin, Oleksandr <
oleksandr(dot)shulgin(at)zalando(dot)de>:
>>
>> On Fri, Jul 10, 2015 at 5:16 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
wrote:
>>>>
>>>>
>>>> Well, one could call it premature pessimization due to dynamic call
overhead.
>>>>
>>>> IMO, the fact that json_out_init_context() sets the value callback to
json_out_value is an implementation detail, the other parts of code should
not rely on. And for the Explain output, there definitely going to be
*some* code between context initialization and output callbacks: these are
done in a number of different functions.
>>>
>>>
>>> Again - it is necessary? Postgres still use modular code, not OOP code.
I can understand the using of this technique, when I need a possibility to
change behave. But these function are used for printing JSON, not printing
any others.
>>
>>
>> No, it's not strictly necessary.
>>
>> For me it's not about procedural- vs. object- style, but rather about
being able to override/extend the behavior consistently. And for that I
would prefer that if I override the value callback in a JSON output
context, that it would be called for every value being printed, not only
for some of them.
>
>
> please, can me show any real use case? JSON is JSON, not art work.
To quote my first mail:
The motivation behind this to be able to produce specially-crafted JSON in
a logical replication output plugin, such that numeric (and bigint) values
are quoted. This requirement, in turn, arises from the fact that
JavaScript specification, which is quite natural to expect as a consumer
for this JSON data, allows to silently drop significant digits when
converting from string to number object.
I believe this is a well-known problem and I'm aware of a number of tricks
that might be used to avoid it, but none of them seems to be optimal from
my standpoint.
I can also imagine this can be used to convert date/time to string
differently, or adding indentation depending on the depth in object
hierarchy, etc.
> Still I don't see any value of this.
Huh? Why then do you spend time on review?
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2015-07-11 18:40:32 | Re: [PATCH] Generalized JSON output functions |
Previous Message | Tom Lane | 2015-07-11 16:32:48 | Re: strange plan with bitmap heap scan and multiple partial indexes |