Re: BUG #13514: PostgreSQL backend process crashes on jsonb_object_agg()
От | Tom Lane |
---|---|
Тема | Re: BUG #13514: PostgreSQL backend process crashes on jsonb_object_agg() |
Дата | |
Msg-id | 26929.1437621293@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | BUG #13514: PostgreSQL backend process crashes on jsonb_object_agg() (b.yordanov2@gmail.com) |
Ответы |
Re: BUG #13514: PostgreSQL backend process crashes on jsonb_object_agg()
|
Список | pgsql-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 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);
В списке pgsql-bugs по дате отправления: