You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by eh...@apache.org on 2010/09/10 12:31:10 UTC

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

Author: ehu
Date: Fri Sep 10 10:31:10 2010
New Revision: 995737

URL: http://svn.apache.org/viewvc?rev=995737&view=rev
Log:
Convert more queries from NODE_DATA to NODES.

 * subversion/libsvn_wc/wc-queries.sql
   (STMT_INSERT_NODE_DATA,
    STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_BASE_1,
    STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_BASE_2,
    STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_WORKING_1,
    STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_WORKING_2,
    STMT_UPDATE_NODE_DATA_BASE_PROPS,
    STMT_UPDATE_NODE_DATA_WORKING_PROPS): Remove.
   (STMT_INSERT_WORKING_NODE_COPY_FROM_BASE_1,
    STMT_INSERT_WORKING_NODE_COPY_FROM_WORKING_1,
    STMT_UPDATE_NODE_BASE_PROPS,
    STMT_UPDATE_NODE_WORKING_PROPS): Add, with a _1 suffix to 
       be removed when switching to NODES_ONLY.

 * subversion/libsvn_wc/wc_db.c
   (insert_working_node, create_db, svn_wc__db_op_copy,
    svn_wc__db_temp_base_set_props,
    svn_wc__db_temp_working_set_props): Eliminate SVN_WC__NODE_DATA
     sections, replacing with SVN_WC__NODES where appropriate.

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=995737&r1=995736&r2=995737&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Fri Sep 10 10:31:10 2010
@@ -86,15 +86,6 @@ insert or replace into nodes (
 values (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14,
         ?15, ?16, ?17, ?18, ?19);
 
--- STMT_INSERT_NODE_DATA
-insert or replace into node_data (
-   wc_id, local_relpath, op_depth, parent_relpath, presence, kind,
-   changed_revision, changed_date, changed_author, depth, checksum,
-   symlink_target, original_repos_id, original_repos_path,
-   original_revision, properties)
-values (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12,
-        ?13, ?14, ?15, ?16);
-
 -- STMT_INSERT_BASE_NODE_INCOMPLETE
 insert or ignore into base_node (
   wc_id, local_relpath, parent_relpath, presence, kind, revnum)
@@ -156,20 +147,21 @@ where wc_id = ?1 and local_relpath = ?2;
 update base_node set properties = ?3
 where wc_id = ?1 and local_relpath = ?2;
 
--- STMT_UPDATE_NODE_DATA_BASE_PROPS
-update node_data set properties = ?3
+-- STMT_UPDATE_NODE_BASE_PROPS
+update nodes set properties = ?3
 where wc_id = ?1 and local_relpath = ?2 and op_depth = 0;
 
 -- STMT_UPDATE_WORKING_PROPS
 update working_node set properties = ?3
 where wc_id = ?1 and local_relpath = ?2;
 
--- STMT_UPDATE_NODE_DATA_WORKING_PROPS
-update node_data set properties = ?3
+-- STMT_UPDATE_NODE_WORKING_PROPS
+update nodes set properties = ?3
 where wc_id = ?1 and local_relpath = ?2
   and op_depth in
-   (select max(op_depth) from node_data
-    where wc_id = ?1 and local_relpath = ?2);
+   (select op_depth from nodes
+    where wc_id = ?1 and local_relpath = ?2
+    limit 1);
 
 -- STMT_UPDATE_ACTUAL_PROPS
 update actual_node set properties = ?3
@@ -638,30 +630,18 @@ SELECT wc_id, ?3 AS local_relpath, ?4 AS
     ?7 AS copyfrom_repos_path, ?8 AS copyfrom_revnum FROM BASE_NODE
 WHERE wc_id = ?1 AND local_relpath = ?2;
 
-
--- STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_BASE_1
-INSERT OR REPLACE INTO NODE_DATA (
-    wc_id, local_relpath, op_depth, parent_relpath, presence, kind, checksum,
-    changed_revision, changed_date, changed_author, depth, symlink_target,
-    properties, original_repos_id, original_repos_path, original_revision )
-SELECT n.wc_id, ?3 AS local_relpath, ?4 AS op_depth, ?5 AS parent_relpath,
-       ?6 AS presence, n.kind, n.checksum, n.changed_revision, n.changed_date,
-       n.changed_author, n.depth, n.symlink_target, n.properties,
-       ?7 AS original_repos_id, ?8 AS original_repos_path,
-       ?9 AS original_revision
-FROM BASE_NODE AS b INNER JOIN NODE_DATA AS n
-     ON b.wc_id = n.wc_id
-     AND b.local_relpath = n.local_relpath
-     AND n.op_depth = 0
-WHERE n.wc_id = ?1 AND n.local_relpath = ?2;
-
--- STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_BASE_2
-INSERT OR REPLACE INTO WORKING_NODE (
-   wc_id, local_relpath, parent_relpath, translated_size, last_mod_time )
-SELECT wc_id, local_relpath, parent_relpath, translated_size, last_mod_time
-FROM BASE_NODE
-WHERE wc_id = ?1 AND local_relpath = ?2;
-
+-- STMT_INSERT_WORKING_NODE_COPY_FROM_BASE_1
+insert or replace into NODES (
+    wc_id, local_relpath, op_depth, parent_relpath, repos_id,
+    repos_path, revision, presence, depth, kind, changed_revision,
+    changed_date, changed_author, checksum, properties, translated_size,
+    last_mod_time, symlink_target )
+select wc_id, ?3 as local_relpath, ?4 as op_depth, ?5 as parent_relpath,
+    ?6 as repos_id, ?7 as repos_path, ?8 as revision, ?9 as presence, depth,
+    kind, changed_revision, changed_date, changed_author, checksum, properties,
+    translated_size, last_mod_time, symlink_target
+from NODES
+where wc_id = ?1 and local_relpath = ?2 and op_depth = 0;
 
 -- STMT_INSERT_WORKING_NODE_COPY_FROM_WORKING
 INSERT OR REPLACE INTO WORKING_NODE (
@@ -675,33 +655,20 @@ SELECT wc_id, ?3 AS local_relpath, ?4 AS
     ?7 AS copyfrom_repos_path, ?8 AS copyfrom_revnum FROM WORKING_NODE
 WHERE wc_id = ?1 AND local_relpath = ?2;
 
-
--- STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_WORKING_1
-INSERT OR REPLACE INTO NODE_DATA (
-    wc_id, local_relpath, op_depth, parent_relpath, presence, kind, checksum,
-    changed_revision, changed_date, changed_author, depth, symlink_target,
-    properties, original_repos_id, original_repos_path, original_revision )
-SELECT n.wc_id, ?3 AS local_relpath, ?4 AS op_depth, ?5 AS parent_relpath,
-       ?6 AS presence, n.kind, n.checksum, n.changed_revision, n.changed_date,
-       n.changed_author, n.depth, n.symlink_target, n.properties,
-       ?7 AS original_repos_id, ?8 AS original_repos_path,
-       ?9 as original_revision
-FROM WORKING_NODE AS w INNER JOIN NODE_DATA AS n
-     ON w.wc_id = n.wc_id
-     AND w.local_relpath = n.local_relpath
-WHERE w.wc_id = ?1 AND w.local_relpath = ?2
-ORDER BY n.op_depth
-LIMIT 1;
-
--- STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_WORKING_2
-/* ### there's probably no need to set translated_size and last_mod_time,
-   they are probably set again later (after re-expanding the base) */
-INSERT OR REPLACE INTO WORKING_NODE (
-    wc_id, local_relpath, parent_relpath, translated_size, last_mod_time )
-SELECT wc_id, ?3 as local_relpath, ?4 as parent_relpath,
-       translated_size, last_mod_time
-FROM WORKING_NODE
-WHERE wc_id = ?1 AND local_relpath = ?2;
+-- STMT_INSERT_WORKING_NODE_COPY_FROM_WORKING_1
+insert or replace into NODES (
+    wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path,
+    revision, presence, depth, kind, changed_revision, changed_date,
+    changed_author, checksum, properties, translated_size, last_mod_time,
+    symlink_target )
+select wc_id, ?3 as local_relpath, ?4 as op_depth, ?5 as parent_relpath,
+    ?6 as repos_id, ?7 as repos_path, ?8 as revision, ?9 as presence, depth,
+    kind, changed_revision, changed_date, changed_author, checksum, properties,
+    translated_size, last_mod_time, symlink_target
+from NODES
+where wc_id = ?1 and local_relpath = ?2
+order by op_depth desc
+limit 1;
 
 -- STMT_INSERT_ACTUAL_NODE_FROM_ACTUAL_NODE
 INSERT OR REPLACE INTO ACTUAL_NODE (

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=995737&r1=995736&r2=995737&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Fri Sep 10 10:31:10 2010
@@ -839,7 +839,7 @@ insert_working_node(void *baton,
   const insert_working_baton_t *piwb = baton;
   const char *parent_relpath;
   svn_sqlite__stmt_t *stmt;
-#ifdef SVN_WC__NODE_DATA
+#ifdef SVN_WC__NODES
   svn_sqlite__stmt_t *stmt_node;
   apr_int64_t op_depth;
 #endif
@@ -852,6 +852,7 @@ insert_working_node(void *baton,
   else
     parent_relpath = svn_relpath_dirname(piwb->local_relpath, scratch_pool);
 
+#ifndef SVN_WC__NODES_ONLY
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_INSERT_WORKING_NODE));
   SVN_ERR(svn_sqlite__bindf(stmt, "isstt",
                             piwb->wc_id, piwb->local_relpath,
@@ -907,55 +908,51 @@ insert_working_node(void *baton,
 
   SVN_ERR(svn_sqlite__insert(NULL, stmt));
 
+#endif
 
-#ifdef SVN_WC__NODE_DATA
+#ifdef SVN_WC__NODES
   op_depth = (parent_relpath == NULL) ? 1   /* THIS_DIR */
                                       : 2;  /* immediate children */
-  SVN_ERR(svn_sqlite__get_statement(&stmt_node, sdb, STMT_INSERT_NODE_DATA));
-  SVN_ERR(svn_sqlite__bindf(stmt_node, "isistt",
-                            piwb->wc_id, piwb->local_relpath,
-                            op_depth,
-                            parent_relpath,
-                            presence_map, piwb->presence,
-                            kind_map, piwb->kind));
+  SVN_ERR(svn_sqlite__get_statement(&stmt_node, sdb, STMT_INSERT_NODE));
+  SVN_ERR(svn_sqlite__bindf(stmt_node, "isisnnntstrisn"
+                "nnnn" /* properties translated_size last_mod_time dav_cache */
+                "s",
+                piwb->wc_id, piwb->local_relpath,
+                op_depth,
+                parent_relpath,
+                presence_map, piwb->presence,
+                (piwb->kind == svn_wc__db_kind_dir)
+                            ? svn_depth_to_word(piwb->depth) : NULL,
+                kind_map, piwb->kind,
+                piwb->changed_rev,
+                piwb->changed_date,
+                piwb->changed_author,
+                (piwb->kind == svn_wc__db_kind_symlink)
+                            ? piwb->target : NULL));
 
-  if (SVN_IS_VALID_REVNUM(piwb->changed_rev))
-    SVN_ERR(svn_sqlite__bind_int64(stmt_node, 7, piwb->changed_rev));
-  if (piwb->changed_date)
-    SVN_ERR(svn_sqlite__bind_int64(stmt_node, 8, piwb->changed_date));
-  if (piwb->changed_author)
-    SVN_ERR(svn_sqlite__bind_text(stmt_node, 9, piwb->changed_author));
 
-  if (piwb->kind == svn_wc__db_kind_dir)
+  if (piwb->kind == svn_wc__db_kind_file)
     {
-      SVN_ERR(svn_sqlite__bind_text(stmt_node, 10,
-                                    svn_depth_to_word(piwb->depth)));
-    }
-  else if (piwb->kind == svn_wc__db_kind_file)
-    {
-      SVN_ERR(svn_sqlite__bind_checksum(stmt_node, 11, piwb->checksum,
+      SVN_ERR(svn_sqlite__bind_checksum(stmt_node, 14, piwb->checksum,
                                         scratch_pool));
     }
   else if (piwb->kind == svn_wc__db_kind_symlink)
     {
       /* Note: incomplete nodes may have a NULL target.  */
       if (piwb->target)
-        SVN_ERR(svn_sqlite__bind_text(stmt_node, 12, piwb->target));
+        SVN_ERR(svn_sqlite__bind_text(stmt_node, 19, piwb->target));
     }
 
   if (piwb->original_repos_relpath != NULL)
     {
-      SVN_ERR(svn_sqlite__bind_int64(stmt_node, 13, piwb->original_repos_id));
-      SVN_ERR(svn_sqlite__bind_text(stmt_node, 14,
+      SVN_ERR(svn_sqlite__bind_int64(stmt_node, 5, piwb->original_repos_id));
+      SVN_ERR(svn_sqlite__bind_text(stmt_node, 6,
                     piwb->original_repos_relpath));
-      SVN_ERR(svn_sqlite__bind_int64(stmt_node, 15, piwb->original_revnum));
+      SVN_ERR(svn_sqlite__bind_int64(stmt_node, 7, piwb->original_revnum));
     }
 
 
-  /* Don't bind original_repos_id, original_repos_path and original_revision */
-
-
-  SVN_ERR(svn_sqlite__bind_properties(stmt_node, 16, piwb->props,
+  SVN_ERR(svn_sqlite__bind_properties(stmt_node, 15, piwb->props,
                       scratch_pool));
 
   SVN_ERR(svn_sqlite__insert(NULL, stmt_node));
@@ -1382,11 +1379,6 @@ create_db(svn_sqlite__db_t **sdb,
   /* Create the database's schema.  */
   SVN_ERR(svn_sqlite__exec_statements(*sdb, STMT_CREATE_SCHEMA));
 
-#ifdef SVN_WC__NODE_DATA
-  /* Create the NODE_DATA table for the experimental schema */
-  SVN_ERR(svn_sqlite__exec_statements(*sdb, STMT_CREATE_NODE_DATA));
-#endif
-
 #ifdef SVN_WC__NODES
   /* Create the NODES table for the experimental schema */
   SVN_ERR(svn_sqlite__exec_statements(*sdb, STMT_CREATE_NODES));
@@ -3207,6 +3199,7 @@ svn_wc__db_op_copy(svn_wc__db_t *db,
       const char *dst_parent_relpath = svn_relpath_dirname(dst_relpath,
                                                            scratch_pool);
 
+#ifndef SVN_WC__NODES_ONLY
       if (have_work)
         SVN_ERR(svn_sqlite__get_statement(&stmt, src_pdh->wcroot->sdb,
                                   STMT_INSERT_WORKING_NODE_COPY_FROM_WORKING));
@@ -3226,17 +3219,18 @@ svn_wc__db_op_copy(svn_wc__db_t *db,
           SVN_ERR(svn_sqlite__bind_int64(stmt, 8, copyfrom_rev));
         }
       SVN_ERR(svn_sqlite__step_done(stmt));
+#endif
 
-#ifdef SVN_WC__NODE_DATA
+#ifdef SVN_WC__NODES
 
       if (have_work)
         SVN_ERR(svn_sqlite__get_statement(&stmt, src_pdh->wcroot->sdb,
-                         STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_WORKING_1));
+                         STMT_INSERT_WORKING_NODE_COPY_FROM_WORKING_1));
       else
         SVN_ERR(svn_sqlite__get_statement(&stmt, src_pdh->wcroot->sdb,
-                          STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_BASE_1));
+                          STMT_INSERT_WORKING_NODE_COPY_FROM_BASE_1));
 
-      SVN_ERR(svn_sqlite__bindf(stmt, "issist",
+      SVN_ERR(svn_sqlite__bindf(stmt, "issisnnnt",
                     src_pdh->wcroot->wc_id, src_relpath,
                     dst_relpath,
                     (children == NULL) ? (apr_int64_t)2 :
@@ -3246,28 +3240,12 @@ svn_wc__db_op_copy(svn_wc__db_t *db,
 
       if (copyfrom_relpath)
         {
-          SVN_ERR(svn_sqlite__bind_int64(stmt, 7, copyfrom_id));
-          SVN_ERR(svn_sqlite__bind_text(stmt, 8, copyfrom_relpath));
-          SVN_ERR(svn_sqlite__bind_int64(stmt, 9, copyfrom_rev));
+          SVN_ERR(svn_sqlite__bind_int64(stmt, 6, copyfrom_id));
+          SVN_ERR(svn_sqlite__bind_text(stmt, 7, copyfrom_relpath));
+          SVN_ERR(svn_sqlite__bind_int64(stmt, 8, copyfrom_rev));
         }
       SVN_ERR(svn_sqlite__step_done(stmt));
 
-#if 0
-      /* ### NODE_DATA the section below can only be enabled once we stop
-         running STMT_INSERT_WORKING_NODE_COPY_FROM_{BASE,WORKING} above */
-      if (have_work)
-        SVN_ERR(svn_sqlite__get_statement(&stmt, src_pdh->wcroot->sdb,
-                            STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_WORKING_2));
-      else
-        SVN_ERR(svn_sqlite__get_statement(&stmt, src_pdh->wcroot->sdb,
-                            STMT_INSERT_WORKING_NODE_DATA_COPY_FROM_BASE_2));
-
-      SVN_ERR(svn_sqlite__bindf(stmt, "isss",
-                                src_pdh->wcroot->wc_id, src_relpath,
-                                dst_relpath, dst_parent_relpath));
-
-      SVN_ERR(svn_sqlite__step_done(stmt));
-#endif
 #endif
 
       /* ### Copying changelist is OK for a move but what about a copy? */
@@ -3740,15 +3718,20 @@ svn_wc__db_temp_base_set_props(svn_wc__d
                                const apr_hash_t *props,
                                apr_pool_t *scratch_pool)
 {
-#ifdef SVN_WC__NODE_DATA
+#ifdef SVN_WC__NODES
   SVN_ERR(set_properties(db, local_abspath, props,
-                         STMT_UPDATE_NODE_DATA_BASE_PROPS,
+                         STMT_UPDATE_NODE_BASE_PROPS,
                          "base node", scratch_pool));
 #endif
+
+#ifndef SVN_WC__NODES_ONLY
   return svn_error_return(set_properties(db, local_abspath, props,
                                          STMT_UPDATE_BASE_PROPS,
                                          "base_node",
                                          scratch_pool));
+#else
+  return SVN_NO_ERROR;
+#endif
 }
 
 
@@ -3758,15 +3741,20 @@ svn_wc__db_temp_working_set_props(svn_wc
                                   const apr_hash_t *props,
                                   apr_pool_t *scratch_pool)
 {
-#ifdef SVN_WC__NODE_DATA
+#ifdef SVN_WC__NODES
   SVN_ERR(set_properties(db, local_abspath, props,
-                         STMT_UPDATE_NODE_DATA_WORKING_PROPS,
+                         STMT_UPDATE_NODE_WORKING_PROPS,
                          "working node", scratch_pool));
 #endif
+
+#ifndef SVN_WC__NODES_ONLY
   return svn_error_return(set_properties(db, local_abspath, props,
                                          STMT_UPDATE_WORKING_PROPS,
                                          "working_node",
                                          scratch_pool));
+#else
+  return SVN_NO_ERROR;
+#endif
 }
 
 #endif /* SVN__SUPPORT_BASE_MERGE  */