/ Check-in [3fbfa9a8]
Login

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

Overview
Comment:The sqlite3_snapshot_describe() interface useful for debugging snapshot logic.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | sqlite3_snapshot_describe
Files: files | file ages | folders
SHA3-256: 3fbfa9a8e88e354d113e7b30c948dbf8bf6d53d93b2fc69652a3ff58dbf4df57
User & Date: drh 2017-09-21 14:03:59
Context
2017-09-21
14:03
The sqlite3_snapshot_describe() interface useful for debugging snapshot logic. Leaf check-in: 3fbfa9a8 user: drh tags: sqlite3_snapshot_describe
01:04
Revert one performance improvement changes from check-in [3b3e32d4cd07] as it was causing a reference to an uninitialized value. check-in: f8b1c64d user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/sqlite.h.in.

8571
8572
8573
8574
8575
8576
8577

8578
8579
8580
8581
8582
8583
8584
....
8658
8659
8660
8661
8662
8663
8664

8665
8666
8667
8668
8669
8670
8671
....
8718
8719
8720
8721
8722
8723
8724
























8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
*/
typedef struct sqlite3_snapshot {
  unsigned char hidden[48];
} sqlite3_snapshot;

/*
** CAPI3REF: Record A Database Snapshot

** EXPERIMENTAL
**
** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
** new [sqlite3_snapshot] object that records the current state of
** schema S in database connection D.  ^On success, the
** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
................................................................................
  sqlite3 *db,
  const char *zSchema,
  sqlite3_snapshot *pSnapshot
);

/*
** CAPI3REF: Destroy a snapshot

** EXPERIMENTAL
**
** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
** The application must eventually free every [sqlite3_snapshot] object
** using this routine to avoid a memory leak.
**
** The [sqlite3_snapshot_free()] interface is only available when the
................................................................................
** transaction open on the database, or if the database is not a wal mode
** database.
**
** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
*/
SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);

























/*
** Undo the hack that converts floating point types to integer for
** builds on processors without floating point support.
*/
#ifdef SQLITE_OMIT_FLOATING_POINT
# undef double
#endif

#ifdef __cplusplus
}  /* End of the 'extern "C"' block */
#endif
#endif /* SQLITE3_H */







>







 







>







 







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












8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
....
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
....
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
*/
typedef struct sqlite3_snapshot {
  unsigned char hidden[48];
} sqlite3_snapshot;

/*
** CAPI3REF: Record A Database Snapshot
** CONSTRUCTOR: sqlite3_snapshot
** EXPERIMENTAL
**
** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
** new [sqlite3_snapshot] object that records the current state of
** schema S in database connection D.  ^On success, the
** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
................................................................................
  sqlite3 *db,
  const char *zSchema,
  sqlite3_snapshot *pSnapshot
);

/*
** CAPI3REF: Destroy a snapshot
** DESTRUCTOR: sqlite3_snapshot
** EXPERIMENTAL
**
** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
** The application must eventually free every [sqlite3_snapshot] object
** using this routine to avoid a memory leak.
**
** The [sqlite3_snapshot_free()] interface is only available when the
................................................................................
** transaction open on the database, or if the database is not a wal mode
** database.
**
** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
*/
SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);


/*
** CAPI3REF: Human-readable description of a snapshot
** EXPERIMENTAL
**
** The sqlite3_snapshot_describe(S,B,N) interface writes a human-readable
** description of snapshot S into the array of characters B of length N.
** As long as N is greater than 0, the string written into B is guaranteed
** to be zero terminated.
**
** This routine is intended for testing and debugging use only. The details
** of the text description written into B may vary from one release to the
** next.
**
** The [sqlite3_snapshot_describe()] interface is only available when the
** both the [SQLITE_ENABLE_SNAPSHOT] an [SQLITE_DEBUG] compile-time options
** are used.
*/
SQLITE_EXPERIMENTAL void sqlite3_snapshot_describe(
  sqlite3_snapshot*,   /* The snapshot to be described */
  char *pBuf,          /* Write the description into this buffer */
  int nBuf             /* Length of pBuf in bytes */
);

/*
** Undo the hack that converts floating point types to integer for
** builds on processors without floating point support.
*/
#ifdef SQLITE_OMIT_FLOATING_POINT
# undef double
#endif

#ifdef __cplusplus
}  /* End of the 'extern "C"' block */
#endif
#endif /* SQLITE3_H */

Changes to src/wal.c.

3510
3511
3512
3513
3514
3515
3516























3517
3518
3519
3520
3521
3522
3523
  ** is incremented each time the wal file is restarted.  */
  if( pHdr1->aSalt[0]<pHdr2->aSalt[0] ) return -1;
  if( pHdr1->aSalt[0]>pHdr2->aSalt[0] ) return +1;
  if( pHdr1->mxFrame<pHdr2->mxFrame ) return -1;
  if( pHdr1->mxFrame>pHdr2->mxFrame ) return +1;
  return 0;
}























#endif /* SQLITE_ENABLE_SNAPSHOT */

#ifdef SQLITE_ENABLE_ZIPVFS
/*
** If the argument is not NULL, it points to a Wal object that holds a
** read-lock. This function returns the database page-size if it is known,
** or zero if it is not (or if pWal is NULL).







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







3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
  ** is incremented each time the wal file is restarted.  */
  if( pHdr1->aSalt[0]<pHdr2->aSalt[0] ) return -1;
  if( pHdr1->aSalt[0]>pHdr2->aSalt[0] ) return +1;
  if( pHdr1->mxFrame<pHdr2->mxFrame ) return -1;
  if( pHdr1->mxFrame>pHdr2->mxFrame ) return +1;
  return 0;
}

/*
** Write a human-readable description of a snapshot into a text buffer.
*/
void sqlite3_snapshot_describe(sqlite3_snapshot *pSS, char *z, int n){
  WalIndexHdr *p = (WalIndexHdr*)pSS;
  sqlite3_snprintf(n,z,
     "mxFrame %u "
     "nPage %u "
     "szPage %u "
     "iChange %u "
     "aFrameCksum 0x%08x%08x "
     "aSalt 0x%08x%08x "
     "iVersion %u ",
     p->mxFrame,
     p->nPage,
     p->szPage,
     p->iChange,
     p->aFrameCksum[0], p->aFrameCksum[1],
     p->aSalt[0], p->aSalt[1],
     p->iVersion
  );
}
#endif /* SQLITE_ENABLE_SNAPSHOT */

#ifdef SQLITE_ENABLE_ZIPVFS
/*
** If the argument is not NULL, it points to a Wal object that holds a
** read-lock. This function returns the database page-size if it is known,
** or zero if it is not (or if pWal is NULL).