Re: BUG #13936: jsonb_object() -> ERROR: unknown type of jsonb container

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: BUG #13936: jsonb_object() -> ERROR: unknown type of jsonb container
Дата
Msg-id 56C9DBCA.1070804@dunslane.net
обсуждение исходный текст
Ответ на Re: BUG #13936: jsonb_object() -> ERROR: unknown type of jsonb container  (Michael Paquier <michael.paquier@gmail.com>)
Ответы Re: BUG #13936: jsonb_object() -> ERROR: unknown type of jsonb container
Список pgsql-bugs
On 02/09/2016 06:57 AM, Michael Paquier wrote:
>
> Yep, this comes from a copy-paste error in jsonb_object_two_arg from
> json_object_two_arg, caused by this bit particularly:
>      if (nkdims == 0)
>          PG_RETURN_DATUM(CStringGetTextDatum("{}"));
> json is represented as an equivalent of a text data type, but that's
> not the case of jsonb. So while this will work for json, that's really
> broken for jsonb.
>
> One way to address this issue is to call jsonb_from_cstring() when
> nkdims == 0. Another method, a bit more complex, is to build an empty
> object and then return it as a result, like more or less that for
> example:
> pushJsonbValue(&result.parseState, WJB_BEGIN_OBJECT, NULL);
> result = pushJsonbValue(&result.parseState, WJB_END_OBJECT, NULL);
> return result;
>
> The patch attached uses jsonb_from_cstring(), with new regression
> tests, and it fixes the issue for me. That seems more simple, but the
> other method would work as well, though I am not sure this is worth
> the complication.
> Regards,



I have committed a fix for this, mainly using your patch. In the end I
used the same pattern for handling the case that we use in the
one-argument form of the function, i.e. we just drop through to the end,
skipping over the part where we add object elements.

cheers

andrew

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

Предыдущее
От: Brian Ghidinelli
Дата:
Сообщение: Re: BUG #13970: Vacuum hangs on particular table; cannot be terminated - requires `kill -QUIT pid`
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: BUG #13936: jsonb_object() -> ERROR: unknown type of jsonb container