From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: T L <tinlyx@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: printing JsonbPair values of input JSONB on server side?
Date: Mon, 18 Mar 2019 21:29:06 +0000
Message-ID: <87k1gvyizo.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <CAOb=C0dQJwL-=uv3Q61irz+2meTVrva6ifmARXCtu5XqJtC7HA@mail.gmail.com>
References: <CAOb=C0c=iuYXAL-b-19t-F0XcPBQOin+vReOqSa2BYminvg6Zw@mail.gmail.com>
<87r2b4x7pg.fsf@news-spur.riddles.org.uk>
<CAOb=C0dQJwL-=uv3Q61irz+2meTVrva6ifmARXCtu5XqJtC7HA@mail.gmail.com>
>>>>> "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)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: andrew@tao11.riddles.org.uk, tinlyx@gmail.com
Subject: Re: printing JsonbPair values of input JSONB on server side?
In-Reply-To: <87k1gvyizo.fsf@news-spur.riddles.org.uk>
References: <CAOb=C0c=iuYXAL-b-19t-F0XcPBQOin+vReOqSa2BYminvg6Zw@mail.gmail.com> <87r2b4x7pg.fsf@news-spur.riddles.org.uk> <CAOb=C0dQJwL-=uv3Q61irz+2meTVrva6ifmARXCtu5XqJtC7HA@mail.gmail.com> <87k1gvyizo.fsf@news-spur.riddles.org.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox