Re: jsonb and nested hstore

Поиск
Список
Период
Сортировка
От Hannu Krosing
Тема Re: jsonb and nested hstore
Дата
Msg-id 52F8A5B3.5080809@2ndQuadrant.com
обсуждение исходный текст
Ответ на Re: jsonb and nested hstore  (Andres Freund <andres@2ndquadrant.com>)
Список pgsql-hackers
On 02/10/2014 11:05 AM, Andres Freund wrote:
> Hi,
>
> On 2014-02-06 18:47:31 -0500, Andrew Dunstan wrote:
>>  * switching to using text representation in jsonb send/recv
>> +/*
>> + * jsonb type recv function
>> + *
>> + * the type is sent as text in binary mode, so this is almost the same
>> + * as the input function.
>> + */
>> +Datum
>> +jsonb_recv(PG_FUNCTION_ARGS)
>> +{
>> +    StringInfo    buf = (StringInfo) PG_GETARG_POINTER(0);
>> +    text       *result = cstring_to_text_with_len(buf->data, buf->len);
>> +
>> +    return deserialize_json_text(result);
>> +}
>> +/*
>> + * jsonb type send function
>> + *
>> + * Just send jsonb as a string of text
>> + */
>> +Datum
>> +jsonb_send(PG_FUNCTION_ARGS)
>> +{
>> +    Jsonb       *jb = PG_GETARG_JSONB(0);
>> +    StringInfoData buf;
>> +    char       *out;
>> +
>> +    out = JsonbToCString(NULL, (JB_ISEMPTY(jb)) ? NULL : VARDATA(jb), VARSIZE(jb));
>> +
>> +    pq_begintypsend(&buf);
>> +    pq_sendtext(&buf, out, strlen(out));
>> +    PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
>> +}
> I'd suggest making the format discernible from possible different future
> formats, to allow introducing a proper binary at some later time. Maybe
> just send a int8 first, containing the format.
+10

Especially as this is one type where we may want add type-specific
compression options at some point


Cheers

-- 
Hannu Krosing
PostgreSQL Consultant
Performance, Scalability and High Availability
2ndQuadrant Nordic OÜ




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: jsonb and nested hstore
Следующее
От: Marti Raudsepp
Дата:
Сообщение: Re: PoC: Partial sort