+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()


Jentry + header + reservation for aligment

+                       v->hash.pairs = palloc(sizeof(*v->hash.pairs) * 
if (v->hash.npairs > (buf->len  - buf->cursor) / (2 * sizeof(uint32)))
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.

+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)
+                                       goto reout;


:) commented


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: teo...@sigaev.ru
                                                   WWW: http://www.sigaev.ru/

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to