mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
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.
This commit is contained in:
parent
e259e1f748
commit
d77f014efa
@ -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->resnull = false;
|
||||||
*op->resvalue = *op->resvalue;
|
}
|
||||||
*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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
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->resnull = false;
|
||||||
*op->resvalue = *op->resvalue;
|
}
|
||||||
*op->resnull = false;
|
/* else, input value is the correct output as well */
|
||||||
|
|
||||||
EEO_NEXT();
|
EEO_NEXT();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user