Hi!
I have a problem when I try to create a new database in a thread and try to add a table on it. The following C code (see in the end of this e-mail) produces: in SQLite 3.7.5: Disk I/O error (same problem with 3.7.4) SQLite Treadsafe..... Yes (1). SQLite Lib version... 3.7.5. SQLite Lib vernumber. 3007005. Open/Create try.db... Exec 'CREATE TABLE test (id INTEGER PRIMARY KEY, name TEST)'... !!! ERROR:Can't exec: disk I/O error(10) Close... In SQlite 3.6.22: No problem SQLite Treadsafe..... Yes (1). SQLite Lib version... 3.6.22. SQLite Lib vernumber. 3006022. Open/Create try.db... Exec 'CREATE TABLE test (id INTEGER PRIMARY KEY, name TEST)'... Close... If I open the database in the main function (moving openDatabase from test() to main()), there is no problem with both SQLite version. Any ideas? Regards, Sylvain ====== C Source Code ===== #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <sqlite3.h> static sqlite3 *db_p=NULL; static const int openMode=SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE; static char *errmsg_p=NULL; static void openDatabase(const char *filename_p) { printf("Open/Create %s...\n",filename_p); int rc = sqlite3_open_v2(filename_p, &db_p,openMode,NULL); if ( rc ) printf("Can't open database %s: %s(%d)\n", filename_p, sqlite3_errmsg(db_p), rc); } static void closeDatabase(void) { printf("Close...\n"); int rc = sqlite3_close(db_p); if ( rc ) printf("Can't close database: %s(%d)\n", sqlite3_errmsg(db_p), rc); } static void exec(const char* query_p) { printf("Exec '%s'...\n",query_p); int rc = sqlite3_exec(db_p,query_p,NULL,NULL,&errmsg_p); if ( rc ) printf("!!! ERROR:Can't exec: %s(%d)\n", errmsg_p, rc); } static void* test(void *arg_p) { openDatabase((char*)arg_p); exec("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEST)"); closeDatabase(); return NULL; } static void getConfig(void) { printf("SQLite Treadsafe..... %s (%d).\n",sqlite3_threadsafe()==0?"No":"Yes",sqlite3_threadsafe()); printf("SQLite Lib version... %s.\n",sqlite3_libversion()); printf("SQLite Lib vernumber. %d.\n",sqlite3_libversion_number()); } int main(int agrc, char *argv[]) { getConfig(); pthread_t id; int rc=pthread_create(&id,NULL,test,(void*)"try.db"); if ( rc ) perror("pthread_create"); pthread_join(id,NULL); } _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users