Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5zoo-0007Vc-Ru for pgsql-general@arkaria.postgresql.org; Mon, 18 Mar 2019 21:29:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h5zon-0000T6-J5 for pgsql-general@arkaria.postgresql.org; Mon, 18 Mar 2019 21:29:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5zon-0000Sm-6l for pgsql-general@lists.postgresql.org; Mon, 18 Mar 2019 21:29:13 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5zoj-0008Tu-Qi for pgsql-general@lists.postgresql.org; Mon, 18 Mar 2019 21:29:11 +0000 Received: from [192.168.127.1] (port=19511 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1h5zoh-000O5A-0q; Mon, 18 Mar 2019 21:29:07 +0000 Received: from [127.0.0.1] (port=48721 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1h5zog-00012F-BN; Mon, 18 Mar 2019 21:29:06 +0000 From: Andrew Gierth To: T L Cc: pgsql-general@lists.postgresql.org Subject: Re: printing JsonbPair values of input JSONB on server side? In-Reply-To: (T. L.'s message of "Mon, 18 Mar 2019 15:59:42 -0500") Message-ID: <87k1gvyizo.fsf@news-spur.riddles.org.uk> References: <87r2b4x7pg.fsf@news-spur.riddles.org.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Mon, 18 Mar 2019 21:29:06 +0000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "T" == T L 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)