aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2018-01-29 12:16:53 -0800
committerAndres Freund <andres@anarazel.de>2018-01-29 12:19:12 -0800
commitc12693d8f3bbbffcb79f6af476cc647402e1145e (patch)
tree94ea605c5cfd798de9a570fcb5e5cc2c7a9f18a1 /src/backend/executor
parent97d4445a033f1cc02784d42561b52b3441c8eddd (diff)
downloadpostgresql-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/backend/executor')
-rw-r--r--src/backend/executor/nodeBitmapHeapscan.c9
-rw-r--r--src/backend/executor/nodeHash.c10
-rw-r--r--src/backend/executor/nodeIndexonlyscan.c3
-rw-r--r--src/backend/executor/nodeIndexscan.c11
4 files changed, 8 insertions, 25 deletions
diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 7ba1db7d7ec..fa65d4efbe7 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -352,9 +352,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
if (tbmres->recheck)
{
econtext->ecxt_scantuple = slot;
- ResetExprContext(econtext);
-
- if (!ExecQual(node->bitmapqualorig, econtext))
+ if (!ExecQualAndReset(node->bitmapqualorig, econtext))
{
/* Fails recheck, so drop it and loop back for another */
InstrCountFiltered2(node, 1);
@@ -717,10 +715,7 @@ BitmapHeapRecheck(BitmapHeapScanState *node, TupleTableSlot *slot)
/* Does the tuple meet the original qual conditions? */
econtext->ecxt_scantuple = slot;
-
- ResetExprContext(econtext);
-
- return ExecQual(node->bitmapqualorig, econtext);
+ return ExecQualAndReset(node->bitmapqualorig, econtext);
}
/* ----------------------------------------------------------------
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index a9149ef81ce..c26b8ea44e3 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -1942,10 +1942,7 @@ ExecScanHashBucket(HashJoinState *hjstate,
false); /* do not pfree */
econtext->ecxt_innertuple = inntuple;
- /* reset temp memory each time to avoid leaks from qual expr */
- ResetExprContext(econtext);
-
- if (ExecQual(hjclauses, econtext))
+ if (ExecQualAndReset(hjclauses, econtext))
{
hjstate->hj_CurTuple = hashTuple;
return true;
@@ -2002,10 +1999,7 @@ ExecParallelScanHashBucket(HashJoinState *hjstate,
false); /* do not pfree */
econtext->ecxt_innertuple = inntuple;
- /* reset temp memory each time to avoid leaks from qual expr */
- ResetExprContext(econtext);
-
- if (ExecQual(hjclauses, econtext))
+ if (ExecQualAndReset(hjclauses, econtext))
{
hjstate->hj_CurTuple = hashTuple;
return true;
diff --git a/src/backend/executor/nodeIndexonlyscan.c b/src/backend/executor/nodeIndexonlyscan.c
index f61b3abf326..8ffcc52bea5 100644
--- a/src/backend/executor/nodeIndexonlyscan.c
+++ b/src/backend/executor/nodeIndexonlyscan.c
@@ -214,8 +214,7 @@ IndexOnlyNext(IndexOnlyScanState *node)
if (scandesc->xs_recheck)
{
econtext->ecxt_scantuple = slot;
- ResetExprContext(econtext);
- if (!ExecQual(node->indexqual, econtext))
+ if (!ExecQualAndReset(node->indexqual, econtext))
{
/* Fails recheck, so drop it and loop back for another */
InstrCountFiltered2(node, 1);
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c
index eed69a0c665..b8b961add4c 100644
--- a/src/backend/executor/nodeIndexscan.c
+++ b/src/backend/executor/nodeIndexscan.c
@@ -152,8 +152,7 @@ IndexNext(IndexScanState *node)
if (scandesc->xs_recheck)
{
econtext->ecxt_scantuple = slot;
- ResetExprContext(econtext);
- if (!ExecQual(node->indexqualorig, econtext))
+ if (!ExecQualAndReset(node->indexqualorig, econtext))
{
/* Fails recheck, so drop it and loop back for another */
InstrCountFiltered2(node, 1);
@@ -300,8 +299,7 @@ next_indextuple:
if (scandesc->xs_recheck)
{
econtext->ecxt_scantuple = slot;
- ResetExprContext(econtext);
- if (!ExecQual(node->indexqualorig, econtext))
+ if (!ExecQualAndReset(node->indexqualorig, econtext))
{
/* Fails recheck, so drop it and loop back for another */
InstrCountFiltered2(node, 1);
@@ -420,10 +418,7 @@ IndexRecheck(IndexScanState *node, TupleTableSlot *slot)
/* Does the tuple meet the indexqual condition? */
econtext->ecxt_scantuple = slot;
-
- ResetExprContext(econtext);
-
- return ExecQual(node->indexqualorig, econtext);
+ return ExecQualAndReset(node->indexqualorig, econtext);
}