]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add a missing test that prevented double LEFT JOINs with transitive
authordrh <drh@noemail.net>
Mon, 1 Jul 2013 17:27:19 +0000 (17:27 +0000)
committerdrh <drh@noemail.net>
Mon, 1 Jul 2013 17:27:19 +0000 (17:27 +0000)
constraints from working correctly.  Fix for ticket [868145d012].

FossilOrigin-Name: 72919ec34f0d663d551c1070285ad93b932bcb74

manifest
manifest.uuid
src/where.c
test/tkt-868145d012.test [new file with mode: 0644]

index 7086a26796d39bcf1d80877cbd0e526735b17d11..58b0be2aae117c95ff4d5fd3214ebcdcf1ad1830 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Further\sminor\scomment\scorrections\sand\senhancements\sin\swhere.c.
-D 2013-07-01T11:05:50.653
+C Add\sa\smissing\stest\sthat\sprevented\sdouble\sLEFT\sJOINs\swith\stransitive\nconstraints\sfrom\sworking\scorrectly.\s\sFix\sfor\sticket\s[868145d012].
+D 2013-07-01T17:27:19.953
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -290,7 +290,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83
 F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4
 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
 F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73
-F src/where.c 3ea606b1282032b9cc00ee7b1bb9c1d3683f7ea1
+F src/where.c b546b95b7096f153666c63bb4f76c1a0299d83d6
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6
@@ -848,6 +848,7 @@ F test/tkt-7bbfb7d442.test 7b2cd79c7a17ae6750e75ec1a7846712a69c9d18
 F test/tkt-80ba201079.test 105a721e6aad0ae3c5946d7615d1e4d03f6145b8
 F test/tkt-80e031a00f.test 9a154173461a4dbe2de49cda73963e04842d52f7
 F test/tkt-8454a207b9.test c583a9f814a82a2b5ba95207f55001c9f0cd816c
+F test/tkt-868145d012.test a5f941107ece6a64410ca4755c6329b7eb57a356
 F test/tkt-91e2e8ba6f.test 08c4f94ae07696b05c9b822da0b4e5337a2f54c5
 F test/tkt-94c04eaadb.test fa9c71192f7e2ea2d51bf078bc34e8da6088bf71
 F test/tkt-9d68c883.test 458f7d82a523d7644b54b497c986378a7d8c8b67
@@ -1098,7 +1099,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P 0ffaab3b9c97f4dba0f0ca6e146c8dc2775f7b1c
-R 73899855654d4162ca36e6c20fb7ad55
+P 0d68d4d018e73dcbbc08786071aac6228fca1a8c
+R e2cf3085b0661bbba83fb076c8deb507
 U drh
-Z 9148660e3c1a93ae29b1da887b939490
+Z 7f1cae3d935cfbd38a2ed50893b4a0df
index 68d4179d707ba11116044840149478d16eecd256..73679f745d29e66a43ff9c2d7aee4f05e5d91e8e 100644 (file)
@@ -1 +1 @@
-0d68d4d018e73dcbbc08786071aac6228fca1a8c
\ No newline at end of file
+72919ec34f0d663d551c1070285ad93b932bcb74
\ No newline at end of file
index 1f1944effb0de0a7c8395672a292487859e7b1b5..cf50d1beccdc628e83b860cb18659b402f7dd3e1 100644 (file)
@@ -3887,6 +3887,7 @@ static Bitmask codeOneLoopStart(
     if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
     if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
     if( pTerm->leftCursor!=iCur ) continue;
+    if( pLevel->iLeftJoin ) continue;
     pE = pTerm->pExpr;
     assert( !ExprHasProperty(pE, EP_FromJoin) );
     assert( (pTerm->prereqRight & newNotReady)!=0 );
diff --git a/test/tkt-868145d012.test b/test/tkt-868145d012.test
new file mode 100644 (file)
index 0000000..145d159
--- /dev/null
@@ -0,0 +1,64 @@
+# 2013 March 05
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. Specifically,
+# it tests that ticket [868145d012a1] is fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_execsql_test tkt-868145d012.100 {
+  CREATE TABLE p (
+    id INTEGER PRIMARY KEY,
+    uid VARCHAR(36),
+    t INTEGER
+  );
+  
+  CREATE TABLE pa (
+    id INTEGER PRIMARY KEY,
+    a_uid VARCHAR(36)
+  );
+  
+  CREATE TABLE a (
+    id INTEGER PRIMARY KEY,
+    uid VARCHAR(36),
+    t INTEGER
+  );
+  
+  INSERT INTO pa VALUES(1,'1234');
+  INSERT INTO pa VALUES(2,'2345');
+  INSERT INTO p VALUES(3,'1234',97);
+  INSERT INTO p VALUES(4,'1234',98);
+  INSERT INTO a VALUES(5,'1234',98);
+  INSERT INTO a VALUES(6,'1234',99);
+} {}
+do_execsql_test tkt-868145d012.110 {
+  SELECT DISTINCT pa.id, p.id, a.id
+  FROM
+    pa
+    LEFT JOIN p ON p.uid='1234'
+    LEFT JOIN a ON a.uid=pa.a_uid
+  WHERE
+    a.t=p.t
+  ;
+} {1 4 5}
+do_execsql_test tkt-868145d012.120 {
+  SELECT DISTINCT pa.id, p.id, a.id
+  FROM
+    pa
+    LEFT JOIN p ON p.uid='1234'
+    LEFT JOIN a ON a.uid=pa.a_uid AND a.t=p.t
+  ORDER BY 1, 2, 3
+  ;
+} {1 3 {} 1 4 5 2 3 {} 2 4 {}}
+
+    
+finish_test