Skip to content

Commit 9b058f6

Browse files
committed
Move ExecEvalJsonConstructor new function to a more natural place
Commit 7081ac4 put it at the end of the file, but that doesn't look very nice.
1 parent 47a9709 commit 9b058f6

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

src/backend/executor/execExprInterp.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3884,6 +3884,43 @@ ExecEvalXmlExpr(ExprState *state, ExprEvalStep *op)
38843884
}
38853885
}
38863886

3887+
/*
3888+
* Evaluate a JSON constructor expression.
3889+
*/
3890+
void
3891+
ExecEvalJsonConstructor(ExprState *state, ExprEvalStep *op,
3892+
ExprContext *econtext)
3893+
{
3894+
Datum res;
3895+
JsonConstructorExprState *jcstate = op->d.json_constructor.jcstate;
3896+
JsonConstructorExpr *ctor = jcstate->constructor;
3897+
bool is_jsonb = ctor->returning->format->format_type == JS_FORMAT_JSONB;
3898+
bool isnull = false;
3899+
3900+
if (ctor->type == JSCTOR_JSON_ARRAY)
3901+
res = (is_jsonb ?
3902+
jsonb_build_array_worker :
3903+
json_build_array_worker) (jcstate->nargs,
3904+
jcstate->arg_values,
3905+
jcstate->arg_nulls,
3906+
jcstate->arg_types,
3907+
jcstate->constructor->absent_on_null);
3908+
else if (ctor->type == JSCTOR_JSON_OBJECT)
3909+
res = (is_jsonb ?
3910+
jsonb_build_object_worker :
3911+
json_build_object_worker) (jcstate->nargs,
3912+
jcstate->arg_values,
3913+
jcstate->arg_nulls,
3914+
jcstate->arg_types,
3915+
jcstate->constructor->absent_on_null,
3916+
jcstate->constructor->unique);
3917+
else
3918+
elog(ERROR, "invalid JsonConstructorExpr type %d", ctor->type);
3919+
3920+
*op->resvalue = res;
3921+
*op->resnull = isnull;
3922+
}
3923+
38873924
/*
38883925
* ExecEvalGroupingFunc
38893926
*
@@ -4447,40 +4484,3 @@ ExecAggPlainTransByRef(AggState *aggstate, AggStatePerTrans pertrans,
44474484

44484485
MemoryContextSwitchTo(oldContext);
44494486
}
4450-
4451-
/*
4452-
* Evaluate a JSON constructor expression.
4453-
*/
4454-
void
4455-
ExecEvalJsonConstructor(ExprState *state, ExprEvalStep *op,
4456-
ExprContext *econtext)
4457-
{
4458-
Datum res;
4459-
JsonConstructorExprState *jcstate = op->d.json_constructor.jcstate;
4460-
JsonConstructorExpr *ctor = jcstate->constructor;
4461-
bool is_jsonb = ctor->returning->format->format_type == JS_FORMAT_JSONB;
4462-
bool isnull = false;
4463-
4464-
if (ctor->type == JSCTOR_JSON_ARRAY)
4465-
res = (is_jsonb ?
4466-
jsonb_build_array_worker :
4467-
json_build_array_worker) (jcstate->nargs,
4468-
jcstate->arg_values,
4469-
jcstate->arg_nulls,
4470-
jcstate->arg_types,
4471-
jcstate->constructor->absent_on_null);
4472-
else if (ctor->type == JSCTOR_JSON_OBJECT)
4473-
res = (is_jsonb ?
4474-
jsonb_build_object_worker :
4475-
json_build_object_worker) (jcstate->nargs,
4476-
jcstate->arg_values,
4477-
jcstate->arg_nulls,
4478-
jcstate->arg_types,
4479-
jcstate->constructor->absent_on_null,
4480-
jcstate->constructor->unique);
4481-
else
4482-
elog(ERROR, "invalid JsonConstructorExpr type %d", ctor->type);
4483-
4484-
*op->resvalue = res;
4485-
*op->resnull = isnull;
4486-
}

src/include/executor/execExpr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,15 +787,15 @@ extern void ExecEvalHashedScalarArrayOp(ExprState *state, ExprEvalStep *op,
787787
extern void ExecEvalConstraintNotNull(ExprState *state, ExprEvalStep *op);
788788
extern void ExecEvalConstraintCheck(ExprState *state, ExprEvalStep *op);
789789
extern void ExecEvalXmlExpr(ExprState *state, ExprEvalStep *op);
790+
extern void ExecEvalJsonConstructor(ExprState *state, ExprEvalStep *op,
791+
ExprContext *econtext);
790792
extern void ExecEvalGroupingFunc(ExprState *state, ExprEvalStep *op);
791793
extern void ExecEvalSubPlan(ExprState *state, ExprEvalStep *op,
792794
ExprContext *econtext);
793795
extern void ExecEvalWholeRowVar(ExprState *state, ExprEvalStep *op,
794796
ExprContext *econtext);
795797
extern void ExecEvalSysVar(ExprState *state, ExprEvalStep *op,
796798
ExprContext *econtext, TupleTableSlot *slot);
797-
extern void ExecEvalJsonConstructor(ExprState *state, ExprEvalStep *op,
798-
ExprContext *econtext);
799799

800800
extern void ExecAggInitGroup(AggState *aggstate, AggStatePerTrans pertrans, AggStatePerGroup pergroup,
801801
ExprContext *aggcontext);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy