/ Check-in [214d238a]
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:Add debugging functions btreePageOriginFile() and btreePageOriginOffset().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | btree-debug
Files: files | file ages | folders
SHA3-256: 214d238a4763adffa914232ffb4a94b27008f5429d2952d139490d6f9fd4114e
User & Date: dan 2017-05-27 18:05:32
Context
2017-05-27
18:05
Add debugging functions btreePageOriginFile() and btreePageOriginOffset(). Leaf check-in: 214d238a user: dan tags: btree-debug
2017-05-25
17:36
Merge all fixes from the 3.19.2 release. check-in: 12964240 user: drh tags: apple-osx
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/btree.c.

751
752
753
754
755
756
757




















758
759
760
761
762
763
764
*/
void sqlite3BtreeClearCursor(BtCursor *pCur){
  assert( cursorHoldsMutex(pCur) );
  sqlite3_free(pCur->pKey);
  pCur->pKey = 0;
  pCur->eState = CURSOR_INVALID;
}





















/*
** In this version of BtreeMoveto, pKey is a packed index record
** such as is generated by the OP_MakeRecord opcode.  Unpack the
** record and then call BtreeMovetoUnpacked() to do the work.
*/
static int btreeMoveto(







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
*/
void sqlite3BtreeClearCursor(BtCursor *pCur){
  assert( cursorHoldsMutex(pCur) );
  sqlite3_free(pCur->pKey);
  pCur->pKey = 0;
  pCur->eState = CURSOR_INVALID;
}

/*
** This is a debugging routine designed to reveal the file (database or
** wal file) that the page would be read from if it were reread at the 
** current time. It returns the name of the file.
*/
static const char *btreePageOriginFile(MemPage *pPage){
  return sqlite3PagerOrigin(pPage->pDbPage, 0);
}

/*
** This is a debugging routine designed to reveal the byte offset that
** the page would be read from (from either the database or wal file) if it
** were reread at the current time. The byte offset is returned.
*/
static i64 btreePageOriginOffset(MemPage *pPage){
  i64 iOffset = 0;
  sqlite3PagerOrigin(pPage->pDbPage, &iOffset);
  return iOffset;
}

/*
** In this version of BtreeMoveto, pKey is a packed index record
** such as is generated by the OP_MakeRecord opcode.  Unpack the
** record and then call BtreeMovetoUnpacked() to do the work.
*/
static int btreeMoveto(

Changes to src/pager.c.

7597
7598
7599
7600
7601
7602
7603
7604



























7605
** is empty, return 0.
*/
int sqlite3PagerWalFramesize(Pager *pPager){
  assert( pPager->eState>=PAGER_READER );
  return sqlite3WalFramesize(pPager->pWal);
}
#endif




























#endif /* SQLITE_OMIT_DISKIO */








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
** is empty, return 0.
*/
int sqlite3PagerWalFramesize(Pager *pPager){
  assert( pPager->eState>=PAGER_READER );
  return sqlite3WalFramesize(pPager->pWal);
}
#endif

/*
** Return the name of the file (wal file or database file) that page
** pPg would be read from if it were reread at this point. Also set
** output parameter (*piOffset) to the offset within said file.
*/
const char *sqlite3PagerOrigin(DbPage *pPg, i64 *piOffset){
  Pager *pPager = pPg->pPager;
  Pgno pgno = pPg->pgno;

  assert( pPager->eState>=PAGER_READER );
  assert( assert_pager_state(pPager) );
  assert( pPager->hasHeldSharedLock==1 );

  if( pagerUseWal(pPager) ){
    u32 iFrame = 0;
    int rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);
    if( rc!=SQLITE_OK ) return 0;
    if( iFrame ){
      if( piOffset ) *piOffset = (i64)(iFrame-1) * (pPager->pageSize + 24) + 32;
      return (const char*)pPager->zWal;
    }
  }

  if( piOffset ) *piOffset = (i64)pPager->pageSize * (i64)(pgno-1);
  return (const char*)pPager->zFilename;
}

#endif /* SQLITE_OMIT_DISKIO */

Changes to src/pager.h.

232
233
234
235
236
237
238
239


240
  void sqlite3PagerRefdump(Pager*);
  void disable_simulated_io_errors(void);
  void enable_simulated_io_errors(void);
#else
# define disable_simulated_io_errors()
# define enable_simulated_io_errors()
#endif



#endif /* SQLITE_PAGER_H */








>
>

232
233
234
235
236
237
238
239
240
241
242
  void sqlite3PagerRefdump(Pager*);
  void disable_simulated_io_errors(void);
  void enable_simulated_io_errors(void);
#else
# define disable_simulated_io_errors()
# define enable_simulated_io_errors()
#endif

const char *sqlite3PagerOrigin(DbPage *pPg, i64 *piOffset);

#endif /* SQLITE_PAGER_H */