Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit84cb51b

Browse files
committed
postgres_fdw: Fix interaction of PHVs with child joins.
Commitf49842d introduced theconcept of a child join, but did not update this code accordingly.Ashutosh Bapat, with cosmetic changes by meDiscussion:http://postgr.es/m/CAFjFpRf=J_KPOtw+bhZeURYkbizr8ufSaXg6gPEF6DKpgH-t6g@mail.gmail.com
1 parentde6428a commit84cb51b

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

‎contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7800,4 +7800,44 @@ SELECT t1.a,t1.b FROM fprt1 t1, LATERAL (SELECT t2.a, t2.b FROM fprt2 t2 WHERE t
78007800
400 | 400
78017801
(4 rows)
78027802

7803+
-- with PHVs, partition-wise join selected but no join pushdown
7804+
EXPLAIN (COSTS OFF)
7805+
SELECT t1.a, t1.phv, t2.b, t2.phv FROM (SELECT 't1_phv' phv, * FROM fprt1 WHERE a % 25 = 0) t1 FULL JOIN (SELECT 't2_phv' phv, * FROM fprt2 WHERE b % 25 = 0) t2 ON (t1.a = t2.b) ORDER BY t1.a, t2.b;
7806+
QUERY PLAN
7807+
------------------------------------------------------------
7808+
Sort
7809+
Sort Key: ftprt1_p1.a, ftprt2_p1.b
7810+
-> Result
7811+
-> Append
7812+
-> Hash Full Join
7813+
Hash Cond: (ftprt1_p1.a = ftprt2_p1.b)
7814+
-> Foreign Scan on ftprt1_p1
7815+
-> Hash
7816+
-> Foreign Scan on ftprt2_p1
7817+
-> Hash Full Join
7818+
Hash Cond: (ftprt1_p2.a = ftprt2_p2.b)
7819+
-> Foreign Scan on ftprt1_p2
7820+
-> Hash
7821+
-> Foreign Scan on ftprt2_p2
7822+
(14 rows)
7823+
7824+
SELECT t1.a, t1.phv, t2.b, t2.phv FROM (SELECT 't1_phv' phv, * FROM fprt1 WHERE a % 25 = 0) t1 FULL JOIN (SELECT 't2_phv' phv, * FROM fprt2 WHERE b % 25 = 0) t2 ON (t1.a = t2.b) ORDER BY t1.a, t2.b;
7825+
a | phv | b | phv
7826+
-----+--------+-----+--------
7827+
0 | t1_phv | 0 | t2_phv
7828+
50 | t1_phv | |
7829+
100 | t1_phv | |
7830+
150 | t1_phv | 150 | t2_phv
7831+
200 | t1_phv | |
7832+
250 | t1_phv | 250 | t2_phv
7833+
300 | t1_phv | |
7834+
350 | t1_phv | |
7835+
400 | t1_phv | 400 | t2_phv
7836+
450 | t1_phv | |
7837+
| | 75 | t2_phv
7838+
| | 225 | t2_phv
7839+
| | 325 | t2_phv
7840+
| | 475 | t2_phv
7841+
(14 rows)
7842+
78037843
RESET enable_partitionwise_join;

‎contrib/postgres_fdw/postgres_fdw.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4565,7 +4565,11 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype,
45654565
foreach(lc,root->placeholder_list)
45664566
{
45674567
PlaceHolderInfo*phinfo=lfirst(lc);
4568-
Relidsrelids=joinrel->relids;
4568+
Relidsrelids;
4569+
4570+
/* PlaceHolderInfo refers to parent relids, not child relids. */
4571+
relids=IS_OTHER_REL(joinrel) ?
4572+
joinrel->top_parent_relids :joinrel->relids;
45694573

45704574
if (bms_is_subset(phinfo->ph_eval_at,relids)&&
45714575
bms_nonempty_difference(relids,phinfo->ph_eval_at))

‎contrib/postgres_fdw/sql/postgres_fdw.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,4 +1913,9 @@ EXPLAIN (COSTS OFF)
19131913
SELECTt1.a,t1.bFROM fprt1 t1, LATERAL (SELECTt2.a,t2.bFROM fprt2 t2WHEREt1.a=t2.bANDt1.b=t2.a) qWHEREt1.a%25=0ORDER BY1,2;
19141914
SELECTt1.a,t1.bFROM fprt1 t1, LATERAL (SELECTt2.a,t2.bFROM fprt2 t2WHEREt1.a=t2.bANDt1.b=t2.a) qWHEREt1.a%25=0ORDER BY1,2;
19151915

1916+
-- with PHVs, partition-wise join selected but no join pushdown
1917+
EXPLAIN (COSTS OFF)
1918+
SELECTt1.a,t1.phv,t2.b,t2.phvFROM (SELECT't1_phv' phv,*FROM fprt1WHERE a %25=0) t1 FULLJOIN (SELECT't2_phv' phv,*FROM fprt2WHERE b %25=0) t2ON (t1.a=t2.b)ORDER BYt1.a,t2.b;
1919+
SELECTt1.a,t1.phv,t2.b,t2.phvFROM (SELECT't1_phv' phv,*FROM fprt1WHERE a %25=0) t1 FULLJOIN (SELECT't2_phv' phv,*FROM fprt2WHERE b %25=0) t2ON (t1.a=t2.b)ORDER BYt1.a,t2.b;
1920+
19161921
RESET enable_partitionwise_join;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp