Main Page Modules Data Structures File List Data Fields Globals Related Pages

# DataBase Index element API.

## Files
file | rpmdb.c
file | rpmdb.h
| Access RPM indices using Berkeley DB interface(s).

file | rpmlib.h
## Data Structures
struct | _dbiIndex
struct | _dbiIndexItem
struct | _dbiIndexSet
struct | _dbiVec
struct | dbiBStats_s
struct | dbiHStats_s
## Functions
dbiIndex | dbiOpen (rpmdb db, rpmTag rpmtag, unsigned int flags)
int | dbiCopen (dbiIndex dbi, DB_TXN *txnid, DBC **dbcp, unsigned int flags)
int | dbiCclose (dbiIndex dbi, DBC *dbcursor, unsigned int flags)
int | dbiCdup (dbiIndex dbi, DBC *dbcursor, DBC **dbcp, unsigned int flags)
int | dbiDel (dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, unsigned int flags)
int | dbiGet (dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, unsigned int flags)
int | dbiPget (dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *pkey, DBT *data, unsigned int flags)
int | dbiPut (dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, unsigned int flags)
int | dbiCount (dbiIndex dbi, DBC *dbcursor, unsigned int *countp, unsigned int flags)
int | dbiVerify (dbiIndex dbi, unsigned int flags)
int | dbiClose (dbiIndex dbi, unsigned int flags)
int | dbiSync (dbiIndex dbi, unsigned int flags)
int | dbiAssociate (dbiIndex dbi, dbiIndex dbisecondary, int(*callback)(DB *, const DBT *, const DBT *, DBT *), unsigned int flags)
int | dbiJoin (dbiIndex dbi, DBC **curslist, DBC **dbcp, unsigned int flags)
int | dbiByteSwapped (dbiIndex dbi)
int | dbiStat (dbiIndex dbi, unsigned int flags)
dbiIndexSet | dbiFreeIndexSet (dbiIndexSet set)
unsigned int | dbiIndexSetCount (dbiIndexSet set)
unsigned int | dbiIndexRecordOffset (dbiIndexSet set, int recno)
unsigned int | dbiIndexRecordFileNumber (dbiIndexSet set, int recno)
## Variables
int(* | open )(rpmdb rpmdb, rpmTag rpmtag, dbiIndex *dbip)
int(* | close )(dbiIndex dbi, unsigned int flags)
int(* | sync )(dbiIndex dbi, unsigned int flags)
int(* | associate )(dbiIndex dbi, dbiIndex dbisecondary, int(*callback)(DB *, const DBT *, const DBT *, DBT *), unsigned int flags)
int(* | join )(dbiIndex dbi, DBC **curslist, DBC **dbcp, unsigned int flags)
int(* | copen )(dbiIndex dbi, DB_TXN *txnid, DBC **dbcp, unsigned int dbiflags)
int(* | cclose )(dbiIndex dbi, DBC *dbcursor, unsigned int flags)
int(* | cdup )(dbiIndex dbi, DBC *dbcursor, DBC **dbcp, unsigned int flags)
int(* | cdel )(dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, unsigned int flags)
int(* | cget )(dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, unsigned int flags)
int(* | cpget )(dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *pkey, DBT *data, unsigned int flags)
int(* | cput )(dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, unsigned int flags)
int(* | ccount )(dbiIndex dbi, DBC *dbcursor, unsigned int *countp, unsigned int flags)
int(* | byteswapped )(dbiIndex dbi)
int(* | stat )(dbiIndex dbi, unsigned int flags)

## Function Documentation

int dbiAssociate | ( | dbiIndex | dbi,
|  | dbiIndex | dbisecondary,
|  | int(* | callback)(DB *, const DBT *, const DBT *, DBT *),
|  | unsigned int | flags
| ) | `[inline, static]`

  | Associate secondary database with primary. Parameters:
  dbi | index database handle
  dbisecondary | secondary index database handle
  callback | create secondary key from primary (NULL if DB_RDONLY)
  flags | DB_CREATE or 0
Returns: 0 on success Definition at line 692 of file rpmdb.h.

int dbiByteSwapped | ( | dbiIndex | dbi | ) | `[inline, static]`

  | Is database byte swapped? Parameters:
  dbi | index database handle
Returns: 0 same order, 1 swapped order Definition at line 724 of file rpmdb.h. References _dbiVec::byteswapped, _dbiIndex::dbi_byteswapped, and _dbiIndex::dbi_vec. Referenced by dbt2set, and set2dbt.

int dbiCclose | ( | dbiIndex | dbi,
|  | DBC * | dbcursor,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Close a database cursor. Parameters:
  dbi | index database handle
  dbcursor | database cursor
  flags | (unused)
Returns: 0 on success Definition at line 523 of file rpmdb.h. Referenced by rpmdbAdd, rpmdbCountPackages, rpmdbFindByFile, rpmdbFreeIterator, rpmdbGrowIterator, rpmdbInitIterator, rpmdbRemove, and unsatisfiedDepend.

int dbiCdup | ( | dbiIndex | dbi,
|  | DBC * | dbcursor,
|  | DBC ** | dbcp,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Duplicate a database cursor. Parameters:
  dbi | index database handle
  dbcursor | database cursor
  Return values:
  dbcp | address of new database cursor
  Parameters:
  flags | DB_POSITION for same position, 0 for uninitialized
Returns: 0 on success Definition at line 539 of file rpmdb.h.

int dbiClose | ( | dbiIndex | dbi,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Close index database. Parameters:
  dbi | index database handle
  flags | (unused)
Returns: 0 on success Definition at line 662 of file rpmdb.h. Referenced by rpmdbClose, and rpmdbCloseDBI.

int dbiCopen | ( | dbiIndex | dbi,
|  | DB_TXN * | txnid,
|  | DBC ** | dbcp,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Open a database cursor. Parameters:
  dbi | index database handle
  txnid | database transaction handle
  Return values:
  dbcp | returned database cursor
  Parameters:
  flags | DB_WRITECURSOR if writing, or 0
Returns: 0 on success Definition at line 507 of file rpmdb.h. Referenced by rpmdbAdd, rpmdbCountPackages, rpmdbFindByFile, rpmdbGrowIterator, rpmdbInitIterator, rpmdbNextIterator, rpmdbRemove, and unsatisfiedDepend.

int dbiCount | ( | dbiIndex | dbi,
|  | DBC * | dbcursor,
|  | unsigned int * | countp,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Retrieve count of (possible) duplicate items. Parameters:
  dbi | index database handle
  dbcursor | database cursor
  countp | address of count
  flags | (unused)
Returns: 0 on success Definition at line 632 of file rpmdb.h.

int dbiDel | ( | dbiIndex | dbi,
|  | DBC * | dbcursor,
|  | DBT * | key,
|  | DBT * | data,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Delete (key,data) pair(s) from index database. Parameters:
  dbi | index database handle
  dbcursor | database cursor (NULL will use db->del)
  key | delete key value/length/flags
  data | delete data value/length/flags
  flags | (unused)
Returns: 0 on success Definition at line 556 of file rpmdb.h. Referenced by rpmdbRemove.

dbiIndexSet dbiFreeIndexSet | ( | dbiIndexSet | set | ) |

  | Destroy set of index database items. Parameters:
  set | set of index database items
Returns: NULL always Definition at line 611 of file rpmdb.c. Referenced by dbiFindByLabel, dbiFindMatches, rpmdbAdd, rpmdbCountPackages, rpmdbFindByFile, rpmdbFreeIterator, rpmdbGrowIterator, rpmdbInitIterator, and rpmdbRemove.

int dbiGet | ( | dbiIndex | dbi,
|  | DBC * | dbcursor,
|  | DBT * | key,
|  | DBT * | data,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Retrieve (key,data) pair from index database. Parameters:
  dbi | index database handle
  dbcursor | database cursor (NULL will use db->get)
  key | retrieve key value/length/flags
  data | retrieve data value/length/flags
  flags | (unused)
Returns: 0 on success Definition at line 575 of file rpmdb.h. Referenced by dbiFindMatches, rpmdbAdd, rpmdbCountPackages, rpmdbFindByFile, rpmdbGrowIterator, rpmdbInitIterator, rpmdbNextIterator, rpmdbRemove, and unsatisfiedDepend.

unsigned int dbiIndexRecordFileNumber | ( | dbiIndexSet | set,
|  | int | recno
| ) |

  | Return file index from element in index database set. Parameters:
  set | set of index database items
  recno | index of item in set
Returns: file index Definition at line 606 of file rpmdb.c. Referenced by rpmdbFindByFile, and rpmdbNextIterator.

unsigned int dbiIndexRecordOffset | ( | dbiIndexSet | set,
|  | int | recno
| ) |

  | Return record offset of header from element in index database set. Parameters:
  set | set of index database items
  recno | index of item in set
Returns: record offset of header Definition at line 601 of file rpmdb.c. Referenced by dbiFindMatches, rpmdbFindByFile, and rpmdbNextIterator.

unsigned int dbiIndexSetCount | ( | dbiIndexSet | set | ) |

  | Count items in index database set. Parameters:
  set | set of index database items
Returns: number of items Definition at line 596 of file rpmdb.c. Referenced by dbiFindMatches, and rpmdbCountPackages.

int dbiJoin | ( | dbiIndex | dbi,
|  | DBC ** | curslist,
|  | DBC ** | dbcp,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Return join cursor for list of cursors. Parameters:
  dbi | index database handle
  curslist | NULL terminated list of database cursors
  Return values:
  dbcp | address of join database cursor
  Parameters:
  flags | DB_JOIN_NOSORT or 0
Returns: 0 on success Definition at line 710 of file rpmdb.h. References _dbiIndex::dbi_vec, and _dbiVec::join.

dbiIndex dbiOpen | ( | rpmdb | db,
|  | rpmTag | rpmtag,
|  | unsigned int | flags
| ) |

  | Return handle for an index database. Parameters:
  db | rpm database
  rpmtag | rpm tag
  flags | (unused)
Returns: index database handle Definition at line 244 of file rpmdb.c. References _dbiVec::byteswapped, and _dbiVec::stat. Referenced by openDatabase, rpmdbAdd, rpmdbCountPackages, rpmdbFindByFile, rpmdbFreeIterator, rpmdbGrowIterator, rpmdbInitIterator, rpmdbNextIterator, rpmdbOpenAll, rpmdbRemove, and unsatisfiedDepend.

int dbiPget | ( | dbiIndex | dbi,
|  | DBC * | dbcursor,
|  | DBT * | key,
|  | DBT * | pkey,
|  | DBT * | data,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Retrieve (key,data) pair using dbcursor->c_pget. Parameters:
  dbi | index database handle
  dbcursor | database cursor (NULL will use db->get)
  key | secondary retrieve key value/length/flags
  pkey | primary retrieve key value/length/flags
  data | primary retrieve data value/length/flags
  flags | DB_NEXT, DB_SET, or 0
Returns: 0 on success Definition at line 595 of file rpmdb.h.

int dbiPut | ( | dbiIndex | dbi,
|  | DBC * | dbcursor,
|  | DBT * | key,
|  | DBT * | data,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Store (key,data) pair in index database. Parameters:
  dbi | index database handle
  dbcursor | database cursor (NULL will use db->put)
  key | store key value/length/flags
  data | store data value/length/flags
  flags | (unused)
Returns: 0 on success Definition at line 614 of file rpmdb.h. Referenced by miFreeHeader, rpmdbAdd, rpmdbRemove, and unsatisfiedDepend.

int dbiStat | ( | dbiIndex | dbi,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Is database byte swapped? Parameters:
  dbi | index database handle
  flags | DB_FAST_STAT or 0
Returns: 0 on success Definition at line 738 of file rpmdb.h. References _dbiIndex::dbi_vec, and _dbiVec::stat. Referenced by dbiOpen.

int dbiSync | ( | dbiIndex | dbi,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Flush pending operations to disk. Parameters:
  dbi | index database handle
  flags | (unused)
Returns: 0 on success Definition at line 676 of file rpmdb.h. Referenced by miFreeHeader, rpmdbAdd, rpmdbRemove, and rpmdbSync.

int dbiVerify | ( | dbiIndex | dbi,
|  | unsigned int | flags
| ) | `[inline, static]`

  | Verify (and close) index database. Parameters:
  dbi | index database handle
  flags | (unused)
Returns: 0 on success Definition at line 647 of file rpmdb.h. Referenced by rpmdbVerify.

## Variable Documentation

int(* _dbiVec::associate)(dbiIndex dbi, dbiIndex dbisecondary, int (*callback) (DB *, const DBT *, const DBT *, DBT *), unsigned int flags)`[inherited]`

  | Associate secondary database with primary. Parameters:
  dbi | index database handle
  dbisecondary | secondary index database handle
  callback | create secondary key from primary (NULL if DB_RDONLY)
  flags | DB_CREATE or 0
Returns: 0 on success Referenced by rpmdbCheckSignals.

int(* _dbiVec::byteswapped)(dbiIndex dbi)`[inherited]`

  | Is database byte swapped? Parameters:
  dbi | index database handle
Returns: 0 no Referenced by dbiByteSwapped, and dbiOpen.

int(* _dbiVec::cclose)(dbiIndex dbi, DBC * dbcursor, unsigned int flags)`[inherited]`

  | Close database cursor. Parameters:
  dbi | index database handle
  dbcursor | database cursor
  flags | (unused)
Returns: 0 on success

int(* _dbiVec::ccount)(dbiIndex dbi, DBC * dbcursor, unsigned int * countp, unsigned int flags)`[inherited]`

  | Retrieve count of (possible) duplicate items using dbcursor->c_count. Parameters:
  dbi | index database handle
  dbcursor | database cursor
  countp | address of count
  flags | (unused)
Returns: 0 on success

int(* _dbiVec::cdel)(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, unsigned int flags)`[inherited]`

  | Delete (key,data) pair(s) using db->del or dbcursor->c_del. Parameters:
  dbi | index database handle
  dbcursor | database cursor (NULL will use db->del)
  key | delete key value/length/flags
  data | delete data value/length/flags
  flags | (unused)
Returns: 0 on success

int(* _dbiVec::cdup)(dbiIndex dbi, DBC * dbcursor, DBC ** dbcp, unsigned int flags)`[inherited]`

  | Duplicate a database cursor. Parameters:
  dbi | index database handle
  dbcursor | database cursor
  Return values:
  dbcp | address of new database cursor
  Parameters:
  flags | DB_POSITION for same position, 0 for uninitialized
Returns: 0 on success

int(* _dbiVec::cget)(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, unsigned int flags)`[inherited]`

  | Retrieve (key,data) pair using db->get or dbcursor->c_get. Parameters:
  dbi | index database handle
  dbcursor | database cursor (NULL will use db->get)
  key | retrieve key value/length/flags
  data | retrieve data value/length/flags
  flags | (unused)
Returns: 0 on success

int(* _dbiVec::close)( dbiIndex dbi, unsigned int flags)`[inherited]`

  | Close index database, and destroy database handle. Parameters:
  dbi | index database handle
  flags | (unused)
Returns: 0 on success

int(* _dbiVec::copen)(dbiIndex dbi, DB_TXN * txnid, DBC ** dbcp, unsigned int dbiflags)`[inherited]`

  | Open database cursor. Parameters:
  dbi | index database handle
  txnid | database transaction handle
  Return values:
  dbcp | address of new database cursor
  Parameters:
  dbiflags | DB_WRITECURSOR or 0
Returns: 0 on success

int(* _dbiVec::cpget)(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * pkey, DBT * data, unsigned int flags)`[inherited]`

  | Retrieve (key,data) pair using dbcursor->c_pget. Parameters:
  dbi | index database handle
  dbcursor | database cursor
  key | secondary retrieve key value/length/flags
  pkey | primary retrieve key value/length/flags
  data | primary retrieve data value/length/flags
  flags | DB_NEXT, DB_SET, or 0
Returns: 0 on success

int(* _dbiVec::cput)(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, unsigned int flags)`[inherited]`

  | Store (key,data) pair using db->put or dbcursor->c_put. Parameters:
  dbi | index database handle
  dbcursor | database cursor (NULL will use db->put)
  key | store key value/length/flags
  data | store data value/length/flags
  flags | (unused)
Returns: 0 on success

int(* _dbiVec::join)(dbiIndex dbi, DBC ** curslist, DBC ** dbcp, unsigned int flags)`[inherited]`

  | Return join cursor for list of cursors. Parameters:
  dbi | index database handle
  curslist | NULL terminated list of database cursors
  Return values:
  dbcp | address of join database cursor
  Parameters:
  flags | DB_JOIN_NOSORT or 0
Returns: 0 on success Referenced by dbiJoin.

int(* _dbiVec::open)(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip)`[inherited]`

  | Return handle for an index database. Parameters:
  rpmdb | rpm database
  rpmtag | rpm tag
Returns: 0 on success Referenced by dbiOpen.

int(* _dbiVec::stat)(dbiIndex dbi, unsigned int flags)`[inherited]`

  | Save statistics in database handle. Parameters:
  dbi | index database handle
  flags | retrieve statistics that don't require traversal?
Returns: 0 on success Referenced by dbiOpen, and dbiStat.

int(* _dbiVec::sync)(dbiIndex dbi, unsigned int flags)`[inherited]`

  | Flush pending operations to disk. Parameters:
  dbi | index database handle
  flags | (unused)
Returns: 0 on success