Skip to content

Commit

Permalink
Mark foreign scan as parallel safe
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoslot authored and mtuncer committed Dec 14, 2018
1 parent 8141c79 commit 1bbc557
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cstore_fdw.c
Expand Up @@ -143,6 +143,10 @@ static TupleTableSlot * CStoreExecForeignInsert(EState *executorState,
TupleTableSlot *planSlot);
static void CStoreEndForeignModify(EState *executorState, ResultRelInfo *relationInfo);
static void CStoreEndForeignInsert(EState *executorState, ResultRelInfo *relationInfo);
#if PG_VERSION_NUM >= 90600
static bool CStoreIsForeignScanParallelSafe(PlannerInfo *root, RelOptInfo *rel,
RangeTblEntry *rte);
#endif


/* declarations for dynamic loading */
Expand Down Expand Up @@ -1214,6 +1218,10 @@ cstore_fdw_handler(PG_FUNCTION_ARGS)
fdwRoutine->EndForeignInsert = CStoreEndForeignInsert;
#endif

#if PG_VERSION_NUM >= 90600
fdwRoutine->IsForeignScanParallelSafe = CStoreIsForeignScanParallelSafe;
#endif

PG_RETURN_POINTER(fdwRoutine);
}

Expand Down Expand Up @@ -2336,3 +2344,23 @@ CStoreEndForeignInsert(EState *executorState, ResultRelInfo *relationInfo)
heap_close(relation, ShareUpdateExclusiveLock);
}
}


#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

0 comments on commit 1bbc557

Please sign in to comment.