Commit a09c1c19 authored by gwenn's avatar gwenn

Add binding to sqlite3_config(SQLITE_CONFIG_MEMSTATUS|SQLITE_CONFIG_URI).

parent 5a25a02d
......@@ -49,3 +49,7 @@ int goSqlite3ConfigLog(void *udp) {
int goSqlite3ConfigThreadMode(int mode) {
return sqlite3_config(mode);
}
int goSqlite3Config(int op, int mode) {
return sqlite3_config(op, mode);
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ static void my_log(int iErrCode, char *msg) {
int goSqlite3ConfigLog(void *udp);
int goSqlite3ConfigThreadMode(int mode);
int goSqlite3Config(int op, int mode);
*/
import "C"
......@@ -303,19 +304,40 @@ func ConfigLog(f Logger, udp interface{}) error {
return Errno(rv)
}
type ThreadMode int
type ThreadingMode int
const (
SINGLETHREAD ThreadMode = C.SQLITE_CONFIG_SINGLETHREAD
MULTITHREAD ThreadMode = C.SQLITE_CONFIG_MULTITHREAD
SERIALIZED ThreadMode = C.SQLITE_CONFIG_SERIALIZED
SINGLETHREAD ThreadingMode = C.SQLITE_CONFIG_SINGLETHREAD
MULTITHREAD ThreadingMode = C.SQLITE_CONFIG_MULTITHREAD
SERIALIZED ThreadingMode = C.SQLITE_CONFIG_SERIALIZED
)
// Alters threading mode
// (See sqlite3_config(SQLITE_CONFIG_SINGLETHREAD|SQLITE_CONFIG_MULTITHREAD|SQLITE_CONFIG_SERIALIZED): http://sqlite.org/c3ref/config.html)
func ConfigThreadMode(mode ThreadMode) error {
func ConfigThreadingMode(mode ThreadingMode) error {
rv := C.goSqlite3ConfigThreadMode(C.int(mode))
if rv == C.SQLITE_OK {
return nil
}
return Errno(rv)
}
// Enables or disables the collection of memory allocation statistics
// (See sqlite3_config(SQLITE_CONFIG_MEMSTATUS): http://sqlite.org/c3ref/config.html)
func ConfigMemStatus(b bool) error {
rv := C.goSqlite3Config(C.SQLITE_CONFIG_MEMSTATUS, btocint(b))
if rv == C.SQLITE_OK {
return nil
}
return Errno(rv)
}
// Enables or disables URI handling
// (See sqlite3_config(SQLITE_CONFIG_URI): http://sqlite.org/c3ref/config.html)
func ConfigUri(b bool) error {
rv := C.goSqlite3Config(C.SQLITE_CONFIG_URI, btocint(b))
if rv == C.SQLITE_OK {
return nil
}
return Errno(rv)
}
......@@ -11,9 +11,13 @@ import (
)
func init() {
err := ConfigThreadMode(SERIALIZED)
err := ConfigThreadingMode(SERIALIZED)
if err != nil {
panic(fmt.Sprintf("cannot change thread mode: '%s'", err))
panic(fmt.Sprintf("cannot change threading mode: '%s'", err))
}
err = ConfigMemStatus(true)
if err != nil {
panic(fmt.Sprintf("cannot activate mem status: '%s'", err))
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment