summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/jsonb.c
diff options
context:
space:
mode:
authorPavan Deolasee2016-07-11 08:29:50 +0000
committerPavan Deolasee2016-10-18 10:07:18 +0000
commit073288180d1072bd3f1d27e96e89c674cc10d6a6 (patch)
tree2b07fccd8db67f174a0829a5f741a35cab2a6a95 /src/backend/utils/adt/jsonb.c
parent77f74072fae3c89ed9ce3b169f1ff1481843158a (diff)
Change several asserts checking for aggregate context to errors
This should address the crash in assert-enabled build reported by Pallavi Sontakke. SQLSmith tries to call various functions from system catalogs and functions should be prepared to handle such calls.
Diffstat (limited to 'src/backend/utils/adt/jsonb.c')
-rw-r--r--src/backend/utils/adt/jsonb.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c
index 55bbec9c03..d2b5e1efdc 100644
--- a/src/backend/utils/adt/jsonb.c
+++ b/src/backend/utils/adt/jsonb.c
@@ -1703,9 +1703,11 @@ jsonb_agg_finalfn(PG_FUNCTION_ARGS)
JsonbAggState *arg;
JsonbInState result;
Jsonb *out;
+ MemoryContext aggcontext;
/* cannot be called directly because of internal-type argument */
- Assert(AggCheckCallContext(fcinfo, NULL));
+ if (!AggCheckCallContext(fcinfo, &aggcontext))
+ elog(ERROR, "jsonb_agg_finalfn called in non-aggregate context");
if (PG_ARGISNULL(0))
PG_RETURN_NULL(); /* returns null iff no input values */
@@ -1929,9 +1931,11 @@ jsonb_object_agg_finalfn(PG_FUNCTION_ARGS)
JsonbAggState *arg;
JsonbInState result;
Jsonb *out;
+ MemoryContext aggcontext;
/* cannot be called directly because of internal-type argument */
- Assert(AggCheckCallContext(fcinfo, NULL));
+ if (!AggCheckCallContext(fcinfo, &aggcontext))
+ elog(ERROR, "jsonb_object_agg_finalfn called in non-aggregate context");
if (PG_ARGISNULL(0))
PG_RETURN_NULL(); /* returns null iff no input values */