hamsterdb Embedded Database  2.1.7
Macros | Typedefs | Functions
hamsterdb Transaction Functions

Macros

#define HAM_TXN_READ_ONLY   1
 
#define HAM_TXN_TEMPORARY   2
 

Typedefs

typedef struct ham_txn_t ham_txn_t
 

Functions

HAM_EXPORT ham_status_t ham_txn_begin (ham_txn_t **txn, ham_env_t *env, const char *name, void *reserved, ham_u32_t flags)
 
HAM_EXPORT const char * ham_txn_get_name (ham_txn_t *txn)
 
HAM_EXPORT ham_status_t ham_txn_commit (ham_txn_t *txn, ham_u32_t flags)
 
HAM_EXPORT ham_status_t ham_txn_abort (ham_txn_t *txn, ham_u32_t flags)
 

Detailed Description

Macro Definition Documentation

#define HAM_TXN_READ_ONLY   1

Flag for ham_txn_begin

Definition at line 1058 of file hamsterdb.h.

#define HAM_TXN_TEMPORARY   2

Definition at line 1061 of file hamsterdb.h.

Typedef Documentation

typedef struct ham_txn_t ham_txn_t

Definition at line 1023 of file hamsterdb.h.

Function Documentation

HAM_EXPORT ham_status_t ham_txn_abort ( ham_txn_t txn,
ham_u32_t  flags 
)

Aborts a Transaction

This function aborts (= cancels) the sequence of Database operations.

Note that the function will fail with HAM_CURSOR_STILL_OPEN if a Cursor was attached to this Transaction (with ham_cursor_create or ham_cursor_clone), and the Cursor was not closed.

Parameters
txnPointer to a Transaction structure
flagsOptional flags for aborting the Transaction, combined with bitwise OR. Unused, set to 0.
Returns
HAM_SUCCESS upon success
HAM_IO_ERROR if writing to the Database file or logfile failed
HAM_CURSOR_STILL_OPEN if there are Cursors attached to this Transaction

Referenced by hamsterdb::txn::abort().

HAM_EXPORT ham_status_t ham_txn_begin ( ham_txn_t **  txn,
ham_env_t env,
const char *  name,
void *  reserved,
ham_u32_t  flags 
)

Begins a new Transaction

A Transaction is an atomic sequence of Database operations. With ham_txn_begin such a new sequence is started. To write all operations of this sequence to the Database use ham_txn_commit. To abort and cancel this sequence use ham_txn_abort.

In order to use Transactions, the Environment has to be created or opened with the flag HAM_ENABLE_TRANSACTIONS.

You can create as many Transactions as you want (older versions of hamsterdb did not allow to create more than one Transaction in parallel).

Parameters
txnPointer to a pointer of a Transaction structure
envA valid Environment handle
nameAn optional Transaction name
reservedA reserved pointer; always set to NULL
flagsOptional flags for beginning the Transaction, combined with bitwise OR. Possible flags are:
Returns
HAM_SUCCESS upon success
HAM_OUT_OF_MEMORY if memory allocation failed

Referenced by hamsterdb::env::begin().

HAM_EXPORT ham_status_t ham_txn_commit ( ham_txn_t txn,
ham_u32_t  flags 
)

Commits a Transaction

This function applies the sequence of Database operations.

Note that the function will fail with HAM_CURSOR_STILL_OPEN if a Cursor was attached to this Transaction (with ham_cursor_create or ham_cursor_clone), and the Cursor was not closed.

Parameters
txnPointer to a Transaction structure
flagsOptional flags for committing the Transaction, combined with bitwise OR. Unused, set to 0.
Returns
HAM_SUCCESS upon success
HAM_IO_ERROR if writing to the file failed
HAM_CURSOR_STILL_OPEN if there are Cursors attached to this Transaction

Referenced by hamsterdb::txn::commit().

HAM_EXPORT const char* ham_txn_get_name ( ham_txn_t txn)

Retrieves the Transaction name

Returns
NULL if the name was not assigned or if txn is invalid

Referenced by hamsterdb::txn::get_name().