diff --git a/manifest b/manifest index b6583d963c..d9dec4830b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sobsolete\svector-IN\stest\scases.\s\sFix\sa\sbad\stestcase()\smacro. -D 2016-09-06T19:08:21.705 +C Merge\sfixes\sfrom\strunk. +D 2016-09-07T13:12:13.158 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5017381e4853b1472e01d5bb926be1268eba429c @@ -386,7 +386,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 24f40fd0c3475821d1ad762a3f2c3455cc839b42 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 244f9cc5e4662987cd2ef5c22d1b7027560f3425 -F src/shell.c 79dda477be6c96eba6e952a934957ad36f87acc7 +F src/shell.c de7c7e98846cacbfbe062cbd98bca899dfb720e3 F src/sqlite.h.in 4a030e254e204570444b34bf7d40fb4a5416089e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae @@ -465,7 +465,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 02eeecc265f6ffd0597378f5d8ae9070b62a406a F src/wal.h 6dd221ed384afdc204bc61e25c23ef7fd5a511f2 F src/walker.c 2d2cc7fb0f320f7f415215d7247f3c584141ac09 -F src/where.c 48d705e5196a0611a7be90698eade455ee238536 +F src/where.c edbd73a87ba2e186928e9bfc14348b1bbb2628c5 F src/whereInt.h 14dd243e13b81cbb0a66063d38b70f93a7d6e613 F src/wherecode.c b0d4febdd9de07ad68faadeacb30df9785f9b979 F src/whereexpr.c e3db778ed205e982f31960896db71c50612ae009 @@ -890,7 +890,7 @@ F test/like.test 81632c437a947bf1f7130b19537da6a1a844806a F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da F test/like3.test 3608a2042b6f922f900fbfd5d3ce4e7eca57f7c4 F test/limit.test 0c99a27a87b14c646a9d583c7c89fd06c352663e -F test/limit2.test 40e79f3d95f2077742aa5b7676f58c9af1735d83 +F test/limit2.test ac97b8d07060a0280162ba4159e4c0c765861127 F test/loadext.test d077450695ddb5c1ea3ad7d48e5f5850fe732ad9 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -1080,7 +1080,7 @@ F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 F test/shell1.test 65b10cd8a90cda9b5af9100a45689a57dcc01a31 F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell3.test da513d522ef6f01cee8475dcf8332bff8982b3dd -F test/shell4.test 69995ee1cc278eb149aa8746ce1f935f4eaf98b9 +F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell5.test 50a732c1c2158b1cd62cf53975ce1ea7ce6b9dc9 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5 @@ -1522,7 +1522,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8329ac6f8d1edcc19c3e0559abe9a8011dbe1497 -R c63acfebc9bb94150dde03620f804079 +P ab3f8f193a7ec36018bf26c9231a1a6a58b6a523 d8451fe84d09db6ec7e1bd5f0708ea1b5e85f3d6 +R 9be49f79015d1d1f29328535fe4e7eb6 U drh -Z 4492b1886315f856574968e31e230cb0 +Z 2891e6cf4d042c296a4853701a08d60f diff --git a/manifest.uuid b/manifest.uuid index 130764cfa2..c5b7f13bc8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ab3f8f193a7ec36018bf26c9231a1a6a58b6a523 \ No newline at end of file +193f036c87857bd77577ceb462af5034c7cc77da \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 18c6ef7197..21cba66b1c 100644 --- a/src/shell.c +++ b/src/shell.c @@ -524,7 +524,7 @@ static char *local_getline(char *zLine, FILE *in){ #if defined(_WIN32) || defined(WIN32) /* For interactive input on Windows systems, translate the ** multi-byte characterset characters into UTF-8. */ - if( stdin_is_interactive ){ + if( stdin_is_interactive && in==stdin ){ char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0); if( zTrans ){ int nTrans = strlen30(zTrans)+1; @@ -4905,7 +4905,7 @@ static int process_input(ShellState *p, FILE *in){ zLine = one_input_line(in, zLine, nSql>0); if( zLine==0 ){ /* End of input */ - if( stdin_is_interactive ) printf("\n"); + if( in==0 && stdin_is_interactive ) printf("\n"); break; } if( seenInterrupt ){ diff --git a/src/where.c b/src/where.c index f60d5be6da..1785107244 100644 --- a/src/where.c +++ b/src/where.c @@ -3521,6 +3521,14 @@ static i8 wherePathSatisfiesOrderBy( pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn, ~ready, eqOpMask, 0); if( pTerm==0 ) continue; + if( pTerm->eOperator==WO_IN ){ + /* IN terms are only valid for sorting in the ORDER BY LIMIT + ** optimization, and then only if they are actually used + ** by the query plan */ + assert( wctrlFlags & WHERE_ORDERBY_LIMIT ); + for(j=0; jnLTerm && pTerm!=pLoop->aLTerm[j]; j++){} + if( j>=pLoop->nLTerm ) continue; + } if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){ const char *z1, *z2; pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr); diff --git a/test/limit2.test b/test/limit2.test index fb4c89644f..0f82ab8d55 100644 --- a/test/limit2.test +++ b/test/limit2.test @@ -96,7 +96,18 @@ do_execsql_test limit2-210 { SELECT *, '|' FROM t200 LEFT JOIN t201 ON x=b ORDER BY y LIMIT 3; } {1 1 {} {} | 3 3 {} {} | 4 4 {} {} |} - +# Bug in the ORDER BY LIMIT optimization reported on 2016-09-06. +# Ticket https://www.sqlite.org/src/info/559733b09e96 +# +do_execsql_test limit2-300 { + CREATE TABLE t300(a,b,c); + CREATE INDEX t300x ON t300(a,b,c); + INSERT INTO t300 VALUES(0,1,99),(0,1,0),(0,0,0); + SELECT *,'.' FROM t300 WHERE a=0 AND (c=0 OR c=99) ORDER BY c DESC; +} {0 1 99 . 0 0 0 . 0 1 0 .} +do_execsql_test limit2-310 { + SELECT *,'.' FROM t300 WHERE a=0 AND (c=0 OR c=99) ORDER BY c DESC LIMIT 1; +} {0 1 99 .} diff --git a/test/shell4.test b/test/shell4.test index 3e4ae55816..88e5e69a28 100644 --- a/test/shell4.test +++ b/test/shell4.test @@ -18,6 +18,7 @@ # # shell4-1.*: Basic tests specific to the "stats" command. # shell4-2.*: Basic tests for ".trace" +# shell4-3.*: The ".read" command takes the shell out of interactive mode # set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -124,5 +125,17 @@ do_test shell4-2.5 { } {0 {SELECT * FROM t1;}} } +do_test shell4-3.1 { + set fd [open t1.txt wb] + puts $fd "SELECT 'squirrel';" + close $fd + exec $::CLI :memory: --interactive ".read t1.txt" +} {squirrel} +do_test shell4-3.2 { + set fd [open t1.txt wb] + puts $fd "SELECT 'pound: \302\243';" + close $fd + exec $::CLI :memory: --interactive ".read t1.txt" +} {pound: £} finish_test