]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Refactoring some variable names in wal.c.
authordrh <drh@noemail.net>
Wed, 19 May 2010 17:49:50 +0000 (17:49 +0000)
committerdrh <drh@noemail.net>
Wed, 19 May 2010 17:49:50 +0000 (17:49 +0000)
FossilOrigin-Name: 1d201ff51f7c5ecdf71a91ed25204b7130894282

manifest
manifest.uuid
src/wal.c

index 762dea9f6b90c544046ea4b6de421581d2c07bb7..c964b500ff2b4aee6ec40adba08bdbece3a5e292 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,8 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-C Add\sa\slarge\scomment\sto\swal.c\sdescribing\sthe\sWAL\sand\swal-index\sfile\sformats.
-D 2010-05-19T01:53:54
+C Refactoring\ssome\svariable\snames\sin\swal.c.
+D 2010-05-19T17:49:50
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -227,7 +227,7 @@ F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e
 F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1
 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
 F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda
-F src/wal.c 59463e08693a9fddf516197e0053ebcd58f74c66
+F src/wal.c 105bad789a23a495fe134f5ef9dac6d8c06f971d
 F src/wal.h 434f76f51225bb614e43ccb6bd2341541ba6a06e
 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
 F src/where.c 75fee9e255b62f773fcadd1d1f25b6f63ac7a356
@@ -816,14 +816,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P ada9a8c7b69c5dd2d66bbf62b61181651e6d2142
-R 18fadfda9fbc33cddb219c42d944f3cc
+P a71a22b52f4570e934063553a81b39268127dc44
+R 1c999fd53b1df4ca8173c8fb4d6b6989
 U drh
-Z da5a3c11958bee0d8152271c179253e5
+Z cc4a12a1a16f8ebec7597d63ade72388
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (GNU/Linux)
 
-iD8DBQFL80S1oxKgR168RlERAoLoAJoDDynU57b4fyCkRG5FEJ7stDA9hQCcDNGs
-5upq5UH5aI43a8UF2LKqxus=
-=50kN
+iD8DBQFL9CTBoxKgR168RlERAlCKAJ4zOxPBD9LXWpD6J1dW7wmEg9tn5QCfTw1j
+bOeNi5aQREq9/zvmCMu2nsA=
+=EdxO
 -----END PGP SIGNATURE-----
index a5efb9540101a4b63ab55dbc9fb85ad9ae23722b..2826d32ea4e41eb882f91d045c2b925ad18cf277 100644 (file)
@@ -1 +1 @@
-a71a22b52f4570e934063553a81b39268127dc44
\ No newline at end of file
+1d201ff51f7c5ecdf71a91ed25204b7130894282
\ No newline at end of file
index 3de43ddc6ed02277929ae6aa2638a42be681fc87..eb5e2e4de90e2d967966d46abf952a3fdb8e6de1 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -187,12 +187,12 @@ typedef struct WalIterator WalIterator;
 ** is currently empty.
 */
 struct WalIndexHdr {
-  u32 iChange;                    /* Counter incremented each transaction */
-  u32 pgsz;                       /* Database page size in bytes */
-  u32 mxFrame;                    /* Index of last valid frame in the WAL */
-  u32 nPage;                      /* Size of database in pages */
-  u32 iCheck1;                    /* Checkpoint value 1 */
-  u32 iCheck2;                    /* Checkpoint value 2 */
+  u32 iChange;          /* Counter incremented each transaction */
+  u32 szPage;           /* Database page size in bytes */
+  u32 mxFrame;          /* Index of last valid frame in the WAL */
+  u32 nPage;            /* Size of database in pages */
+  u32 iCheck1;          /* Checksum value 1 */
+  u32 iCheck2;          /* Checksum value 2 */
 };
 
 /* Size of serialized WalIndexHdr object. */
@@ -214,11 +214,11 @@ struct WalIndexHdr {
 
 /*
 ** Return the offset of frame iFrame in the write-ahead log file, 
-** assuming a database page size of pgsz bytes. The offset returned
+** assuming a database page size of szPage bytes. The offset returned
 ** is to the start of the write-ahead log frame-header.
 */
-#define walFrameOffset(iFrame, pgsz) (                               \
-  WAL_HDRSIZE + ((iFrame)-1)*((pgsz)+WAL_FRAME_HDRSIZE)        \
+#define walFrameOffset(iFrame, szPage) (                               \
+  WAL_HDRSIZE + ((iFrame)-1)*((szPage)+WAL_FRAME_HDRSIZE)        \
 )
 
 /*
@@ -649,7 +649,7 @@ static int walIndexRecover(Wal *pWal){
     u8 *aData;                    /* Pointer to data part of aFrame buffer */
     int iFrame;                   /* Index of last frame read */
     i64 iOffset;                  /* Next offset to read from log file */
-    int nPgsz;                    /* Page size according to the log */
+    int szPage;                   /* Page size according to the log */
     u32 aCksum[2];                /* Running checksum */
 
     /* Read in the first frame header in the file (to determine the 
@@ -661,17 +661,17 @@ static int walIndexRecover(Wal *pWal){
     }
 
     /* If the database page size is not a power of two, or is greater than
-    ** SQLITE_MAX_PAGE_SIZE, conclude that the log file contains no valid data.
+    ** SQLITE_MAX_PAGE_SIZE, conclude that the WAL file contains no valid data.
     */
-    nPgsz = sqlite3Get4byte(&aBuf[0]);
-    if( nPgsz&(nPgsz-1) || nPgsz>SQLITE_MAX_PAGE_SIZE || nPgsz<512 ){
+    szPage = sqlite3Get4byte(&aBuf[0]);
+    if( szPage&(szPage-1) || szPage>SQLITE_MAX_PAGE_SIZE || szPage<512 ){
       goto finished;
     }
     aCksum[0] = sqlite3Get4byte(&aBuf[4]);
     aCksum[1] = sqlite3Get4byte(&aBuf[8]);
 
     /* Malloc a buffer to read frames into. */
-    nFrame = nPgsz + WAL_FRAME_HDRSIZE;
+    nFrame = szPage + WAL_FRAME_HDRSIZE;
     aFrame = (u8 *)sqlite3_malloc(nFrame);
     if( !aFrame ){
       return SQLITE_NOMEM;
@@ -688,7 +688,7 @@ static int walIndexRecover(Wal *pWal){
       /* Read and decode the next log frame. */
       rc = sqlite3OsRead(pWal->pWalFd, aFrame, nFrame, iOffset);
       if( rc!=SQLITE_OK ) break;
-      isValid = walDecodeFrame(aCksum, &pgno, &nTruncate, nPgsz, aData, aFrame);
+      isValid = walDecodeFrame(aCksum, &pgno, &nTruncate, szPage, aData, aFrame);
       if( !isValid ) break;
       rc = walIndexAppend(pWal, ++iFrame, pgno);
       if( rc!=SQLITE_OK ) break;
@@ -699,7 +699,7 @@ static int walIndexRecover(Wal *pWal){
         hdr.iCheck2 = aCksum[1];
         hdr.mxFrame = iFrame;
         hdr.nPage = nTruncate;
-        hdr.pgsz = nPgsz;
+        hdr.szPage = szPage;
       }
     }
 
@@ -985,7 +985,7 @@ static int walCheckpoint(
   u8 *zBuf                        /* Temporary buffer to use */
 ){
   int rc;                         /* Return code */
-  int pgsz = pWal->hdr.pgsz;      /* Database page-size */
+  int szPage = pWal->hdr.szPage;  /* Database page-size */
   WalIterator *pIter = 0;         /* Wal iterator context */
   u32 iDbpage = 0;                /* Next database page to write */
   u32 iFrame = 0;                 /* Wal frame containing data for iDbpage */
@@ -996,7 +996,7 @@ static int walCheckpoint(
     goto out;
   }
 
-  if( pWal->hdr.pgsz!=nBuf ){
+  if( pWal->hdr.szPage!=nBuf ){
     rc = SQLITE_CORRUPT_BKPT;
     goto out;
   }
@@ -1009,16 +1009,16 @@ static int walCheckpoint(
 
   /* Iterate through the contents of the log, copying data to the db file. */
   while( 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
-    rc = sqlite3OsRead(pWal->pWalFd, zBuf, pgsz
-        walFrameOffset(iFrame, pgsz) + WAL_FRAME_HDRSIZE
+    rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage
+        walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE
     );
     if( rc!=SQLITE_OK ) goto out;
-    rc = sqlite3OsWrite(pWal->pDbFd, zBuf, pgsz, (iDbpage-1)*pgsz);
+    rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, (iDbpage-1)*szPage);
     if( rc!=SQLITE_OK ) goto out;
   }
 
   /* Truncate the database file */
-  rc = sqlite3OsTruncate(pWal->pDbFd, ((i64)pWal->hdr.nPage*(i64)pgsz));
+  rc = sqlite3OsTruncate(pWal->pDbFd, ((i64)pWal->hdr.nPage*(i64)szPage));
   if( rc!=SQLITE_OK ) goto out;
 
   /* Sync the database file. If successful, update the wal-index. */
@@ -1308,7 +1308,7 @@ int sqlite3WalRead(
   **
   ** This code may run concurrently to the code in walIndexAppend()
   ** that adds entries to the wal-index (and possibly to this hash 
-  ** table). This means the non-zero value just read from the hash 
+  ** table). This means the value just read from the hash 
   ** slot (aHash[iKey]) may have been added before or after the 
   ** current read transaction was opened. Values added after the
   ** read transaction was opened may have been written incorrectly -
@@ -1331,17 +1331,17 @@ int sqlite3WalRead(
   **     This filters out a dangerous class of garbage data. The 
   **     garbage hash slot may refer to a frame with the correct page 
   **     number, but not the most recent version of the frame. For
-  **     example, if at the start of the read-transaction the log 
+  **     example, if at the start of the read-transaction the WAL
   **     contains three copies of the desired page in frames 2, 3 and 4,
   **     the hash table may contain the following:
   **
-  **       { ..., 2, 3, 4, 0, 0, ..... }
+  **       { ..., 2, 3, 4, 99, 99, ..... }
   **
   **     The correct answer is to read data from frame 4. But a 
   **     dirty-read may potentially cause the hash-table to appear as 
   **     follows to the reader:
   **
-  **       { ..., 2, 3, 4, 3, 0, ..... }
+  **       { ..., 2, 3, 4, 3, 99, ..... }
   **
   **     Without this part of the if(...) clause, the reader might
   **     incorrectly read data from frame 3 instead of 4. This would be
@@ -1391,7 +1391,7 @@ int sqlite3WalRead(
   */
   walIndexUnmap(pWal);
   if( iRead ){
-    i64 iOffset = walFrameOffset(iRead, pWal->hdr.pgsz) + WAL_FRAME_HDRSIZE;
+    i64 iOffset = walFrameOffset(iRead, pWal->hdr.szPage) + WAL_FRAME_HDRSIZE;
     *pInWal = 1;
     return sqlite3OsRead(pWal->pWalFd, pOut, nOut, iOffset);
   }
@@ -1491,7 +1491,7 @@ int sqlite3WalSavepointUndo(Wal *pWal, u32 iFrame){
 
   pWal->hdr.mxFrame = iFrame;
   if( iFrame>0 ){
-    i64 iOffset = walFrameOffset(iFrame, pWal->hdr.pgsz) + sizeof(u32)*2;
+    i64 iOffset = walFrameOffset(iFrame, pWal->hdr.szPage) + sizeof(u32)*2;
     rc = sqlite3OsRead(pWal->pWalFd, aCksum, sizeof(aCksum), iOffset);
     pWal->hdr.iCheck1 = sqlite3Get4byte(&aCksum[0]);
     pWal->hdr.iCheck2 = sqlite3Get4byte(&aCksum[4]);
@@ -1506,7 +1506,7 @@ int sqlite3WalSavepointUndo(Wal *pWal, u32 iFrame){
 */
 int sqlite3WalFrames(
   Wal *pWal,                      /* Wal handle to write to */
-  int nPgsz,                      /* Database page-size in bytes */
+  int szPage,                     /* Database page-size in bytes */
   PgHdr *pList,                   /* List of dirty pages to write */
   Pgno nTruncate,                 /* Database size after this commit */
   int isCommit,                   /* True if this is a commit */
@@ -1532,7 +1532,7 @@ int sqlite3WalFrames(
   assert( WAL_FRAME_HDRSIZE>=WAL_HDRSIZE );
   iFrame = pWal->hdr.mxFrame;
   if( iFrame==0 ){
-    sqlite3Put4byte(aFrame, nPgsz);
+    sqlite3Put4byte(aFrame, szPage);
     sqlite3_randomness(8, &aFrame[4]);
     pWal->hdr.iCheck1 = sqlite3Get4byte(&aFrame[4]);
     pWal->hdr.iCheck2 = sqlite3Get4byte(&aFrame[8]);
@@ -1550,18 +1550,18 @@ int sqlite3WalFrames(
     u32 nDbsize;                  /* Db-size field for frame header */
     i64 iOffset;                  /* Write offset in log file */
 
-    iOffset = walFrameOffset(++iFrame, nPgsz);
+    iOffset = walFrameOffset(++iFrame, szPage);
     
     /* Populate and write the frame header */
     nDbsize = (isCommit && p->pDirty==0) ? nTruncate : 0;
-    walEncodeFrame(aCksum, p->pgno, nDbsize, nPgsz, p->pData, aFrame);
+    walEncodeFrame(aCksum, p->pgno, nDbsize, szPage, p->pData, aFrame);
     rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset);
     if( rc!=SQLITE_OK ){
       return rc;
     }
 
     /* Write the page data */
-    rc = sqlite3OsWrite(pWal->pWalFd, p->pData, nPgsz, iOffset+sizeof(aFrame));
+    rc = sqlite3OsWrite(pWal->pWalFd, p->pData, szPage, iOffset+sizeof(aFrame));
     if( rc!=SQLITE_OK ){
       return rc;
     }
@@ -1571,26 +1571,26 @@ int sqlite3WalFrames(
   /* Sync the log file if the 'isSync' flag was specified. */
   if( sync_flags ){
     i64 iSegment = sqlite3OsSectorSize(pWal->pWalFd);
-    i64 iOffset = walFrameOffset(iFrame+1, nPgsz);
+    i64 iOffset = walFrameOffset(iFrame+1, szPage);
 
     assert( isCommit );
     assert( iSegment>0 );
 
     iSegment = (((iOffset+iSegment-1)/iSegment) * iSegment);
     while( iOffset<iSegment ){
-      walEncodeFrame(aCksum,pLast->pgno,nTruncate,nPgsz,pLast->pData,aFrame);
+      walEncodeFrame(aCksum,pLast->pgno,nTruncate,szPage,pLast->pData,aFrame);
       rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset);
       if( rc!=SQLITE_OK ){
         return rc;
       }
 
       iOffset += WAL_FRAME_HDRSIZE;
-      rc = sqlite3OsWrite(pWal->pWalFd, pLast->pData, nPgsz, iOffset); 
+      rc = sqlite3OsWrite(pWal->pWalFd, pLast->pData, szPage, iOffset); 
       if( rc!=SQLITE_OK ){
         return rc;
       }
       nLast++;
-      iOffset += nPgsz;
+      iOffset += szPage;
     }
 
     rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
@@ -1615,7 +1615,7 @@ int sqlite3WalFrames(
 
   if( rc==SQLITE_OK ){
     /* Update the private copy of the header. */
-    pWal->hdr.pgsz = nPgsz;
+    pWal->hdr.szPage = szPage;
     pWal->hdr.mxFrame = iFrame;
     if( isCommit ){
       pWal->hdr.iChange++;