mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Pass constructName to transformJsonValueExpr()
This allows it to pass to coerce_to_specific_type() the actual name corresponding to the specific JSON_* function expression being transformed, instead of the currently hardcoded string. Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/CA+HiwqE4XTdfb1nW=Ojoy_tQSRhYt-q_kb6i5d4xcKyrLC1Nbg@mail.gmail.com
This commit is contained in:
parent
c17164aec8
commit
785480c953
@ -3222,8 +3222,8 @@ makeCaseTestExpr(Node *expr)
|
||||
* default format otherwise.
|
||||
*/
|
||||
static Node *
|
||||
transformJsonValueExpr(ParseState *pstate, JsonValueExpr *ve,
|
||||
JsonFormatType default_format)
|
||||
transformJsonValueExpr(ParseState *pstate, char *constructName,
|
||||
JsonValueExpr *ve, JsonFormatType default_format)
|
||||
{
|
||||
Node *expr = transformExprRecurse(pstate, (Node *) ve->raw_expr);
|
||||
Node *rawexpr;
|
||||
@ -3233,12 +3233,8 @@ transformJsonValueExpr(ParseState *pstate, JsonValueExpr *ve,
|
||||
char typcategory;
|
||||
bool typispreferred;
|
||||
|
||||
/*
|
||||
* Using JSON_VALUE here is slightly bogus: perhaps we need to be passed a
|
||||
* JsonConstructorType so that we can use one of JSON_OBJECTAGG, etc.
|
||||
*/
|
||||
if (exprType(expr) == UNKNOWNOID)
|
||||
expr = coerce_to_specific_type(pstate, expr, TEXTOID, "JSON_VALUE");
|
||||
expr = coerce_to_specific_type(pstate, expr, TEXTOID, constructName);
|
||||
|
||||
rawexpr = expr;
|
||||
exprtype = exprType(expr);
|
||||
@ -3588,7 +3584,8 @@ transformJsonObjectConstructor(ParseState *pstate, JsonObjectConstructor *ctor)
|
||||
{
|
||||
JsonKeyValue *kv = castNode(JsonKeyValue, lfirst(lc));
|
||||
Node *key = transformExprRecurse(pstate, (Node *) kv->key);
|
||||
Node *val = transformJsonValueExpr(pstate, kv->value,
|
||||
Node *val = transformJsonValueExpr(pstate, "JSON_OBJECT()",
|
||||
kv->value,
|
||||
JS_FORMAT_DEFAULT);
|
||||
|
||||
args = lappend(args, key);
|
||||
@ -3768,7 +3765,9 @@ transformJsonObjectAgg(ParseState *pstate, JsonObjectAgg *agg)
|
||||
Oid aggtype;
|
||||
|
||||
key = transformExprRecurse(pstate, (Node *) agg->arg->key);
|
||||
val = transformJsonValueExpr(pstate, agg->arg->value, JS_FORMAT_DEFAULT);
|
||||
val = transformJsonValueExpr(pstate, "JSON_OBJECTAGG()",
|
||||
agg->arg->value,
|
||||
JS_FORMAT_DEFAULT);
|
||||
args = list_make2(key, val);
|
||||
|
||||
returning = transformJsonConstructorOutput(pstate, agg->constructor->output,
|
||||
@ -3824,7 +3823,9 @@ transformJsonArrayAgg(ParseState *pstate, JsonArrayAgg *agg)
|
||||
Oid aggfnoid;
|
||||
Oid aggtype;
|
||||
|
||||
arg = transformJsonValueExpr(pstate, agg->arg, JS_FORMAT_DEFAULT);
|
||||
arg = transformJsonValueExpr(pstate, "JSON_ARRAYAGG()",
|
||||
agg->arg,
|
||||
JS_FORMAT_DEFAULT);
|
||||
|
||||
returning = transformJsonConstructorOutput(pstate, agg->constructor->output,
|
||||
list_make1(arg));
|
||||
@ -3870,7 +3871,8 @@ transformJsonArrayConstructor(ParseState *pstate, JsonArrayConstructor *ctor)
|
||||
foreach(lc, ctor->exprs)
|
||||
{
|
||||
JsonValueExpr *jsval = castNode(JsonValueExpr, lfirst(lc));
|
||||
Node *val = transformJsonValueExpr(pstate, jsval,
|
||||
Node *val = transformJsonValueExpr(pstate, "JSON_ARRAY()",
|
||||
jsval,
|
||||
JS_FORMAT_DEFAULT);
|
||||
|
||||
args = lappend(args, val);
|
||||
|
Loading…
x
Reference in New Issue
Block a user