gpt4 book ai didi

sqlite - sqlite3 WAL/SHM文件未删除

转载 作者:行者123 更新时间:2023-12-03 18:48:01 26 4
gpt4 key购买 nike

我有以下代码

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文件。但是,执行该程序后,这些文件仍然存在。文档说,如果程序无法完全完成,文件可能仍然存在,但我只是没有看到。有见识吗?
谢谢!

最佳答案

checkpoint之后,将删除-shm-wal文件。
这不能在只读数据库上完成。

关于sqlite - sqlite3 WAL/SHM文件未删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33177784/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com