subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danie...@apache.org
Subject svn commit: r1139971 - /subversion/trunk/subversion/libsvn_subr/sqlite.c
Date Sun, 26 Jun 2011 23:43:29 GMT
Author: danielsh
Date: Sun Jun 26 23:43:28 2011
New Revision: 1139971

URL: http://svn.apache.org/viewvc?rev=1139971&view=rev
Log:
Work around a bug in SQLite 3.7.7.

See this thread for context:
http://mid.gmane.org/BANLkTimDypWGY-8tHFgJsTxN6ty6OkdJ0Q@mail.gmail.com

* subversion/libsvn_subr/sqlite.c
  (exec_sql): Rename to exec_sql2. Grow and use IGNORED_ERR parameter.
  (exec_sql): New macro wrapper.
  (svn_sqlite__open): Ran the CASE_SENSITIVE_LIKE pragma separately, with
    special error checking when SQLite is 3.7.7 (exactly).

Found by: arfrever

Suggested by: Richard Hipp <drh@sqlite.org>

Modified:
    subversion/trunk/subversion/libsvn_subr/sqlite.c

Modified: subversion/trunk/subversion/libsvn_subr/sqlite.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sqlite.c?rev=1139971&r1=1139970&r2=1139971&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sqlite.c (original)
+++ subversion/trunk/subversion/libsvn_subr/sqlite.c Sun Jun 26 23:43:28 2011
@@ -133,13 +133,18 @@ struct svn_sqlite__value_t
 } while (0)
 
 
+/* Convenience wrapper around exec_sql2(). */
+#define exec_sql(db, sql) exec_sql2((db), (sql), SQLITE_OK)
+
+/* Run the statement SQL on DB, ignoring SQLITE_OK and IGNORED_ERR.
+   (Note: the IGNORED_ERR parameter itself is not ignored.) */
 static svn_error_t *
-exec_sql(svn_sqlite__db_t *db, const char *sql)
+exec_sql2(svn_sqlite__db_t *db, const char *sql, int ignored_err)
 {
   char *err_msg;
   int sqlite_err = sqlite3_exec(db->db3, sql, NULL, NULL, &err_msg);
 
-  if (sqlite_err != SQLITE_OK)
+  if (sqlite_err != SQLITE_OK && sqlite_err != ignored_err)
     {
       svn_error_t *err = svn_error_createf(SQLITE_ERROR_CODE(sqlite_err), NULL,
                                            _("%s, executing statement '%s'"),
@@ -909,8 +914,16 @@ svn_sqlite__open(svn_sqlite__db_t **db, 
   sqlite3_profile((*db)->db3, sqlite_profiler, (*db)->db3);
 #endif
 
+#if SQLITE_VERSION_AT_LEAST(3,7,7) \
+    && !SQLITE_VERSION_AT_LEAST(3,7,8) \
+    && defined(SQLITE_SCHEMA)
+  /* See message <BANLkTimDypWGY-8tHFgJsTxN6ty6OkdJ0Q@mail.gmail.com> on dev@ */
+  SVN_ERR(exec_sql2(*db, "PRAGMA case_sensitive_like=1;", SQLITE_SCHEMA));
+#else
+  SVN_ERR(exec_sql2(*db, "PRAGMA case_sensitive_like=1;", SQLITE_OK));
+#endif /* 3.7.7 && SQLITE_SCHEMA */
+
   SVN_ERR(exec_sql(*db,
-              "PRAGMA case_sensitive_like=1;"
               /* Disable synchronization to disable the explicit disk flushes
                  that make Sqlite up to 50 times slower; especially on small
                  transactions.



Mime
View raw message