1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix test cases so that they work with the new EXPLAIN QUERY PLAN output

format.  Only some of the cases have been fixed.  This is an incremental
check-in.

FossilOrigin-Name: 5f0e803e33aa557865d5fc830d9202d628de9a94c9757058ca48f1a560702cd3
This commit is contained in:
drh
2018-05-02 18:00:17 +00:00
parent 84a01debf9
commit b3f0276b9e
43 changed files with 527 additions and 540 deletions

View File

@ -357,25 +357,25 @@ do_test where9-2.8 {
ifcapable explain {
do_execsql_test where9-3.1 {
EXPLAIN QUERY PLAN
do_eqp_test where9-3.1 {
SELECT t2.a FROM t1, t2
WHERE t1.a=80 AND ((t1.c=t2.c AND t1.d=t2.d) OR t1.f=t2.f)
} {
0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?)}
0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?)}
0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?)}
}
do_execsql_test where9-3.2 {
EXPLAIN QUERY PLAN
} [string map {"\n " \n} {
QUERY PLAN
|--SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?)
|--SEARCH TABLE t2 USING INDEX t2d (d=?)
`--SEARCH TABLE t2 USING COVERING INDEX t2f (f=?)
}]
do_eqp_test where9-3.2 {
SELECT coalesce(t2.a,9999)
FROM t1 LEFT JOIN t2 ON (t1.c+1=t2.c AND t1.d=t2.d) OR (t1.f||'x')=t2.f
WHERE t1.a=80
} {
0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?)}
0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?)}
0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?)}
}
} [string map {"\n " \n} {
QUERY PLAN
|--SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?)
|--SEARCH TABLE t2 USING INDEX t2d (d=?)
`--SEARCH TABLE t2 USING COVERING INDEX t2f (f=?)
}]
}
# Make sure that INDEXED BY and multi-index OR clauses play well with
@ -446,35 +446,30 @@ do_test where9-4.8 {
}
} {1 {no query solution}}
ifcapable explain {
# The (c=31031 OR d IS NULL) clause is preferred over b>1000 because
# the former is an equality test which is expected to return fewer rows.
#
do_execsql_test where9-5.1 {
EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b>1000 AND (c=31031 OR d IS NULL)
} {
0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?)}
0 0 0 {SEARCH TABLE t1 USING INDEX t1d (d=?)}
}
# In contrast, b=1000 is preferred over any OR-clause.
#
do_execsql_test where9-5.2 {
EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b=1000 AND (c=31031 OR d IS NULL)
} {
0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}
}
# Likewise, inequalities in an AND are preferred over inequalities in
# an OR.
#
do_execsql_test where9-5.3 {
EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b>1000 AND (c>=31031 OR d IS NULL)
} {
0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>?)}
}
# The (c=31031 OR d IS NULL) clause is preferred over b>1000 because
# the former is an equality test which is expected to return fewer rows.
#
do_eqp_test where9-5.1 {
SELECT a FROM t1 WHERE b>1000 AND (c=31031 OR d IS NULL)
} {
QUERY PLAN
|--SEARCH TABLE t1 USING INDEX t1c (c=?)
`--SEARCH TABLE t1 USING INDEX t1d (d=?)
}
# In contrast, b=1000 is preferred over any OR-clause.
#
do_eqp_test where9-5.2 {
SELECT a FROM t1 WHERE b=1000 AND (c=31031 OR d IS NULL)
} {SEARCH TABLE t1 USING INDEX t1b (b=?)}
# Likewise, inequalities in an AND are preferred over inequalities in
# an OR.
#
do_eqp_test where9-5.3 {
SELECT a FROM t1 WHERE b>1000 AND (c>=31031 OR d IS NULL)
} {SEARCH TABLE t1 USING INDEX t1b (b>?)}
############################################################################
# Make sure OR-clauses work correctly on UPDATE and DELETE statements.