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 2013/11/05 11:07:34 UTC
svn commit: r1538925 - in /subversion/trunk/subversion/libsvn_wc:
wc-queries.sql wc_db.c
Author: rhuijben
Date: Tue Nov 5 10:07:34 2013
New Revision: 1538925
URL: http://svn.apache.org/r1538925
Log:
Tweak some wc.db query usages in preparation for changing
svn_wc__db_retract_parent_delete()'s behavior to keep
the moved to state valid.
No functional changes.
* subversion/libsvn_wc/wc-queries.sql
(STMT_DELETE_NODE): Redefine with additional argument, as this name
didn't explain the true behavior anyway.
(STMT_DELETE_ALL_LAYERS): Rename to ...
(STMT_DELETE_NODE_ALL_LAYERS): ... this, to document that it removes
all layers of a node by its name.
* subversion/libsvn_wc/wc_db.c
(svn_wc__db_retract_parent_delete): Implement logic in c that used to be
performed in sqlite to allow handling other cases. Document what needs
to be fixed. As this function is only used within sqlite transactions
there is no measurable performance impact.
(remove_node_txn,
commit_node): Use STMT_DELETE_NODE_ALL_LAYERS instead of the old,
but (identical) STMT_DELETE_NODE.
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=1538925&r1=1538924&r2=1538925&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Tue Nov 5 10:07:34 2013
@@ -198,7 +198,7 @@ WHERE wc_id = ?1
-- STMT_DELETE_NODE
DELETE
FROM NODES
-WHERE wc_id = ?1 AND local_relpath = ?2
+WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?3
-- STMT_DELETE_ACTUAL_FOR_BASE_RECURSIVE
/* The ACTUAL_NODE applies to BASE, unless there is in at least one op_depth
@@ -718,7 +718,7 @@ WHERE wc_id = ?1 AND local_relpath = ?2
WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > ?3)
AND presence = MAP_BASE_DELETED
--- STMT_DELETE_ALL_LAYERS
+-- STMT_DELETE_NODE_ALL_LAYERS
DELETE FROM nodes
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=1538925&r1=1538924&r2=1538925&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Nov 5 10:07:34 2013
@@ -627,6 +627,10 @@ svn_wc__db_extend_parent_delete(svn_wc__
When removing a node if the parent has a higher working node then
the parent node and this node are both deleted or replaced and any
delete over this node must be removed.
+
+ This function (like most wcroot functions) assumes that its caller
+ only uses this function within an sqlite transaction if atomic
+ behavior is needed.
*/
svn_error_t *
svn_wc__db_retract_parent_delete(svn_wc__db_wcroot_t *wcroot,
@@ -635,12 +639,41 @@ svn_wc__db_retract_parent_delete(svn_wc_
apr_pool_t *scratch_pool)
{
svn_sqlite__stmt_t *stmt;
+ svn_boolean_t have_row;
+ int working_depth;
+ svn_wc__db_status_t presence;
+ const char *moved_to;
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
- STMT_DELETE_LOWEST_WORKING_NODE));
+ STMT_SELECT_LOWEST_WORKING_NODE));
SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id, local_relpath,
op_depth));
- SVN_ERR(svn_sqlite__step_done(stmt));
+ SVN_ERR(svn_sqlite__step(&have_row, stmt));
+
+ if (!have_row)
+ return svn_error_trace(svn_sqlite__reset(stmt));
+
+ working_depth = svn_sqlite__column_int(stmt, 0);
+ presence = svn_sqlite__column_token(stmt, 1, presence_map);
+ moved_to = svn_sqlite__column_text(stmt, 3, scratch_pool);
+
+ SVN_ERR(svn_sqlite__reset(stmt));
+
+ if (moved_to)
+ {
+ /* ### TODO: Turn the move into a copy to keep the NODES table
+ valid */
+ }
+
+ if (presence == svn_wc__db_status_base_deleted)
+ {
+ SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, STMT_DELETE_NODE));
+
+ SVN_ERR(svn_sqlite__bindf(stmt, "isd", wcroot->wc_id, local_relpath,
+ working_depth));
+
+ SVN_ERR(svn_sqlite__update(NULL, stmt));
+ }
return SVN_NO_ERROR;
}
@@ -7180,7 +7213,7 @@ remove_node_txn(svn_boolean_t *left_chan
if (local_relpath[0] != '\0')
{
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
- STMT_DELETE_NODE));
+ STMT_DELETE_NODE_ALL_LAYERS));
SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
SVN_ERR(svn_sqlite__step_done(stmt));
}
@@ -10878,7 +10911,7 @@ commit_node(svn_wc__db_wcroot_t *wcroot,
if we need to remove shadowed layers below our descendants. */
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
- STMT_DELETE_ALL_LAYERS));
+ STMT_DELETE_NODE_ALL_LAYERS));
SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));
SVN_ERR(svn_sqlite__update(&affected_rows, stmt));