Re: [HACKERS] PATCH: recursive json_populate_record() - Mailing list pgsql-hackers

From David Steele
Subject Re: [HACKERS] PATCH: recursive json_populate_record()
Date
Msg-id 9bf14a7c-0794-f90c-c012-8dd0335ab364@pgmasters.net
Whole thread Raw
In response to Re: [HACKERS] PATCH: recursive json_populate_record()  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: [HACKERS] PATCH: recursive json_populate_record()  (David Steele <david@pgmasters.net>)
List pgsql-hackers
On 2/1/17 12:53 AM, Michael Paquier wrote:
> On Thu, Jan 26, 2017 at 6:49 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Nikita Glukhov <n.gluhov@postgrespro.ru> writes:
>>> On 25.01.2017 23:58, Tom Lane wrote:
>>>> I think you need to take a second look at the code you're producing
>>>> and realize that it's not so clean either.  This extract from
>>>> populate_record_field, for example, is pretty horrid:
>>
>>> But what if we introduce some helper macros like this:
>>
>>> #define JsValueIsNull(jsv) \
>>>      ((jsv)->is_json ? !(jsv)->val.json.str \
>>>          : !(jsv)->val.jsonb || (jsv)->val.jsonb->type == jbvNull)
>>
>>> #define JsValueIsString(jsv) \
>>>      ((jsv)->is_json ? (jsv)->val.json.type == JSON_TOKEN_STRING \
>>>          : (jsv)->val.jsonb && (jsv)->val.jsonb->type == jbvString)
>>
>> Yeah, I was wondering about that too.  I'm not sure that you can make
>> a reasonable set of helper macros that will fix this, but if you want
>> to try, go for it.
>>
>> BTW, just as a stylistic thing, I find "a?b:c||d" unreadable: I have
>> to go back to the manual every darn time to convince myself whether
>> that means (a?b:c)||d or a?b:(c||d).  It's better not to rely on
>> the reader (... or the author) having memorized C's precedence rules
>> in quite that much detail.  Extra parens help.
> 
> Moved to CF 2017-03 as discussion is going on and more review is
> needed on the last set of patches.
> 

The current patches do not apply cleanly at cccbdde:

$ git apply ../other/0001-introduce-JsonContainerXxx-macros-v04.patch
error: patch failed: src/backend/utils/adt/jsonb_util.c:328
error: src/backend/utils/adt/jsonb_util.c: patch does not apply
error: patch failed: src/backend/utils/adt/jsonfuncs.c:1266
error: src/backend/utils/adt/jsonfuncs.c: patch does not apply
error: patch failed: src/include/utils/jsonb.h:218
error: src/include/utils/jsonb.h: patch does not apply

In addition, it appears a number of suggestions have been made by Tom
that warrant new patches.  Marked "Waiting on Author".

-- 
-David
david@pgmasters.net



pgsql-hackers by date:

Previous
From: Jon Nelson
Date:
Subject: Re: [HACKERS] [PATCH] guc-ify the formerly hard-coded MAX_SEND_SIZE to max_wal_send
Next
From: Robert Haas
Date:
Subject: Re: [HACKERS] [PATCH] guc-ify the formerly hard-coded MAX_SEND_SIZEto max_wal_send