1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Remove the unused journal.c source file (its function have been subsumed into

memjournal.c).  Refactor some of the names in memjournal.c.  No functional
changes.

FossilOrigin-Name: 5f2a262d3f6b1531001326faf1d3b3d92c20a30a
This commit is contained in:
drh
2016-03-05 15:35:09 +00:00
parent 65a7e769e7
commit c2f18adde5
8 changed files with 31 additions and 300 deletions

View File

@@ -60,7 +60,7 @@ struct MemJournal {
const sqlite3_io_methods *pMethod; /* Parent class. MUST BE FIRST */
int nChunkSize; /* In-memory chunk-size */
int nBuf; /* Bytes of data before flushing */
int nSpill; /* Bytes of data before flushing */
int nSize; /* Bytes of data currently in memory */
FileChunk *pFirst; /* Head of in-memory chunk-list */
FilePoint endpoint; /* Pointer to the end of the file */
@@ -137,7 +137,7 @@ static void memjrnlFreeChunks(MemJournal *p){
/*
** Flush the contents of memory to a real file on disk.
*/
static int createFile(MemJournal *p){
static int memjrnlCreateFile(MemJournal *p){
int rc = SQLITE_OK;
if( !p->pReal ){
sqlite3_file *pReal = (sqlite3_file *)&p[1];
@@ -192,8 +192,8 @@ static int memjrnlWrite(
}
/* If the file should be created now. */
else if( p->nBuf>0 && (iAmt+iOfst)>p->nBuf ){
int rc = createFile(p);
else if( p->nSpill>0 && (iAmt+iOfst)>p->nSpill ){
int rc = memjrnlCreateFile(p);
if( rc==SQLITE_OK ){
rc = memjrnlWrite(pJfd, zBuf, iAmt, iOfst);
}
@@ -333,12 +333,12 @@ static const struct sqlite3_io_methods MemJournalMethods = {
** Open a journal file.
**
** The behaviour of the journal file depends on the value of parameter
** nBuf. If nBuf is 0, then the journal file is always create and
** accessed using the underlying VFS. If nBuf is less than zero, then
** all content is always stored in main-memory. Finally, if nBuf is a
** nSpill. If nSpill is 0, then the journal file is always create and
** accessed using the underlying VFS. If nSpill is less than zero, then
** all content is always stored in main-memory. Finally, if nSpill is a
** positive value, then the journal file is initially created in-memory
** but may be flushed to disk later on. In this case the journal file is
** flushed to disk either when it grows larger than nBuf bytes in size,
** flushed to disk either when it grows larger than nSpill bytes in size,
** or when sqlite3JournalCreate() is called.
*/
int sqlite3JournalOpen(
@@ -346,28 +346,28 @@ int sqlite3JournalOpen(
const char *zName, /* Name of the journal file */
sqlite3_file *pJfd, /* Preallocated, blank file handle */
int flags, /* Opening flags */
int nBuf /* Bytes buffered before opening the file */
int nSpill /* Bytes buffered before opening the file */
){
MemJournal *p = (MemJournal*)pJfd;
/* Zero the file-handle object. If nBuf was passed zero, initialize
/* Zero the file-handle object. If nSpill was passed zero, initialize
** it using the sqlite3OsOpen() function of the underlying VFS. In this
** case none of the code in this module is executed as a result of calls
** made on the journal file-handle. */
memset(p, 0, sizeof(MemJournal) + (pVfs ? pVfs->szOsFile : 0));
if( nBuf==0 ){
if( nSpill==0 ){
return sqlite3OsOpen(pVfs, zName, pJfd, flags, 0);
}
if( nBuf>0 ){
p->nChunkSize = nBuf;
if( nSpill>0 ){
p->nChunkSize = nSpill;
}else{
p->nChunkSize = 8 + MEMJOURNAL_DFLT_FILECHUNKSIZE - sizeof(FileChunk);
assert( MEMJOURNAL_DFLT_FILECHUNKSIZE==fileChunkSize(p->nChunkSize) );
}
p->pMethod = (const sqlite3_io_methods*)&MemJournalMethods;
p->nBuf = nBuf;
p->nSpill = nSpill;
p->flags = flags;
p->zJournal = zName;
p->pVfs = pVfs;
@@ -385,13 +385,13 @@ void sqlite3MemJournalOpen(sqlite3_file *pJfd){
/*
** If the argument p points to a MemJournal structure that is not an
** in-memory-only journal file (i.e. is one that was opened with a +ve
** nBuf parameter), and the underlying file has not yet been created,
** nSpill parameter), and the underlying file has not yet been created,
** create it now.
*/
int sqlite3JournalCreate(sqlite3_file *p){
int rc = SQLITE_OK;
if( p->pMethods==&MemJournalMethods && ((MemJournal*)p)->nBuf>0 ){
rc = createFile((MemJournal*)p);
if( p->pMethods==&MemJournalMethods && ((MemJournal*)p)->nSpill>0 ){
rc = memjrnlCreateFile((MemJournal*)p);
}
return rc;
}