mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Simplify handling of remote-qual pass-forward in postgres_fdw.
Commit0bf3ae88a
encountered a need to pass the finally chosen remote qual conditions forward from postgresGetForeignPlan to postgresPlanDirectModify. It solved that by sticking them into the plan node's fdw_private list, which in hindsight was a pretty bad idea. In the first place, there's no use for those qual trees either in EXPLAIN or execution; indeed they could never safely be used for any post-planning purposes, because they would not get processed by setrefs.c. So they're just dead weight to carry around in the finished plan tree, plus being an attractive nuisance for somebody who might get the idea that they could be used that way. Secondly, because those qual trees (sometimes) contained RestrictInfos, they created a plan-transmission hazard for parallel query, which is how come we noticed a problem. We dealt with that symptom in commit28b047875
, but really a more straightforward and more efficient fix is to pass the data through in a new field of struct PgFdwRelationInfo. So do it that way. (There's no need to revert28b047875
, as it has sufficient reason to live anyway.) Per fuzz testing by Andreas Seltenreich. Discussion: https://postgr.es/m/87tw5x4vcu.fsf@credativ.de
This commit is contained in:
@ -22,7 +22,10 @@
|
||||
|
||||
/*
|
||||
* FDW-specific planner information kept in RelOptInfo.fdw_private for a
|
||||
* foreign table. This information is collected by postgresGetForeignRelSize.
|
||||
* postgres_fdw foreign table. For a baserel, this struct is created by
|
||||
* postgresGetForeignRelSize, although some fields are not filled till later.
|
||||
* postgresGetForeignJoinPaths creates it for a joinrel, and
|
||||
* postgresGetForeignUpperPaths creates it for an upperrel.
|
||||
*/
|
||||
typedef struct PgFdwRelationInfo
|
||||
{
|
||||
@ -40,6 +43,9 @@ typedef struct PgFdwRelationInfo
|
||||
List *remote_conds;
|
||||
List *local_conds;
|
||||
|
||||
/* Actual remote restriction clauses for scan (sans RestrictInfos) */
|
||||
List *final_remote_exprs;
|
||||
|
||||
/* Bitmap of attr numbers we need to fetch from the remote server. */
|
||||
Bitmapset *attrs_used;
|
||||
|
||||
@ -83,6 +89,7 @@ typedef struct PgFdwRelationInfo
|
||||
RelOptInfo *outerrel;
|
||||
RelOptInfo *innerrel;
|
||||
JoinType jointype;
|
||||
/* joinclauses contains only JOIN/ON conditions for an outer join */
|
||||
List *joinclauses; /* List of RestrictInfo */
|
||||
|
||||
/* Grouping information */
|
||||
|
Reference in New Issue
Block a user