On Fri, Sep 10, 2010 at 01:11:23PM -0700, Josh scratched on the wall: > It should be noted that my program is a single thread, and I can assume no > other programs or threads should be accessing my database file. Since > SQLite auto commits transactions and I won't have any transactions open, > I'm thinking there shouldn't be any reason I couldn't just copy the file > without an exclusive lock, but it sounds like I may be missing something?
If you can really, truly, assume all those things, then yes. > I'm assuming the BEGIN EXCLUSIVE will get a file lock. Will the BEGIN > EXCLUSIVE statement block, waiting until it can get an exclusive lock, or > if it fails to get an exclusive lock, will it immediately return to the > caller (if called by sqlite3_get_table() for example)? It will fail and return SQLITE_BUSY. > runsql("sync database somehow?"); //do I need this? No. > runsql("BEGIN EXCLUSIVE"); > copydatabasefile(); > runsql("ROLLBACK"); Assuming runsql() will re-run a statement until it works (which is normally a bad practice), then that's the general idea. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users