mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Add SQLITE_IOCAP_ZERO_DAMAGE and enable it for both unix and windows. Use
this device characteristic to reduce the required work in journaling. A side effect is that this changes the default page exists back to 1024 even with the use of statvfs(). FossilOrigin-Name: a0be6ea464695fdf1eaf2b7cf0652778617814f2
This commit is contained in:
13
src/pager.c
13
src/pager.c
@@ -2515,11 +2515,22 @@ static int pager_truncate(Pager *pPager, Pgno nPage){
|
||||
** the value returned by the xSectorSize() method rounded up to 32 if
|
||||
** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it
|
||||
** is greater than MAX_SECTOR_SIZE.
|
||||
**
|
||||
** If the file has the SQLITE_IOCAP_ZERO_DAMAGE property, then set the
|
||||
** effective sector size to its minimum value (512). The purpose of
|
||||
** pPager->sectorSize is to define the "blast radius" of bytes that
|
||||
** might change if a crash occurs while writing to a single byte in
|
||||
** that range. But with ZERO_DAMAGE, the blast radius is zero, so
|
||||
** we minimize the sector size. For backwards compatibility of the
|
||||
** rollback journal file format, we cannot reduce the effective sector
|
||||
** size below 512.
|
||||
*/
|
||||
static void setSectorSize(Pager *pPager){
|
||||
assert( isOpen(pPager->fd) || pPager->tempFile );
|
||||
|
||||
if( !pPager->tempFile ){
|
||||
if( !pPager->tempFile
|
||||
&& (sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_ZERO_DAMAGE)==0
|
||||
){
|
||||
/* Sector size doesn't matter for temporary files. Also, the file
|
||||
** may not have been opened yet, in which case the OsSectorSize()
|
||||
** call will segfault.
|
||||
|
Reference in New Issue
Block a user