diff options
| author | Robert Haas | 2016-01-28 19:05:36 +0000 |
|---|---|---|
| committer | Robert Haas | 2016-01-28 19:05:36 +0000 |
| commit | fbe5a3fb73102c2cfec11aaaa4a67943f4474383 (patch) | |
| tree | 44b327ff5aaceb5a20346ee4c914914450e51368 /src/include | |
| parent | 2f6b041f76e6de0fa2921131a23bda794ffb83bb (diff) | |
Only try to push down foreign joins if the user mapping OIDs match.
Previously, the foreign join pushdown infrastructure left the question
of security entirely up to individual FDWs, but it would be easy for
a foreign data wrapper to inadvertently open up subtle security holes
that way. So, make it the core code's job to determine which user
mapping OID is relevant, and don't attempt join pushdown unless it's
the same for all relevant relations.
Per a suggestion from Tom Lane. Shigeru Hanada and Ashutosh Bapat,
reviewed by Etsuro Fujita and KaiGai Kohei, with some further
changes by me.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/foreign/foreign.h | 1 | ||||
| -rw-r--r-- | src/include/nodes/plannodes.h | 1 | ||||
| -rw-r--r-- | src/include/nodes/relation.h | 2 | ||||
| -rw-r--r-- | src/include/utils/plancache.h | 1 |
4 files changed, 5 insertions, 0 deletions
diff --git a/src/include/foreign/foreign.h b/src/include/foreign/foreign.h index 5dc2c90f3c..d1359163e4 100644 --- a/src/include/foreign/foreign.h +++ b/src/include/foreign/foreign.h @@ -72,6 +72,7 @@ typedef struct ForeignTable extern ForeignServer *GetForeignServer(Oid serverid); extern ForeignServer *GetForeignServerByName(const char *name, bool missing_ok); extern UserMapping *GetUserMapping(Oid userid, Oid serverid); +extern Oid GetUserMappingId(Oid userid, Oid serverid); extern ForeignDataWrapper *GetForeignDataWrapper(Oid fdwid); extern ForeignDataWrapper *GetForeignDataWrapperByName(const char *name, bool missing_ok); diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index e823c83011..55d6bbe8f0 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -73,6 +73,7 @@ typedef struct PlannedStmt bool hasRowSecurity; /* row security applied? */ bool parallelModeNeeded; /* parallel mode required to execute? */ + bool hasForeignJoin; /* Plan has a pushed down foreign join */ } PlannedStmt; /* macro for fetching the Plan associated with a SubPlan node */ diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index b233b62d56..94925984bf 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -108,6 +108,7 @@ typedef struct PlannerGlobal bool parallelModeOK; /* parallel mode potentially OK? */ bool parallelModeNeeded; /* parallel mode actually required? */ + bool hasForeignJoin; /* does have a pushed down foreign join */ } PlannerGlobal; /* macro for fetching the Plan associated with a SubPlan node */ @@ -490,6 +491,7 @@ typedef struct RelOptInfo /* Information about foreign tables and foreign joins */ Oid serverid; /* identifies server for the table or join */ + Oid umid; /* identifies user mapping for the table or join */ /* use "struct FdwRoutine" to avoid including fdwapi.h here */ struct FdwRoutine *fdwroutine; void *fdw_private; diff --git a/src/include/utils/plancache.h b/src/include/utils/plancache.h index 0929f58d6b..7a98c5fa97 100644 --- a/src/include/utils/plancache.h +++ b/src/include/utils/plancache.h @@ -135,6 +135,7 @@ typedef struct CachedPlan * changes from this value */ int generation; /* parent's generation number for this plan */ int refcount; /* count of live references to this struct */ + bool has_foreign_join; /* plan has pushed down a foreign join */ MemoryContext context; /* context containing this CachedPlan */ } CachedPlan; |
