Re: Schizophrenic coding in gin_extract_jsonb(_hash)

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Schizophrenic coding in gin_extract_jsonb(_hash)
Дата
Msg-id 536A6192.9050109@vmware.com
обсуждение исходный текст
Ответ на Re: Schizophrenic coding in gin_extract_jsonb(_hash)  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Schizophrenic coding in gin_extract_jsonb(_hash)
Список pgsql-hackers
On 05/07/2014 06:27 PM, Tom Lane wrote:
> I think you're just proving the point that this code is woefully
> underdocumented.  If there were, somewhere, some comment explaining
> what the heck JB_ROOT_COUNT actually counts, maybe I wouldn't be asking
> this question.  jsonb.h is certainly not divulging any such information.

After having reverse-engineered the convertJsonb code, I think I can 
explain what JB_ROOT_COUNT is.

If the root of the Jsonb datum is an array, it's the number of elements 
in that top-level array. If it's an object, it's the number of key/value 
pairs in that top-level object. Some of the elements of that array (or 
values of the object) can be arrays or objects themselves.

gin_extract_jsonb recursively extracts all the elements, keys and values 
of any sub-object too, but JB_ROOT_COUNT only counts the top-level elements.

(I hope this is made a bit more clear in the comments I added in the 
patch I posted this morning)

- Heikki



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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: [v9.5] Custom Plan API
Следующее
От: Andres Freund
Дата:
Сообщение: Re: PGDLLEXPORTing all GUCs?