mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Add function sqlite3OsFileControlNoFail(), which is the same as sqlite3OsFileControl() except that it does not simulate OOM errors. This saves adding calls to the BenignMalloc() functions around each of the invocations of sqliteOsFileControl() that ignore the return code.
FossilOrigin-Name: af59b182d797642e5ec3ddf291cf62662a136bd1
This commit is contained in:
22
manifest
22
manifest
@@ -1,5 +1,5 @@
|
||||
C Check\sthe\sreturn\scode\sfrom\ssqlite3OsFileControl()\sin\ssqlite3BtreeCopyFile()\nand\sreport\sany\serrors\sthat\sit\sgenerates.
|
||||
D 2012-01-10T16:40:50.339
|
||||
C Add\sfunction\ssqlite3OsFileControlNoFail(),\swhich\sis\sthe\ssame\sas\ssqlite3OsFileControl()\sexcept\sthat\sit\sdoes\snot\ssimulate\sOOM\serrors.\sThis\ssaves\sadding\scalls\sto\sthe\sBenignMalloc()\sfunctions\saround\seach\sof\sthe\sinvocations\sof\ssqliteOsFileControl()\sthat\signore\sthe\sreturn\scode.
|
||||
D 2012-01-10T16:56:39.621
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@@ -162,19 +162,19 @@ F src/mutex_os2.c 882d735098c07c8c6a5472b8dd66e19675fe117f
|
||||
F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc
|
||||
F src/mutex_w32.c 5e54f3ba275bcb5d00248b8c23107df2e2f73e33
|
||||
F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
|
||||
F src/os.c f03339a44ded105eafcd7185a420a51d51e0f6ee
|
||||
F src/os.h c7d888830f168a9b681b3aec30789f4ad2445c17
|
||||
F src/os.c dedfe4786cc4a88033bbf43fcf1fb01cbec03dcc
|
||||
F src/os.h 7a24446bcd9834d868b2bc303ec3bd38e64e04bc
|
||||
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
|
||||
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
|
||||
F src/os_unix.c 2ad4366b3c41dc813345d6dbb3cab97d62d60b96
|
||||
F src/os_win.c e344ccb73aaeb5caab2c3419fba2857f914198d7
|
||||
F src/pager.c 818ae6c440e7387690271d01b5764bc234cf3e92
|
||||
F src/pager.c e7c940ef4a3bad34c9c44ac429257fcf301b828f
|
||||
F src/pager.h 5cd760857707529b403837d813d86b68938d6183
|
||||
F src/parse.y fabb2e7047417d840e6fdb3ef0988a86849a08ba
|
||||
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
|
||||
F src/pcache.h b1d8775a9bddf44e65edb0d20bfc57a4982f840f
|
||||
F src/pcache1.c 281822d22265245b19f908cb3f5df725f7e11b06
|
||||
F src/pragma.c dd66f21fafe7be40e1a48ad4195764cc191cf583
|
||||
F src/pragma.c 492fabe0b360776354024a3372b96995e81910fb
|
||||
F src/prepare.c ec4989f7f480544bdc4192fe663470d2a2d7d61e
|
||||
F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699
|
||||
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
|
||||
@@ -250,7 +250,7 @@ F src/vdbemem.c 4f7d25d5ea2e2040254095b8f6de07f8dbbadf80
|
||||
F src/vdbesort.c 468d43c057063e54da4f1988b38b4f46d60e7790
|
||||
F src/vdbetrace.c d6e50e04e1ec498150e519058f617d91b8f5c843
|
||||
F src/vtab.c e9318d88feac85be8e27ee783ac8f5397933fc8a
|
||||
F src/wal.c 32dd3bda6aa6b2311af9269fcbadd42ffb2ceeea
|
||||
F src/wal.c 1e96783f757706e934cd9495f0c354c5bd63c2e9
|
||||
F src/wal.h eaa00b9a403ddda2b56d01b7afc19ef600f9363f
|
||||
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
|
||||
F src/where.c af623942514571895818b9b7ae11db95ae3b3d88
|
||||
@@ -986,7 +986,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
|
||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||
P 38bc4236d5a9d9f22a525bf9308d90cd4d9ce5a4
|
||||
R c4e25307d4fb90fb68174b26289cb5de
|
||||
U drh
|
||||
Z 18b8db42ef28aa8a6ef4ac91e374bf92
|
||||
P 7f852ac6435f1c9e25b07f816cca5ba40484579e
|
||||
R 0386e0f2452004fbea4274e17c048ecf
|
||||
U dan
|
||||
Z d0553b98b27ed93d2ef4aa9f634cdd90
|
||||
|
@@ -1 +1 @@
|
||||
7f852ac6435f1c9e25b07f816cca5ba40484579e
|
||||
af59b182d797642e5ec3ddf291cf62662a136bd1
|
5
src/os.c
5
src/os.c
@@ -101,6 +101,11 @@ int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){
|
||||
DO_OS_MALLOC_TEST(id);
|
||||
return id->pMethods->xFileControl(id, op, pArg);
|
||||
}
|
||||
#ifdef SQLITE_TEST
|
||||
int sqlite3OsFileControlNoFail(sqlite3_file *id, int op, void *pArg){
|
||||
return id->pMethods->xFileControl(id, op, pArg);
|
||||
}
|
||||
#endif
|
||||
int sqlite3OsSectorSize(sqlite3_file *id){
|
||||
int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;
|
||||
return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);
|
||||
|
6
src/os.h
6
src/os.h
@@ -260,6 +260,12 @@ int sqlite3OsShmLock(sqlite3_file *id, int, int, int);
|
||||
void sqlite3OsShmBarrier(sqlite3_file *id);
|
||||
int sqlite3OsShmUnmap(sqlite3_file *id, int);
|
||||
|
||||
#ifdef SQLITE_TEST
|
||||
int sqlite3OsFileControlNoFail(sqlite3_file*,int,void*);
|
||||
#else
|
||||
# define sqlite3OsFileControlNoFail(x,y,z) sqlite3OsFileControl(x,y,z)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Functions for accessing sqlite3_vfs methods
|
||||
*/
|
||||
|
@@ -2747,10 +2747,12 @@ end_playback:
|
||||
** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the
|
||||
** assertion that the transaction counter was modified.
|
||||
*/
|
||||
sqlite3BeginBenignMalloc();
|
||||
assert(
|
||||
pPager->fd->pMethods==0 ||
|
||||
sqlite3OsFileControl(pPager->fd,SQLITE_FCNTL_DB_UNCHANGED,0)>=SQLITE_OK
|
||||
sqlite3OsFileControlNoFail(pPager->fd,SQLITE_FCNTL_DB_UNCHANGED,0)>=0
|
||||
);
|
||||
sqlite3EndBenignMalloc();
|
||||
|
||||
/* If this playback is happening automatically as a result of an IO or
|
||||
** malloc error that occurred after the change-counter was updated but
|
||||
@@ -4029,9 +4031,7 @@ static int pager_write_pagelist(Pager *pPager, PgHdr *pList){
|
||||
assert( rc!=SQLITE_OK || isOpen(pPager->fd) );
|
||||
if( rc==SQLITE_OK && pPager->dbSize>pPager->dbHintSize ){
|
||||
sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;
|
||||
sqlite3BeginBenignMalloc();
|
||||
sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);
|
||||
sqlite3EndBenignMalloc();
|
||||
sqlite3OsFileControlNoFail(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);
|
||||
pPager->dbHintSize = pPager->dbSize;
|
||||
}
|
||||
|
||||
|
@@ -795,7 +795,7 @@ void sqlite3Pragma(
|
||||
Pager *pPager = sqlite3BtreePager(pDb->pBt);
|
||||
char *proxy_file_path = NULL;
|
||||
sqlite3_file *pFile = sqlite3PagerFile(pPager);
|
||||
sqlite3OsFileControl(pFile, SQLITE_GET_LOCKPROXYFILE,
|
||||
sqlite3OsFileControlNoFail(pFile, SQLITE_GET_LOCKPROXYFILE,
|
||||
&proxy_file_path);
|
||||
|
||||
if( proxy_file_path ){
|
||||
|
@@ -1727,7 +1727,7 @@ static int walCheckpoint(
|
||||
i64 nReq = ((i64)mxPage * szPage);
|
||||
rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
|
||||
if( rc==SQLITE_OK && nSize<nReq ){
|
||||
sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
|
||||
sqlite3OsFileControlNoFail(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1843,7 +1843,9 @@ int sqlite3WalClose(
|
||||
);
|
||||
if( rc==SQLITE_OK ){
|
||||
int bPersist = -1;
|
||||
sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersist);
|
||||
sqlite3OsFileControlNoFail(
|
||||
pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersist
|
||||
);
|
||||
if( bPersist!=1 ){
|
||||
/* Try to delete the WAL file if the checkpoint completed and
|
||||
** fsyned (rc==SQLITE_OK) and if we are not in persistent-wal
|
||||
|
Reference in New Issue
Block a user