On 17 May 2012, at 4:34pm, Rajesh Kumar <thisiz...@gmail.com> wrote:
> No am not using any PRAGMAs. I just cross compiled sqlite source to > ARM architecture. Can't I forcefully do commit on my transaction???? If you are correctly using _open() and _close(), and haven't disabled synchrony with PRAGMAs or compilation settings, then you should be getting COMMIT automatically. There's no way to force SQLite to flush changes to disk because SQLite flushes changes to disk as part of normal working. As for use of COMMIT … every SQL command executed with SQLite is part of a transaction. So normal programming tends to look like BEGIN; … any number of INSERT, DELETE, SELECT, UPDATE commands here … COMMIT; By the time SQLite has returned from the COMMIT, your changes should have made it to disk. There's no flushing to do, SQLite already did it. If you do happen to issue a SQL command without having issued a 'BEGIN' first, then SQLite helpfully wraps it in its own transaction for you, executing all of these BEGIN (<-- I helpfully do this for you because you forgot) Your command here COMMIT (<-- since you forgot the BEGIN you'll probably forget the COMMIT too) with the single call to sqlite3_exec() you made, and doing the COMMIT before it returns from processing that call. So even if all you do is use sqlite3_exec('UPDATE command here'), SQLite has already done all the flushing to disk that needs doing. However, the code in SQLite that does the COMMIT includes the C command fsync() as part of its working. (I think this is right. I haven't read the source code.) And its the fsync() that does the flushing. So if that's not correctly implemented on your platform (which is depressingly common) then things like application crashes or power loss can lead to a corrupt database. Which is why Richard pointed to http://www.sqlite.org/atomiccommit.html and http://www.sqlite.org/howtocorrupt.html Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users