Index: src/sqlite.h.in ================================================================== --- src/sqlite.h.in +++ src/sqlite.h.in @@ -8573,10 +8573,11 @@ 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 @@ -8660,10 +8661,11 @@ 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. @@ -8720,10 +8722,34 @@ ** ** 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 Index: src/wal.c ================================================================== --- src/wal.c +++ src/wal.c @@ -3512,10 +3512,33 @@ if( pHdr1->aSalt[0]>pHdr2->aSalt[0] ) return +1; if( pHdr1->mxFramemxFrame ) 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