From: drh Date: Thu, 21 Sep 2017 14:03:59 +0000 (+0000) Subject: The sqlite3_snapshot_describe() interface useful for debugging snapshot logic. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=08104aaae735d66a5133b9a40545bf836be6a942;p=thirdparty%2Fsqlite.git The sqlite3_snapshot_describe() interface useful for debugging snapshot logic. FossilOrigin-Name: 3fbfa9a8e88e354d113e7b30c948dbf8bf6d53d93b2fc69652a3ff58dbf4df57 --- diff --git a/manifest b/manifest index 3992ec18ab..3dc11249b6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revert\sone\sperformance\simprovement\schanges\sfrom\scheck-in\s[3b3e32d4cd07]\sas\nit\swas\scausing\sa\sreference\sto\san\suninitialized\svalue. -D 2017-09-21T01:04:30.271 +C The\ssqlite3_snapshot_describe()\sinterface\suseful\sfor\sdebugging\ssnapshot\slogic. +D 2017-09-21T14:03:59.304 F Makefile.in 4bc36d913c2e3e2d326d588d72f618ac9788b2fd4b7efda61102611a6495c3ff F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6033b51b6aea702ea059f6ab2d47b1d3cef648695f787247dd4fb395fe60673f @@ -461,7 +461,7 @@ F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 9fa0db382f43217e207a145b8c6cec26e85cd1a42a8428ee8b3df5870dfea0f4 F src/shell.c c1206a23d9239f8f51751d3be9b8c3b02fa4103546bea1add7f864d84a8276ab F src/shell.c.in bb9720a8c5c98d3984b16ab7540e7142bcae959666ecf248bfc523a1d44220ee -F src/sqlite.h.in ab4f8a29d1580dfaeb6891fa1b83cff8229ba0daa56994707ceaca71495d9ab7 +F src/sqlite.h.in 41d873beefa82473dbbcffc9af29a87d7ce9be918a58d97312f1ce2bc3062abb F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h a1fd3aa82f967da436164e0728a7d6841651fd0c6e27b9044e0eb9f6c8462e47 F src/sqliteInt.h 12aa1f626b3209ffa6a50d9d1e6b4235abd33273a0fcbfeedb66f573a68932b9 @@ -537,7 +537,7 @@ F src/vdbesort.c 731a09e5cb9e96b70c394c1b7cf3860fbe84acca7682e178615eb941a3a0ef2 F src/vdbetrace.c 48e11ebe040c6b41d146abed2602e3d00d621d7ebe4eb29b0a0f1617fd3c2f6c F src/vtab.c f1d5c23132fb0247af3e86146404112283ddedb6c518de0d4edc91cfb36970ef F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 -F src/wal.c 839db09792fead5052bb35e533fa485e134913d547d05b5f42e537b73e63f07a +F src/wal.c 0f3fc4059289142998100d38f98e4b89ee23a9fb450438d4c27b7c1721bd6452 F src/wal.h 8de5d2d3de0956d6f6cb48c83a4012d5f227b8fe940f3a349a4b7e85ebcb492a F src/walker.c 3ccfa8637f95355bff61144e01a615b8ef26f79c312880848da73f03367da1e6 F src/where.c 21eea981920a13fd3c0ac3d6c128d0a34b22cbec064e4f0603375fe1ffe26ca6 @@ -1655,7 +1655,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P adc12c83dda8ba93ca220bbff649f763058b9440968ae463621f0cb7de8889cf -R 74e9a42e62567d447ce10652f9c93fed +P f8b1c64d3eeb8413ca149f34cc00f9154a5446d06ad33bbffa69118e6110f81d +R 5b5eb921c8efc28de7d196a6a9e85cac +T *branch * sqlite3_snapshot_describe +T *sym-sqlite3_snapshot_describe * +T -sym-trunk * U drh -Z 07fc711a459108ff2c2431795ab36ea3 +Z 6a46e389b1ff02d5f104988f972409a5 diff --git a/manifest.uuid b/manifest.uuid index 4aaeed6a9d..ba3f44d8be 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f8b1c64d3eeb8413ca149f34cc00f9154a5446d06ad33bbffa69118e6110f81d \ No newline at end of file +3fbfa9a8e88e354d113e7b30c948dbf8bf6d53d93b2fc69652a3ff58dbf4df57 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9ff366304f..1c9aa0e940 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -8575,6 +8575,7 @@ typedef struct sqlite3_snapshot { /* ** CAPI3REF: Record A Database Snapshot +** CONSTRUCTOR: sqlite3_snapshot ** EXPERIMENTAL ** ** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a @@ -8662,6 +8663,7 @@ SQLITE_EXPERIMENTAL int sqlite3_snapshot_open( /* ** CAPI3REF: Destroy a snapshot +** DESTRUCTOR: sqlite3_snapshot ** EXPERIMENTAL ** ** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P. @@ -8722,6 +8724,30 @@ SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp( */ 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. diff --git a/src/wal.c b/src/wal.c index 9930b84421..f49ee655fa 100644 --- a/src/wal.c +++ b/src/wal.c @@ -3514,6 +3514,29 @@ int sqlite3_snapshot_cmp(sqlite3_snapshot *p1, sqlite3_snapshot *p2){ 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