/ Check-in [241f7bd1]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Make the sqlite3_db_status() routine threadsafe.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 241f7bd190329fa02ca428651072a4a206132eab
User & Date: dan 2010-07-22 17:55:40
Context
2010-07-22
22:40
Add evidence marks to the where.c source file. Comment only - no code changes. check-in: f3f9e8e5 user: drh tags: trunk
17:55
Make the sqlite3_db_status() routine threadsafe. check-in: 241f7bd1 user: dan tags: trunk
17:49
Enhance the LIKE/GLOB query optimization so that it works as long as there is an index with the appropriate collating sequence and even if the default collating sequence of the column is different. Ticket [4711020446da7d93d99]. check-in: 9f932655 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/status.c.

    99     99   int sqlite3_db_status(
   100    100     sqlite3 *db,          /* The database connection whose status is desired */
   101    101     int op,               /* Status verb */
   102    102     int *pCurrent,        /* Write current value here */
   103    103     int *pHighwater,      /* Write high-water mark here */
   104    104     int resetFlag         /* Reset high-water mark if true */
   105    105   ){
          106  +  int rc = SQLITE_OK;   /* Return code */
          107  +  sqlite3_mutex_enter(db->mutex);
   106    108     switch( op ){
   107    109       case SQLITE_DBSTATUS_LOOKASIDE_USED: {
   108    110         *pCurrent = db->lookaside.nOut;
   109    111         *pHighwater = db->lookaside.mxOut;
   110    112         if( resetFlag ){
   111    113           db->lookaside.mxOut = db->lookaside.nOut;
   112    114         }
................................................................................
   117    119       ** Return an approximation for the amount of memory currently used
   118    120       ** by all pagers associated with the given database connection.  The
   119    121       ** highwater mark is meaningless and is returned as zero.
   120    122       */
   121    123       case SQLITE_DBSTATUS_CACHE_USED: {
   122    124         int totalUsed = 0;
   123    125         int i;
          126  +      sqlite3BtreeEnterAll(db);
   124    127         for(i=0; i<db->nDb; i++){
   125    128           Btree *pBt = db->aDb[i].pBt;
   126    129           if( pBt ){
   127    130             Pager *pPager = sqlite3BtreePager(pBt);
   128    131             totalUsed += sqlite3PagerMemUsed(pPager);
   129    132           }
   130    133         }
          134  +      sqlite3BtreeLeaveAll(db);
   131    135         *pCurrent = totalUsed;
   132    136         *pHighwater = 0;
   133    137         break;
   134    138       }
   135    139       default: {
   136         -      return SQLITE_ERROR;
          140  +      rc = SQLITE_ERROR;
   137    141       }
   138    142     }
   139         -  return SQLITE_OK;
          143  +  sqlite3_mutex_leave(db->mutex);
          144  +  return rc;
   140    145   }