[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r33520 - requiring SQLite

From: Greg Stein <gstein_at_gmail.com>
Date: Tue, 7 Oct 2008 14:20:41 -0700

There is some #if'd code in init_sqlite() that is incomplete. Are
those two functions in 3.4?

On Tue, Oct 7, 2008 at 2:09 PM, Justin Erenkrantz <justin_at_erenkrantz.com> wrote:
> On Tue, Oct 7, 2008 at 1:19 PM, Greg Stein <gstein_at_gmail.com> wrote:
>> So. For the moment, we require 3.5.x (and allow 3.6.x). If somebody
>> wants to do the legwork for 3.4.x, then by all means...
>
> Patch below compiles against SQLite 3.4.0 as shipped with Mac OS X
> 10.5. Do you see any reason not to commit?
>
> This should institute the checking when we do read-only/read-write
> that the database already exists. And, since older versions of
> sqlite3 don't support read-only ops, it will be implicitly read-write;
> but not a whole lot we can do there, IMO.
>
> I haven't checked to see whether 3.3 or 3.2 would be coming along for
> free - perhaps, but this should be okay with 3.4.x. -- justin
>
> ---
>
> SQLite: compile against version 3.4.x (aka what Mac OS X 10.5 includes).
>
> * subversion/libsvn_subr/sqlite.c
> (private/svn_dep_compat.h): Include.
> (svn_sqlite__open): Use sqlite3_open on older sqlite instances.
> * subversion/include/private/svn_dep_compat.h
> (SQLITE_VERSION_AT_LEAST): Implement helper macro.
> * configure.ac
> (SQLITE_ALLOWED_PATTERN): Add 3.4.x to mix.
>
> Index: subversion/libsvn_subr/sqlite.c
> ===================================================================
> --- subversion/libsvn_subr/sqlite.c (revision 33523)
> +++ subversion/libsvn_subr/sqlite.c (working copy)
> @@ -25,6 +25,7 @@
>
> #include "private/svn_sqlite.h"
> #include "svn_private_config.h"
> +#include "private/svn_dep_compat.h"
>
>
> #ifdef SQLITE3_DEBUG
> @@ -364,6 +365,7 @@
> /* ### use a pool cleanup to close this? (instead of __close()) */
> *db = apr_palloc(result_pool, sizeof(**db));
>
> +#if SQLITE_VERSION_AT_LEAST(3,5,0)
> if (mode == svn_sqlite__mode_readonly)
> flags = SQLITE_OPEN_READONLY;
> else if (mode == svn_sqlite__mode_readwrite)
> @@ -387,7 +389,34 @@
> occurs (except for out-of-memory); thus, we can safely use it to
> extract an error message and construct an svn_error_t. */
> SQLITE_ERR(sqlite3_open_v2(path, &(*db)->db3, flags, NULL), *db);
> +#else
> + /* Older versions of SQLite (pre-3.5.x) will always create the database
> + if it doesn't exist. So, if we are asked to be read-only or read-write,
> + we ensure the database already exists - if it doesn't, then we will
> + explicitly error out before asking SQLite to do anything.
>
> + Pre-3.5.x SQLite versions also don't support read-only ops either.
> + */
> + if (mode == svn_sqlite__mode_readonly || mode == svn_sqlite__mode_readwrite)
> + {
> + svn_node_kind_t *kind;
> + SVN_ERR(svn_io_check_path(path, &kind, scratch_pool));
> + if (kind != svn_node_file) {
> + return svn_error_createf(SVN_ERR_WC_CORRUPT, NULL,
> + _("Expected SQLite database not found: %s"),
> + svn_path_local_style(path, scratch_pool));
> + }
> + }
> + else if (mode == svn_sqlite__mode_rwcreate)
> + {
> + /* do nothing - older SQLite's will create automatically. */
> + }
> + else
> + SVN_ERR_MALFUNCTION();
> +
> + SQLITE_ERR(sqlite3_open(path, &(*db)->db3), *db);
> +#endif
> +
> /* Retry until timeout when database is busy. */
> SQLITE_ERR(sqlite3_busy_timeout((*db)->db3, BUSY_TIMEOUT), *db);
> #ifdef SQLITE3_DEBUG
> Index: subversion/include/private/svn_dep_compat.h
> ===================================================================
> --- subversion/include/private/svn_dep_compat.h (revision 33523)
> +++ subversion/include/private/svn_dep_compat.h (working copy)
> @@ -69,6 +69,23 @@ extern "C" {
> (patch) <= SERF_PATCH_VERSION))
> #endif /* SERF_VERSION_AT_LEAST */
>
> +/**
> + * Check at compile time if the SQLite version is at least a certain
> + * level.
> + * @param major The major version component of the version checked
> + * for (e.g., the "1" of "1.3.0").
> + * @param minor The minor version component of the version checked
> + * for (e.g., the "3" of "1.3.0").
> + * @param patch The patch level component of the version checked
> + * for (e.g., the "0" of "1.3.0").
> + *
> + * @since New in 1.6.
> + */
> +#ifndef SQLITE_VERSION_AT_LEAST
> +#define SQLITE_VERSION_AT_LEAST(major,minor,patch) \
> +((major*1000000 + minor*1000 + patch) <= SQLITE_VERSION_NUMBER)
> +#endif /* SQLITE_VERSION_AT_LEAST */
> +
> #ifdef __cplusplus
> }
> #endif /* __cplusplus */
> Index: configure.ac
> ===================================================================
> --- configure.ac (revision 33523)
> +++ configure.ac (working copy)
> @@ -111,7 +111,7 @@ dnl Find Apache with a recent-enough magic module
> SVN_FIND_APACHE(20020903)
>
> dnl Search for SQLite
> -SQLITE_ALLOWED_PATTERN="(3\.5|3\.6)($|\..*)"
> +SQLITE_ALLOWED_PATTERN="(3\.4|3\.5|3\.6)($|\..*)"
> SQLITE_RECOMMENDED_VER="3.5.9"
> SQLITE_URL="http://www.sqlite.org/sqlite-${SQLITE_RECOMMENDED_VER}.tar.gz"
> SVN_LIB_SQLITE(${SQLITE_ALLOWED_PATTERN}, ${SQLITE_RECOMMENDED_VER},
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-10-07 23:20:54 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.