Re: printing JsonbPair values of input JSONB on server side? - Mailing list pgsql-general

From Andrew Gierth
Subject Re: printing JsonbPair values of input JSONB on server side?
Date
Msg-id 87k1gvyizo.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: printing JsonbPair values of input JSONB on server side?  (T L <tinlyx@gmail.com>)
Responses Re: printing JsonbPair values of input JSONB on server side?  (T L <tinlyx@gmail.com>)
List pgsql-general
>>>>> "T" == T L <tinlyx@gmail.com> writes:

 T>         //problem lines!!! //either elog crashes pg server
 T>         char *buf = pnstrdup(ptr->key.val.string.val,
 T>                              ptr-> key.val.string.len);
 T>         elog(NOTICE, "print_kv_pair(): k = %s",
 T> (ptr->key).val.string.val);  //debug

It doesn't help to make a null-terminated copy of the string if you're
then just going to try and print the original.

    elog(NOTICE, "print_kv_pair(): k = %s", buf);

 T>         elog(NOTICE, "print_kv_pair(): v = %s",
 T> DatumGetCString(DirectFunctionCall1(numeric_out,
 T>                 NumericGetDatum(ptr->value.val.numeric))) ); //debug

That should work, _provided_ that value.type == jbvNumeric - did you
consider checking that first?

-- 
Andrew (irc:RhodiumToad)


pgsql-general by date:

Previous
From: "Peter J. Holzer"
Date:
Subject: Re: Facing issue in using special characters
Next
From: T L
Date:
Subject: Re: printing JsonbPair values of input JSONB on server side?