FFTransaction

FFTransaction — Class for handling transactions.

Synopsis


#include <ff-transaction.h>


struct      FFTransaction;
struct      FFTransactionClass;

FFTransaction* ff_transaction_new           (void);

FFDatabase* ff_transaction_get_default_database
                                            (FFTransaction *self);
void        ff_transaction_set_default_database
                                            (FFTransaction *self,
                                             FFDatabase *db);
const isc_tr_handle ff_transaction_get_handle
                                            (FFTransaction *self);

gboolean    ff_transaction_in_transaction   (FFTransaction *self);
gboolean    ff_transaction_start            (FFTransaction *self);
gboolean    ff_transaction_commit           (FFTransaction *self);
gboolean    ff_transaction_rollback         (FFTransaction *self);


Description

Firebird is a transactional database, and because of that it uses a transaction for almost any operation. There are a few cases where transactions aren't needed, for example when you insert or delete a record from database using "DELETE FROM ..." or "INSERT INTO ...".

Details

struct FFTransaction

struct FFTransaction {

	gboolean def_action_rollback;		/* Default: TRUE */
};

gboolean def_action_rollbackThis is the default action for transaction close that is TRUE by default.

struct FFTransactionClass

struct FFTransactionClass {

	void (* on_start)	(FFTransaction *self, gpointer data);
	void (* on_commit)	(FFTransaction *self, gpointer data);
	void (* on_rollback)	(FFTransaction *self, gpointer data);
	void (* on_close)	(FFTransaction *self, gpointer data);
	void (* on_error)	(FFTransaction *self, FFError *error, gpointer data);
};

void (*on_start) (FFTransaction *self, gpointer data)Triggers after the transaction is started.
void (*on_commit) (FFTransaction *self, gpointer data)Triggers after the transaction is commited.
void (*on_rollback) (FFTransaction *self, gpointer data)Triggers after transaction rollback.
void (*on_close) (FFTransaction *self, gpointer data)
void (*on_error) (FFTransaction *self, FFError *error, gpointer data)Triggers after an error is raised.

ff_transaction_new ()

FFTransaction* ff_transaction_new           (void);

Constructor for FFTransaction class.

Returns : A new FFTransaction object.

ff_transaction_get_default_database ()

FFDatabase* ff_transaction_get_default_database
                                            (FFTransaction *self);

Get self transaction default database.

self : A FFTransaction.
Returns : Transaction's default FFDatabase object.

ff_transaction_set_default_database ()

void        ff_transaction_set_default_database
                                            (FFTransaction *self,
                                             FFDatabase *db);

Set self transaction default database.

self : A FFTransaction.
db : A FFDatabase.

ff_transaction_get_handle ()

const isc_tr_handle ff_transaction_get_handle
                                            (FFTransaction *self);

Get transaction handle.

self : A FFTransaction.
Returns : A transaction handle or NULL if transaction is not active.

ff_transaction_in_transaction ()

gboolean    ff_transaction_in_transaction   (FFTransaction *self);

See if transaction is in transaction.

self : A FFTransaction.
Returns : TRUE if transaction is active, or FALSE otherwise.

ff_transaction_start ()

gboolean    ff_transaction_start            (FFTransaction *self);

Start transaction if is not olready opened.

self : A FFTransaction.
Returns : TRUE if transaction was successfully opened, or FALSE otherwise.

ff_transaction_commit ()

gboolean    ff_transaction_commit           (FFTransaction *self);

Commit current transaction.

self : A FFTransaction.
Returns : TRUE if transaction was successfully commited, or FALSE otherwise.

ff_transaction_rollback ()

gboolean    ff_transaction_rollback         (FFTransaction *self);

Rollback current transaction.

self : A FFTransaction.
Returns : TRUE if operation was successfully completed, or FALSE otherwise.