1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Generalize the in-memory journal so that it is able to accept writes that

begin at any offset less than or equal to the current file size.

FossilOrigin-Name: c039d5476e0836c16d8c1ad99a2620f7fd04eb4b0e5dcb2246b42dde2ae1f95a
This commit is contained in:
drh
2022-02-14 21:11:17 +00:00
parent 7d5113f0a3
commit e63b7bdac8
4 changed files with 19 additions and 24 deletions

View File

@@ -178,6 +178,9 @@ static int memjrnlCreateFile(MemJournal *p){
}
/* Forward reference */
static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size);
/*
** Write data to the file.
*/
@@ -207,18 +210,15 @@ static int memjrnlWrite(
** access writes are not required. The only exception to this is when
** the in-memory journal is being used by a connection using the
** atomic-write optimization. In this case the first 28 bytes of the
** journal file may be written as part of committing the transaction. */
assert( iOfst==p->endpoint.iOffset || iOfst==0 );
#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \
|| defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
** journal file may be written as part of committing the transaction. */
assert( iOfst<=p->endpoint.iOffset );
if( iOfst>0 && iOfst!=p->endpoint.iOffset ){
memjrnlTruncate(pJfd, iOfst);
}
if( iOfst==0 && p->pFirst ){
assert( p->nChunkSize>iAmt );
memcpy((u8*)p->pFirst->zChunk, zBuf, iAmt);
}else
#else
assert( iOfst>0 || p->pFirst==0 );
#endif
{
}else{
while( nWrite>0 ){
FileChunk *pChunk = p->endpoint.pChunk;
int iChunkOffset = (int)(p->endpoint.iOffset%p->nChunkSize);