/ Check-in [5ba880dd]
Login

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

Overview
Comment:Simplifications and comment enhancements on btree.c. (CVS 6925)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5ba880dde8a219543ced6f792c7f9ecdcd8c1cbb
User & Date: drh 2009-07-23 01:44:00
Context
2009-07-24
12:35
Simplifications and comment improvements in pager.c. (CVS 6926) check-in: 2d2f42ca user: drh tags: trunk
2009-07-23
01:44
Simplifications and comment enhancements on btree.c. (CVS 6925) check-in: 5ba880dd user: drh tags: trunk
2009-07-22
18:24
Modify mksqlite3c.tcl so that it inserts SQLITE_API macros into sqlite3.h. Ticket #3983. (CVS 6924) check-in: 803ec79f user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.700 2009/07/22 18:07:41 drh Exp $
           12  +** $Id: btree.c,v 1.701 2009/07/23 01:44:00 drh Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** See the header comment on "btreeInt.h" for additional information.
    16     16   ** Including a description of file format and an overview of operation.
    17     17   */
    18     18   #include "btreeInt.h"
    19     19   
................................................................................
  2311   2311       assert( pBt->pPage1->aData );
  2312   2312       releasePage(pBt->pPage1);
  2313   2313       pBt->pPage1 = 0;
  2314   2314     }
  2315   2315   }
  2316   2316   
  2317   2317   /*
  2318         -** Create a new database by initializing the first page of the
  2319         -** file.
         2318  +** If pBt points to an empty file then convert that empty file
         2319  +** into a new empty database by initializing the first page of
         2320  +** the database.
  2320   2321   */
  2321   2322   static int newDatabase(BtShared *pBt){
  2322   2323     MemPage *pP1;
  2323   2324     unsigned char *data;
  2324   2325     int rc;
  2325   2326     int nPage;
  2326   2327   
  2327   2328     assert( sqlite3_mutex_held(pBt->mutex) );
         2329  +  /* The database size has already been measured and cached, so failure
         2330  +  ** is impossible here.  If the original size measurement failed, then
         2331  +  ** processing aborts before entering this routine. */
  2328   2332     rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
  2329         -  if( rc!=SQLITE_OK || nPage>0 ){
         2333  +  if( NEVER(rc!=SQLITE_OK) || nPage>0 ){
  2330   2334       return rc;
  2331   2335     }
  2332   2336     pP1 = pBt->pPage1;
  2333   2337     assert( pP1!=0 );
  2334   2338     data = pP1->aData;
  2335   2339     rc = sqlite3PagerWrite(pP1->pDbPage);
  2336   2340     if( rc ) return rc;