Re: document json[b] limitation

2018-04-25 Thread Oleg Bartunov
On Wed, Apr 25, 2018 at 2:12 AM, Tom Lane  wrote:
> Oleg Bartunov  writes:
>> Attached is a small patch, which documents the maximum size of
>> json[b] types. Probably, it's worth to patch previous releases, where
>> the types were introduced.
>
> If you said "maximum size is 1GB", period, I'd believe it ... although
> I'm pretty sure that general limitation is already documented elsewhere.
> I don't believe that it's possible to make a 256 Gb jsonb.  How will
> that fit in the varlena header?

Oops, it should be 256 Mb :)

>
> regards, tom lane
>



-- 
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



Re: document json[b] limitation

2018-04-25 Thread Oleg Bartunov
On Wed, Apr 25, 2018 at 6:50 PM, Oleg Bartunov  wrote:
> On Wed, Apr 25, 2018 at 2:12 AM, Tom Lane  wrote:
>> Oleg Bartunov  writes:
>>> Attached is a small patch, which documents the maximum size of
>>> json[b] types. Probably, it's worth to patch previous releases, where
>>> the types were introduced.
>>
>> If you said "maximum size is 1GB", period, I'd believe it ... although
>> I'm pretty sure that general limitation is already documented elsewhere.
>> I don't believe that it's possible to make a 256 Gb jsonb.  How will
>> that fit in the varlena header?
>
> Oops, it should be 256 Mb :)

patch attached.

>
>>
>> regards, tom lane
>>
>
>
>
> --
> Postgres Professional: http://www.postgrespro.com
> The Russian Postgres Company



-- 
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company


json.sgml.patch
Description: Binary data


Re: how does jsonb_set work?

2018-04-25 Thread Bruce Momjian
On Sun, Apr 15, 2018 at 01:45:22PM +, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
> 
> Page: https://www.postgresql.org/docs/10/static/functions-json.html
> Description:
> 
> the documentation is missing some information
> 
> how does the jsonb_set function work?
> does it create a whole new json and updates it in the column? or it actually
> only updates the specific key in "path"

jsonb_set() is a function that returns a JSONB value with the fields
changed.  It is up to you to assign it to a column.

-- 
  Bruce Momjian  http://momjian.us
  EnterpriseDB http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+  Ancient Roman grave inscription +



Re: document json[b] limitation

2018-04-25 Thread Michael Paquier
On Wed, Apr 25, 2018 at 06:50:51PM +0300, Oleg Bartunov wrote:
> Oops, it should be 256 Mb :)

The numbers you are presenting are right, aka 1GB for json:
=# create table aa (a json);
CREATE TABLE
=# insert into aa select ('{"key":"' || repeat('a', 512 * 1024 * 1024) ||
 repeat('a', 500 * 1024 * 1024) || '"}')::json;
INSERT 0 1
=# insert into aa select ('{"key":"' || repeat('a', 512 * 1024 *
 1024) || repeat('a', 512 * 1024 * 1024) || '"}')::json;
ERROR:  XX000: invalid memory alloc request size 1073741836
LOCATION:  palloc, mcxt.c:934

And 256MB for jsonb:
=# create table ab (a jsonb);
CREATE TABLE
=# insert into aa select ('{"key":"' || repeat('a', 256 * 1024 *
1024) || '"}')::jsonb;
ERROR:  54000: string too long to represent as jsonb string
DETAIL:  Due to an implementation restriction, jsonb strings cannot
exceed 268435455 bytes.

Be sure to use an upper-case "B" to mean bytes and not bits in the
documentation.
--
Michael


signature.asc
Description: PGP signature