vendredi 16 octobre 2015

sqlite3 WAL/SHM files not deleted

I have the following code

int main(){
sqlite3 *db;
int     rc;
char filename[512];
char query[512];
char trace_string[512];
sqlite3_stmt *Stmt;
const char *zLeftover;

strcpy(filename,"/data/xcd/textdatabase/2015274/2015274_mos.sqlite");
strcpy(query,"ATTACH '/data/xcd/textdatabase/2015273/2015273_mos.sqlite' as db1");

rc = sqlite3_open_v2(filename, &db,SQLITE_OPEN_READONLY,NULL);
if (rc != SQLITE_OK) {
    sprintf(trace_string,"open_database: failed to open %s, rc=%d\n", filename, rc);
    fprintf(stdout,trace_string);
    return 0;
}
else {
    sprintf(trace_string,"open_database: %s opened rc=%d\n", filename, rc);
    fprintf(stdout,trace_string);
}

rc = sqlite3_prepare(db, query, -1, &Stmt, &zLeftover);
if (rc != SQLITE_OK) {
    sprintf(trace_string,"test: sqlite3_prepare, command=%s, rc=%d\n", query, rc);
    fprintf(stdout,trace_string);
    return rc;
}

rc = sqlite3_step(Stmt);
if ((rc != SQLITE_OK) && (rc != SQLITE_DONE) && (rc != SQLITE_ROW)) {
    sprintf(trace_string,"test: sqlite3_step, command=%s, rc=%d\n", query, rc);
    fprintf(stdout,trace_string);
    return rc;
}

rc = sqlite3_finalize(Stmt);

sprintf(trace_string,"test: sqlite3_finalize, command=%s, rc=%d\n", query, rc);
fprintf(stdout,trace_string);

rc=sqlite3_close(db);
sprintf(trace_string,"close_database: rc=%d\n", rc);
fprintf(stdout,trace_string);
return (rc);

}

The databases I'm working with are write ahead logging (WAL) databases. According to the SQLite documentation, the shm and wal files are supposed to be deleted upon completion of the program. However, these files are still there after execution of this program. The documentation says the files might still be there if the program does not complete cleanly, but I'm just not seeing that. Any insight? Thanks!

Aucun commentaire:

Enregistrer un commentaire