Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/eqp2.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / eqp2.test` 83 lines ยท 1966 bytes Raw Blame History 1 # 2024 March 20 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 6 # May you do good and not evil. 7 # May you find forgiveness for yourself and forgive others. 8 # May you share freely, never taking more than you give. 9 # 10 #*********************************************************************** 11 # 12 13 set testdir [file dirname $argv0] 14 source $testdir/tester.tcl 15 16 set testprefix eqp2 17 18 do_execsql_test 1.0 { 19 CREATE TABLE t1(a, b, c, d); 20 CREATE INDEX i1 ON t1(a, b, c); 21 } 22 23 do_eqp_test 1.1 { 24 SELECT * FROM t1 ORDER BY a, b, c 25 } { 26 QUERY PLAN 27 `--SCAN t1 USING INDEX i1 28 } 29 30 31 do_eqp_test 1.2 { 32 SELECT * FROM t1 ORDER BY a, b, +c 33 } { 34 QUERY PLAN 35 |--SCAN t1 USING INDEX i1 36 `--USE TEMP B-TREE FOR LAST TERM OF ORDER BY 37 } 38 39 do_eqp_test 1.3 { 40 SELECT * FROM t1 ORDER BY a, +b, +c 41 } { 42 QUERY PLAN 43 |--SCAN t1 USING INDEX i1 44 `--USE TEMP B-TREE FOR LAST 2 TERMS OF ORDER BY 45 } 46 47 #------------------------------------------------------------------------- 48 # Test that a bound value of 0 is handled in the same way as a literal 49 # 0 when estimating the probability of (x=). 50 # 51 reset_db 52 do_execsql_test 2.0 { 53 CREATE TABLE t1(a INT, b INT); 54 CREATE TABLE t2(x INT, y INT); 55 CREATE INDEX t1_a ON t1(a); 56 CREATE INDEX t1_b ON t1(b); 57 CREATE INDEX t2_x ON t2(x); 58 59 WITH s(i) AS ( SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<999) 60 INSERT INTO t1 SELECT i%33, i FROM s; 61 62 WITH s(i) AS ( SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<59) 63 INSERT INTO t2 SELECT i, i%3 FROM s; 64 65 ANALYZE; 66 } 67 68 set zero [expr 0] 69 70 if {[permutation] != "prepare"} { 71 do_eqp_test 2.1 { 72 SELECT * FROM t1 JOIN t2 ON t1.b = t2.x 73 WHERE t1.a = 5 AND t2.y = $zero 74 } {SEARCH t1 USING INDEX t1_a (a=?)*SEARCH t2 USING INDEX t2_x (x=?)} 75 } 76 77 do_eqp_test 2.2 { 78 SELECT * FROM t1 JOIN t2 ON t1.b = t2.x 79 WHERE t1.a = 5 AND t2.y = 0 80 } {SEARCH t1 USING INDEX t1_a (a=?)*SEARCH t2 USING INDEX t2_x (x=?)} 81 82 83 finish_test