summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/json.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/json.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/json.c')
-rw-r--r--src/backend/utils/adt/json.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c
index d8ae7d3985..773ace3c7b 100644
--- a/src/backend/utils/adt/json.c
+++ b/src/backend/utils/adt/json.c
@@ -1961,10 +1961,6 @@ json_agg_collectfn(PG_FUNCTION_ARGS)
elog(ERROR, "json_agg_collectfn called in non-aggregate context");
}
-
- /* cannot be called directly because of internal-type argument */
- Assert(AggCheckCallContext(fcinfo, NULL));
-
if (PG_ARGISNULL(0))
{
/*
@@ -2013,11 +2009,12 @@ json_agg_collectfn(PG_FUNCTION_ARGS)
Datum
json_agg_finalfn(PG_FUNCTION_ARGS)
{
- JsonAggState *state;
+ JsonAggState *state;
MemoryContext aggcontext;
/* cannot be called directly because of internal-type argument */
- Assert(AggCheckCallContext(fcinfo, NULL));
+ if (!AggCheckCallContext(fcinfo, &aggcontext))
+ elog(ERROR, "aggregate function called in non-aggregate context");
state = PG_ARGISNULL(0) ?
NULL :
@@ -2130,11 +2127,12 @@ json_object_agg_transfn(PG_FUNCTION_ARGS)
Datum
json_object_agg_finalfn(PG_FUNCTION_ARGS)
{
- JsonAggState *state;
+ JsonAggState *state;
MemoryContext aggcontext;
/* cannot be called directly because of internal-type argument */
- Assert(AggCheckCallContext(fcinfo, NULL));
+ if (!AggCheckCallContext(fcinfo, &aggcontext))
+ elog(ERROR, "aggregate function called in non-aggregate context");
state = PG_ARGISNULL(0) ? NULL : (JsonAggState *) PG_GETARG_POINTER(0);