hanito / sqdbcpp

Automatically exported from code.google.com/p/sqdbcpp
0 stars 0 forks source link

sqlite3_open_v2 only supported starting with 3.5.0 #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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, &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.

Original issue reported on code.google.com by radio.w7...@gmail.com on 2 Aug 2012 at 11:59

GoogleCodeExporter commented 9 years ago
Sorry, had two windows open on two different projects and posted to the wrong 
one.  Please forgive me.

Original comment by radio.w7...@gmail.com on 3 Aug 2012 at 12:07