Author: rhuijben
Date: Tue Feb 17 15:42:58 2015
New Revision: 1660425
URL: http://svn.apache.org/r1660425
Log:
Commit a disabled simple hack to apply some verifications at the time we close
a wc.db file. This code identified some ACTUAL cleanup problems.
No functional changes (unless VERIFY_ON_CLOSE is defined in maintainer mode)
* subversion/libsvn_wc/wc-checks.sql
(STMT_STATIC_VERIFY): New statement.
* subversion/libsvn_wc/wc_db_wcroot.c
(includes): Add svn_pools.h
(VERIFY_ON_CLOSE): Document undefined macro.
(verify_sqlite): New function, disabled by VERIFY_ON_CLOSE.
(close_wcroot): Call verify_sqlite if defined, and when
SVN_CMDLINE_VERIFY_SQL_AT_CLOSE is set.
Modified:
subversion/trunk/subversion/libsvn_wc/wc-checks.sql
subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c
Modified: subversion/trunk/subversion/libsvn_wc/wc-checks.sql
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-checks.sql?rev=1660425&r1=1660424&r2=1660425&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-checks.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-checks.sql Tue Feb 17 15:42:58 2015
@@ -75,3 +75,36 @@ BEGIN
SELECT RAISE(FAIL, 'WC DB validity check 04 failed');
END;
+-- STMT_STATIC_VERIFY
+SELECT local_relpath, 'SV001: No ancestor in NODES'
+FROM nodes n WHERE local_relpath != ''
+ AND file_external IS NULL
+ AND NOT EXISTS(SELECT 1 from nodes i
+ WHERE i.wc_id=n.wc_id
+ AND i.local_relpath=n.parent_relpath)
+
+UNION ALL
+
+SELECT local_relpath, 'SV002: No ancestor in ACTUAL'
+FROM actual_node a WHERE local_relpath != ''
+ AND NOT EXISTS(SELECT 1 from nodes i
+ WHERE i.wc_id=a.wc_id
+ AND i.local_relpath=a.parent_relpath)
+ AND NOT EXISTS(SELECT 1 from nodes i
+ WHERE i.wc_id=a.wc_id
+ AND i.local_relpath=a.local_relpath)
+
+UNION ALL
+
+SELECT a.local_relpath, 'SV003: Bad or Unneeded actual data'
+FROM actual_node a
+LEFT JOIN nodes n on n.wc_id = a.wc_id AND n.local_relpath = a.local_relpath
+ AND n.op_depth = (SELECT MAX(op_depth) from nodes i
+ WHERE i.wc_id=a.wc_id AND i.local_relpath=a.local_relpath)
+WHERE (a.properties IS NOT NULL
+ AND n.presence NOT IN (MAP_NORMAL, MAP_INCOMPLETE))
+ OR (a.changelist IS NOT NULL AND (n.kind IS NOT NULL AND n.kind !=
MAP_FILE))
+ OR (a.conflict_data IS NULL AND a.properties IS NULL AND a.changelist IS
NULL)
+ AND NOT EXISTS(SELECT 1 from nodes i
+ WHERE i.wc_id=a.wc_id
+ AND i.local_relpath=a.parent_relpath)
Modified: subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c?rev=1660425&r1=1660424&r2=1660425&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_wcroot.c Tue Feb 17 15:42:58
2015
@@ -28,6 +28,7 @@
#include "svn_dirent_uri.h"
#include "svn_hash.h"
#include "svn_path.h"
+#include "svn_pools.h"
#include "svn_version.h"
#include "wc.h"
@@ -42,7 +43,7 @@
#define UNKNOWN_WC_ID ((apr_int64_t) -1)
#define FORMAT_FROM_SDB (-1)
-
+/* #define VERIFY_ON_CLOSE */
/* Get the format version from a wc-1 directory. If it is not a working copy
directory, then it sets VERSION to zero and returns no error. */
@@ -162,6 +163,32 @@ svn_wc__db_verify_no_work(svn_sqlite__db
return SVN_NO_ERROR;
}
+#if defined(VERIFY_ON_CLOSE) && defined(SVN_DEBUG)
+static svn_error_t *
+verify_sqlite(svn_sqlite__db_t *sdb,
+ const char *wc_abspath,
+ apr_pool_t *scratch_pool)
+{
+ svn_sqlite__stmt_t *stmt;
+ svn_boolean_t have_row;
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_STATIC_VERIFY));
+ SVN_ERR(svn_sqlite__step(&have_row, stmt));
+
+ while (have_row)
+ {
+ const char *item = svn_sqlite__column_text(stmt, 0, scratch_pool);
+ const char *msg = svn_sqlite__column_text(stmt, 1, scratch_pool);
+
+ SVN_DBG(("DB-VRFY: %s: %s: %s", wc_abspath, item, msg));
+
+ SVN_ERR(svn_sqlite__step(&have_row, stmt));
+ }
+
+ SVN_ERR(svn_sqlite__reset(stmt));
+ return SVN_NO_ERROR;
+}
+#endif
/* */
static apr_status_t
@@ -172,6 +199,18 @@ close_wcroot(void *data)
SVN_ERR_ASSERT_NO_RETURN(wcroot->sdb != NULL);
+#if defined(VERIFY_ON_CLOSE) && defined(SVN_DEBUG)
+ if (getenv("SVN_CMDLINE_VERIFY_SQL_AT_CLOSE"))
+ {
+ apr_pool_t *scratch_pool = svn_pool_create(NULL);
+
+ svn_error_clear(verify_sqlite(wcroot->sdb, wcroot->abspath,
+ scratch_pool));
+
+ svn_pool_destroy(scratch_pool);
+ }
+#endif
+
err = svn_sqlite__close(wcroot->sdb);
wcroot->sdb = NULL;
if (err)