我有以下代码
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);
}
我正在使用的数据库是预写日志 (WAL) 数据库。根据 SQLite 文档,应该在程序完成后删除 shm 和 wal 文件。但是,执行此程序后,这些文件仍然存在。文档说如果程序没有干净地完成,文件可能仍然存在,但我只是没有看到。有什么见解吗?谢谢!