more
This commit is contained in:
parent
e37711199f
commit
c7cb16d4dd
|
@ -21,7 +21,6 @@
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
// #include "wal.h"
|
// #include "wal.h"
|
||||||
|
|
||||||
|
|
||||||
// /******************* NOTES ON THE DESIGN OF THE PAGER ************************
|
// /******************* NOTES ON THE DESIGN OF THE PAGER ************************
|
||||||
// **
|
// **
|
||||||
// ** This comment block describes invariants that hold when using a rollback
|
// ** This comment block describes invariants that hold when using a rollback
|
||||||
|
@ -413,7 +412,6 @@
|
||||||
// */
|
// */
|
||||||
// #define MAX_SECTOR_SIZE 0x10000
|
// #define MAX_SECTOR_SIZE 0x10000
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** An instance of the following structure is allocated for each active
|
// ** An instance of the following structure is allocated for each active
|
||||||
// ** savepoint and statement transaction in the system. All such structures
|
// ** savepoint and statement transaction in the system. All such structures
|
||||||
|
@ -447,175 +445,175 @@
|
||||||
// #define SPILLFLAG_ROLLBACK 0x02 /* Current rolling back, so do not spill */
|
// #define SPILLFLAG_ROLLBACK 0x02 /* Current rolling back, so do not spill */
|
||||||
// #define SPILLFLAG_NOSYNC 0x04 /* Spill is ok, but do not sync */
|
// #define SPILLFLAG_NOSYNC 0x04 /* Spill is ok, but do not sync */
|
||||||
|
|
||||||
// /*
|
/*
|
||||||
// ** An open page cache is an instance of struct Pager. A description of
|
** An open page cache is an instance of struct Pager. A description of
|
||||||
// ** some of the more important member variables follows:
|
** some of the more important member variables follows:
|
||||||
// **
|
**
|
||||||
// ** eState
|
** eState
|
||||||
// **
|
**
|
||||||
// ** The current 'state' of the pager object. See the comment and state
|
** The current 'state' of the pager object. See the comment and state
|
||||||
// ** diagram above for a description of the pager state.
|
** diagram above for a description of the pager state.
|
||||||
// **
|
**
|
||||||
// ** eLock
|
** eLock
|
||||||
// **
|
**
|
||||||
// ** For a real on-disk database, the current lock held on the database file -
|
** For a real on-disk database, the current lock held on the database file -
|
||||||
// ** NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.
|
** NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.
|
||||||
// **
|
**
|
||||||
// ** For a temporary or in-memory database (neither of which require any
|
** For a temporary or in-memory database (neither of which require any
|
||||||
// ** locks), this variable is always set to EXCLUSIVE_LOCK. Since such
|
** locks), this variable is always set to EXCLUSIVE_LOCK. Since such
|
||||||
// ** databases always have Pager.exclusiveMode==1, this tricks the pager
|
** databases always have Pager.exclusiveMode==1, this tricks the pager
|
||||||
// ** logic into thinking that it already has all the locks it will ever
|
** logic into thinking that it already has all the locks it will ever
|
||||||
// ** need (and no reason to release them).
|
** need (and no reason to release them).
|
||||||
// **
|
**
|
||||||
// ** In some (obscure) circumstances, this variable may also be set to
|
** In some (obscure) circumstances, this variable may also be set to
|
||||||
// ** UNKNOWN_LOCK. See the comment above the #define of UNKNOWN_LOCK for
|
** UNKNOWN_LOCK. See the comment above the #define of UNKNOWN_LOCK for
|
||||||
// ** details.
|
** details.
|
||||||
// **
|
**
|
||||||
// ** changeCountDone
|
** changeCountDone
|
||||||
// **
|
**
|
||||||
// ** This boolean variable is used to make sure that the change-counter
|
** This boolean variable is used to make sure that the change-counter
|
||||||
// ** (the 4-byte header field at byte offset 24 of the database file) is
|
** (the 4-byte header field at byte offset 24 of the database file) is
|
||||||
// ** not updated more often than necessary.
|
** not updated more often than necessary.
|
||||||
// **
|
**
|
||||||
// ** It is set to true when the change-counter field is updated, which
|
** It is set to true when the change-counter field is updated, which
|
||||||
// ** can only happen if an exclusive lock is held on the database file.
|
** can only happen if an exclusive lock is held on the database file.
|
||||||
// ** It is cleared (set to false) whenever an exclusive lock is
|
** It is cleared (set to false) whenever an exclusive lock is
|
||||||
// ** relinquished on the database file. Each time a transaction is committed,
|
** relinquished on the database file. Each time a transaction is committed,
|
||||||
// ** The changeCountDone flag is inspected. If it is true, the work of
|
** The changeCountDone flag is inspected. If it is true, the work of
|
||||||
// ** updating the change-counter is omitted for the current transaction.
|
** updating the change-counter is omitted for the current transaction.
|
||||||
// **
|
**
|
||||||
// ** This mechanism means that when running in exclusive mode, a connection
|
** This mechanism means that when running in exclusive mode, a connection
|
||||||
// ** need only update the change-counter once, for the first transaction
|
** need only update the change-counter once, for the first transaction
|
||||||
// ** committed.
|
** committed.
|
||||||
// **
|
**
|
||||||
// ** setSuper
|
** setSuper
|
||||||
// **
|
**
|
||||||
// ** When PagerCommitPhaseOne() is called to commit a transaction, it may
|
** When PagerCommitPhaseOne() is called to commit a transaction, it may
|
||||||
// ** (or may not) specify a super-journal name to be written into the
|
** (or may not) specify a super-journal name to be written into the
|
||||||
// ** journal file before it is synced to disk.
|
** journal file before it is synced to disk.
|
||||||
// **
|
**
|
||||||
// ** Whether or not a journal file contains a super-journal pointer affects
|
** Whether or not a journal file contains a super-journal pointer affects
|
||||||
// ** the way in which the journal file is finalized after the transaction is
|
** the way in which the journal file is finalized after the transaction is
|
||||||
// ** committed or rolled back when running in "journal_mode=PERSIST" mode.
|
** committed or rolled back when running in "journal_mode=PERSIST" mode.
|
||||||
// ** If a journal file does not contain a super-journal pointer, it is
|
** If a journal file does not contain a super-journal pointer, it is
|
||||||
// ** finalized by overwriting the first journal header with zeroes. If
|
** finalized by overwriting the first journal header with zeroes. If
|
||||||
// ** it does contain a super-journal pointer the journal file is finalized
|
** it does contain a super-journal pointer the journal file is finalized
|
||||||
// ** by truncating it to zero bytes, just as if the connection were
|
** by truncating it to zero bytes, just as if the connection were
|
||||||
// ** running in "journal_mode=truncate" mode.
|
** running in "journal_mode=truncate" mode.
|
||||||
// **
|
**
|
||||||
// ** Journal files that contain super-journal pointers cannot be finalized
|
** Journal files that contain super-journal pointers cannot be finalized
|
||||||
// ** simply by overwriting the first journal-header with zeroes, as the
|
** simply by overwriting the first journal-header with zeroes, as the
|
||||||
// ** super-journal pointer could interfere with hot-journal rollback of any
|
** super-journal pointer could interfere with hot-journal rollback of any
|
||||||
// ** subsequently interrupted transaction that reuses the journal file.
|
** subsequently interrupted transaction that reuses the journal file.
|
||||||
// **
|
**
|
||||||
// ** The flag is cleared as soon as the journal file is finalized (either
|
** The flag is cleared as soon as the journal file is finalized (either
|
||||||
// ** by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the
|
** by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the
|
||||||
// ** journal file from being successfully finalized, the setSuper flag
|
** journal file from being successfully finalized, the setSuper flag
|
||||||
// ** is cleared anyway (and the pager will move to ERROR state).
|
** is cleared anyway (and the pager will move to ERROR state).
|
||||||
// **
|
**
|
||||||
// ** doNotSpill
|
** doNotSpill
|
||||||
// **
|
**
|
||||||
// ** This variables control the behavior of cache-spills (calls made by
|
** This variables control the behavior of cache-spills (calls made by
|
||||||
// ** the pcache module to the pagerStress() routine to write cached data
|
** the pcache module to the pagerStress() routine to write cached data
|
||||||
// ** to the file-system in order to free up memory).
|
** to the file-system in order to free up memory).
|
||||||
// **
|
**
|
||||||
// ** When bits SPILLFLAG_OFF or SPILLFLAG_ROLLBACK of doNotSpill are set,
|
** When bits SPILLFLAG_OFF or SPILLFLAG_ROLLBACK of doNotSpill are set,
|
||||||
// ** writing to the database from pagerStress() is disabled altogether.
|
** writing to the database from pagerStress() is disabled altogether.
|
||||||
// ** The SPILLFLAG_ROLLBACK case is done in a very obscure case that
|
** The SPILLFLAG_ROLLBACK case is done in a very obscure case that
|
||||||
// ** comes up during savepoint rollback that requires the pcache module
|
** comes up during savepoint rollback that requires the pcache module
|
||||||
// ** to allocate a new page to prevent the journal file from being written
|
** to allocate a new page to prevent the journal file from being written
|
||||||
// ** while it is being traversed by code in pager_playback(). The SPILLFLAG_OFF
|
** while it is being traversed by code in pager_playback(). The SPILLFLAG_OFF
|
||||||
// ** case is a user preference.
|
** case is a user preference.
|
||||||
// **
|
**
|
||||||
// ** If the SPILLFLAG_NOSYNC bit is set, writing to the database from
|
** If the SPILLFLAG_NOSYNC bit is set, writing to the database from
|
||||||
// ** pagerStress() is permitted, but syncing the journal file is not.
|
** pagerStress() is permitted, but syncing the journal file is not.
|
||||||
// ** This flag is set by sqlite3PagerWrite() when the file-system sector-size
|
** This flag is set by sqlite3PagerWrite() when the file-system sector-size
|
||||||
// ** is larger than the database page-size in order to prevent a journal sync
|
** is larger than the database page-size in order to prevent a journal sync
|
||||||
// ** from happening in between the journalling of two pages on the same sector.
|
** from happening in between the journalling of two pages on the same sector.
|
||||||
// **
|
**
|
||||||
// ** subjInMemory
|
** subjInMemory
|
||||||
// **
|
**
|
||||||
// ** This is a boolean variable. If true, then any required sub-journal
|
** This is a boolean variable. If true, then any required sub-journal
|
||||||
// ** is opened as an in-memory journal file. If false, then in-memory
|
** is opened as an in-memory journal file. If false, then in-memory
|
||||||
// ** sub-journals are only used for in-memory pager files.
|
** sub-journals are only used for in-memory pager files.
|
||||||
// **
|
**
|
||||||
// ** This variable is updated by the upper layer each time a new
|
** This variable is updated by the upper layer each time a new
|
||||||
// ** write-transaction is opened.
|
** write-transaction is opened.
|
||||||
// **
|
**
|
||||||
// ** dbSize, dbOrigSize, dbFileSize
|
** dbSize, dbOrigSize, dbFileSize
|
||||||
// **
|
**
|
||||||
// ** Variable dbSize is set to the number of pages in the database file.
|
** Variable dbSize is set to the number of pages in the database file.
|
||||||
// ** It is valid in PAGER_READER and higher states (all states except for
|
** It is valid in PAGER_READER and higher states (all states except for
|
||||||
// ** OPEN and ERROR).
|
** OPEN and ERROR).
|
||||||
// **
|
**
|
||||||
// ** dbSize is set based on the size of the database file, which may be
|
** dbSize is set based on the size of the database file, which may be
|
||||||
// ** larger than the size of the database (the value stored at offset
|
** larger than the size of the database (the value stored at offset
|
||||||
// ** 28 of the database header by the btree). If the size of the file
|
** 28 of the database header by the btree). If the size of the file
|
||||||
// ** is not an integer multiple of the page-size, the value stored in
|
** is not an integer multiple of the page-size, the value stored in
|
||||||
// ** dbSize is rounded down (i.e. a 5KB file with 2K page-size has dbSize==2).
|
** dbSize is rounded down (i.e. a 5KB file with 2K page-size has dbSize==2).
|
||||||
// ** Except, any file that is greater than 0 bytes in size is considered
|
** Except, any file that is greater than 0 bytes in size is considered
|
||||||
// ** to have at least one page. (i.e. a 1KB file with 2K page-size leads
|
** to have at least one page. (i.e. a 1KB file with 2K page-size leads
|
||||||
// ** to dbSize==1).
|
** to dbSize==1).
|
||||||
// **
|
**
|
||||||
// ** During a write-transaction, if pages with page-numbers greater than
|
** During a write-transaction, if pages with page-numbers greater than
|
||||||
// ** dbSize are modified in the cache, dbSize is updated accordingly.
|
** dbSize are modified in the cache, dbSize is updated accordingly.
|
||||||
// ** Similarly, if the database is truncated using PagerTruncateImage(),
|
** Similarly, if the database is truncated using PagerTruncateImage(),
|
||||||
// ** dbSize is updated.
|
** dbSize is updated.
|
||||||
// **
|
**
|
||||||
// ** Variables dbOrigSize and dbFileSize are valid in states
|
** Variables dbOrigSize and dbFileSize are valid in states
|
||||||
// ** PAGER_WRITER_LOCKED and higher. dbOrigSize is a copy of the dbSize
|
** PAGER_WRITER_LOCKED and higher. dbOrigSize is a copy of the dbSize
|
||||||
// ** variable at the start of the transaction. It is used during rollback,
|
** variable at the start of the transaction. It is used during rollback,
|
||||||
// ** and to determine whether or not pages need to be journalled before
|
** and to determine whether or not pages need to be journalled before
|
||||||
// ** being modified.
|
** being modified.
|
||||||
// **
|
**
|
||||||
// ** Throughout a write-transaction, dbFileSize contains the size of
|
** Throughout a write-transaction, dbFileSize contains the size of
|
||||||
// ** the file on disk in pages. It is set to a copy of dbSize when the
|
** the file on disk in pages. It is set to a copy of dbSize when the
|
||||||
// ** write-transaction is first opened, and updated when VFS calls are made
|
** write-transaction is first opened, and updated when VFS calls are made
|
||||||
// ** to write or truncate the database file on disk.
|
** to write or truncate the database file on disk.
|
||||||
// **
|
**
|
||||||
// ** The only reason the dbFileSize variable is required is to suppress
|
** The only reason the dbFileSize variable is required is to suppress
|
||||||
// ** unnecessary calls to xTruncate() after committing a transaction. If,
|
** unnecessary calls to xTruncate() after committing a transaction. If,
|
||||||
// ** when a transaction is committed, the dbFileSize variable indicates
|
** when a transaction is committed, the dbFileSize variable indicates
|
||||||
// ** that the database file is larger than the database image (Pager.dbSize),
|
** that the database file is larger than the database image (Pager.dbSize),
|
||||||
// ** pager_truncate() is called. The pager_truncate() call uses xFilesize()
|
** pager_truncate() is called. The pager_truncate() call uses xFilesize()
|
||||||
// ** to measure the database file on disk, and then truncates it if required.
|
** to measure the database file on disk, and then truncates it if required.
|
||||||
// ** dbFileSize is not used when rolling back a transaction. In this case
|
** dbFileSize is not used when rolling back a transaction. In this case
|
||||||
// ** pager_truncate() is called unconditionally (which means there may be
|
** pager_truncate() is called unconditionally (which means there may be
|
||||||
// ** a call to xFilesize() that is not strictly required). In either case,
|
** a call to xFilesize() that is not strictly required). In either case,
|
||||||
// ** pager_truncate() may cause the file to become smaller or larger.
|
** pager_truncate() may cause the file to become smaller or larger.
|
||||||
// **
|
**
|
||||||
// ** dbHintSize
|
** dbHintSize
|
||||||
// **
|
**
|
||||||
// ** The dbHintSize variable is used to limit the number of calls made to
|
** The dbHintSize variable is used to limit the number of calls made to
|
||||||
// ** the VFS xFileControl(FCNTL_SIZE_HINT) method.
|
** the VFS xFileControl(FCNTL_SIZE_HINT) method.
|
||||||
// **
|
**
|
||||||
// ** dbHintSize is set to a copy of the dbSize variable when a
|
** dbHintSize is set to a copy of the dbSize variable when a
|
||||||
// ** write-transaction is opened (at the same time as dbFileSize and
|
** write-transaction is opened (at the same time as dbFileSize and
|
||||||
// ** dbOrigSize). If the xFileControl(FCNTL_SIZE_HINT) method is called,
|
** dbOrigSize). If the xFileControl(FCNTL_SIZE_HINT) method is called,
|
||||||
// ** dbHintSize is increased to the number of pages that correspond to the
|
** dbHintSize is increased to the number of pages that correspond to the
|
||||||
// ** size-hint passed to the method call. See pager_write_pagelist() for
|
** size-hint passed to the method call. See pager_write_pagelist() for
|
||||||
// ** details.
|
** details.
|
||||||
// **
|
**
|
||||||
// ** errCode
|
** errCode
|
||||||
// **
|
**
|
||||||
// ** The Pager.errCode variable is only ever used in PAGER_ERROR state. It
|
** The Pager.errCode variable is only ever used in PAGER_ERROR state. It
|
||||||
// ** is set to zero in all other states. In PAGER_ERROR state, Pager.errCode
|
** is set to zero in all other states. In PAGER_ERROR state, Pager.errCode
|
||||||
// ** is always set to SQLITE_FULL, SQLITE_IOERR or one of the SQLITE_IOERR_XXX
|
** is always set to SQLITE_FULL, SQLITE_IOERR or one of the SQLITE_IOERR_XXX
|
||||||
// ** sub-codes.
|
** sub-codes.
|
||||||
// **
|
**
|
||||||
// ** syncFlags, walSyncFlags
|
** syncFlags, walSyncFlags
|
||||||
// **
|
**
|
||||||
// ** syncFlags is either SQLITE_SYNC_NORMAL (0x02) or SQLITE_SYNC_FULL (0x03).
|
** syncFlags is either SQLITE_SYNC_NORMAL (0x02) or SQLITE_SYNC_FULL (0x03).
|
||||||
// ** syncFlags is used for rollback mode. walSyncFlags is used for WAL mode
|
** syncFlags is used for rollback mode. walSyncFlags is used for WAL mode
|
||||||
// ** and contains the flags used to sync the checkpoint operations in the
|
** and contains the flags used to sync the checkpoint operations in the
|
||||||
// ** lower two bits, and sync flags used for transaction commits in the WAL
|
** lower two bits, and sync flags used for transaction commits in the WAL
|
||||||
// ** file in bits 0x04 and 0x08. In other words, to get the correct sync flags
|
** file in bits 0x04 and 0x08. In other words, to get the correct sync flags
|
||||||
// ** for checkpoint operations, use (walSyncFlags&0x03) and to get the correct
|
** for checkpoint operations, use (walSyncFlags&0x03) and to get the correct
|
||||||
// ** sync flags for transaction commit, use ((walSyncFlags>>2)&0x03). Note
|
** sync flags for transaction commit, use ((walSyncFlags>>2)&0x03). Note
|
||||||
// ** that with synchronous=NORMAL in WAL mode, transaction commit is not synced
|
** that with synchronous=NORMAL in WAL mode, transaction commit is not synced
|
||||||
// ** meaning that the 0x04 and 0x08 bits are both zero.
|
** meaning that the 0x04 and 0x08 bits are both zero.
|
||||||
// */
|
*/
|
||||||
// struct Pager {
|
struct Pager {
|
||||||
// sqlite3_vfs *pVfs; /* OS functions to use for IO */
|
// sqlite3_vfs *pVfs; /* OS functions to use for IO */
|
||||||
// u8 exclusiveMode; /* Boolean. True if locking_mode==EXCLUSIVE */
|
// u8 exclusiveMode; /* Boolean. True if locking_mode==EXCLUSIVE */
|
||||||
// u8 journalMode; /* One of the PAGER_JOURNALMODE_* values */
|
// u8 journalMode; /* One of the PAGER_JOURNALMODE_* values */
|
||||||
|
@ -698,7 +696,7 @@
|
||||||
// Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */
|
// Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */
|
||||||
// char *zWal; /* File name for write-ahead log */
|
// char *zWal; /* File name for write-ahead log */
|
||||||
// #endif
|
// #endif
|
||||||
// };
|
};
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains
|
// ** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains
|
||||||
|
@ -724,8 +722,6 @@
|
||||||
// # define PAGER_INCR(v)
|
// # define PAGER_INCR(v)
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** Journal files begin with the following magic string. The data
|
// ** Journal files begin with the following magic string. The data
|
||||||
// ** was obtained from /dev/random. It is used only as a sanity check.
|
// ** was obtained from /dev/random. It is used only as a sanity check.
|
||||||
|
@ -1110,7 +1106,6 @@
|
||||||
// */
|
// */
|
||||||
// #define put32bits(A,B) sqlite3Put4byte((u8*)A,B)
|
// #define put32bits(A,B) sqlite3Put4byte((u8*)A,B)
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** Write a 32-bit integer into the given file descriptor. Return SQLITE_OK
|
// ** Write a 32-bit integer into the given file descriptor. Return SQLITE_OK
|
||||||
// ** on success or an error code is something goes wrong.
|
// ** on success or an error code is something goes wrong.
|
||||||
|
@ -1658,7 +1653,6 @@
|
||||||
// return rc;
|
// return rc;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** Write the supplied super-journal name into the journal file for pager
|
// ** Write the supplied super-journal name into the journal file for pager
|
||||||
// ** pPager at the current location. The super-journal name must be the last
|
// ** pPager at the current location. The super-journal name must be the last
|
||||||
|
@ -2578,7 +2572,6 @@
|
||||||
// return rc;
|
// return rc;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** This function is used to change the actual size of the database
|
// ** This function is used to change the actual size of the database
|
||||||
// ** file in the file-system. This only happens when committing a transaction,
|
// ** file in the file-system. This only happens when committing a transaction,
|
||||||
|
@ -2946,7 +2939,6 @@
|
||||||
// return rc;
|
// return rc;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** Read the content for page pPg out of the database file (or out of
|
// ** Read the content for page pPg out of the database file (or out of
|
||||||
// ** the WAL if that is where the most recent copy if found) into
|
// ** the WAL if that is where the most recent copy if found) into
|
||||||
|
@ -3857,7 +3849,6 @@
|
||||||
// *pnPage = (int)pPager->dbSize;
|
// *pnPage = (int)pPager->dbSize;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** Try to obtain a lock of type locktype on the database file. If
|
// ** Try to obtain a lock of type locktype on the database file. If
|
||||||
// ** a similar or greater lock is already held, this function is a no-op
|
// ** a similar or greater lock is already held, this function is a no-op
|
||||||
|
@ -3953,7 +3944,6 @@
|
||||||
// ** is no longer correct. */
|
// ** is no longer correct. */
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** This function is called before attempting a hot-journal rollback. It
|
// ** This function is called before attempting a hot-journal rollback. It
|
||||||
// ** syncs the journal file to disk, then sets pPager->journalHdr to the
|
// ** syncs the journal file to disk, then sets pPager->journalHdr to the
|
||||||
|
@ -4080,22 +4070,21 @@
|
||||||
// return rc;
|
// return rc;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/*
|
||||||
// /*
|
** Shutdown the page cache. Free all memory and close all files.
|
||||||
// ** Shutdown the page cache. Free all memory and close all files.
|
**
|
||||||
// **
|
** If a transaction was in progress when this routine is called, that
|
||||||
// ** If a transaction was in progress when this routine is called, that
|
** transaction is rolled back. All outstanding pages are invalidated
|
||||||
// ** transaction is rolled back. All outstanding pages are invalidated
|
** and their memory is freed. Any attempt to use a page associated
|
||||||
// ** and their memory is freed. Any attempt to use a page associated
|
** with this page cache after this function returns will likely
|
||||||
// ** with this page cache after this function returns will likely
|
** result in a coredump.
|
||||||
// ** result in a coredump.
|
**
|
||||||
// **
|
** This function always succeeds. If a transaction is active an attempt
|
||||||
// ** This function always succeeds. If a transaction is active an attempt
|
** is made to roll it back. If an error occurs during the rollback
|
||||||
// ** is made to roll it back. If an error occurs during the rollback
|
** a hot journal may be left in the filesystem but no error is returned
|
||||||
// ** a hot journal may be left in the filesystem but no error is returned
|
** to the caller.
|
||||||
// ** to the caller.
|
*/
|
||||||
// */
|
int sqlite3PagerClose(Pager *pPager, sqlite3 *db) {
|
||||||
// int sqlite3PagerClose(Pager *pPager, sqlite3 *db){
|
|
||||||
// u8 *pTmp = (u8*)pPager->pTmpSpace;
|
// u8 *pTmp = (u8*)pPager->pTmpSpace;
|
||||||
// assert( db || pagerUseWal(pPager)==0 );
|
// assert( db || pagerUseWal(pPager)==0 );
|
||||||
// assert( assert_pager_state(pPager) );
|
// assert( assert_pager_state(pPager) );
|
||||||
|
@ -4149,8 +4138,8 @@
|
||||||
// assert( !isOpen(pPager->jfd) && !isOpen(pPager->sjfd) );
|
// assert( !isOpen(pPager->jfd) && !isOpen(pPager->sjfd) );
|
||||||
|
|
||||||
// sqlite3_free(pPager);
|
// sqlite3_free(pPager);
|
||||||
// return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #if !defined(NDEBUG) || defined(SQLITE_TEST)
|
// #if !defined(NDEBUG) || defined(SQLITE_TEST)
|
||||||
// /*
|
// /*
|
||||||
|
@ -4620,47 +4609,46 @@
|
||||||
// return rc;
|
// return rc;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /*
|
/*
|
||||||
// ** Allocate and initialize a new Pager object and put a pointer to it
|
** Allocate and initialize a new Pager object and put a pointer to it
|
||||||
// ** in *ppPager. The pager should eventually be freed by passing it
|
** in *ppPager. The pager should eventually be freed by passing it
|
||||||
// ** to sqlite3PagerClose().
|
** to sqlite3PagerClose().
|
||||||
// **
|
**
|
||||||
// ** The zFilename argument is the path to the database file to open.
|
** The zFilename argument is the path to the database file to open.
|
||||||
// ** If zFilename is NULL then a randomly-named temporary file is created
|
** If zFilename is NULL then a randomly-named temporary file is created
|
||||||
// ** and used as the file to be cached. Temporary files are be deleted
|
** and used as the file to be cached. Temporary files are be deleted
|
||||||
// ** automatically when they are closed. If zFilename is ":memory:" then
|
** automatically when they are closed. If zFilename is ":memory:" then
|
||||||
// ** all information is held in cache. It is never written to disk.
|
** all information is held in cache. It is never written to disk.
|
||||||
// ** This can be used to implement an in-memory database.
|
** This can be used to implement an in-memory database.
|
||||||
// **
|
**
|
||||||
// ** The nExtra parameter specifies the number of bytes of space allocated
|
** The nExtra parameter specifies the number of bytes of space allocated
|
||||||
// ** along with each page reference. This space is available to the user
|
** along with each page reference. This space is available to the user
|
||||||
// ** via the sqlite3PagerGetExtra() API. When a new page is allocated, the
|
** via the sqlite3PagerGetExtra() API. When a new page is allocated, the
|
||||||
// ** first 8 bytes of this space are zeroed but the remainder is uninitialized.
|
** first 8 bytes of this space are zeroed but the remainder is uninitialized.
|
||||||
// ** (The extra space is used by btree as the MemPage object.)
|
** (The extra space is used by btree as the MemPage object.)
|
||||||
// **
|
**
|
||||||
// ** The flags argument is used to specify properties that affect the
|
** The flags argument is used to specify properties that affect the
|
||||||
// ** operation of the pager. It should be passed some bitwise combination
|
** operation of the pager. It should be passed some bitwise combination
|
||||||
// ** of the PAGER_* flags.
|
** of the PAGER_* flags.
|
||||||
// **
|
**
|
||||||
// ** The vfsFlags parameter is a bitmask to pass to the flags parameter
|
** The vfsFlags parameter is a bitmask to pass to the flags parameter
|
||||||
// ** of the xOpen() method of the supplied VFS when opening files.
|
** of the xOpen() method of the supplied VFS when opening files.
|
||||||
// **
|
**
|
||||||
// ** If the pager object is allocated and the specified file opened
|
** If the pager object is allocated and the specified file opened
|
||||||
// ** successfully, SQLITE_OK is returned and *ppPager set to point to
|
** successfully, SQLITE_OK is returned and *ppPager set to point to
|
||||||
// ** the new pager object. If an error occurs, *ppPager is set to NULL
|
** the new pager object. If an error occurs, *ppPager is set to NULL
|
||||||
// ** and error code returned. This function may return SQLITE_NOMEM
|
** and error code returned. This function may return SQLITE_NOMEM
|
||||||
// ** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or
|
** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or
|
||||||
// ** various SQLITE_IO_XXX errors.
|
** various SQLITE_IO_XXX errors.
|
||||||
// */
|
*/
|
||||||
// int sqlite3PagerOpen(
|
int sqlite3PagerOpen(sqlite3_vfs *pVfs, /* The virtual file system to use */
|
||||||
// sqlite3_vfs *pVfs, /* The virtual file system to use */
|
Pager ** ppPager, /* OUT: Return the Pager structure here */
|
||||||
// Pager **ppPager, /* OUT: Return the Pager structure here */
|
const char * zFilename, /* Name of the database file to open */
|
||||||
// const char *zFilename, /* Name of the database file to open */
|
int nExtra, /* Extra bytes append to each in-memory page */
|
||||||
// int nExtra, /* Extra bytes append to each in-memory page */
|
int flags, /* flags controlling this file */
|
||||||
// int flags, /* flags controlling this file */
|
int vfsFlags, /* flags passed through to sqlite3_vfs.xOpen() */
|
||||||
// int vfsFlags, /* flags passed through to sqlite3_vfs.xOpen() */
|
void (*xReinit)(DbPage *) /* Function to reinitialize pages */
|
||||||
// void (*xReinit)(DbPage*) /* Function to reinitialize pages */
|
) {
|
||||||
// ){
|
|
||||||
// u8 *pPtr;
|
// u8 *pPtr;
|
||||||
// Pager *pPager = 0; /* Pager object to allocate and return */
|
// Pager *pPager = 0; /* Pager object to allocate and return */
|
||||||
// int rc = SQLITE_OK; /* Return code */
|
// int rc = SQLITE_OK; /* Return code */
|
||||||
|
@ -4831,7 +4819,6 @@
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /* Fill in Pager.zJournal */
|
// /* Fill in Pager.zJournal */
|
||||||
// if( nPathname>0 ){
|
// if( nPathname>0 ){
|
||||||
// pPager->zJournal = (char*)pPtr;
|
// pPager->zJournal = (char*)pPtr;
|
||||||
|
@ -5016,8 +5003,8 @@
|
||||||
// /* pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c */
|
// /* pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c */
|
||||||
|
|
||||||
// *ppPager = pPager;
|
// *ppPager = pPager;
|
||||||
// return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** Return the sqlite3_file for the main database given the name
|
// ** Return the sqlite3_file for the main database given the name
|
||||||
|
@ -5033,7 +5020,6 @@
|
||||||
// return pPager->fd;
|
// return pPager->fd;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** This function is called after transitioning from PAGER_UNLOCK to
|
// ** This function is called after transitioning from PAGER_UNLOCK to
|
||||||
// ** PAGER_SHARED state. It tests if there is a hot journal present in
|
// ** PAGER_SHARED state. It tests if there is a hot journal present in
|
||||||
|
@ -5650,7 +5636,6 @@
|
||||||
// return pPager->errCode;
|
// return pPager->errCode;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /* Dispatch all page fetch requests to the appropriate getter method.
|
// /* Dispatch all page fetch requests to the appropriate getter method.
|
||||||
// */
|
// */
|
||||||
// int sqlite3PagerGet(
|
// int sqlite3PagerGet(
|
||||||
|
@ -5790,7 +5775,6 @@
|
||||||
// assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
|
// assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /* Write the first journal header to the journal file and open
|
// /* Write the first journal header to the journal file and open
|
||||||
// ** the sub-journal if necessary.
|
// ** the sub-journal if necessary.
|
||||||
// */
|
// */
|
||||||
|
@ -6589,7 +6573,6 @@
|
||||||
// return rc;
|
// return rc;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** When this function is called, the database file has been completely
|
// ** When this function is called, the database file has been completely
|
||||||
// ** updated to reflect the changes made by the current transaction and
|
// ** updated to reflect the changes made by the current transaction and
|
||||||
|
@ -6879,7 +6862,6 @@
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** This function is called to rollback or release (commit) a savepoint.
|
// ** This function is called to rollback or release (commit) a savepoint.
|
||||||
// ** The savepoint to release or rollback need not be the most recently
|
// ** The savepoint to release or rollback need not be the most recently
|
||||||
|
@ -7401,7 +7383,6 @@
|
||||||
// }
|
// }
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
// #ifndef SQLITE_OMIT_WAL
|
// #ifndef SQLITE_OMIT_WAL
|
||||||
// /*
|
// /*
|
||||||
// ** This function is called when the user invokes "PRAGMA wal_checkpoint",
|
// ** This function is called when the user invokes "PRAGMA wal_checkpoint",
|
||||||
|
@ -7496,7 +7477,6 @@
|
||||||
// return rc;
|
// return rc;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// ** The caller must be holding a SHARED lock on the database file to call
|
// ** The caller must be holding a SHARED lock on the database file to call
|
||||||
// ** this function.
|
// ** this function.
|
||||||
|
|
|
@ -46,6 +46,8 @@ typedef struct sqlite3_pcache_page {
|
||||||
typedef struct sqlite3_vfs sqlite3_vfs;
|
typedef struct sqlite3_vfs sqlite3_vfs;
|
||||||
typedef struct sqlite3 sqlite3;
|
typedef struct sqlite3 sqlite3;
|
||||||
|
|
||||||
|
#define SQLITE_DEFAULT_PAGE_SIZE 4096
|
||||||
|
|
||||||
#include "pager.h"
|
#include "pager.h"
|
||||||
|
|
||||||
#include "pcache.h"
|
#include "pcache.h"
|
||||||
|
|
Loading…
Reference in New Issue