我試圖從sqlite3 VFS examples運行test_onefile.c例子,我得到以下故障:sqlite3的one_file VFS失敗
test_onefile: test_onefile.c:693: fsDelete: Assertion `strpcmp("-journal", &zPath[nName])==0' failed.
我運行代碼如下:
int retval;
fs_register();
int q_cnt = 5,q_size = 150,ind = 0;
char **queries = (char**) malloc(sizeof(char) * q_cnt * q_size);
sqlite3_stmt *stmt;
sqlite3 *handle;
retval = sqlite3_open_v2("sampledb.sqlite2", &handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE , "fs");
if(retval)
{
printf("Database connection failed\n");
return -1;
}
printf("Connection successful\n");
// Create the SQL query for creating a table
char create_table[100] = "CREATE TABLE IF NOT EXISTS users (uname TEXT,pass TEXT NOT NULL,activated INTEGER)";
// Execute the query for creating the table
retval = sqlite3_exec(handle,create_table,0,0,0);
// Insert first row and second row
queries[ind++] = "INSERT INTO users VALUES('manish','mani',1)";
retval = sqlite3_exec(handle,queries[ind-1],0,0,0);
queries[ind++] = "INSERT INTO users VALUES('mehul','pulsar',0)";
retval = sqlite3_exec(handle,queries[ind-1],0,0,0);
編輯: 失敗的文件是sampledb.sqlite2-wal
,顯然不是日誌文件。但是,我不明白它是如何達到它的。
EDIT2: 好,去除源文件中的聲明後:
assert(strcmp("-journal", &zPath[nName])==0);
的代碼似乎工作。然而,我並不是斷言刪除的忠實粉絲,顯然這會導致一些意想不到的行爲。作者有理由使用該斷言。
可能會讓你斷言你的比較失敗(不匹配兩個字符串)。所以它從這一點上打破了執行。 –
不是。確切的代碼適用於默認的VFS和演示VFS。它斷言失敗,因爲它試圖刪除一個'-wal'文件。 – Mattan