1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-05 09:19:17 +03:00

SQL/JSON: Fix some obsolete comments.

JSON_OBJECT(), JSON_OBJETAGG(), JSON_ARRAY(), and JSON_ARRAYAGG()
added in 7081ac46ace are not transformed into direct calls to
user-defined functions as the comments claim. Fix by mentioning
instead that they are transformed into JsonConstructorExpr nodes,
which may call them, for example, for the *AGG() functions.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/058c856a-e090-ac42-ff00-ffe394f52a87%40gmail.com
Backpatch-through: 16
This commit is contained in:
Amit Langote 2024-06-28 15:09:59 +09:00
parent b81a71aa05
commit 3a8a1f3254

View File

@ -3709,11 +3709,9 @@ makeJsonConstructorExpr(ParseState *pstate, JsonConstructorType type,
/* /*
* Transform JSON_OBJECT() constructor. * Transform JSON_OBJECT() constructor.
* *
* JSON_OBJECT() is transformed into json[b]_build_object[_ext]() call * JSON_OBJECT() is transformed into a JsonConstructorExpr node of type
* depending on the output JSON format. The first two arguments of * JSCTOR_JSON_OBJECT. The result is coerced to the target type given
* json[b]_build_object_ext() are absent_on_null and check_unique. * by ctor->output.
*
* Then function call result is coerced to the target type.
*/ */
static Node * static Node *
transformJsonObjectConstructor(ParseState *pstate, JsonObjectConstructor *ctor) transformJsonObjectConstructor(ParseState *pstate, JsonObjectConstructor *ctor)
@ -3903,10 +3901,11 @@ transformJsonAggConstructor(ParseState *pstate, JsonAggConstructor *agg_ctor,
/* /*
* Transform JSON_OBJECTAGG() aggregate function. * Transform JSON_OBJECTAGG() aggregate function.
* *
* JSON_OBJECTAGG() is transformed into * JSON_OBJECT() is transformed into a JsonConstructorExpr node of type
* json[b]_objectagg[_unique][_strict](key, value) call depending on * JSCTOR_JSON_OBJECTAGG, which at runtime becomes a
* the output JSON format. Then the function call result is coerced to the * json[b]_object_agg[_unique][_strict](agg->arg->key, agg->arg->value) call
* target output type. * depending on the output JSON format. The result is coerced to the target
* type given by agg->constructor->output.
*/ */
static Node * static Node *
transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg) transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg)
@ -3966,9 +3965,11 @@ transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg)
/* /*
* Transform JSON_ARRAYAGG() aggregate function. * Transform JSON_ARRAYAGG() aggregate function.
* *
* JSON_ARRAYAGG() is transformed into json[b]_agg[_strict]() call depending * JSON_ARRAYAGG() is transformed into a JsonConstructorExpr node of type
* on the output JSON format and absent_on_null. Then the function call result * JSCTOR_JSON_ARRAYAGG, which at runtime becomes a
* is coerced to the target output type. * json[b]_object_agg[_unique][_strict](agg->arg) call depending on the output
* JSON format. The result is coerced to the target type given by
* agg->constructor->output.
*/ */
static Node * static Node *
transformJsonArrayAgg(ParseState *pstate, JsonArrayAgg *agg) transformJsonArrayAgg(ParseState *pstate, JsonArrayAgg *agg)
@ -4004,11 +4005,9 @@ transformJsonArrayAgg(ParseState *pstate, JsonArrayAgg *agg)
/* /*
* Transform JSON_ARRAY() constructor. * Transform JSON_ARRAY() constructor.
* *
* JSON_ARRAY() is transformed into json[b]_build_array[_ext]() call * JSON_ARRAY() is transformed into a JsonConstructorExpr node of type
* depending on the output JSON format. The first argument of * JSCTOR_JSON_ARRAY. The result is coerced to the target type given
* json[b]_build_array_ext() is absent_on_null. * by ctor->output.
*
* Then function call result is coerced to the target type.
*/ */
static Node * static Node *
transformJsonArrayConstructor(ParseState *pstate, JsonArrayConstructor *ctor) transformJsonArrayConstructor(ParseState *pstate, JsonArrayConstructor *ctor)