Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: third_party/sqlite/src/src/memjournal.c

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/src/mem5.c ('k') | third_party/sqlite/src/src/msvc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ** 2008 October 7 2 ** 2008 October 7
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
11 ************************************************************************* 11 *************************************************************************
12 ** 12 **
13 ** This file contains code use to implement an in-memory rollback journal. 13 ** This file contains code use to implement an in-memory rollback journal.
14 ** The in-memory rollback journal is used to journal transactions for 14 ** The in-memory rollback journal is used to journal transactions for
15 ** ":memory:" databases and when the journal_mode=MEMORY pragma is used. 15 ** ":memory:" databases and when the journal_mode=MEMORY pragma is used.
16 **
17 ** Update: The in-memory journal is also used to temporarily cache
18 ** smaller journals that are not critical for power-loss recovery.
19 ** For example, statement journals that are not too big will be held
20 ** entirely in memory, thus reducing the number of file I/O calls, and
21 ** more importantly, reducing temporary file creation events. If these
22 ** journals become too large for memory, they are spilled to disk. But
23 ** in the common case, they are usually small and no file I/O needs to
24 ** occur.
16 */ 25 */
17 #include "sqliteInt.h" 26 #include "sqliteInt.h"
18 27
19 /* Forward references to internal structures */ 28 /* Forward references to internal structures */
20 typedef struct MemJournal MemJournal; 29 typedef struct MemJournal MemJournal;
21 typedef struct FilePoint FilePoint; 30 typedef struct FilePoint FilePoint;
22 typedef struct FileChunk FileChunk; 31 typedef struct FileChunk FileChunk;
23 32
24 /* Space to hold the rollback journal is allocated in increments of
25 ** this many bytes.
26 **
27 ** The size chosen is a little less than a power of two. That way,
28 ** the FileChunk object will have a size that almost exactly fills
29 ** a power-of-two allocation. This minimizes wasted space in power-of-two
30 ** memory allocators.
31 */
32 #define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*)))
33
34 /* 33 /*
35 ** The rollback journal is composed of a linked list of these structures. 34 ** The rollback journal is composed of a linked list of these structures.
35 **
36 ** The zChunk array is always at least 8 bytes in size - usually much more.
37 ** Its actual size is stored in the MemJournal.nChunkSize variable.
36 */ 38 */
37 struct FileChunk { 39 struct FileChunk {
38 FileChunk *pNext; /* Next chunk in the journal */ 40 FileChunk *pNext; /* Next chunk in the journal */
39 u8 zChunk[JOURNAL_CHUNKSIZE]; /* Content of this chunk */ 41 u8 zChunk[8]; /* Content of this chunk */
40 }; 42 };
41 43
42 /* 44 /*
45 ** By default, allocate this many bytes of memory for each FileChunk object.
46 */
47 #define MEMJOURNAL_DFLT_FILECHUNKSIZE 1024
48
49 /*
50 ** For chunk size nChunkSize, return the number of bytes that should
51 ** be allocated for each FileChunk structure.
52 */
53 #define fileChunkSize(nChunkSize) (sizeof(FileChunk) + ((nChunkSize)-8))
54
55 /*
43 ** An instance of this object serves as a cursor into the rollback journal. 56 ** An instance of this object serves as a cursor into the rollback journal.
44 ** The cursor can be either for reading or writing. 57 ** The cursor can be either for reading or writing.
45 */ 58 */
46 struct FilePoint { 59 struct FilePoint {
47 sqlite3_int64 iOffset; /* Offset from the beginning of the file */ 60 sqlite3_int64 iOffset; /* Offset from the beginning of the file */
48 FileChunk *pChunk; /* Specific chunk into which cursor points */ 61 FileChunk *pChunk; /* Specific chunk into which cursor points */
49 }; 62 };
50 63
51 /* 64 /*
52 ** This subclass is a subclass of sqlite3_file. Each open memory-journal 65 ** This structure is a subclass of sqlite3_file. Each open memory-journal
53 ** is an instance of this class. 66 ** is an instance of this class.
54 */ 67 */
55 struct MemJournal { 68 struct MemJournal {
56 sqlite3_io_methods *pMethod; /* Parent class. MUST BE FIRST */ 69 const sqlite3_io_methods *pMethod; /* Parent class. MUST BE FIRST */
70 int nChunkSize; /* In-memory chunk-size */
71
72 int nSpill; /* Bytes of data before flushing */
73 int nSize; /* Bytes of data currently in memory */
57 FileChunk *pFirst; /* Head of in-memory chunk-list */ 74 FileChunk *pFirst; /* Head of in-memory chunk-list */
58 FilePoint endpoint; /* Pointer to the end of the file */ 75 FilePoint endpoint; /* Pointer to the end of the file */
59 FilePoint readpoint; /* Pointer to the end of the last xRead() */ 76 FilePoint readpoint; /* Pointer to the end of the last xRead() */
77
78 int flags; /* xOpen flags */
79 sqlite3_vfs *pVfs; /* The "real" underlying VFS */
80 const char *zJournal; /* Name of the journal file */
60 }; 81 };
61 82
62 /* 83 /*
63 ** Read data from the in-memory journal file. This is the implementation 84 ** Read data from the in-memory journal file. This is the implementation
64 ** of the sqlite3_vfs.xRead method. 85 ** of the sqlite3_vfs.xRead method.
65 */ 86 */
66 static int memjrnlRead( 87 static int memjrnlRead(
67 sqlite3_file *pJfd, /* The journal file from which to read */ 88 sqlite3_file *pJfd, /* The journal file from which to read */
68 void *zBuf, /* Put the results here */ 89 void *zBuf, /* Put the results here */
69 int iAmt, /* Number of bytes to read */ 90 int iAmt, /* Number of bytes to read */
70 sqlite_int64 iOfst /* Begin reading at this offset */ 91 sqlite_int64 iOfst /* Begin reading at this offset */
71 ){ 92 ){
72 MemJournal *p = (MemJournal *)pJfd; 93 MemJournal *p = (MemJournal *)pJfd;
73 u8 *zOut = zBuf; 94 u8 *zOut = zBuf;
74 int nRead = iAmt; 95 int nRead = iAmt;
75 int iChunkOffset; 96 int iChunkOffset;
76 FileChunk *pChunk; 97 FileChunk *pChunk;
77 98
78 /* SQLite never tries to read past the end of a rollback journal file */ 99 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
79 assert( iOfst+iAmt<=p->endpoint.iOffset ); 100 if( (iAmt+iOfst)>p->endpoint.iOffset ){
101 return SQLITE_IOERR_SHORT_READ;
102 }
103 #endif
80 104
105 assert( (iAmt+iOfst)<=p->endpoint.iOffset );
106 assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 );
81 if( p->readpoint.iOffset!=iOfst || iOfst==0 ){ 107 if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
82 sqlite3_int64 iOff = 0; 108 sqlite3_int64 iOff = 0;
83 for(pChunk=p->pFirst; 109 for(pChunk=p->pFirst;
84 ALWAYS(pChunk) && (iOff+JOURNAL_CHUNKSIZE)<=iOfst; 110 ALWAYS(pChunk) && (iOff+p->nChunkSize)<=iOfst;
85 pChunk=pChunk->pNext 111 pChunk=pChunk->pNext
86 ){ 112 ){
87 iOff += JOURNAL_CHUNKSIZE; 113 iOff += p->nChunkSize;
88 } 114 }
89 }else{ 115 }else{
90 pChunk = p->readpoint.pChunk; 116 pChunk = p->readpoint.pChunk;
117 assert( pChunk!=0 );
91 } 118 }
92 119
93 iChunkOffset = (int)(iOfst%JOURNAL_CHUNKSIZE); 120 iChunkOffset = (int)(iOfst%p->nChunkSize);
94 do { 121 do {
95 int iSpace = JOURNAL_CHUNKSIZE - iChunkOffset; 122 int iSpace = p->nChunkSize - iChunkOffset;
96 int nCopy = MIN(nRead, (JOURNAL_CHUNKSIZE - iChunkOffset)); 123 int nCopy = MIN(nRead, (p->nChunkSize - iChunkOffset));
97 memcpy(zOut, &pChunk->zChunk[iChunkOffset], nCopy); 124 memcpy(zOut, (u8*)pChunk->zChunk + iChunkOffset, nCopy);
98 zOut += nCopy; 125 zOut += nCopy;
99 nRead -= iSpace; 126 nRead -= iSpace;
100 iChunkOffset = 0; 127 iChunkOffset = 0;
101 } while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 ); 128 } while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );
102 p->readpoint.iOffset = iOfst+iAmt; 129 p->readpoint.iOffset = pChunk ? iOfst+iAmt : 0;
103 p->readpoint.pChunk = pChunk; 130 p->readpoint.pChunk = pChunk;
104 131
105 return SQLITE_OK; 132 return SQLITE_OK;
106 } 133 }
107 134
108 /* 135 /*
136 ** Free the list of FileChunk structures headed at MemJournal.pFirst.
137 */
138 static void memjrnlFreeChunks(MemJournal *p){
139 FileChunk *pIter;
140 FileChunk *pNext;
141 for(pIter=p->pFirst; pIter; pIter=pNext){
142 pNext = pIter->pNext;
143 sqlite3_free(pIter);
144 }
145 p->pFirst = 0;
146 }
147
148 /*
149 ** Flush the contents of memory to a real file on disk.
150 */
151 static int memjrnlCreateFile(MemJournal *p){
152 int rc;
153 sqlite3_file *pReal = (sqlite3_file*)p;
154 MemJournal copy = *p;
155
156 memset(p, 0, sizeof(MemJournal));
157 rc = sqlite3OsOpen(copy.pVfs, copy.zJournal, pReal, copy.flags, 0);
158 if( rc==SQLITE_OK ){
159 int nChunk = copy.nChunkSize;
160 i64 iOff = 0;
161 FileChunk *pIter;
162 for(pIter=copy.pFirst; pIter; pIter=pIter->pNext){
163 if( iOff + nChunk > copy.endpoint.iOffset ){
164 nChunk = copy.endpoint.iOffset - iOff;
165 }
166 rc = sqlite3OsWrite(pReal, (u8*)pIter->zChunk, nChunk, iOff);
167 if( rc ) break;
168 iOff += nChunk;
169 }
170 if( rc==SQLITE_OK ){
171 /* No error has occurred. Free the in-memory buffers. */
172 memjrnlFreeChunks(&copy);
173 }
174 }
175 if( rc!=SQLITE_OK ){
176 /* If an error occurred while creating or writing to the file, restore
177 ** the original before returning. This way, SQLite uses the in-memory
178 ** journal data to roll back changes made to the internal page-cache
179 ** before this function was called. */
180 sqlite3OsClose(pReal);
181 *p = copy;
182 }
183 return rc;
184 }
185
186
187 /*
109 ** Write data to the file. 188 ** Write data to the file.
110 */ 189 */
111 static int memjrnlWrite( 190 static int memjrnlWrite(
112 sqlite3_file *pJfd, /* The journal file into which to write */ 191 sqlite3_file *pJfd, /* The journal file into which to write */
113 const void *zBuf, /* Take data to be written from here */ 192 const void *zBuf, /* Take data to be written from here */
114 int iAmt, /* Number of bytes to write */ 193 int iAmt, /* Number of bytes to write */
115 sqlite_int64 iOfst /* Begin writing at this offset into the file */ 194 sqlite_int64 iOfst /* Begin writing at this offset into the file */
116 ){ 195 ){
117 MemJournal *p = (MemJournal *)pJfd; 196 MemJournal *p = (MemJournal *)pJfd;
118 int nWrite = iAmt; 197 int nWrite = iAmt;
119 u8 *zWrite = (u8 *)zBuf; 198 u8 *zWrite = (u8 *)zBuf;
120 199
121 /* An in-memory journal file should only ever be appended to. Random 200 /* If the file should be created now, create it and write the new data
122 ** access writes are not required by sqlite. 201 ** into the file on disk. */
123 */ 202 if( p->nSpill>0 && (iAmt+iOfst)>p->nSpill ){
124 assert( iOfst==p->endpoint.iOffset ); 203 int rc = memjrnlCreateFile(p);
125 UNUSED_PARAMETER(iOfst); 204 if( rc==SQLITE_OK ){
205 rc = sqlite3OsWrite(pJfd, zBuf, iAmt, iOfst);
206 }
207 return rc;
208 }
126 209
127 while( nWrite>0 ){ 210 /* If the contents of this write should be stored in memory */
128 FileChunk *pChunk = p->endpoint.pChunk; 211 else{
129 int iChunkOffset = (int)(p->endpoint.iOffset%JOURNAL_CHUNKSIZE); 212 /* An in-memory journal file should only ever be appended to. Random
130 int iSpace = MIN(nWrite, JOURNAL_CHUNKSIZE - iChunkOffset); 213 ** access writes are not required. The only exception to this is when
214 ** the in-memory journal is being used by a connection using the
215 ** atomic-write optimization. In this case the first 28 bytes of the
216 ** journal file may be written as part of committing the transaction. */
217 assert( iOfst==p->endpoint.iOffset || iOfst==0 );
218 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
219 if( iOfst==0 && p->pFirst ){
220 assert( p->nChunkSize>iAmt );
221 memcpy((u8*)p->pFirst->zChunk, zBuf, iAmt);
222 }else
223 #else
224 assert( iOfst>0 || p->pFirst==0 );
225 #endif
226 {
227 while( nWrite>0 ){
228 FileChunk *pChunk = p->endpoint.pChunk;
229 int iChunkOffset = (int)(p->endpoint.iOffset%p->nChunkSize);
230 int iSpace = MIN(nWrite, p->nChunkSize - iChunkOffset);
131 231
132 if( iChunkOffset==0 ){ 232 if( iChunkOffset==0 ){
133 /* New chunk is required to extend the file. */ 233 /* New chunk is required to extend the file. */
134 FileChunk *pNew = sqlite3_malloc(sizeof(FileChunk)); 234 FileChunk *pNew = sqlite3_malloc(fileChunkSize(p->nChunkSize));
135 if( !pNew ){ 235 if( !pNew ){
136 return SQLITE_IOERR_NOMEM; 236 return SQLITE_IOERR_NOMEM_BKPT;
237 }
238 pNew->pNext = 0;
239 if( pChunk ){
240 assert( p->pFirst );
241 pChunk->pNext = pNew;
242 }else{
243 assert( !p->pFirst );
244 p->pFirst = pNew;
245 }
246 p->endpoint.pChunk = pNew;
247 }
248
249 memcpy((u8*)p->endpoint.pChunk->zChunk + iChunkOffset, zWrite, iSpace);
250 zWrite += iSpace;
251 nWrite -= iSpace;
252 p->endpoint.iOffset += iSpace;
137 } 253 }
138 pNew->pNext = 0; 254 p->nSize = iAmt + iOfst;
139 if( pChunk ){
140 assert( p->pFirst );
141 pChunk->pNext = pNew;
142 }else{
143 assert( !p->pFirst );
144 p->pFirst = pNew;
145 }
146 p->endpoint.pChunk = pNew;
147 } 255 }
148
149 memcpy(&p->endpoint.pChunk->zChunk[iChunkOffset], zWrite, iSpace);
150 zWrite += iSpace;
151 nWrite -= iSpace;
152 p->endpoint.iOffset += iSpace;
153 } 256 }
154 257
155 return SQLITE_OK; 258 return SQLITE_OK;
156 } 259 }
157 260
158 /* 261 /*
159 ** Truncate the file. 262 ** Truncate the file.
263 **
264 ** If the journal file is already on disk, truncate it there. Or, if it
265 ** is still in main memory but is being truncated to zero bytes in size,
266 ** ignore
160 */ 267 */
161 static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){ 268 static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
162 MemJournal *p = (MemJournal *)pJfd; 269 MemJournal *p = (MemJournal *)pJfd;
163 FileChunk *pChunk; 270 if( ALWAYS(size==0) ){
164 assert(size==0); 271 memjrnlFreeChunks(p);
165 UNUSED_PARAMETER(size); 272 p->nSize = 0;
166 pChunk = p->pFirst; 273 p->endpoint.pChunk = 0;
167 while( pChunk ){ 274 p->endpoint.iOffset = 0;
168 FileChunk *pTmp = pChunk; 275 p->readpoint.pChunk = 0;
169 pChunk = pChunk->pNext; 276 p->readpoint.iOffset = 0;
170 sqlite3_free(pTmp);
171 } 277 }
172 sqlite3MemJournalOpen(pJfd);
173 return SQLITE_OK; 278 return SQLITE_OK;
174 } 279 }
175 280
176 /* 281 /*
177 ** Close the file. 282 ** Close the file.
178 */ 283 */
179 static int memjrnlClose(sqlite3_file *pJfd){ 284 static int memjrnlClose(sqlite3_file *pJfd){
180 memjrnlTruncate(pJfd, 0); 285 MemJournal *p = (MemJournal *)pJfd;
286 memjrnlFreeChunks(p);
181 return SQLITE_OK; 287 return SQLITE_OK;
182 } 288 }
183 289
184
185 /* 290 /*
186 ** Sync the file. 291 ** Sync the file.
187 ** 292 **
188 ** Syncing an in-memory journal is a no-op. And, in fact, this routine 293 ** If the real file has been created, call its xSync method. Otherwise,
189 ** is never called in a working implementation. This implementation 294 ** syncing an in-memory journal is a no-op.
190 ** exists purely as a contingency, in case some malfunction in some other
191 ** part of SQLite causes Sync to be called by mistake.
192 */ 295 */
193 static int memjrnlSync(sqlite3_file *NotUsed, int NotUsed2){ 296 static int memjrnlSync(sqlite3_file *pJfd, int flags){
194 UNUSED_PARAMETER2(NotUsed, NotUsed2); 297 UNUSED_PARAMETER2(pJfd, flags);
195 return SQLITE_OK; 298 return SQLITE_OK;
196 } 299 }
197 300
198 /* 301 /*
199 ** Query the size of the file in bytes. 302 ** Query the size of the file in bytes.
200 */ 303 */
201 static int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){ 304 static int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){
202 MemJournal *p = (MemJournal *)pJfd; 305 MemJournal *p = (MemJournal *)pJfd;
203 *pSize = (sqlite_int64) p->endpoint.iOffset; 306 *pSize = (sqlite_int64) p->endpoint.iOffset;
204 return SQLITE_OK; 307 return SQLITE_OK;
(...skipping 18 matching lines...) Expand all
223 0, /* xDeviceCharacteristics */ 326 0, /* xDeviceCharacteristics */
224 0, /* xShmMap */ 327 0, /* xShmMap */
225 0, /* xShmLock */ 328 0, /* xShmLock */
226 0, /* xShmBarrier */ 329 0, /* xShmBarrier */
227 0, /* xShmUnmap */ 330 0, /* xShmUnmap */
228 0, /* xFetch */ 331 0, /* xFetch */
229 0 /* xUnfetch */ 332 0 /* xUnfetch */
230 }; 333 };
231 334
232 /* 335 /*
233 ** Open a journal file. 336 ** Open a journal file.
337 **
338 ** The behaviour of the journal file depends on the value of parameter
339 ** nSpill. If nSpill is 0, then the journal file is always create and
340 ** accessed using the underlying VFS. If nSpill is less than zero, then
341 ** all content is always stored in main-memory. Finally, if nSpill is a
342 ** positive value, then the journal file is initially created in-memory
343 ** but may be flushed to disk later on. In this case the journal file is
344 ** flushed to disk either when it grows larger than nSpill bytes in size,
345 ** or when sqlite3JournalCreate() is called.
234 */ 346 */
235 void sqlite3MemJournalOpen(sqlite3_file *pJfd){ 347 int sqlite3JournalOpen(
236 MemJournal *p = (MemJournal *)pJfd; 348 sqlite3_vfs *pVfs, /* The VFS to use for actual file I/O */
237 assert( EIGHT_BYTE_ALIGNMENT(p) ); 349 const char *zName, /* Name of the journal file */
238 memset(p, 0, sqlite3MemJournalSize()); 350 sqlite3_file *pJfd, /* Preallocated, blank file handle */
239 p->pMethod = (sqlite3_io_methods*)&MemJournalMethods; 351 int flags, /* Opening flags */
352 int nSpill /* Bytes buffered before opening the file */
353 ){
354 MemJournal *p = (MemJournal*)pJfd;
355
356 /* Zero the file-handle object. If nSpill was passed zero, initialize
357 ** it using the sqlite3OsOpen() function of the underlying VFS. In this
358 ** case none of the code in this module is executed as a result of calls
359 ** made on the journal file-handle. */
360 memset(p, 0, sizeof(MemJournal));
361 if( nSpill==0 ){
362 return sqlite3OsOpen(pVfs, zName, pJfd, flags, 0);
363 }
364
365 if( nSpill>0 ){
366 p->nChunkSize = nSpill;
367 }else{
368 p->nChunkSize = 8 + MEMJOURNAL_DFLT_FILECHUNKSIZE - sizeof(FileChunk);
369 assert( MEMJOURNAL_DFLT_FILECHUNKSIZE==fileChunkSize(p->nChunkSize) );
370 }
371
372 p->pMethod = (const sqlite3_io_methods*)&MemJournalMethods;
373 p->nSpill = nSpill;
374 p->flags = flags;
375 p->zJournal = zName;
376 p->pVfs = pVfs;
377 return SQLITE_OK;
240 } 378 }
241 379
242 /* 380 /*
243 ** Return true if the file-handle passed as an argument is 381 ** Open an in-memory journal file.
244 ** an in-memory journal
245 */ 382 */
246 int sqlite3IsMemJournal(sqlite3_file *pJfd){ 383 void sqlite3MemJournalOpen(sqlite3_file *pJfd){
247 return pJfd->pMethods==&MemJournalMethods; 384 sqlite3JournalOpen(0, 0, pJfd, 0, -1);
385 }
386
387 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
388 /*
389 ** If the argument p points to a MemJournal structure that is not an
390 ** in-memory-only journal file (i.e. is one that was opened with a +ve
391 ** nSpill parameter), and the underlying file has not yet been created,
392 ** create it now.
393 */
394 int sqlite3JournalCreate(sqlite3_file *p){
395 int rc = SQLITE_OK;
396 if( p->pMethods==&MemJournalMethods && ((MemJournal*)p)->nSpill>0 ){
397 rc = memjrnlCreateFile((MemJournal*)p);
398 }
399 return rc;
400 }
401 #endif
402
403 /*
404 ** The file-handle passed as the only argument is open on a journal file.
405 ** Return true if this "journal file" is currently stored in heap memory,
406 ** or false otherwise.
407 */
408 int sqlite3JournalIsInMemory(sqlite3_file *p){
409 return p->pMethods==&MemJournalMethods;
248 } 410 }
249 411
250 /* 412 /*
251 ** Return the number of bytes required to store a MemJournal file descriptor. 413 ** Return the number of bytes required to store a JournalFile that uses vfs
414 ** pVfs to create the underlying on-disk files.
252 */ 415 */
253 int sqlite3MemJournalSize(void){ 416 int sqlite3JournalSize(sqlite3_vfs *pVfs){
254 return sizeof(MemJournal); 417 return MAX(pVfs->szOsFile, (int)sizeof(MemJournal));
255 } 418 }
OLDNEW
« no previous file with comments | « third_party/sqlite/src/src/mem5.c ('k') | third_party/sqlite/src/src/msvc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698