]> granicus.if.org Git - postgresql/commitdiff
Fix a bug in the original implementation of redundant-join-clause removal:
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 31 Jul 2007 19:53:37 +0000 (19:53 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 31 Jul 2007 19:53:37 +0000 (19:53 +0000)
clauses in which one side or the other references both sides of the join
cannot be removed as redundant, because that expression won't have been
constrained below the join.  Per report from Sergey Burladyan.

CVS HEAD does not contain this bug due to EquivalenceClass rewrite, but it
seems wise to include the regression test for it anyway.

src/test/regress/expected/join.out
src/test/regress/expected/join_1.out
src/test/regress/sql/join.sql

index 8b6716def814c2b0ca67e46c8b503c60ec7fbf83..3b7bdd9cbb321f9b0aa125b0b169746947ab1321 100644 (file)
@@ -2250,3 +2250,19 @@ WHERE d.f1 IS NULL;
  9999
 (3 rows)
 
+--
+-- regression test for problems of the sort depicted in bug #3494
+--
+create temp table tt5(f1 int, f2 int);
+create temp table tt6(f1 int, f2 int);
+insert into tt5 values(1, 10);
+insert into tt5 values(1, 11);
+insert into tt6 values(1, 9);
+insert into tt6 values(1, 2);
+insert into tt6 values(2, 9);
+select * from tt5,tt6 where tt5.f1 = tt6.f1 and tt5.f1 = tt5.f2 - tt6.f2;
+ f1 | f2 | f1 | f2 
+----+----+----+----
+  1 | 10 |  1 |  9
+(1 row)
+
index 8e7e4de014147c73114e525638f78e23a1d32d43..f1bf4b9af269b25781478148296430ddbcfeecaf 100644 (file)
@@ -2250,3 +2250,19 @@ WHERE d.f1 IS NULL;
  9999
 (3 rows)
 
+--
+-- regression test for problems of the sort depicted in bug #3494
+--
+create temp table tt5(f1 int, f2 int);
+create temp table tt6(f1 int, f2 int);
+insert into tt5 values(1, 10);
+insert into tt5 values(1, 11);
+insert into tt6 values(1, 9);
+insert into tt6 values(1, 2);
+insert into tt6 values(2, 9);
+select * from tt5,tt6 where tt5.f1 = tt6.f1 and tt5.f1 = tt5.f2 - tt6.f2;
+ f1 | f2 | f1 | f2 
+----+----+----+----
+  1 | 10 |  1 |  9
+(1 row)
+
index d3433effd11c884817faeb3270518ba993464674..ad8957cd6e3a3675e2471460df34880cf1bb06b8 100644 (file)
@@ -424,3 +424,19 @@ LEFT JOIN (
         WHERE c.f1 IS NULL
 ) AS d ON (a.f1 = d.f1)
 WHERE d.f1 IS NULL;
+
+--
+-- regression test for problems of the sort depicted in bug #3494
+--
+
+create temp table tt5(f1 int, f2 int);
+create temp table tt6(f1 int, f2 int);
+
+insert into tt5 values(1, 10);
+insert into tt5 values(1, 11);
+
+insert into tt6 values(1, 9);
+insert into tt6 values(1, 2);
+insert into tt6 values(2, 9);
+
+select * from tt5,tt6 where tt5.f1 = tt6.f1 and tt5.f1 = tt5.f2 - tt6.f2;