[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH][merge-tracking] Reduce one query to sqlite while retrieveing the mergeinfo.

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-11-15 11:12:36 CET

Hi All,
Find the attached patch and log.

With regards
Kamesh Jayachandran

[[[
Reduce one query to sqlite.

* subversion/libsvn_fs_util/merge-info-sqlite-index.c
  (parse_mergeinfo_from_db):
   changing the name of the arg 'rev' to 'lastmerged_rev'.
   Don't deduce the 'lastchanged_rev' as the caller himself would give it
   as 'lastmerged_rev'.
  (get_merge_info_for_path):
   Don't get the count of records rather get the lastmerged_rev itself.
   
Patch by: Kamesh Jayachandran <kamesh@collab.net>
]]]

Index: subversion/libsvn_fs_util/merge-info-sqlite-index.c
===================================================================
--- subversion/libsvn_fs_util/merge-info-sqlite-index.c (revision 22305)
+++ subversion/libsvn_fs_util/merge-info-sqlite-index.c (working copy)
@@ -268,28 +268,13 @@
 static svn_error_t *
 parse_mergeinfo_from_db(sqlite3 *db,
                         const char *path,
- svn_revnum_t rev,
+ svn_revnum_t lastmerged_rev,
                         apr_hash_t **result,
                         apr_pool_t *pool)
 {
   sqlite3_stmt *stmt;
- sqlite_int64 lastchanged_rev;
   int sqlite_result;
 
- SQLITE_ERR(sqlite3_prepare(db, "SELECT MAX(revision) from mergeinfo_changed"
- " where path = ? and revision <= ?;",
- -1, &stmt, NULL), db);
- SQLITE_ERR(sqlite3_bind_text(stmt, 1, path, -1, SQLITE_TRANSIENT), db);
- SQLITE_ERR(sqlite3_bind_int64(stmt, 2, rev), db);
- sqlite_result = sqlite3_step(stmt);
- if (sqlite_result != SQLITE_ROW)
- return svn_error_create(SVN_ERR_FS_SQLITE_ERROR, NULL,
- sqlite3_errmsg(db));
-
- lastchanged_rev = sqlite3_column_int64(stmt, 0);
-
- SQLITE_ERR(sqlite3_finalize(stmt), db);
-
   SQLITE_ERR(sqlite3_prepare(db,
                              "SELECT mergedfrom, mergedrevstart,"
                              "mergedrevend from mergeinfo "
@@ -297,7 +282,7 @@
                              "order by mergedfrom;",
                              -1, &stmt, NULL), db);
   SQLITE_ERR(sqlite3_bind_text(stmt, 1, path, -1, SQLITE_TRANSIENT), db);
- SQLITE_ERR(sqlite3_bind_int64(stmt, 2, lastchanged_rev), db);
+ SQLITE_ERR(sqlite3_bind_int64(stmt, 2, lastmerged_rev), db);
   sqlite_result = sqlite3_step(stmt);
 
   /* It is possible the mergeinfo changed because of a delete, and
@@ -403,7 +388,7 @@
   apr_hash_t *path_mergeinfo;
   sqlite3_stmt *stmt;
   int sqlite_result;
- sqlite_int64 count;
+ sqlite_int64 lastmerged_rev;
 
   path_mergeinfo = apr_hash_get(cache, path, APR_HASH_KEY_STRING);
   if (path_mergeinfo != NULL)
@@ -415,7 +400,7 @@
 
   /* See if we have a mergeinfo_changed record for this path. If not,
      then it can't have mergeinfo. */
- SQLITE_ERR(sqlite3_prepare(db, "SELECT COUNT(*) from mergeinfo_changed"
+ SQLITE_ERR(sqlite3_prepare(db, "SELECT MAX(revision) from mergeinfo_changed"
                              " where path = ? and revision <= ?;",
                              -1, &stmt, NULL), db);
 
@@ -426,14 +411,15 @@
     return svn_error_create(SVN_ERR_FS_SQLITE_ERROR, NULL,
                             sqlite3_errmsg(db));
 
- count = sqlite3_column_int64(stmt, 0);
+ lastmerged_rev = sqlite3_column_int64(stmt, 0);
   SQLITE_ERR(sqlite3_finalize(stmt), db);
 
   /* If we've got mergeinfo data, transform it from the db into a
      mergeinfo hash */
- if (count > 0)
+ if (lastmerged_rev > 0)
     {
- SVN_ERR(parse_mergeinfo_from_db(db, path, rev, &path_mergeinfo, pool));
+ SVN_ERR(parse_mergeinfo_from_db(db, path, lastmerged_rev,
+ &path_mergeinfo, pool));
       if (path_mergeinfo)
         {
           if (result)
@@ -446,7 +432,7 @@
     }
 
   /* If this path has no mergeinfo, and we are asked to, check our parent */
- if (count == 0 && include_parents)
+ if (lastmerged_rev == 0 && include_parents)
     {
       svn_stringbuf_t *parentpath;
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Nov 15 11:13:01 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.