@@ -3138,7 +3138,7 @@ makeJsonByteaToTextConversion(Node *expr, JsonFormat *format, int location)
3138
3138
}
3139
3139
3140
3140
/*
3141
- * Make CaseTestExpr node.
3141
+ * Make a CaseTestExpr node.
3142
3142
*/
3143
3143
static Node *
3144
3144
makeCaseTestExpr (Node * expr )
@@ -3456,6 +3456,9 @@ coerceJsonFuncExpr(ParseState *pstate, Node *expr,
3456
3456
return res ;
3457
3457
}
3458
3458
3459
+ /*
3460
+ * Make a JsonConstructorExpr node.
3461
+ */
3459
3462
static Node *
3460
3463
makeJsonConstructorExpr (ParseState * pstate , JsonConstructorType type ,
3461
3464
List * args , Expr * fexpr , JsonReturning * returning ,
@@ -3464,8 +3467,6 @@ makeJsonConstructorExpr(ParseState *pstate, JsonConstructorType type,
3464
3467
JsonConstructorExpr * jsctor = makeNode (JsonConstructorExpr );
3465
3468
Node * placeholder ;
3466
3469
Node * coercion ;
3467
- Oid intermediate_typid =
3468
- returning -> format -> format_type == JS_FORMAT_JSONB ? JSONBOID : JSONOID ;
3469
3470
3470
3471
jsctor -> args = args ;
3471
3472
jsctor -> func = fexpr ;
@@ -3481,7 +3482,8 @@ makeJsonConstructorExpr(ParseState *pstate, JsonConstructorType type,
3481
3482
{
3482
3483
CaseTestExpr * cte = makeNode (CaseTestExpr );
3483
3484
3484
- cte -> typeId = intermediate_typid ;
3485
+ cte -> typeId = returning -> format -> format_type == JS_FORMAT_JSONB ?
3486
+ JSONBOID : JSONOID ;
3485
3487
cte -> typeMod = -1 ;
3486
3488
cte -> collation = InvalidOid ;
3487
3489
@@ -3501,7 +3503,7 @@ makeJsonConstructorExpr(ParseState *pstate, JsonConstructorType type,
3501
3503
*
3502
3504
* JSON_OBJECT() is transformed into json[b]_build_object[_ext]() call
3503
3505
* depending on the output JSON format. The first two arguments of
3504
- * json[b]_build_object_ext() are absent_on_null and check_key_uniqueness .
3506
+ * json[b]_build_object_ext() are absent_on_null and check_unique .
3505
3507
*
3506
3508
* Then function call result is coerced to the target type.
3507
3509
*/
@@ -3615,9 +3617,11 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
3615
3617
{
3616
3618
Oid aggfnoid ;
3617
3619
Node * 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 ;
3621
3625
3622
3626
aggfnoid = DatumGetInt32 (DirectFunctionCall1 (regprocin ,
3623
3627
CStringGetDatum (aggfn )));
@@ -3631,10 +3635,10 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
3631
3635
wfunc -> wintype = aggtype ;
3632
3636
/* wincollid and inputcollid will be set by parse_collate.c */
3633
3637
wfunc -> args = args ;
3638
+ wfunc -> aggfilter = aggfilter ;
3634
3639
/* winref will be set by transformWindowFuncCall */
3635
3640
wfunc -> winstar = false;
3636
3641
wfunc -> winagg = true;
3637
- wfunc -> aggfilter = aggfilter ;
3638
3642
wfunc -> location = agg_ctor -> location ;
3639
3643
3640
3644
/*
@@ -3659,16 +3663,19 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
3659
3663
aggref -> aggtype = aggtype ;
3660
3664
3661
3665
/* 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 */
3663
3667
/* aggargtypes will be set by transformAggregateCall */
3664
3668
/* aggdirectargs and args will be set by transformAggregateCall */
3665
3669
/* aggorder and aggdistinct will be set by transformAggregateCall */
3666
3670
aggref -> aggfilter = aggfilter ;
3667
3671
aggref -> aggstar = false;
3668
3672
aggref -> aggvariadic = false;
3669
3673
aggref -> aggkind = AGGKIND_NORMAL ;
3674
+ aggref -> aggpresorted = false;
3670
3675
/* agglevelsup will be set by transformAggregateCall */
3671
3676
aggref -> aggsplit = AGGSPLIT_SIMPLE ; /* planner might change this */
3677
+ aggref -> aggno = -1 ; /* planner will set aggno and aggtransno */
3678
+ aggref -> aggtransno = -1 ;
3672
3679
aggref -> location = agg_ctor -> location ;
3673
3680
3674
3681
transformAggregateCall (pstate , aggref , args , agg_ctor -> agg_order , false);
@@ -3685,7 +3692,7 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
3685
3692
* Transform JSON_OBJECTAGG() aggregate function.
3686
3693
*
3687
3694
* 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
3689
3696
* the output JSON format. Then the function call result is coerced to the
3690
3697
* target output type.
3691
3698
*/
0 commit comments