title: sqlite3 WAL/SHM files not deleted
body: <p>I have the following code</p>
  
  <pre><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, &amp;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, &amp;Stmt, &amp;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) &amp;&amp; (rc != SQLITE_DONE) &amp;&amp; (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);
  </code></pre>
  
  <p>}</p>
  
  <p>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!</p>