diff options
author | drh <drh@noemail.net> | 2014-06-16 18:35:06 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2014-06-16 18:35:06 +0000 |
commit | 0bdbc90db80e23896c8d3e9e376219d8aa076d7c (patch) | |
tree | e04a2a6a45ae5e0797c80deb225321b42521a14b /src/os_unix.c | |
parent | 2fe708196def2a3bd7133b142f04ffdecab38ff9 (diff) | |
download | sqlite-0bdbc90db80e23896c8d3e9e376219d8aa076d7c.tar.gz sqlite-0bdbc90db80e23896c8d3e9e376219d8aa076d7c.zip |
Add the SQLITE_UNLINK_AFTER_CLOSE compile-time option. If enabled, the
unlink of temporary files on unix is deferred until after the file is closed.
FossilOrigin-Name: e43a2f92b616ec885a1ee62911fa8f6991d277f7
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index fc320a492..7eb25c85f 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1919,6 +1919,13 @@ static int closeUnixFile(sqlite3_file *id){ pFile->pId = 0; } #endif +#ifdef SQLITE_UNLINK_AFTER_CLOSE + if( pFile->ctrlFlags & UNIXFILE_DELETE ){ + osUnlink(pFile->zPath); + sqlite3_free(*(char**)&pFile->zPath); + pFile->zPath = 0; + } +#endif OSTRACE(("CLOSE %-3d\n", pFile->h)); OpenCounter(-1); sqlite3_free(pFile->pUnused); @@ -5772,6 +5779,12 @@ static int unixOpen( if( isDelete ){ #if OS_VXWORKS zPath = zName; +#elif defined(SQLITE_UNLINK_AFTER_CLOSE) + zPath = sqlite3_mprintf("%s", zName); + if( zPath==0 ){ + robust_close(p, fd, __LINE__); + return SQLITE_NOMEM; + } #else osUnlink(zName); #endif |