diff options
author | Andres Freund <andres@anarazel.de> | 2018-01-29 12:16:53 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2018-01-29 12:19:12 -0800 |
commit | c12693d8f3bbbffcb79f6af476cc647402e1145e (patch) | |
tree | 94ea605c5cfd798de9a570fcb5e5cc2c7a9f18a1 /src/include/executor/executor.h | |
parent | 97d4445a033f1cc02784d42561b52b3441c8eddd (diff) | |
download | postgresql-c12693d8f3bbbffcb79f6af476cc647402e1145e.tar.gz postgresql-c12693d8f3bbbffcb79f6af476cc647402e1145e.zip |
Introduce ExecQualAndReset() helper.
It's a common task to evaluate a qual and reset the corresponding
expression context. Currently that requires storing the result of the
qual eval, resetting the context, and then reacting on the result. As
that's awkward several places only reset the context next time through
a node. That's not great, so introduce a helper that evaluates and
resets.
It's a bit ugly that it currently uses MemoryContextReset() instead of
ResetExprContext(), but that seems easier than reordering all of
executor.h.
Author: Andres Freund
Discussion: https://postgr.es/m/20180109222544.f7loxrunqh3xjl5f@alap3.anarazel.de
Diffstat (limited to 'src/include/executor/executor.h')
-rw-r--r-- | src/include/executor/executor.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 6545a802223..1d824eff361 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -17,6 +17,7 @@ #include "catalog/partition.h" #include "executor/execdesc.h" #include "nodes/parsenodes.h" +#include "utils/memutils.h" /* @@ -381,6 +382,22 @@ ExecQual(ExprState *state, ExprContext *econtext) } #endif +/* + * ExecQualAndReset() - evaluate qual with ExecQual() and reset expression + * context. + */ +#ifndef FRONTEND +static inline bool +ExecQualAndReset(ExprState *state, ExprContext *econtext) +{ + bool ret = ExecQual(state, econtext); + + /* inline ResetExprContext, to avoid ordering issue in this file */ + MemoryContextReset(econtext->ecxt_per_tuple_memory); + return ret; +} +#endif + extern bool ExecCheck(ExprState *state, ExprContext *context); /* |