Author: rhuijben
Date: Fri May 25 09:24:43 2012
New Revision: 1342541

URL: http://svn.apache.org/viewvc?rev=1342541&view=rev
Log:
Simplify file external processing in our queries a tiny bit (aka make Sqlite
do less work) by using the fact that we store '1' as file external value to
avoid 'IS NOT NULL' checks. NULL would be read as boolean FALSE, while '1'
is TRUE.

We didn't do this before as during 1.7 development we assumed that there
would be development working copies from between 1.6 and 1.7 around. For
1.8 I don't think we don't have to assume that. And the bump to format 30
will handle the theoretical edge cases anyway.
(Any svn update with 1.7 would have turned a skel into a '1')

* subversion/libsvn_wc/wc-metadata.sql
  (STMT_CREATE_NODES): Define file_external as an integer.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_SELECT_BASE_NODE,
   STMT_SELECT_BASE_NODE_WITH_LOCK) Just pass the file_external column directly
     instead of making sqlite create a variable for the unlikely case that the
     query user actually asks for this column.
     (wc_db.c also uses the first variant as a row exists check)

  (STMT_SELECT_BASE_CHILDREN_INFO): Remove IS NULL for file_external.

  (STMT_SELECT_NODE_CHILDREN_INFO): Remove IS NULL for file_external and just
     avoid the lock join for op_depth > 0.

Modified:
    subversion/trunk/subversion/libsvn_wc/wc-metadata.sql
    subversion/trunk/subversion/libsvn_wc/wc-queries.sql

Modified: subversion/trunk/subversion/libsvn_wc/wc-metadata.sql
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-metadata.sql?rev=1342541&r1=1342540&r2=1342541&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-metadata.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-metadata.sql Fri May 25 09:24:43 
2012
@@ -465,9 +465,11 @@ CREATE TABLE NODES (
   /* Is there a file external in this location. NULL if there
      is no file external, otherwise '1'  */
   /* ### Originally we had a wc-1.0 like skel in this place, so we
-     ### check for NULL */
-  file_external  TEXT,
-
+     ### check for NULL.
+     ### In Subversion 1.7 we defined this column as TEXT, but Sqlite
+     ### only uses this information for deciding how to optimize
+     ### anyway. */
+  file_external  INTEGER,
 
   PRIMARY KEY (wc_id, local_relpath, op_depth)
 
@@ -755,6 +757,10 @@ PRAGMA user_version = 29;
 CREATE UNIQUE INDEX IF NOT EXISTS I_NODES_MOVED
 ON NODES (wc_id, moved_to, op_depth);
 
+/* Just to be sure clear out file external skels from pre 1.7.0 development
+   working copies that were never updated by 1.7.0+ style clients */
+UPDATE nodes SET file_external=1 WHERE file_external IS NOT NULL;
+
 /* ------------------------------------------------------------------------- */
 
 /* Format YYY introduces new handling for conflict information.  */

Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=1342541&r1=1342540&r2=1342541&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Fri May 25 09:24:43 
2012
@@ -51,14 +51,14 @@ ORDER BY op_depth DESC
 -- STMT_SELECT_BASE_NODE
 SELECT repos_id, repos_path, presence, kind, revision, checksum,
   translated_size, changed_revision, changed_date, changed_author, depth,
-  symlink_target, last_mod_time, properties, file_external IS NOT NULL
+  symlink_target, last_mod_time, properties, file_external
 FROM nodes
 WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0
 
 -- STMT_SELECT_BASE_NODE_WITH_LOCK
 SELECT nodes.repos_id, nodes.repos_path, presence, kind, revision,
   checksum, translated_size, changed_revision, changed_date, changed_author,
-  depth, symlink_target, last_mod_time, properties, file_external IS NOT NULL,
+  depth, symlink_target, last_mod_time, properties, file_external,
   /* All the columns until now must match those returned by
      STMT_SELECT_BASE_NODE. The implementation of svn_wc__db_base_get_info()
      assumes that these columns are followed by the lock information) */
@@ -70,7 +70,7 @@ WHERE wc_id = ?1 AND local_relpath = ?2 
 
 -- STMT_SELECT_BASE_CHILDREN_INFO
 SELECT local_relpath, nodes.repos_id, nodes.repos_path, presence, kind,
-  revision, depth, file_external IS NOT NULL,
+  revision, depth, file_external,
   lock_token, lock_owner, lock_comment, lock_date
 FROM nodes
 LEFT OUTER JOIN lock ON nodes.repos_id = lock.repos_id
@@ -125,11 +125,10 @@ WHERE wc_id = ?1 AND local_relpath = ?2 
 SELECT op_depth, nodes.repos_id, nodes.repos_path, presence, kind, revision,
   checksum, translated_size, changed_revision, changed_date, changed_author,
   depth, symlink_target, last_mod_time, properties, lock_token, lock_owner,
-  lock_comment, lock_date, local_relpath, moved_here, moved_to, 
-  file_external IS NOT NULL
+  lock_comment, lock_date, local_relpath, moved_here, moved_to, file_external
 FROM nodes
 LEFT OUTER JOIN lock ON nodes.repos_id = lock.repos_id
-  AND nodes.repos_path = lock.repos_relpath
+  AND nodes.repos_path = lock.repos_relpath AND op_depth = 0
 WHERE wc_id = ?1 AND parent_relpath = ?2
 
 -- STMT_SELECT_NODE_CHILDREN_WALKER_INFO


Reply via email to