diff options
Diffstat (limited to 'subversion/libsvn_wc')
-rw-r--r-- | subversion/libsvn_wc/conflicts.h | 8 | ||||
-rw-r--r-- | subversion/libsvn_wc/diff_local.c | 17 | ||||
-rw-r--r-- | subversion/libsvn_wc/upgrade.c | 4 | ||||
-rw-r--r-- | subversion/libsvn_wc/wc-checks.h | 2 | ||||
-rw-r--r-- | subversion/libsvn_wc/wc-metadata.h | 149 | ||||
-rw-r--r-- | subversion/libsvn_wc/wc-metadata.sql | 48 | ||||
-rw-r--r-- | subversion/libsvn_wc/wc-queries.h | 162 | ||||
-rw-r--r-- | subversion/libsvn_wc/wc-queries.sql | 7 | ||||
-rw-r--r-- | subversion/libsvn_wc/wc.h | 2 | ||||
-rw-r--r-- | subversion/libsvn_wc/wc_db.c | 26 | ||||
-rw-r--r-- | subversion/libsvn_wc/wc_db.h | 10 | ||||
-rw-r--r-- | subversion/libsvn_wc/wc_db_util.c | 16 |
12 files changed, 296 insertions, 155 deletions
diff --git a/subversion/libsvn_wc/conflicts.h b/subversion/libsvn_wc/conflicts.h index d473065..839e8a0 100644 --- a/subversion/libsvn_wc/conflicts.h +++ b/subversion/libsvn_wc/conflicts.h @@ -401,14 +401,18 @@ svn_wc__conflict_create_markers(svn_skel_t **work_item, apr_pool_t *result_pool, apr_pool_t *scratch_pool); -/* Call the interactive conflict resolver RESOLVER_FUNC with RESOLVER_BATON to - allow resolving the conflicts on LOCAL_ABSPATH. +/* Call the conflict resolver RESOLVER_FUNC with RESOLVER_BATON for each + of the conflicts on LOCAL_ABSPATH. Depending on the results that + the callback returns, perhaps resolve the conflicts, and perhaps mark + them as resolved in the WC DB. Call RESOLVER_FUNC once for each property conflict, and again for any text conflict, and again for any tree conflict on the node. CONFLICT_SKEL contains the details of the conflicts on LOCAL_ABSPATH. + Use MERGE_OPTIONS when the resolver requests a merge. + Resolver actions are directly applied to the in-db state of LOCAL_ABSPATH, so the conflict and the state in CONFLICT_SKEL must already be installed in wc.db. */ diff --git a/subversion/libsvn_wc/diff_local.c b/subversion/libsvn_wc/diff_local.c index 0bd4a45..04d4c48 100644 --- a/subversion/libsvn_wc/diff_local.c +++ b/subversion/libsvn_wc/diff_local.c @@ -116,13 +116,20 @@ ensure_state(struct diff_baton *eb, apr_pool_t *ns_pool; if (!eb->cur) { - if (!svn_dirent_is_ancestor(eb->anchor_abspath, local_abspath)) + const char *relpath; + + relpath = svn_dirent_skip_ancestor(eb->anchor_abspath, local_abspath); + if (! relpath) return SVN_NO_ERROR; - SVN_ERR(ensure_state(eb, - svn_dirent_dirname(local_abspath,scratch_pool), - FALSE, - scratch_pool)); + /* Don't recurse on the anchor, as that might loop infinately because + svn_dirent_dirname("/",...) -> "/" + svn_dirent_dirname("C:/",...) -> "C:/" (Windows) */ + if (*relpath) + SVN_ERR(ensure_state(eb, + svn_dirent_dirname(local_abspath,scratch_pool), + FALSE, + scratch_pool)); } else if (svn_dirent_is_child(eb->cur->local_abspath, local_abspath, NULL)) SVN_ERR(ensure_state(eb, svn_dirent_dirname(local_abspath,scratch_pool), diff --git a/subversion/libsvn_wc/upgrade.c b/subversion/libsvn_wc/upgrade.c index ff5543c..af615fd 100644 --- a/subversion/libsvn_wc/upgrade.c +++ b/subversion/libsvn_wc/upgrade.c @@ -1958,6 +1958,10 @@ svn_wc__upgrade_sdb(int *result_format, case SVN_WC__VERSION: /* already upgraded */ *result_format = SVN_WC__VERSION; + + SVN_SQLITE__WITH_LOCK( + svn_wc__db_install_schema_statistics(sdb, scratch_pool), + sdb); } #ifdef SVN_DEBUG diff --git a/subversion/libsvn_wc/wc-checks.h b/subversion/libsvn_wc/wc-checks.h index 3d87a03..14d7ef3 100644 --- a/subversion/libsvn_wc/wc-checks.h +++ b/subversion/libsvn_wc/wc-checks.h @@ -1,4 +1,4 @@ -/* This file is automatically generated from wc-checks.sql and .dist_sandbox/subversion-1.8.5/subversion/libsvn_wc/token-map.h. +/* This file is automatically generated from wc-checks.sql and .dist_sandbox/subversion-1.8.8/subversion/libsvn_wc/token-map.h. * Do not edit this file -- edit the source and rerun gen-make.py */ #define STMT_VERIFICATION_TRIGGERS 0 diff --git a/subversion/libsvn_wc/wc-metadata.h b/subversion/libsvn_wc/wc-metadata.h index 2e3182d..0ab17d4 100644 --- a/subversion/libsvn_wc/wc-metadata.h +++ b/subversion/libsvn_wc/wc-metadata.h @@ -1,4 +1,4 @@ -/* This file is automatically generated from wc-metadata.sql and .dist_sandbox/subversion-1.8.5/subversion/libsvn_wc/token-map.h. +/* This file is automatically generated from wc-metadata.sql and .dist_sandbox/subversion-1.8.8/subversion/libsvn_wc/token-map.h. * Do not edit this file -- edit the source and rerun gen-make.py */ #define STMT_CREATE_SCHEMA 0 @@ -159,9 +159,30 @@ " local_relpath); " \ "" -#define STMT_UPGRADE_TO_20 4 -#define STMT_4_INFO {"STMT_UPGRADE_TO_20", NULL} +#define STMT_INSTALL_SCHEMA_STATISTICS 4 +#define STMT_4_INFO {"STMT_INSTALL_SCHEMA_STATISTICS", NULL} #define STMT_4 \ + "ANALYZE sqlite_master; " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('NODES', 'sqlite_autoindex_NODES_1', '8000 8000 2 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('NODES', 'I_NODES_PARENT', '8000 8000 10 2 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('NODES', 'I_NODES_MOVED', '8000 8000 1 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('ACTUAL_NODE', 'sqlite_autoindex_ACTUAL_NODE_1', '8000 8000 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('ACTUAL_NODE', 'I_ACTUAL_PARENT', '8000 8000 10 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('LOCK', 'sqlite_autoindex_LOCK_1', '100 100 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('WC_LOCK', 'sqlite_autoindex_WC_LOCK_1', '100 100 1'); " \ + "ANALYZE sqlite_master; " \ + "" + +#define STMT_UPGRADE_TO_20 5 +#define STMT_5_INFO {"STMT_UPGRADE_TO_20", NULL} +#define STMT_5 \ "UPDATE BASE_NODE SET checksum = (SELECT checksum FROM pristine " \ " WHERE md5_checksum = BASE_NODE.checksum) " \ "WHERE EXISTS (SELECT 1 FROM pristine WHERE md5_checksum = BASE_NODE.checksum); " \ @@ -202,59 +223,59 @@ "PRAGMA user_version = 20; " \ "" -#define STMT_UPGRADE_TO_21 5 -#define STMT_5_INFO {"STMT_UPGRADE_TO_21", NULL} -#define STMT_5 \ +#define STMT_UPGRADE_TO_21 6 +#define STMT_6_INFO {"STMT_UPGRADE_TO_21", NULL} +#define STMT_6 \ "PRAGMA user_version = 21; " \ "" -#define STMT_UPGRADE_21_SELECT_OLD_TREE_CONFLICT 6 -#define STMT_6_INFO {"STMT_UPGRADE_21_SELECT_OLD_TREE_CONFLICT", NULL} -#define STMT_6 \ +#define STMT_UPGRADE_21_SELECT_OLD_TREE_CONFLICT 7 +#define STMT_7_INFO {"STMT_UPGRADE_21_SELECT_OLD_TREE_CONFLICT", NULL} +#define STMT_7 \ "SELECT wc_id, local_relpath, tree_conflict_data " \ "FROM actual_node " \ "WHERE tree_conflict_data IS NOT NULL " \ "" -#define STMT_UPGRADE_21_ERASE_OLD_CONFLICTS 7 -#define STMT_7_INFO {"STMT_UPGRADE_21_ERASE_OLD_CONFLICTS", NULL} -#define STMT_7 \ +#define STMT_UPGRADE_21_ERASE_OLD_CONFLICTS 8 +#define STMT_8_INFO {"STMT_UPGRADE_21_ERASE_OLD_CONFLICTS", NULL} +#define STMT_8 \ "UPDATE actual_node SET tree_conflict_data = NULL " \ "" -#define STMT_UPGRADE_TO_22 8 -#define STMT_8_INFO {"STMT_UPGRADE_TO_22", NULL} -#define STMT_8 \ +#define STMT_UPGRADE_TO_22 9 +#define STMT_9_INFO {"STMT_UPGRADE_TO_22", NULL} +#define STMT_9 \ "UPDATE actual_node SET tree_conflict_data = conflict_data; " \ "UPDATE actual_node SET conflict_data = NULL; " \ "PRAGMA user_version = 22; " \ "" -#define STMT_UPGRADE_TO_23 9 -#define STMT_9_INFO {"STMT_UPGRADE_TO_23", NULL} -#define STMT_9 \ +#define STMT_UPGRADE_TO_23 10 +#define STMT_10_INFO {"STMT_UPGRADE_TO_23", NULL} +#define STMT_10 \ "PRAGMA user_version = 23; " \ "" -#define STMT_UPGRADE_23_HAS_WORKING_NODES 10 -#define STMT_10_INFO {"STMT_UPGRADE_23_HAS_WORKING_NODES", NULL} -#define STMT_10 \ +#define STMT_UPGRADE_23_HAS_WORKING_NODES 11 +#define STMT_11_INFO {"STMT_UPGRADE_23_HAS_WORKING_NODES", NULL} +#define STMT_11 \ "SELECT 1 FROM nodes WHERE op_depth > 0 " \ "LIMIT 1 " \ "" -#define STMT_UPGRADE_TO_24 11 -#define STMT_11_INFO {"STMT_UPGRADE_TO_24", NULL} -#define STMT_11 \ +#define STMT_UPGRADE_TO_24 12 +#define STMT_12_INFO {"STMT_UPGRADE_TO_24", NULL} +#define STMT_12 \ "UPDATE pristine SET refcount = " \ " (SELECT COUNT(*) FROM nodes " \ " WHERE checksum = pristine.checksum ); " \ "PRAGMA user_version = 24; " \ "" -#define STMT_UPGRADE_TO_25 12 -#define STMT_12_INFO {"STMT_UPGRADE_TO_25", NULL} -#define STMT_12 \ +#define STMT_UPGRADE_TO_25 13 +#define STMT_13_INFO {"STMT_UPGRADE_TO_25", NULL} +#define STMT_13 \ "DROP VIEW IF EXISTS NODES_CURRENT; " \ "CREATE VIEW NODES_CURRENT AS " \ " SELECT * FROM nodes " \ @@ -266,9 +287,9 @@ "PRAGMA user_version = 25; " \ "" -#define STMT_UPGRADE_TO_26 13 -#define STMT_13_INFO {"STMT_UPGRADE_TO_26", NULL} -#define STMT_13 \ +#define STMT_UPGRADE_TO_26 14 +#define STMT_14_INFO {"STMT_UPGRADE_TO_26", NULL} +#define STMT_14 \ "DROP VIEW IF EXISTS NODES_BASE; " \ "CREATE VIEW NODES_BASE AS " \ " SELECT * FROM nodes " \ @@ -276,15 +297,15 @@ "PRAGMA user_version = 26; " \ "" -#define STMT_UPGRADE_TO_27 14 -#define STMT_14_INFO {"STMT_UPGRADE_TO_27", NULL} -#define STMT_14 \ +#define STMT_UPGRADE_TO_27 15 +#define STMT_15_INFO {"STMT_UPGRADE_TO_27", NULL} +#define STMT_15 \ "PRAGMA user_version = 27; " \ "" -#define STMT_UPGRADE_27_HAS_ACTUAL_NODES_CONFLICTS 15 -#define STMT_15_INFO {"STMT_UPGRADE_27_HAS_ACTUAL_NODES_CONFLICTS", NULL} -#define STMT_15 \ +#define STMT_UPGRADE_27_HAS_ACTUAL_NODES_CONFLICTS 16 +#define STMT_16_INFO {"STMT_UPGRADE_27_HAS_ACTUAL_NODES_CONFLICTS", NULL} +#define STMT_16 \ "SELECT 1 FROM actual_node " \ "WHERE NOT ((prop_reject IS NULL) AND (conflict_old IS NULL) " \ " AND (conflict_new IS NULL) AND (conflict_working IS NULL) " \ @@ -292,18 +313,18 @@ "LIMIT 1 " \ "" -#define STMT_UPGRADE_TO_28 16 -#define STMT_16_INFO {"STMT_UPGRADE_TO_28", NULL} -#define STMT_16 \ +#define STMT_UPGRADE_TO_28 17 +#define STMT_17_INFO {"STMT_UPGRADE_TO_28", NULL} +#define STMT_17 \ "UPDATE NODES SET checksum = (SELECT checksum FROM pristine " \ " WHERE md5_checksum = nodes.checksum) " \ "WHERE EXISTS (SELECT 1 FROM pristine WHERE md5_checksum = nodes.checksum); " \ "PRAGMA user_version = 28; " \ "" -#define STMT_UPGRADE_TO_29 17 -#define STMT_17_INFO {"STMT_UPGRADE_TO_29", NULL} -#define STMT_17 \ +#define STMT_UPGRADE_TO_29 18 +#define STMT_18_INFO {"STMT_UPGRADE_TO_29", NULL} +#define STMT_18 \ "DROP TRIGGER IF EXISTS nodes_update_checksum_trigger; " \ "DROP TRIGGER IF EXISTS nodes_insert_trigger; " \ "DROP TRIGGER IF EXISTS nodes_delete_trigger; " \ @@ -333,9 +354,9 @@ "PRAGMA user_version = 29; " \ "" -#define STMT_UPGRADE_TO_30 18 -#define STMT_18_INFO {"STMT_UPGRADE_TO_30", NULL} -#define STMT_18 \ +#define STMT_UPGRADE_TO_30 19 +#define STMT_19_INFO {"STMT_UPGRADE_TO_30", NULL} +#define STMT_19 \ "CREATE UNIQUE INDEX IF NOT EXISTS I_NODES_MOVED " \ "ON NODES (wc_id, moved_to, op_depth); " \ "CREATE INDEX IF NOT EXISTS I_PRISTINE_MD5 ON PRISTINE (md5_checksum); " \ @@ -343,9 +364,9 @@ "UPDATE nodes SET file_external=1 WHERE file_external IS NOT NULL; " \ "" -#define STMT_UPGRADE_30_SELECT_CONFLICT_SEPARATE 19 -#define STMT_19_INFO {"STMT_UPGRADE_30_SELECT_CONFLICT_SEPARATE", NULL} -#define STMT_19 \ +#define STMT_UPGRADE_30_SELECT_CONFLICT_SEPARATE 20 +#define STMT_20_INFO {"STMT_UPGRADE_30_SELECT_CONFLICT_SEPARATE", NULL} +#define STMT_20 \ "SELECT wc_id, local_relpath, " \ " conflict_old, conflict_working, conflict_new, prop_reject, tree_conflict_data " \ "FROM actual_node " \ @@ -357,24 +378,24 @@ "ORDER by wc_id, local_relpath " \ "" -#define STMT_UPGRADE_30_SET_CONFLICT 20 -#define STMT_20_INFO {"STMT_UPGRADE_30_SET_CONFLICT", NULL} -#define STMT_20 \ +#define STMT_UPGRADE_30_SET_CONFLICT 21 +#define STMT_21_INFO {"STMT_UPGRADE_30_SET_CONFLICT", NULL} +#define STMT_21 \ "UPDATE actual_node SET conflict_data = ?3, conflict_old = NULL, " \ " conflict_working = NULL, conflict_new = NULL, prop_reject = NULL, " \ " tree_conflict_data = NULL " \ "WHERE wc_id = ?1 and local_relpath = ?2 " \ "" -#define STMT_UPGRADE_TO_31_ALTER_TABLE 21 -#define STMT_21_INFO {"STMT_UPGRADE_TO_31_ALTER_TABLE", NULL} -#define STMT_21 \ +#define STMT_UPGRADE_TO_31_ALTER_TABLE 22 +#define STMT_22_INFO {"STMT_UPGRADE_TO_31_ALTER_TABLE", NULL} +#define STMT_22 \ "ALTER TABLE NODES ADD COLUMN inherited_props BLOB; " \ "" -#define STMT_UPGRADE_TO_31_FINALIZE 22 -#define STMT_22_INFO {"STMT_UPGRADE_TO_31_FINALIZE", NULL} -#define STMT_22 \ +#define STMT_UPGRADE_TO_31_FINALIZE 23 +#define STMT_23_INFO {"STMT_UPGRADE_TO_31_FINALIZE", NULL} +#define STMT_23 \ "DROP INDEX IF EXISTS I_ACTUAL_CHANGELIST; " \ "DROP INDEX IF EXISTS I_EXTERNALS_PARENT; " \ "DROP INDEX I_NODES_PARENT; " \ @@ -386,9 +407,9 @@ "PRAGMA user_version = 31; " \ "" -#define STMT_UPGRADE_31_SELECT_WCROOT_NODES 23 -#define STMT_23_INFO {"STMT_UPGRADE_31_SELECT_WCROOT_NODES", NULL} -#define STMT_23 \ +#define STMT_UPGRADE_31_SELECT_WCROOT_NODES 24 +#define STMT_24_INFO {"STMT_UPGRADE_31_SELECT_WCROOT_NODES", NULL} +#define STMT_24 \ "SELECT l.wc_id, l.local_relpath FROM nodes as l " \ "LEFT OUTER JOIN nodes as r " \ "ON l.wc_id = r.wc_id " \ @@ -400,9 +421,9 @@ " OR (l.repos_path IS NOT (CASE WHEN (r.local_relpath) = '' THEN (CASE WHEN (r.repos_path) = '' THEN (l.local_relpath) WHEN (l.local_relpath) = '' THEN (r.repos_path) ELSE (r.repos_path) || '/' || (l.local_relpath) END) WHEN (r.repos_path) = '' THEN (CASE WHEN (r.local_relpath) = '' THEN (l.local_relpath) WHEN SUBSTR((l.local_relpath), 1, LENGTH(r.local_relpath)) = (r.local_relpath) THEN CASE WHEN LENGTH(r.local_relpath) = LENGTH(l.local_relpath) THEN '' WHEN SUBSTR((l.local_relpath), LENGTH(r.local_relpath)+1, 1) = '/' THEN SUBSTR((l.local_relpath), LENGTH(r.local_relpath)+2) END END) WHEN SUBSTR((l.local_relpath), 1, LENGTH(r.local_relpath)) = (r.local_relpath) THEN CASE WHEN LENGTH(r.local_relpath) = LENGTH(l.local_relpath) THEN (r.repos_path) WHEN SUBSTR((l.local_relpath), LENGTH(r.local_relpath)+1, 1) = '/' THEN (r.repos_path) || SUBSTR((l.local_relpath), LENGTH(r.local_relpath)+1) END END))) " \ "" -#define STMT_UPGRADE_TO_32 24 -#define STMT_24_INFO {"STMT_UPGRADE_TO_32", NULL} -#define STMT_24 \ +#define STMT_UPGRADE_TO_32 25 +#define STMT_25_INFO {"STMT_UPGRADE_TO_32", NULL} +#define STMT_25 \ "DROP INDEX IF EXISTS I_ACTUAL_CHANGELIST; " \ "DROP INDEX IF EXISTS I_EXTERNALS_PARENT; " \ "CREATE INDEX I_EXTERNALS_PARENT ON EXTERNALS (wc_id, parent_relpath); " \ @@ -482,6 +503,7 @@ STMT_22, \ STMT_23, \ STMT_24, \ + STMT_25, \ NULL \ } @@ -512,5 +534,6 @@ STMT_22_INFO, \ STMT_23_INFO, \ STMT_24_INFO, \ + STMT_25_INFO, \ {NULL, NULL} \ } diff --git a/subversion/libsvn_wc/wc-metadata.sql b/subversion/libsvn_wc/wc-metadata.sql index d2a6161..848293d 100644 --- a/subversion/libsvn_wc/wc-metadata.sql +++ b/subversion/libsvn_wc/wc-metadata.sql @@ -573,6 +573,54 @@ CREATE UNIQUE INDEX I_EXTERNALS_DEFINED ON EXTERNALS (wc_id, local_relpath); /* ------------------------------------------------------------------------- */ +/* This statement provides SQLite with the necessary information about our + indexes to make better decisions in the query planner. + + For every interesting index this contains a number of rows where the + statistics ar calculated for and then for every column in the index the + average number of rows with the same value in all columns left of this + column including the column itself. + + See http://www.sqlite.org/fileformat2.html#stat1tab for more details. + + The important thing here is that this tells Sqlite that the wc_id column + of the NODES and ACTUAL_NODE table is usually a single value, so queries + should use more than one column for index usage. + + The current hints describe NODES+ACTUAL_NODE as a working copy with + 8000 nodes in 1 a single working copy(=wc_id), 10 nodes per directory + and an average of 2 op-depth layers per node. + + The number of integers must be number of index columns + 1, which is + verified via the test_schema_statistics() test. + */ +-- STMT_INSTALL_SCHEMA_STATISTICS +ANALYZE sqlite_master; /* Creates empty sqlite_stat1 if necessary */ + +INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES + ('NODES', 'sqlite_autoindex_NODES_1', '8000 8000 2 1'); +INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES + ('NODES', 'I_NODES_PARENT', '8000 8000 10 2 1'); +/* Tell a lie: We ignore that 99.9% of all moved_to values are NULL */ +INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES + ('NODES', 'I_NODES_MOVED', '8000 8000 1 1'); + +INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES + ('ACTUAL_NODE', 'sqlite_autoindex_ACTUAL_NODE_1', '8000 8000 1'); +INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES + ('ACTUAL_NODE', 'I_ACTUAL_PARENT', '8000 8000 10 1'); + +INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES + ('LOCK', 'sqlite_autoindex_LOCK_1', '100 100 1'); + +INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES + ('WC_LOCK', 'sqlite_autoindex_WC_LOCK_1', '100 100 1'); + +/* sqlite_autoindex_WORK_QUEUE_1 doesn't exist because WORK_QUEUE is + a INTEGER PRIMARY KEY AUTOINCREMENT table */ + +ANALYZE sqlite_master; /* Loads sqlite_stat1 data for query optimizer */ +/* ------------------------------------------------------------------------- */ /* Format 20 introduces NODES and removes BASE_NODE and WORKING_NODE */ diff --git a/subversion/libsvn_wc/wc-queries.h b/subversion/libsvn_wc/wc-queries.h index edcf81e..0246ee5 100644 --- a/subversion/libsvn_wc/wc-queries.h +++ b/subversion/libsvn_wc/wc-queries.h @@ -1,4 +1,4 @@ -/* This file is automatically generated from wc-queries.sql and .dist_sandbox/subversion-1.8.5/subversion/libsvn_wc/token-map.h. +/* This file is automatically generated from wc-queries.sql and .dist_sandbox/subversion-1.8.8/subversion/libsvn_wc/token-map.h. * Do not edit this file -- edit the source and rerun gen-make.py */ #define STMT_SELECT_NODE_INFO 0 @@ -1991,10 +1991,15 @@ #define STMT_190_INFO {"STMT_SELECT_MOVED_PAIR3", NULL} #define STMT_190 \ "SELECT local_relpath, moved_to, op_depth, kind FROM nodes " \ + "WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > ?3 " \ + " AND moved_to IS NOT NULL " \ + "UNION ALL " \ + "SELECT local_relpath, moved_to, op_depth, kind FROM nodes " \ "WHERE wc_id = ?1 " \ - " AND (local_relpath = ?2 OR (((local_relpath) > (CASE (?2) WHEN '' THEN '' ELSE (?2) || '/' END)) AND ((local_relpath) < CASE (?2) WHEN '' THEN X'FFFF' ELSE (?2) || '0' END))) " \ + " AND (((local_relpath) > (CASE (?2) WHEN '' THEN '' ELSE (?2) || '/' END)) AND ((local_relpath) < CASE (?2) WHEN '' THEN X'FFFF' ELSE (?2) || '0' END)) " \ " AND op_depth > ?3 " \ " AND moved_to IS NOT NULL " \ + "ORDER BY local_relpath, op_depth " \ "" #define STMT_SELECT_MOVED_OUTSIDE 191 @@ -2299,9 +2304,30 @@ " local_relpath); " \ "" -#define STMT_UPGRADE_TO_20 209 -#define STMT_209_INFO {"STMT_UPGRADE_TO_20", NULL} +#define STMT_INSTALL_SCHEMA_STATISTICS 209 +#define STMT_209_INFO {"STMT_INSTALL_SCHEMA_STATISTICS", NULL} #define STMT_209 \ + "ANALYZE sqlite_master; " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('NODES', 'sqlite_autoindex_NODES_1', '8000 8000 2 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('NODES', 'I_NODES_PARENT', '8000 8000 10 2 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('NODES', 'I_NODES_MOVED', '8000 8000 1 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('ACTUAL_NODE', 'sqlite_autoindex_ACTUAL_NODE_1', '8000 8000 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('ACTUAL_NODE', 'I_ACTUAL_PARENT', '8000 8000 10 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('LOCK', 'sqlite_autoindex_LOCK_1', '100 100 1'); " \ + "INSERT OR REPLACE INTO sqlite_stat1(tbl, idx, stat) VALUES " \ + " ('WC_LOCK', 'sqlite_autoindex_WC_LOCK_1', '100 100 1'); " \ + "ANALYZE sqlite_master; " \ + "" + +#define STMT_UPGRADE_TO_20 210 +#define STMT_210_INFO {"STMT_UPGRADE_TO_20", NULL} +#define STMT_210 \ "UPDATE BASE_NODE SET checksum = (SELECT checksum FROM pristine " \ " WHERE md5_checksum = BASE_NODE.checksum) " \ "WHERE EXISTS (SELECT 1 FROM pristine WHERE md5_checksum = BASE_NODE.checksum); " \ @@ -2342,59 +2368,59 @@ "PRAGMA user_version = 20; " \ "" -#define STMT_UPGRADE_TO_21 210 -#define STMT_210_INFO {"STMT_UPGRADE_TO_21", NULL} -#define STMT_210 \ +#define STMT_UPGRADE_TO_21 211 +#define STMT_211_INFO {"STMT_UPGRADE_TO_21", NULL} +#define STMT_211 \ "PRAGMA user_version = 21; " \ "" -#define STMT_UPGRADE_21_SELECT_OLD_TREE_CONFLICT 211 -#define STMT_211_INFO {"STMT_UPGRADE_21_SELECT_OLD_TREE_CONFLICT", NULL} -#define STMT_211 \ +#define STMT_UPGRADE_21_SELECT_OLD_TREE_CONFLICT 212 +#define STMT_212_INFO {"STMT_UPGRADE_21_SELECT_OLD_TREE_CONFLICT", NULL} +#define STMT_212 \ "SELECT wc_id, local_relpath, tree_conflict_data " \ "FROM actual_node " \ "WHERE tree_conflict_data IS NOT NULL " \ "" -#define STMT_UPGRADE_21_ERASE_OLD_CONFLICTS 212 -#define STMT_212_INFO {"STMT_UPGRADE_21_ERASE_OLD_CONFLICTS", NULL} -#define STMT_212 \ +#define STMT_UPGRADE_21_ERASE_OLD_CONFLICTS 213 +#define STMT_213_INFO {"STMT_UPGRADE_21_ERASE_OLD_CONFLICTS", NULL} +#define STMT_213 \ "UPDATE actual_node SET tree_conflict_data = NULL " \ "" -#define STMT_UPGRADE_TO_22 213 -#define STMT_213_INFO {"STMT_UPGRADE_TO_22", NULL} -#define STMT_213 \ +#define STMT_UPGRADE_TO_22 214 +#define STMT_214_INFO {"STMT_UPGRADE_TO_22", NULL} +#define STMT_214 \ "UPDATE actual_node SET tree_conflict_data = conflict_data; " \ "UPDATE actual_node SET conflict_data = NULL; " \ "PRAGMA user_version = 22; " \ "" -#define STMT_UPGRADE_TO_23 214 -#define STMT_214_INFO {"STMT_UPGRADE_TO_23", NULL} -#define STMT_214 \ +#define STMT_UPGRADE_TO_23 215 +#define STMT_215_INFO {"STMT_UPGRADE_TO_23", NULL} +#define STMT_215 \ "PRAGMA user_version = 23; " \ "" -#define STMT_UPGRADE_23_HAS_WORKING_NODES 215 -#define STMT_215_INFO {"STMT_UPGRADE_23_HAS_WORKING_NODES", NULL} -#define STMT_215 \ +#define STMT_UPGRADE_23_HAS_WORKING_NODES 216 +#define STMT_216_INFO {"STMT_UPGRADE_23_HAS_WORKING_NODES", NULL} +#define STMT_216 \ "SELECT 1 FROM nodes WHERE op_depth > 0 " \ "LIMIT 1 " \ "" -#define STMT_UPGRADE_TO_24 216 -#define STMT_216_INFO {"STMT_UPGRADE_TO_24", NULL} -#define STMT_216 \ +#define STMT_UPGRADE_TO_24 217 +#define STMT_217_INFO {"STMT_UPGRADE_TO_24", NULL} +#define STMT_217 \ "UPDATE pristine SET refcount = " \ " (SELECT COUNT(*) FROM nodes " \ " WHERE checksum = pristine.checksum ); " \ "PRAGMA user_version = 24; " \ "" -#define STMT_UPGRADE_TO_25 217 -#define STMT_217_INFO {"STMT_UPGRADE_TO_25", NULL} -#define STMT_217 \ +#define STMT_UPGRADE_TO_25 218 +#define STMT_218_INFO {"STMT_UPGRADE_TO_25", NULL} +#define STMT_218 \ "DROP VIEW IF EXISTS NODES_CURRENT; " \ "CREATE VIEW NODES_CURRENT AS " \ " SELECT * FROM nodes " \ @@ -2406,9 +2432,9 @@ "PRAGMA user_version = 25; " \ "" -#define STMT_UPGRADE_TO_26 218 -#define STMT_218_INFO {"STMT_UPGRADE_TO_26", NULL} -#define STMT_218 \ +#define STMT_UPGRADE_TO_26 219 +#define STMT_219_INFO {"STMT_UPGRADE_TO_26", NULL} +#define STMT_219 \ "DROP VIEW IF EXISTS NODES_BASE; " \ "CREATE VIEW NODES_BASE AS " \ " SELECT * FROM nodes " \ @@ -2416,15 +2442,15 @@ "PRAGMA user_version = 26; " \ "" -#define STMT_UPGRADE_TO_27 219 -#define STMT_219_INFO {"STMT_UPGRADE_TO_27", NULL} -#define STMT_219 \ +#define STMT_UPGRADE_TO_27 220 +#define STMT_220_INFO {"STMT_UPGRADE_TO_27", NULL} +#define STMT_220 \ "PRAGMA user_version = 27; " \ "" -#define STMT_UPGRADE_27_HAS_ACTUAL_NODES_CONFLICTS 220 -#define STMT_220_INFO {"STMT_UPGRADE_27_HAS_ACTUAL_NODES_CONFLICTS", NULL} -#define STMT_220 \ +#define STMT_UPGRADE_27_HAS_ACTUAL_NODES_CONFLICTS 221 +#define STMT_221_INFO {"STMT_UPGRADE_27_HAS_ACTUAL_NODES_CONFLICTS", NULL} +#define STMT_221 \ "SELECT 1 FROM actual_node " \ "WHERE NOT ((prop_reject IS NULL) AND (conflict_old IS NULL) " \ " AND (conflict_new IS NULL) AND (conflict_working IS NULL) " \ @@ -2432,18 +2458,18 @@ "LIMIT 1 " \ "" -#define STMT_UPGRADE_TO_28 221 -#define STMT_221_INFO {"STMT_UPGRADE_TO_28", NULL} -#define STMT_221 \ +#define STMT_UPGRADE_TO_28 222 +#define STMT_222_INFO {"STMT_UPGRADE_TO_28", NULL} +#define STMT_222 \ "UPDATE NODES SET checksum = (SELECT checksum FROM pristine " \ " WHERE md5_checksum = nodes.checksum) " \ "WHERE EXISTS (SELECT 1 FROM pristine WHERE md5_checksum = nodes.checksum); " \ "PRAGMA user_version = 28; " \ "" -#define STMT_UPGRADE_TO_29 222 -#define STMT_222_INFO {"STMT_UPGRADE_TO_29", NULL} -#define STMT_222 \ +#define STMT_UPGRADE_TO_29 223 +#define STMT_223_INFO {"STMT_UPGRADE_TO_29", NULL} +#define STMT_223 \ "DROP TRIGGER IF EXISTS nodes_update_checksum_trigger; " \ "DROP TRIGGER IF EXISTS nodes_insert_trigger; " \ "DROP TRIGGER IF EXISTS nodes_delete_trigger; " \ @@ -2473,9 +2499,9 @@ "PRAGMA user_version = 29; " \ "" -#define STMT_UPGRADE_TO_30 223 -#define STMT_223_INFO {"STMT_UPGRADE_TO_30", NULL} -#define STMT_223 \ +#define STMT_UPGRADE_TO_30 224 +#define STMT_224_INFO {"STMT_UPGRADE_TO_30", NULL} +#define STMT_224 \ "CREATE UNIQUE INDEX IF NOT EXISTS I_NODES_MOVED " \ "ON NODES (wc_id, moved_to, op_depth); " \ "CREATE INDEX IF NOT EXISTS I_PRISTINE_MD5 ON PRISTINE (md5_checksum); " \ @@ -2483,9 +2509,9 @@ "UPDATE nodes SET file_external=1 WHERE file_external IS NOT NULL; " \ "" -#define STMT_UPGRADE_30_SELECT_CONFLICT_SEPARATE 224 -#define STMT_224_INFO {"STMT_UPGRADE_30_SELECT_CONFLICT_SEPARATE", NULL} -#define STMT_224 \ +#define STMT_UPGRADE_30_SELECT_CONFLICT_SEPARATE 225 +#define STMT_225_INFO {"STMT_UPGRADE_30_SELECT_CONFLICT_SEPARATE", NULL} +#define STMT_225 \ "SELECT wc_id, local_relpath, " \ " conflict_old, conflict_working, conflict_new, prop_reject, tree_conflict_data " \ "FROM actual_node " \ @@ -2497,24 +2523,24 @@ "ORDER by wc_id, local_relpath " \ "" -#define STMT_UPGRADE_30_SET_CONFLICT 225 -#define STMT_225_INFO {"STMT_UPGRADE_30_SET_CONFLICT", NULL} -#define STMT_225 \ +#define STMT_UPGRADE_30_SET_CONFLICT 226 +#define STMT_226_INFO {"STMT_UPGRADE_30_SET_CONFLICT", NULL} +#define STMT_226 \ "UPDATE actual_node SET conflict_data = ?3, conflict_old = NULL, " \ " conflict_working = NULL, conflict_new = NULL, prop_reject = NULL, " \ " tree_conflict_data = NULL " \ "WHERE wc_id = ?1 and local_relpath = ?2 " \ "" -#define STMT_UPGRADE_TO_31_ALTER_TABLE 226 -#define STMT_226_INFO {"STMT_UPGRADE_TO_31_ALTER_TABLE", NULL} -#define STMT_226 \ +#define STMT_UPGRADE_TO_31_ALTER_TABLE 227 +#define STMT_227_INFO {"STMT_UPGRADE_TO_31_ALTER_TABLE", NULL} +#define STMT_227 \ "ALTER TABLE NODES ADD COLUMN inherited_props BLOB; " \ "" -#define STMT_UPGRADE_TO_31_FINALIZE 227 -#define STMT_227_INFO {"STMT_UPGRADE_TO_31_FINALIZE", NULL} -#define STMT_227 \ +#define STMT_UPGRADE_TO_31_FINALIZE 228 +#define STMT_228_INFO {"STMT_UPGRADE_TO_31_FINALIZE", NULL} +#define STMT_228 \ "DROP INDEX IF EXISTS I_ACTUAL_CHANGELIST; " \ "DROP INDEX IF EXISTS I_EXTERNALS_PARENT; " \ "DROP INDEX I_NODES_PARENT; " \ @@ -2526,9 +2552,9 @@ "PRAGMA user_version = 31; " \ "" -#define STMT_UPGRADE_31_SELECT_WCROOT_NODES 228 -#define STMT_228_INFO {"STMT_UPGRADE_31_SELECT_WCROOT_NODES", NULL} -#define STMT_228 \ +#define STMT_UPGRADE_31_SELECT_WCROOT_NODES 229 +#define STMT_229_INFO {"STMT_UPGRADE_31_SELECT_WCROOT_NODES", NULL} +#define STMT_229 \ "SELECT l.wc_id, l.local_relpath FROM nodes as l " \ "LEFT OUTER JOIN nodes as r " \ "ON l.wc_id = r.wc_id " \ @@ -2540,9 +2566,9 @@ " OR (l.repos_path IS NOT (CASE WHEN (r.local_relpath) = '' THEN (CASE WHEN (r.repos_path) = '' THEN (l.local_relpath) WHEN (l.local_relpath) = '' THEN (r.repos_path) ELSE (r.repos_path) || '/' || (l.local_relpath) END) WHEN (r.repos_path) = '' THEN (CASE WHEN (r.local_relpath) = '' THEN (l.local_relpath) WHEN SUBSTR((l.local_relpath), 1, LENGTH(r.local_relpath)) = (r.local_relpath) THEN CASE WHEN LENGTH(r.local_relpath) = LENGTH(l.local_relpath) THEN '' WHEN SUBSTR((l.local_relpath), LENGTH(r.local_relpath)+1, 1) = '/' THEN SUBSTR((l.local_relpath), LENGTH(r.local_relpath)+2) END END) WHEN SUBSTR((l.local_relpath), 1, LENGTH(r.local_relpath)) = (r.local_relpath) THEN CASE WHEN LENGTH(r.local_relpath) = LENGTH(l.local_relpath) THEN (r.repos_path) WHEN SUBSTR((l.local_relpath), LENGTH(r.local_relpath)+1, 1) = '/' THEN (r.repos_path) || SUBSTR((l.local_relpath), LENGTH(r.local_relpath)+1) END END))) " \ "" -#define STMT_UPGRADE_TO_32 229 -#define STMT_229_INFO {"STMT_UPGRADE_TO_32", NULL} -#define STMT_229 \ +#define STMT_UPGRADE_TO_32 230 +#define STMT_230_INFO {"STMT_UPGRADE_TO_32", NULL} +#define STMT_230 \ "DROP INDEX IF EXISTS I_ACTUAL_CHANGELIST; " \ "DROP INDEX IF EXISTS I_EXTERNALS_PARENT; " \ "CREATE INDEX I_EXTERNALS_PARENT ON EXTERNALS (wc_id, parent_relpath); " \ @@ -2595,9 +2621,9 @@ "DROP TABLE ACTUAL_NODE_BACKUP; " \ "" -#define STMT_VERIFICATION_TRIGGERS 230 -#define STMT_230_INFO {"STMT_VERIFICATION_TRIGGERS", NULL} -#define STMT_230 \ +#define STMT_VERIFICATION_TRIGGERS 231 +#define STMT_231_INFO {"STMT_VERIFICATION_TRIGGERS", NULL} +#define STMT_231 \ "CREATE TEMPORARY TRIGGER no_repository_updates BEFORE UPDATE ON repository " \ "BEGIN " \ " SELECT RAISE(FAIL, 'Updates to REPOSITORY are not allowed.'); " \ @@ -2869,6 +2895,7 @@ STMT_228, \ STMT_229, \ STMT_230, \ + STMT_231, \ NULL \ } @@ -3105,5 +3132,6 @@ STMT_228_INFO, \ STMT_229_INFO, \ STMT_230_INFO, \ + STMT_231_INFO, \ {NULL, NULL} \ } diff --git a/subversion/libsvn_wc/wc-queries.sql b/subversion/libsvn_wc/wc-queries.sql index d275a7b..a8388a3 100644 --- a/subversion/libsvn_wc/wc-queries.sql +++ b/subversion/libsvn_wc/wc-queries.sql @@ -1565,10 +1565,15 @@ WHERE wc_id = ?1 -- STMT_SELECT_MOVED_PAIR3 SELECT local_relpath, moved_to, op_depth, kind FROM nodes +WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth > ?3 + AND moved_to IS NOT NULL +UNION ALL +SELECT local_relpath, moved_to, op_depth, kind FROM nodes WHERE wc_id = ?1 - AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2)) + AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2) AND op_depth > ?3 AND moved_to IS NOT NULL +ORDER BY local_relpath, op_depth -- STMT_SELECT_MOVED_OUTSIDE SELECT local_relpath, moved_to, op_depth FROM nodes diff --git a/subversion/libsvn_wc/wc.h b/subversion/libsvn_wc/wc.h index 9438e2b..70c591e 100644 --- a/subversion/libsvn_wc/wc.h +++ b/subversion/libsvn_wc/wc.h @@ -157,6 +157,8 @@ extern "C" { * The bump to 31 added the inherited_props column in the NODES table. * Bumped in r1395109. * + * == 1.8.x shipped with format 31 + * * Please document any further format changes here. */ diff --git a/subversion/libsvn_wc/wc_db.c b/subversion/libsvn_wc/wc_db.c index 8b024c2..7d038cf 100644 --- a/subversion/libsvn_wc/wc_db.c +++ b/subversion/libsvn_wc/wc_db.c @@ -1390,6 +1390,15 @@ does_node_exist(svn_boolean_t *exists, return svn_error_trace(svn_sqlite__reset(stmt)); } +svn_error_t * +svn_wc__db_install_schema_statistics(svn_sqlite__db_t *sdb, + apr_pool_t *scratch_pool) +{ + SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_INSTALL_SCHEMA_STATISTICS)); + + return SVN_NO_ERROR; +} + /* Helper for create_db(). Initializes our wc.db schema. */ static svn_error_t * @@ -1417,6 +1426,8 @@ init_db(/* output values */ SVN_ERR(create_repos_id(repos_id, repos_root_url, repos_uuid, db, scratch_pool)); + SVN_ERR(svn_wc__db_install_schema_statistics(db, scratch_pool)); + /* Insert the wcroot. */ /* ### Right now, this just assumes wc metadata is being stored locally. */ SVN_ERR(svn_sqlite__get_statement(&stmt, db, STMT_INSERT_WCROOT)); @@ -4551,6 +4562,21 @@ db_op_copy(svn_wc__db_wcroot_t *src_wcroot, } else { + if (copyfrom_relpath) + { + const char *repos_root_url; + const char *repos_uuid; + + /* Pass the right repos-id for the destination db! */ + + SVN_ERR(svn_wc__db_fetch_repos_info(&repos_root_url, &repos_uuid, + src_wcroot->sdb, copyfrom_id, + scratch_pool)); + + SVN_ERR(create_repos_id(©from_id, repos_root_url, repos_uuid, + dst_wcroot->sdb, scratch_pool)); + } + SVN_ERR(cross_db_copy(src_wcroot, src_relpath, dst_wcroot, dst_relpath, dst_presence, dst_op_depth, dst_np_op_depth, kind, diff --git a/subversion/libsvn_wc/wc_db.h b/subversion/libsvn_wc/wc_db.h index 61906e3..a4ed3f9 100644 --- a/subversion/libsvn_wc/wc_db.h +++ b/subversion/libsvn_wc/wc_db.h @@ -2831,6 +2831,16 @@ svn_wc__db_scan_deletion(const char **base_del_abspath, @{ */ +/* Installs or updates Sqlite schema statistics for the current (aka latest) + working copy schema. + + This function should be called once on initializing the database and after + an schema update completes */ +svn_error_t * +svn_wc__db_install_schema_statistics(svn_sqlite__db_t *sdb, + apr_pool_t *scratch_pool); + + /* Create a new wc.db file for LOCAL_DIR_ABSPATH, which is going to be a working copy for the repository REPOS_ROOT_URL with uuid REPOS_UUID. Return the raw sqlite handle, repository id and working copy id diff --git a/subversion/libsvn_wc/wc_db_util.c b/subversion/libsvn_wc/wc_db_util.c index 39dd034..a6616e4 100644 --- a/subversion/libsvn_wc/wc_db_util.c +++ b/subversion/libsvn_wc/wc_db_util.c @@ -136,22 +136,6 @@ svn_wc__db_util_open_db(svn_sqlite__db_t **sdb, svn_dirent_local_style(sdb_abspath, scratch_pool)); } -#ifndef WIN32 - else - { - apr_file_t *f; - - /* A standard SQLite build creates a DB with mode 644 ^ !umask - which means the file doesn't have group/world write access - even when umask allows it. By ensuring the file exists before - SQLite gets involved we give it the permissions allowed by - umask. */ - SVN_ERR(svn_io_file_open(&f, sdb_abspath, - (APR_READ | APR_WRITE | APR_CREATE), - APR_OS_DEFAULT, scratch_pool)); - SVN_ERR(svn_io_file_close(f, scratch_pool)); - } -#endif SVN_ERR(svn_sqlite__open(sdb, sdb_abspath, smode, my_statements ? my_statements : statements, |