pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: b.yordanov2@gmail.com
Cc: pgsql-bugs@postgresql.org, Andrew Dunstan <andrew@dunslane.net>
Subject: Re: BUG #13514: PostgreSQL backend process crashes on jsonb_object_agg()
Date: Wed, 22 Jul 2015 23:14:53 -0400
Message-ID: <26929.1437621293@sss.pgh.pa.us> (raw)
In-Reply-To: <20150722143933.9710.39668@wrigleys.postgresql.org>
References: <20150722143933.9710.39668@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

b.yordanov2@gmail.com writes:
> jsonb_object_agg() appears to fail when the second argument (in this case
> attributes->z->'tt') is a nonexistent jsonb column (there is
> attributes->z->'t' but not 'tt').

Seems to be failure to handle nulls properly.  The attached patch stops
the crash for me, but I've not checked to see if the results are "right",
nor scouted around to see if there are similar bugs nearby.

			regards, tom lane

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

jsonb-nulls-crash.patch (text/x-diff, 1.4K) download diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c index e689722..b82bde0 100644 *** a/src/backend/utils/adt/jsonb.c --- b/src/backend/utils/adt/jsonb.c *************** jsonb_agg_transfn(PG_FUNCTION_ARGS) *** 1606,1612 **** memset(&elem, 0, sizeof(JsonbInState)); ! datum_to_jsonb(val, false, &elem, tcategory, outfuncoid, false); jbelem = JsonbValueToJsonb(elem.res); --- 1606,1612 ---- memset(&elem, 0, sizeof(JsonbInState)); ! datum_to_jsonb(val, PG_ARGISNULL(1), &elem, tcategory, outfuncoid, false); jbelem = JsonbValueToJsonb(elem.res); *************** jsonb_object_agg_transfn(PG_FUNCTION_ARG *** 1759,1765 **** memset(&elem, 0, sizeof(JsonbInState)); ! datum_to_jsonb(val, false, &elem, tcategory, outfuncoid, true); jbkey = JsonbValueToJsonb(elem.res); --- 1759,1765 ---- memset(&elem, 0, sizeof(JsonbInState)); ! datum_to_jsonb(val, PG_ARGISNULL(1), &elem, tcategory, outfuncoid, true); jbkey = JsonbValueToJsonb(elem.res); *************** jsonb_object_agg_transfn(PG_FUNCTION_ARG *** 1777,1783 **** memset(&elem, 0, sizeof(JsonbInState)); ! datum_to_jsonb(val, false, &elem, tcategory, outfuncoid, false); jbval = JsonbValueToJsonb(elem.res); --- 1777,1783 ---- memset(&elem, 0, sizeof(JsonbInState)); ! datum_to_jsonb(val, PG_ARGISNULL(2), &elem, tcategory, outfuncoid, false); jbval = JsonbValueToJsonb(elem.res);

view thread (6+ messages)  latest in thread

Message-ID: <26929.1437621293@sss.pgh.pa.us>
Permalink:  ../26929.1437621293@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26929.1437621293@sss.pgh.pa.us

 ·  · 

reply

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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, b.yordanov2@gmail.com, andrew@dunslane.net
  Subject: Re: BUG #13514: PostgreSQL backend process crashes on jsonb_object_agg()
  In-Reply-To: <26929.1437621293@sss.pgh.pa.us>
  References: <20150722143933.9710.39668@wrigleys.postgresql.org> <26929.1437621293@sss.pgh.pa.us>

* 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