You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2010/02/03 01:04:58 UTC
svn commit: r905845 - in /subversion/trunk: Makefile.in build.conf
subversion/libsvn_wc/upgrade.c subversion/libsvn_wc/wc-metadata.sql
subversion/libsvn_wc/wc-queries.sql subversion/libsvn_wc/wc_db.c
subversion/tests/libsvn_wc/db-test.c
Author: gstein
Date: Wed Feb 3 00:04:58 2010
New Revision: 905845
URL: http://svn.apache.org/viewvc?rev=905845&view=rev
Log:
For wc-ng, switch to manual upgrade up the schema, rather than using the
"upgrade_sql" feature of svn_sqlite__open(). We need fine-grained control
in some cases. This also gives us an explicit set of statements for our
current schema (plus mods to convert older schemas to current). This is
clearer than a big, old schema, plus mods to update it.
* subversion/libsvn_wc/wc-metadata.sql:
(STMT_CREATE_SCHEMA): new statement, replacing the format 12 set of
commands. later formats' changes have been folded in, as detailed
below. this statement ends with setting the user_version to 16.
(PRISTINE): add the md5_checksum column
(ACTUAL_NODE): add the conflict_data and *_checksum columns
(WORK_QUEUE, WC_LOCK): pull these out of their format NN sections. add
the 'locked_levels' column to WC_LOCK.
(STMT_UPGRADE_TO_13, STMT_UPGRADE_TO_14, STMT_UPGRADE_TO_15,
STMT_UPGRADE_TO_16): new statements, based on old format sections.
each statements ends with setting the user_version appropriately.
* subversion/libsvn_wc/wc-queries.sql:
(): include the wc-metadata file to glom *all* statements into one table
* subversion/libsvn_wc/wc_db.c:
(): no need to include wc-metadata.h any more
(upgrade_sql): removed. no longer used.
(open_db): no longer pass a format version or the upgrade_sql to the
sqlite_open call.
(create_db): create the schema after the sdb has been created
* subversion/tests/libsvn_wc/db-test.c:
(): include wc-queries.h rather than wc-metadata.h. we need the schema
creation statements.
(data_loading_sql): removed. the extra statement to load data are in ...
(TESTING_DATA): new constant for loading data into the sdb. since the
ACTUAL_NODE table is immediately constructed with all current columns,
we need to adjust one INSERT to account for that.
(create_fake_wc): after the sdb is created, construct the schema and
load some testing data.
* subversion/libsvn_wc/upgrade.c:
(svn_wc__upgrade_sdb): error out if we reach the auto-schema-upgrade
code. this isn't ready yet.
* Makefile.in:
(wc-queries.h): add an explicit dep on wc-metadata.sql
* build.conf:
(wc-metadata): remove this build rule. no longer needed.
Modified:
subversion/trunk/Makefile.in
subversion/trunk/build.conf
subversion/trunk/subversion/libsvn_wc/upgrade.c
subversion/trunk/subversion/libsvn_wc/wc-metadata.sql
subversion/trunk/subversion/libsvn_wc/wc-queries.sql
subversion/trunk/subversion/libsvn_wc/wc_db.c
subversion/trunk/subversion/tests/libsvn_wc/db-test.c
Modified: subversion/trunk/Makefile.in
URL: http://svn.apache.org/viewvc/subversion/trunk/Makefile.in?rev=905845&r1=905844&r2=905845&view=diff
==============================================================================
--- subversion/trunk/Makefile.in (original)
+++ subversion/trunk/Makefile.in Wed Feb 3 00:04:58 2010
@@ -835,3 +835,7 @@
$(PYTHON) setup.py clean --all
extraclean-ctypes-python: clean-ctypes-python
+
+
+# manually describe a dependency, which we won't otherwise detect
+subversion/libsvn_wc/wc-queries.h: $(abs_srcdir)/subversion/libsvn_wc/wc-metadata.sql
Modified: subversion/trunk/build.conf
URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=905845&r1=905844&r2=905845&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Wed Feb 3 00:04:58 2010
@@ -382,12 +382,6 @@
path = subversion/libsvn_fs_fs
sources = revprops-db.sql
-[wc_metadata]
-description = Schema for the WC database
-type = sql-header
-path = subversion/libsvn_wc
-sources = wc-metadata.sql
-
[wc_queries]
desription = Queries on the WC database
type = sql-header
Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=905845&r1=905844&r2=905845&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Wed Feb 3 00:04:58 2010
@@ -914,6 +914,12 @@
scratch_pool),
start_format);
+ /* ### need lock-out. only one upgrade at a time. note that other code
+ ### cannot use this un-upgraded database until we finish the upgrade. */
+
+ /* ### the code to upgrade has bit-rotted. just fail for now. */
+ SVN_ERR_MALFUNCTION();
+
/* Note: none of these have "break" statements; the fall-through is
intentional. */
switch (start_format)
Modified: subversion/trunk/subversion/libsvn_wc/wc-metadata.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-metadata.sql?rev=905845&r1=905844&r2=905845&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-metadata.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-metadata.sql Wed Feb 3 00:04:58 2010
@@ -38,8 +38,8 @@
* "base-deleted" -- node represents a delete of a BASE node
*/
-/* All the SQL below is for format 12: SVN_WC__WC_NG_VERSION */
--- format: 12
+/* One big list of statements to create our (current) schema. */
+-- STMT_CREATE_SCHEMA
/* ------------------------------------------------------------------------- */
@@ -181,7 +181,9 @@
/* ### this will probably go away, in favor of counting references
### that exist in BASE_NODE and WORKING_NODE. */
- refcount INTEGER NOT NULL
+ refcount INTEGER NOT NULL,
+
+ md5_checksum TEXT
);
@@ -349,6 +351,15 @@
removed in format 13, in favor of the CONFLICT_VICTIM table*/
tree_conflict_data TEXT,
+ /* A skel containing the conflict details. */
+ conflict_data BLOB,
+
+ /* Three columns containing the checksums of older, left and right conflict
+ texts. Stored in a column to allow storing them in the pristine store */
+ older_checksum TEXT,
+ left_checksum TEXT,
+ right_checksum TEXT,
+
PRIMARY KEY (wc_id, local_relpath)
);
@@ -382,9 +393,37 @@
/* ------------------------------------------------------------------------- */
+CREATE TABLE WORK_QUEUE (
+ /* Work items are identified by this value. */
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+
+ /* A serialized skel specifying the work item. */
+ work BLOB NOT NULL
+ );
+
+
+/* ------------------------------------------------------------------------- */
+
+CREATE TABLE WC_LOCK (
+ /* specifies the location of this node in the local filesystem */
+ wc_id INTEGER NOT NULL REFERENCES WCROOT (id),
+ local_dir_relpath TEXT NOT NULL,
+
+ locked_levels INTEGER NOT NULL DEFAULT -1,
+
+ PRIMARY KEY (wc_id, local_dir_relpath)
+ );
+
+
+PRAGMA user_version = 16;
+
+
+/* ------------------------------------------------------------------------- */
+
/* Format 13 introduces the work queue, and erases a few columns from the
original schema. */
--- format: 13
+-- STMT_UPGRADE_TO_13
+
CREATE TABLE WORK_QUEUE (
/* Work items are identified by this value. */
id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -397,11 +436,14 @@
erase anything there. */
UPDATE BASE_NODE SET incomplete_children=null, dav_cache=null;
+PRAGMA user_version = 13;
+
+
/* ------------------------------------------------------------------------- */
/* Format 14 introduces a table for storing wc locks, and additional columns
for storing conflict data in ACTUAL. */
--- format: 14
+-- STMT_UPGRADE_TO_14
/* The existence of a row in this table implies a write lock. */
CREATE TABLE WC_LOCK (
@@ -427,10 +469,13 @@
ALTER TABLE ACTUAL_NODE
ADD COLUMN right_checksum TEXT;
+PRAGMA user_version = 14;
+
+
/* ------------------------------------------------------------------------- */
/* Format 15 introduces new handling for excluded nodes. */
--- format: 15
+-- STMT_UPGRADE_TO_15
UPDATE base_node
SET
@@ -454,10 +499,13 @@
last_mod_time = NULL, properties = NULL, keep_local = NULL
WHERE depth = 'exclude';
+PRAGMA user_version = 15;
+
+
/* ------------------------------------------------------------------------- */
/* Format 16 introduces some new columns for pristines and locks. */
--- format: 16
+-- STMT_UPGRADE_TO_16
/* An md5 column for the pristine table. */
ALTER TABLE PRISTINE
@@ -471,6 +519,8 @@
UPDATE wc_lock
SET locked_levels = 0;
+PRAGMA user_version = 16;
+
/* ------------------------------------------------------------------------- */
Modified: subversion/trunk/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc-queries.sql?rev=905845&r1=905844&r2=905845&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/trunk/subversion/libsvn_wc/wc-queries.sql Wed Feb 3 00:04:58 2010
@@ -375,3 +375,7 @@
/* ------------------------------------------------------------------------- */
+
+/* Grab all the statements related to the schema. */
+
+-- include: wc-metadata
Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=905845&r1=905844&r2=905845&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Feb 3 00:04:58 2010
@@ -36,7 +36,6 @@
#include "wc.h"
#include "wc_db.h"
#include "adm_files.h"
-#include "wc-metadata.h"
#include "wc-queries.h"
#include "entries.h"
#include "lock.h"
@@ -203,18 +202,6 @@
### need to undo the SKIP. */
#define SVN__SKIP_SUBDIR
-/* ### duplicates entries.c */
-static const char * const upgrade_sql[] = {
- NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL,
- NULL, NULL,
- WC_METADATA_SQL_12,
- WC_METADATA_SQL_13,
- WC_METADATA_SQL_14,
- WC_METADATA_SQL_15,
- WC_METADATA_SQL_16
-};
-
WC_QUERIES_SQL_DECLARE_STATEMENTS(statements);
@@ -813,7 +800,7 @@
return svn_error_return(svn_sqlite__open(sdb, sdb_abspath,
smode, statements,
- SVN_WC__VERSION, upgrade_sql,
+ 0, NULL,
result_pool, scratch_pool));
}
@@ -1474,6 +1461,9 @@
svn_sqlite__mode_rwcreate,
result_pool, scratch_pool));
+ /* Create the database's schema. */
+ SVN_ERR(svn_sqlite__exec_statements(*sdb, STMT_CREATE_SCHEMA));
+
/* Insert the repository. */
SVN_ERR(create_repos_id(repos_id, repos_root_url, repos_uuid, *sdb,
scratch_pool));
Modified: subversion/trunk/subversion/tests/libsvn_wc/db-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/db-test.c?rev=905845&r1=905844&r2=905845&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/db-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/db-test.c Wed Feb 3 00:04:58 2010
@@ -41,7 +41,7 @@
#include "../../libsvn_wc/wc.h"
#include "../../libsvn_wc/wc_db.h"
-#include "../../libsvn_wc/wc-metadata.h"
+#include "../../libsvn_wc/wc-queries.h"
#include "private/svn_wc_private.h"
@@ -77,13 +77,7 @@
#define I_TC_DATA "((conflict F file update edited deleted (version 23 " ROOT_ONE " 1 2 branch1/ft/F none) (version 23 " ROOT_ONE " 1 3 branch1/ft/F file)) (conflict G file update edited deleted (version 23 " ROOT_ONE " 1 2 branch1/ft/F none) (version 23 " ROOT_ONE " 1 3 branch1/ft/F file)) )"
-static const char * const data_loading_sql[] = {
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- (
- /* Load the table and index definitions. */
- WC_METADATA_SQL_12
- " "
-
+static const char * const TESTING_DATA = (
/* Load our test data.
Note: do not use named-column insertions. This allows us to test
@@ -301,7 +295,7 @@
" "
"insert into actual_node values ("
" 1, 'I', '', null, null, null, null, null, 'changelist', null, "
- "'" I_TC_DATA "');"
+ "'" I_TC_DATA "', null, null, null, null);"
" "
"insert into base_node values ("
" 1, 'M', null, null, '', 'normal', 'dir', "
@@ -313,13 +307,9 @@
" null, null, "
" null, null, null, null, null, "
" null, null, null, 0, null, null, '()', 0); "
- ),
+ );
- WC_METADATA_SQL_13,
- WC_METADATA_SQL_14,
- WC_METADATA_SQL_15,
- WC_METADATA_SQL_16
-};
+WC_QUERIES_SQL_DECLARE_STATEMENTS(statements);
static svn_error_t *
@@ -329,13 +319,25 @@
"fake-wc", subdir, ".svn", NULL);
const char *dbpath = svn_dirent_join(dirpath, "wc.db", scratch_pool);
svn_sqlite__db_t *sdb;
+ const char * const my_statements[] = {
+ statements[STMT_CREATE_SCHEMA],
+ TESTING_DATA,
+ NULL
+ };
SVN_ERR(svn_io_make_dir_recursively(dirpath, scratch_pool));
svn_error_clear(svn_io_remove_file(dbpath, scratch_pool));
- SVN_ERR(svn_sqlite__open(&sdb, dbpath, svn_sqlite__mode_rwcreate, NULL,
- format, data_loading_sql,
+ SVN_ERR(svn_sqlite__open(&sdb, dbpath, svn_sqlite__mode_rwcreate,
+ my_statements,
+ 0, NULL,
scratch_pool, scratch_pool));
+ /* Create the database's schema. */
+ SVN_ERR(svn_sqlite__exec_statements(sdb, /* my_statements[] */ 0));
+
+ /* Throw our extra data into the database. */
+ SVN_ERR(svn_sqlite__exec_statements(sdb, /* my_statements[] */ 1));
+
return SVN_NO_ERROR;
}