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

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: T L <tinlyx(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: printing JsonbPair values of input JSONB on server side?
Date: 2019-03-18 21:29:06
Message-ID: 87k1gvyizo.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>>> "T" == T L <tinlyx(at)gmail(dot)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)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message T L 2019-03-18 21:57:31 Re: printing JsonbPair values of input JSONB on server side?
Previous Message Peter J. Holzer 2019-03-18 21:19:23 Re: Facing issue in using special characters