This patch is what I intend to commit just as soon as I get the WC tests
sorted out to install these triggers too.  Just posting this now because
I can't commit it till after the weekend.

- Julian

Install the WC DB validation triggers as temporary triggers on opening the
DB, instead of installing them in the DB.

* subversion/libsvn_wc/upgrade.c
  (bump_to_29): Don't install them here.

* subversion/libsvn_wc/wc-checks.sql
  Mark all these triggers as temporary.

* subversion/libsvn_wc/wc_db.c
  (create_db): Don't install them here.

* subversion/libsvn_wc/wc_db_util.c
  (svn_wc__db_util_open_db): Install the triggers here, after opening the DB.
--This line, and those below, will be ignored--

Index: subversion/libsvn_wc/upgrade.c
===================================================================
--- subversion/libsvn_wc/upgrade.c	(revision 1128387)
+++ subversion/libsvn_wc/upgrade.c	(working copy)
@@ -1261,7 +1261,6 @@ 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;
 }
Index: subversion/libsvn_wc/wc-checks.sql
===================================================================
--- subversion/libsvn_wc/wc-checks.sql	(revision 1128387)
+++ subversion/libsvn_wc/wc-checks.sql	(working copy)
@@ -26,7 +26,7 @@
 
 /* ------------------------------------------------------------------------- */
 
-CREATE TRIGGER no_repository_updates BEFORE UPDATE ON REPOSITORY
+CREATE TEMP TRIGGER no_repository_updates BEFORE UPDATE ON REPOSITORY
 BEGIN
   SELECT RAISE(FAIL, 'Updates to REPOSITORY are not allowed.');
 END;
@@ -34,7 +34,7 @@ END;
 /* ------------------------------------------------------------------------- */
 
 /* Verify: on every NODES row: parent_relpath is parent of local_relpath */
-CREATE TRIGGER validation_01 BEFORE INSERT ON NODES
+CREATE TEMP 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))
@@ -43,14 +43,14 @@ BEGIN
 END;
 
 /* Verify: on every NODES row: its op-depth <= its own depth */
-CREATE TRIGGER validation_02 BEFORE INSERT ON NODES
+CREATE TEMP 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;
 
 /* Verify: on every NODES row: it is an op-root or its op-root row exists. */
-CREATE TRIGGER validation_03 BEFORE INSERT ON NODES
+CREATE TEMP TRIGGER validation_03 BEFORE INSERT ON NODES
 WHEN NOT (
     (new.op_depth = relpath_depth(new.local_relpath))
     OR
Index: subversion/libsvn_wc/wc_db.c
===================================================================
--- subversion/libsvn_wc/wc_db.c	(revision 1128387)
+++ subversion/libsvn_wc/wc_db.c	(working copy)
@@ -1381,7 +1381,6 @@ 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. */
Index: subversion/libsvn_wc/wc_db_util.c
===================================================================
--- subversion/libsvn_wc/wc_db_util.c	(revision 1128387)
+++ subversion/libsvn_wc/wc_db_util.c	(working copy)
@@ -128,6 +128,11 @@ svn_wc__db_util_open_db(svn_sqlite__db_t
   SVN_ERR(svn_sqlite__create_scalar_function(*sdb, "relpath_depth", 1,
                                              relpath_depth, NULL));
 
+#ifdef SVN_DEBUG
+  /* Install self-verification trigger statements. */
+  SVN_ERR(svn_sqlite__exec_statements(*sdb, STMT_VERIFICATION_TRIGGERS));
+#endif
+
   return SVN_NO_ERROR;
 }
 

Reply via email to