Home | History | Annotate | Download | only in orig

Lines Matching refs:Pager

5402 ** CAPI3REF: Enable Or Disable Shared Pager Cache
6872 ** memory used by all pager caches associated with the database connection.)^
6892 ** <dd>This parameter returns the number of pager cache hits that have
6898 ** <dd>This parameter returns the number of pager cache misses that have
9840 ** callback for the database handle. Each pager opened via the sqlite
9842 ** callback is currently invoked only from within pager.c.
10048 ** pager.h.
10128 ** It is a read-only number computed by the pager. But we merge it with
10196 SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
10773 /************** Include pager.h in the middle of sqliteInt.h *****************/
10774 /************** Begin file pager.h *******************************************/
10810 ** Each open file is managed by a separate instance of the "Pager" structure.
10812 typedef struct Pager Pager;
10824 ** roll back. See comments for function writeMasterJournal() in pager.c
10875 ** that make up the Pager sub-system API. See source code comments for
10879 /* Open and close a Pager connection. */
10882 Pager **ppPager,
10889 SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager);
10890 SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
10892 /* Functions used to configure a Pager object. */
10893 SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
10894 SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);
10896 SQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager*,Pager*);
10898 SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int);
10899 SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);
10900 SQLITE_PRIVATE void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64);
10901 SQLITE_PRIVATE void sqlite3PagerShrink(Pager*);
10902 SQLITE_PRIVATE void sqlite3PagerSetFlags(Pager*,unsigned);
10903 SQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *, int);
10904 SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *, int);
10905 SQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager*);
10906 SQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager*);
10907 SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
10908 SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager*);
10911 SQLITE_PRIVATE int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
10913 SQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
10921 SQLITE_PRIVATE int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);
10926 /* Functions used to manage pager transactions and savepoints. */
10927 SQLITE_PRIVATE void sqlite3PagerPagecount(Pager*, int*);
10928 SQLITE_PRIVATE int sqlite3PagerBegin(Pager*, int exFlag, int);
10929 SQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int);
10930 SQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager*);
10931 SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager, const char *zMaster);
10932 SQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager*);
10933 SQLITE_PRIVATE int sqlite3PagerRollback(Pager*);
10934 SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
10935 SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
10936 SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager);
10939 SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*);
10940 SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager);
10941 SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager);
10942 SQLITE_PRIVATE int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
10943 SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager);
10947 SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager);
10950 /* Functions used to query pager state and configuration. */
10951 SQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager*);
10952 SQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager*);
10954 SQLITE_PRIVATE int sqlite3PagerRefcount(Pager*);
10956 SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager*);
10957 SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*, int);
10958 SQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager*);
10959 SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*);
10960 SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
10961 SQLITE_PRIVATE int sqlite3PagerNosync(Pager*);
10962 SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
10963 SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
10964 SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);
10965 SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *);
10969 SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
10983 SQLITE_PRIVATE int *sqlite3PagerStats(Pager*);
10984 SQLITE_PRIVATE void sqlite3PagerRefdump(Pager*);
10994 /************** End of pager.h ***********************************************/
11027 Pager *pPager; /* The pager this page is part of */
11064 /* Create a new pager cache.
11135 /* Set and get the suggested cache-size for the specified pager-cache.
11138 ** the total number of pages cached by purgeable pager-caches to the sum
11362 ** actual data in the bytes used for locking. The pager never allocates
11810 #define SQLITE_CacheSpill 0x00000010 /* OK to spill pager cache */
15963 Pager *pPager = sqlite3BtreePager(pBt);
16053 Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);
30483 /* The pager calls this method to signal that it has done
41170 ** The pcache.c and pager.c modules deal pointers to PgHdr objects.
42299 ** held by the pager system. Memory in use by any SQLite pager allocated
42867 /************** Begin file pager.c *******************************************/
42879 ** This is the implementation of the page cache subsystem or "pager".
42881 ** The pager is used to access a database disk file. It implements
42883 ** is separate from the database file. The pager also implements file
42890 /************** Include wal.h in the middle of pager.c ***********************/
42943 ** There is one object of this type for each pager.
43010 ** by the pager layer on the database file.
43031 /************** Continuing where we left off in pager.c **********************/
43034 /******************* NOTES ON THE DESIGN OF THE PAGER ************************
43135 ** PAGERID() takes a pointer to a Pager struct as its argument. The
43143 ** The Pager.eState variable stores the current 'state' of a pager. A
43144 ** pager may be in any one of the seven states shown in the following
43182 ** The pager starts up in this state. Nothing is guaranteed in this
43193 ** rollback (non-WAL) mode are met. Unless the pager is (or recently
43216 ** The pager moves to this state from READER when a write-transaction
43239 ** * The contents of the pager cache have not been modified.
43245 ** A pager moves from WRITER_LOCKED state to this state when a page is
43258 ** The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state
43274 ** A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD
43292 ** difficult to be sure that the in-memory pager state (cache contents,
43295 ** Temporary pager files may enter the ERROR state, but in-memory pagers
43304 ** file. To avoid this hazard, the pager switches into the ERROR state
43307 ** Once it has entered the ERROR state, any attempt to use the pager
43309 ** outstanding transactions have been abandoned, the pager is able to
43313 ** when a read-transaction is next opened on the pager (transitioning
43314 ** the pager into READER state). At that point the system has recovered
43317 ** Specifically, the pager jumps into the ERROR state if:
43331 ** persists, the pager enters the ERROR state via condition (1) above.
43337 ** read-only statement cannot leave the pager in an internally inconsistent
43340 ** * The Pager.errCode variable is set to something other than SQLITE_OK.
43342 ** last reference is dropped the pager should move back to OPEN state).
43343 ** * The pager is not an in-memory pager.
43348 ** * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the
43355 ** executed), and when the pager is leaving the "error state".
43368 ** The Pager.eLock variable is almost always set to one of the
43379 ** VFS call is successful. This way, the Pager.eLock variable may be set
43387 ** The exception is when the database file is unlocked as the pager moves
43390 ** transition, by the same pager or any other). If the call to xUnlock()
43391 ** fails at this point and the pager is left holding an EXCLUSIVE lock, this
43404 ** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It
43407 ** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK
43412 ** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in
43442 ** are stored in the Pager.aSavepoint[] array, which is allocated and
43465 ** Bits of the Pager.doNotSpill flag. See further description below.
43472 ** An open page cache is an instance of struct Pager. A description of
43477 ** The current 'state' of the pager object. See the comment and state
43478 ** diagram above for a description of the pager state.
43487 ** databases always have Pager.exclusiveMode==1, this tricks the pager
43535 ** is cleared anyway (and the pager will move to ERROR state).
43561 ** sub-journals are only used for in-memory pager files.
43600 ** that the database file is larger than the database image (Pager.dbSize),
43622 ** The Pager.errCode variable is only ever used in PAGER_ERROR state. It
43623 ** is set to zero in all other states. In PAGER_ERROR state, Pager.errCode
43627 struct Pager {
43645 ** when the pager is first created or else only change when there is a
43648 ** the "state" of the pager, while other class members describe the
43649 ** "configuration" of the pager.
43651 u8 eState; /* Pager state (OPEN, READER, WRITER_LOCKED..) */
43708 char *pTmpSpace; /* Pager.pageSize bytes of space for tmp use */
43717 ** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains
43775 ** The journal header size for this pager. This is usually the same
43822 ** Return true if this pager uses a write-ahead log instead of the usual
43826 static int pagerUseWal(Pager *pPager){
43844 ** the internal state of the Pager object.
43846 static int assert_pager_state(Pager *p){
43847 Pager *pPager = p;
43873 ** this means an in-memory pager performs no IO at all, it cannot encounter
43877 ** is therefore not possible for an in-memory pager to enter the ERROR
43962 /* There must be at least one outstanding reference to the pager if
43963 ** in ERROR state. Otherwise the pager should have already dropped
43978 ** containing the state of the Pager object passed as an argument. This
43984 static char *print_pager_state(Pager *p){
44036 Pager *pPager = pPg->pPager;
44053 static int pageInJournal(Pager *pPager, PgHdr *pPg){
44093 ** succeeds, set the Pager.eLock variable to match the (attempted) new lock.
44095 ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is
44099 static int pagerUnlockDb(Pager *pPager, int eLock){
44119 ** Pager.eLock variable to the new locking state.
44121 ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is
44126 static int pagerLockDb(Pager *pPager, int eLock){
44142 ** can be used with this pager. The optimization can be used if:
44158 static int jrnlBufferSize(Pager *pPager){
44212 Pager *pPager = pPg->pPager;
44225 ** When this is called the journal file for pager pPager must be open.
44295 ** Pager.journalOff Return value
44303 static i64 journalHdrOffset(Pager *pPager){
44319 ** within the current transaction (i.e. if Pager.journalOff==0).
44321 ** If doTruncate is non-zero or the Pager.journalSizeLimit variable is
44324 ** if the pager is not in no-sync mode, sync the journal file immediately
44327 ** If Pager.journalSizeLimit is set to a positive, non-zero value, and
44330 ** journal file to Pager.journalSizeLimit bytes. The journal file does
44336 static int zeroJournalHdr(Pager *pPager, int doTruncate){
44385 static int writeJournalHdr(Pager *pPager){
44424 ** * When the pager is in no-sync mode. Corruption can follow a
44461 ** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next
44472 ** database page size. Since the zHeader buffer is only Pager.pageSize
44504 Pager *pPager, /* Pager object */
44516 /* Advance Pager.journalOff to the start of the next sector. If the
44564 ** journal header to zero. In this case, assume that the Pager.pageSize
44599 ** of Pager.sectorSize is restored at the end of that routine.
44610 ** Write the supplied master journal name into the journal file for pager
44612 ** thing written to a journal file. If the pager is in full-sync mode, the
44628 static int writeMasterJournal(Pager *pPager, const char *zMaster){
44675 /* If the pager is in peristent-journal mode, then the physical
44696 static void pager_reset(Pager *pPager){
44705 SQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager *pPager){
44711 ** Free all structures in the Pager.aSavepoint[] array and set both
44712 ** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal
44713 ** if it is open and the pager is not in exclusive mode.
44715 static void releaseAllSavepoints(Pager *pPager){
44716 int ii; /* Iterator for looping through Pager.aSavepoint */
44734 static int addToSavepointBitvecs(Pager *pPager, Pgno pgno){
44750 ** This function is a no-op if the pager is in exclusive mode and not
44751 ** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN
44754 ** If the pager is not in exclusive-access mode, the database file is
44759 ** If the pager is in ERROR state when this function is called, the
44760 ** contents of the pager cache are discarded before switching back to
44761 ** the OPEN state. Regardless of whether the pager is in exclusive-mode
44766 static void pager_unlock(Pager *pPager){
44802 /* If the pager is in the ERROR state and the call to unlock the database
44812 /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here
44821 /* If Pager.errCode is set, the contents of the pager cache cannot be
44822 ** trusted. Now that there are no outstanding references to the pager,
44842 ** the pager to transition into the ERROR state may ahve occurred.
44843 ** The first argument is a pointer to the pager structure, the second
44844 ** the error-code about to be returned by a pager API function. The
44848 ** IOERR sub-codes, the pager enters the ERROR state and the error code
44849 ** is stored in Pager.errCode. While the pager remains in the ERROR state,
44850 ** all major API calls on the Pager will immediately return Pager.errCode.
44852 ** The ERROR state indicates that the contents of the pager-cache
44854 ** the contents of the pager-cache. If a transaction was active when
44859 static int pager_error(Pager *pPager, int rc){
44874 static int pager_truncate(Pager *pPager, Pgno nPage);
44893 ** depends on whether or not the pager is running in exclusive mode and
44894 ** the current journal-mode (Pager.journalMode value), as follows:
44911 ** If the pager is running in exclusive mode, this method of finalizing
44913 ** DELETE and the pager is in exclusive mode, the method described under
44916 ** After the journal is finalized, the pager moves to PAGER_READER state.
44929 static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){
44933 /* Do nothing if the pager does not have an open write transaction
44982 /* This branch may be executed with Pager.journalMode==MEMORY if
45055 ** If the pager has already entered the ERROR state, do not attempt
45058 ** the database file and move the pager back to OPEN state. If this
45060 ** connection to obtain a shared lock on the pager (which may be this one)
45063 ** If the pager has not already entered the ERROR state, but an IO or
45065 ** the pager to enter the ERROR state. Which will be cleared by the
45068 static void pagerUnlockAndRollback(Pager *pPager){
45102 static u32 pager_cksum(Pager *pPager, const u8 *aData){
45117 static void pagerReportSize(Pager *pPager){
45130 ** pager as it is in the source. This comes up when a VACUUM changes the
45133 SQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager *pDest, Pager *pSrc){
45151 ** is greater than the current value of Pager.dbSize, then playback is
45179 Pager *pPager, /* The pager being played back */
45204 ** a hot-journal rollback. If it is a hot-journal rollback, the pager
45257 /* If the pager is in CACHEMOD state, then there must be a copy of this
45258 ** page in the pager cache. In this case just update the pager cache,
45263 ** not be in the pager cache. Later: if a malloc() or IO error occurs
45269 ** pager cache if it exists and the main file. The page is then marked
45272 ** if the pager is in OPEN state.
45338 ** and if the pager requires a journal-sync, then mark the page as
45374 ** already in the journal file (recorded in Pager.pInJournal) and
45387 /* If this was page 1, then restore the value of Pager.dbFileVers.
45406 ** Argument zMaster may point to Pager.pTmpSpace. So that buffer is not
45443 static int pager_delmaster(Pager *pPager, const char *zMaster){
45538 ** If the main database file is not open, or the pager is not in either
45553 static int pager_truncate(Pager *pPager, Pgno nPage){
45564 /* TODO: Is it safe to use Pager.dbFileSize here? */
45601 ** Set the value of the Pager.sectorSize variable for the given
45602 ** pager based on the value returned by the xSectorSize method
45623 static void setSectorSize(Pager *pPager){
45692 ** If the journal really is hot, reset the pager cache prior rolling
45696 static int pager_playback(Pager *pPager, int isHot){
45723 ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that
45823 ** code. This will cause the pager to enter the error state
45884 /* The Pager.sectorSize variable may have been updated while rolling
45898 ** If page 1 is read, then the value of Pager.dbFileVers[] is set to
45905 Pager *pPager = pPg->pPager; /* Pager object associated with page pPg */
45985 ** is actually a pointer to the Pager structure.
45995 Pager *pPager = (Pager *)pCtx;
46032 static int pagerRollbackWal(Pager *pPager){
46065 Pager *pPager, /* Pager object */
46131 static int pagerBeginReadTransaction(Pager *pPager){
46158 ** in pages (assuming the page size currently stored in Pager.pageSize).
46164 static int pagerPagecount(Pager *pPager, Pgno *pnPage){
46168 ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or
46195 ** configured maximum pager number, increase the allowed limit so
46212 ** If the database is not empty and the *-wal file exists, open the pager
46214 ** if no error occurs, make sure Pager.journalMode is not set to
46225 static int pagerOpenWalIfPresent(Pager *pPager){
46289 ** In either case, before playback commences the Pager.dbSize variable
46294 static int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){
46405 SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager *pPager, int mxPage){
46412 static void pagerFixMaplimit(Pager *pPager){
46427 SQLITE_PRIVATE void sqlite3PagerSetMmapLimit(Pager *pPager, sqlite3_int64 szMmap){
46433 ** Free as much memory as possible from the pager.
46435 SQLITE_PRIVATE void sqlite3PagerShrink(Pager *pPager){
46440 ** Adjust settings of the pager to those specified in the pgFlags parameter.
46487 Pager *pPager, /* The pager to set safety level for */
46544 Pager *pPager, /* The pager object */
46564 ** The pager invokes the busy-handler if sqlite3OsLock() returns
46580 ** returned to the caller of the pager API function.
46583 Pager *pPager, /* Pager object */
46599 ** Change the page size used by the Pager object. The new page size
46602 ** If the pager is in the error state when this function is called, it
46616 ** then the pager object page size is set to *pPageSize.
46619 ** to obtain a new Pager.pTmpSpace buffer. If this allocation attempt
46624 ** conditions above is not true, the pager was in error state when this
46628 SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager *pPager, u32 *pPageSize, int nReserve){
46633 ** of the Pager object is internally consistent.
46635 ** At one point this function returned an error if the pager was in
46685 ** by the pager. This is a buffer that is big enough to hold the
46691 SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager *pPager){
46702 SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
46739 ** If the pager was opened on a transient file (zFilename==""), or
46749 SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager *pPager, int N, unsigned char *pDest){
46755 ** the Pager object. There has not been an opportunity to transition
46772 ** the pager. It returns the total number of pages in the database.
46777 SQLITE_PRIVATE void sqlite3PagerPagecount(Pager *pPager, int *pnPage){
46795 ** the lock. If the lock is obtained successfully, set the Pager.state
46798 static int pager_wait_on_lock(Pager *pPager, int locktype){
46844 static void assertTruncateConstraint(Pager *pPager){
46854 ** just sets the internal state of the pager object so that the
46862 SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){
46873 ** Pager object may still have open savepoints (Pager.nSavepoint!=0),
46893 static int pagerSyncHotJournal(Pager *pPager){
46915 Pager *pPager, /* Pager object */
46957 Pager *pPager = pPg->pPager;
46967 ** Free all PgHdr objects stored in the Pager.pMmapFreelist list.
46969 static void pagerFreeMapHdrs(Pager *pPager){
46993 SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager){
47015 ** If an error occurs while trying to sync the journal, shift the pager
47067 ** If the Pager.noSync flag is set, then this function is a no-op.
47077 ** been written following it. If the pager is operating in full-sync
47097 static int syncJournal(Pager *pPager, int newHdr){
47119 ** than Pager.journalOff bytes. If the next thing in the journal
47130 ** a valid header following Pager.journalOff, then write a 0x00
47198 /* Unless the pager is in noSync mode, the journal file was just
47215 ** The pager must hold at least a RESERVED lock when this function
47220 ** If the pager is a temp-file pager and the actual file-system file
47228 ** * The page number is greater than Pager.dbSize, or
47231 ** If writing out a page causes the database file to grow, Pager.dbFileSize
47233 ** in Pager.dbFileVers[] is updated to match the new value stored in
47240 static int pager_write_pagelist(Pager *pPager, PgHdr *pList){
47274 ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to
47294 /* If page 1 was just written, update Pager.dbFileVers to match
47306 /* Update any backup objects copying the contents of this pager. */
47331 static int openSubJournal(Pager *pPager){
47356 Pager *pPager = pPg->pPager;
47401 ** soft memory limit. The first argument is a pointer to a Pager object
47402 ** (cast as a void*). The pager is always 'purgeable' (not an in-memory
47405 ** is always associated with the Pager object passed as the first
47419 Pager *pPager = (Pager *)p;
47486 ** Allocate and initialize a new Pager object and put a pointer to it
47487 ** in *ppPager. The pager should eventually be freed by passing it
47502 ** operation of the pager. It should be passed some bitwise combination
47508 ** If the pager object is allocated and the specified file opened
47510 ** the new pager object. If an error occurs, *ppPager is set to NULL
47517 Pager **ppPager, /* OUT: Return the Pager structure here */
47525 Pager *pPager = 0; /* Pager object to allocate and return */
47604 /* Allocate memory for the Pager structure, PCache object, the
47608 ** Pager object (sizeof(Pager) bytes)
47617 ROUND8(sizeof(*pPager)) + /* Pager structure */
47632 pPager = (Pager*)(pPtr);
47640 /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */
47660 /* Open the pager file.
47729 ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer.
47745 /* If an error occurred above, free the Pager structure and close the file.
47812 ** under the pager. Return SQLITE_OK if the database is still were it ought
47816 static int databaseIsUnmoved(Pager *pPager){
47839 ** the file-system for the given pager. A hot journal is one that
47867 static int hasHotJournal(Pager *pPager, int *pExists){
47967 ** 1) If the pager is currently in PAGER_OPEN state (no lock held
47976 ** 2) If the pager is running in exclusive-mode, and there are currently
47986 SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){
47990 ** outstanding pages. This implies that the pager state should either
47991 ** be OPEN or READER. READER is only possible if the pager is or was in
48037 ** Unless the pager is in locking_mode=exclusive mode, the lock is
48055 ** may mean that the pager was in the error-state when this
48099 ** the file. If the unlock attempt fails, then Pager.eLock must be
48103 ** In order to get pager_unlock() to do this, set Pager.eState to
48107 ** shortly transition the pager object to the OPEN state. Calling
48161 ** In this case there may exist a Pager.pMap mapping that appears
48202 ** transaction and unlock the pager.
48208 static void pagerUnlockIfUnused(Pager *pPager){
48215 ** Acquire a reference to page number pgno in pager pPager (a page
48247 ** to pgno in Pager.pInJournal (bitvec of pages already written to the
48265 Pager *pPager, /* The pager open on the database file */
48299 /* If the pager is in the error state, return an error immediately.
48355 ** pager was already in the error-state when this function was called.
48372 /* The pager cache has created a new page. Its content needs to
48446 SQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){
48466 Pager *pPager;
48485 ** Open the journal file for pager pPager and write a journal header
48496 ** Pager.pInJournal bitvec structure is allocated.
48499 ** SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or
48502 static int pager_open_journal(Pager *pPager){
48575 ** Begin a write-transaction on the specified pager object. If a
48591 SQLITE_PRIVATE int sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory){
48602 /* If the pager is configured to use locking_mode=exclusive, and an
48634 ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD
48661 Pager *pPager = pPg->pPager;
48714 ** Pager.pInJournal bitvec and the PagerSavepoint.pInSavepoint bitvecs
48718 Pager *pPager = pPg->pPager;
48740 ** an error might occur and the pager would end up in WRITER_LOCKED state
48816 Pager *pPager = pPg->pPager; /* The pager that owns pPg */
48904 Pager *pPager = pPg->pPager;
48931 ** A call to this routine tells the pager that it is not necessary to
48938 ** on the given page is unused. The pager marks the page as clean so
48945 Pager *pPager = pPg->pPager;
48958 ** byte offset 24 of the pager file. The secondary change counter at
48977 static int pager_incr_changecounter(Pager *pPager, int isDirectMode){
49035 /* Update the pager's copy of the change-counter. Otherwise, the
49055 ** or pages with the Pager.noSync flag set.
49057 ** If successful, or if called on a pager for which it is a no-op, this
49060 SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager, const char *zMaster){
49086 SQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager *pPager){
49100 ** Sync the database file for the pager pPager. zMaster points to the name
49126 Pager *pPager, /* Pager object */
49295 ** If an error occurs, an IO error code is returned and the pager
49298 SQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager *pPager){
49313 ** this transaction, the pager is running in exclusive-mode and is
49320 ** header. Since the pager is in exclusive mode, there is no need
49341 ** The pager falls back to PAGER_READER state if successful, or PAGER_ERROR
49344 ** If the pager is already in PAGER_ERROR state when this function is called,
49345 ** it returns Pager.errCode immediately. No work is performed in this case.
49364 SQLITE_PRIVATE int sqlite3PagerRollback(Pager *pPager){
49369 ** the pager is already in the ERROR state, the rollback is not
49385 /* This can happen using journal_mode=off. Move the pager to the error
49403 /* If an error occurs during a ROLLBACK, we can no longer trust the pager
49413 SQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager *pPager){
49421 SQLITE_PRIVATE int sqlite3PagerRefcount(Pager *pPager){
49428 ** used by the pager and its associated cache.
49430 SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager *pPager){
49449 SQLITE_PRIVATE int *sqlite3PagerStats(Pager *pPager){
49473 SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){
49491 ** Return true if this is an in-memory pager.
49493 SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager *pPager){
49507 static SQLITE_NOINLINE int pagerOpenSavepoint(Pager *pPager, int nSavepoint){
49511 PagerSavepoint *aNew; /* New Pager.aSavepoint array */
49517 /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM
49552 SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){
49576 ** (the first created). A value of (Pager.nSavepoint-1) means operate
49578 ** (Pager.nSavepoint-1), then this function is a no-op.
49594 SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
49644 ** Except, if the pager is in-memory only, then return an empty string if
49651 SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager *pPager, int nullIfMemDb){
49656 ** Return the VFS structure for the pager.
49658 SQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager *pPager){
49664 ** with the pager. This might return NULL if the file has
49667 SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager *pPager){
49674 SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager *pPager){
49679 ** Return true if fsync() calls are disabled for this pager. Return FALSE
49682 SQLITE_PRIVATE int sqlite3PagerNosync(Pager *pPager){
49688 ** Set or retrieve the codec for this pager
49691 Pager *pPager,
49704 SQLITE_PRIVATE void *sqlite3PagerGetCodec(Pager *pPager){
49722 ** Return the current pager state
49724 SQLITE_PRIVATE int sqlite3PagerState(Pager *pPager){
49755 SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){
49855 ** loading the page into the pager-cache and setting the PGHDR_NEED_SYNC
49904 ** Return a pointer to the Pager.nExtra bytes of "extra" space
49912 ** Get/set the locking-mode for this pager. Parameter eMode must be one
49921 SQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *pPager, int eMode){
49935 ** Set the journal-mode for this pager. Parameter eMode must be one of:
49954 SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
49995 ** mode except WAL, unless the pager is in locking_mode=exclusive mode,
50052 SQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager *pPager){
50057 ** Return TRUE if the pager is in a state where it is OK to change the
50061 SQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager *pPager){
50074 SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *pPager, i64 iLimit){
50088 SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){
50094 ** Unless this is an in-memory or temporary database, clear the pager cache.
50096 SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){
50109 SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int eMode, int *pnLog, int *pnCkpt){
50122 SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager){
50127 ** Return true if the underlying VFS for the given pager supports the
50130 SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager){
50139 static int pagerExclusiveLock(Pager *pPager){
50154 ** Call sqlite3WalOpen() to open the WAL handle. If the pager is in
50159 static int pagerOpenWal(Pager *pPager){
50165 /* If the pager is already in exclusive-mode, the WAL module will use
50193 ** If the pager passed as the first argument is open on a real database
50196 ** return SQLITE_OK. If an error occurs or the VFS used by the pager does
50200 ** If the pager is open on a temp-file (or in-memory database), or if
50205 Pager *pPager, /* Pager object */
50243 SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager){
50284 ** A read-lock must be held on the pager when this function is called. If
50285 ** the pager is in WAL mode and the WAL file currently contains one or more
50290 SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){
50299 /************** End of pager.c ***********************************************/
52646 ** Pager layer will use this to know that is cache is stale and
53369 ** performed, then the pager-cache associated with pWal is now
53371 ** next time the pager opens a snapshot on this database it knows that
53408 ** operation must occur while the pager is still holding the exclusive
53415 ** routine is a no-op. The pager must already hold the exclusive lock
53419 ** not actually change anything. The pager uses this to see if it
53431 ** locks are taken in this case). Nor should the pager attempt to
53802 DbPage *pDbPage; /* Pager page handle */
53918 Pager *pPager; /* The page cache */
54179 Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */
54586 ** Enable or disable the shared pager and schema features.
55069 ** page from the pager layer with the 'no-content' flag set. True otherwise.
56382 ** Convert a DbPage obtained from the pager into a MemPage used by
56396 ** Get a page from the pager. Initialize the MemPage.pBt and
56424 ** Retrieve a page from the pager cache. If the requested page is not
56425 ** already in the pager cache return NULL. Initialize the MemPage.pBt and
56452 ** Get a page from the pager and initialize it.
56561 ** During a rollback, when the pager reloads information into the cache
56882 /* If the B-Tree was successfully opened, set the pager-cache size to the
56883 ** default value. Except, when opening on an existing shared pager-cache,
56884 ** do not change the pager-cache size.
57041 ** value of mxPage. If mxPage is negative, the pager will
57725 /* This call makes sure that the pager has the correct number of
57866 Pager *pPager = pBt->pPager;
58115 Pager *pPager = pBt->pPager;
58237 ** call below will unlock the pager. */
58247 ** pager if this call closed the only read or write transaction. */
58267 ** Normally, if an error occurs while the pager layer is attempting to
58273 ** functions return code. So, even if an error occurs in the pager layer,
58275 ** transaction has been closed. This is quite safe, as the pager will have
58471 /* At the pager level, a statement transaction is a savepoint with
58533 ** 2: Other database connections that share the same pager cache
60228 ** pager layer with the 'no-content' flag set. This prevents the pager
60233 ** not set the no-content flag. This causes the pager to load and journal
60236 ** Note that the pager will not actually attempt to load or journal
61895 ** we do the detection here in order to avoid populating the pager
63125 ** from the pager. The BTREE_DATA_VERSION value is not actually stored in the
63126 ** database file. It is a number computed by the pager. But its access
63260 ** Return the pager associated with a BTree. This routine is used for
63263 SQLITE_PRIVATE Pager *sqlite3BtreePager(Btree *p){
63886 ** The pager filename is invariant as long as the pager is
63899 ** The pager journal filename is invariant as long as the pager is
64198 int isAttached; /* True once backup has been registered with pager */
64199 sqlite3_backup *pNext; /* Next backup associated with source pager */
64214 ** invoked by the pager layer to report various state changes in
64399 Pager * const pDestPager = sqlite3BtreePager(p->pDest);
64464 ** and the pager code use this trick (clearing the first byte
64499 ** Register this backup object with the associated source pager for
64531 Pager * const pSrcPager = sqlite3BtreePager(p->pSrc); /* Source pager */
64532 Pager * const pDestPager = sqlite3BtreePager(p->pDest); /* Dest pager */
64537 /* If the source pager is currently in a write-transaction, return
64573 ** source pager for the number of pages in the database.
64773 /* Detach this backup from the source pager. */
64857 ** has been modified by a transaction on the source pager. Copy
64877 ** Restart the backup process. This is called when the pager layer
69116 ** pagerStress() in pager.c), the rollback is required to restore
69117 ** the pager to a consistent state.
76061 ** P3==3 is the recommended pager cache size, and so forth. P1==0 is
76092 ** P2==2 is the database format. P2==3 is the recommended pager cache
78840 Pager *pPager; /* Pager associated with pBt */
92058 Pager *pPager;
106019 ** Set the safety_level and pager flags for pager iDb. Or if iDb<0
106068 ** defined in pager.h. This function returns the associated lowercase
106286 ** buffer that the pager module resizes using sqlite3_realloc().
106370 Pager *pPager;
106449 Pager *pPager = sqlite3BtreePager(pDb->pBt);
106716 Pager *pPager = sqlite3BtreePager(pDb->pBt);
106723 Pager *pPager = sqlite3BtreePager(pDb->pBt);
116550 ** An optimisation would be to use a non-journaled pager.
116746 ** vacuum database. The vacuum_db journal file is deleted when the pager
131540 Pager *pPager = sqlite3BtreePager(pBt);
131710 ** at the b-tree/pager level.
131879 ** the pager rollback and schema reset an atomic operation. */
132881 ** a temporary file for transient pager files and statement journals.
133642 ** database it is 'NONE'. This matches the pager layer defaults.
134168 Pager *pPager;
140703 ** of the number of overflow pages that will be loaded by the pager layer
161899 ** level pager to use "journal_mode=off". This prevents it from
163262 Pager *pPager = sqlite3BtreePager(pBt);
163291 Pager *pPager = sqlite3BtreePager(pBt);