|
|
|
@ -3884,6 +3884,43 @@ ExecEvalXmlExpr(ExprState *state, ExprEvalStep *op) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Evaluate a JSON constructor expression. |
|
|
|
|
*/ |
|
|
|
|
void |
|
|
|
|
ExecEvalJsonConstructor(ExprState *state, ExprEvalStep *op, |
|
|
|
|
ExprContext *econtext) |
|
|
|
|
{ |
|
|
|
|
Datum res; |
|
|
|
|
JsonConstructorExprState *jcstate = op->d.json_constructor.jcstate; |
|
|
|
|
JsonConstructorExpr *ctor = jcstate->constructor; |
|
|
|
|
bool is_jsonb = ctor->returning->format->format_type == JS_FORMAT_JSONB; |
|
|
|
|
bool isnull = false; |
|
|
|
|
|
|
|
|
|
if (ctor->type == JSCTOR_JSON_ARRAY) |
|
|
|
|
res = (is_jsonb ? |
|
|
|
|
jsonb_build_array_worker : |
|
|
|
|
json_build_array_worker) (jcstate->nargs, |
|
|
|
|
jcstate->arg_values, |
|
|
|
|
jcstate->arg_nulls, |
|
|
|
|
jcstate->arg_types, |
|
|
|
|
jcstate->constructor->absent_on_null); |
|
|
|
|
else if (ctor->type == JSCTOR_JSON_OBJECT) |
|
|
|
|
res = (is_jsonb ? |
|
|
|
|
jsonb_build_object_worker : |
|
|
|
|
json_build_object_worker) (jcstate->nargs, |
|
|
|
|
jcstate->arg_values, |
|
|
|
|
jcstate->arg_nulls, |
|
|
|
|
jcstate->arg_types, |
|
|
|
|
jcstate->constructor->absent_on_null, |
|
|
|
|
jcstate->constructor->unique); |
|
|
|
|
else |
|
|
|
|
elog(ERROR, "invalid JsonConstructorExpr type %d", ctor->type); |
|
|
|
|
|
|
|
|
|
*op->resvalue = res; |
|
|
|
|
*op->resnull = isnull; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ExecEvalGroupingFunc |
|
|
|
|
* |
|
|
|
@ -4447,40 +4484,3 @@ ExecAggPlainTransByRef(AggState *aggstate, AggStatePerTrans pertrans, |
|
|
|
|
|
|
|
|
|
MemoryContextSwitchTo(oldContext); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Evaluate a JSON constructor expression. |
|
|
|
|
*/ |
|
|
|
|
void |
|
|
|
|
ExecEvalJsonConstructor(ExprState *state, ExprEvalStep *op, |
|
|
|
|
ExprContext *econtext) |
|
|
|
|
{ |
|
|
|
|
Datum res; |
|
|
|
|
JsonConstructorExprState *jcstate = op->d.json_constructor.jcstate; |
|
|
|
|
JsonConstructorExpr *ctor = jcstate->constructor; |
|
|
|
|
bool is_jsonb = ctor->returning->format->format_type == JS_FORMAT_JSONB; |
|
|
|
|
bool isnull = false; |
|
|
|
|
|
|
|
|
|
if (ctor->type == JSCTOR_JSON_ARRAY) |
|
|
|
|
res = (is_jsonb ? |
|
|
|
|
jsonb_build_array_worker : |
|
|
|
|
json_build_array_worker) (jcstate->nargs, |
|
|
|
|
jcstate->arg_values, |
|
|
|
|
jcstate->arg_nulls, |
|
|
|
|
jcstate->arg_types, |
|
|
|
|
jcstate->constructor->absent_on_null); |
|
|
|
|
else if (ctor->type == JSCTOR_JSON_OBJECT) |
|
|
|
|
res = (is_jsonb ? |
|
|
|
|
jsonb_build_object_worker : |
|
|
|
|
json_build_object_worker) (jcstate->nargs, |
|
|
|
|
jcstate->arg_values, |
|
|
|
|
jcstate->arg_nulls, |
|
|
|
|
jcstate->arg_types, |
|
|
|
|
jcstate->constructor->absent_on_null, |
|
|
|
|
jcstate->constructor->unique); |
|
|
|
|
else |
|
|
|
|
elog(ERROR, "invalid JsonConstructorExpr type %d", ctor->type); |
|
|
|
|
|
|
|
|
|
*op->resvalue = res; |
|
|
|
|
*op->resnull = isnull; |
|
|
|
|
} |
|
|
|
|