I know that AsyncIO is now superseded by WAL [1], but according to
Richard it should still work for existing applications [2].
However, I experience the opposite.
The small C application below runs well when linked against SQLite
3.7.14. With SQLite 3.7.15, it mysteriously fails. I see two types of
outcomes:
1. Error SQLITE_IOERR, followed by SQLITE_ERROR. Nothing is written to
the target database.
2. No errors, but nothing is written to the target database.
Both which happen randomly with no obvious pattern. Could this hint at a
missing memory initialization or overrun?
Even though AsyncIO is no longer actively maintained, can anyone
reproduce my findings? I am running on Windows and have limited testing
capabilities like no Valgrind, etc.
Ralf
[1] http://www.sqlite.org/src/info/3d548db7eb
[2] http://www.mail-archive.com/sqlite-users@sqlite.org/msg74170.html
#include
#include
#include
#include "sqlite3.h"
#include "sqlite3async.h"
#pragma hdrstop
sqlite3 *db;
void sqlite3_check(int e) {
if (e != SQLITE_OK) {
printf("Error %d\n", e);
}
}
#ifdef SQLITE_ENABLE_ASYNCIO
int StopThread = 0;
DWORD WINAPI MyThreadFunction( LPVOID lpParam )
{
do {
printf ("sqlite3async_run() ...");
sqlite3async_run();
sqlite3_sleep (0);
printf ("OK\n");
}
while (!StopThread);
return 0;
}
#endif /* SQLITE_ENABLE_ASYNCIO */
char* FILE_NAME = "test.db3";
int main(int argc, _TCHAR* argv[])
{
int i;
#ifdef SQLITE_ENABLE_ASYNCIO
HANDLE ThreadHandle;
#endif /* SQLITE_ENABLE_ASYNCIO */
if (!DeleteFile(FILE_NAME)) {
printf("Error deleting file %s\n", FILE_NAME);
}
#ifdef SQLITE_ENABLE_ASYNCIO
sqlite3_check(sqlite3async_initialize(NULL, 1));
sqlite3async_control(SQLITEASYNC_HALT, SQLITEASYNC_HALT_IDLE);
ThreadHandle = CreateThread(
NULL, // default security attributes
0, // use default stack size
MyThreadFunction, // thread function name
NULL, // argument to thread function
0, // use default creation flags
NULL); // returns the thread identifier
#endif /* SQLITE_ENABLE_ASYNCIO */
sqlite3_check(sqlite3_open_v2 (FILE_NAME, ,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL));
sqlite3_check(sqlite3_exec(db, "create table if not exists t (a)",
NULL, NULL, NULL));
for (i = 0; i < 10; i++) {
char *s = sqlite3_mprintf("insert into t values (%d);", i);
sqlite3_check(sqlite3_exec(db, s, NULL, NULL, NULL));
sqlite3_free(s);
}
sqlite3_check(sqlite3_close(db));
#ifdef SQLITE_ENABLE_ASYNCIO
StopThread = 1;
WaitForSingleObject(ThreadHandle, INFINITE);
CloseHandle(ThreadHandle);
sqlite3async_shutdown();
#endif /* SQLITE_ENABLE_ASYNCIO */
printf("Done.\nPress enter a number to quit.\n");
scanf("%d", );
return 0;
}
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users