diff --git a/cstore_fdw.c b/cstore_fdw.c index cc36d2c..09eae6c 100644 --- a/cstore_fdw.c +++ b/cstore_fdw.c @@ -140,6 +140,10 @@ static TupleTableSlot * CStoreExecForeignInsert(EState *executorState, TupleTableSlot *tupleSlot, TupleTableSlot *planSlot); static void CStoreEndForeignModify(EState *executorState, ResultRelInfo *relationInfo); +#if PG_VERSION_NUM >= 90600 +static bool CStoreIsForeignScanParallelSafe(PlannerInfo *root, RelOptInfo *rel, + RangeTblEntry *rte); +#endif /* declarations for dynamic loading */ @@ -1206,6 +1210,10 @@ cstore_fdw_handler(PG_FUNCTION_ARGS) fdwRoutine->ExecForeignInsert = CStoreExecForeignInsert; fdwRoutine->EndForeignModify = CStoreEndForeignModify; +#if PG_VERSION_NUM >= 90600 + fdwRoutine->IsForeignScanParallelSafe = CStoreIsForeignScanParallelSafe; +#endif + PG_RETURN_POINTER(fdwRoutine); } @@ -2302,3 +2310,22 @@ CStoreEndForeignModify(EState *executorState, ResultRelInfo *relationInfo) } } + +#if PG_VERSION_NUM >= 90600 +/* + * CStoreIsForeignScanParallelSafe always returns true to indicate that + * reading from a cstore_fdw table in a parallel worker is safe. This + * does not enable parallelism for queries on individual cstore_fdw + * tables, but does allow parallel scans of cstore_fdw partitions. + * + * cstore_fdw is parallel-safe because all writes are immediately committed + * to disk and then read from disk. There is no uncommitted state that needs + * to be shared across processes. + */ +static bool +CStoreIsForeignScanParallelSafe(PlannerInfo *root, RelOptInfo *rel, + RangeTblEntry *rte) +{ + return true; +} +#endif