Oid *rettype,
int32 *rettypmod);
static int exec_run_select(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr, long maxtuples, Portal *portalP,
- bool parallelOK);
+ PLpgSQL_expr *expr, long maxtuples, Portal *portalP);
static int exec_for_query(PLpgSQL_execstate *estate, PLpgSQL_stmt_forq *stmt,
Portal portal, bool prefetch_ok);
static ParamListInfo setup_param_list(PLpgSQL_execstate *estate,
{
PLpgSQL_expr *expr = stmt->expr;
- (void) exec_run_select(estate, expr, 0, NULL, true);
+ (void) exec_run_select(estate, expr, 0, NULL);
exec_set_found(estate, (estate->eval_processed != 0));
exec_eval_cleanup(estate);
/*
* Open the implicit cursor for the statement using exec_run_select
*/
- exec_run_select(estate, stmt->query, 0, &portal, false);
+ exec_run_select(estate, stmt->query, 0, &portal);
/*
* Execute the loop
if (stmt->query != NULL)
{
/* static query */
- exec_run_select(estate, stmt->query, 0, &portal, false);
+ exec_run_select(estate, stmt->query, 0, &portal);
}
else
{
{
ListCell *l;
- exec_prepare_plan(estate, expr, 0);
+ exec_prepare_plan(estate, expr, CURSOR_OPT_PARALLEL_OK);
stmt->mod_stmt = false;
foreach(l, SPI_plan_get_plan_sources(expr->plan))
{
* If first time through, create a plan for this expression.
*/
if (expr->plan == NULL)
- exec_prepare_plan(estate, expr, 0);
+ exec_prepare_plan(estate, expr, CURSOR_OPT_PARALLEL_OK);
/*
* If this is a simple expression, bypass SPI and use the executor
/*
* Else do it the hard way via exec_run_select
*/
- rc = exec_run_select(estate, expr, 2, NULL, false);
+ rc = exec_run_select(estate, expr, 2, NULL);
if (rc != SPI_OK_SELECT)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
*/
static int
exec_run_select(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr, long maxtuples, Portal *portalP,
- bool parallelOK)
+ PLpgSQL_expr *expr, long maxtuples, Portal *portalP)
{
ParamListInfo paramLI;
int rc;
/*
- * On the first call for this expression generate the plan
+ * On the first call for this expression generate the plan.
+ *
+ * If we don't need to return a portal, then we're just going to execute
+ * the query once, which means it's OK to use a parallel plan, even if the
+ * number of rows being fetched is limited. If we do need to return a
+ * portal, the caller might do cursor operations, which parallel query
+ * can't support.
*/
if (expr->plan == NULL)
- exec_prepare_plan(estate, expr, parallelOK ?
- CURSOR_OPT_PARALLEL_OK : 0);
+ exec_prepare_plan(estate, expr,
+ portalP == NULL ? CURSOR_OPT_PARALLEL_OK : 0);
/*
* If a portal was requested, put the query into the portal