Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fbf76e7

Browse files
author
Nikita Glukhov
committed
Use nodes JsonFomat and JsonReturning in JSON_ARRAYAGG
1 parent cd4b585 commit fbf76e7

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/backend/parser/parse_expr.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4088,7 +4088,7 @@ transformJsonAggCtor(ParseState *pstate, JsonAggCtor *agg_ctor,
40884088
jsctor = makeNode(JsonCtorExpr);
40894089
jsctor->func = (Expr *) node;
40904090
jsctor->type = ctor_type;
4091-
jsctor->returning = *returning;
4091+
jsctor->returning = returning;
40924092
jsctor->unique = unique;
40934093
jsctor->absent_on_null = absent_on_null;
40944094
jsctor->location = agg_ctor->location;
@@ -4107,15 +4107,13 @@ transformJsonAggCtor(ParseState *pstate, JsonAggCtor *agg_ctor,
41074107
static Node *
41084108
transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg)
41094109
{
4110-
JsonReturning returning;
4110+
JsonReturning *returning;
41114111
Node *key;
41124112
Node *val;
41134113
List *args;
41144114
const char *aggfnname;
41154115
Oid aggtype;
41164116

4117-
transformJsonOutput(pstate, agg->ctor.output, true, &returning);
4118-
41194117
key = transformExprRecurse(pstate, (Node *) agg->arg->key);
41204118
val = transformJsonValueExpr(pstate, agg->arg->value, JS_FORMAT_DEFAULT);
41214119

@@ -4124,7 +4122,9 @@ transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg)
41244122
makeBoolConst(agg->absent_on_null, false),
41254123
makeBoolConst(agg->unique, false));
41264124

4127-
if (returning.format.type == JS_FORMAT_JSONB)
4125+
returning = transformJsonCtorOutput(pstate, agg->ctor.output, args);
4126+
4127+
if (returning->format->format == JS_FORMAT_JSONB)
41284128
{
41294129
aggfnname = "pg_catalog.jsonb_objectagg"; /* F_JSONB_OBJECTAGG */
41304130
aggtype = JSONBOID;
@@ -4135,7 +4135,7 @@ transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg)
41354135
aggtype = JSONOID;
41364136
}
41374137

4138-
return transformJsonAggCtor(pstate, &agg->ctor, &returning, args, aggfnname,
4138+
return transformJsonAggCtor(pstate, &agg->ctor, returning, args, aggfnname,
41394139
aggtype, JSCTOR_JSON_OBJECTAGG,
41404140
agg->unique, agg->absent_on_null);
41414141
}
@@ -4150,16 +4150,17 @@ transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg)
41504150
static Node *
41514151
transformJsonArrayAgg(ParseState *pstate, JsonArrayAgg *agg)
41524152
{
4153-
JsonReturning returning;
4153+
JsonReturning *returning;
41544154
Node *arg;
41554155
const char *aggfnname;
41564156
Oid aggtype;
41574157

4158-
transformJsonOutput(pstate, agg->ctor.output, true, &returning);
4159-
41604158
arg = transformJsonValueExpr(pstate, agg->arg, JS_FORMAT_DEFAULT);
41614159

4162-
if (returning.format.type == JS_FORMAT_JSONB)
4160+
returning = transformJsonCtorOutput(pstate, agg->ctor.output,
4161+
list_make1(arg));
4162+
4163+
if (returning->format->format == JS_FORMAT_JSONB)
41634164
{
41644165
aggfnname = agg->absent_on_null ?
41654166
"pg_catalog.jsonb_agg_strict" : "pg_catalog.jsonb_agg";
@@ -4172,7 +4173,7 @@ transformJsonArrayAgg(ParseState *pstate, JsonArrayAgg *agg)
41724173
aggtype = JSONOID;
41734174
}
41744175

4175-
return transformJsonAggCtor(pstate, &agg->ctor, &returning, list_make1(arg),
4176+
return transformJsonAggCtor(pstate, &agg->ctor, returning, list_make1(arg),
41764177
aggfnname, aggtype, JSCTOR_JSON_ARRAYAGG,
41774178
false, agg->absent_on_null);
41784179
}

src/backend/utils/adt/ruleutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9402,7 +9402,7 @@ get_json_ctor_options(JsonCtorExpr *ctor, StringInfo buf)
94029402
if (ctor->unique)
94039403
appendStringInfoString(buf, " WITH UNIQUE KEYS");
94049404

9405-
get_json_returning(&ctor->returning, buf, true);
9405+
get_json_returning(ctor->returning, buf, true);
94069406
}
94079407

94089408
static void

0 commit comments

Comments
 (0)