Commit d77f014e authored by Tom Lane's avatar Tom Lane

Improve implementation of EEOP_BOOLTEST_* opcodes.

Both Andres and I were happy with "*op->resvalue = *op->resvalue;",
but Coverity isn't; and it has a point, because some compilers might
not be smart enough to elide that.  So remove it.  In passing, also
avoid doing unnecessary assignments to *op->resnull when it's already
known to have the right value.
parent e259e1f7
...@@ -958,10 +958,11 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) ...@@ -958,10 +958,11 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
EEO_CASE(EEOP_BOOLTEST_IS_TRUE) EEO_CASE(EEOP_BOOLTEST_IS_TRUE)
{ {
if (*op->resnull) if (*op->resnull)
{
*op->resvalue = BoolGetDatum(false); *op->resvalue = BoolGetDatum(false);
else
*op->resvalue = *op->resvalue;
*op->resnull = false; *op->resnull = false;
}
/* else, input value is the correct output as well */
EEO_NEXT(); EEO_NEXT();
} }
...@@ -969,10 +970,12 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) ...@@ -969,10 +970,12 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
EEO_CASE(EEOP_BOOLTEST_IS_NOT_TRUE) EEO_CASE(EEOP_BOOLTEST_IS_NOT_TRUE)
{ {
if (*op->resnull) if (*op->resnull)
{
*op->resvalue = BoolGetDatum(true); *op->resvalue = BoolGetDatum(true);
*op->resnull = false;
}
else else
*op->resvalue = BoolGetDatum(!DatumGetBool(*op->resvalue)); *op->resvalue = BoolGetDatum(!DatumGetBool(*op->resvalue));
*op->resnull = false;
EEO_NEXT(); EEO_NEXT();
} }
...@@ -980,10 +983,12 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) ...@@ -980,10 +983,12 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
EEO_CASE(EEOP_BOOLTEST_IS_FALSE) EEO_CASE(EEOP_BOOLTEST_IS_FALSE)
{ {
if (*op->resnull) if (*op->resnull)
{
*op->resvalue = BoolGetDatum(false); *op->resvalue = BoolGetDatum(false);
*op->resnull = false;
}
else else
*op->resvalue = BoolGetDatum(!DatumGetBool(*op->resvalue)); *op->resvalue = BoolGetDatum(!DatumGetBool(*op->resvalue));
*op->resnull = false;
EEO_NEXT(); EEO_NEXT();
} }
...@@ -991,10 +996,11 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) ...@@ -991,10 +996,11 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
EEO_CASE(EEOP_BOOLTEST_IS_NOT_FALSE) EEO_CASE(EEOP_BOOLTEST_IS_NOT_FALSE)
{ {
if (*op->resnull) if (*op->resnull)
{
*op->resvalue = BoolGetDatum(true); *op->resvalue = BoolGetDatum(true);
else
*op->resvalue = *op->resvalue;
*op->resnull = false; *op->resnull = false;
}
/* else, input value is the correct output as well */
EEO_NEXT(); EEO_NEXT();
} }
......
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