Export to GitHub

sqdbcpp - issue #2

sqlite3_open_v2 only supported starting with 3.5.0


Posted on Aug 2, 2012 by Grumpy Horse

What steps will reproduce the problem? 1. Compile with sqlite3 version < 3.5.0 installed

What is the expected output? What do you see instead? Compiler error about sqlite3_open_v2 being undefined

What version of the product are you using? On what operating system? I am on CentOS but it does not matter. This is an issue with the SQLite library version.

git log says: commit af1718a8f315c4e5c4294322d7be0eb758444143 Author: Wongoo Lee Date: Fri May 25 10:24:55 2012 -0700

Please provide any additional information below.

See SQLite 3.5.0 release notes at http://www.sqlite.org/34to35.html

The solution is to wrap the sqlite3pp::database::connect_v2 declaration and definition like this:

// sqlite3pp.h ~line 67

if SQLITE_VERSION_NUMBER >= 3005000 // sqlite3_open_v2 not available until sqlite 3.5.0

int connect_v2(char const* dbname, int flags, char const* vfs = 0);

endif

// sqlite3pp.cpp ~line 93

if SQLITE_VERSION_NUMBER >= 3005000 // sqlite3_open_v2 not available until sqlite 3.5.0

int database::connect_v2(char const* dbname, int flags, char const* vfs) { disconnect();

return sqlite3_open_v2(dbname, &amp;db_, flags, vfs);

}

endif

You could, of course, decide to simply call connect from connect_v2 in the case that SQLite is not the right version. However, this seems more risky since, presumably, the caller wanted to use the extended features of the v2 interface. I think it is better to let the library user make the decision explicitly.

Comment #1

Posted on Aug 3, 2012 by Grumpy Horse

Sorry, had two windows open on two different projects and posted to the wrong one. Please forgive me.

Status: New

Labels:
Type-Defect Priority-Medium