Move ExecEvalJsonConstructor new function to a more natural place
authorAlvaro Herrera <[email protected]>
Fri, 31 Mar 2023 10:55:25 +0000 (12:55 +0200)
committerAlvaro Herrera <[email protected]>
Fri, 31 Mar 2023 10:55:25 +0000 (12:55 +0200)
Commit 7081ac46ace8 put it at the end of the file, but that doesn't look
very nice.

src/backend/executor/execExprInterp.c
src/include/executor/execExpr.h

index 8c1e124db677c762f2cd1a833fb27119788a193c..5e55592f801934fcb4d7ada7269368f58e394a00 100644 (file)
@@ -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;
-}
index f5a72a8b40f0db4259021407ef8353d6ef641ee0..53e2c9a467aaac61aed63c40d6f4e41f5803a6c4 100644 (file)
@@ -787,6 +787,8 @@ extern void ExecEvalHashedScalarArrayOp(ExprState *state, ExprEvalStep *op,
 extern void ExecEvalConstraintNotNull(ExprState *state, ExprEvalStep *op);
 extern void ExecEvalConstraintCheck(ExprState *state, ExprEvalStep *op);
 extern void ExecEvalXmlExpr(ExprState *state, ExprEvalStep *op);
+extern void ExecEvalJsonConstructor(ExprState *state, ExprEvalStep *op,
+                                                                       ExprContext *econtext);
 extern void ExecEvalGroupingFunc(ExprState *state, ExprEvalStep *op);
 extern void ExecEvalSubPlan(ExprState *state, ExprEvalStep *op,
                                                        ExprContext *econtext);
@@ -794,8 +796,6 @@ extern void ExecEvalWholeRowVar(ExprState *state, ExprEvalStep *op,
                                                                ExprContext *econtext);
 extern void ExecEvalSysVar(ExprState *state, ExprEvalStep *op,
                                                   ExprContext *econtext, TupleTableSlot *slot);
-extern void ExecEvalJsonConstructor(ExprState *state, ExprEvalStep *op,
-                                                                       ExprContext *econtext);
 
 extern void ExecAggInitGroup(AggState *aggstate, AggStatePerTrans pertrans, AggStatePerGroup pergroup,
                                                         ExprContext *aggcontext);