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 2012/05/23 02:52:16 UTC

svn commit: r1341693 - in /subversion/trunk/subversion: libsvn_wc/wc-queries.sql libsvn_wc/wc_db.c tests/libsvn_wc/wc-queries-test.c

Author: rhuijben
Date: Wed May 23 00:52:16 2012
New Revision: 1341693

URL: http://svn.apache.org/viewvc?rev=1341693&view=rev
Log:
Switch the few remaining queries that still used the LIKE operator to
IS_STRICT_DESCENDANT_OF().

* subversion/libsvn_wc/wc-queries.sql
  (STMT_FIND_WC_LOCK,
   STMT_SELECT_REVERT_LIST_COPIED_CHILDREN,
   STMT_SELECT_REVERT_LIST_RECURSIVE,
   STMT_DELETE_REVERT_LIST_RECURSIVE): Use IS_STRICT_DESCENDANT_OF().

* subversion/libsvn_wc/wc_db.c
  (construct_like_arg): Remove unused function.
  (revert_list_read_copied_children,
   svn_wc__db_revert_list_notify): Update user.
  (wclock_obtain_cb): Remove unused variable. The code was accidentally
    already updated to use the local_relpath in r1341690.

* subversion/tests/libsvn_wc/wc-queries-test.c
  (slow_statements): Remove 3 more previously slow queries.
  (is_node_table): Handle wc_lock as node table for measurements.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.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=1341693&r1=1341692&r2=1341693&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Wed May 23 00:52:16 2012
@@ -785,7 +785,8 @@ WHERE wc_id = ?1 AND local_dir_relpath =
 
 -- STMT_FIND_WC_LOCK
 SELECT local_dir_relpath FROM wc_lock
-WHERE wc_id = ?1 AND local_dir_relpath LIKE ?2 ESCAPE '#'
+WHERE wc_id = ?1
+  AND IS_STRICT_DESCENDANT_OF(local_dir_relpath, ?2)
 
 -- STMT_DELETE_WC_LOCK_ORPHAN
 DELETE FROM wc_lock
@@ -1199,7 +1200,7 @@ ORDER BY actual DESC
 -- STMT_SELECT_REVERT_LIST_COPIED_CHILDREN
 SELECT local_relpath, kind
 FROM revert_list
-WHERE local_relpath LIKE ?1 ESCAPE '#'
+WHERE IS_STRICT_DESCENDANT_OF(local_relpath, ?1)
   AND op_depth >= ?2
   AND repos_id IS NOT NULL
 ORDER BY local_relpath
@@ -1210,13 +1211,15 @@ DELETE FROM revert_list WHERE local_relp
 -- STMT_SELECT_REVERT_LIST_RECURSIVE
 SELECT DISTINCT local_relpath
 FROM revert_list
-WHERE (local_relpath = ?1 OR local_relpath LIKE ?2 ESCAPE '#')
+WHERE (local_relpath = ?1
+       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?1))
   AND (notify OR actual = 0)
 ORDER BY local_relpath
 
 -- STMT_DELETE_REVERT_LIST_RECURSIVE
 DELETE FROM revert_list
-WHERE local_relpath = ?1 OR local_relpath LIKE ?2 ESCAPE '#'
+WHERE (local_relpath = ?1
+       OR IS_STRICT_DESCENDANT_OF(local_relpath, ?1))
 
 -- STMT_DROP_REVERT_LIST
 DROP TABLE IF EXISTS revert_list

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1341693&r1=1341692&r2=1341693&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed May 23 00:52:16 2012
@@ -490,26 +490,6 @@ escape_sqlite_like(const char * const st
   return result;
 }
 
-
-/* Return a string that can be used as the argument to a SQLite 'LIKE'
-   operator, in order to match any path that is a child of LOCAL_RELPATH
-   (at any depth below LOCAL_RELPATH), *excluding* LOCAL_RELPATH itself.
-   LOCAL_RELPATH may be the empty string, in which case the result will
-   match any path except the empty path.
-
-   Allocate the result either statically or in RESULT_POOL.  */
-static const char *construct_like_arg(const char *local_relpath,
-                                      apr_pool_t *result_pool)
-{
-  if (local_relpath[0] == '\0')
-    return "_%";
-
-  return apr_pstrcat(result_pool,
-                     escape_sqlite_like(local_relpath, result_pool),
-                     "/%", (char *)NULL);
-}
-
-
 /* Look up REPOS_ID in SDB and set *REPOS_ROOT_URL and/or *REPOS_UUID to
    its root URL and UUID respectively.  If REPOS_ID is INVALID_REPOS_ID,
    use NULL for both URL and UUID.  Either or both output parameters may be
@@ -5852,8 +5832,7 @@ revert_list_read_copied_children(void *b
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_SELECT_REVERT_LIST_COPIED_CHILDREN));
   SVN_ERR(svn_sqlite__bindf(stmt, "sd",
-                            construct_like_arg(local_relpath, scratch_pool),
-                            relpath_depth(local_relpath)));
+                            local_relpath, relpath_depth(local_relpath)));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   while (have_row)
     {
@@ -5910,7 +5889,7 @@ svn_wc__db_revert_list_notify(svn_wc_not
                               apr_pool_t *scratch_pool)
 {
   svn_wc__db_wcroot_t *wcroot;
-  const char *local_relpath, *like_arg;
+  const char *local_relpath;
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
@@ -5919,11 +5898,9 @@ svn_wc__db_revert_list_notify(svn_wc_not
                               db, local_abspath, scratch_pool, iterpool));
   VERIFY_USABLE_WCROOT(wcroot);
 
-  like_arg = construct_like_arg(local_relpath, scratch_pool);
-
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_SELECT_REVERT_LIST_RECURSIVE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "ss", local_relpath, like_arg));
+  SVN_ERR(svn_sqlite__bindf(stmt, "s", local_relpath));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   if (!have_row)
     return svn_error_trace(svn_sqlite__reset(stmt)); /* optimise for no row */
@@ -5947,7 +5924,7 @@ svn_wc__db_revert_list_notify(svn_wc_not
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
                                     STMT_DELETE_REVERT_LIST_RECURSIVE));
-  SVN_ERR(svn_sqlite__bindf(stmt, "ss", local_relpath, like_arg));
+  SVN_ERR(svn_sqlite__bindf(stmt, "s", local_relpath));
   SVN_ERR(svn_sqlite__step_done(stmt));
 
   svn_pool_destroy(iterpool);
@@ -11750,7 +11727,6 @@ wclock_obtain_cb(void *baton,
   int max_depth;
   int lock_depth;
   svn_boolean_t got_row;
-  const char *filter;
 
   svn_wc__db_wclock_t lock;
 
@@ -11772,8 +11748,6 @@ wclock_obtain_cb(void *baton,
                                                         scratch_pool));
     }
 
-  filter = construct_like_arg(local_relpath, scratch_pool);
-
   /* Check if there are nodes locked below the new lock root */
   SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, STMT_FIND_WC_LOCK));
   SVN_ERR(svn_sqlite__bindf(stmt, "is", wcroot->wc_id, local_relpath));

Modified: subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c?rev=1341693&r1=1341692&r2=1341693&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/wc-queries-test.c Wed May 23 00:52:16 2012
@@ -101,9 +101,6 @@ static const int slow_statements[] =
   STMT_SELECT_COMMITTABLE_EXTERNALS_BELOW,
   STMT_SELECT_EXTERNALS_DEFINED,
   STMT_SELECT_EXTERNAL_PROPERTIES,
-  STMT_SELECT_REVERT_LIST_COPIED_CHILDREN,
-  STMT_SELECT_REVERT_LIST_RECURSIVE,
-  STMT_DELETE_REVERT_LIST_RECURSIVE,
   STMT_SELECT_CONFLICT_MARKER_FILES,
   STMT_DELETE_ACTUAL_EMPTIES,
 
@@ -441,7 +438,8 @@ is_node_table(const char *table_name)
 {
   return (apr_strnatcasecmp(table_name, "nodes") == 0
           || apr_strnatcasecmp(table_name, "actual_node") == 0
-          || apr_strnatcasecmp(table_name, "externals") == 0);
+          || apr_strnatcasecmp(table_name, "externals") == 0
+          || apr_strnatcasecmp(table_name, "wc_lock") == 0);
 }
 
 static svn_error_t *