/ Check-in [f2e15b19]
Login

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

Overview
Comment:Merge all changes from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | nextgen-query-plan-exp
Files: files | file ages | folders
SHA1:f2e15b1974e55373b5819e3b2326653f890f409f
User & Date: drh 2013-06-12 17:17:45
Context
2013-06-12
17:55
Bug fixes in the handling of virtual tables. check-in: 25c0f729 user: drh tags: nextgen-query-plan-exp
17:17
Merge all changes from trunk. check-in: f2e15b19 user: drh tags: nextgen-query-plan-exp
17:08
"make test" now passing. check-in: addd7f46 user: drh tags: nextgen-query-plan-exp
2013-06-11
14:22
Add the SQLITE_FTS3_MAX_EXPR_DEPTH compile time option. check-in: 24fc9d44 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3Int.h.

    34     34   # include "sqlite3ext.h" 
    35     35   extern const sqlite3_api_routines *sqlite3_api;
    36     36   #endif
    37     37   
    38     38   #include "sqlite3.h"
    39     39   #include "fts3_tokenizer.h"
    40     40   #include "fts3_hash.h"
           41  +
           42  +/*
           43  +** This constant determines the maximum depth of an FTS expression tree
           44  +** that the library will create and use. FTS uses recursion to perform 
           45  +** various operations on the query tree, so the disadvantage of a large
           46  +** limit is that it may allow very large queries to use large amounts
           47  +** of stack space (perhaps causing a stack overflow).
           48  +*/
           49  +#ifndef SQLITE_FTS3_MAX_EXPR_DEPTH
           50  +# define SQLITE_FTS3_MAX_EXPR_DEPTH 12
           51  +#endif
           52  +
    41     53   
    42     54   /*
    43     55   ** This constant controls how often segments are merged. Once there are
    44     56   ** FTS3_MERGE_COUNT segments of level N, they are merged into a single
    45     57   ** segment of level N+1.
    46     58   */
    47     59   #define FTS3_MERGE_COUNT 16

Changes to ext/fts3/fts3_expr.c.

   996    996     int bFts4,                          /* True to allow FTS4-only syntax */
   997    997     int nCol,                           /* Number of entries in azCol[] */
   998    998     int iDefaultCol,                    /* Default column to query */
   999    999     const char *z, int n,               /* Text of MATCH query */
  1000   1000     Fts3Expr **ppExpr,                  /* OUT: Parsed query structure */
  1001   1001     char **pzErr                        /* OUT: Error message (sqlite3_malloc) */
  1002   1002   ){
  1003         -  static const int MAX_EXPR_DEPTH = 12;
  1004   1003     int rc = fts3ExprParseUnbalanced(
  1005   1004         pTokenizer, iLangid, azCol, bFts4, nCol, iDefaultCol, z, n, ppExpr
  1006   1005     );
  1007   1006     
  1008   1007     /* Rebalance the expression. And check that its depth does not exceed
  1009         -  ** MAX_EXPR_DEPTH.  */
         1008  +  ** SQLITE_FTS3_MAX_EXPR_DEPTH.  */
  1010   1009     if( rc==SQLITE_OK && *ppExpr ){
  1011         -    rc = fts3ExprBalance(ppExpr, MAX_EXPR_DEPTH);
         1010  +    rc = fts3ExprBalance(ppExpr, SQLITE_FTS3_MAX_EXPR_DEPTH);
  1012   1011       if( rc==SQLITE_OK ){
  1013         -      rc = fts3ExprCheckDepth(*ppExpr, MAX_EXPR_DEPTH);
         1012  +      rc = fts3ExprCheckDepth(*ppExpr, SQLITE_FTS3_MAX_EXPR_DEPTH);
  1014   1013       }
  1015   1014     }
  1016   1015   
  1017   1016     if( rc!=SQLITE_OK ){
  1018   1017       sqlite3Fts3ExprFree(*ppExpr);
  1019   1018       *ppExpr = 0;
  1020   1019       if( rc==SQLITE_TOOBIG ){
  1021   1020         *pzErr = sqlite3_mprintf(
  1022         -          "FTS expression tree is too large (maximum depth %d)", MAX_EXPR_DEPTH
         1021  +          "FTS expression tree is too large (maximum depth %d)", 
         1022  +          SQLITE_FTS3_MAX_EXPR_DEPTH
  1023   1023         );
  1024   1024         rc = SQLITE_ERROR;
  1025   1025       }else if( rc==SQLITE_ERROR ){
  1026   1026         *pzErr = sqlite3_mprintf("malformed MATCH expression: [%s]", z);
  1027   1027       }
  1028   1028     }
  1029   1029   

Changes to ext/fts3/fts3_unicode2.c.

    97     97       0x02A00801, 0x02A01801, 0x02A02C01, 0x02A08C09, 0x02A0D804,
    98     98       0x02A1D004, 0x02A20002, 0x02A2D011, 0x02A33802, 0x02A38012,
    99     99       0x02A3E003, 0x02A4980A, 0x02A51C0D, 0x02A57C01, 0x02A60004,
   100    100       0x02A6CC1B, 0x02A77802, 0x02A8A40E, 0x02A90C01, 0x02A93002,
   101    101       0x02A97004, 0x02A9DC03, 0x02A9EC01, 0x02AAC001, 0x02AAC803,
   102    102       0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07,
   103    103       0x02ABD402, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02,
   104         -    0x037FFC02, 0x03E3FC01, 0x03EC7801, 0x03ECA401, 0x03EEC810,
   105         -    0x03F4F802, 0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023,
   106         -    0x03F95013, 0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807,
   107         -    0x03FCEC06, 0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405,
   108         -    0x04040003, 0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E,
   109         -    0x040E7C01, 0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01,
   110         -    0x04280403, 0x04281402, 0x04283004, 0x0428E003, 0x0428FC01,
   111         -    0x04294009, 0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016,
   112         -    0x04420003, 0x0442C012, 0x04440003, 0x04449C0E, 0x04450004,
   113         -    0x04460003, 0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004,
   114         -    0x05BD442E, 0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5,
   115         -    0x07480046, 0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01,
   116         -    0x075C5401, 0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401,
   117         -    0x075EA401, 0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064,
   118         -    0x07C2800F, 0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F,
   119         -    0x07C4C03C, 0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009,
   120         -    0x07C94002, 0x07CC0021, 0x07CCC006, 0x07CCDC46, 0x07CE0014,
   121         -    0x07CE8025, 0x07CF1805, 0x07CF8011, 0x07D0003F, 0x07D10001,
   122         -    0x07D108B6, 0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018,
   123         -    0x07D7EC46, 0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401,
   124         -    0x38008060, 0x380400F0, 0x3C000001, 0x3FFFF401, 0x40000001,
   125         -    0x43FFF401,
          104  +    0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802,
          105  +    0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023, 0x03F95013,
          106  +    0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06,
          107  +    0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003,
          108  +    0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E, 0x040E7C01,
          109  +    0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01, 0x04280403,
          110  +    0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009,
          111  +    0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016, 0x04420003,
          112  +    0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, 0x04460003,
          113  +    0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004, 0x05BD442E,
          114  +    0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5, 0x07480046,
          115  +    0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401,
          116  +    0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401,
          117  +    0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064, 0x07C2800F,
          118  +    0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F, 0x07C4C03C,
          119  +    0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, 0x07C94002,
          120  +    0x07CC0021, 0x07CCC006, 0x07CCDC46, 0x07CE0014, 0x07CE8025,
          121  +    0x07CF1805, 0x07CF8011, 0x07D0003F, 0x07D10001, 0x07D108B6,
          122  +    0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018, 0x07D7EC46,
          123  +    0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401, 0x38008060,
          124  +    0x380400F0,
   126    125     };
   127    126     static const unsigned int aAscii[4] = {
   128    127       0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001,
   129    128     };
   130    129   
   131    130     if( c<128 ){
   132    131       return ( (aAscii[c >> 5] & (1 << (c & 0x001F)))==0 );

Changes to ext/fts3/unicode/mkunicode.tcl.

   235    235       if {$line == ""} continue
   236    236   
   237    237       set fields [split $line ";"]
   238    238       if {[llength $fields] != [llength $lField]} { error "parse error: $line" }
   239    239       foreach $lField $fields {}
   240    240   
   241    241       set iCode [expr "0x$code"]
   242         -    set bAlnum [expr {[lsearch {L N} [string range $general_category 0 0]]>=0}]
          242  +    set bAlnum [expr {
          243  +         [lsearch {L N} [string range $general_category 0 0]] >= 0
          244  +      || $general_category=="Co"
          245  +    }]
   243    246   
   244    247       if { !$bAlnum } { lappend lRet $iCode }
   245    248     }
   246    249   
   247    250     close $fd
   248    251     set lRet
   249    252   }
................................................................................
   356    359           iLo = iTest+1;
   357    360         }else{
   358    361           iHi = iTest-1;
   359    362         }
   360    363       }
   361    364       assert( aEntry[0]<key );
   362    365       assert( key>=aEntry[iRes] );
   363         -    return (c >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));
          366  +    return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));
   364    367     }
   365    368     return 1;}
   366    369     puts "\}"
   367    370   }
   368    371   
   369    372   proc print_test_isalnum {zFunc lRange} {
   370    373     foreach range $lRange {
................................................................................
   725    728   */
   726    729   
   727    730   /*
   728    731   ** DO NOT EDIT THIS MACHINE GENERATED FILE.
   729    732   */
   730    733     }]
   731    734     puts ""
   732         -  puts "#if !defined(SQLITE_DISABLE_FTS3_UNICODE)"
          735  +  puts "#if defined(SQLITE_ENABLE_FTS4_UNICODE61)"
   733    736     puts "#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)"
   734    737     puts ""
   735    738     puts "#include <assert.h>"
   736    739     puts ""
   737    740   }
   738    741   
   739    742   proc print_test_main {} {
................................................................................
   801    804   if {$::generate_test_code} {
   802    805     print_test_isalnum sqlite3FtsUnicodeIsalnum $lRange
   803    806     print_fold_test sqlite3FtsUnicodeFold $mappings
   804    807     print_test_main 
   805    808   }
   806    809   
   807    810   puts "#endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */"
   808         -puts "#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */"
          811  +puts "#endif /* !defined(SQLITE_ENABLE_FTS4_UNICODE61) */"

Changes to src/build.c.

  1272   1272     i = p->nCol-1;
  1273   1273     db = pParse->db;
  1274   1274     zColl = sqlite3NameFromToken(db, pToken);
  1275   1275     if( !zColl ) return;
  1276   1276   
  1277   1277     if( sqlite3LocateCollSeq(pParse, zColl) ){
  1278   1278       Index *pIdx;
         1279  +    sqlite3DbFree(db, p->aCol[i].zColl);
  1279   1280       p->aCol[i].zColl = zColl;
  1280   1281     
  1281   1282       /* If the column is declared as "<name> PRIMARY KEY COLLATE <type>",
  1282   1283       ** then an index may have been created on this column before the
  1283   1284       ** collation type was added. Correct this if it is the case.
  1284   1285       */
  1285   1286       for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){

Changes to src/where.c.

    73     73     int addrBrk;          /* Jump here to break out of the loop */
    74     74     int addrNxt;          /* Jump here to start the next IN combination */
    75     75     int addrCont;         /* Jump here to continue with the next loop cycle */
    76     76     int addrFirst;        /* First instruction of interior of the loop */
    77     77     u8 iFrom;             /* Which entry in the FROM clause */
    78     78     u8 op, p5;            /* Opcode and P5 of the opcode that ends the loop */
    79     79     int p1, p2;           /* Operands of the opcode used to ends the loop */
    80         -  union {               /* Information that depends on plan.wsFlags */
           80  +  union {               /* Information that depends on pWLoop->wsFlags */
    81     81       struct {
    82     82         int nIn;              /* Number of entries in aInLoop[] */
    83     83         struct InLoop {
    84     84           int iCur;              /* The VDBE cursor used by this IN operator */
    85     85           int addrInTop;         /* Top of the IN loop */
    86     86           u8 eEndLoopOp;         /* IN Loop terminator. OP_Next or OP_Prev */
    87     87         } *aInLoop;           /* Information about each nested IN operator */
    88         -    } in;                 /* Used when plan.wsFlags&WHERE_IN_ABLE */
           88  +    } in;                 /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */
    89     89       Index *pCovidx;       /* Possible covering index for WHERE_MULTI_OR */
    90     90     } u;
    91     91     struct WhereLoop *pWLoop;  /* The selected WhereLoop object */
    92     92   };
    93     93   
    94     94   /*
    95     95   ** Each instance of this object represents a way of evaluating one
................................................................................
  2810   2810       WhereLoop *pLoop = pLevel->pWLoop;
  2811   2811   
  2812   2812       if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0
  2813   2813         && pLoop->u.btree.pIndex!=0
  2814   2814         && pLoop->u.btree.pIndex->aSortOrder[iEq]
  2815   2815       ){
  2816   2816         testcase( iEq==0 );
  2817         -      testcase( iEq==pLevel->plan.u.pIdx->nColumn-1 );
  2818         -      testcase( iEq>0 && iEq+1<pLevel->plan.u.pIdx->nColumn );
  2819   2817         testcase( bRev );
  2820   2818         bRev = !bRev;
  2821   2819       }
  2822   2820       assert( pX->op==TK_IN );
  2823   2821       iReg = iTarget;
  2824   2822       eType = sqlite3FindInIndex(pParse, pX, 0);
  2825   2823       if( eType==IN_INDEX_INDEX_DESC ){
................................................................................
  3551   3549       }
  3552   3550   
  3553   3551       /* If there are inequality constraints, check that the value
  3554   3552       ** of the table column that the inequality contrains is not NULL.
  3555   3553       ** If it is, jump to the next iteration of the loop.
  3556   3554       */
  3557   3555       r1 = sqlite3GetTempReg(pParse);
  3558         -    testcase( pLevel->plan.wsFlags & WHERE_BTM_LIMIT );
  3559         -    testcase( pLevel->plan.wsFlags & WHERE_TOP_LIMIT );
         3556  +    testcase( pLoop->wsFlags & WHERE_BTM_LIMIT );
         3557  +    testcase( pLoop->wsFlags & WHERE_TOP_LIMIT );
  3560   3558       if( (pLoop->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0 ){
  3561   3559         sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1);
  3562   3560         sqlite3VdbeAddOp2(v, OP_IsNull, r1, addrCont);
  3563   3561       }
  3564   3562       sqlite3ReleaseTempReg(pParse, r1);
  3565   3563   
  3566   3564       /* Seek the table cursor, if required */

Changes to test/collate1.test.

   300    300     }
   301    301   } {{} 1 12 101}
   302    302   do_test collate1-4.5 {
   303    303     execsql {
   304    304       DROP TABLE collate1t1;
   305    305     }
   306    306   } {}
          307  +
          308  +# A problem reported on the mailing list:  A CREATE TABLE statement
          309  +# is allowed to have two or more COLLATE clauses on the same column.
          310  +# That probably ought to be an error, but we allow it for backwards
          311  +# compatibility.  Just make sure it works and doesn't leak memory.
          312  +#
          313  +do_test collate1-5.1 {
          314  +  execsql {
          315  +    CREATE TABLE c5(
          316  +      id INTEGER PRIMARY KEY,
          317  +      a TEXT COLLATE binary COLLATE nocase COLLATE rtrim,
          318  +      b TEXT COLLATE nocase COLLATE binary,
          319  +      c TEXT COLLATE rtrim COLLATE binary COLLATE rtrim COLLATE nocase
          320  +    );
          321  +    INSERT INTO c5 VALUES(1, 'abc','abc','abc');
          322  +    INSERT INTO c5 VALUES(2, 'abc   ','ABC','ABC');
          323  +    SELECT id FROM c5 WHERE a='abc' ORDER BY id;
          324  +  }
          325  +} {1 2}
          326  +do_test collate1-5.2 {
          327  +  execsql {
          328  +    SELECT id FROM c5 WHERE b='abc' ORDER BY id;
          329  +  }
          330  +} {1}
          331  +do_test collate1-5.3 {
          332  +  execsql {
          333  +    SELECT id FROM c5 WHERE c='abc' ORDER BY id;
          334  +  }
          335  +} {1 2}
   307    336   
   308    337   finish_test

Changes to test/fts4unicode.test.

   379    379   
   380    380     do_isspace_test 6.$T.19 $T   {32 160 5760 6158}
   381    381     do_isspace_test 6.$T.19 $T   {8192 8193 8194 8195}
   382    382     do_isspace_test 6.$T.19 $T   {8196 8197 8198 8199}
   383    383     do_isspace_test 6.$T.19 $T   {8200 8201 8202 8239}
   384    384     do_isspace_test 6.$T.19 $T   {8287 12288}
   385    385   }
          386  +
          387  +#-------------------------------------------------------------------------
          388  +# Test that the private use ranges are treated as alphanumeric.
          389  +#
          390  +breakpoint
          391  +foreach {tn1 c} {
          392  +  1 \ue000 2 \ue001 3 \uf000 4 \uf8fe 5 \uf8ff
          393  +} {
          394  +  foreach {tn2 config res} {
          395  +    1 ""             "0 hello*world hello*world"
          396  +    2 "separators=*" "0 hello hello 1 world world"
          397  +  } {
          398  +    set config [string map [list * $c] $config]
          399  +    set input  [string map [list * $c] "hello*world"]
          400  +    set output [string map [list * $c] $res]
          401  +    do_unicode_token_test3 7.$tn1.$tn2 {*}$config $input $output
          402  +  }
          403  +}
   386    404   
   387    405   
   388    406   finish_test

Changes to tool/build-all-msvc.bat.

   370    370             )
   371    371           ) ELSE (
   372    372             REM
   373    373             REM NOTE: Even when the cleaning step has been disabled, we still
   374    374             REM       need to remove the build output for the files we are
   375    375             REM       specifically wanting to build for each platform.
   376    376             REM
   377         -          %__ECHO% DEL /Q sqlite3.dll sqlite3.lib sqlite3.pdb
          377  +          %__ECHO% DEL /Q *.lo sqlite3.dll sqlite3.lib sqlite3.pdb
   378    378           )
   379    379   
   380    380           REM
   381    381           REM NOTE: Call NMAKE with the MSVC makefile to build the "sqlite3.dll"
   382    382           REM       binary.  The x86 compiler will be used to compile the native
   383    383           REM       command line tools needed during the build process itself.
   384    384           REM       Also, disable looking for and/or linking to the native Tcl