From 14479504381b65251f332d819e7f03a36ad08ea1 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 22 Feb 2016 19:51:08 +0000 Subject: [PATCH] Add test script shell6.test, containing tests for schemalint. FossilOrigin-Name: 0b73406595c9a077399b0f4c17af3a826cf3612f --- manifest | 15 ++-- manifest.uuid | 2 +- src/shell_indexes.c | 21 ++++- src/where.c | 6 +- test/shell6.test | 191 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 221 insertions(+), 14 deletions(-) create mode 100644 test/shell6.test diff --git a/manifest b/manifest index 549a6f5bf1..1ea78374dd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scouple\sof\sbugs\sin\sthe\sschemalint\scode. -D 2016-02-19T07:53:43.883 +C Add\stest\sscript\sshell6.test,\scontaining\stests\sfor\sschemalint. +D 2016-02-22T19:51:08.971 F Makefile.in dac2776c84e0d533b158a9af6e57e05c4a6b19f3 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b0493f10caddb8adf992a4e6f1943141fc7c6816 @@ -350,7 +350,7 @@ F src/resolve.c 9f7ce3a3c087afb7597b7c916c99126ff3f12f0c F src/rowset.c 9fe4b3ad7cc00944386bb600233d8f523de07a6e F src/select.c ff80004a9a6ece891a8d9327a88e7b6e2588ee6d F src/shell.c 2cde87e03712204231167c4a6c61b0eb5129e105 -F src/shell_indexes.c c0099c01c7af01038ab4315621814df535b700a3 +F src/shell_indexes.c e10b3c2c4bc9a87f7bff1cf622473717b1a00698 F src/sqlite.h.in c7db059d3b810b70b83d9ed1436fa813eba22462 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d @@ -428,7 +428,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c d21b99fd1458159d0b1ecdccc8ee6ada4fdc4c54 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 -F src/where.c 89d5845353fe6d2e77bce52a2c8bea0781c69dad +F src/where.c 0ecce6da62ad521cac83dfa1b60a37936b36b6a1 F src/whereInt.h 78b6b4de94db84aecbdc07fe3e38f648eb391e9a F src/wherecode.c 791a784bbf8749d560fdb0b990b607bc4f44a38d F src/whereexpr.c de117970b29471177a6901d60ad83a194671dc03 @@ -1025,6 +1025,7 @@ F test/shell2.test 12b8bf901b0e3a8ac58cf5c0c63a0a388d4d1862 F test/shell3.test 5e8545ec72c4413a0e8d4c6be56496e3c257ca29 F test/shell4.test ddf0a99044e2245a87fc17423e3aaa1445b3243b F test/shell5.test c04e9f9f948305706b88377c464c7f08ce7479f9 +F test/shell6.test dc93ef3f42c5c385e66b97729374fa1c017ea5ed F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce @@ -1430,7 +1431,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4ab3df25f1fee7c8fea19d0c64b3e0e4d3b9c3cf -R 0c9cae22954d1f32b48770c565f201e2 +P 02fbf699c07286f842d9617755f071b0fffc5d40 +R a01d8436d914e04ca0b643f78b3bf6ab U dan -Z cecc60af647c055f880ee4bdf2018855 +Z 48d2e83e55b4a0cbf023823a82d88ee7 diff --git a/manifest.uuid b/manifest.uuid index 675cfe73ee..a71d648d17 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -02fbf699c07286f842d9617755f071b0fffc5d40 \ No newline at end of file +0b73406595c9a077399b0f4c17af3a826cf3612f \ No newline at end of file diff --git a/src/shell_indexes.c b/src/shell_indexes.c index cd8a5e7288..738a035f02 100644 --- a/src/shell_indexes.c +++ b/src/shell_indexes.c @@ -34,6 +34,7 @@ struct IdxConstraint { int iCol; /* Constrained table column */ i64 depmask; /* Dependency mask */ int bFlag; /* Used by idxFindCompatible() */ + int bDesc; /* True if ORDER BY DESC */ IdxConstraint *pNext; /* Next constraint in pEq or pRange list */ IdxConstraint *pLink; /* See above */ }; @@ -198,11 +199,17 @@ static void idxWhereInfo( case SQLITE_WHEREINFO_ORDERBY: { IdxConstraint *pNew = idxNewConstraint(&p->rc, zVal); - IdxConstraint **pp; if( pNew==0 ) return; pNew->iCol = iVal; - for(pp=&p->pScan->pOrder; *pp; pp=&(*pp)->pNext); - *pp = pNew; + pNew->bDesc = (int)mask; + if( p->pScan->pOrder==0 ){ + p->pScan->pOrder = pNew; + }else{ + IdxConstraint *pIter; + for(pIter=p->pScan->pOrder; pIter->pNext; pIter=pIter->pNext); + pIter->pNext = pNew; + pIter->pLink = pNew; + } break; } @@ -508,6 +515,10 @@ static char *idxAppendColDefn( zRet = idxAppendText(pRc, zRet, " COLLATE %s", pCons->zColl); } } + + if( pCons->bDesc ){ + zRet = idxAppendText(pRc, zRet, " DESC"); + } return zRet; } @@ -812,7 +823,9 @@ int idxFindIndexes( } if( zIdx ){ int nIdx = 0; - while( zIdx[nIdx]!='\0' && zIdx[nIdx]!=' ' ) nIdx++; + while( zIdx[nIdx]!='\0' && (zIdx[nIdx]!=' ' || zIdx[nIdx+1]!='(') ){ + nIdx++; + } sqlite3_bind_text(pSelect, 1, zIdx, nIdx, SQLITE_STATIC); if( SQLITE_ROW==sqlite3_step(pSelect) ){ i64 iRowid = sqlite3_column_int64(pSelect, 0); diff --git a/src/where.c b/src/where.c index 3724fa33e0..6275fc8d1e 100644 --- a/src/where.c +++ b/src/where.c @@ -3990,11 +3990,13 @@ static void whereTraceBuilder( for(i=0; ipOrderBy->nExpr; i++){ Expr *pExpr = p->pOrderBy->a[i].pExpr; CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr); + assert( pColl || pParse->rc ); pExpr = sqlite3ExprSkipCollate(pExpr); if( pExpr->op==TK_COLUMN && pExpr->iTable==pItem->iCursor ){ int iCol = pExpr->iColumn; - if( iCol>=0 ){ - x(pCtx, SQLITE_WHEREINFO_ORDERBY, pColl->zName, iCol, 0); + if( pColl && iCol>=0 ){ + int bDesc = p->pOrderBy->a[i].sortOrder; + x(pCtx, SQLITE_WHEREINFO_ORDERBY, pColl->zName, iCol, bDesc); } } } diff --git a/test/shell6.test b/test/shell6.test new file mode 100644 index 0000000000..2b200a2757 --- /dev/null +++ b/test/shell6.test @@ -0,0 +1,191 @@ +# 2009 Nov 11 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# The focus of this file is testing the CLI shell tool. Specifically, +# the ".recommend" command. +# +# + +# Test plan: +# +# shell1-1.*: Basic command line option handling. +# shell1-2.*: Basic "dot" command token parsing. +# shell1-3.*: Basic test that "dot" command can be called. +# +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix shell6 + +if {$tcl_platform(platform)=="windows"} { + set CLI "sqlite3.exe" +} else { + set CLI "./sqlite3" +} +if {![file executable $CLI]} { + finish_test + return +} + + +proc squish {txt} { + regsub -all {[[:space:]]+} $txt { } +} + +proc do_rec_test {tn sql res} { + set res [squish [string trim $res]] + set tst [subst -nocommands { + squish [lindex [catchcmd [list -rec test.db {$sql;}]] 1] + }] + uplevel [list do_test $tn $tst $res] +} + +proc do_setup_rec_test {tn setup sql res} { + reset_db + db eval $setup + uplevel [list do_rec_test $tn $sql $res] +} + + +do_setup_rec_test 1.1 { CREATE TABLE t1(a, b, c) } { + SELECT * FROM t1 +} { + (no new indexes) + 0|0|0|SCAN TABLE t1 +} + +do_setup_rec_test 1.2 { + CREATE TABLE t1(a, b, c); +} { + SELECT * FROM t1 WHERE b>?; +} { + CREATE INDEX t1_idx_00000062 ON t1(b) + 0|0|0|SEARCH TABLE t1 USING INDEX t1_idx_00000062 (b>?) +} + +do_setup_rec_test 1.3 { + CREATE TABLE t1(a, b, c); +} { + SELECT * FROM t1 WHERE b COLLATE nocase BETWEEN ? AND ? +} { + CREATE INDEX t1_idx_3e094c27 ON t1(b COLLATE NOCASE) + 0|0|0|SEARCH TABLE t1 USING INDEX t1_idx_3e094c27 (b>? AND b? AND b