#include <stdio.h>#include <string.h>#include <time.h>#include <sys/types.h>#include <dirent.h>#include "../../ut.h"#include "../../mem/mem.h"#include "../../dprint.h"#include "bdb_util.h"#include "bdb_lib.h"#include "bdb_val.h"

Go to the source code of this file.
Functions | |
| int | bdblib_close (char *_n) |
| int | bdblib_create_dbenv (DB_ENV **_dbenv, char *_home) |
| int | bdblib_create_journal (table_p _tp) |
| table_p | bdblib_create_table (database_p _db, str *_s) |
| int | bdblib_destroy (void) |
| database_p | bdblib_get_db (str *_s) |
| tbl_cache_p | bdblib_get_table (database_p _db, str *_s) |
| int | bdblib_init (db_parms_p _p) |
| void | bdblib_log (int op, table_p _tp, char *_msg, int len) |
| int | bdblib_recover (table_p _tp, int _rc) |
| int | bdblib_reopen (char *_n) |
| int | bdblib_valtochar (table_p _tp, int *_lres, char *_k, int *_klen, db_val_t *_v, int _n, int _ko) |
| int | db_free (database_p _dbp) |
| int | load_metadata_columns (table_p _tp) |
| int | load_metadata_defaults (table_p _tp) |
| int | load_metadata_keys (table_p _tp) |
| int | load_metadata_logflags (table_p _tp) |
| int | load_metadata_readonly (table_p _tp) |
| int | tbl_cache_free (tbl_cache_p _tbc) |
| int | tbl_free (table_p _tp) |
Variables | |
| static database_p * | _cachedb = NULL |
| static db_parms_p | _db_parms = NULL |
| int bdblib_close | ( | char * | _n | ) |
closes the underlying Berkeley DB. assumes the lib data-structures are already initialzed; used to sync and reload the db file.
Definition at line 104 of file bdb_lib.c.
References _table::db, _database::dbenv, _tbl_cache::dtp, _str::len, LM_CRIT, LM_DBG, _table::name, _database::name, _tbl_cache::next, NULL, _str::s, s, _table::sem, and _database::tables.
Referenced by bdb_reload().
| int bdblib_create_dbenv | ( | DB_ENV ** | _dbenv, | |
| char * | _home | |||
| ) |
Definition at line 298 of file bdb_lib.c.
References _db_parms::cache_size, and LM_ERR.
Referenced by bdblib_get_db(), and bdblib_reopen().
| int bdblib_create_journal | ( | table_p | _tp | ) |
Definition at line 716 of file bdb_lib.c.
References _table::fp, _str::len, LM_ERR, _db_parms::log_enable, _table::name, _database::name, NULL, _str::s, s, and _table::t.
Referenced by bdblib_create_table(), and bdblib_log().
| table_p bdblib_create_table | ( | database_p | _db, | |
| str * | _s | |||
| ) |
The function is called to create a handle to a db table.
On startup, we do not create any of the db handles. Instead it is done on first-use (lazy-initialized) to only create handles to files (db) that we require.
There is one db file per openser table (eg. acc), and they should exist in your DB_PATH (refer to kamctlrc) directory.
This function does _not_ create the underlying binary db tables. Creating the tables MUST be manually performed before openser startup by 'kamdbctl create'
Function returns NULL on error, which will cause openser to exit.
Definition at line 562 of file bdb_lib.c.
References bdblib_create_journal(), _table::colp, _table::db, _database::dbenv, _table::fp, _table::ino, JLOG_FILE, _str::len, LM_DBG, LM_ERR, LM_INFO, load_metadata_columns(), load_metadata_defaults(), load_metadata_keys(), load_metadata_logflags(), load_metadata_readonly(), _table::logflags, MAX_NUM_COLS, MAX_TABLENAME_SIZE, _table::name, _table::ncols, _table::nkeys, NULL, pkg_free, pkg_malloc, _table::ro, _str::s, _table::sem, and _table::t.
Referenced by bdblib_get_table().
| int bdblib_destroy | ( | void | ) |
| database_p bdblib_get_db | ( | str * | _s | ) |
Definition at line 358 of file bdb_lib.c.
References bdb_is_database(), bdblib_create_dbenv(), _database::dbenv, _str::len, LM_DBG, LM_ERR, _database::name, NULL, pkg_free, pkg_malloc, _str::s, and _database::tables.
Referenced by bdb_init().
| tbl_cache_p bdblib_get_table | ( | database_p | _db, | |
| str * | _s | |||
| ) |
look thru a linked list for the table. if dne, create a new one and add to the list
Definition at line 421 of file bdb_lib.c.
References bdblib_create_table(), _database::dbenv, _tbl_cache::dtp, _str::len, LM_DBG, LM_ERR, _table::name, _tbl_cache::next, NULL, pkg_free, pkg_malloc, _str::s, _tbl_cache::sem, and _database::tables.
Referenced by _bdb_delete_cursor(), bdb_check_reload(), bdb_delete(), bdb_insert(), bdb_query(), and bdb_update().
| int bdblib_init | ( | db_parms_p | _p | ) |
Definition at line 49 of file bdb_lib.c.
References _db_parms::auto_reload, _db_parms::cache_size, _db_parms::journal_roll_interval, LM_CRIT, _db_parms::log_enable, NULL, and pkg_malloc.
Referenced by mod_init().
| void bdblib_log | ( | int | op, | |
| table_p | _tp, | |||
| char * | _msg, | |||
| int | len | |||
| ) |
Definition at line 486 of file bdb_lib.c.
References bdblib_create_journal(), buf, _table::fp, JLOG_DELETE, JLOG_INSERT, JLOG_NONE, JLOG_STDOUT, JLOG_SYSLOG, JLOG_UPDATE, _db_parms::journal_roll_interval, LM_ERR, _db_parms::log_enable, _table::logflags, MAX_ROW_SIZE, NULL, and _table::t.
Referenced by bdb_delete(), bdb_insert(), and bdb_update().
| int bdblib_recover | ( | table_p | _tp, | |
| int | _rc | |||
| ) |
Definition at line 1309 of file bdb_lib.c.
References bdblib_destroy(), and LM_ERR.
Referenced by _bdb_delete_cursor(), bdb_delete(), bdb_insert(), bdb_query(), bdb_update(), and bdblib_reopen().
| int bdblib_reopen | ( | char * | _n | ) |
opens the underlying Berkeley DB. assumes the lib data-structures are already initialzed; used to sync and reload the db file.
Definition at line 188 of file bdb_lib.c.
References bdblib_create_dbenv(), bdblib_recover(), _table::db, _database::dbenv, _tbl_cache::dtp, _str::len, LM_CRIT, LM_DBG, _table::name, _database::name, _tbl_cache::next, NULL, _str::s, s, _table::sem, and _database::tables.
Referenced by bdb_reload().
| int bdblib_valtochar | ( | table_p | _tp, | |
| int * | _lres, | |||
| char * | _k, | |||
| int * | _klen, | |||
| db_val_t * | _v, | |||
| int | _n, | |||
| int | _ko | |||
| ) |
Definition at line 1047 of file bdb_lib.c.
References bdb_val2str(), _table::colp, DELIM, DELIM_LEN, _column::dv, _column::flag, _str::len, len, LM_DBG, LM_ERR, MAX_ROW_SIZE, _column::name, _table::name, _table::ncols, _str::s, and ZSW.
Referenced by bdb_delete(), bdb_insert(), bdb_query(), and bdb_update().
| int db_free | ( | database_p | _dbp | ) |
Definition at line 1233 of file bdb_lib.c.
References _database::dbenv, _database::name, _tbl_cache::next, NULL, pkg_free, _str::s, _database::tables, and tbl_cache_free().
Referenced by bdblib_destroy().
| int load_metadata_columns | ( | table_p | _tp | ) |
Definition at line 770 of file bdb_lib.c.
References _table::colp, _table::db, DB_DATETIME, DB_DOUBLE, DB_INT, DB_STRING, _column::flag, _str::len, len, LM_ERR, MAX_NUM_COLS, MAX_ROW_SIZE, METADATA_COLUMNS, _column::name, _table::ncols, NULL, pkg_malloc, _str::s, s, and _column::type.
Referenced by bdblib_create_table().
| int load_metadata_defaults | ( | table_p | _tp | ) |
Definition at line 966 of file bdb_lib.c.
References _table::colp, _table::db, DELIM, _column::dv, _str::len, len, LM_DBG, MAX_ROW_SIZE, METADATA_DEFAULTS, _column::name, _table::ncols, NULL, pkg_malloc, _str::s, s, and ZSW.
Referenced by bdblib_create_table().
| int load_metadata_keys | ( | table_p | _tp | ) |
Definition at line 857 of file bdb_lib.c.
References _table::colp, _table::db, _column::flag, LM_ERR, MAX_ROW_SIZE, METADATA_KEY, _table::nkeys, NULL, and s.
Referenced by bdblib_create_table().
| int load_metadata_logflags | ( | table_p | _tp | ) |
Definition at line 934 of file bdb_lib.c.
References _table::db, _table::logflags, MAX_ROW_SIZE, METADATA_LOGFLAGS, and NULL.
Referenced by bdblib_create_table().
| int load_metadata_readonly | ( | table_p | _tp | ) |
Definition at line 902 of file bdb_lib.c.
References _table::db, MAX_ROW_SIZE, METADATA_READONLY, NULL, and _table::ro.
Referenced by bdblib_create_table().
| int tbl_cache_free | ( | tbl_cache_p | _tbc | ) |
Definition at line 1263 of file bdb_lib.c.
References _tbl_cache::dtp, pkg_free, _tbl_cache::sem, and tbl_free().
Referenced by db_free().
| int tbl_free | ( | table_p | _tp | ) |
close DB (sync data to disk) and free mem
Definition at line 1283 of file bdb_lib.c.
References _table::colp, _table::db, _column::dv, _table::fp, _column::name, _table::name, _table::ncols, pkg_free, and _str::s.
Referenced by tbl_cache_free().
database_p* _cachedb = NULL [static] |
db_parms_p _db_parms = NULL [static] |
1.5.6