diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-02-26 16:14:46 +0530 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-02-26 16:14:46 +0530 |
commit | 35746bc348b6bf1f690fe17f4f80cfb68e22f504 (patch) | |
tree | 249efeced5372af345491e39d2c442f3ca610b6d /contrib | |
parent | 9117985b6ba9beda4f280f596035649fc23b6233 (diff) | |
download | postgresql-35746bc348b6bf1f690fe17f4f80cfb68e22f504.tar.gz |
Add new FDW API to test for parallel-safety.
This is basically a bug fix; the old code assumes that a ForeignScan
is always parallel-safe, but for postgres_fdw, for example, this is
definitely false. It should be true for file_fdw, though, since a
worker can read a file from the filesystem just as well as any other
backend process.
Original patch by Thomas Munro. Documentation, and changes to the
comments, by me.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/file_fdw/file_fdw.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c index cf12710b71..dc035d72a2 100644 --- a/contrib/file_fdw/file_fdw.c +++ b/contrib/file_fdw/file_fdw.c @@ -131,6 +131,8 @@ static void fileEndForeignScan(ForeignScanState *node); static bool fileAnalyzeForeignTable(Relation relation, AcquireSampleRowsFunc *func, BlockNumber *totalpages); +static bool fileIsForeignScanParallelSafe(PlannerInfo *root, RelOptInfo *rel, + RangeTblEntry *rte); /* * Helper functions @@ -170,6 +172,7 @@ file_fdw_handler(PG_FUNCTION_ARGS) fdwroutine->ReScanForeignScan = fileReScanForeignScan; fdwroutine->EndForeignScan = fileEndForeignScan; fdwroutine->AnalyzeForeignTable = fileAnalyzeForeignTable; + fdwroutine->IsForeignScanParallelSafe = fileIsForeignScanParallelSafe; PG_RETURN_POINTER(fdwroutine); } @@ -762,6 +765,18 @@ fileAnalyzeForeignTable(Relation relation, } /* + * fileIsForeignScanParallelSafe + * Reading a file in a parallel worker should work just the same as + * reading it in the leader, so mark scans safe. + */ +static bool +fileIsForeignScanParallelSafe(PlannerInfo *root, RelOptInfo *rel, + RangeTblEntry *rte) +{ + return true; +} + +/* * check_selective_binary_conversion * * Check to see if it's useful to convert only a subset of the file's columns |