summaryrefslogtreecommitdiffstats
path: root/test/whereL.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/whereL.test')
-rw-r--r--test/whereL.test45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/whereL.test b/test/whereL.test
index c3bdcb8..2e9ae21 100644
--- a/test/whereL.test
+++ b/test/whereL.test
@@ -49,6 +49,33 @@ do_eqp_test 120 {
|--SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (a=?)
`--SCAN t3
}
+do_eqp_test 121 {
+ SELECT * FROM t1, t2, t3
+ WHERE t1.a=t2.a AND t2.a=t3.j AND t3.j=abs(5)
+ ORDER BY t1.a;
+} {
+ QUERY PLAN
+ |--SEARCH t1 USING INDEX sqlite_autoindex_t1_1 (a=?)
+ |--SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (a=?)
+ `--SCAN t3
+}
+
+# The sqlite3ExprIsConstant() routine does not believe that
+# the expression "coalesce(5,random())" is constant. So the
+# optimization does not apply in this case.
+#
+sqlite3_create_function db
+do_eqp_test 122 {
+ SELECT * FROM t1, t2, t3
+ WHERE t1.a=t2.a AND t2.a=t3.j AND t3.j=coalesce(5,random())
+ ORDER BY t1.a;
+} {
+ QUERY PLAN
+ |--SCAN t3
+ |--SEARCH t1 USING INDEX sqlite_autoindex_t1_1 (a=?)
+ |--SEARCH t2 USING INDEX sqlite_autoindex_t2_1 (a=?)
+ `--USE TEMP B-TREE FOR ORDER BY
+}
# Constant propagation in the face of collating sequences:
#
@@ -209,4 +236,22 @@ do_eqp_test 710 {
`--SEARCH t1 USING INDEX idx (<expr>=?)
}
+# 2024-03-07 https://sqlite.org/forum/forumpost/ecdfc02339
+# A refinement is needed to the enhancements tested by the prior test case
+# to avoid another problem with indexes on constant expressions.
+#
+reset_db
+db null NULL
+do_execsql_test 800 {
+ CREATE TABLE t0(c0, c1);
+ CREATE TABLE t1(c2);
+ CREATE INDEX i0 ON t1(NULL);
+ INSERT INTO t1(c2) VALUES (0.2);
+ CREATE VIEW v0(c3) AS SELECT DISTINCT c2 FROM t1;
+ SELECT * FROM v0 LEFT JOIN t0 ON c3<NULL LEFT JOIN t1 ON 1;
+} {0.2 NULL NULL 0.2}
+do_execsql_test 810 {
+ SELECT * FROM v0 LEFT JOIN t0 ON c3<NULL LEFT JOIN t1 ON 1 WHERE c2/0.1;
+} {0.2 NULL NULL 0.2}
+
finish_test