mirror of https://github.com/mattn/go-sqlite3.git
Some older version of sqlite3 does not have SQLITE_OPEN_URI.
This commit is contained in:
parent
6e13c4512d
commit
9b745ee433
14
sqlite3.go
14
sqlite3.go
|
@ -5,6 +5,15 @@ package sqlite
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
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
|
static int
|
||||||
_sqlite3_bind_text(sqlite3_stmt *stmt, int n, char *p, int np) {
|
_sqlite3_bind_text(sqlite3_stmt *stmt, int n, char *p, int np) {
|
||||||
return sqlite3_bind_text(stmt, n, p, np, SQLITE_TRANSIENT);
|
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
|
var db *C.sqlite3
|
||||||
name := C.CString(dsn)
|
name := C.CString(dsn)
|
||||||
defer C.free(unsafe.Pointer(name))
|
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_FULLMUTEX|
|
||||||
C.SQLITE_OPEN_READWRITE|
|
C.SQLITE_OPEN_READWRITE|
|
||||||
C.SQLITE_OPEN_CREATE |
|
C.SQLITE_OPEN_CREATE,
|
||||||
C.SQLITE_OPEN_URI,
|
|
||||||
nil)
|
nil)
|
||||||
if rv != 0 {
|
if rv != 0 {
|
||||||
return nil, errors.New(C.GoString(C.sqlite3_errmsg(db)))
|
return nil, errors.New(C.GoString(C.sqlite3_errmsg(db)))
|
||||||
|
|
Loading…
Reference in New Issue