Re: [HACKERS] Schizophrenic coding in gin_extract_jsonb(_hash)

2014-05-07 Thread Tom Lane
Peter Geoghegan p...@heroku.com writes: On Tue, May 6, 2014 at 8:08 PM, Tom Lane t...@sss.pgh.pa.us wrote: The early-exit code path supposes that JB_ROOT_COUNT is absolutely reliable as an indicator that there's nothing in the jsonb value. On the other hand, the realloc logic inside the

Re: [HACKERS] Schizophrenic coding in gin_extract_jsonb(_hash)

2014-05-07 Thread Heikki Linnakangas
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

Re: [HACKERS] Schizophrenic coding in gin_extract_jsonb(_hash)

2014-05-07 Thread Tom Lane
Heikki Linnakangas hlinnakan...@vmware.com writes: 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. Got it. So if the top level is empty, we can exit early, but otherwise we use its length * 2

Re: [HACKERS] Schizophrenic coding in gin_extract_jsonb(_hash)

2014-05-06 Thread Peter Geoghegan
On Tue, May 6, 2014 at 8:08 PM, Tom Lane t...@sss.pgh.pa.us wrote: The early-exit code path supposes that JB_ROOT_COUNT is absolutely reliable as an indicator that there's nothing in the jsonb value. On the other hand, the realloc logic inside the iteration loop implies that JB_ROOT_COUNT is