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

[PATCH][merge-tracking] Normalizing the merge-tracking sqlite schema

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-09-01 20:39:53 CEST

Hi All,
Find the attached log and patch.

With regards
Kamesh Jayachandran

Index: subversion/libsvn_fs_fs/tree.c
===================================================================
--- subversion/libsvn_fs_fs/tree.c (revision 21323)
+++ subversion/libsvn_fs_fs/tree.c (working copy)
@@ -1103,9 +1103,10 @@
 {
   sqlite3_stmt *stmt;
   sqlite_int64 lastchanged_rev;
+ sqlite_int64 last_mergeid;
   int sqlite_result;
 
- SQLITE_ERR(sqlite3_prepare(db, "SELECT MAX(revision) from mergeinfo_changed"
+ SQLITE_ERR(sqlite3_prepare(db, "SELECT mergeid, 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);
@@ -1115,17 +1116,18 @@
     return svn_error_create(SVN_ERR_FS_SQLITE_ERROR, NULL,
                             sqlite3_errmsg(db));
 
- lastchanged_rev = sqlite3_column_int64(stmt, 0);
+ last_mergeid = sqlite3_column_int64(stmt, 0);
+ lastchanged_rev = sqlite3_column_int64(stmt, 1);
 
   SQLITE_ERR(sqlite3_finalize(stmt), db);
 
   SQLITE_ERR(sqlite3_prepare(db,
                              "SELECT mergedfrom, mergedrevstart,"
                              "mergedrevend from mergeinfo "
- "where mergedto = ? and revision = ? "
+ "where mergeid = ? and revision = ? "
                              "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, 1, last_mergeid), db);
   SQLITE_ERR(sqlite3_bind_int64(stmt, 2, lastchanged_rev), db);
   sqlite_result = sqlite3_step(stmt);
 
Index: subversion/libsvn_fs_fs/fs_fs.c
===================================================================
--- subversion/libsvn_fs_fs/fs_fs.c (revision 21323)
+++ subversion/libsvn_fs_fs/fs_fs.c (working copy)
@@ -4000,11 +4000,28 @@
   apr_hash_index_t *hi;
   sqlite3_stmt *stmt;
   fs_txn_data_t *ftd;
+ sqlite_int64 mergeid;
   
   ftd = txn->fsap_data;
 
   SVN_ERR(svn_mergeinfo_parse(minfostring->data, &minfo, pool));
 
+ SQLITE_ERR (sqlite3_prepare(ftd->mtd,
+ "INSERT INTO mergeinfo_changed (revision, path) VALUES (?, ?);",
+ -1, &stmt, NULL),
+ ftd->mtd);
+ SQLITE_ERR(sqlite3_bind_int64(stmt, 1, new_rev), ftd->mtd);
+
+ SQLITE_ERR(sqlite3_bind_text(stmt, 2, path, -1, SQLITE_TRANSIENT),
+ ftd->mtd);
+
+ if (sqlite3_step(stmt) != SQLITE_DONE)
+ return svn_error_create(SVN_ERR_FS_SQLITE_ERROR, NULL,
+ sqlite3_errmsg(ftd->mtd));
+
+ mergeid = sqlite3_last_insert_rowid(ftd->mtd);
+ SQLITE_ERR(sqlite3_finalize(stmt), ftd->mtd);
+
   for (hi = apr_hash_first(pool, minfo);
        hi != NULL;
        hi = apr_hash_next(hi))
@@ -4023,11 +4040,10 @@
         {
           int i;
           SQLITE_ERR(sqlite3_prepare(ftd->mtd,
- "INSERT INTO mergeinfo (revision, mergedto, mergedfrom, mergedrevstart, mergedrevend) VALUES (?, ?, ?, ?, ?);",
+ "INSERT INTO mergeinfo (revision, mergeid, mergedfrom, mergedrevstart, mergedrevend) VALUES (?, ?, ?, ?, ?);",
                                      -1, &stmt, NULL), ftd->mtd);
           SQLITE_ERR(sqlite3_bind_int64(stmt, 1, new_rev), ftd->mtd);
- SQLITE_ERR(sqlite3_bind_text(stmt, 2, path, -1, SQLITE_TRANSIENT),
- ftd->mtd);
+ SQLITE_ERR(sqlite3_bind_int64(stmt, 2, mergeid), ftd->mtd);
           SQLITE_ERR(sqlite3_bind_text(stmt, 3, from, -1, SQLITE_TRANSIENT),
                      ftd->mtd);
           for (i = 0; i < revlist->nelts; i++)
@@ -4048,21 +4064,7 @@
           SQLITE_ERR(sqlite3_finalize(stmt), ftd->mtd);
         }
     }
- SQLITE_ERR (sqlite3_prepare(ftd->mtd,
- "INSERT INTO mergeinfo_changed (revision, path) VALUES (?, ?);",
- -1, &stmt, NULL),
- ftd->mtd);
- SQLITE_ERR(sqlite3_bind_int64(stmt, 1, new_rev), ftd->mtd);
   
- SQLITE_ERR(sqlite3_bind_text(stmt, 2, path, -1, SQLITE_TRANSIENT),
- ftd->mtd);
-
- if (sqlite3_step(stmt) != SQLITE_DONE)
- return svn_error_create(SVN_ERR_FS_SQLITE_ERROR, NULL,
- sqlite3_errmsg(ftd->mtd));
-
- SQLITE_ERR(sqlite3_finalize(stmt), ftd->mtd);
-
   return SVN_NO_ERROR;
 }
 
@@ -4365,16 +4367,16 @@
 
 const char SVN_MTD_CREATE_SQL[] = "pragma auto_vacuum = 1;"
   APR_EOL_STR
- "create table mergeinfo (revision integer not null, mergedfrom text not null, mergedto text not null, mergedrevstart integer not null, mergedrevend integer not null);"
+ "create table mergeinfo (mergeid integer not null, revision integer not null, mergedfrom text not null, mergedrevstart integer not null, mergedrevend integer not null);"
   APR_EOL_STR
   "create index mi_mergedfrom_idx on mergeinfo (mergedfrom);"
   APR_EOL_STR
- "create index mi_mergedto_idx on mergeinfo (mergedto);"
- APR_EOL_STR
   "create index mi_revision_idx on mergeinfo (revision);"
   APR_EOL_STR
- "create table mergeinfo_changed (revision integer not null, path text not null);"
+ "create index mi_mergeid_idx on mergeinfo (mergeid);"
   APR_EOL_STR
+ "create table mergeinfo_changed (mergeid integer primary key not null, revision integer not null, path text not null);"
+ APR_EOL_STR
   "create unique index mi_c_revpath_idx on mergeinfo_changed (revision, path);"
   APR_EOL_STR
   "create index mi_c_path_idx on mergeinfo_changed (path);"

[[[
Patch by: Kamesh Jayachandran <kamesh@collab.net>

Normalizing the mergeinfo index schema, to avoid duplication of
'mergeinfo.mergedto'.

* subversion/libsvn_fs_fs/fs_fs.c
  (SVN_MTD_CREATE_SQL): Schema change.
    (mergeinfo.mergedto): Removed.
    (mergeinfo.mergedid): Added.
    (mi_mergedto_idx): Removed.
    (mi_mergeid_idx): Added.
    (mergeinfo_changed.mergeid): Added.

  (index_path_merge_info): Adjust for above schema change.

* subversion/libsvn_fs_fs/tree.c
  (parse_mergeinfo_from_db): Adjust for above schema change.

]]]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Sep 1 20:40:34 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.