You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2010/11/02 16:25:15 UTC
svn commit: r1030085 - in /subversion/trunk/subversion/libsvn_wc:
wc-queries.sql wc_db.c
Author: julianfoad
Date: Tue Nov 2 15:25:14 2010
New Revision: 1030085
URL: http://svn.apache.org/viewvc?rev=1030085&view=rev
Log:
Check pre- and post-conditions when deleting a row from the NODES table.
* subversion/libsvn_wc/wc_db.c
(db_working_actual_remove): Check pre- and post-conditions.
* subversion/libsvn_wc/wc-queries.sql
(STMT_SELECT_NODES_GE_OP_DEPTH_RECURSIVE, STMT_SELECT_ACTUAL_NODE_RECURSIVE):
New statements.
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=1030085&r1=1030084&r2=1030085&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Tue Nov 2 15:25:14 2010
@@ -663,6 +663,17 @@ WHERE wc_id = ?1 AND local_relpath = ?2
UPDATE nodes SET repos_id = ?3, repos_path = ?4
WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0;
+-- STMT_SELECT_NODES_GE_OP_DEPTH_RECURSIVE
+SELECT 1
+FROM nodes
+WHERE wc_id = ?1 AND (local_relpath = ?2 OR local_relpath LIKE ?3 ESCAPE '#')
+ AND op_depth >= ?4;
+
+-- STMT_SELECT_ACTUAL_NODE_RECURSIVE
+SELECT 1
+FROM actual_node
+WHERE wc_id = ?1 AND (local_relpath = ?2 OR local_relpath LIKE ?3 ESCAPE '#');
+
/* ------------------------------------------------------------------------- */
/* these are used in entries.c */
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1030085&r1=1030084&r2=1030085&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Nov 2 15:25:14 2010
@@ -4590,6 +4590,21 @@ db_working_actual_remove(svn_wc__db_pdh_
apr_pool_t *scratch_pool)
{
svn_sqlite__stmt_t *stmt;
+ apr_int64_t op_depth;
+
+ /* Precondition: There is a working row in NODES.
+ * Record its op_depth, which is needed for postcondition checking. */
+ {
+ svn_boolean_t have_row;
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
+ STMT_SELECT_WORKING_NODE));
+ SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id, local_relpath));
+ SVN_ERR(svn_sqlite__step(&have_row, stmt));
+ SVN_ERR_ASSERT(have_row);
+ op_depth = svn_sqlite__column_int64(stmt, 0);
+ SVN_ERR(svn_sqlite__reset(stmt));
+ }
SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
STMT_DELETE_WORKING_NODE));
@@ -4603,6 +4618,33 @@ db_working_actual_remove(svn_wc__db_pdh_
SVN_ERR(delete_not_present_children(pdh, local_relpath, scratch_pool));
+ /* Postcondition: There are no NODES rows in this subtree, at same or
+ * greater op_depth. */
+ {
+ svn_boolean_t have_row;
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
+ STMT_SELECT_NODES_GE_OP_DEPTH_RECURSIVE));
+ SVN_ERR(svn_sqlite__bindf(stmt, "issi", pdh->wcroot->wc_id, local_relpath,
+ construct_like_arg(local_relpath, scratch_pool),
+ op_depth));
+ SVN_ERR(svn_sqlite__step(&have_row, stmt));
+ SVN_ERR_ASSERT(! have_row);
+ SVN_ERR(svn_sqlite__reset(stmt));
+ }
+ /* Postcondition: There are no ACTUAL_NODE rows in this subtree. */
+ {
+ svn_boolean_t have_row;
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
+ STMT_SELECT_ACTUAL_NODE_RECURSIVE));
+ SVN_ERR(svn_sqlite__bindf(stmt, "iss", pdh->wcroot->wc_id, local_relpath,
+ construct_like_arg(local_relpath, scratch_pool)));
+ SVN_ERR(svn_sqlite__step(&have_row, stmt));
+ SVN_ERR_ASSERT(! have_row);
+ SVN_ERR(svn_sqlite__reset(stmt));
+ }
+
return SVN_NO_ERROR;
}