SQLite Forum

vfs write amount size without WAL
Login

vfs write amount size without WAL

(1) By anonymous on 2021-09-22 12:48:52 [source]

I try create a vfs, on my test the iAmt from write method always equal page size.

I want to confirm this allway be true if I stay on memory journal mode(or OFF mode)?

(2) By Richard Hipp (drh) on 2021-09-22 12:58:20 in reply to 1 [link] [source]

SQLite itself will only write to the database file page-size chunks that are aligned to a page boundary.

But beware: Intermediate VFS shims might change that. Also, an application could, if it wanted to, acquire the sqlite3_file object for the database and then invoke the xWrite method with any parameters it wants.

So, in other words, it would be reasonable to return SQLITE_IOERR or some other error code if you get an iAmt that is different from the page size, but it would not be reasonable to assert().

(3.1) By Max (Maxulite) on 2021-09-24 11:43:14 edited from 3.0 in reply to 1 [link] [source]

A good source of wisdom in this respect is The Checksum VFS Shim. Looking at the xRead and xWrite handlers one can notice that the check-summing logic will go completely out of sync if the requests are not equal to the page size. And for this to happen the implementation ignores (bypasses to the default implementation) anything but main and wal file

  if( (flags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_WAL))==0 ){
    return pSubVfs->xOpen(pSubVfs, zName, pFile, flags, pOutFlags);
  }