Sqlite code 28 "renamed file while opening"

This is a consequence of this question .

I have a Mac app that uses sqlite extensively. Multiple threads block sqlite code without using any shared resources. I created sqlite_config_log via sqlite3_config function and I keep getting this message with code 28:

renamed file during open:

Code 28 is SQLITE_WARNING. I found what appears to be the original code that logs this warning (search on the "file renamed at open time" page), and it seems to indicate the path to the offending file, but that is not in the log statement. I even put a breakpoint in my log function and checked the memory of the "renamed" line, and there is no filename there; it doesn't just turn off the log because of an erroneous null character.

I also know that I am not actually renaming the file. It gives me this warning right after the file is created. And the same code works in an iOS app (which is linked to sqlite version 3.7.13 and Mac is 3.8.5) without generating warnings. So the question is: what could cause this warning other than renaming the file?

Update: No warning appears if the database is converted to DELETE log mode before any statements are executed on it.

+3


source to share


1 answer


I was able to fix this by linking the latest SQLite in my project as source instead of linking to dylib. It was some kind of bug in sqlite, probably caused by the way my application manages files, it creates an empty file on disk and then passes it to sqlite to create the database file (as opposed to passing sqlite the path to empty place). I am currently running 3.8.8.2; the version that came with Yosemite was 3.7. something I guess. This same version ships in iOS 8 and caused the same issue in my companion iOS app.



Note. If you are bundling sqlite into an Xcode project, make sure HAVE_USLEEP is defined or it will sleep for whole seconds waiting for locks .

+2


source







All Articles