Hello all- Bear with me, my problem is a little goofy and has stolen six hours of my life. I'm using the C API of sqlite 3.6.12 on Mac OS X 10.6.2.
I'm using a sqlite database table to collect paths from a filesystem. So, I have some C code that opens the database at the beginning of an indexing job, prepares an insert statement, and then for each file: sqlite3_bind_text()'s the path into the insert statement and sqlite3_step()'s it for every file I'm indexing, and then sqlite3_reset()'s the statement for the next path to insert. My code works for hundreds of iterations at a time; if I start iterating through a folder with a few hundred paths, I generally have no problem. However, if I start higher up, and have a directory tree with 1000 or more paths, at some point or other sqlite_step() will return SQLITE_CANTOPEN and any call I try against my sqlite3 *database after that point will return SQLITE_MISUSE. For a given set of paths, sqlite_step() will always fail on the same path, plus or minus 1. If I start in a completely different part of the filesystem, sqlite_step() will usually fail eventually, with the same consistency, but never after the same number of inserts -- for one folder, it fails consistently after 1598 inserts +/-1, for another folder, it fails at 620 +/-1. * At first, given the consistency, I thought there might be some sort of memory/allocation problem, but going over my code carefully and with profiling, I can find no leaks. * I breakpoint on sqlite3_step() returning an error, and when I look at the frame, I see no suspicious nulls or bad argument values. If I use dummy code that inserts an identical dummy string for every call into sqlite3_step(), it still eventually fails. * When I change my sql "create" statement for the table I'm inserting into into a temp table, the code can index tens of thousands of files and never has an issue. * This made me think there was some sort of issue with sqlite's IO with the disk, but I can't figure out where the problem is. Googling tells me a lot of people have a problem when they are trying to write a db file to a directory their code doesn't have readwrite on, but I've verified that my database directory (for purposes of testing) is chmod 777. So, has anyone else run into SQLITE_CANTOPEN in a situation where it wasn't a permissions issue? I'll include the code if you'd really like to see it but it's essentially like this: (eliding all error checking, etc) /* EXAMPLE.c */ char *nextPath(); /* returns next path to index */ sqlite3 *_database; int retVal; sqlite3_open_v2(PATH_TO_DB, &_database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); sqlite3_stmt *statement; const char *szStmt = "replace into AudioFiles (file_url) values (?)"; retVal = sqlite3_prepare_v2(_database, szStmt, strlen(szStmt), &statement, NULL); char *path; while ( path = nextPath() ) { retVal = sqlite3_bind_text(statement, 1, path , strlen(path) , SQLITE_STATIC); /* I've tried every variation for argument 5 here */ retVal = sqlite3_step(statement); retVal = sqlite3_reset(statement); } sqlite3_finalize(_upsertStatement); sqlite3_close(_database); /* end EXAMPLE.c */ -------------------------- Jamie Hardt http://www.imdb.com/name/nm0362504/ http://www.soundepartment.com/ _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users