VACUUM with multiplex does not delete chunks on Windows (fossil [8ce2b74a82]).

It seems this is because the file handle(s) are still held open by the 
multiplex layer when xDelete is triggered. Since Windows can not delete open 
files, they are kept.

I have not investigated this in depth, but closing the file handle before 
deleting the file works well for my simple test case. Here is the change in 
multiplexSubClose():

static void multiplexSubClose(
  multiplexGroup *pGroup,
  int iChunk,
  sqlite3_vfs *pOrigVfs
){
  sqlite3_file *pSubOpen = pGroup->aReal[iChunk].p;
  if( pSubOpen ){
    pSubOpen->pMethods->xClose(pSubOpen); /* <-- Moved here */
    if( pOrigVfs ) pOrigVfs->xDelete(pOrigVfs, pGroup->aReal[iChunk].z, 0);
    /* pSubOpen->pMethods->xClose(pSubOpen); <-- Moved above */
    sqlite3_free(pGroup->aReal[iChunk].p);
  }
  sqlite3_free(pGroup->aReal[iChunk].z);
  memset(&pGroup->aReal[iChunk], 0, sizeof(pGroup->aReal[iChunk]));
}

By the way: No error is returned if multiplex VACUUM fails to delete a chunk. 
Maybe it should, to warn curious end users who like to investigate files with 
uncommon names?

Ralf
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to