Re: WIP Patch: Add a function that returns binary JSONB as a bytea - Mailing list pgsql-hackers

From Andres Freund
Subject Re: WIP Patch: Add a function that returns binary JSONB as a bytea
Date
Msg-id 20181102211816.eznnyvenxweqbzza@alap3.anarazel.de
Whole thread Raw
In response to Re: WIP Patch: Add a function that returns binary JSONB as a bytea  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,


On 2018-11-02 11:52:59 -0400, Tom Lane wrote:
> Andres' point about alignment is a pretty good one as well, if it applies
> here --- I don't recall just what internal alignment requirements jsonb
> has.  We have not historically expected clients to have to deal with that.

Certainly looks like it takes it into account:

static void
fillJsonbValue(JsonbContainer *container, int index,
               char *base_addr, uint32 offset,
               JsonbValue *result)
...
    else if (JBE_ISNUMERIC(entry))
    {
        result->type = jbvNumeric;
        result->val.numeric = (Numeric) (base_addr + INTALIGN(offset));
    }
...
    else
    {
        Assert(JBE_ISCONTAINER(entry));
        result->type = jbvBinary;
        /* Remove alignment padding from data pointer and length */
        result->val.binary.data = (JsonbContainer *) (base_addr + INTALIGN(offset));
        result->val.binary.len = getJsonbLength(container, index) -
            (INTALIGN(offset) - offset);
    }
...

Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: WIP Patch: Add a function that returns binary JSONB as a bytea
Next
From: Andres Freund
Date:
Subject: Re: WIP Patch: Add a function that returns binary JSONB as a bytea