Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/postgres_fdw')
-rw-r--r--contrib/postgres_fdw/expected/postgres_fdw.out30
-rw-r--r--contrib/postgres_fdw/postgres_fdw.c20
-rw-r--r--contrib/postgres_fdw/sql/postgres_fdw.sql2
3 files changed, 26 insertions, 26 deletions
diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out
index f6d3b8ec08e..77df7eb8e48 100644
--- a/contrib/postgres_fdw/expected/postgres_fdw.out
+++ b/contrib/postgres_fdw/expected/postgres_fdw.out
@@ -2316,31 +2316,21 @@ SELECT t1."C 1" FROM "S 1"."T 1" t1, LATERAL (SELECT DISTINCT t2.c1, t3.c1 FROM
1
(10 rows)
--- join with pseudoconstant quals, not pushed down.
+-- join with pseudoconstant quals
EXPLAIN (VERBOSE, COSTS OFF)
SELECT t1.c1, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1 AND CURRENT_USER = SESSION_USER) ORDER BY t1.c3, t1.c1 OFFSET 100 LIMIT 10;
- QUERY PLAN
--------------------------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit
Output: t1.c1, t2.c1, t1.c3
- -> Sort
+ -> Result
Output: t1.c1, t2.c1, t1.c3
- Sort Key: t1.c3, t1.c1
- -> Result
- Output: t1.c1, t2.c1, t1.c3
- One-Time Filter: (CURRENT_USER = SESSION_USER)
- -> Hash Join
- Output: t1.c1, t1.c3, t2.c1
- Hash Cond: (t2.c1 = t1.c1)
- -> Foreign Scan on public.ft2 t2
- Output: t2.c1
- Remote SQL: SELECT "C 1" FROM "S 1"."T 1"
- -> Hash
- Output: t1.c1, t1.c3
- -> Foreign Scan on public.ft1 t1
- Output: t1.c1, t1.c3
- Remote SQL: SELECT "C 1", c3 FROM "S 1"."T 1"
-(19 rows)
+ One-Time Filter: (CURRENT_USER = SESSION_USER)
+ -> Foreign Scan
+ Output: t1.c1, t1.c3, t2.c1
+ Relations: (public.ft1 t1) INNER JOIN (public.ft2 t2)
+ Remote SQL: SELECT r1."C 1", r2."C 1", r1.c3 FROM ("S 1"."T 1" r1 INNER JOIN "S 1"."T 1" r2 ON (((r2."C 1" = r1."C 1")))) ORDER BY r1.c3 ASC NULLS LAST, r1."C 1" ASC NULLS LAST
+(9 rows)
-- non-Var items in targetlist of the nullable rel of a join preventing
-- push-down in some cases
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index c5cada55fb7..ef58b8b0ea2 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -524,7 +524,7 @@ static List *get_useful_pathkeys_for_relation(PlannerInfo *root,
RelOptInfo *rel);
static List *get_useful_ecs_for_relation(PlannerInfo *root, RelOptInfo *rel);
static void add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel,
- Path *epq_path);
+ Path *epq_path, List *restrictlist);
static void add_foreign_grouping_paths(PlannerInfo *root,
RelOptInfo *input_rel,
RelOptInfo *grouped_rel,
@@ -1034,11 +1034,12 @@ postgresGetForeignPaths(PlannerInfo *root,
NIL, /* no pathkeys */
baserel->lateral_relids,
NULL, /* no extra plan */
+ NIL, /* no fdw_restrictinfo list */
NIL); /* no fdw_private list */
add_path(baserel, (Path *) path);
/* Add paths with pathkeys */
- add_paths_with_pathkeys_for_rel(root, baserel, NULL);
+ add_paths_with_pathkeys_for_rel(root, baserel, NULL, NIL);
/*
* If we're not using remote estimates, stop here. We have no way to
@@ -1206,6 +1207,7 @@ postgresGetForeignPaths(PlannerInfo *root,
NIL, /* no pathkeys */
param_info->ppi_req_outer,
NULL,
+ NIL, /* no fdw_restrictinfo list */
NIL); /* no fdw_private list */
add_path(baserel, (Path *) path);
}
@@ -5991,7 +5993,7 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype,
static void
add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel,
- Path *epq_path)
+ Path *epq_path, List *restrictlist)
{
List *useful_pathkeys_list = NIL; /* List of all pathkeys */
ListCell *lc;
@@ -6085,6 +6087,7 @@ add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel,
useful_pathkeys,
rel->lateral_relids,
sorted_epq_path,
+ NIL, /* no fdw_restrictinfo list */
NIL));
else
add_path(rel, (Path *)
@@ -6096,6 +6099,7 @@ add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel,
useful_pathkeys,
rel->lateral_relids,
sorted_epq_path,
+ restrictlist,
NIL));
}
}
@@ -6348,13 +6352,15 @@ postgresGetForeignJoinPaths(PlannerInfo *root,
NIL, /* no pathkeys */
joinrel->lateral_relids,
epq_path,
+ extra->restrictlist,
NIL); /* no fdw_private */
/* Add generated path into joinrel by add_path(). */
add_path(joinrel, (Path *) joinpath);
/* Consider pathkeys for the join relation */
- add_paths_with_pathkeys_for_rel(root, joinrel, epq_path);
+ add_paths_with_pathkeys_for_rel(root, joinrel, epq_path,
+ extra->restrictlist);
/* XXX Consider parameterized paths for the join relation */
}
@@ -6735,6 +6741,7 @@ add_foreign_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
total_cost,
NIL, /* no pathkeys */
NULL,
+ NIL, /* no fdw_restrictinfo list */
NIL); /* no fdw_private */
/* Add generated path into grouped_rel by add_path(). */
@@ -6868,6 +6875,7 @@ add_foreign_ordered_paths(PlannerInfo *root, RelOptInfo *input_rel,
total_cost,
root->sort_pathkeys,
NULL, /* no extra plan */
+ NIL, /* no fdw_restrictinfo list */
fdw_private);
/* and add it to the ordered_rel */
@@ -6983,7 +6991,8 @@ add_foreign_final_paths(PlannerInfo *root, RelOptInfo *input_rel,
path->total_cost,
path->pathkeys,
NULL, /* no extra plan */
- NULL); /* no fdw_private */
+ NIL, /* no fdw_restrictinfo list */
+ NIL); /* no fdw_private */
/* and add it to the final_rel */
add_path(final_rel, (Path *) final_path);
@@ -7103,6 +7112,7 @@ add_foreign_final_paths(PlannerInfo *root, RelOptInfo *input_rel,
total_cost,
pathkeys,
NULL, /* no extra plan */
+ NIL, /* no fdw_restrictinfo list */
fdw_private);
/* and add it to the final_rel */
diff --git a/contrib/postgres_fdw/sql/postgres_fdw.sql b/contrib/postgres_fdw/sql/postgres_fdw.sql
index 436feee396b..cfb1b57e337 100644
--- a/contrib/postgres_fdw/sql/postgres_fdw.sql
+++ b/contrib/postgres_fdw/sql/postgres_fdw.sql
@@ -640,7 +640,7 @@ SELECT t1c1, avg(t1c1 + t2c1) FROM (SELECT t1.c1, t2.c1 FROM ft1 t1 JOIN ft2 t2
EXPLAIN (VERBOSE, COSTS OFF)
SELECT t1."C 1" FROM "S 1"."T 1" t1, LATERAL (SELECT DISTINCT t2.c1, t3.c1 FROM ft1 t2, ft2 t3 WHERE t2.c1 = t3.c1 AND t2.c2 = t1.c2) q ORDER BY t1."C 1" OFFSET 10 LIMIT 10;
SELECT t1."C 1" FROM "S 1"."T 1" t1, LATERAL (SELECT DISTINCT t2.c1, t3.c1 FROM ft1 t2, ft2 t3 WHERE t2.c1 = t3.c1 AND t2.c2 = t1.c2) q ORDER BY t1."C 1" OFFSET 10 LIMIT 10;
--- join with pseudoconstant quals, not pushed down.
+-- join with pseudoconstant quals
EXPLAIN (VERBOSE, COSTS OFF)
SELECT t1.c1, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1 AND CURRENT_USER = SESSION_USER) ORDER BY t1.c3, t1.c1 OFFSET 100 LIMIT 10;