diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index cec37ce..69a540e 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -159,7 +159,7 @@ PrepareQuery(PrepareStmt *stmt, const char *queryString) nargs, NULL, NULL, - 0, /* default cursor options */ + CURSOR_OPT_PARALLEL_OK, /* allow parallel mode */ true); /* fixed result */ /* diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 6872562..368c952 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -1539,10 +1539,16 @@ ExecutePlan(EState *estate, estate->es_direction = direction; /* - * If a tuple count was supplied, we must force the plan to run without - * parallelism, because we might exit early. - */ - if (numberTuples) + * Force the plan to run without parallelism, if the operation was not + * a read-only operation or if a tuple count was supplied. We can't run + * in parallel mode if tuple count was supplied, because we might exit + * early. + */ + if (numberTuples || + dest->mydest == DestIntoRel || + dest->mydest == DestCopyOut || + dest->mydest == DestTransientRel || + dest->mydest == DestTuplestore) use_parallel_mode = false; /*