/ Check-in [f1922da2]
Login

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

Overview
Comment:Formatting changes in btree.c. (CVS 2865)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f1922da2d20c5091678e47cc4f43a2a9d141a3b1
User & Date: drh 2006-01-06 01:42:58
Context
2006-01-06
03:29
Enable async testing. Modify the OS layer interface. Add the sqlite3_aux.h include file. Add tests for boolean value representation in file format 4. (CVS 2866) check-in: b8332aa8 user: drh tags: trunk
01:42
Formatting changes in btree.c. (CVS 2865) check-in: f1922da2 user: drh tags: trunk
00:36
Windows implementation of the thread-specific data interface. (CVS 2864) check-in: 3aa8befe user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/btree.c.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
...
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
...
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
...
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
....
6492
6493
6494
6495
6496
6497
6498
6499
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.279 2006/01/05 11:34:34 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
**
**     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
**     "Sorting And Searching", pages 473-480. Addison-Wesley
**     Publishing Company, Reading, Massachusetts.
................................................................................
  u16 idxParent;       /* Index in parent of this node */
  u16 nFree;           /* Number of free bytes on the page */
  u16 nCell;           /* Number of cells on this page, local and ovfl */
  struct _OvflCell {   /* Cells that will not fit on aData[] */
    u8 *pCell;          /* Pointers to the body of the overflow cell */
    u16 idx;            /* Insert this cell before idx-th non-overflow cell */
  } aOvfl[5];
  BtShared *pBt;        /* Pointer back to BTree structure */
  u8 *aData;            /* Pointer back to the start of the page */
  Pgno pgno;            /* Page number for this page */
  MemPage *pParent;     /* The parent of this page.  NULL for root */
};

/*
** The in-memory image of a disk page has the auxiliary information appended
** to the end.  EXTRA_SIZE is the number of bytes of space needed to hold
** that extra information.
*/
................................................................................
    ** table, then malloc space for and store the pCur->nKey bytes of key 
    ** data.
    */
    if( rc==SQLITE_OK && 0==pCur->pPage->intKey){
      void *pKey = sqliteMalloc(pCur->nKey);
      if( pKey ){
        rc = sqlite3BtreeKey(pCur, 0, pCur->nKey, pKey);
        if( pKey ){
          pCur->pKey = pKey;
        }else{
          sqliteFree(pKey);
        }
      }else{
        rc = SQLITE_NOMEM;
      }
................................................................................
  ** not create or respect table locks. The locking procedure for a 
  ** write-cursor does not change.
  */
  if( 
    !p->pSqlite || 
    0==(p->pSqlite->flags&SQLITE_ReadUncommitted) || 
    eLock==WRITE_LOCK ||
    iTab==1
  ){
    for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
      if( pIter->pBtree!=p && pIter->iTable==iTab && 
          (pIter->eLock!=eLock || eLock!=READ_LOCK) ){
        return SQLITE_BUSY;
      }
    }
................................................................................
  ** comment in function queryTableLock() for more info on handling 
  ** the ReadUncommitted flag.
  */
  if( 
    (p->pSqlite) && 
    (p->pSqlite->flags&SQLITE_ReadUncommitted) && 
    (eLock==READ_LOCK) &&
    iTable!=1
  ){
    return SQLITE_OK;
  }

  /* First search the list for an existing lock on this table. */
  for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
    if( pIter->iTable==iTable && pIter->pBtree==p ){
................................................................................
  if( pTsd->pPager ){
    return SQLITE_MISUSE;
  }
  pTsd->useSharedData = enable;
  return SQLITE_OK;
}
#endif








|







 







|
|
|
|







 







|







 







|







 







|







 







<
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
...
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
...
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
...
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
....
6492
6493
6494
6495
6496
6497
6498

** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.280 2006/01/06 01:42:58 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
**
**     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
**     "Sorting And Searching", pages 473-480. Addison-Wesley
**     Publishing Company, Reading, Massachusetts.
................................................................................
  u16 idxParent;       /* Index in parent of this node */
  u16 nFree;           /* Number of free bytes on the page */
  u16 nCell;           /* Number of cells on this page, local and ovfl */
  struct _OvflCell {   /* Cells that will not fit on aData[] */
    u8 *pCell;          /* Pointers to the body of the overflow cell */
    u16 idx;            /* Insert this cell before idx-th non-overflow cell */
  } aOvfl[5];
  BtShared *pBt;       /* Pointer back to BTree structure */
  u8 *aData;           /* Pointer back to the start of the page */
  Pgno pgno;           /* Page number for this page */
  MemPage *pParent;    /* The parent of this page.  NULL for root */
};

/*
** The in-memory image of a disk page has the auxiliary information appended
** to the end.  EXTRA_SIZE is the number of bytes of space needed to hold
** that extra information.
*/
................................................................................
    ** table, then malloc space for and store the pCur->nKey bytes of key 
    ** data.
    */
    if( rc==SQLITE_OK && 0==pCur->pPage->intKey){
      void *pKey = sqliteMalloc(pCur->nKey);
      if( pKey ){
        rc = sqlite3BtreeKey(pCur, 0, pCur->nKey, pKey);
        if( rc==SQLITE_OK ){
          pCur->pKey = pKey;
        }else{
          sqliteFree(pKey);
        }
      }else{
        rc = SQLITE_NOMEM;
      }
................................................................................
  ** not create or respect table locks. The locking procedure for a 
  ** write-cursor does not change.
  */
  if( 
    !p->pSqlite || 
    0==(p->pSqlite->flags&SQLITE_ReadUncommitted) || 
    eLock==WRITE_LOCK ||
    iTab==MASTER_ROOT
  ){
    for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
      if( pIter->pBtree!=p && pIter->iTable==iTab && 
          (pIter->eLock!=eLock || eLock!=READ_LOCK) ){
        return SQLITE_BUSY;
      }
    }
................................................................................
  ** comment in function queryTableLock() for more info on handling 
  ** the ReadUncommitted flag.
  */
  if( 
    (p->pSqlite) && 
    (p->pSqlite->flags&SQLITE_ReadUncommitted) && 
    (eLock==READ_LOCK) &&
    iTable!=MASTER_ROOT
  ){
    return SQLITE_OK;
  }

  /* First search the list for an existing lock on this table. */
  for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
    if( pIter->iTable==iTable && pIter->pBtree==p ){
................................................................................
  if( pTsd->pPager ){
    return SQLITE_MISUSE;
  }
  pTsd->useSharedData = enable;
  return SQLITE_OK;
}
#endif