Author: rhuijben
Date: Mon Feb 24 23:27:53 2014
New Revision: 1571489
URL: http://svn.apache.org/r1571489
Log:
Merge r1542765,1571214, resolving text conflicts and tweaked for 1.7 schema
Modified:
subversion/branches/1.7.x-r1542765/ (props changed)
subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/upgrade.c
subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc-metadata.sql
subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc_db.c
subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc_db.h
Propchange: subversion/branches/1.7.x-r1542765/
------------------------------------------------------------------------------
Merged /subversion/trunk:r1542765,1571214
Modified: subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/upgrade.c
URL:
http://svn.apache.org/viewvc/subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/upgrade.c?rev=1571489&r1=1571488&r2=1571489&view=diff
==============================================================================
--- subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/upgrade.c Mon Feb
24 23:27:53 2014
@@ -1645,6 +1645,10 @@ svn_wc__upgrade_sdb(int *result_format,
*result_format = XXX;
/* FALLTHROUGH */
#endif
+
+ SVN_SQLITE__WITH_LOCK(
+ svn_wc__db_install_schema_statistics(sdb, scratch_pool),
+ sdb);
}
#ifdef SVN_DEBUG
Modified:
subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc-metadata.sql
URL:
http://svn.apache.org/viewvc/subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc-metadata.sql?rev=1571489&r1=1571488&r2=1571489&view=diff
==============================================================================
--- subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc-metadata.sql
(original)
+++ subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc-metadata.sql Mon
Feb 24 23:27:53 2014
@@ -571,6 +571,56 @@ CREATE UNIQUE INDEX I_EXTERNALS_DEFINED
def_local_relpath,
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 */
+
+DELETE FROM sqlite_stat1
+WHERE tbl in ('NODES', 'ACTUAL_NODE', 'LOCK', 'WC_LOCK');
+
+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
+ ('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 */
-- STMT_UPGRADE_TO_20
Modified: subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc_db.c
URL:
http://svn.apache.org/viewvc/subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc_db.c?rev=1571489&r1=1571488&r2=1571489&view=diff
==============================================================================
--- subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc_db.c Mon Feb 24
23:27:53 2014
@@ -1373,6 +1373,75 @@ 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 *
+init_db(/* output values */
+ apr_int64_t *repos_id,
+ apr_int64_t *wc_id,
+ /* input values */
+ svn_sqlite__db_t *db,
+ const char *repos_root_url,
+ const char *repos_uuid,
+ const char *root_node_repos_relpath,
+ svn_revnum_t root_node_revision,
+ svn_depth_t root_node_depth,
+ apr_pool_t *scratch_pool)
+{
+ svn_sqlite__stmt_t *stmt;
+
+ /* Create the database's schema. */
+ SVN_ERR(svn_sqlite__exec_statements(db, STMT_CREATE_SCHEMA));
+ SVN_ERR(svn_sqlite__exec_statements(db, STMT_CREATE_NODES));
+ SVN_ERR(svn_sqlite__exec_statements(db, STMT_CREATE_NODES_TRIGGERS));
+ SVN_ERR(svn_sqlite__exec_statements(db, STMT_CREATE_EXTERNALS));
+
+ /* Insert the repository. */
+ 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));
+ SVN_ERR(svn_sqlite__insert(wc_id, stmt));
+
+ if (root_node_repos_relpath)
+ {
+ svn_wc__db_status_t status = svn_wc__db_status_normal;
+
+ if (root_node_revision > 0)
+ status = svn_wc__db_status_incomplete; /* Will be filled by update */
+
+ SVN_ERR(svn_sqlite__get_statement(&stmt, db, STMT_INSERT_NODE));
+ SVN_ERR(svn_sqlite__bindf(stmt, "isdsisrtst",
+ *wc_id, /* 1 */
+ "", /* 2 */
+ 0, /* op_depth is 0 for base
*/
+ NULL, /* 4 */
+ *repos_id,
+ root_node_repos_relpath,
+ root_node_revision,
+ presence_map, status, /* 8 */
+ svn_token__to_word(depth_map,
+ root_node_depth),
+ kind_map, svn_node_dir /* 10 */));
+
+ SVN_ERR(svn_sqlite__insert(NULL, stmt));
+ }
+
+ return SVN_NO_ERROR;
+}
/* Create an sqlite database at DIR_ABSPATH/SDB_FNAME and insert
records for REPOS_ID (using REPOS_ROOT_URL and REPOS_UUID) into
Modified: subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc_db.h
URL:
http://svn.apache.org/viewvc/subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc_db.h?rev=1571489&r1=1571488&r2=1571489&view=diff
==============================================================================
--- subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/branches/1.7.x-r1542765/subversion/libsvn_wc/wc_db.h Mon Feb 24
23:27:53 2014
@@ -2591,6 +2591,16 @@ svn_wc__db_scan_deletion(const char **ba
@{
*/
+/* 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