You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2011/03/07 23:07:21 UTC

svn commit: r1078975 - in /subversion/trunk/subversion: include/private/svn_sqlite.h libsvn_subr/sqlite.c

Author: hwright
Date: Mon Mar  7 22:07:21 2011
New Revision: 1078975

URL: http://svn.apache.org/viewvc?rev=1078975&view=rev
Log:
When creating the SAVEPOINT and RELEASE commands, just use a static buf,
rather than a dynamically allocated one in a pool.  This is simpler and
quicker.

* subversion/libsvn_subr/sqlite.c
  (svn_sqlite__with_lock): Introduce a static buffer, and use it for allocating
    the various SAVEPOINT and RELEASE statements.

* subversion/include/private/svn_sqlite.h
  (svn_sqlite__with_lock): Update docstring.

Modified:
    subversion/trunk/subversion/include/private/svn_sqlite.h
    subversion/trunk/subversion/libsvn_subr/sqlite.c

Modified: subversion/trunk/subversion/include/private/svn_sqlite.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_sqlite.h?rev=1078975&r1=1078974&r2=1078975&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_sqlite.h (original)
+++ subversion/trunk/subversion/include/private/svn_sqlite.h Mon Mar  7 22:07:21 2011
@@ -337,6 +337,8 @@ svn_sqlite__with_immediate_transaction(s
    will be shared over multiple statements, instead of being reobtained
    everytime, which requires disk and/or network io.
 
+   SCRATCH_POOL will be passed to the callback (NULL is valid).
+
    ### Since we now require SQLite >= 3.6.18, this function has the effect of
        always behaving like a defered transaction.  Can it be combined with
        svn_sqlite__with_transaction()?

Modified: subversion/trunk/subversion/libsvn_subr/sqlite.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sqlite.c?rev=1078975&r1=1078974&r2=1078975&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sqlite.c (original)
+++ subversion/trunk/subversion/libsvn_subr/sqlite.c Mon Mar  7 22:07:21 2011
@@ -1056,12 +1056,15 @@ svn_sqlite__with_lock(svn_sqlite__db_t *
   svn_error_t *err2;
   int savepoint = db->savepoint_nr++;
   const char *release_stmt;
+  /* This buffer is plenty big to hold the SAVEPOINT and RELEASE commands. */
+  char buf[32];
 
-  SVN_ERR(exec_sql(db,
-                   apr_psprintf(scratch_pool, "SAVEPOINT s%u;", savepoint)));
+  snprintf(buf, sizeof(buf), "SAVEPOINT s%u", savepoint);
+  SVN_ERR(exec_sql(db, buf));
   err = cb_func(cb_baton, db, scratch_pool);
 
-  release_stmt = apr_psprintf(scratch_pool, "RELEASE s%u;", savepoint);
+  snprintf(buf, sizeof(buf), "RELEASE   s%u", savepoint);
+  release_stmt = buf;
   err2 = exec_sql(db, release_stmt);
 
   if (err2 && err2->apr_err == SVN_ERR_SQLITE_BUSY)