From 38f4722f6f3db30f68a219853a0caeba2b837845 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Thu, 16 Jun 2016 16:53:02 -0700 Subject: [PATCH] Add tests for LEFT JOIN ON clauses preventing matches left/right. --- .../regress/input/multi_outer_join.source | 13 ++++++++++ .../regress/output/multi_outer_join.source | 24 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/test/regress/input/multi_outer_join.source b/src/test/regress/input/multi_outer_join.source index c59fdec37..6aeca757f 100644 --- a/src/test/regress/input/multi_outer_join.source +++ b/src/test/regress/input/multi_outer_join.source @@ -120,6 +120,19 @@ FROM multi_outer_join_left a LEFT JOIN multi_outer_join_right b ON (l_custkey = r_custkey AND r_custkey = 5); +-- Apply a filter before the join (no matches right) +SELECT + count(l_custkey), count(r_custkey) +FROM + multi_outer_join_left a LEFT JOIN multi_outer_join_right b + ON (l_custkey = r_custkey AND r_custkey = -1 /* nonexistant */); + +-- Apply a filter before the join (no matches left) +SELECT + count(l_custkey), count(r_custkey) +FROM + multi_outer_join_left a LEFT JOIN multi_outer_join_right b + ON (l_custkey = r_custkey AND l_custkey = -1 /* nonexistant */); -- Right join should be disallowed in this case SELECT diff --git a/src/test/regress/output/multi_outer_join.source b/src/test/regress/output/multi_outer_join.source index 3a159e840..fedd7a657 100644 --- a/src/test/regress/output/multi_outer_join.source +++ b/src/test/regress/output/multi_outer_join.source @@ -158,6 +158,30 @@ LOG: join order: [ "multi_outer_join_left" ][ broadcast join "multi_outer_join_ 20 | 1 (1 row) +-- Apply a filter before the join (no matches right) +SELECT + count(l_custkey), count(r_custkey) +FROM + multi_outer_join_left a LEFT JOIN multi_outer_join_right b + ON (l_custkey = r_custkey AND r_custkey = -1 /* nonexistant */); +LOG: join order: [ "multi_outer_join_left" ][ broadcast join "multi_outer_join_right" ] + count | count +-------+------- + 20 | 0 +(1 row) + +-- Apply a filter before the join (no matches left) +SELECT + count(l_custkey), count(r_custkey) +FROM + multi_outer_join_left a LEFT JOIN multi_outer_join_right b + ON (l_custkey = r_custkey AND l_custkey = -1 /* nonexistant */); +LOG: join order: [ "multi_outer_join_left" ][ broadcast join "multi_outer_join_right" ] + count | count +-------+------- + 20 | 0 +(1 row) + -- Right join should be disallowed in this case SELECT min(r_custkey), max(r_custkey)