Author: rhuijben
Date: Tue Feb 17 21:50:39 2015
New Revision: 1660508
URL: http://svn.apache.org/r1660508
Log:
Stop storing values in columns of NODES rows where their presence implies that
they shouldn't have those values, in the few code paths that still added them.
* subversion/libsvn_wc/wc-checks.sql
(STMT_STATIC_VERIFY): Extend verifications.
* subversion/libsvn_wc/wc_db.c
(insert_base_node,
insert_working_node): Stop storing depth, properties when the
node has not a present status.
* subversion/tests/libsvn_wc/wc-test-queries.sql
(STMT_INSERT_NODE): Don't add values invalid for this presence.
Modified:
subversion/trunk/subversion/libsvn_wc/wc-checks.sql
subversion/trunk/subversion/libsvn_wc/wc_db.c
subversion/trunk/subversion/tests/libsvn_wc/wc-test-queries.sql
Modified: subversion/trunk/subversion/libsvn_wc/wc-checks.sql
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-checks.sql?rev=1660508&r1=1660507&r2=1660508&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-checks.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-checks.sql Tue Feb 17 21:50:39 2015
@@ -108,3 +108,30 @@ WHERE (a.properties IS NOT NULL
AND NOT EXISTS(SELECT 1 from nodes i
WHERE i.wc_id=a.wc_id
AND i.local_relpath=a.parent_relpath)
+
+UNION ALL
+
+SELECT local_relpath, 'SV004: Unneeded node data'
+FROM nodes
+WHERE presence NOT IN (MAP_NORMAL, MAP_INCOMPLETE)
+AND (properties IS NOT NULL
+ OR checksum IS NOT NULL
+ OR depth IS NOT NULL
+ OR symlink_target IS NOT NULL
+ OR changed_revision IS NOT NULL
+ OR (changed_date IS NOT NULL AND changed_date != 0)
+ OR changed_author IS NOT NULL
+ OR translated_size IS NOT NULL
+ OR last_mod_time IS NOT NULL
+ OR dav_cache IS NOT NULL
+ OR file_external IS NOT NULL
+ OR inherited_props IS NOT NULL)
+
+UNION ALL
+
+SELECT local_relpath, 'SV005: Unneeded base-deleted node data'
+FROM nodes
+WHERE presence IN (MAP_BASE_DELETED)
+AND (repos_id IS NOT NULL
+ OR repos_path IS NOT NULL
+ OR revision IS NOT NULL)
\ No newline at end of file
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1660508&r1=1660507&r2=1660508&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Tue Feb 17 21:50:39 2015
@@ -743,6 +743,7 @@ insert_base_node(const insert_base_baton
svn_sqlite__stmt_t *stmt;
svn_filesize_t recorded_size = SVN_INVALID_FILESIZE;
apr_int64_t recorded_time;
+ svn_boolean_t present;
/* The directory at the WCROOT has a NULL parent_relpath. Otherwise,
bind the appropriate parent_relpath. */
@@ -773,6 +774,9 @@ insert_base_node(const insert_base_baton
SVN_ERR(svn_sqlite__reset(stmt));
}
+ present = (pibb->status == svn_wc__db_status_normal
+ || pibb->status == svn_wc__db_status_incomplete);
+
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, STMT_INSERT_NODE));
SVN_ERR(svn_sqlite__bindf(stmt, "isdsisr"
"tstr" /* 8 - 11 */
@@ -785,15 +789,16 @@ insert_base_node(const insert_base_baton
pibb->repos_relpath,
pibb->revision,
presence_map, pibb->status, /* 8 */
- (pibb->kind == svn_node_dir) ? /* 9 */
- svn_token__to_word(depth_map, pibb->depth) : NULL,
+ (pibb->kind == svn_node_dir && present) /* 9 */
+ ? svn_token__to_word(depth_map, pibb->depth)
+ : NULL,
kind_map, pibb->kind, /* 10 */
pibb->changed_rev, /* 11 */
pibb->changed_date, /* 12 */
pibb->changed_author, /* 13 */
- (pibb->kind == svn_node_symlink) ?
+ (pibb->kind == svn_node_symlink && present) ?
pibb->target : NULL)); /* 19 */
- if (pibb->kind == svn_node_file)
+ if (pibb->kind == svn_node_file && present)
{
if (!pibb->checksum
&& pibb->status != svn_wc__db_status_not_present
@@ -818,11 +823,14 @@ insert_base_node(const insert_base_baton
assert(pibb->status == svn_wc__db_status_normal
|| pibb->status == svn_wc__db_status_incomplete
|| pibb->props == NULL);
- SVN_ERR(svn_sqlite__bind_properties(stmt, 15, pibb->props,
- scratch_pool));
+ if (present)
+ {
+ SVN_ERR(svn_sqlite__bind_properties(stmt, 15, pibb->props,
+ scratch_pool));
- SVN_ERR(svn_sqlite__bind_iprops(stmt, 23, pibb->iprops,
+ SVN_ERR(svn_sqlite__bind_iprops(stmt, 23, pibb->iprops,
scratch_pool));
+ }
if (pibb->dav_cache)
SVN_ERR(svn_sqlite__bind_properties(stmt, 18, pibb->dav_cache,
@@ -1027,6 +1035,7 @@ insert_working_node(const insert_working
const char *moved_to_relpath = NULL;
svn_sqlite__stmt_t *stmt;
svn_boolean_t have_row;
+ svn_boolean_t present;
SVN_ERR_ASSERT(piwb->op_depth > 0);
@@ -1045,6 +1054,9 @@ insert_working_node(const insert_working
moved_to_relpath = svn_sqlite__column_text(stmt, 0, scratch_pool);
SVN_ERR(svn_sqlite__reset(stmt));
+ present = (piwb->presence == svn_wc__db_status_normal
+ || piwb->presence == svn_wc__db_status_incomplete);
+
SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, STMT_INSERT_NODE));
SVN_ERR(svn_sqlite__bindf(stmt, "isdsnnntstrisn"
"nnnn" /* properties translated_size last_mod_time dav_cache */
@@ -1053,14 +1065,14 @@ insert_working_node(const insert_working
piwb->op_depth,
parent_relpath,
presence_map, piwb->presence,
- (piwb->kind == svn_node_dir)
+ (piwb->kind == svn_node_dir && present)
? svn_token__to_word(depth_map, piwb->depth) :
NULL,
kind_map, piwb->kind,
piwb->changed_rev,
piwb->changed_date,
piwb->changed_author,
/* Note: incomplete nodes may have a NULL target. */
- (piwb->kind == svn_node_symlink)
+ (piwb->kind == svn_node_symlink && present)
? piwb->target : NULL,
moved_to_relpath));
@@ -1069,7 +1081,7 @@ insert_working_node(const insert_working
SVN_ERR(svn_sqlite__bind_int(stmt, 8, TRUE));
}
- if (piwb->kind == svn_node_file)
+ if (piwb->kind == svn_node_file && present)
{
SVN_ERR(svn_sqlite__bind_checksum(stmt, 14, piwb->checksum,
scratch_pool));
@@ -1086,7 +1098,8 @@ insert_working_node(const insert_working
assert(piwb->presence == svn_wc__db_status_normal
|| piwb->presence == svn_wc__db_status_incomplete
|| piwb->props == NULL);
- SVN_ERR(svn_sqlite__bind_properties(stmt, 15, piwb->props, scratch_pool));
+ if (present)
+ SVN_ERR(svn_sqlite__bind_properties(stmt, 15, piwb->props, scratch_pool));
SVN_ERR(svn_sqlite__insert(NULL, stmt));
Modified: subversion/trunk/subversion/tests/libsvn_wc/wc-test-queries.sql
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/wc-test-queries.sql?rev=1660508&r1=1660507&r2=1660508&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/wc-test-queries.sql (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/wc-test-queries.sql Tue Feb 17
21:50:39 2015
@@ -45,7 +45,11 @@ DELETE FROM nodes;
-- STMT_INSERT_NODE
INSERT INTO nodes (local_relpath, op_depth, presence, repos_path,
revision, parent_relpath, wc_id, repos_id, kind, depth)
- VALUES (?1, ?2, ?3, ?4, ?5, ?6, 1, 1, 'dir', 'infinity')
+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, 1,
+ CASE WHEN ?3 != 'base-deleted' THEN 1 END,
+ 'dir',
+ CASE WHEN ?3 in ('normal', 'incomplete')
+ THEN 'infinity' END)
-- STMT_DELETE_ACTUAL
DELETE FROM actual_node;