Re: [PATCH] Generalized JSON output functions

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

On Fri, Jul 10, 2015 at 4:04 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
wrote:

>
>>
>>> 2. why you did indirect call via JsonOutContext?
>>>>
>>>> What is benefit
>>>>
>>>> dst.value(&dst, (Datum) 0, JSONTYPE_NULL, InvalidOid, InvalidOid,
>>>> false);
>>>>
>>>> instead
>>>>
>>>> json_out_value(&dst, ....)
>>>>
>>>
>> For consistency. Even though we initialize the output context ourselves,
>> there might be some code introduced between json_out_init_context() and
>> dst.value() calls that replaces some of the callbacks, and then there would
>> be a difference.
>>
>
> with this consistency? I didn't see this style everywhere in Postgres?
> Isn't it premature optimization?
>

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.

--
Alex

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-07-10 14:16:59 Re: creating extension including dependencies
Previous Message Sawada Masahiko 2015-07-10 14:11:45 Re: Freeze avoidance of very large table.