Heikki Linnakangas 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 as a guess at how big
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 a
Peter Geoghegan writes:
> On Tue, May 6, 2014 at 8:08 PM, Tom Lane 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
On Tue, May 6, 2014 at 8:08 PM, Tom Lane 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 just an untrustw
Would someone care to defend this code?
inttotal = 2 * JB_ROOT_COUNT(jb);
...
if (total == 0)
{
*nentries = 0;
PG_RETURN_POINTER(NULL);
}
...
while ((r = JsonbIteratorNext(&it, &v, false)) != WJB_DONE)
{
if (i >= total)