/ Check-in [515cb3f4]
Login

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

Overview
Comment:Merge with latest trunk changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fts3-experimental
Files: files | file ages | folders
SHA1: 515cb3f4e5282551d300ba79c8885b8ca016a408
User & Date: dan 2010-11-26 10:58:49
Context
2010-11-26
15:13
Add a couple of comments to fts3_snippet.c. Closed-Leaf check-in: ad8df6c5 user: dan tags: fts3-experimental
10:58
Merge with latest trunk changes. check-in: 515cb3f4 user: dan tags: fts3-experimental
2010-11-25
17:49
Add coverage tests (and associated fixes) for new matchinfo() code. check-in: 70495cec user: dan tags: fts3-experimental
2010-11-24
13:04
Fix a couple of compiler warnings in test_superlock.c. Add superlock.c to the Makefile.in used by the configure script. check-in: 461f1a01 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

   369    369     $(TOP)/src/test_onefile.c \
   370    370     $(TOP)/src/test_osinst.c \
   371    371     $(TOP)/src/test_pcache.c \
   372    372     $(TOP)/src/test_quota.c \
   373    373     $(TOP)/src/test_rtree.c \
   374    374     $(TOP)/src/test_schema.c \
   375    375     $(TOP)/src/test_server.c \
          376  +  $(TOP)/src/test_superlock.c \
   376    377     $(TOP)/src/test_stat.c \
   377    378     $(TOP)/src/test_tclvar.c \
   378    379     $(TOP)/src/test_thread.c \
   379    380     $(TOP)/src/test_vfs.c \
   380    381     $(TOP)/src/test_wsd.c
   381    382   
   382    383   # Source code to the library files needed by the test fixture

Changes to src/pager.c.

  3479   3479   **
  3480   3480   ** Regardless of mxPage, return the current maximum page count.
  3481   3481   */
  3482   3482   int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
  3483   3483     if( mxPage>0 ){
  3484   3484       pPager->mxPgno = mxPage;
  3485   3485     }
  3486         -  if( pPager->eState!=PAGER_OPEN && pPager->mxPgno<pPager->dbSize ){
  3487         -    pPager->mxPgno = pPager->dbSize;
  3488         -  }
         3486  +  assert( pPager->eState!=PAGER_OPEN );      /* Called only by OP_MaxPgcnt */
         3487  +  assert( pPager->mxPgno>=pPager->dbSize );  /* OP_MaxPgcnt enforces this */
  3489   3488     return pPager->mxPgno;
  3490   3489   }
  3491   3490   
  3492   3491   /*
  3493   3492   ** The following set of routines are used to disable the simulated
  3494   3493   ** I/O error mechanism.  These routines are used to avoid simulated
  3495   3494   ** errors in places where we do not care about errors.

Changes to src/pragma.c.

    31     31                                /* 123456789 123456789 */
    32     32     static const char zText[] = "onoffalseyestruefull";
    33     33     static const u8 iOffset[] = {0, 1, 2, 4, 9, 12, 16};
    34     34     static const u8 iLength[] = {2, 2, 3, 5, 3, 4, 4};
    35     35     static const u8 iValue[] =  {1, 0, 0, 0, 1, 1, 2};
    36     36     int i, n;
    37     37     if( sqlite3Isdigit(*z) ){
    38         -    return (u8)atoi(z);
           38  +    return (u8)sqlite3Atoi(z);
    39     39     }
    40     40     n = sqlite3Strlen30(z);
    41     41     for(i=0; i<ArraySize(iLength); i++){
    42     42       if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0 ){
    43     43         return iValue[i];
    44     44       }
    45     45     }
................................................................................
    72     72   ** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively.
    73     73   */
    74     74   static int getAutoVacuum(const char *z){
    75     75     int i;
    76     76     if( 0==sqlite3StrICmp(z, "none") ) return BTREE_AUTOVACUUM_NONE;
    77     77     if( 0==sqlite3StrICmp(z, "full") ) return BTREE_AUTOVACUUM_FULL;
    78     78     if( 0==sqlite3StrICmp(z, "incremental") ) return BTREE_AUTOVACUUM_INCR;
    79         -  i = atoi(z);
           79  +  i = sqlite3Atoi(z);
    80     80     return (u8)((i>=0&&i<=2)?i:0);
    81     81   }
    82     82   #endif /* ifndef SQLITE_OMIT_AUTOVACUUM */
    83     83   
    84     84   #ifndef SQLITE_OMIT_PAGER_PRAGMAS
    85     85   /*
    86     86   ** Interpret the given string as a temp db location. Return 1 for file
................................................................................
   380    380         sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cache_size", SQLITE_STATIC);
   381    381         pParse->nMem += 2;
   382    382         addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);
   383    383         sqlite3VdbeChangeP1(v, addr, iDb);
   384    384         sqlite3VdbeChangeP1(v, addr+1, iDb);
   385    385         sqlite3VdbeChangeP1(v, addr+6, SQLITE_DEFAULT_CACHE_SIZE);
   386    386       }else{
   387         -      int size = atoi(zRight);
          387  +      int size = sqlite3Atoi(zRight);
   388    388         if( size<0 ) size = -size;
   389    389         sqlite3BeginWriteOperation(pParse, 0, iDb);
   390    390         sqlite3VdbeAddOp2(v, OP_Integer, size, 1);
   391    391         sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1);
   392    392         pDb->pSchema->cache_size = size;
   393    393         sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
   394    394       }
................................................................................
   409    409       if( !zRight ){
   410    410         int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;
   411    411         returnSingleInt(pParse, "page_size", size);
   412    412       }else{
   413    413         /* Malloc may fail when setting the page-size, as there is an internal
   414    414         ** buffer that the pager module resizes using sqlite3_realloc().
   415    415         */
   416         -      db->nextPagesize = atoi(zRight);
          416  +      db->nextPagesize = sqlite3Atoi(zRight);
   417    417         if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){
   418    418           db->mallocFailed = 1;
   419    419         }
   420    420       }
   421    421     }else
   422    422   
   423         -  /*
   424         -  **  PRAGMA [database.]max_page_count
   425         -  **  PRAGMA [database.]max_page_count=N
   426         -  **
   427         -  ** The first form reports the current setting for the
   428         -  ** maximum number of pages in the database file.  The 
   429         -  ** second form attempts to change this setting.  Both
   430         -  ** forms return the current setting.
   431         -  */
   432         -  if( sqlite3StrICmp(zLeft,"max_page_count")==0 ){
   433         -    Btree *pBt = pDb->pBt;
   434         -    int newMax = 0;
   435         -    assert( pBt!=0 );
   436         -    if( zRight ){
   437         -      newMax = atoi(zRight);
   438         -    }
   439         -    if( ALWAYS(pBt) ){
   440         -      newMax = sqlite3BtreeMaxPageCount(pBt, newMax);
   441         -    }
   442         -    returnSingleInt(pParse, "max_page_count", newMax);
   443         -  }else
   444         -
   445    423     /*
   446    424     **  PRAGMA [database.]secure_delete
   447    425     **  PRAGMA [database.]secure_delete=ON/OFF
   448    426     **
   449    427     ** The first form reports the current setting for the
   450    428     ** secure_delete flag.  The second form changes the secure_delete
   451    429     ** flag setting and reports thenew value.
................................................................................
   464    442         }
   465    443       }
   466    444       b = sqlite3BtreeSecureDelete(pBt, b);
   467    445       returnSingleInt(pParse, "secure_delete", b);
   468    446     }else
   469    447   
   470    448     /*
          449  +  **  PRAGMA [database.]max_page_count
          450  +  **  PRAGMA [database.]max_page_count=N
          451  +  **
          452  +  ** The first form reports the current setting for the
          453  +  ** maximum number of pages in the database file.  The 
          454  +  ** second form attempts to change this setting.  Both
          455  +  ** forms return the current setting.
          456  +  **
   471    457     **  PRAGMA [database.]page_count
   472    458     **
   473    459     ** Return the number of pages in the specified database.
   474    460     */
   475         -  if( sqlite3StrICmp(zLeft,"page_count")==0 ){
          461  +  if( sqlite3StrICmp(zLeft,"page_count")==0
          462  +   || sqlite3StrICmp(zLeft,"max_page_count")==0
          463  +  ){
   476    464       int iReg;
   477    465       if( sqlite3ReadSchema(pParse) ) goto pragma_out;
   478    466       sqlite3CodeVerifySchema(pParse, iDb);
   479    467       iReg = ++pParse->nMem;
   480         -    sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg);
          468  +    if( zLeft[0]=='p' ){
          469  +      sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg);
          470  +    }else{
          471  +      sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, sqlite3Atoi(zRight));
          472  +    }
   481    473       sqlite3VdbeAddOp2(v, OP_ResultRow, iReg, 1);
   482    474       sqlite3VdbeSetNumCols(v, 1);
   483         -    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "page_count", SQLITE_STATIC);
          475  +    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT);
   484    476     }else
   485    477   
   486    478     /*
   487    479     **  PRAGMA [database.]locking_mode
   488    480     **  PRAGMA [database.]locking_mode = (normal|exclusive)
   489    481     */
   490    482     if( sqlite3StrICmp(zLeft,"locking_mode")==0 ){
................................................................................
   698    690     ** N should be a positive integer.
   699    691     */
   700    692     if( sqlite3StrICmp(zLeft,"cache_size")==0 ){
   701    693       if( sqlite3ReadSchema(pParse) ) goto pragma_out;
   702    694       if( !zRight ){
   703    695         returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size);
   704    696       }else{
   705         -      int size = atoi(zRight);
          697  +      int size = sqlite3Atoi(zRight);
   706    698         if( size<0 ) size = -size;
   707    699         pDb->pSchema->cache_size = size;
   708    700         sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
   709    701       }
   710    702     }else
   711    703   
   712    704     /*
................................................................................
  1091   1083       pParse->nMem = 6;
  1092   1084       sqlite3VdbeSetNumCols(v, 1);
  1093   1085       sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "integrity_check", SQLITE_STATIC);
  1094   1086   
  1095   1087       /* Set the maximum error count */
  1096   1088       mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
  1097   1089       if( zRight ){
  1098         -      mxErr = atoi(zRight);
         1090  +      sqlite3GetInt32(zRight, &mxErr);
  1099   1091         if( mxErr<=0 ){
  1100   1092           mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
  1101   1093         }
  1102   1094       }
  1103   1095       sqlite3VdbeAddOp2(v, OP_Integer, mxErr, 1);  /* reg[1] holds errors left */
  1104   1096   
  1105   1097       /* Do an integrity check on each database file */
................................................................................
  1348   1340         static const VdbeOpList setCookie[] = {
  1349   1341           { OP_Transaction,    0,  1,  0},    /* 0 */
  1350   1342           { OP_Integer,        0,  1,  0},    /* 1 */
  1351   1343           { OP_SetCookie,      0,  0,  1},    /* 2 */
  1352   1344         };
  1353   1345         int addr = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie);
  1354   1346         sqlite3VdbeChangeP1(v, addr, iDb);
  1355         -      sqlite3VdbeChangeP1(v, addr+1, atoi(zRight));
         1347  +      sqlite3VdbeChangeP1(v, addr+1, sqlite3Atoi(zRight));
  1356   1348         sqlite3VdbeChangeP1(v, addr+2, iDb);
  1357   1349         sqlite3VdbeChangeP2(v, addr+2, iCookie);
  1358   1350       }else{
  1359   1351         /* Read the specified cookie value */
  1360   1352         static const VdbeOpList readCookie[] = {
  1361   1353           { OP_Transaction,     0,  0,  0},    /* 0 */
  1362   1354           { OP_ReadCookie,      0,  1,  0},    /* 1 */
................................................................................
  1409   1401     **
  1410   1402     ** Configure a database connection to automatically checkpoint a database
  1411   1403     ** after accumulating N frames in the log. Or query for the current value
  1412   1404     ** of N.
  1413   1405     */
  1414   1406     if( sqlite3StrICmp(zLeft, "wal_autocheckpoint")==0 ){
  1415   1407       if( zRight ){
  1416         -      int nAuto = atoi(zRight);
  1417         -      sqlite3_wal_autocheckpoint(db, nAuto);
         1408  +      sqlite3_wal_autocheckpoint(db, sqlite3Atoi(zRight));
  1418   1409       }
  1419   1410       returnSingleInt(pParse, "wal_autocheckpoint", 
  1420   1411          db->xWalCallback==sqlite3WalDefaultHook ? 
  1421   1412              SQLITE_PTR_TO_INT(db->pWalArg) : 0);
  1422   1413     }else
  1423   1414   #endif
  1424   1415   

Changes to src/prepare.c.

    75     75       */
    76     76       int rc;
    77     77       sqlite3_stmt *pStmt;
    78     78       TESTONLY(int rcp);            /* Return code from sqlite3_prepare() */
    79     79   
    80     80       assert( db->init.busy );
    81     81       db->init.iDb = iDb;
    82         -    db->init.newTnum = atoi(argv[1]);
           82  +    db->init.newTnum = sqlite3Atoi(argv[1]);
    83     83       db->init.orphanTrigger = 0;
    84     84       TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);
    85     85       rc = db->errCode;
    86     86       assert( (rc&0xFF)==(rcp&0xFF) );
    87     87       db->init.iDb = 0;
    88     88       if( SQLITE_OK!=rc ){
    89     89         if( db->init.orphanTrigger ){

Changes to src/sqliteInt.h.

  2836   2836   int sqlite3FixSrcList(DbFixer*, SrcList*);
  2837   2837   int sqlite3FixSelect(DbFixer*, Select*);
  2838   2838   int sqlite3FixExpr(DbFixer*, Expr*);
  2839   2839   int sqlite3FixExprList(DbFixer*, ExprList*);
  2840   2840   int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
  2841   2841   int sqlite3AtoF(const char *z, double*, int, u8);
  2842   2842   int sqlite3GetInt32(const char *, int*);
         2843  +int sqlite3Atoi(const char*);
  2843   2844   int sqlite3Utf16ByteLen(const void *pData, int nChar);
  2844   2845   int sqlite3Utf8CharLen(const char *pData, int nByte);
  2845   2846   int sqlite3Utf8Read(const u8*, const u8**);
  2846   2847   
  2847   2848   /*
  2848   2849   ** Routines to read and write variable-length integers.  These used to
  2849   2850   ** be defined locally, but now we use the varint routines in the util.c

Changes to src/test_superlock.c.

    98     98   static int superlockWalLock(
    99     99     sqlite3 *db,                    /* Database handle open on WAL database */
   100    100     SuperlockBusy *pBusy            /* Busy handler wrapper object */
   101    101   ){
   102    102     int rc;                         /* Return code */
   103    103     sqlite3_file *fd = 0;           /* Main database file handle */
   104    104     void volatile *p = 0;           /* Pointer to first page of shared memory */
   105         -  int nBusy = 0;                  /* Number of calls already made to xBusy */
   106    105   
   107    106     /* Obtain a pointer to the sqlite3_file object open on the main db file. */
   108    107     rc = sqlite3_file_control(db, "main", SQLITE_FCNTL_FILE_POINTER, (void *)&fd);
   109    108     if( rc!=SQLITE_OK ) return rc;
   110    109   
   111    110     /* Obtain the "recovery" lock. Normally, this lock is only obtained by
   112    111     ** clients running database recovery.  
................................................................................
   307    306     }
   308    307   
   309    308     rc = sqlite3demo_superlock(zPath, zVfs, xBusy, &busy, &pLock);
   310    309     assert( rc==SQLITE_OK || pLock==0 );
   311    310     assert( rc!=SQLITE_OK || pLock!=0 );
   312    311   
   313    312     if( rc!=SQLITE_OK ){
          313  +    extern const char *sqlite3ErrStr(int);
   314    314       Tcl_ResetResult(interp);
   315    315       Tcl_AppendResult(interp, sqlite3ErrStr(rc), 0);
   316    316       return TCL_ERROR;
   317    317     }
   318    318   
   319    319     Tcl_CreateObjCommand(
   320    320         interp, Tcl_GetString(objv[1]), superunlock_cmd, pLock, superunlock_del

Changes to src/util.c.

   536    536     }
   537    537     if( neg ){
   538    538       v = -v;
   539    539     }
   540    540     *pValue = (int)v;
   541    541     return 1;
   542    542   }
          543  +
          544  +/*
          545  +** Return a 32-bit integer value extracted from a string.  If the
          546  +** string is not an integer, just return 0.
          547  +*/
          548  +int sqlite3Atoi(const char *z){
          549  +  int x = 0;
          550  +  if( z ) sqlite3GetInt32(z, &x);
          551  +  return x;
          552  +}
   543    553   
   544    554   /*
   545    555   ** The variable-length integer encoding is as follows:
   546    556   **
   547    557   ** KEY:
   548    558   **         A = 0xxxxxxx    7 bits of data and one flag bit
   549    559   **         B = 1xxxxxxx    7 bits of data and one flag bit

Changes to src/vdbe.c.

  5783   5783   ** Write the current number of pages in database P1 to memory cell P2.
  5784   5784   */
  5785   5785   case OP_Pagecount: {            /* out2-prerelease */
  5786   5786     pOut->u.i = sqlite3BtreeLastPage(db->aDb[pOp->p1].pBt);
  5787   5787     break;
  5788   5788   }
  5789   5789   #endif
         5790  +
         5791  +
         5792  +#ifndef  SQLITE_OMIT_PAGER_PRAGMAS
         5793  +/* Opcode: MaxPgcnt P1 P2 P3 * *
         5794  +**
         5795  +** Try to set the maximum page count for database P1 to the value in P3.
         5796  +** Do not let the maximum page count fall below the current page count and
         5797  +** do not change the maximum page count value if P3==0.
         5798  +**
         5799  +** Store the maximum page count after the change in register P2.
         5800  +*/
         5801  +case OP_MaxPgcnt: {            /* out2-prerelease */
         5802  +  unsigned int newMax;
         5803  +  Btree *pBt;
         5804  +
         5805  +  pBt = db->aDb[pOp->p1].pBt;
         5806  +  newMax = 0;
         5807  +  if( pOp->p3 ){
         5808  +    newMax = sqlite3BtreeLastPage(pBt);
         5809  +    if( pOp->p3>newMax ) newMax = pOp->p3;
         5810  +  }
         5811  +  pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);
         5812  +  break;
         5813  +}
         5814  +#endif
         5815  +
  5790   5816   
  5791   5817   #ifndef SQLITE_OMIT_TRACE
  5792   5818   /* Opcode: Trace * * * P4 *
  5793   5819   **
  5794   5820   ** If tracing is enabled (by the sqlite3_trace()) interface, then
  5795   5821   ** the UTF-8 string contained in P4 is emitted on the trace callback.
  5796   5822   */

Changes to test/pager1.test.

  1058   1058   } {13}
  1059   1059   do_execsql_test pager1-6.8 {
  1060   1060       INSERT INTO t11 VALUES(3, 4);
  1061   1061       PRAGMA max_page_count = 10;
  1062   1062   } {11}
  1063   1063   do_execsql_test pager1-6.9 { COMMIT } {}
  1064   1064   
  1065         -do_execsql_test pager1-6.10 { PRAGMA max_page_count = 10 } {10}
         1065  +do_execsql_test pager1-6.10 { PRAGMA max_page_count = 10 } {11}
  1066   1066   do_execsql_test pager1-6.11 { SELECT * FROM t11 }          {1 2 3 4}
  1067   1067   do_execsql_test pager1-6.12 { PRAGMA max_page_count }      {11}
  1068   1068   
  1069   1069   
  1070   1070   #-------------------------------------------------------------------------
  1071   1071   # The following tests work with "PRAGMA journal_mode=TRUNCATE" and
  1072   1072   # "PRAGMA locking_mode=EXCLUSIVE".

Changes to tool/lemon.c.

    16     16   #ifndef __WIN32__
    17     17   #   if defined(_WIN32) || defined(WIN32)
    18     18   #	define __WIN32__
    19     19   #   endif
    20     20   #endif
    21     21   
    22     22   #ifdef __WIN32__
    23         -extern int access();
           23  +#ifdef __cplusplus
           24  +extern "C" {
           25  +#endif
           26  +extern int access(const char *path, int mode);
           27  +#ifdef __cplusplus
           28  +}
           29  +#endif
    24     30   #else
    25     31   #include <unistd.h>
    26     32   #endif
    27     33   
    28     34   /* #define PRIVATE static */
    29     35   #define PRIVATE
    30     36   
................................................................................
  3259   3265     if( n<=0 ){
  3260   3266       if( n<0 ){
  3261   3267         used += n;
  3262   3268         assert( used>=0 );
  3263   3269       }
  3264   3270       n = lemonStrlen(zText);
  3265   3271     }
  3266         -  if( n+sizeof(zInt)*2+used >= alloced ){
         3272  +  if( (int) (n+sizeof(zInt)*2+used) >= alloced ){
  3267   3273       alloced = n + sizeof(zInt)*2 + used + 200;
  3268   3274       z = (char *) realloc(z,  alloced);
  3269   3275     }
  3270   3276     if( z==0 ) return empty;
  3271   3277     while( n-- > 0 ){
  3272   3278       c = *(zText++);
  3273   3279       if( c=='%' && n>0 && zText[0]=='d' ){