|
ITTIA DB SQL C API
5.4.0
|
Defines | |
| #define | DB_SAVEPOINT_DEFAULT _DB_SAVEPOINT_DEFAULT |
| #define | DB_SAVEPOINT_UNIQUE _DB_SAVEPOINT_UNIQUE |
| #define | DB_SAVEPOINT_NESTED _DB_SAVEPOINT_NESTED |
| #define | DB_SAVEPOINT_OVERRIDE _DB_SAVEPOINT_OVERRIDE |
Typedefs | |
| typedef struct db_savepoint_t_s * | db_savepoint_t |
Functions | |
| db_result_t | db_begin_tx (db_t, db_flags_t) |
| db_result_t | db_commit_tx (db_t, db_flags_t) |
| db_result_t | db_abort_tx (db_t, db_flags_t) |
| db_result_t | db_flush_tx (db_t, db_flags_t) |
| int | db_is_active_tx (db_t) |
| db_result_t | db_set_tx_default (db_t, db_flags_t) |
| db_flags_t | db_get_tx_default (db_t) |
| db_savepoint_t | db_set_savepoint (db_t, const db_objname_t *, db_flags_t flags) |
| db_savepoint_t | db_find_savepoint (db_t, const db_objname_t *) |
| db_result_t | db_release_savepoint (db_t, db_savepoint_t) |
| db_result_t | db_rollback_savepoint (db_t, db_savepoint_t) |
Transaction Isolation Levels | |
| #define | DB_DEFAULT_ISOLATION _DB_DEFAULT_ISOLATION |
| #define | DB_READ_COMMITTED _DB_READ_COMMITTED |
| #define | DB_REPEATABLE_READ _DB_REPEATABLE_READ |
| #define | DB_SERIALIZABLE _DB_SERIALIZABLE |
| #define | DB_ISOLATION_MASK _DB_ISOLATION_MASK |
Transaction Completion Modes | |
| #define | DB_DEFAULT_COMPLETION _DB_DEFAULT_COMPLETION |
| #define | DB_LAZY_COMPLETION _DB_LAZY_COMPLETION |
| #define | DB_FORCED_COMPLETION _DB_FORCED_COMPLETION |
| #define | DB_GROUP_COMPLETION _DB_GROUP_COMPLETION |
| #define | DB_COMPLETION_MASK _DB_COMPLETION_MASK |
Flush Mode | |
| #define | DB_FLUSH_JOURNAL _DB_FLUSH_JOURNAL |
| #define | DB_FLUSH_STORAGE _DB_FLUSH_STORAGE |
| #define | DB_FLUSH_MASK _DB_FLUSH_MASK |
All data access operations must occur inside a transaction.
A transaction is a logical group of operations that must all succeed or fail together. Changes made to the database do not become permanent until the transaction is committed. A transaction can also be aborted, which will undo any changes made since the transaction was started.
Transactions can be further divided into savepoints, allowing a transaction to be rolled back to the beginning of each savepoint. A savepoint should be used when a nested function is called during a transaction. The nested function can roll back its work if an error occurs, without affecting the enclosing scope.
| #define DB_SAVEPOINT_DEFAULT _DB_SAVEPOINT_DEFAULT |
Set savepoint with default behavior.
| #define DB_SAVEPOINT_UNIQUE _DB_SAVEPOINT_UNIQUE |
Set savepoint only if no existing savepoint has the same name.
| #define DB_SAVEPOINT_NESTED _DB_SAVEPOINT_NESTED |
Nest savepoints with the same name.
| #define DB_SAVEPOINT_OVERRIDE _DB_SAVEPOINT_OVERRIDE |
Replace savepoints with the same name.
| #define DB_DEFAULT_ISOLATION _DB_DEFAULT_ISOLATION |
Default isolation mode.
| #define DB_DEFAULT_COMPLETION _DB_DEFAULT_COMPLETION |
Default completion mode.
| #define DB_FLUSH_JOURNAL _DB_FLUSH_JOURNAL |
Flush only the journal.
| #define DB_READ_COMMITTED _DB_READ_COMMITTED |
Read committed isolation.
| #define DB_REPEATABLE_READ _DB_REPEATABLE_READ |
Repeatable read isolation.
| #define DB_SERIALIZABLE _DB_SERIALIZABLE |
Serializable isolation.
| #define DB_LAZY_COMPLETION _DB_LAZY_COMPLETION |
Lazy completion.
| #define DB_FORCED_COMPLETION _DB_FORCED_COMPLETION |
Immediate completion.
| #define DB_GROUP_COMPLETION _DB_GROUP_COMPLETION |
Group completion.
| #define DB_FLUSH_STORAGE _DB_FLUSH_STORAGE |
Flush both the journal and storage.
| typedef struct db_savepoint_t_s* db_savepoint_t |
Savepoint handle.
| db_result_t db_begin_tx | ( | db_t | hdb, |
| db_flags_t | flags | ||
| ) |
Begin a transaction.
| hdb | Database handle |
| flags |
|
On failure, one of the following error codes is set:
starting a new transaction. To continue using the previous transaction, ignore this error.
| db_result_t db_commit_tx | ( | db_t | hdb, |
| db_flags_t | flags | ||
| ) |
Commit a database's active transaction.
| hdb | Database handle. |
| flags |
|
On failure, one of the following error codes is set:
| db_result_t db_abort_tx | ( | db_t | hdb, |
| db_flags_t | flags | ||
| ) |
Abort a database's active transaction.
| hdb | Database handle. |
| flags |
|
On failure, one of the following error codes is set:
| db_result_t db_flush_tx | ( | db_t | hdb, |
| db_flags_t | flags | ||
| ) |
Flush completed transactions to disk.
| hdb | Database handle. |
| flags |
|
On failure, one of the following error codes is set:
Call db_flush_tx with the DB_FLUSH_JOURNAL flag to flush transactions that were committed with the DB_LAZY_COMPLETION flag. You do not need to call db_flush_tx if transactions are committed with the
necessary, transactions that have not been flushed may be aborted.
Call db_flush_tx with the DB_FLUSH_STORAGE flag to flush improve performance of automatic recovery and db_shutdown by flushing all dirty buffers to disk.
| int db_is_active_tx | ( | db_t | hdb | ) |
Determine whether a transaction is active.
| hdb | Database handle. |
| db_result_t db_set_tx_default | ( | db_t | hdb, |
| db_flags_t | flags | ||
| ) |
Set default transaction mode.
| hdb | Database handle. |
| flags |
|
On failure, one of the following error codes is set:
This function can set the default mode for isolation, completion, or both. If a flag is not provided for either mode, the default for that mode will remain unchanged.
| db_flags_t db_get_tx_default | ( | db_t | hdb | ) |
Get default transaction mode.
| hdb | Database handle. |
On failure, one of the following error codes is set:
| db_savepoint_t db_set_savepoint | ( | db_t | hdb, |
| const db_objname_t * | name, | ||
| db_flags_t | flags | ||
| ) |
Create a save point and return a handle to identify it.
| hdb | Database handle. |
| name | Name to assign the savepoint. |
| flags | Select behavior when name clashes with an existing savepoint:
|
A transaction is started if not already active. Savepoints are automatically released when the transaction is committed or rolled back.
| db_savepoint_t db_find_savepoint | ( | db_t | hdb, |
| const db_objname_t * | name | ||
| ) |
Identify the most recent savepoint with a given name.
| hdb | Database handle. |
| name | Name of savepoint to find, or NULL to find the most recently created savepoint. |
| db_result_t db_release_savepoint | ( | db_t | hdb, |
| db_savepoint_t | sp | ||
| ) |
Release a savepoint.
| hdb | Database handle. |
| sp | Savepoint handle, or NULL to release the most recent savepoint. |
When a savepoint is released, it can no longer be used to roll back to beginning of the savepoint. However, this does not garauntee that any work will be saved. If the enclosing transaction or an enclosing savepoint is rolled back, work performed in this savepoint will be lost.
Any savepoints that were subsequently set are automatically released.
Locks obtained during the savepoint are not released until the end of the enclosing transaction.
| db_result_t db_rollback_savepoint | ( | db_t | hdb, |
| db_savepoint_t | sp | ||
| ) |
Roll back a savepoint.
| hdb | Database handle. |
| sp | Savepoint handle, or NULL to roll back the most recent savepoint. |
When a savepoint is rolled back, the database is returned to the state it was in when the savepoint was set. Any savepoints that were subsequently set are automatically rolled back as well.
Locks obtained during the savepoint are not released until the end of the enclosing transaction.