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/17 12:13:12 UTC

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

Author: philip
Date: Fri Sep 17 10:13:11 2010
New Revision: 998049

URL: http://svn.apache.org/viewvc?rev=998049&view=rev
Log:
Convert two more queries for NODES and add properties comparison.
The comparison is currently disabled for WORKING_NODE because for
base-deleted nodes the NODES table can have properties while they
are null in WORKING_NODE.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_BASE_PROPS_1, STMT_SELECT_WORKING_PROPS_1): New.

* subversion/libsvn_wc/wc_db.c
  (assert_blob_columns_equal): New.
  (assert_base_rows_match): Compare properties.
  (assert_working_rows_match): Disabled properties comparison.
  (svn_wc__db_base_get_prop,
   svn_wc__db_read_pristine_props): Query NODES.

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=998049&r1=998048&r2=998049&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Fri Sep 17 10:13:11 2010
@@ -156,10 +156,19 @@ where wc_id = ?1 and local_relpath = ?2;
 select properties from base_node
 where wc_id = ?1 and local_relpath = ?2;
 
+-- STMT_SELECT_BASE_PROPS_1
+select properties from nodes
+where wc_id = ?1 and local_relpath = ?2 and op_depth = 0;
+
 -- STMT_SELECT_WORKING_PROPS
 SELECT properties, presence FROM WORKING_NODE
 WHERE wc_id = ?1 AND local_relpath = ?2;
 
+-- STMT_SELECT_WORKING_PROPS_1
+SELECT properties, presence FROM NODES
+WHERE wc_id = ?1 AND local_relpath = ?2
+AND op_depth > 0 ORDER BY op_depth DESC LIMIT 1;
+
 -- STMT_SELECT_ACTUAL_PROPS
 select properties from actual_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=998049&r1=998048&r2=998049&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Fri Sep 17 10:13:11 2010
@@ -405,6 +405,27 @@ assert_text_columns_equal(svn_sqlite__st
 }
 
 static svn_error_t *
+assert_blob_columns_equal(svn_sqlite__stmt_t *stmt1,
+                          svn_sqlite__stmt_t *stmt2,
+                          int column,
+                          apr_pool_t *scratch_pool)
+{
+  apr_size_t len1, len2;
+  const void *val1 = svn_sqlite__column_blob(stmt1, column, &len1, NULL);
+  const void *val2 = svn_sqlite__column_blob(stmt2, column, &len2, NULL);
+
+  if (!len1 && !len2)
+    return SVN_NO_ERROR;
+
+  if (len1 != len2 || memcmp(val1, val2, len1))
+    return svn_error_createf(SVN_ERR_WC_CORRUPT, NULL,
+                             "Blob of length %ld in statement 1 differs "
+                             "from blob of length %ld in statement 2",
+                             len1, len2);
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
 assert_base_rows_match(svn_boolean_t have_row1,
                        svn_boolean_t have_row2,
                        svn_sqlite__stmt_t *stmt1,
@@ -453,7 +474,8 @@ assert_base_rows_match(svn_boolean_t hav
     SVN_ERR_ASSERT(svn_sqlite__column_int64(stmt1, 12)
                    == svn_sqlite__column_int64(stmt2, 12));
 
-    /* 14: verify props? */
+    /* verify props */
+    SVN_ERR(assert_blob_columns_equal(stmt1, stmt2, 13, scratch_pool));
   }
 
   return SVN_NO_ERROR;
@@ -511,6 +533,10 @@ assert_working_rows_match(svn_boolean_t 
   SVN_ERR_ASSERT(svn_sqlite__column_int64(stmt1, 14)
                  == svn_sqlite__column_int64(stmt2, 14));
   /* properties */
+#if 0
+  /* Disabled for now as base-deleted don't match */
+  SVN_ERR(assert_blob_columns_equal(stmt1, stmt2, 15, scratch_pool));
+#endif
 
   return SVN_NO_ERROR;
 }
@@ -2429,10 +2455,29 @@ svn_wc__db_base_get_props(apr_hash_t **p
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
   svn_error_t *err;
+#ifdef SVN_WC__NODES
+  svn_sqlite__stmt_t *stmt_node;
+  svn_boolean_t have_node_row;
+#endif
 
+#ifndef SVN_WC__NODES_ONLY
   SVN_ERR(get_statement_for_path(&stmt, db, local_abspath,
                                  STMT_SELECT_BASE_PROPS, scratch_pool));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
+#endif
+#ifdef SVN_WC__NODES
+  SVN_ERR(get_statement_for_path(&stmt_node, db, local_abspath,
+                                 STMT_SELECT_BASE_PROPS_1, scratch_pool));
+  SVN_ERR(svn_sqlite__step(&have_node_row, stmt_node));
+#ifndef SVN_WC__NODES_ONLY
+  SVN_ERR_ASSERT(have_row == have_node_row);
+  SVN_ERR(assert_blob_columns_equal(stmt, stmt_node, 0, scratch_pool));
+  SVN_ERR(svn_sqlite__reset(stmt_node));
+#else
+  stmt = stmt_node;
+  have_row = have_node_row;
+#endif
+#endif
   if (!have_row)
     {
       err = svn_sqlite__reset(stmt);
@@ -5411,10 +5456,34 @@ svn_wc__db_read_pristine_props(apr_hash_
 {
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
+#ifdef SVN_WC__NODES
+  svn_sqlite__stmt_t *stmt_node;
+  svn_boolean_t have_node_row;
+#endif
 
+#ifndef SVN_WC__NODES_ONLY
   SVN_ERR(get_statement_for_path(&stmt, db, local_abspath,
                                  STMT_SELECT_WORKING_PROPS, scratch_pool));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
+#endif
+
+#ifdef SVN_WC__NODES
+  SVN_ERR(get_statement_for_path(&stmt_node, db, local_abspath,
+                                 STMT_SELECT_WORKING_PROPS_1, scratch_pool));
+  SVN_ERR(svn_sqlite__step(&have_node_row, stmt_node));
+
+#ifndef SVN_WC__NODES_ONLY
+  SVN_ERR_ASSERT(have_row == have_node_row);
+#if 0
+  /* Disabled for now as base-deleted don't match */
+  SVN_ERR(assert_blob_columns_equal(stmt, stmt_node, 0, scratch_pool));
+#endif
+  SVN_ERR(svn_sqlite__reset(stmt_node));
+#else
+  stmt = stmt_node;
+  have_row = have_node_row;
+#endif
+#endif
 
   /* If there is a WORKING row, then examine its status: