Re: jsonb and nested hstore

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Andres Freund <andres(at)2ndquadrant(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: jsonb and nested hstore
Date: 2014-02-05 15:36:05
Message-ID: 52F25A65.7000305@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2014-02-05 15:48:20 Re: jsonb and nested hstore
Previous Message Amit Kapila 2014-02-05 15:26:47 Re: Performance Improvement by reducing WAL for Update Operation