Re: printing JsonbPair values of input JSONB on server side?

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема Re: printing JsonbPair values of input JSONB on server side?
Дата
Msg-id 87r2b4x7pg.fsf@news-spur.riddles.org.uk
обсуждение исходный текст
Ответ на printing JsonbPair values of input JSONB on server side?  (T L <tinlyx@gmail.com>)
Ответы Re: printing JsonbPair values of input JSONB on server side?
Список pgsql-general
>>>>> "T" == T L <tinlyx@gmail.com> writes:

 T>     //Problem line!!!
 T>     //            elog(NOTICE, "print_kv_pair(): k = %s, v = %s",
 T>      ptr-> key.val.string.val, numeric_out(ptr->value.val.numeric));

string.val isn't a C string (notice the "not null terminated" comment in
the structure definition), and you can't call numeric_out like that.
Either of those would crash it.

You could use pnstrdup to get a valid C string, and use
DatumGetCString(DirectFunctionCall1(
                  numeric_out,
                  NumericGetDatum(ptr->value.val.numeric)))

to get the numeric value as a C string.

-- 
Andrew (irc:RhodiumToad)


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

Предыдущее
От: T L
Дата:
Сообщение: printing JsonbPair values of input JSONB on server side?
Следующее
От: T L
Дата:
Сообщение: Re: printing JsonbPair values of input JSONB on server side?