Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: third_party/sqlite/src/test/index6.test

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/test/index5.test ('k') | third_party/sqlite/src/test/index7.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/index6.test
diff --git a/third_party/sqlite/src/test/index6.test b/third_party/sqlite/src/test/index6.test
index 68bdd06c14b477c31f9c276828925688b333492e..33ae3d1cb11f7f5a945716b7a197490edfa0f130 100644
--- a/third_party/sqlite/src/test/index6.test
+++ b/third_party/sqlite/src/test/index6.test
@@ -267,5 +267,113 @@ do_execsql_test index6-6.2 {
PRAGMA integrity_check;
} {ok}
+# Test case for ticket [2326c258d02ead33d69faa63de8f4686b9b1b9d9] on
+# 2015-02-24. Any use of a partial index qualifying constraint inside
+# the ON clause of a LEFT JOIN was causing incorrect results for all
+# versions of SQLite 3.8.0 through 3.8.8.
+#
+do_execsql_test index6-7.0 {
+ CREATE TABLE t7a(x);
+ CREATE TABLE t7b(y);
+ INSERT INTO t7a(x) VALUES(1);
+ CREATE INDEX t7ax ON t7a(x) WHERE x=99;
+ PRAGMA automatic_index=OFF;
+ SELECT * FROM t7a LEFT JOIN t7b ON (x=99) ORDER BY x;
+} {1 {}}
+do_execsql_test index6-7.1 {
+ INSERT INTO t7b(y) VALUES(2);
+ SELECT * FROM t7a JOIN t7b ON (x=99) ORDER BY x;
+} {}
+do_execsql_test index6-7.2 {
+ INSERT INTO t7a(x) VALUES(99);
+ SELECT * FROM t7a LEFT JOIN t7b ON (x=99) ORDER BY x;
+} {1 {} 99 2}
+do_execsql_test index6-7.3 {
+ SELECT * FROM t7a JOIN t7b ON (x=99) ORDER BY x;
+} {99 2}
+do_execsql_test index6-7.4 {
+ EXPLAIN QUERY PLAN
+ SELECT * FROM t7a JOIN t7b ON (x=99) ORDER BY x;
+} {/USING COVERING INDEX t7ax/}
+
+
+do_execsql_test index6-8.0 {
+ CREATE TABLE t8a(a,b);
+ CREATE TABLE t8b(x,y);
+ CREATE INDEX i8c ON t8b(y) WHERE x = 'value';
+
+ INSERT INTO t8a VALUES(1, 'one');
+ INSERT INTO t8a VALUES(2, 'two');
+ INSERT INTO t8a VALUES(3, 'three');
+
+ INSERT INTO t8b VALUES('value', 1);
+ INSERT INTO t8b VALUES('dummy', 2);
+ INSERT INTO t8b VALUES('value', 3);
+ INSERT INTO t8b VALUES('dummy', 4);
+} {}
+
+do_eqp_test index6-8.1 {
+ SELECT * FROM t8a LEFT JOIN t8b ON (x = 'value' AND y = a)
+} {
+ 0 0 0 {SCAN TABLE t8a}
+ 0 1 1 {SEARCH TABLE t8b USING INDEX i8c (y=?)}
+}
+
+do_execsql_test index6-8.2 {
+ SELECT * FROM t8a LEFT JOIN t8b ON (x = 'value' AND y = a)
+} {
+ 1 one value 1
+ 2 two {} {}
+ 3 three value 3
+}
+
+# 2015-06-11. Assertion fault found by AFL
+#
+do_execsql_test index6-9.1 {
+ CREATE TABLE t9(a int, b int, c int);
+ CREATE INDEX t9ca ON t9(c,a) WHERE a in (10,12,20);
+ INSERT INTO t9 VALUES(1,1,9),(10,2,35),(11,15,82),(20,19,5),(NULL,7,3);
+ UPDATE t9 SET b=c WHERE a in (10,12,20);
+ SELECT a,b,c,'|' FROM t9 ORDER BY a;
+} {{} 7 3 | 1 1 9 | 10 35 35 | 11 15 82 | 20 5 5 |}
+do_execsql_test index6-9.2 {
+ DROP TABLE t9;
+ CREATE TABLE t9(a int, b int, c int, PRIMARY KEY(a)) WITHOUT ROWID;
+ CREATE INDEX t9ca ON t9(c,a) WHERE a in (10,12,20);
+ INSERT INTO t9 VALUES(1,1,9),(10,2,35),(11,15,82),(20,19,5);
+ UPDATE t9 SET b=c WHERE a in (10,12,20);
+ SELECT a,b,c,'|' FROM t9 ORDER BY a;
+} {1 1 9 | 10 35 35 | 11 15 82 | 20 5 5 |}
+
+# AND-connected terms in the WHERE clause of a partial index
+#
+do_execsql_test index6-10.1 {
+ CREATE TABLE t10(a,b,c,d,e INTEGER PRIMARY KEY);
+ INSERT INTO t10 VALUES
+ (1,2,3,4,5),
+ (2,3,4,5,6),
+ (3,4,5,6,7),
+ (1,2,3,8,9);
+ CREATE INDEX t10x ON t10(d) WHERE a=1 AND b=2 AND c=3;
+ SELECT e FROM t10 WHERE a=1 AND b=2 AND c=3 ORDER BY d;
+} {5 9}
+do_execsql_test index6-10.1eqp {
+ EXPLAIN QUERY PLAN
+ SELECT e FROM t10 WHERE a=1 AND b=2 AND c=3 ORDER BY d;
+} {/USING INDEX t10x/}
+do_execsql_test index6-10.2 {
+ SELECT e FROM t10 WHERE c=3 AND 2=b AND a=1 ORDER BY d DESC;
+} {9 5}
+do_execsql_test index6-10.2eqp {
+ EXPLAIN QUERY PLAN
+ SELECT e FROM t10 WHERE c=3 AND 2=b AND a=1 ORDER BY d DESC;
+} {/USING INDEX t10x/}
+do_execsql_test index6-10.3 {
+ SELECT e FROM t10 WHERE a=1 AND b=2 ORDER BY d DESC;
+} {9 5}
+do_execsql_test index6-10.3eqp {
+ EXPLAIN QUERY PLAN
+ SELECT e FROM t10 WHERE a=1 AND b=2 ORDER BY d DESC;
+} {~/USING INDEX t10x/}
finish_test
« no previous file with comments | « third_party/sqlite/src/test/index5.test ('k') | third_party/sqlite/src/test/index7.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698