You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2010/09/21 19:02:42 UTC

svn commit: r999498 - in /subversion/trunk/subversion: libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c tests/libsvn_wc/db-test.c

Author: philip
Date: Tue Sep 21 17:02:41 2010
New Revision: 999498

URL: http://svn.apache.org/viewvc?rev=999498&view=rev
Log:
Convert some more queries to NODES, this is sufficient for
a simple status to work with SVN_WC__NODES_ONLY.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_COUNT_BASE_NODE_CHILDREN_1,
   STMT_COUNT_WORKING_NODE_CHILDREN_1,
   STMT_SELECT_BASE_NODE_CHILDREN_1,
   STMT_SELECT_WORKING_NODE_CHILDREN_1): New.

* subversion/libsvn_wc/wc_db.c
  (union_children, gather_children): Query the NODES table.

* subversion/tests/libsvn_wc/db-test.c
  (TESTING_DATA): Insert NODES data for M and M/M-a.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/tests/libsvn_wc/db-test.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=999498&r1=999497&r2=999498&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Tue Sep 21 17:02:41 2010
@@ -132,18 +132,43 @@ VALUES (?1, ?2, ?3, 'incomplete', 'unkno
 SELECT COUNT(*) FROM BASE_NODE
 WHERE wc_id = ?1 AND parent_relpath = ?2;
 
+-- STMT_COUNT_BASE_NODE_CHILDREN_1
+SELECT COUNT(*) FROM NODES
+WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth = 0;
+
 -- STMT_COUNT_WORKING_NODE_CHILDREN
 SELECT COUNT(*) FROM WORKING_NODE
 WHERE wc_id = ?1 AND parent_relpath = ?2;
 
+-- STMT_COUNT_WORKING_NODE_CHILDREN_1
+SELECT COUNT(*) FROM NODES
+WHERE wc_id = ?1 AND parent_relpath = ?2
+  AND op_depth IN (SELECT op_depth FROM NODES
+                   WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth > 0
+                   ORDER BY op_depth DESC
+                   LIMIT 1);
+
+
 -- STMT_SELECT_BASE_NODE_CHILDREN
 select local_relpath from base_node
 where wc_id = ?1 and parent_relpath = ?2;
 
+-- STMT_SELECT_BASE_NODE_CHILDREN_1
+select local_relpath from nodes
+where wc_id = ?1 and parent_relpath = ?2 and op_depth = 0;
+
 -- STMT_SELECT_WORKING_NODE_CHILDREN
 SELECT local_relpath FROM WORKING_NODE
 WHERE wc_id = ?1 AND parent_relpath = ?2;
 
+-- STMT_SELECT_WORKING_NODE_CHILDREN_1
+SELECT local_relpath FROM NODES
+WHERE wc_id = ?1 AND parent_relpath = ?2
+  AND op_depth IN (SELECT op_depth FROM NODES
+                   WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth > 0
+                   ORDER BY op_depth DESC
+                   LIMIT 1);
+
 -- STMT_SELECT_WORKING_IS_FILE
 select kind == 'file' from working_node
 where wc_id = ?1 and local_relpath = ?2;

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=999498&r1=999497&r2=999498&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Sep 21 17:02:41 2010
@@ -1231,6 +1231,9 @@ union_children(const apr_array_header_t 
 {
   /* ### it would be nice to pre-size this hash table.  */
   apr_hash_t *names = apr_hash_make(scratch_pool);
+#ifdef SVN_WC__NODES
+  apr_hash_t *names_nodes = apr_hash_make(scratch_pool);
+#endif
   apr_array_header_t *names_array;
 
   /* All of the names get allocated in RESULT_POOL.  */
@@ -1238,6 +1241,17 @@ union_children(const apr_array_header_t 
                                sdb, wc_id, parent_relpath, result_pool));
   SVN_ERR(add_children_to_hash(names, STMT_SELECT_WORKING_NODE_CHILDREN,
                                sdb, wc_id, parent_relpath, result_pool));
+#ifdef SVN_WC__NODES
+  SVN_ERR(add_children_to_hash(names_nodes, STMT_SELECT_BASE_NODE_CHILDREN_1,
+                               sdb, wc_id, parent_relpath, result_pool));
+  SVN_ERR(add_children_to_hash(names_nodes, STMT_SELECT_WORKING_NODE_CHILDREN_1,
+                               sdb, wc_id, parent_relpath, result_pool));
+#ifndef SVN_WC__NODES_ONLY
+  SVN_ERR_ASSERT(apr_hash_count(names) == apr_hash_count(names_nodes));
+#else
+  names = names_nodes;
+#endif
+#endif
 
   SVN_ERR(svn_hash_keys(&names_array, names, result_pool));
   *children = names_array;
@@ -1306,6 +1320,10 @@ gather_children(const apr_array_header_t
   const char *local_relpath;
   int base_count;
   int working_count;
+#ifdef SVN_WC__NODES
+  int base_count_nodes, working_count_nodes;
+  const apr_array_header_t *children_nodes;
+#endif
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
 
@@ -1321,17 +1339,47 @@ gather_children(const apr_array_header_t
          directory in its repository.
 
          ### note "files". should redo count with subdirs included */
-      return svn_error_return(single_table_children(
-                                children, STMT_SELECT_BASE_NODE_CHILDREN,
-                                10 /* start_size */,
-                                pdh->wcroot->sdb, pdh->wcroot->wc_id,
-                                local_relpath, result_pool));
+#ifndef SVN_WC__NODES_ONLY
+      SVN_ERR(single_table_children(children, STMT_SELECT_BASE_NODE_CHILDREN,
+                                    10 /* start_size */,
+                                    pdh->wcroot->sdb, pdh->wcroot->wc_id,
+                                    local_relpath, result_pool));
+#endif
+#ifdef SVN_WC__NODES
+      SVN_ERR(single_table_children(&children_nodes,
+                                    STMT_SELECT_BASE_NODE_CHILDREN_1,
+                                    10 /* start_size */,
+                                    pdh->wcroot->sdb, pdh->wcroot->wc_id,
+                                    local_relpath, result_pool));
+#ifndef SVN_WC__NODES_ONLY
+      SVN_ERR_ASSERT((*children)->nelts == children_nodes->nelts);
+#else
+      *children = children_nodes;
+#endif
+#endif
+      return SVN_NO_ERROR;
     }
 
+#ifndef SVN_WC__NODES_ONLY
   SVN_ERR(count_children(&base_count, STMT_COUNT_BASE_NODE_CHILDREN,
                          pdh->wcroot->sdb, pdh->wcroot->wc_id, local_relpath));
   SVN_ERR(count_children(&working_count, STMT_COUNT_WORKING_NODE_CHILDREN,
                          pdh->wcroot->sdb, pdh->wcroot->wc_id, local_relpath));
+#endif
+#ifdef SVN_WC__NODES
+  SVN_ERR(count_children(&base_count_nodes, STMT_COUNT_BASE_NODE_CHILDREN_1,
+                         pdh->wcroot->sdb, pdh->wcroot->wc_id, local_relpath));
+  SVN_ERR(count_children(&working_count_nodes,
+                         STMT_COUNT_WORKING_NODE_CHILDREN_1,
+                         pdh->wcroot->sdb, pdh->wcroot->wc_id, local_relpath));
+#ifndef SVN_WC__NODES_ONLY
+  SVN_ERR_ASSERT(base_count == base_count_nodes);
+  SVN_ERR_ASSERT(working_count == working_count_nodes);
+#else
+  base_count = base_count_nodes;
+  working_count = working_count_nodes;
+#endif
+#endif
 
   if (base_count == 0)
     {
@@ -1341,18 +1389,48 @@ gather_children(const apr_array_header_t
           return SVN_NO_ERROR;
         }
 
-      return svn_error_return(single_table_children(
-                                children, STMT_SELECT_WORKING_NODE_CHILDREN,
-                                working_count,
-                                pdh->wcroot->sdb, pdh->wcroot->wc_id,
-                                local_relpath, result_pool));
+#ifndef SVN_WC__NODES_ONLY
+      SVN_ERR(single_table_children(children, STMT_SELECT_WORKING_NODE_CHILDREN,
+                                    working_count,
+                                    pdh->wcroot->sdb, pdh->wcroot->wc_id,
+                                    local_relpath, result_pool));
+#endif
+#ifdef SVN_WC__NODES
+      SVN_ERR(single_table_children(&children_nodes,
+                                    STMT_SELECT_WORKING_NODE_CHILDREN,
+                                    working_count,
+                                    pdh->wcroot->sdb, pdh->wcroot->wc_id,
+                                    local_relpath, result_pool));
+#ifndef SVN_WC__NODES_ONLY
+      SVN_ERR_ASSERT((*children)->nelts == children_nodes->nelts);
+#else
+      *children = children_nodes;
+#endif
+#endif
+      return SVN_NO_ERROR;
     }
   if (working_count == 0)
-    return svn_error_return(single_table_children(
-                              children, STMT_SELECT_BASE_NODE_CHILDREN,
-                              base_count,
-                              pdh->wcroot->sdb, pdh->wcroot->wc_id,
-                              local_relpath, result_pool));
+    {
+#ifndef SVN_WC__NODES_ONLY
+      SVN_ERR(single_table_children(children, STMT_SELECT_BASE_NODE_CHILDREN,
+                                    base_count,
+                                    pdh->wcroot->sdb, pdh->wcroot->wc_id,
+                                    local_relpath, result_pool));
+#endif
+#ifdef SVN_WC__NODES
+      SVN_ERR(single_table_children(&children_nodes,
+                                    STMT_SELECT_BASE_NODE_CHILDREN_1,
+                                    base_count,
+                                    pdh->wcroot->sdb, pdh->wcroot->wc_id,
+                                    local_relpath, result_pool));
+#ifndef SVN_WC__NODES_ONLY
+      SVN_ERR_ASSERT((*children)->nelts == children_nodes->nelts);
+#else
+      *children = children_nodes;
+#endif
+#endif
+      return SVN_NO_ERROR;
+    }
 
   /* ### it would be nice to pass BASE_COUNT and WORKING_COUNT, but there is
      ### nothing union_children() can do with those.  */

Modified: subversion/trunk/subversion/tests/libsvn_wc/db-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/db-test.c?rev=999498&r1=999497&r2=999498&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/db-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/db-test.c Tue Sep 21 17:02:41 2010
@@ -486,17 +486,15 @@ static const char * const TESTING_DATA =
    "  null, null, null, null, null, "
    "  null, null, null, 0, null, null, '()', 0); "
 #endif
-#ifdef SVN_WC__NODES_not_enabled_yet
+#ifdef SVN_WC__NODES
    "insert into nodes values ("
-   "  1, 'M', null, null, '', 'normal', 'dir', "
-   "  1, null, null, "
-   "  1, " TIME_1s ", '" AUTHOR_1 "', null, null, null, '()', null, null, "
-   "  null); "
+   "  1, 'M', 0, '', null, null, null, 'normal', null, "
+   "  1, null, 'dir', 1, " TIME_1s ", '" AUTHOR_1 "', null, '()', "
+   "  null, null, null, null, null);"
    "insert into nodes values ("
-   "  1, 'M/M-a', 'M', 'not-present', 'file', "
-   "  null, null, "
-   "  null, null, null, null, null, "
-   "  null, null, null, 0, null, null, '()', 0); "
+   "  1, 'M/M-a', 1, 'M', null, null, null, 'not-present', null, "
+   "  null, null, 'file', null, null, null, null, '()', "
+   "  null, 0, null, null, null);"
 #endif
    );