summaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2023-03-31 12:55:25 +0200
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2023-03-31 12:55:25 +0200
commit9b058f6b0d9c3d1ccde4d51a72bf15ce731973a1 (patch)
treed66e4a51a7bc85a804de0e9cd2a1bea5460c9dcd /src/backend/executor
parent47a97098467fda56b497049430d0949f3a7dde01 (diff)
downloadpostgresql-9b058f6b0d9c3d1ccde4d51a72bf15ce731973a1.tar.gz
Move ExecEvalJsonConstructor new function to a more natural place
Commit 7081ac46ace8 put it at the end of the file, but that doesn't look very nice.
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execExprInterp.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 8c1e124db6..5e55592f80 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -3885,6 +3885,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
*
* Computes a bitmask with a bit for each (unevaluated) argument expression
@@ -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;
-}