1*059b2d50Sdrh# 2014-10-24 2*059b2d50Sdrh# 3*059b2d50Sdrh# The author disclaims copyright to this source code. In place of 4*059b2d50Sdrh# a legal notice, here is a blessing: 5*059b2d50Sdrh# 6*059b2d50Sdrh# May you do good and not evil. 7*059b2d50Sdrh# May you find forgiveness for yourself and forgive others. 8*059b2d50Sdrh# May you share freely, never taking more than you give. 9*059b2d50Sdrh# 10*059b2d50Sdrh#************************************************************************* 11*059b2d50Sdrh# 12*059b2d50Sdrh# This file implements regression tests for SQLite library. The 13*059b2d50Sdrh# focus of this script is testing automatic index creation logic, 14*059b2d50Sdrh# and specifically creation of automatic partial indexes. 15*059b2d50Sdrh# 16*059b2d50Sdrh 17*059b2d50Sdrhset testdir [file dirname $argv0] 18*059b2d50Sdrhsource $testdir/tester.tcl 19*059b2d50Sdrh 20*059b2d50Sdrhdo_execsql_test autoindex4-1.0 { 21*059b2d50Sdrh CREATE TABLE t1(a,b); 22*059b2d50Sdrh INSERT INTO t1 VALUES(123,'abc'),(234,'def'),(234,'ghi'),(345,'jkl'); 23*059b2d50Sdrh CREATE TABLE t2(x,y); 24*059b2d50Sdrh INSERT INTO t2 VALUES(987,'zyx'),(654,'wvu'),(987,'rqp'); 25*059b2d50Sdrh 26*059b2d50Sdrh SELECT *, '|' FROM t1, t2 WHERE a=234 AND x=987 ORDER BY +b; 27*059b2d50Sdrh} {234 def 987 rqp | 234 def 987 zyx | 234 ghi 987 rqp | 234 ghi 987 zyx |} 28*059b2d50Sdrhdo_execsql_test autoindex4-1.1 { 29*059b2d50Sdrh SELECT *, '|' FROM t1, t2 WHERE a=234 AND x=555; 30*059b2d50Sdrh} {} 31*059b2d50Sdrh 32*059b2d50Sdrhdo_execsql_test autoindex4-1.2 { 33*059b2d50Sdrh SELECT *, '|' FROM t1 LEFT JOIN t2 ON a=234 AND x=555; 34*059b2d50Sdrh} {123 abc {} {} | 234 def {} {} | 234 ghi {} {} | 345 jkl {} {} |} 35*059b2d50Sdrhdo_execsql_test autoindex4-1.3 { 36*059b2d50Sdrh SELECT *, '|' FROM t1 LEFT JOIN t2 ON x=555 WHERE a=234; 37*059b2d50Sdrh} {234 def {} {} | 234 ghi {} {} |} 38*059b2d50Sdrhdo_execsql_test autoindex4-1.4 { 39*059b2d50Sdrh SELECT *, '|' FROM t1 LEFT JOIN t2 WHERE a=234 AND x=555; 40*059b2d50Sdrh} {} 41*059b2d50Sdrh 42*059b2d50Sdrh 43*059b2d50Sdrhdo_execsql_test autoindex4-2.0 { 44*059b2d50Sdrh CREATE TABLE t3(e,f); 45*059b2d50Sdrh INSERT INTO t3 VALUES(123,654),(555,444),(234,987); 46*059b2d50Sdrh 47*059b2d50Sdrh SELECT (SELECT count(*) FROM t1, t2 WHERE a=e AND x=f), e, f, '|' 48*059b2d50Sdrh FROM t3 49*059b2d50Sdrh ORDER BY rowid; 50*059b2d50Sdrh} {1 123 654 | 0 555 444 | 4 234 987 |} 51*059b2d50Sdrh 52*059b2d50Sdrhfinish_test 53