Re: Wanted: jsonb on-disk representation documentation - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Wanted: jsonb on-disk representation documentation
Date
Msg-id 536A125B.2090005@vmware.com
Whole thread Raw
In response to Re: Wanted: jsonb on-disk representation documentation  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Responses Re: Wanted: jsonb on-disk representation documentation  (Heikki Linnakangas <hlinnakangas@vmware.com>)
List pgsql-hackers
Continuing the review, I don't like the "superheader" terminology. To
me, "super" implies that there's some other kind of header involved, and
the superheader somehow includes or the parent of that. But it actually
seems to refer to the header field in the beginning of an array or
object value. In essence, "superheader" is used as the common term to
refer to an object that can be an array or an object. I propose that we
change that to "container".

Noticed something funny while looking at the convertJsonb function:

postgres=# select substr(((('["' ||repeat('x', 268435455) || '", "' ||
repeat('y', 2) || '"]')::jsonb)::text), 268435455);
                                                                  substr


------------------------------------------------------------------------------
-----------------------------------------------------------
  xxx",
0.000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000]
(1 row)

Somehow the second string element in the array, "yy", gets turned into a
numeric. The reason is that although we check that the length of a
single string doesn't exceed the maximum of 2^28 that can be stored in
the space reserved for the length in a Jentry, there are no length
checks for the end offset stored there in an array. So if the total size
of elements in an array exceed 2^28, funny things like above happen.

Attached is a WIP patch that fixes the above, renames "superheader" to
"container", and includes the refactorings and cleanup that I posted
earlier today.

- Heikki


Attachment

pgsql-hackers by date:

Previous
From: Christoph Berg
Date:
Subject: Re: postgresql.auto.conf read from wrong directory
Next
From: Heikki Linnakangas
Date:
Subject: Re: Wanted: jsonb on-disk representation documentation