> commit = 1; > pStmt != NULL > but > sql = NULL; //under debugger: pStmt->isPrepareV2 = 0; pStmt->zSql = NULL;
So, I was right then that in case of not finished SELECT statement autocommit will still be 1. But as you correctly noticed above isPrepareV2 = 0 and it means that this statement wasn't prepared with sqlite3_prepare_v2 and sql text is never stored in this case. Do you prepare all your statements with sqlite3_prepare_v2? If yes then probably it's statement created by one of sqlite3_blob_open calls which wasn't matched with sqlite3_blob_close then. Check carefully that you close all blob handles. Pavel On Thu, Feb 4, 2010 at 3:36 PM, a1rex <a1rex2...@yahoo.com> wrote: > > Thank you very much for your advice! > >>to check that transaction >>wasn't committed yet you can connect to the database with external >>command while application is working and try to update or insert >>something. If it fails with message "The database file is locked" then >>application didn't commit transaction > > Yes, you are right. Update fails with message "The database file is locked". > > I inserted following statements: > > const char *sql; > int commit = sqlite3_get_autocommit(db); > > sqlite3_stmt *pStmt = sqlite3_next_stmt(db, NULL); > > if(pStmt != NULL) > { > sql = sqlite3_sql(pStmt); > } > > right after : > > sqlite3_blob_close(); > > And received: > commit = 1; > pStmt != NULL > but > sql = NULL; //under debugger: pStmt->isPrepareV2 = 0; pStmt->zSql = NULL; > > The results surprised me. I think that I do not have any > statement open yet sqlite3_next_stmt tells me that I have statement prepared > and pending. At the same time sqlite3_sql(pStmt) says that that statement is > a NULL statement. > > I just got more confused. > > Best regards, > Samuel > > > ----- Original Message ---- > From: Pavel Ivanov <paiva...@gmail.com> > To: General Discussion of SQLite Database <sqlite-users@sqlite.org> > Sent: Thu, February 4, 2010 2:07:12 PM > Subject: Re: [sqlite] When incremental write is committed to the hard drive? > >> 1) What else can prevent incremental data to be written to the hard drive? > > Besides all that I mentioned only explicit BEGIN statement can open > transaction and thus prevent anything after that from being written to > disk immediately until COMMIT is executed. What you can do now is > first of all use sqlite3_get_autocommit function > (http://www.sqlite.org/c3ref/get_autocommit.html) after closing blob > handle to check that transaction should be automatically committed. > But I'm not sure that it will return 0 if some SELECT statement is in > progress. To check that you can call sqlite3_next_stmt(db, NULL) > (http://www.sqlite.org/c3ref/next_stmt.html) to obtain pointer to the > statement that is still open (if you finalize all your statements then > this function should return NULL). If function returns some statement > you can use sqlite3_sql (http://www.sqlite.org/c3ref/sql.html) to see > what statement is at fault. > >> 2) Is there a way to force a write to the hard drive? > > Nothing but COMMIT statement (or auto-commit) can force new and > changed data to be written on disk. BTW, to check that transaction > wasn't committed yet you can connect to the database with external > command while application is working and try to update or insert > something. If it fails with message "The database file is locked" then > application didn't commit transaction. If update succeeds and you > still cannot see changes made by application then you have some > problems with file system, but I hope you have not. > > > __________________________________________________________________ > Looking for the perfect gift? Give the gift of Flickr! > > http://www.flickr.com/gift/ > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users