mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
For improved clarity of presentation,
refactor some of the code associated with ZERO_DAMAGE and sector-size. FossilOrigin-Name: 1dde96c9ee88af1c4e37c2e65acb7c0fe6a20e2a
This commit is contained in:
23
src/pager.c
23
src/pager.c
@@ -2528,21 +2528,22 @@ static int pager_truncate(Pager *pPager, Pgno nPage){
|
||||
static void setSectorSize(Pager *pPager){
|
||||
assert( isOpen(pPager->fd) || pPager->tempFile );
|
||||
|
||||
if( !pPager->tempFile
|
||||
&& (sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_ZERO_DAMAGE)==0
|
||||
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.
|
||||
*/
|
||||
pPager->sectorSize = sqlite3OsSectorSize(pPager->fd);
|
||||
}
|
||||
if( pPager->sectorSize<32 ){
|
||||
** call will segfault. */
|
||||
pPager->sectorSize = 512;
|
||||
}
|
||||
if( pPager->sectorSize>MAX_SECTOR_SIZE ){
|
||||
assert( MAX_SECTOR_SIZE>=512 );
|
||||
pPager->sectorSize = MAX_SECTOR_SIZE;
|
||||
}else{
|
||||
pPager->sectorSize = sqlite3OsSectorSize(pPager->fd);
|
||||
if( pPager->sectorSize<32 ){
|
||||
pPager->sectorSize = 512;
|
||||
}
|
||||
if( pPager->sectorSize>MAX_SECTOR_SIZE ){
|
||||
assert( MAX_SECTOR_SIZE>=512 );
|
||||
pPager->sectorSize = MAX_SECTOR_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user