Re: jsonb and nested hstore - Mailing list pgsql-hackers

From Teodor Sigaev
Subject Re: jsonb and nested hstore
Date
Msg-id 52F25A65.7000305@sigaev.ru
Whole thread Raw
In response to Re: jsonb and nested hstore  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: jsonb and nested hstore  (Andrew Dunstan <andrew@dunslane.net>)
Re: jsonb and nested hstore  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
>> +static void
>> +recvJsonbValue(StringInfo buf, JsonbValue *v, uint32 level, int c)
>> +        v->size = sizeof(JEntry) * 2 + VARSIZE_ANY(v->numeric);
>
> What's the *2 here?
Reservation for aligment. It's allowed to be v->size greater than it's actually 
needed. Fixed.


> This function and recvJsonbValue call each other recursively, afaics
> without any limit, shouldn't they check for the stack depth?
added a check_stack_depth()

>
> *3?

Jentry + header + reservation for aligment

>> +            v->hash.pairs = palloc(sizeof(*v->hash.pairs) * v->hash.npairs);
>> +
if (v->hash.npairs > (buf->len  - buf->cursor) / (2 * sizeof(uint32)))ereport(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE)
2 * sizeof(uint32)  - minimal size of object element (key plus its value)


> Shouldn't that be an ereport(ERRCODE_DATATYPE_MISMATCH)? Similar in a
> few other places.
fixed

>> +char *
>> +JsonbToCString(StringInfo out, char *in, int estimated_len)
> Such a behaviour certainly deserves a documentary comment. Generally
> some more functions could use that.
add comment

>
>> +    while ((type = JsonbIteratorGet(&it, &v, false)) != 0)
>> +reout:
>> +                    goto reout;
>
> Hrmpf.

:) commented

>
>> +Datum
>> +jsonb_typeof(PG_FUNCTION_ARGS)
>> +{
> ...
>> +}
>
> Hm, shouldn't that be in jsonfuncs.c?
No idea, i don't have an objection

send/recv for hstore is fixed too. Should I make new version of patch? Right now 
it's placed on github. May be Andrew wants to change something?



-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
  WWW: http://www.sigaev.ru/
 



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Performance Improvement by reducing WAL for Update Operation
Next
From: Merlin Moncure
Date:
Subject: Re: jsonb and nested hstore