/ Check-in [74934d3f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Simplification to the posix_fallocate() replacement used for the SQLITE_FCNTL_SIZE_HINT file control in the unix VFS.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 74934d3f60ad9f6550297410eada0f288e0123c4
User & Date: drh 2015-12-01 22:09:42
Context
2015-12-02
00:05
Remove all traces of SQLITE_FCNTL_WAL_BLOCK from the unix VFS - that feature had been disabled for a long time and never actually worked. check-in: e1d5320c user: drh tags: trunk
2015-12-01
22:09
Simplification to the posix_fallocate() replacement used for the SQLITE_FCNTL_SIZE_HINT file control in the unix VFS. check-in: 74934d3f user: drh tags: trunk
21:23
Add the SQLITE_LIKE_DOESNT_MATCH_BLOBS compile-time option. check-in: 9e1d6d4c user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

  3658   3658         ** This is a similar technique to that used by glibc on systems
  3659   3659         ** that do not have a real fallocate() call.
  3660   3660         */
  3661   3661         int nBlk = buf.st_blksize;  /* File-system block size */
  3662   3662         int nWrite = 0;             /* Number of bytes written by seekAndWrite */
  3663   3663         i64 iWrite;                 /* Next offset to write to */
  3664   3664   
  3665         -      iWrite = ((buf.st_size + 2*nBlk - 1)/nBlk)*nBlk-1;
         3665  +      iWrite = (buf.st_size/nBlk)*nBlk + nBlk - 1;
  3666   3666         assert( iWrite>=buf.st_size );
  3667         -      assert( (iWrite/nBlk)==((buf.st_size+nBlk-1)/nBlk) );
  3668   3667         assert( ((iWrite+1)%nBlk)==0 );
  3669         -      for(/*no-op*/; iWrite<nSize; iWrite+=nBlk ){
         3668  +      for(/*no-op*/; iWrite<nSize+nBlk-1; iWrite+=nBlk ){
         3669  +        if( iWrite>=nSize ) iWrite = nSize - 1;
  3670   3670           nWrite = seekAndWrite(pFile, iWrite, "", 1);
  3671   3671           if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
  3672   3672         }
  3673         -      if( nWrite==0 || (nSize%nBlk) ){
  3674         -        nWrite = seekAndWrite(pFile, nSize-1, "", 1);
  3675         -        if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
  3676         -      }
  3677   3673   #endif
  3678   3674       }
  3679   3675     }
  3680   3676   
  3681   3677   #if SQLITE_MAX_MMAP_SIZE>0
  3682   3678     if( pFile->mmapSizeMax>0 && nByte>pFile->mmapSize ){
  3683   3679       int rc;