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

Re: svn commit: r934008 - /subversion/trunk/subversion/libsvn_subr/sqlite.c

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Wed, 14 Apr 2010 21:24:08 +0300 (Jerusalem Daylight Time)

philip_at_apache.org wrote on Wed, 14 Apr 2010 at 16:35 -0000:
> - /* We could use the SQLite backup interface (from 3.6.11 and still
> - experimental) and the copy would be done in chunks with the lock
> - released between chunks. */
> +#if SQLITE_VERSION_AT_LEAST(3,6,11)
> + {

Given that the API is experimental, perhaps we shouldn't automatically
allow all future versions of sqlite here?

We can allow everything up to whatever is currently latest, but forbid
new versions (since the API is "is subject to change without notice").

[[[
Index: sqlite.c
===================================================================
--- sqlite.c (revision 934083)
+++ sqlite.c (working copy)
@@ -981,7 +981,9 @@ svn_sqlite__hotcopy(const char *src_path,
                            internal_statements, 0, NULL,
                            scratch_pool, scratch_pool));
 
-#if SQLITE_VERSION_AT_LEAST(3,6,11)
+#if SQLITE_VERSION_AT_LEAST(3,6,24)
+# error "sqlite3_backup_*() is experimental and may have changed semantics"
+#elif SQLITE_VERSION_AT_LEAST(3,6,11)
   {
     svn_sqlite__db_t *dst_db;
     sqlite3_backup *backup;
]]]

?

Daniel

> + svn_sqlite__db_t *dst_db;
> + sqlite3_backup *backup;
> + int rc1, rc2;
> +
> + SVN_ERR(svn_sqlite__open(&dst_db, dst_path, svn_sqlite__mode_rwcreate,
> + NULL, 0, NULL, scratch_pool, scratch_pool));
> + backup = sqlite3_backup_init(dst_db->db3, "main", src_db->db3, "main");
> + if (!backup)
> + return SVN_NO_ERROR;
> + do
> + {
> + /* Pages are usually 1024 byte (SQLite docs). On my laptop
> + copying gets faster as the number of pages is increased up
> + to about 64, beyond that speed levels off. Lets put the
> + number of pages an order of magnitude higher, this is still
> + likely to be a fraction of large databases. */
> + rc1 = sqlite3_backup_step(backup, 1024);
> + if (rc1 == SQLITE_BUSY || rc1 == SQLITE_LOCKED)
> + sqlite3_sleep(25);
> + }
> + while (rc1 == SQLITE_OK || rc1 == SQLITE_BUSY || rc1 == SQLITE_LOCKED);
> + rc2 = sqlite3_backup_finish(backup);
> + if (rc1 != SQLITE_DONE)
> + SQLITE_ERR(rc1, dst_db);
> + SQLITE_ERR(rc2, dst_db);
> + SVN_ERR(svn_sqlite__close(dst_db));
> + }
> +#else
Received on 2010-04-14 20:24:02 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.