Modify some comments in pager.c.
FossilOrigin-Name: 5662da6d4f648e5d07d7cbea6bbd92fa684c02c9
This commit is contained in:
parent
5a26383ab7
commit
de5fd22f3d
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Merge\slatest\strunk\schanges\swith\sexperimental\sbranch.
|
||||
D 2010-08-09T16:52:12
|
||||
C Modify\ssome\scomments\sin\spager.c.
|
||||
D 2010-08-09T19:17:29
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -156,7 +156,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
|
||||
F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e
|
||||
F src/os_unix.c ae5ca8a6031380708f3fec7be325233d49944914
|
||||
F src/os_win.c 51cb62f76262d961ea4249489383d714501315a7
|
||||
F src/pager.c ad850e0b0547ff3781676c311c276123b5e07902
|
||||
F src/pager.c df8e60594f095c3bd6b74c7c8a2585655b055536
|
||||
F src/pager.h 80726162dc3942f59ab27b738fb667b9ba0a89d5
|
||||
F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
|
||||
F src/pcache.c 1e9aa2dbc0845b52e1b51cc39753b6d1e041cb07
|
||||
@ -843,7 +843,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P f229487cccc7514b2663e8e6e04798702c9cfb10 9cebaf2dca6dc35e489537fe7c55474e1029a98e
|
||||
R a8ec38097bd382b8337fdc3c678431ed
|
||||
P aecbd890327dc676d6c2366b07f3d2e636a4983e
|
||||
R f5e40f8996c812e7f2b0312f4a214200
|
||||
U dan
|
||||
Z 5adcbb92ea687904b54262b46cb56097
|
||||
Z 6addb6181e8f60b5f4d1be2660768d4f
|
||||
|
@ -1 +1 @@
|
||||
aecbd890327dc676d6c2366b07f3d2e636a4983e
|
||||
5662da6d4f648e5d07d7cbea6bbd92fa684c02c9
|
81
src/pager.c
81
src/pager.c
@ -241,6 +241,11 @@ int sqlite3PagerTrace=1; /* True to enable tracing */
|
||||
**
|
||||
** WRITER_DBMOD:
|
||||
**
|
||||
** The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state
|
||||
** when it modifies the contents of the database file. WAL connections
|
||||
** never enter this state (since they do not modify the database file,
|
||||
** just the log file).
|
||||
**
|
||||
** * A write transaction is active.
|
||||
** * An EXCLUSIVE or greater lock is held on the database file.
|
||||
** * The journal file is open and the first header has been written
|
||||
@ -250,6 +255,15 @@ int sqlite3PagerTrace=1; /* True to enable tracing */
|
||||
**
|
||||
** WRITER_FINISHED:
|
||||
**
|
||||
** It is not possible for a WAL connection to enter this state.
|
||||
**
|
||||
** A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD
|
||||
** state after the entire transaction has been successfully written into the
|
||||
** database file. In this state the transaction may be committed simply
|
||||
** by finalizing the journal file. Once in WRITER_FINISHED state, it is
|
||||
** not possible to modify the database further. At this point, the upper
|
||||
** layer must either commit or rollback the transaction.
|
||||
**
|
||||
** * A write transaction is active.
|
||||
** * An EXCLUSIVE or greater lock is held on the database file.
|
||||
** * All writing and syncing of journal and database data has finished.
|
||||
@ -1642,17 +1656,29 @@ static int addToSavepointBitvecs(Pager *pPager, Pgno pgno){
|
||||
}
|
||||
|
||||
/*
|
||||
** Unlock the database file. This function is a no-op if the pager
|
||||
** is in exclusive mode.
|
||||
** This function is a no-op if the pager is in exclusive mode and not
|
||||
** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN
|
||||
** state.
|
||||
**
|
||||
** If the pager is currently in error state, discard the contents of
|
||||
** the cache and reset the Pager structure internal state. If there is
|
||||
** an open journal-file, then the next time a shared-lock is obtained
|
||||
** on the pager file (by this or any other process), it will be
|
||||
** treated as a hot-journal and rolled back.
|
||||
** If the pager is not in exclusive-access mode, the database file is
|
||||
** completely unlocked. If the file is unlocked and the file-system does
|
||||
** not exhibit the UNDELETABLE_WHEN_OPEN property, the journal file is
|
||||
** closed (if it is open).
|
||||
**
|
||||
** If the pager is in ERROR state when this function is called, the
|
||||
** contents of the pager cache are discarded before switching back to
|
||||
** the OPEN state. Regardless of whether the pager is in exclusive-mode
|
||||
** or not, any journal file left in the file-system will be treated
|
||||
** as a hot-journal and rolled back the next time a read-transaction
|
||||
** is opened (by this or by any other connection).
|
||||
*/
|
||||
static void pager_unlock(Pager *pPager){
|
||||
|
||||
assert( pPager->eState==PAGER_READER
|
||||
|| pPager->eState==PAGER_OPEN
|
||||
|| pPager->eState==PAGER_ERROR
|
||||
);
|
||||
|
||||
sqlite3BitvecDestroy(pPager->pInJournal);
|
||||
pPager->pInJournal = 0;
|
||||
releaseAllSavepoints(pPager);
|
||||
@ -1719,18 +1745,20 @@ static void pager_unlock(Pager *pPager){
|
||||
}
|
||||
|
||||
/*
|
||||
** This function should be called when an IOERR, CORRUPT or FULL error
|
||||
** may have occurred. The first argument is a pointer to the pager
|
||||
** structure, the second the error-code about to be returned by a pager
|
||||
** API function. The value returned is a copy of the second argument
|
||||
** to this function.
|
||||
** This function is called whenever an IOERR or FULL error that requires
|
||||
** the pager to transition into the ERROR state may ahve occurred.
|
||||
** The first argument is a pointer to the pager structure, the second
|
||||
** the error-code about to be returned by a pager API function. The
|
||||
** value returned is a copy of the second argument to this function.
|
||||
**
|
||||
** If the second argument is SQLITE_IOERR, SQLITE_CORRUPT, or SQLITE_FULL
|
||||
** the error becomes persistent. Until the persistent error is cleared,
|
||||
** subsequent API calls on this Pager will immediately return the same
|
||||
** error code.
|
||||
** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the
|
||||
** IOERR sub-codes, the pager enters the ERROR state and the error code
|
||||
** is stored in Pager.errCode. While the pager remains in the ERROR state,
|
||||
** all major API calls on the Pager will immediately return Pager.errCode.
|
||||
** Except, if the error-code is SQLITE_FULL, calls to PagerLookup() and
|
||||
** PagerAcquire are handled as if the pager were in PAGER_READER state.
|
||||
**
|
||||
** A persistent error indicates that the contents of the pager-cache
|
||||
** The ERROR state indicates that the contents of the pager-cache
|
||||
** cannot be trusted. This state can be cleared by completely discarding
|
||||
** the contents of the pager-cache. If a transaction was active when
|
||||
** the persistent error occurred, then the rollback journal may need
|
||||
@ -2087,7 +2115,7 @@ static int pager_playback_one_page(
|
||||
pagerReportSize(pPager);
|
||||
}
|
||||
|
||||
/* If the pager is in RESERVED state, then there must be a copy of this
|
||||
/* If the pager is in CACHEMOD state, then there must be a copy of this
|
||||
** page in the pager cache. In this case just update the pager cache,
|
||||
** not the database file. The page is left marked dirty in this case.
|
||||
**
|
||||
@ -2098,8 +2126,11 @@ static int pager_playback_one_page(
|
||||
** either. So the condition described in the above paragraph is not
|
||||
** assert()able.
|
||||
**
|
||||
** If in EXCLUSIVE state, then we update the pager cache if it exists
|
||||
** and the main file. The page is then marked not dirty.
|
||||
** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the
|
||||
** pager cache if it exists and the main file. The page is then marked
|
||||
** not dirty. Since this code is only executed in PAGER_OPEN state for
|
||||
** a hot-journal rollback, it is guaranteed that the page-cache is empty
|
||||
** if the pager is in OPEN state.
|
||||
**
|
||||
** Ticket #1171: The statement journal might contain page content that is
|
||||
** different from the page content at the start of the transaction.
|
||||
@ -2125,6 +2156,7 @@ static int pager_playback_one_page(
|
||||
pPg = pager_lookup(pPager, pgno);
|
||||
}
|
||||
assert( pPg || !MEMDB );
|
||||
assert( pPager->eState!=PAGER_OPEN || pPg==0 );
|
||||
PAGERTRACE(("PLAYBACK %d page %d hash(%08x) %s\n",
|
||||
PAGERID(pPager), pgno, pager_datahash(pPager->pageSize, (u8*)aData),
|
||||
(isMainJrnl?"main-journal":"sub-journal")
|
||||
@ -2365,10 +2397,10 @@ delmaster_out:
|
||||
** file in the file-system. This only happens when committing a transaction,
|
||||
** or rolling back a transaction (including rolling back a hot-journal).
|
||||
**
|
||||
** If the main database file is not open, or an exclusive lock is not
|
||||
** held, this function is a no-op. Otherwise, the size of the file is
|
||||
** changed to nPage pages (nPage*pPager->pageSize bytes). If the file
|
||||
** on disk is currently larger than nPage pages, then use the VFS
|
||||
** If the main database file is not open, or the pager is not in either
|
||||
** DBMOD or OPEN state, this function is a no-op. Otherwise, the size
|
||||
** of the file is changed to nPage pages (nPage*pPager->pageSize bytes).
|
||||
** If the file on disk is currently larger than nPage pages, then use the VFS
|
||||
** xTruncate() method to truncate it.
|
||||
**
|
||||
** Or, it might might be the case that the file on disk is smaller than
|
||||
@ -2389,6 +2421,7 @@ static int pager_truncate(Pager *pPager, Pgno nPage){
|
||||
&& (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)
|
||||
){
|
||||
i64 currentSize, newSize;
|
||||
assert( pPager->eLock==EXCLUSIVE_LOCK );
|
||||
/* TODO: Is it safe to use Pager.dbFileSize here? */
|
||||
rc = sqlite3OsFileSize(pPager->fd, ¤tSize);
|
||||
newSize = pPager->pageSize*(i64)nPage;
|
||||
|
Loading…
Reference in New Issue
Block a user