Re: [GENERAL] How to get the size of JSONB in bytes?

2015-12-15 Thread Dmitry Savenko
Hi, Petr, Jim, thank you for suggestions and thoughts. Now I see, that you can't cast 'jsonb' to 'bytea' directly, but you can do it through 'text'. I modified my trigger like this create function check_document() returns trigger as $$ begin if 10240 < octet_length(new.jdoc::text::bytea) the

[GENERAL] How to get the size of JSONB in bytes?

2015-12-15 Thread Dmitry Savenko
Hi, I want to impose size restrictions on JSONB documents stored in my table. Say, no document over 10Kb must be inserted in the table. For that, I try to write a trigger like this (jdoc here is of JSONB type): create function check_document() returns trigger as $$ begin    if 10 * 1024 < octet_l