]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Experimental change to omit writing frame checksums to the wal file.
authordan <Dan Kennedy>
Wed, 20 Nov 2024 18:49:01 +0000 (18:49 +0000)
committerdan <Dan Kennedy>
Wed, 20 Nov 2024 18:49:01 +0000 (18:49 +0000)
FossilOrigin-Name: 4d3706727005397c3c9006b9ad9a2645b09533b02735ea68974c4f2df4c2e853

manifest
manifest.uuid
src/wal.c

index dd2ce21a04e4cb4ebdbef578b0bd6910342ad347..c2eac0ac10a3ac963803e86085a0a006b5275051 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Update\slogging\sversion\sto\s"v=11".\sThis\sshould\shave\sbeen\spart\sof\sthe\sprevious\scommit.
-D 2024-11-20T17:47:40.626
+C Experimental\schange\sto\somit\swriting\sframe\schecksums\sto\sthe\swal\sfile.
+D 2024-11-20T18:49:01.906
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -857,7 +857,7 @@ F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf8
 F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3
 F src/vtab.c 5fb499d20494b7eecaadb7584634af9afcb374cb0524912b475fcb1712458a1b
 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
-F src/wal.c b15990d5cc1fbc418170a5d14bc32c84b955c29ab189056ad60db31f87ea72b2
+F src/wal.c 2b1947a92536c1eeca743cd54b5fddb726040e413abd66197744b645f232fd85
 F src/wal.h 8c59ee7a835574396d7cbd04626d11fd849613e361a46e7e9519091ab03bdb29
 F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014
 F src/where.c c046dd58c3410f7b7528e1e6317cb876398557bad346d568ed8562321a7d002d
@@ -2249,8 +2249,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 2ba41da8c437e466c71f65d67a615293efb5a2d9da9b6e9cbb7b296221d4104a
-R 8660444da434974fa9ec38b189262163
+P e6663fab61cbcb6e7955ab726821831dd55cc210550d74327265210e5bb93c2a
+R 9a6fce3789fc705965d6b202838b94f6
 U dan
-Z 0bff1af09fe1a52da23cc13f5d3ade4b
+Z 6cbcba363e01fa0e7f18f1969c59edcc
 # Remove this line to create a well-formed Fossil manifest.
index 2c9dc1967ec4caa6db584ea2f9724b05609f12cc..903e279c1990457ea365f0b76f5e1e58629a6b1f 100644 (file)
@@ -1 +1 @@
-e6663fab61cbcb6e7955ab726821831dd55cc210550d74327265210e5bb93c2a
+4d3706727005397c3c9006b9ad9a2645b09533b02735ea68974c4f2df4c2e853
index 117781aed0cb7ed1e1120d432a7cadab5fbfa37c..9de87bf24aef38b7d6248a6c6631dbfada01ab95 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -461,6 +461,19 @@ int sqlite3WalTrace = 0;
 #define WAL_VERSION1 3007000      /* For "journal_mode=wal" */
 #define WAL_VERSION2 3021000      /* For "journal_mode=wal2" */
 
+#define SQLITE_ENABLE_WAL2NOCKSUM 1
+
+#ifdef SQLITE_ENABLE_WAL2NOCKSUM
+# undef WAL_VERSION2
+# define WAL_VERSION2 3048000     /* For "journal_mode=wal2" sans checksums */
+
+# define isNocksum(pWal) isWalMode2(pWal)
+#else
+# define isNocksum(pWal) 0
+#endif
+
+
+
 
 /*
 ** Index numbers for various locking bytes.   WAL_NREADER is the number
@@ -1245,12 +1258,15 @@ static void walEncodeFrame(
   if( pWal->iReCksum==0 ){
     memcpy(&aFrame[8], pWal->hdr.aSalt, 8);
 
-    nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);
-    walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);
-    walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);
+    if( isNocksum(pWal)==0 ){
+      nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);
+      walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);
+      walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);
+    }
 
     sqlite3Put4byte(&aFrame[16], aCksum[0]);
     sqlite3Put4byte(&aFrame[20], aCksum[1]);
+
   }else{
     memset(&aFrame[8], 0, 16);
   }
@@ -1292,14 +1308,16 @@ static int walDecodeFrame(
   ** and the frame-data matches the checksum in the last 8
   ** bytes of this frame-header.
   */
-  nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);
-  walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);
-  walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);
-  if( aCksum[0]!=sqlite3Get4byte(&aFrame[16])
-   || aCksum[1]!=sqlite3Get4byte(&aFrame[20])
-  ){
-    /* Checksum failed. */
-    return 0;
+  if( isNocksum(pWal)==0 ){
+    nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);
+    walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);
+    walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);
+    if( aCksum[0]!=sqlite3Get4byte(&aFrame[16])
+        || aCksum[1]!=sqlite3Get4byte(&aFrame[20])
+      ){
+      /* Checksum failed. */
+      return 0;
+    }
   }
 
   /* If we reach this point, the frame is valid.  Return the page number
@@ -5116,10 +5134,21 @@ static int walWriteOneFrame(
 
   pData = pPage->pData;
   walEncodeFrame(p->pWal, pPage->pgno, nTruncate, pData, aFrame);
-  rc = walWriteToLog(p, aFrame, sizeof(aFrame), iOffset);
-  if( rc ) return rc;
+
+  if( isNocksum(p->pWal)==0 ){
+    /* Write the header in normal mode */
+    rc = walWriteToLog(p, aFrame, sizeof(aFrame), iOffset);
+    if( rc ) return rc;
+  }
+
   /* Write the page data */
   rc = walWriteToLog(p, pData, p->szPage, iOffset+sizeof(aFrame));
+
+  if( isNocksum(p->pWal) ){
+    /* Write the header in no-checksum mode */
+    if( rc ) return rc;
+    rc = walWriteToLog(p, aFrame, sizeof(aFrame), iOffset);
+  }
   return rc;
 }