diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-03-26 15:57:02 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-03-26 15:57:02 -0400 |
commit | d77f014efa7eda4357fbc851dbf25c6b256ddf35 (patch) | |
tree | da3c05889a9de9400b1a5027dd0273e609080c87 | |
parent | e259e1f748c7a6d67e307a90d6c27b8ab8b90df8 (diff) | |
download | postgresql-d77f014efa7eda4357fbc851dbf25c6b256ddf35.tar.gz postgresql-d77f014efa7eda4357fbc851dbf25c6b256ddf35.zip |
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.
-rw-r--r-- | src/backend/executor/execExprInterp.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c index de7fe895f81..02fb29cde3f 100644 --- a/src/backend/executor/execExprInterp.c +++ b/src/backend/executor/execExprInterp.c @@ -958,10 +958,11 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) EEO_CASE(EEOP_BOOLTEST_IS_TRUE) { if (*op->resnull) + { *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(); } @@ -969,10 +970,12 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) EEO_CASE(EEOP_BOOLTEST_IS_NOT_TRUE) { if (*op->resnull) + { *op->resvalue = BoolGetDatum(true); + *op->resnull = false; + } else *op->resvalue = BoolGetDatum(!DatumGetBool(*op->resvalue)); - *op->resnull = false; EEO_NEXT(); } @@ -980,10 +983,12 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) EEO_CASE(EEOP_BOOLTEST_IS_FALSE) { if (*op->resnull) + { *op->resvalue = BoolGetDatum(false); + *op->resnull = false; + } else *op->resvalue = BoolGetDatum(!DatumGetBool(*op->resvalue)); - *op->resnull = false; EEO_NEXT(); } @@ -991,10 +996,11 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) EEO_CASE(EEOP_BOOLTEST_IS_NOT_FALSE) { if (*op->resnull) + { *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(); } |