示例#1
0
文件: txn.go 项目: Crest/gomdb
func (txn *Txn) DBIOpen(name *string, flags uint) (DBI, error) {
	var _dbi C.MDB_dbi
	var cname *C.char
	if name == nil {
		cname = nil
	} else {
		cname = C.CString(*name)
		defer C.free(unsafe.Pointer(cname))
	}
	ret := C.mdb_dbi_open(txn._txn, cname, C.uint(flags), &_dbi)
	if ret != SUCCESS {
		return DBI(math.NaN()), Errno(ret)
	}
	return DBI(_dbi), nil
}
示例#2
0
文件: txn.go 项目: pasinskim/mender
// openDBI returns returns whatever DBI value was set by mdb_open_dbi.  In an
// error case, LMDB does not currently set DBI in case of failure, so zero is
// returned in those cases.  This is not a big deal for now because
// applications are expected to handle any error encountered opening a
// database.
func (txn *Txn) openDBI(cname *C.char, flags uint) (DBI, error) {
	var dbi C.MDB_dbi
	ret := C.mdb_dbi_open(txn._txn, cname, C.uint(flags), &dbi)
	return DBI(dbi), operrno("mdb_dbi_open", ret)
}