Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Comment edits and cleanup in wal.c. No functional code changes. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | wal-incr-ckpt |
Files: | files | file ages | folders |
SHA1: |
e8e666ab8273f5db5265f0773b39820f |
User & Date: | drh 2010-06-01 01:08:09.000 |
Context
2010-06-01
| ||
07:51 | Fixes to the test cases in wal2.test. (check-in: cd5fbcbce8 user: dan tags: wal-incr-ckpt) | |
01:08 | Comment edits and cleanup in wal.c. No functional code changes. (check-in: e8e666ab82 user: drh tags: wal-incr-ckpt) | |
00:28 | Attempt to get the filectrl.test script running. (check-in: e46a8f2b75 user: drh tags: wal-incr-ckpt) | |
Changes
Changes to src/wal.c.
︙ | ︙ | |||
591 592 593 594 595 596 597 | #define HASHTABLE_DATATYPE u16 #define HASHTABLE_HASH_1 383 /* Should be prime */ #define HASHTABLE_NSLOT (HASHTABLE_NPAGE*2) /* Must be a power of 2 */ #define HASHTABLE_NBYTE (sizeof(HASHTABLE_DATATYPE)*HASHTABLE_NSLOT) #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG) /* | | > | > > | 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | #define HASHTABLE_DATATYPE u16 #define HASHTABLE_HASH_1 383 /* Should be prime */ #define HASHTABLE_NSLOT (HASHTABLE_NPAGE*2) /* Must be a power of 2 */ #define HASHTABLE_NBYTE (sizeof(HASHTABLE_DATATYPE)*HASHTABLE_NSLOT) #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG) /* ** Names of locks. This routine is used to provide debugging output and is not ** a part of an ordinary build. */ static const char *walLockName(int lockIdx){ if( lockIdx==WAL_WRITE_LOCK ){ return "WRITE-LOCK"; }else if( lockIdx==WAL_CKPT_LOCK ){ return "CKPT-LOCK"; }else if( lockIdx==WAL_RECOVER_LOCK ){ return "RECOVER-LOCK"; }else{ static char zName[15]; sqlite3_snprintf(sizeof(zName), zName, "READ-LOCK[%d]", lockIdx-WAL_READ_LOCK(0)); return zName; } } #endif /*defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */ /* ** Set or release locks on the WAL. Locks are either shared or exclusive. ** A lock cannot be moved directly between shared and exclusive - it must go ** through the unlocked state first. ** ** In locking_mode=EXCLUSIVE, all of these routines become no-ops. */ static int walLockShared(Wal *pWal, int lockIdx){ int rc; if( pWal->exclusiveMode ) return SQLITE_OK; rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1, |
︙ | ︙ | |||
670 671 672 673 674 675 676 | (WALINDEX_LOCK_OFFSET+WALINDEX_LOCK_RESERVED)/sizeof(u32) + (((iFrame-1)/HASHTABLE_NPAGE) * HASHTABLE_NBYTE)/sizeof(u32) + (iFrame-1) ); } /* | | | | | | 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | (WALINDEX_LOCK_OFFSET+WALINDEX_LOCK_RESERVED)/sizeof(u32) + (((iFrame-1)/HASHTABLE_NPAGE) * HASHTABLE_NBYTE)/sizeof(u32) + (iFrame-1) ); } /* ** Return the minimum size of the shared-memory, in bytes, that is needed ** to support a wal-index containing frame iFrame. The value returned ** includes the wal-index header and the complete "block" containing iFrame, ** including the hash table segment that follows the block. */ static int walMappingSize(u32 iFrame){ const int nByte = (sizeof(u32)*HASHTABLE_NPAGE + HASHTABLE_NBYTE) ; return ( WALINDEX_LOCK_OFFSET + WALINDEX_LOCK_RESERVED + nByte * ((iFrame + HASHTABLE_NPAGE - 1)/HASHTABLE_NPAGE) ); |
︙ | ︙ | |||
739 740 741 742 743 744 745 | } assert( pWal->szWIndex>=enlargeTo || rc!=SQLITE_OK ); return rc; } /* ** Compute a hash on a page number. The resulting hash value must land | | > | 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | } assert( pWal->szWIndex>=enlargeTo || rc!=SQLITE_OK ); return rc; } /* ** Compute a hash on a page number. The resulting hash value must land ** between 0 and (HASHTABLE_NSLOT-1). The walHashNext() function advances ** the hash to the next value in the event of a collision. */ static int walHash(u32 iPage){ assert( iPage>0 ); assert( (HASHTABLE_NSLOT & (HASHTABLE_NSLOT-1))==0 ); return (iPage*HASHTABLE_HASH_1) & (HASHTABLE_NSLOT-1); } static int walNextHash(int iPriorHash){ |
︙ | ︙ | |||
802 803 804 805 806 807 808 | /* ** Remove entries from the hash table that point to WAL slots greater ** than pWal->hdr.mxFrame. ** ** This function is called whenever pWal->hdr.mxFrame is decreased due ** to a rollback or savepoint. ** | | | | > | 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | /* ** Remove entries from the hash table that point to WAL slots greater ** than pWal->hdr.mxFrame. ** ** This function is called whenever pWal->hdr.mxFrame is decreased due ** to a rollback or savepoint. ** ** At most only the hash table containing pWal->hdr.mxFrame needs to be ** updated. Any later hash tables will be automatically cleared when ** pWal->hdr.mxFrame advances to the point where those hash tables are ** actually needed. */ static void walCleanupHash(Wal *pWal){ volatile HASHTABLE_DATATYPE *aHash; /* Pointer to hash table to clear */ volatile u32 *aPgno; /* Unused return from walHashFind() */ u32 iZero; /* frame == (aHash[x]+iZero) */ int iLimit; /* Zero values greater than this */ |
︙ | ︙ | |||
1085 1086 1087 1088 1089 1090 1091 | if( pWal->isWIndexOpen ){ sqlite3OsShmClose(pWal->pDbFd, isDelete); pWal->isWIndexOpen = 0; } } /* | | | < < | | 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 | if( pWal->isWIndexOpen ){ sqlite3OsShmClose(pWal->pDbFd, isDelete); pWal->isWIndexOpen = 0; } } /* ** Open a connection to the WAL file associated with database zDbName. ** The database file must already be opened on connection pDbFd. ** ** A SHARED lock should be held on the database file when this function ** is called. The purpose of this SHARED lock is to prevent any other ** client from unlinking the WAL or wal-index file. If another process ** were to do this just after this client opened one of these files, the ** system would be badly broken. ** ** If the log file is successfully opened, SQLITE_OK is returned and ** *ppWal is set to point to a new WAL handle. If an error occurs, ** an SQLite error code is returned and *ppWal is left unmodified. */ |
︙ | ︙ |