aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/error.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-09-19 09:50:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-09-19 09:50:53 +0200
commitfd2e006c32a407e4f097250b1e5e7f04098bae7b (patch)
treea66fd91f636104b621998b3df5be4575009ff743 /odb/sqlite/error.cxx
parenta77615868e8935e84ebbb4c441858917e971942c (diff)
Make sure we support older versions of SQLite (3.5.3 and up)
Diffstat (limited to 'odb/sqlite/error.cxx')
-rw-r--r--odb/sqlite/error.cxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/odb/sqlite/error.cxx b/odb/sqlite/error.cxx
index b7d56c1..847e9c1 100644
--- a/odb/sqlite/error.cxx
+++ b/odb/sqlite/error.cxx
@@ -10,6 +10,8 @@
#include <odb/sqlite/connection.hxx>
#include <odb/sqlite/exceptions.hxx>
+#include <odb/sqlite/details/config.hxx> // LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY
+
using namespace std;
namespace odb
@@ -20,7 +22,14 @@ namespace odb
translate_error (int e, connection& c)
{
sqlite3* h (c.handle ());
+
+ // Extended error codes are only available in 3.6.5 and later.
+ //
+#if SQLITE_VERSION_NUMBER >= 3006005
int ee (sqlite3_extended_errcode (h));
+#else
+ int ee (0);
+#endif
string m;
switch (e)
@@ -40,9 +49,10 @@ namespace odb
}
case SQLITE_LOCKED:
{
+#ifdef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY
if (ee != SQLITE_LOCKED_SHAREDCACHE)
throw deadlock (); // The DROP TABLE special case.
-
+#endif
// Getting SQLITE_LOCKED_SHAREDCACHE here means we don't have
// the unlock notify support. Translate this to timeout.
//
@@ -51,8 +61,10 @@ namespace odb
case SQLITE_BUSY:
case SQLITE_IOERR:
{
+#if SQLITE_VERSION_NUMBER >= 3006005
if (e != SQLITE_IOERR || ee == SQLITE_IOERR_BLOCKED)
throw timeout ();
+#endif
// Fall throught.
}