/ Check-in [917c4108]
Login

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

Overview
Comment:Version 3.8.4 for sessions (plus two minor fixes).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1: 917c410808756e1697bd628f4c9c57dd13d08ce7
User & Date: drh 2014-03-11 01:48:06
Context
2014-03-12
10:03
Bump the version number to 3.8.4.1., to conform with trunk. check-in: 42c9d8fc user: drh tags: sessions
2014-03-11
01:48
Version 3.8.4 for sessions (plus two minor fixes). check-in: 917c4108 user: drh tags: sessions
2014-03-10
20:12
Adjustments to the cost computation for the skip-scan query plan, to take into account the fact that a seek has to occur on each skip. check-in: 0769eebd user: drh tags: trunk
2014-03-07
14:36
Merge the fix for the journal_mode=PERSIST error recovery delay bug. check-in: bb6a75f4 user: drh tags: sessions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/func.c.

  1013   1013   static void charFunc(
  1014   1014     sqlite3_context *context,
  1015   1015     int argc,
  1016   1016     sqlite3_value **argv
  1017   1017   ){
  1018   1018     unsigned char *z, *zOut;
  1019   1019     int i;
  1020         -  zOut = z = sqlite3_malloc( argc*4 );
         1020  +  zOut = z = sqlite3_malloc( argc*4+1 );
  1021   1021     if( z==0 ){
  1022   1022       sqlite3_result_error_nomem(context);
  1023   1023       return;
  1024   1024     }
  1025   1025     for(i=0; i<argc; i++){
  1026   1026       sqlite3_int64 x;
  1027   1027       unsigned c;

Changes to src/pager.c.

  4885   4885       ** in fact there is none.  This results in a false-positive which will
  4886   4886       ** be dealt with by the playback routine.  Ticket #3883.
  4887   4887       */
  4888   4888       rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);
  4889   4889       if( rc==SQLITE_OK && !locked ){
  4890   4890         Pgno nPage;                 /* Number of pages in database file */
  4891   4891   
  4892         -      /* Check the size of the database file. If it consists of 0 pages
  4893         -      ** and the journal is not being persisted, then delete the journal
  4894         -      ** file.  See the header comment above for the reasoning here.
  4895         -      ** Delete the obsolete journal file under a RESERVED lock to avoid
  4896         -      ** race conditions and to avoid violating [H33020].
  4897         -      */
  4898   4892         rc = pagerPagecount(pPager, &nPage);
  4899   4893         if( rc==SQLITE_OK ){
         4894  +        /* If the database is zero pages in size, that means that either (1) the
         4895  +        ** journal is a remnant from a prior database with the same name where
         4896  +        ** the database file but not the journal was deleted, or (2) the initial
         4897  +        ** transaction that populates a new database is being rolled back.
         4898  +        ** In either case, the journal file can be deleted.  However, take care
         4899  +        ** not to delete the journal file if it is already open due to
         4900  +        ** journal_mode=PERSIST.
         4901  +        */
  4900   4902           if( nPage==0 && !jrnlOpen ){
  4901   4903             sqlite3BeginBenignMalloc();
  4902   4904             if( pagerLockDb(pPager, RESERVED_LOCK)==SQLITE_OK ){
  4903   4905               sqlite3OsDelete(pVfs, pPager->zJournal, 0);
  4904   4906               if( !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);
  4905   4907             }
  4906   4908             sqlite3EndBenignMalloc();

Changes to src/pragma.c.

   820    820     ** Older versions of SQLite would set the default cache size to a
   821    821     ** negative number to indicate synchronous=OFF.  These days, synchronous
   822    822     ** is always on by default regardless of the sign of the default cache
   823    823     ** size.  But continue to take the absolute value of the default cache
   824    824     ** size of historical compatibility.
   825    825     */
   826    826     case PragTyp_DEFAULT_CACHE_SIZE: {
   827         -    static const int iLn = __LINE__+2;
          827  +    static const int iLn = VDBE_OFFSET_LINENO(2);
   828    828       static const VdbeOpList getCacheSize[] = {
   829    829         { OP_Transaction, 0, 0,        0},                         /* 0 */
   830    830         { OP_ReadCookie,  0, 1,        BTREE_DEFAULT_CACHE_SIZE},  /* 1 */
   831    831         { OP_IfPos,       1, 8,        0},
   832    832         { OP_Integer,     0, 2,        0},
   833    833         { OP_Subtract,    1, 2,        1},
   834    834         { OP_IfPos,       1, 8,        0},
................................................................................
  1083   1083         rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);
  1084   1084         if( rc==SQLITE_OK && (eAuto==1 || eAuto==2) ){
  1085   1085           /* When setting the auto_vacuum mode to either "full" or 
  1086   1086           ** "incremental", write the value of meta[6] in the database
  1087   1087           ** file. Before writing to meta[6], check that meta[3] indicates
  1088   1088           ** that this really is an auto-vacuum capable database.
  1089   1089           */
  1090         -        static const int iLn = __LINE__+2;
         1090  +        static const int iLn = VDBE_OFFSET_LINENO(2);
  1091   1091           static const VdbeOpList setMeta6[] = {
  1092   1092             { OP_Transaction,    0,         1,                 0},    /* 0 */
  1093   1093             { OP_ReadCookie,     0,         1,         BTREE_LARGEST_ROOT_PAGE},
  1094   1094             { OP_If,             1,         0,                 0},    /* 2 */
  1095   1095             { OP_Halt,           SQLITE_OK, OE_Abort,          0},    /* 3 */
  1096   1096             { OP_Integer,        0,         1,                 0},    /* 4 */
  1097   1097             { OP_SetCookie,      0,         BTREE_INCR_VACUUM, 1},    /* 5 */
................................................................................
  1786   1786     case PragTyp_INTEGRITY_CHECK: {
  1787   1787       int i, j, addr, mxErr;
  1788   1788   
  1789   1789       /* Code that appears at the end of the integrity check.  If no error
  1790   1790       ** messages have been generated, output OK.  Otherwise output the
  1791   1791       ** error message
  1792   1792       */
  1793         -    static const int iLn = __LINE__+2;
         1793  +    static const int iLn = VDBE_OFFSET_LINENO(2);
  1794   1794       static const VdbeOpList endCode[] = {
  1795   1795         { OP_AddImm,      1, 0,        0},    /* 0 */
  1796   1796         { OP_IfNeg,       1, 0,        0},    /* 1 */
  1797   1797         { OP_String8,     0, 3,        0},    /* 2 */
  1798   1798         { OP_ResultRow,   3, 1,        0},
  1799   1799       };
  1800   1800   

Changes to src/trigger.c.

   562    562   #endif
   563    563   
   564    564     /* Generate code to destroy the database record of the trigger.
   565    565     */
   566    566     assert( pTable!=0 );
   567    567     if( (v = sqlite3GetVdbe(pParse))!=0 ){
   568    568       int base;
   569         -    static const int iLn = __LINE__+2;
          569  +    static const int iLn = VDBE_OFFSET_LINENO(2);
   570    570       static const VdbeOpList dropTrigger[] = {
   571    571         { OP_Rewind,     0, ADDR(9),  0},
   572    572         { OP_String8,    0, 1,        0}, /* 1 */
   573    573         { OP_Column,     0, 1,        2},
   574    574         { OP_Ne,         2, ADDR(8),  1},
   575    575         { OP_String8,    0, 1,        0}, /* 4: "trigger" */
   576    576         { OP_Column,     0, 0,        2},

Changes to src/vdbe.h.

   270    270   */
   271    271   #ifdef SQLITE_VDBE_COVERAGE
   272    272     void sqlite3VdbeSetLineNumber(Vdbe*,int);
   273    273   # define VdbeCoverage(v) sqlite3VdbeSetLineNumber(v,__LINE__)
   274    274   # define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__)
   275    275   # define VdbeCoverageAlwaysTaken(v) sqlite3VdbeSetLineNumber(v,2);
   276    276   # define VdbeCoverageNeverTaken(v) sqlite3VdbeSetLineNumber(v,1);
          277  +# define VDBE_OFFSET_LINENO(x) (__LINE__+x)
   277    278   #else
   278    279   # define VdbeCoverage(v)
   279    280   # define VdbeCoverageIf(v,x)
   280    281   # define VdbeCoverageAlwaysTaken(v)
   281    282   # define VdbeCoverageNeverTaken(v)
          283  +# define VDBE_OFFSET_LINENO(x) 0
   282    284   #endif
   283    285   
   284    286   #endif

Changes to src/vdbeblob.c.

   131    131     ** uses it to implement the blob_read(), blob_write() and 
   132    132     ** blob_bytes() functions.
   133    133     **
   134    134     ** The sqlite3_blob_close() function finalizes the vdbe program,
   135    135     ** which closes the b-tree cursor and (possibly) commits the 
   136    136     ** transaction.
   137    137     */
   138         -  static const int iLn = __LINE__+4;
          138  +  static const int iLn = VDBE_OFFSET_LINENO(4);
   139    139     static const VdbeOpList openBlob[] = {
   140    140       /* {OP_Transaction, 0, 0, 0},  // 0: Inserted separately */
   141    141       {OP_TableLock, 0, 0, 0},       /* 1: Acquire a read or write lock */
   142    142       /* One of the following two instructions is replaced by an OP_Noop. */
   143    143       {OP_OpenRead, 0, 0, 0},        /* 2: Open cursor 0 for reading */
   144    144       {OP_OpenWrite, 0, 0, 0},       /* 3: Open cursor 0 for read/write */
   145    145       {OP_Variable, 1, 1, 1},        /* 4: Push the rowid to the stack */

Changes to src/where.c.

  3970   3970     ){
  3971   3971       LogEst nIter;
  3972   3972       pNew->u.btree.nEq++;
  3973   3973       pNew->u.btree.nSkip++;
  3974   3974       pNew->aLTerm[pNew->nLTerm++] = 0;
  3975   3975       pNew->wsFlags |= WHERE_SKIPSCAN;
  3976   3976       nIter = sqlite3LogEst(pProbe->aiRowEst[0]/pProbe->aiRowEst[saved_nEq+1]);
         3977  +    pNew->rRun = rLogSize + nIter;
         3978  +    pNew->nOut += nIter;
  3977   3979       whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter);
         3980  +    pNew->nOut = saved_nOut;
  3978   3981     }
  3979   3982     for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
  3980   3983       int nIn = 0;
  3981   3984   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  3982   3985       int nRecValid = pBuilder->nRecValid;
  3983   3986   #endif
  3984   3987       if( (pTerm->eOperator==WO_ISNULL || (pTerm->wtFlags&TERM_VNULL)!=0)

Changes to test/func.test.

  1357   1357     if {$i==0xfeff} continue
  1358   1358     do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i
  1359   1359   }
  1360   1360   for {set i 65536} {$i<=0x10ffff} {incr i 139} {
  1361   1361     do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i
  1362   1362   }
  1363   1363   
         1364  +# Test char().
         1365  +#
         1366  +do_execsql_test func-31.1 { 
         1367  +  SELECT char(), length(char()), typeof(char()) 
         1368  +} {{} 0 text}
  1364   1369   finish_test

Changes to test/skipscan1.test.

   204    204     SELECT i FROM t4 WHERE c=3;
   205    205     SELECT i FROM t4 WHERE d=4;
   206    206     SELECT i FROM t4 WHERE e=5;
   207    207     SELECT i FROM t4 WHERE f=6;
   208    208     SELECT i FROM t4 WHERE g=7;
   209    209     SELECT i FROM t4 WHERE h=8;
   210    210   } {9 9 9 9 9 9 9 9}
          211  +
          212  +# Make sure skip-scan cost computation in the query planner takes into
          213  +# account the fact that the seek must occur multiple times.
          214  +#
          215  +# Prior to 2014-03-10, the costs were computed incorrectly which would
          216  +# cause index t5i2 to be used instead of t5i1 on the skipscan1-5.3.
          217  +#
          218  +do_execsql_test skipscan1-5.1 {
          219  +  CREATE TABLE t5(
          220  +    id INTEGER PRIMARY KEY,
          221  +    loc TEXT,
          222  +    lang INTEGER,
          223  +    utype INTEGER,
          224  +    xa INTEGER,
          225  +    xd INTEGER,
          226  +    xh INTEGER
          227  +  );
          228  +  CREATE INDEX t5i1 on t5(loc, xh, xa, utype, lang);
          229  +  CREATE INDEX t5i2 ON t5(xd,loc,utype,lang);
          230  +  EXPLAIN QUERY PLAN
          231  +    SELECT xh, loc FROM t5 WHERE loc >= 'M' AND loc < 'N';
          232  +} {/.*COVERING INDEX t5i1 .*/}
          233  +do_execsql_test skipscan1-5.2 {
          234  +  ANALYZE;
          235  +  DELETE FROM sqlite_stat1;
          236  +  DROP TABLE IF EXISTS sqlite_stat4;
          237  +  DROP TABLE IF EXISTS sqlite_stat3;
          238  +  INSERT INTO sqlite_stat1 VALUES('t5','t5i1','2702931 3 2 2 2 2');
          239  +  INSERT INTO sqlite_stat1 VALUES('t5','t5i2','2702931 686 2 2 2');
          240  +  ANALYZE sqlite_master;
          241  +} {}
          242  +db cache flush
          243  +do_execsql_test skipscan1-5.3 {
          244  +  EXPLAIN QUERY PLAN
          245  +    SELECT xh, loc FROM t5 WHERE loc >= 'M' AND loc < 'N';
          246  +} {/.*COVERING INDEX t5i1 .*/}
          247  +
          248  +
   211    249   
   212    250   finish_test