Add test case for ticket #601. (CVS 1215)

FossilOrigin-Name: 096312dacb9eb2f8da3cec1504aef8629b505e7f
diff --git a/test/misc3.test b/test/misc3.test
index 980ec5a..1ccc92c 100644
--- a/test/misc3.test
+++ b/test/misc3.test
@@ -13,7 +13,7 @@
 # This file implements tests for miscellanous features that were
 # left out of other test files.
 #
-# $Id: misc3.test,v 1.6 2004/01/14 21:59:24 drh Exp $
+# $Id: misc3.test,v 1.7 2004/02/09 14:35:28 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -207,5 +207,34 @@
   }
 } {64}
 
+# Ticket #601:  Putting a left join inside "SELECT * FROM (<join-here>)"
+# gives different results that if the outer "SELECT * FROM ..." is omitted.
+#
+do_test misc4-5.1 {
+  execsql {
+    CREATE TABLE x1 (b, c);
+    INSERT INTO x1 VALUES('dog',3);
+    INSERT INTO x1 VALUES('cat',1);
+    INSERT INTO x1 VALUES('dog',4);
+    CREATE TABLE x2 (c, e);
+    INSERT INTO x2 VALUES(1,'one');
+    INSERT INTO x2 VALUES(2,'two');
+    INSERT INTO x2 VALUES(3,'three');
+    INSERT INTO x2 VALUES(4,'four');
+    SELECT x2.c AS c, e, b FROM x2 LEFT JOIN
+       (SELECT b, max(c) AS c FROM x1 GROUP BY b)
+       USING(c);
+  }
+} {1 one cat 2 two {} 3 three {} 4 four dog}
+do_test misc4-5.2 {
+  execsql {
+    SELECT * FROM (
+      SELECT x2.c AS c, e, b FROM x2 LEFT JOIN
+         (SELECT b, max(c) AS c FROM x1 GROUP BY b)
+         USING(c)
+    );
+  }
+} {1 one cat 2 two {} 3 three {} 4 four dog}
+
 
 finish_test