diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/join.out | 55 | ||||
-rw-r--r-- | src/test/regress/sql/join.sql | 21 |
2 files changed, 76 insertions, 0 deletions
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out index 756c2e24965..5669ed929a7 100644 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@ -2359,6 +2359,61 @@ where b.f1 = t.thousand and a.f1 = b.f1 and (a.f1+b.f1+999) = t.tenthous; (0 rows) -- +-- Test hash joins with multiple hash keys and subplans. +-- +-- First ensure we get a hash join with multiple hash keys. +explain (costs off) +select t1.unique1,t2.unique1 from tenk1 t1 +inner join tenk1 t2 on t1.two = t2.two + and t1.unique1 = (select min(unique1) from tenk1 + where t2.unique1=unique1) +where t1.unique1 < 10 and t2.unique1 < 10 +order by t1.unique1; + QUERY PLAN +---------------------------------------------------------------------------------------------------- + Sort + Sort Key: t1.unique1 + -> Hash Join + Hash Cond: ((t1.two = t2.two) AND (t1.unique1 = (SubPlan 2))) + -> Bitmap Heap Scan on tenk1 t1 + Recheck Cond: (unique1 < 10) + -> Bitmap Index Scan on tenk1_unique1 + Index Cond: (unique1 < 10) + -> Hash + -> Bitmap Heap Scan on tenk1 t2 + Recheck Cond: (unique1 < 10) + -> Bitmap Index Scan on tenk1_unique1 + Index Cond: (unique1 < 10) + SubPlan 2 + -> Result + InitPlan 1 + -> Limit + -> Index Only Scan using tenk1_unique1 on tenk1 + Index Cond: ((unique1 IS NOT NULL) AND (unique1 = t2.unique1)) +(19 rows) + +-- Ensure we get the expected result +select t1.unique1,t2.unique1 from tenk1 t1 +inner join tenk1 t2 on t1.two = t2.two + and t1.unique1 = (select min(unique1) from tenk1 + where t2.unique1=unique1) +where t1.unique1 < 10 and t2.unique1 < 10 +order by t1.unique1; + unique1 | unique1 +---------+--------- + 0 | 0 + 1 | 1 + 2 | 2 + 3 | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 +(10 rows) + +-- -- checks for correct handling of quals in multiway outer joins -- explain (costs off) diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql index 0c65e5af4be..73474bb64f5 100644 --- a/src/test/regress/sql/join.sql +++ b/src/test/regress/sql/join.sql @@ -442,6 +442,27 @@ select a.f1, b.f1, t.thousand, t.tenthous from where b.f1 = t.thousand and a.f1 = b.f1 and (a.f1+b.f1+999) = t.tenthous; -- +-- Test hash joins with multiple hash keys and subplans. +-- + +-- First ensure we get a hash join with multiple hash keys. +explain (costs off) +select t1.unique1,t2.unique1 from tenk1 t1 +inner join tenk1 t2 on t1.two = t2.two + and t1.unique1 = (select min(unique1) from tenk1 + where t2.unique1=unique1) +where t1.unique1 < 10 and t2.unique1 < 10 +order by t1.unique1; + +-- Ensure we get the expected result +select t1.unique1,t2.unique1 from tenk1 t1 +inner join tenk1 t2 on t1.two = t2.two + and t1.unique1 = (select min(unique1) from tenk1 + where t2.unique1=unique1) +where t1.unique1 < 10 and t2.unique1 < 10 +order by t1.unique1; + +-- -- checks for correct handling of quals in multiway outer joins -- explain (costs off) |