From 9b745ee433e087abc43a6bcefa2ba60b8925711b Mon Sep 17 00:00:00 2001 From: mattn Date: Sun, 3 Feb 2013 23:25:30 +0900 Subject: [PATCH] Some older version of sqlite3 does not have SQLITE_OPEN_URI. --- sqlite3.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sqlite3.go b/sqlite3.go index 6e8ca28..32ca049 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -5,6 +5,15 @@ package sqlite #include #include +static int +_sqlite3_open_v2(const char *filename, sqlite3 **ppDb, int flags, const char *zVfs) { +#ifdef SQLITE_OPEN_URI + return sqlite3_open_v2(filename, ppDb, flags | SQLITE_OPEN_URI, zVfs); +#else + return sqlite3_open_v2(filename, ppDb, flags, zVfs); +#endif +} + static int _sqlite3_bind_text(sqlite3_stmt *stmt, int n, char *p, int np) { return sqlite3_bind_text(stmt, n, p, np, SQLITE_TRANSIENT); @@ -141,11 +150,10 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { var db *C.sqlite3 name := C.CString(dsn) defer C.free(unsafe.Pointer(name)) - rv := C.sqlite3_open_v2(name, &db, + rv := C._sqlite3_open_v2(name, &db, C.SQLITE_OPEN_FULLMUTEX| C.SQLITE_OPEN_READWRITE| - C.SQLITE_OPEN_CREATE | - C.SQLITE_OPEN_URI, + C.SQLITE_OPEN_CREATE, nil) if rv != 0 { return nil, errors.New(C.GoString(C.sqlite3_errmsg(db)))