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 2011/05/26 10:58:42 UTC

svn commit: r1127834 - in /subversion/trunk: Makefile.in subversion/libsvn_wc/upgrade.c subversion/libsvn_wc/wc-checks.sql subversion/libsvn_wc/wc-queries.sql subversion/libsvn_wc/wc_db.c

Author: julianfoad
Date: Thu May 26 08:58:42 2011
New Revision: 1127834

URL: http://svn.apache.org/viewvc?rev=1127834&view=rev
Log:
Write some WC DB verification triggers in SQL.  Add code that will install
them into all new and upgraded DBs when the WC format is bumped to 29.
The verification will not be active until then.

* subversion/libsvn_wc/wc-checks.sql
  (STMT_VERIFICATION_TRIGGERS): New name for the group of statements.
  (validation_01, validation_02): New trigger statements.
  (valid_repos_id_insert): Delete this obsolete trigger statement; it
    operated on the old 'BASE_NODE' table.

* subversion/libsvn_wc/wc-queries.sql
  Include wc-checks.sql.

* subversion/libsvn_wc/upgrade.c
  (bump_to_29): Install the verification trigger statements.

* subversion/libsvn_wc/wc_db.c
  (create_db): Install the verification trigger statements.

* Makefile.in
  Add wc-checks.sql as a dependency of wc-queries.h.

Modified:
    subversion/trunk/Makefile.in
    subversion/trunk/subversion/libsvn_wc/upgrade.c
    subversion/trunk/subversion/libsvn_wc/wc-checks.sql
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c

Modified: subversion/trunk/Makefile.in
URL: http://svn.apache.org/viewvc/subversion/trunk/Makefile.in?rev=1127834&r1=1127833&r2=1127834&view=diff
==============================================================================
--- subversion/trunk/Makefile.in (original)
+++ subversion/trunk/Makefile.in Thu May 26 08:58:42 2011
@@ -849,3 +849,4 @@ extraclean-ctypes-python: clean-ctypes-p
 
 # manually describe a dependency, which we won't otherwise detect
 subversion/libsvn_wc/wc-queries.h: $(abs_srcdir)/subversion/libsvn_wc/wc-metadata.sql
+subversion/libsvn_wc/wc-queries.h: $(abs_srcdir)/subversion/libsvn_wc/wc-checks.sql

Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=1127834&r1=1127833&r2=1127834&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Thu May 26 08:58:42 2011
@@ -1261,6 +1261,7 @@ bump_to_29(void *baton, svn_sqlite__db_t
 
   /* Externals */
   SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_CREATE_EXTERNALS));
+  SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_VERIFICATION_TRIGGERS));
   SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_UPGRADE_TO_29));
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_wc/wc-checks.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-checks.sql?rev=1127834&r1=1127833&r2=1127834&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-checks.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-checks.sql Thu May 26 08:58:42 2011
@@ -22,6 +22,8 @@
  */
 
 
+-- STMT_VERIFICATION_TRIGGERS
+
 /* ------------------------------------------------------------------------- */
 
 CREATE TRIGGER no_repository_updates BEFORE UPDATE ON REPOSITORY
@@ -29,19 +31,21 @@ BEGIN
   SELECT RAISE(FAIL, 'Updates to REPOSITORY are not allowed.');
 END;
 
-
 /* ------------------------------------------------------------------------- */
 
-/* no triggers for WCROOT yet */
-
-
-/* ------------------------------------------------------------------------- */
-
-CREATE TRIGGER valid_repos_id_insert BEFORE INSERT ON BASE_NODE
-WHEN new.repos_id is not null
+/* Verify: on every NODES row: parent_relpath is parent of local_relpath */
+CREATE TRIGGER validation_01 BEFORE INSERT ON NODES
+WHEN NOT ((new.local_relpath = '' AND new.parent_relpath IS NULL)
+          OR (relpath_depth(new.local_relpath)
+              = relpath_depth(new.parent_relpath) + 1))
 BEGIN
-  SELECT * FROM REPOSITORY WHERE id = new.repos_id;
+  SELECT RAISE(FAIL, 'WC DB validity check 01 failed');
 END;
 
+/* Verify: on every NODES row: its op-depth <= its own depth */
+CREATE TRIGGER validation_02 BEFORE INSERT ON NODES
+WHEN NOT new.op_depth <= relpath_depth(new.local_relpath)
+BEGIN
+  SELECT RAISE(FAIL, 'WC DB validity check 02 failed');
+END;
 
-/* ------------------------------------------------------------------------- */

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1127834&r1=1127833&r2=1127834&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Thu May 26 08:58:42 2011
@@ -1289,3 +1289,4 @@ WHERE wc_id == ?1
 /* Grab all the statements related to the schema.  */
 
 -- include: wc-metadata
+-- include: wc-checks

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1127834&r1=1127833&r2=1127834&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu May 26 08:58:42 2011
@@ -1380,6 +1380,7 @@ create_db(svn_sqlite__db_t **sdb,
   SVN_ERR(svn_sqlite__exec_statements(*sdb, STMT_CREATE_NODES_TRIGGERS));
 #if SVN_WC__VERSION >= SVN_WC__HAS_EXTERNALS_STORE
   SVN_ERR(svn_sqlite__exec_statements(*sdb, STMT_CREATE_EXTERNALS));
+  SVN_ERR(svn_sqlite__exec_statements(*sdb, STMT_VERIFICATION_TRIGGERS));
 #endif
 
   /* Insert the repository. */