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 00:51:33 UTC
svn commit: r905841 - in /subversion/trunk/subversion/libsvn_fs_fs: fs_fs.c
rep-cache-db.sql rep-cache.c revprops-db.sql
Author: gstein
Date: Tue Feb 2 23:51:33 2010
New Revision: 905841
URL: http://svn.apache.org/viewvc?rev=905841&view=rev
Log:
For the FSFS uses of sqlite, don't use the "upgrade" mechanism for the
schema. Just create it explicitly using exec_statements().
* libsvn_fs_fs/rep-cache-db.sql:
* libsvn_fs_fs/revprops-db.sql:
(STMT_CREATE_SCHEMA): new statement for the schema creation commands.
make sure to end with a bump for the schema version.
* libsvn_fs_fs/fs_fs.c:
(REVPROPS_SCHEMA_FORMAT, upgrade_sql): removed. no longer used.
(svn_fs_fs__open, upgrade_body, svn_fs_fs__create): stop passing
upgrade_sql and a format version to svn_sqlite__open. for the two
calls where we create the database, follow it up with a call to
construct the schema.
* libsvn_fs_fs/rep-cache.c:
(upgrade_sql): removed. no longer used.
(svn_fs_fs__open_rep_cache): do not pass upgrade_sql to the sdb open
call. examine the version, and if the schema has not been constructed,
then do so.
Modified:
subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
subversion/trunk/subversion/libsvn_fs_fs/rep-cache-db.sql
subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c
subversion/trunk/subversion/libsvn_fs_fs/revprops-db.sql
Modified: subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c?rev=905841&r1=905840&r2=905841&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c Tue Feb 2 23:51:33 2010
@@ -137,13 +137,7 @@
svn_fs_fs__change_txn_props
};
-#define REVPROPS_SCHEMA_FORMAT 1
-
/* SQL bits for revprops. */
-static const char * const upgrade_sql[] = { NULL,
- REVPROPS_DB_SQL
- };
-
REVPROPS_DB_SQL_DECLARE_STATEMENTS(statements);
/* Declarations. */
@@ -1245,7 +1239,7 @@
PATH_REVPROPS_DB,
NULL),
svn_sqlite__mode_readwrite, statements,
- REVPROPS_SCHEMA_FORMAT, upgrade_sql,
+ 0, NULL,
fs->pool, pool));
}
@@ -1319,8 +1313,10 @@
PATH_REVPROPS_DB,
NULL),
svn_sqlite__mode_rwcreate, statements,
- REVPROPS_SCHEMA_FORMAT, upgrade_sql,
+ 0, NULL,
fs->pool, pool));
+ SVN_ERR(svn_sqlite__exec_statements(ffd->revprop_db,
+ STMT_CREATE_SCHEMA));
}
/* Bump the format file. */
@@ -6370,8 +6366,10 @@
PATH_REVPROPS_DB,
NULL),
svn_sqlite__mode_rwcreate, statements,
- REVPROPS_SCHEMA_FORMAT, upgrade_sql,
+ 0, NULL,
fs->pool, pool));
+ SVN_ERR(svn_sqlite__exec_statements(ffd->revprop_db,
+ STMT_CREATE_SCHEMA));
}
/* Create the transaction directory. */
Modified: subversion/trunk/subversion/libsvn_fs_fs/rep-cache-db.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/rep-cache-db.sql?rev=905841&r1=905840&r2=905841&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/rep-cache-db.sql (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/rep-cache-db.sql Tue Feb 2 23:51:33 2010
@@ -21,6 +21,7 @@
* ====================================================================
*/
+-- STMT_CREATE_SCHEMA
pragma auto_vacuum = 1;
/* A table mapping representation hashes to locations in a rev file. */
@@ -30,6 +31,8 @@
size integer not null,
expanded_size integer not null);
+pragma user_version = 1;
+
-- STMT_GET_REP
select revision, offset, size, expanded_size
Modified: subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c?rev=905841&r1=905840&r2=905841&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c Tue Feb 2 23:51:33 2010
@@ -35,10 +35,6 @@
/* A few magic values */
#define REP_CACHE_SCHEMA_FORMAT 1
-static const char * const upgrade_sql[] = { NULL,
- REP_CACHE_DB_SQL
- };
-
REP_CACHE_DB_SQL_DECLARE_STATEMENTS(statements);
@@ -48,6 +44,7 @@
{
fs_fs_data_t *ffd = fs->fsap_data;
const char *db_path;
+ int version;
/* Be idempotent. */
if (ffd->rep_cache_db)
@@ -58,9 +55,18 @@
db_path = svn_dirent_join(fs->path, REP_CACHE_DB_NAME, pool);
SVN_ERR(svn_sqlite__open(&ffd->rep_cache_db, db_path,
svn_sqlite__mode_rwcreate, statements,
- REP_CACHE_SCHEMA_FORMAT, upgrade_sql,
+ 0, NULL,
fs->pool, pool));
+ SVN_ERR(svn_sqlite__read_schema_version(&version, ffd->rep_cache_db, pool));
+ if (version < REP_CACHE_SCHEMA_FORMAT)
+ {
+ /* Must be 0 -- an uninitialized (no schema) database. Create
+ the schema. Results in schema version of 1. */
+ SVN_ERR(svn_sqlite__exec_statements(ffd->rep_cache_db,
+ STMT_CREATE_SCHEMA));
+ }
+
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/libsvn_fs_fs/revprops-db.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/revprops-db.sql?rev=905841&r1=905840&r2=905841&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/revprops-db.sql (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/revprops-db.sql Tue Feb 2 23:51:33 2010
@@ -21,6 +21,7 @@
* ====================================================================
*/
+-- STMT_CREATE_SCHEMA
pragma auto_vacuum = 1;
/* A table for storing revision properties. */
@@ -29,6 +30,9 @@
create index i_revision on revprop (revision);
+pragma user_version = 1;
+
+
-- STMT_SET_REVPROP
insert or replace into revprop(revision, properties)
values (?1, ?2);