@@ -3138,7 +3138,7 @@ makeJsonByteaToTextConversion(Node *expr, JsonFormat *format, int location)
31383138}
31393139
31403140/*
3141- * Make CaseTestExpr node.
3141+ * Makea CaseTestExpr node.
31423142 */
31433143static Node *
31443144makeCaseTestExpr (Node * expr )
@@ -3456,6 +3456,9 @@ coerceJsonFuncExpr(ParseState *pstate, Node *expr,
34563456return res ;
34573457}
34583458
3459+ /*
3460+ * Make a JsonConstructorExpr node.
3461+ */
34593462static Node *
34603463makeJsonConstructorExpr (ParseState * pstate ,JsonConstructorType type ,
34613464List * args ,Expr * fexpr ,JsonReturning * returning ,
@@ -3464,8 +3467,6 @@ makeJsonConstructorExpr(ParseState *pstate, JsonConstructorType type,
34643467JsonConstructorExpr * jsctor = makeNode (JsonConstructorExpr );
34653468Node * placeholder ;
34663469Node * coercion ;
3467- Oid intermediate_typid =
3468- returning -> format -> format_type == JS_FORMAT_JSONB ?JSONBOID :JSONOID ;
34693470
34703471jsctor -> args = args ;
34713472jsctor -> func = fexpr ;
@@ -3481,7 +3482,8 @@ makeJsonConstructorExpr(ParseState *pstate, JsonConstructorType type,
34813482{
34823483CaseTestExpr * cte = makeNode (CaseTestExpr );
34833484
3484- cte -> typeId = intermediate_typid ;
3485+ cte -> typeId = returning -> format -> format_type == JS_FORMAT_JSONB ?
3486+ JSONBOID :JSONOID ;
34853487cte -> typeMod = -1 ;
34863488cte -> collation = InvalidOid ;
34873489
@@ -3501,7 +3503,7 @@ makeJsonConstructorExpr(ParseState *pstate, JsonConstructorType type,
35013503 *
35023504 * JSON_OBJECT() is transformed into json[b]_build_object[_ext]() call
35033505 * depending on the output JSON format. The first two arguments of
3504- * json[b]_build_object_ext() are absent_on_null andcheck_key_uniqueness .
3506+ * json[b]_build_object_ext() are absent_on_null andcheck_unique .
35053507 *
35063508 * Then function call result is coerced to the target type.
35073509 */
@@ -3615,9 +3617,11 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
36153617{
36163618Oid aggfnoid ;
36173619Node * node ;
3618- Expr * aggfilter = agg_ctor -> agg_filter ? (Expr * )
3619- transformWhereClause (pstate ,agg_ctor -> agg_filter ,
3620- EXPR_KIND_FILTER ,"FILTER" ) :NULL ;
3620+ Expr * aggfilter ;
3621+
3622+ aggfilter = agg_ctor -> agg_filter ? (Expr * )
3623+ transformWhereClause (pstate ,agg_ctor -> agg_filter ,
3624+ EXPR_KIND_FILTER ,"FILTER" ) :NULL ;
36213625
36223626aggfnoid = DatumGetInt32 (DirectFunctionCall1 (regprocin ,
36233627CStringGetDatum (aggfn )));
@@ -3631,10 +3635,10 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
36313635wfunc -> wintype = aggtype ;
36323636/* wincollid and inputcollid will be set by parse_collate.c */
36333637wfunc -> args = args ;
3638+ wfunc -> aggfilter = aggfilter ;
36343639/* winref will be set by transformWindowFuncCall */
36353640wfunc -> winstar = false;
36363641wfunc -> winagg = true;
3637- wfunc -> aggfilter = aggfilter ;
36383642wfunc -> location = agg_ctor -> location ;
36393643
36403644/*
@@ -3659,16 +3663,19 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
36593663aggref -> aggtype = aggtype ;
36603664
36613665/* aggcollid and inputcollid will be set by parse_collate.c */
3662- aggref -> aggtranstype = InvalidOid ; /* will be set by planner */
3666+ /* aggtranstype will be set by planner */
36633667/* aggargtypes will be set by transformAggregateCall */
36643668/* aggdirectargs and args will be set by transformAggregateCall */
36653669/* aggorder and aggdistinct will be set by transformAggregateCall */
36663670aggref -> aggfilter = aggfilter ;
36673671aggref -> aggstar = false;
36683672aggref -> aggvariadic = false;
36693673aggref -> aggkind = AGGKIND_NORMAL ;
3674+ aggref -> aggpresorted = false;
36703675/* agglevelsup will be set by transformAggregateCall */
36713676aggref -> aggsplit = AGGSPLIT_SIMPLE ;/* planner might change this */
3677+ aggref -> aggno = -1 ;/* planner will set aggno and aggtransno */
3678+ aggref -> aggtransno = -1 ;
36723679aggref -> location = agg_ctor -> location ;
36733680
36743681transformAggregateCall (pstate ,aggref ,args ,agg_ctor -> agg_order , false);
@@ -3685,7 +3692,7 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
36853692 * Transform JSON_OBJECTAGG() aggregate function.
36863693 *
36873694 * JSON_OBJECTAGG() is transformed into
3688- * json[b]_objectagg(key, value, absent_on_null, check_unique ) call depending on
3695+ * json[b]_objectagg[_unique][_strict] (key, value) call depending on
36893696 * the output JSON format. Then the function call result is coerced to the
36903697 * target output type.
36913698 */