Added flags for txn_begin function.
This commit is contained in:
parent
332e18e7be
commit
f743d855d8
2 changed files with 18 additions and 4 deletions
|
@ -212,7 +212,7 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd,
|
|||
{
|
||||
// Extract the type code and filename from the inbuf
|
||||
// Inbuf is: <<Flags:32/unsigned, Type:8, Name/bytes, 0:8>>
|
||||
unsigned flags = (unsigned) UNPACK_INT(inbuf, 0);
|
||||
unsigned flags = UNPACK_INT(inbuf, 0);
|
||||
DBTYPE type = (DBTYPE) UNPACK_BYTE(inbuf, 4);
|
||||
char* name = UNPACK_STRING(inbuf, 5);
|
||||
int dbref;
|
||||
|
@ -264,8 +264,11 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd,
|
|||
RETURN_INT(ERROR_TXN_OPEN, outbuf);
|
||||
}
|
||||
|
||||
// Inbuf is <<Flags:32/unsigned>>
|
||||
unsigned flags = UNPACK_INT(inbuf, 0);
|
||||
|
||||
// Outbuf is <<Rc:32>>
|
||||
int rc = G_DB_ENV->txn_begin(G_DB_ENV, 0, &(d->txn), 0);
|
||||
int rc = G_DB_ENV->txn_begin(G_DB_ENV, 0, &(d->txn), flags);
|
||||
RETURN_INT(rc, outbuf);
|
||||
}
|
||||
case CMD_TXN_COMMIT:
|
||||
|
|
|
@ -287,7 +287,12 @@ close_database(Port, DbRef, Opts) ->
|
|||
end.
|
||||
|
||||
txn_begin(Port) ->
|
||||
<<Result:32/native>> = erlang:port_control(Port, ?CMD_TXN_BEGIN, <<>>),
|
||||
txn_begin(Port, []).
|
||||
|
||||
txn_begin(Port, Opts) ->
|
||||
Flags = process_flags(Opts),
|
||||
Cmd = <<Flags:32/unsigned-native>>,
|
||||
<<Result:32/native>> = erlang:port_control(Port, ?CMD_TXN_BEGIN, Cmd),
|
||||
case Result of
|
||||
?ERROR_NONE -> ok;
|
||||
?ERROR_ASYNC_PENDING -> {error, async_pending};
|
||||
|
@ -388,5 +393,11 @@ flag_value(Flag) ->
|
|||
rmw -> ?DB_RMW;
|
||||
set_recno -> ?DB_SET_RECNO;
|
||||
threaded -> ?DB_THREAD;
|
||||
truncate -> ?DB_TRUNCATE
|
||||
truncate -> ?DB_TRUNCATE;
|
||||
txn_no_sync -> ?DB_TXN_NOSYNC;
|
||||
txn_no_wait -> ?DB_TXN_NOWAIT;
|
||||
txn_snapshot -> ?DB_TXN_SNAPSHOT;
|
||||
txn_sync -> ?DB_TXN_SYNC;
|
||||
txn_wait -> ?DB_TXN_WAIT;
|
||||
txn_write_nosync -> ?DB_TXN_WRITE_NOSYNC
|
||||
end.
|
||||
|
|
Loading…
Reference in a new issue