|
| DBD * | dbif_init (const char *envhome, const char *dbname) |
| int | dbif_env_open (DBD *dbd, struct db_param *dbp, uint32_t dbenv_oflags) |
| int | dbif_open (DBD *dbd, struct db_param *dbp, int reindex) |
| int | dbif_close (DBD *dbd) |
| int | dbif_env_remove (const char *path) |
| int | dbif_get (DBD *, const int, DBT *, DBT *, uint32_t) |
| int | dbif_pget (DBD *, const int, DBT *, DBT *, DBT *, uint32_t) |
| int | dbif_put (DBD *, const int, DBT *, DBT *, uint32_t) |
| int | dbif_del (DBD *, const int, DBT *, uint32_t) |
| int | dbif_count (DBD *, const int, uint32_t *) |
| int | dbif_search (DBD *dbd, DBT *key, char *resbuf) |
| | Search the database by name.
|
| int | dbif_copy_rootinfokey (DBD *srcdbd, DBD *destdbd) |
| int | dbif_txn_begin (DBD *) |
| int | dbif_txn_commit (DBD *) |
| int | dbif_txn_abort (DBD *) |
| int | dbif_txn_close (DBD *dbd, int ret) |
| | Close a transaction based on ret code.
|
| int | dbif_txn_checkpoint (DBD *, uint32_t, uint32_t, uint32_t) |
| int | dbif_dump (DBD *dbd, int dumpindexes) |
| int | dbif_idwalk (DBD *dbd, cnid_t *cnid, int close) |
| | Iterates over dbd, returning cnids.
|
CNID DBD (Database Daemon) Backend interface definitions.
API usage
Initialization
- Provide storage for a DBD * handle: DBD *dbd;
- Call dbif_init with a filename to receive a DBD handle: dbd = dbif_init("cnid2.db"); Pass NULL to create an in-memory db. Note: the DBD type is NOT from BerkeleyDB ! We've defined it.
- Call dbif_env_open to open an dbd environment if you called dbif_init with a filename. Pass a db_param here for on-disk databases.
- Call dbif_open to finally open the CNID database itself. Pass db_param here for in-memory database.
Querying the CNID database
Call dbif_[get|pget|put|del]. They map to the corresponding BerkeleyDB calls with the same names.
Transactions
We use AUTO_COMMIT for the BDB database accesses. This avoids explicit transactions for every bdb access which speeds up reads. But in order to be able to rollback in case of errors we start a transaction once we encounter the first write from dbif_put or dbif_del. Thus you shouldn't call dbif_txn_[begin|abort|commit], they're used internally.
Checkpoiting
Call dbif_txn_checkpoint.
Closing
Call dbif_close.
Silent Upgrade Support
On cnid_dbd shutdown we reopen the environment with recovery, close and then remove it. This enables an upgraded netatalk installation possibly linked against a newer bdb lib to succesfully open/create an environment and then silently upgrade the database itself. How nice!