/ Check-in [193f036c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge fixes from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rowvalue
Files: files | file ages | folders
SHA1: 193f036c87857bd77577ceb462af5034c7cc77da
User & Date: drh 2016-09-07 13:12:13
Context
2016-09-07
13:30
Simplify the affinity handling logic in codeAllEqualityTerms(). Logically the same, just a little easier to read and understand. check-in: bbab9621 user: drh tags: rowvalue
13:12
Merge fixes from trunk. check-in: 193f036c user: drh tags: rowvalue
10:10
Fix the ".read" command in the command-line shell so that it understands that the input is not interactive. check-in: d8451fe8 user: drh tags: trunk
2016-09-06
19:08
Remove obsolete vector-IN test cases. Fix a bad testcase() macro. check-in: ab3f8f19 user: drh tags: rowvalue
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

   520    520         zLine[n] = 0;
   521    521         break;
   522    522       }
   523    523     }
   524    524   #if defined(_WIN32) || defined(WIN32)
   525    525     /* For interactive input on Windows systems, translate the
   526    526     ** multi-byte characterset characters into UTF-8. */
   527         -  if( stdin_is_interactive ){
          527  +  if( stdin_is_interactive && in==stdin ){
   528    528       char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0);
   529    529       if( zTrans ){
   530    530         int nTrans = strlen30(zTrans)+1;
   531    531         if( nTrans>nLine ){
   532    532           zLine = realloc(zLine, nTrans);
   533    533           if( zLine==0 ){
   534    534             sqlite3_free(zTrans);
................................................................................
  4901   4901     int startline = 0;        /* Line number for start of current input */
  4902   4902   
  4903   4903     while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){
  4904   4904       fflush(p->out);
  4905   4905       zLine = one_input_line(in, zLine, nSql>0);
  4906   4906       if( zLine==0 ){
  4907   4907         /* End of input */
  4908         -      if( stdin_is_interactive ) printf("\n");
         4908  +      if( in==0 && stdin_is_interactive ) printf("\n");
  4909   4909         break;
  4910   4910       }
  4911   4911       if( seenInterrupt ){
  4912   4912         if( in!=0 ) break;
  4913   4913         seenInterrupt = 0;
  4914   4914       }
  4915   4915       lineno++;

Changes to src/where.c.

  3517   3517         if( MASKBIT(i) & obSat ) continue;
  3518   3518         pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);
  3519   3519         if( pOBExpr->op!=TK_COLUMN ) continue;
  3520   3520         if( pOBExpr->iTable!=iCur ) continue;
  3521   3521         pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,
  3522   3522                          ~ready, eqOpMask, 0);
  3523   3523         if( pTerm==0 ) continue;
         3524  +      if( pTerm->eOperator==WO_IN ){
         3525  +        /* IN terms are only valid for sorting in the ORDER BY LIMIT 
         3526  +        ** optimization, and then only if they are actually used
         3527  +        ** by the query plan */
         3528  +        assert( wctrlFlags & WHERE_ORDERBY_LIMIT );
         3529  +        for(j=0; j<pLoop->nLTerm && pTerm!=pLoop->aLTerm[j]; j++){}
         3530  +        if( j>=pLoop->nLTerm ) continue;
         3531  +      }
  3524   3532         if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){
  3525   3533           const char *z1, *z2;
  3526   3534           pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);
  3527   3535           if( !pColl ) pColl = db->pDfltColl;
  3528   3536           z1 = pColl->zName;
  3529   3537           pColl = sqlite3ExprCollSeq(pWInfo->pParse, pTerm->pExpr);
  3530   3538           if( !pColl ) pColl = db->pDfltColl;

Changes to test/limit2.test.

    92     92   
    93     93     SELECT *, '|' FROM t200, t201 WHERE x=b ORDER BY y LIMIT 3;
    94     94   } {2 2 2 12345 |}
    95     95   do_execsql_test limit2-210 {
    96     96     SELECT *, '|' FROM t200 LEFT JOIN t201 ON x=b ORDER BY y LIMIT 3;
    97     97   } {1 1 {} {} | 3 3 {} {} | 4 4 {} {} |}
    98     98   
    99         -
           99  +# Bug in the ORDER BY LIMIT optimization reported on 2016-09-06.
          100  +# Ticket https://www.sqlite.org/src/info/559733b09e96
          101  +#
          102  +do_execsql_test limit2-300 {
          103  +  CREATE TABLE t300(a,b,c);
          104  +  CREATE INDEX t300x ON t300(a,b,c);
          105  +  INSERT INTO t300 VALUES(0,1,99),(0,1,0),(0,0,0);
          106  +  SELECT *,'.' FROM t300 WHERE a=0 AND (c=0 OR c=99) ORDER BY c DESC;
          107  +} {0 1 99 . 0 0 0 . 0 1 0 .}
          108  +do_execsql_test limit2-310 {
          109  +  SELECT *,'.' FROM t300 WHERE a=0 AND (c=0 OR c=99) ORDER BY c DESC LIMIT 1;
          110  +} {0 1 99 .}
   100    111   
   101    112   
   102    113   
   103    114   
   104    115   finish_test

Changes to test/shell4.test.

    14     14   #
    15     15   # 2015-03-19:  Added tests for .trace
    16     16   
    17     17   # Test plan:
    18     18   #
    19     19   #   shell4-1.*: Basic tests specific to the "stats" command.
    20     20   #   shell4-2.*: Basic tests for ".trace"
           21  +#   shell4-3.*: The ".read" command takes the shell out of interactive mode
    21     22   #
    22     23   set testdir [file dirname $argv0]
    23     24   source $testdir/tester.tcl
    24     25   set CLI [test_find_cli]
    25     26   db close
    26     27   forcedelete test.db test.db-journal test.db-wal
    27     28   sqlite3 db test.db
................................................................................
   120    121   } {0 {CREATE TABLE t1(x);
   121    122   SELECT * FROM t1;}}
   122    123   do_test shell4-2.5 {
   123    124     catchcmd ":memory:" "CREATE TABLE t1(x);\n.trace stdout\nSELECT * FROM t1;"
   124    125   } {0 {SELECT * FROM t1;}}
   125    126   }
   126    127   
          128  +do_test shell4-3.1 {
          129  +  set fd [open t1.txt wb]
          130  +  puts $fd "SELECT 'squirrel';"
          131  +  close $fd
          132  +  exec $::CLI :memory: --interactive ".read t1.txt"
          133  +} {squirrel}
          134  +do_test shell4-3.2 {
          135  +  set fd [open t1.txt wb]
          136  +  puts $fd "SELECT 'pound: \302\243';"
          137  +  close $fd
          138  +  exec $::CLI :memory: --interactive ".read t1.txt"
          139  +} {pound: £}
   127    140   
   128    141   finish_test