subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1536325 - /subversion/trunk/subversion/libsvn_subr/sqlite.c
Date Mon, 28 Oct 2013 12:19:31 GMT
Author: rhuijben
Date: Mon Oct 28 12:19:31 2013
New Revision: 1536325

URL: http://svn.apache.org/r1536325
Log:
When an Sqlite statement raises some error, the same error is reported
when resetting the statement for the first time, originally for error
reporting reasons, but now this is considered an original design flaw.

But in this case we forget to mark the statement as already been reset,
which may cause an unnecessary false abort() when running in maintainer mode.

* subversion/libsvn_subr/sqlite.c
  (svn_sqlite__reset): Reverse code, documenting why.

Modified:
    subversion/trunk/subversion/libsvn_subr/sqlite.c

Modified: subversion/trunk/subversion/libsvn_subr/sqlite.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sqlite.c?rev=1536325&r1=1536324&r2=1536325&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sqlite.c (original)
+++ subversion/trunk/subversion/libsvn_subr/sqlite.c Mon Oct 28 12:19:31 2013
@@ -707,9 +707,20 @@ svn_sqlite__finalize(svn_sqlite__stmt_t 
 svn_error_t *
 svn_sqlite__reset(svn_sqlite__stmt_t *stmt)
 {
-  SQLITE_ERR(sqlite3_reset(stmt->s3stmt), stmt->db);
-  SQLITE_ERR(sqlite3_clear_bindings(stmt->s3stmt), stmt->db);
+  /* No need to reset again after a first attempt */
   stmt->needs_reset = FALSE;
+
+  /* Clear bindings first, as there are no documented reasons
+     why this would ever fail, but keeping variable bindings
+     when reset is not what we expect. */
+  SQLITE_ERR(sqlite3_clear_bindings(stmt->s3stmt), stmt->db);
+
+  /* Reset last, as this *will* fail if the statement failed since
+     the last time it was reset, while reporting just the same failure.
+     (In this case the statement is also properly reset).
+
+     See the sqlite3_reset() documentation for more details. */
+  SQLITE_ERR(sqlite3_reset(stmt->s3stmt), stmt->db);
   return SVN_NO_ERROR;
 }
 



Mime
View raw message