Commit fc96c694 authored by Andres Freund's avatar Andres Freund

Initialize unused ExprEvalStep fields.

ExecPushExprSlots didn't initialize ExprEvalStep's resvalue/resnull
steps as it didn't use them. That caused wrong valgrind warnings for
an upcoming patch, so zero-intialize.

Also zero-initialize all scratch ExprEvalStep's allocated on the
stack, to avoid issues with similar future omissions of non-critial
data.
parent 1e1e599d
...@@ -118,7 +118,7 @@ ExprState * ...@@ -118,7 +118,7 @@ ExprState *
ExecInitExpr(Expr *node, PlanState *parent) ExecInitExpr(Expr *node, PlanState *parent)
{ {
ExprState *state; ExprState *state;
ExprEvalStep scratch; ExprEvalStep scratch = {0};
/* Special case: NULL expression produces a NULL ExprState pointer */ /* Special case: NULL expression produces a NULL ExprState pointer */
if (node == NULL) if (node == NULL)
...@@ -155,7 +155,7 @@ ExprState * ...@@ -155,7 +155,7 @@ ExprState *
ExecInitExprWithParams(Expr *node, ParamListInfo ext_params) ExecInitExprWithParams(Expr *node, ParamListInfo ext_params)
{ {
ExprState *state; ExprState *state;
ExprEvalStep scratch; ExprEvalStep scratch = {0};
/* Special case: NULL expression produces a NULL ExprState pointer */ /* Special case: NULL expression produces a NULL ExprState pointer */
if (node == NULL) if (node == NULL)
...@@ -204,7 +204,7 @@ ExprState * ...@@ -204,7 +204,7 @@ ExprState *
ExecInitQual(List *qual, PlanState *parent) ExecInitQual(List *qual, PlanState *parent)
{ {
ExprState *state; ExprState *state;
ExprEvalStep scratch; ExprEvalStep scratch = {0};
List *adjust_jumps = NIL; List *adjust_jumps = NIL;
ListCell *lc; ListCell *lc;
...@@ -353,7 +353,7 @@ ExecBuildProjectionInfo(List *targetList, ...@@ -353,7 +353,7 @@ ExecBuildProjectionInfo(List *targetList,
{ {
ProjectionInfo *projInfo = makeNode(ProjectionInfo); ProjectionInfo *projInfo = makeNode(ProjectionInfo);
ExprState *state; ExprState *state;
ExprEvalStep scratch; ExprEvalStep scratch = {0};
ListCell *lc; ListCell *lc;
projInfo->pi_exprContext = econtext; projInfo->pi_exprContext = econtext;
...@@ -638,7 +638,7 @@ static void ...@@ -638,7 +638,7 @@ static void
ExecInitExprRec(Expr *node, ExprState *state, ExecInitExprRec(Expr *node, ExprState *state,
Datum *resv, bool *resnull) Datum *resv, bool *resnull)
{ {
ExprEvalStep scratch; ExprEvalStep scratch = {0};
/* Guard against stack overflow due to overly complex expressions */ /* Guard against stack overflow due to overly complex expressions */
check_stack_depth(); check_stack_depth();
...@@ -2273,7 +2273,10 @@ ExecInitExprSlots(ExprState *state, Node *node) ...@@ -2273,7 +2273,10 @@ ExecInitExprSlots(ExprState *state, Node *node)
static void static void
ExecPushExprSlots(ExprState *state, LastAttnumInfo *info) ExecPushExprSlots(ExprState *state, LastAttnumInfo *info)
{ {
ExprEvalStep scratch; ExprEvalStep scratch = {0};
scratch.resvalue = NULL;
scratch.resnull = NULL;
/* Emit steps as needed */ /* Emit steps as needed */
if (info->last_inner > 0) if (info->last_inner > 0)
...@@ -2659,7 +2662,7 @@ static void ...@@ -2659,7 +2662,7 @@ static void
ExecInitCoerceToDomain(ExprEvalStep *scratch, CoerceToDomain *ctest, ExecInitCoerceToDomain(ExprEvalStep *scratch, CoerceToDomain *ctest,
ExprState *state, Datum *resv, bool *resnull) ExprState *state, Datum *resv, bool *resnull)
{ {
ExprEvalStep scratch2; ExprEvalStep scratch2 = {0};
DomainConstraintRef *constraint_ref; DomainConstraintRef *constraint_ref;
Datum *domainval = NULL; Datum *domainval = NULL;
bool *domainnull = NULL; bool *domainnull = NULL;
...@@ -2811,7 +2814,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, ...@@ -2811,7 +2814,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
{ {
ExprState *state = makeNode(ExprState); ExprState *state = makeNode(ExprState);
PlanState *parent = &aggstate->ss.ps; PlanState *parent = &aggstate->ss.ps;
ExprEvalStep scratch; ExprEvalStep scratch = {0};
int transno = 0; int transno = 0;
int setoff = 0; int setoff = 0;
bool isCombine = DO_AGGSPLIT_COMBINE(aggstate->aggsplit); bool isCombine = DO_AGGSPLIT_COMBINE(aggstate->aggsplit);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment