summaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execMain.c53
-rw-r--r--src/backend/executor/execParallel.c3
-rw-r--r--src/backend/executor/functions.c2
-rw-r--r--src/backend/executor/spi.c2
4 files changed, 25 insertions, 35 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 5ca856fd279..13f3fcdaee9 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -77,14 +77,12 @@ static void InitPlan(QueryDesc *queryDesc, int eflags);
static void CheckValidRowMarkRel(Relation rel, RowMarkType markType);
static void ExecPostprocessPlan(EState *estate);
static void ExecEndPlan(PlanState *planstate, EState *estate);
-static void ExecutePlan(EState *estate, PlanState *planstate,
- bool use_parallel_mode,
+static void ExecutePlan(QueryDesc *queryDesc,
CmdType operation,
bool sendTuples,
uint64 numberTuples,
ScanDirection direction,
- DestReceiver *dest,
- bool execute_once);
+ DestReceiver *dest);
static bool ExecCheckOneRelPerms(RTEPermissionInfo *perminfo);
static bool ExecCheckPermissionsModified(Oid relOid, Oid userid,
Bitmapset *modifiedCols,
@@ -294,18 +292,17 @@ standard_ExecutorStart(QueryDesc *queryDesc, int eflags)
*/
void
ExecutorRun(QueryDesc *queryDesc,
- ScanDirection direction, uint64 count,
- bool execute_once)
+ ScanDirection direction, uint64 count)
{
if (ExecutorRun_hook)
- (*ExecutorRun_hook) (queryDesc, direction, count, execute_once);
+ (*ExecutorRun_hook) (queryDesc, direction, count);
else
- standard_ExecutorRun(queryDesc, direction, count, execute_once);
+ standard_ExecutorRun(queryDesc, direction, count);
}
void
standard_ExecutorRun(QueryDesc *queryDesc,
- ScanDirection direction, uint64 count, bool execute_once)
+ ScanDirection direction, uint64 count)
{
EState *estate;
CmdType operation;
@@ -354,21 +351,12 @@ standard_ExecutorRun(QueryDesc *queryDesc,
* run plan
*/
if (!ScanDirectionIsNoMovement(direction))
- {
- if (execute_once && queryDesc->already_executed)
- elog(ERROR, "can't re-execute query flagged for single execution");
- queryDesc->already_executed = true;
-
- ExecutePlan(estate,
- queryDesc->planstate,
- queryDesc->plannedstmt->parallelModeNeeded,
+ ExecutePlan(queryDesc,
operation,
sendTuples,
count,
direction,
- dest,
- execute_once);
- }
+ dest);
/*
* Update es_total_processed to keep track of the number of tuples
@@ -1601,22 +1589,19 @@ ExecCloseRangeTableRelations(EState *estate)
* moving in the specified direction.
*
* Runs to completion if numberTuples is 0
- *
- * Note: the ctid attribute is a 'junk' attribute that is removed before the
- * user can see it
* ----------------------------------------------------------------
*/
static void
-ExecutePlan(EState *estate,
- PlanState *planstate,
- bool use_parallel_mode,
+ExecutePlan(QueryDesc *queryDesc,
CmdType operation,
bool sendTuples,
uint64 numberTuples,
ScanDirection direction,
- DestReceiver *dest,
- bool execute_once)
+ DestReceiver *dest)
{
+ EState *estate = queryDesc->estate;
+ PlanState *planstate = queryDesc->planstate;
+ bool use_parallel_mode;
TupleTableSlot *slot;
uint64 current_tuple_count;
@@ -1631,11 +1616,17 @@ ExecutePlan(EState *estate,
estate->es_direction = direction;
/*
- * If the plan might potentially be executed multiple times, we must force
- * it to run without parallelism, because we might exit early.
+ * Set up parallel mode if appropriate.
+ *
+ * Parallel mode only supports complete execution of a plan. If we've
+ * already partially executed it, or if the caller asks us to exit early,
+ * we must force the plan to run without parallelism.
*/
- if (!execute_once)
+ if (queryDesc->already_executed || numberTuples != 0)
use_parallel_mode = false;
+ else
+ use_parallel_mode = queryDesc->plannedstmt->parallelModeNeeded;
+ queryDesc->already_executed = true;
estate->es_use_parallel_mode = use_parallel_mode;
if (use_parallel_mode)
diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c
index bfb3419efb7..846ec727deb 100644
--- a/src/backend/executor/execParallel.c
+++ b/src/backend/executor/execParallel.c
@@ -1471,8 +1471,7 @@ ParallelQueryMain(dsm_segment *seg, shm_toc *toc)
*/
ExecutorRun(queryDesc,
ForwardScanDirection,
- fpes->tuples_needed < 0 ? (int64) 0 : fpes->tuples_needed,
- true);
+ fpes->tuples_needed < 0 ? (int64) 0 : fpes->tuples_needed);
/* Shut down the executor */
ExecutorFinish(queryDesc);
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 8d1fda2ddc0..3b2f78b2197 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -894,7 +894,7 @@ postquel_getnext(execution_state *es, SQLFunctionCachePtr fcache)
/* Run regular commands to completion unless lazyEval */
uint64 count = (es->lazyEval) ? 1 : 0;
- ExecutorRun(es->qd, ForwardScanDirection, count, !fcache->returnsSet || !es->lazyEval);
+ ExecutorRun(es->qd, ForwardScanDirection, count);
/*
* If we requested run to completion OR there was no tuple returned,
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 2fb2e73604e..c1d8fd08c6c 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -2929,7 +2929,7 @@ _SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, uint64 tcount)
ExecutorStart(queryDesc, eflags);
- ExecutorRun(queryDesc, ForwardScanDirection, tcount, true);
+ ExecutorRun(queryDesc, ForwardScanDirection, tcount);
_SPI_current->processed = queryDesc->estate->es_processed;