Change GNC_RESAVE_VERSION to GNUCASH_RESAVE_VERSION so that it's similar to the other version macros; define it at the top of configure.ac so that it's obvious to everybody; and store the current Gnucash version only when doing a full save so that retrospective changes to GNUCASH_RESAVE_VERSION won't skip a resave because the database has been touchedby a newer version.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20223 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
John Ralls 2011-02-02 00:04:29 +00:00
parent dd3f1a3c7d
commit 7cb436e08d
6 changed files with 21 additions and 28 deletions

View File

@ -27,7 +27,11 @@ AC_CONFIG_SRCDIR(src/engine/Transaction.h)
#Change this in development versions when changing anything that
#affects stored data structures. Reset to zero when bumping version.
GNUCASH_NANO_VERSION=0
#This should be the earliest version in the form XXMMUUNN (XX=MAJOR,
#MM=MINOR, UU=MICRO, NN=NANO) or SVN revision if before 2.4.1 which is
#storage-compatible with the current version. See the comments in
#src/backend/dbi/gnc-backend-dbi.c:gnc_dbi_load.
GNUCASH_RESAVE_VERSION=19920
# Initialize automake -- make sure we have at least version 1.9
AM_INIT_AUTOMAKE([1.9 dist-bzip2])
@ -82,6 +86,8 @@ AC_DEFINE_UNQUOTED(GNUCASH_MICRO_VERSION, $GNUCASH_MICRO_VERSION,
[GnuCash Micro version number])
AC_DEFINE_UNQUOTED(GNUCASH_NANO_VERSION, $GNUCASH_NANO_VERSION,
[GnuCash Nano version number])
AC_DEFINE_UNQUOTED(GNUCASH_RESAVE_VERSION, $GNUCASH_RESAVE_VERSION,
[GnuCash earliest compatible databaseversion number])
AC_DEFINE_UNQUOTED(GNUCASH_LATEST_STABLE_SERIES, "$GNUCASH_LATEST_STABLE_SERIES",
[Most recent stable GnuCash series])

View File

@ -33,6 +33,7 @@ libgncmod_backend_dbi_la_LIBADD = \
${GCONF_LIBS} \
${top_builddir}/src/backend/sql/libgnc-backend-sql.la \
${top_builddir}/src/engine/libgncmod-engine.la \
${top_builddir}/src/app-utils/libgncmod-app-utils.la \
${top_builddir}/src/libqof/qof/libgnc-qof.la \
${LIBDBI_LIBS}

View File

@ -1204,6 +1204,15 @@ gnc_dbi_destroy_backend( /*@ only @*/ QofBackend *be )
/* ================================================================= */
/* GNUCASH_RESAVE_VERSION indicates the earliest database version
* compatible with this version of Gnucash; the stored value is the
* earliest version of Gnucash conpatible with the database. If the
* GNUCASH_RESAVE_VERSION for this Gnucash is newer than the Gnucash
* version which created the database, a resave is offered. If the
* version of this Gnucash is older than the saved resave version,
* then the database will be loaded read-only. A resave will update
* both values to match this version of Gnucash.
*/
static void
gnc_dbi_load( QofBackend* qbe, /*@ dependent @*/ QofBook *book, QofBackendLoadType loadType )
{
@ -1228,14 +1237,14 @@ gnc_dbi_load( QofBackend* qbe, /*@ dependent @*/ QofBook *book, QofBackendLoadTy
gnc_sql_load( &be->sql_be, book, loadType );
if ( GNC_RESAVE_VERSION > gnc_sql_get_table_version( &be->sql_be, "Gnucash" ) )
if ( GNUCASH_RESAVE_VERSION > gnc_sql_get_table_version( &be->sql_be, "Gnucash" ) )
{
/* The database was loaded with an older database schema or
* data semantics. In order to ensure consistency, the whole
* thing needs to be saved anew. */
qof_backend_set_error( qbe, ERR_SQL_DB_TOO_OLD );
}
else if ( GNC_RESAVE_VERSION < gnc_sql_get_table_version( &be->sql_be,
else if ( GNUCASH_RESAVE_VERSION < gnc_sql_get_table_version( &be->sql_be,
"Gnucash-Resave"))
{
/* Worse, the database was created with a newer version. We

View File

@ -304,7 +304,7 @@ test_dbi_version_control( const gchar* driver, const gchar* url )
book = qof_session_get_book( sess );
qof_book_begin_edit( book );
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
"Gnucash", GNC_RESAVE_VERSION - 1 );
"Gnucash", GNUCASH_RESAVE_VERSION - 1 );
qof_book_commit_edit( book );
qof_session_end( sess );
qof_session_destroy( sess );

View File

@ -496,7 +496,7 @@ gnc_sql_sync_all( GncSqlBackend* be, /*@ dependent @*/ QofBook *book )
update_progress( be );
(void)reset_version_info( be );
gnc_sql_set_table_version( be, "Gnucash", gnc_get_long_version() );
gnc_sql_set_table_version( be, "Gnucash-Resave", GNC_RESAVE_VERSION );
gnc_sql_set_table_version( be, "Gnucash-Resave", GNUCASH_RESAVE_VERSION );
/* Create new tables */
be->is_pristine_db = TRUE;
@ -610,7 +610,6 @@ gnc_sql_commit_edit( GncSqlBackend *be, QofInstance *inst )
gboolean is_dirty;
gboolean is_destroying;
gboolean is_infant;
const gint gnc_version = gnc_get_long_version();
g_return_if_fail( be != NULL );
g_return_if_fail( inst != NULL );
@ -664,9 +663,6 @@ gnc_sql_commit_edit( GncSqlBackend *be, QofInstance *inst )
be_data.be = be;
be_data.inst = inst;
be_data.is_ok = TRUE;
/* Set/update the application version in the database */
if ( gnc_sql_get_table_version( be, "Gnucash") != gnc_version )
gnc_sql_set_table_version( be, "Gnucash", gnc_version );
qof_object_foreach_backend( GNC_SQL_BACKEND, commit_cb, &be_data );

View File

@ -43,25 +43,6 @@
#include "qofbackend-p.h"
#include <gmodule.h>
/**
* \def GNC_RESAVE_VERSION
*
* Defines the oldest svn revision of Gnucash which stores data in a
* way compatible with the current version. Data stored with an older
* version (or with no version indicated) of Gnucash will cause all
* tables to be moved aside, new tables saved with the current storage
* routines, and the old tables dropped. Any failures will trigger a
* rollback to the original tables.
*
* Encountering a database with a newer resave version will put the
* database in "read only" mode; a "save as" will be required to
* obtain a new database for storing from this instance, and the user
* will be warned of data loss.
*
*/
#define GNC_RESAVE_VERSION 19920
typedef struct GncSqlConnection GncSqlConnection;
/**