You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2012/05/20 16:03:12 UTC

svn commit: r1340725 - in /subversion/trunk/subversion/libsvn_wc: wc-queries.sql wc_db.c

Author: rhuijben
Date: Sun May 20 14:03:12 2012
New Revision: 1340725

URL: http://svn.apache.org/viewvc?rev=1340725&view=rev
Log:
Split two more wc.db sqlite statements to avoid table scans on the ACTUAL table
during delete and revert handling.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_DELETE_ALL_NODES_ABOVE_DEPTH): Renumber argument.

  (STMT_DELETE_ACTUAL_NODE_LEAVING_CHANGELIST_RECURSIVE):
    Remove handling of wcroot.
  (STMT_DELETE_ALL_ACTUAL_NODE_LEAVING_CHANGELIST):
    New statement for wcroot.

  (STMT_CLEAR_ACTUAL_NODE_LEAVING_CHANGELIST_RECURSIVE):
    Remove handling of wcroot.
  (STMT_CLEAR_ALL_ACTUAL_NODE_LEAVING_CHANGELIST):
    New statement for wcroot.

* subversion/libsvn_wc/wc_db.c
  (op_revert_recursive_txn): Separate queries for wcroot and
    not-wcroot. Avoid unused sqlite arguments.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1340725&r1=1340724&r2=1340725&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Sun May 20 14:03:12 2012
@@ -612,7 +612,7 @@ WHERE wc_id = ?1
 -- STMT_DELETE_ALL_NODES_ABOVE_DEPTH
 DELETE FROM nodes
 WHERE wc_id = ?1
-  AND op_depth >= ?3
+  AND op_depth >= ?2
 
 -- STMT_DELETE_ACTUAL_NODE
 DELETE FROM actual_node
@@ -639,11 +639,11 @@ WHERE wc_id = ?1
                       WHERE c.wc_id = ?1 AND c.local_relpath = ?2
                         AND c.kind = 'file'))
 
+/* Not valid for the wc-root */
 -- STMT_DELETE_ACTUAL_NODE_LEAVING_CHANGELIST_RECURSIVE
 DELETE FROM actual_node
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
+  AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
   AND (changelist IS NULL
        OR NOT EXISTS (SELECT 1 FROM nodes_current c
@@ -651,6 +651,15 @@ WHERE wc_id = ?1
                         AND c.local_relpath = actual_node.local_relpath
                         AND c.kind = 'file'))
 
+-- STMT_DELETE_ALL_ACTUAL_NODE_LEAVING_CHANGELIST
+DELETE FROM actual_node
+WHERE wc_id = ?1
+  AND (changelist IS NULL
+       OR NOT EXISTS (SELECT 1 FROM nodes_current c
+                      WHERE c.wc_id = ?1 
+                        AND c.local_relpath = actual_node.local_relpath
+                        AND c.kind = 'file'))
+
 -- STMT_CLEAR_ACTUAL_NODE_LEAVING_CHANGELIST
 UPDATE actual_node
 SET properties = NULL,
@@ -665,6 +674,7 @@ SET properties = NULL,
     right_checksum = NULL
 WHERE wc_id = ?1 AND local_relpath = ?2
 
+/* Not valid for the wc-root */
 -- STMT_CLEAR_ACTUAL_NODE_LEAVING_CHANGELIST_RECURSIVE
 UPDATE actual_node
 SET properties = NULL,
@@ -678,10 +688,23 @@ SET properties = NULL,
     left_checksum = NULL,
     right_checksum = NULL
 WHERE wc_id = ?1
-  AND (?2 = ''
-       OR local_relpath = ?2
+  AND (local_relpath = ?2
        OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
 
+-- STMT_CLEAR_ALL_ACTUAL_NODE_LEAVING_CHANGELIST
+UPDATE actual_node
+SET properties = NULL,
+    text_mod = NULL,
+    tree_conflict_data = NULL,
+    conflict_old = NULL,
+    conflict_new = NULL,
+    conflict_working = NULL,
+    prop_reject = NULL,
+    older_checksum = NULL,
+    left_checksum = NULL,
+    right_checksum = NULL
+WHERE wc_id = ?1
+
 -- STMT_UPDATE_NODE_BASE_DEPTH
 UPDATE nodes SET depth = ?3
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1340725&r1=1340724&r2=1340725&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Sun May 20 14:03:12 2012
@@ -5559,26 +5559,49 @@ op_revert_recursive_txn(void *baton,
   /* Don't delete BASE nodes */
   select_op_depth = op_depth ? op_depth : 1;
 
-  SVN_ERR(svn_sqlite__get_statement(
-                    &stmt, wcroot->sdb,
-                    (local_relpath[0] == '\0')
-                            ? STMT_DELETE_ALL_NODES_ABOVE_DEPTH
-                            : STMT_DELETE_NODES_ABOVE_DEPTH_RECURSIVE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id,
-                            local_relpath, select_op_depth));
-  SVN_ERR(svn_sqlite__step_done(stmt));
+  if (local_relpath[0] == '\0')
+    {
+      /* Reverting the wc-root. Use the table-scan queries */
+      SVN_ERR(svn_sqlite__get_statement(
+                            &stmt, wcroot->sdb,
+                            STMT_DELETE_ALL_NODES_ABOVE_DEPTH));
+      SVN_ERR(svn_sqlite__bindf(stmt, "id", wcroot->wc_id, select_op_depth));
+      SVN_ERR(svn_sqlite__step_done(stmt));
 
-  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+      SVN_ERR(svn_sqlite__get_statement(
+                            &stmt, wcroot->sdb,
+                            STMT_DELETE_ALL_ACTUAL_NODE_LEAVING_CHANGELIST));
+      SVN_ERR(svn_sqlite__bind_int(stmt, 1, wcroot->wc_id));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+
+      SVN_ERR(svn_sqlite__get_statement(
+                            &stmt, wcroot->sdb,
+                            STMT_CLEAR_ALL_ACTUAL_NODE_LEAVING_CHANGELIST));
+      SVN_ERR(svn_sqlite__bind_int(stmt, 1, wcroot->wc_id));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+  }
+  else
+    {
+      /* Reverting any non wc-root node */
+      SVN_ERR(svn_sqlite__get_statement(
+                        &stmt, wcroot->sdb,
+                        STMT_DELETE_NODES_ABOVE_DEPTH_RECURSIVE));
+      SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id,
+                        local_relpath, select_op_depth));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+
+      SVN_ERR(svn_sqlite__get_statement(
+                        &stmt, wcroot->sdb,
                         STMT_DELETE_ACTUAL_NODE_LEAVING_CHANGELIST_RECURSIVE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id,
-                            local_relpath));
-  SVN_ERR(svn_sqlite__step_done(stmt));
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+      SVN_ERR(svn_sqlite__step_done(stmt));
 
-  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+      SVN_ERR(svn_sqlite__get_statement(
+                        &stmt, wcroot->sdb,
                         STMT_CLEAR_ACTUAL_NODE_LEAVING_CHANGELIST_RECURSIVE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id,
-                            local_relpath));
-  SVN_ERR(svn_sqlite__step_done(stmt));
+      SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
+      SVN_ERR(svn_sqlite__step_done(stmt));
+    }
 
   /* ### This removes the locks, but what about the access batons? */
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,