Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "T" == T L <tinlyx@xxxxxxxxx> 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)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux