Re: [sqlite] reporting number of changes
--- [EMAIL PROTECTED] wrote: > Your approach only works in simple cases. The number of changes is a > connection/sqlite3* wide number - ie any SQLite statements associated with it > can cause changes. This would certainly be the case when multi-threading is > used. Yes, agreed > Even in single threading, if you have two statements running at the same time > (eg you are reading rows from one to feed to the other or something something > similar) then the completion order will affect that changes counter. This case seems alright, consider the following scheme where a query overlaps two update statements. sqlite3old real CURSOR OPERATION total_changes total_changes changes 1 execute query 1 fetch row 1 2 execute update 1 0 1 1 fetch row 2 2 execute update 2 1 1 1 end of iteration2 2 0 The real changes are reflected correctly. > By far a better approach would be to enter a ticket requesting that the > sqlite3_stmt_status api include row change counters. That way the numbers > will be completely unambiguous and unaffected by other statements that are > executing. http://www.sqlite.org/cvstrac/tktview?tn=3534 ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] reporting number of changes
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Edzard Pasma wrote: > It appears satisfactory so far. Still wonder why a work-around like this is > needed. Your approach only works in simple cases. The number of changes is a connection/sqlite3* wide number - ie any SQLite statements associated with it can cause changes. This would certainly be the case when multi-threading is used. Even in single threading, if you have two statements running at the same time (eg you are reading rows from one to feed to the other or something something similar) then the completion order will affect that changes counter. By far a better approach would be to enter a ticket requesting that the sqlite3_stmt_status api include row change counters. That way the numbers will be completely unambiguous and unaffected by other statements that are executing. http://sqlite.org/c3ref/stmt_status.html Roger -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAklA+LEACgkQmOOfHg372QQK6ACeKw9kEyKEfba9UHn3eSPqyPy8 AbAAnA83TPMI6CUxpkzff9AJkz/dqDwF =zBrQ -END PGP SIGNATURE- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] reporting number of changes
Possibly my previous post was too short. Any way I have a satisfactory solution now. My question araised when trying to change the apswtrace tool available to Python users. This gathers execution times via a sqlite3_profile callback function. When I call sqlite3_changes from this profiler function, and just blindly display the results on the summary report, this looks like: CALLS TIMEROWSSQL 1 .00212 DELETE FROM t1 1 .00212 SELECT * FROM t1 Which is wrong as the SELECT statement just repeats the number of rows of the last DML (DELETE). My solution is to use sqlite3_total_changes instead of sqlite3_changes, more or less like this: realchanges=sqlite3_total_changes()-old_total_changes if realchanges>0: old_total_changes+=realchanges It appears satisfactory so far. Still wonder why a work-around like this is needed. Edzard Pasma --- [EMAIL PROTECTED] wrote: From: "Edzard Pasma" <[EMAIL PROTECTED]> To: <sqlite-users@sqlite.org> Subject: [sqlite] reporting number of changes Date: Tue, 9 Dec 2008 01:36:39 -0800 Hello, The API function sqlite_changes reports the number of rows changed in the last update/insert/delete. I'd like to use this in a generic SQL-tracing tool and find it a bit inconvenient as the value can only be used if the statement was an update/insert/delete. Is there a reason that the value is not reset for other type of statements? Or is there an easy way to find if a statement was an update? Edzard Pasma ___ 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
[sqlite] reporting number of changes
Hello, The API function sqlite_changes reports the number of rows changed in the last update/insert/delete. I'd like to use this in a generic SQL-tracing tool and find it a bit inconvenient as the value can only be used if the statement was an update/insert/delete. Is there a reason that the value is not reset for other type of statements? Or is there an easy way to find if a statement was an update? Edzard Pasma ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users