rpm 5.3.7
Files | Typedefs | Functions

RPMDB Database API.

Collaboration diagram for RPMDB Database API.:

Files

file  rpmlib.h
 

In Memoriam: Steve Taylor <staylor@redhat.com> was here, now he's not.


file  dbconfig.c
file  hdrNVR.c
file  rpmdb.c
file  rpmdb.h
 

Access RPM indices using Berkeley DB interface(s).


Typedefs

typedef struct _dbiIndexSet * dbiIndexSet
 A single element (i.e.
typedef struct tagStore_s * tagStore_t
typedef struct rpmdb_s * rpmdb
 Database of headers and tag value indices.
typedef struct rpmmi_srpmmi
 Database iterator.

Functions

rpmdb rpmdbUnlink (rpmdb db, const char *msg)
 Unreference a database instance.
rpmdb rpmdbLink (rpmdb db, const char *msg)
 Reference a database instance.
int rpmdbOpen (const char *prefix, rpmdb *dbp, int mode, mode_t perms)
 Open rpm database.
int rpmdbClose (rpmdb db)
 Close all database indices and free rpmdb.
int rpmdbOpenAll (rpmdb db)
 Open all database indices.
int rpmdbCount (rpmdb db, rpmTag tag, const void *keyp, size_t keylen)
 Return number of instances of key in a tag index.
int rpmdbCountPackages (rpmdb db, const char *N)
 Return number of instances of package in Name index.
uint32_t rpmmiInstance (rpmmi mi)
 Return header instance for current position of rpmdb iterator.
uint32_t rpmmiBNTag (rpmmi mi)
 Return basename tag for current position of rpmdb iterator.
unsigned int rpmmiCount (rpmmi mi)
 Return number of elements in rpm database iterator.
int rpmmiGrow (rpmmi mi, const uint32_t *hdrNums, int nHdrNums)
 Append items to set of package instances to iterate.
int rpmmiGrowBasename (rpmmi mi, const char *bn)
 Append packages containing common basename to iterator.
int rpmmiSort (rpmmi mi)
 Sort iterator instances.
int rpmmiPrune (rpmmi mi, uint32_t *hdrNums, int nHdrNums, int sorted)
 Remove items from set of package instances to iterate.
int rpmmiAddPattern (rpmmi mi, rpmTag tag, rpmMireMode mode, const char *pattern)
 Add pattern to iterator selector.
int rpmmiSetRewrite (rpmmi mi, int rewrite)
 Prepare iterator for lazy writes.
int rpmmiSetModified (rpmmi mi, int modified)
 Modify iterator to mark header for lazy write on release.
rpmmi rpmmiInit (rpmdb db, rpmTag tag, const void *keyp, size_t keylen)
 Return database iterator.
Header rpmmiNext (rpmmi mi)
 Return next package header from iteration.
int rpmdbCheckTerminate (int terminate)
 Check rpmdb signal handler for trapped signal and/or requested exit.
int rpmdbCheckSignals (void)
 Check for and exit on termination signals.
rpmmi rpmmiUnlink (rpmmi mi)
 Unreference a rpm database iterator.
rpmmi rpmmiLink (rpmmi mi)
 Reference a rpm database iterator.
rpmmi rpmmiFree (rpmmi mi)
 Destroy rpm database iterator.
int rpmdbMireApply (rpmdb db, rpmTag tag, rpmMireMode mode, const char *pat, const char ***argvp)
 Return array of keys matching a pattern.
int rpmdbAdd (rpmdb db, int iid, Header h, rpmts ts)
 Add package header to rpm database and indices.
int rpmdbRemove (rpmdb db, int rid, uint32_t hdrNum, rpmts ts)
 Remove package header from rpm database and indices.

Typedef Documentation

typedef struct _dbiIndexSet* dbiIndexSet

A single element (i.e.

inverted list from tag values) of a database.

Definition at line 54 of file rpmdb.h.

typedef struct rpmdb_s* rpmdb

Database of headers and tag value indices.

Definition at line 43 of file rpmtypes.h.

typedef struct rpmmi_s* rpmmi

Database iterator.

Definition at line 48 of file rpmtypes.h.

typedef struct tagStore_s* tagStore_t

Definition at line 516 of file rpmtag.h.


Function Documentation

int rpmdbAdd ( rpmdb  db,
int  iid,
Header  h,
rpmts  ts 
)
int rpmdbCheckSignals ( void  )
int rpmdbCheckTerminate ( int  terminate)

Check rpmdb signal handler for trapped signal and/or requested exit.

Clean up any open iterators and databases on termination condition. On non-zero exit any open references to rpmdb are invalid and cannot be accessed anymore, calling process should terminate immediately.

Parameters:
terminate0 to only check for signals, 1 to terminate anyway
Returns:
0 to continue, 1 if termination cleanup was done.

Definition at line 465 of file rpmdb.c.

References rpmmi_s::mi_next, rpmdbClose(), rpmdbRock, rpmmiFree(), and rpmsqCaught.

Referenced by rpm_exithook(), rpmdbCheckSignals(), and rpmts_Die().

int rpmdbClose ( rpmdb  db)

Close all database indices and free rpmdb.

Parameters:
dbrpm database
Returns:
0 on success

Definition at line 749 of file rpmdb.c.

References _free(), _rpmdb_debug, L, rpmdbCheckSignals(), rpmdbRock, rpmioPutPool(), rpmsqEnable(), and tagStoreFree().

Referenced by rpmdb_dealloc(), rpmdbCheckTerminate(), rpmdbOpenDatabase(), rpmmiFini(), rpmtsCloseDB(), and rpmtsCloseSDB().

int rpmdbCount ( rpmdb  db,
rpmTag  tag,
const void *  keyp,
size_t  keylen 
)

Return number of instances of key in a tag index.

Parameters:
dbrpm database
tagrpm tag
keypkey data
keylenkey data length (0 will use strlen(keyp))
Returns:
number of instances

Definition at line 1058 of file rpmdb.c.

References _, __db_dbt::data, DB_NOTFOUND, DB_SET, dbiOpen(), rpmlog(), RPMLOG_ERR, __db_dbt::size, tagName(), and UINT32_T.

Referenced by rpmdbCountPackages().

int rpmdbCountPackages ( rpmdb  db,
const char *  N 
)

Return number of instances of package in Name index.

Parameters:
dbrpm database
Nrpm package name
Returns:
number of instances

Definition at line 1108 of file rpmdb.c.

References rpmdbCount().

Referenced by handleOneTrigger(), rpmpsmStage(), and runTriggers().

rpmdb rpmdbLink ( rpmdb  db,
const char *  msg 
)

Reference a database instance.

Parameters:
dbrpm database
msg
Returns:
new rpm database reference

Referenced by rpmdbNew(), and rpmmiInit().

int rpmdbMireApply ( rpmdb  db,
rpmTag  tag,
rpmMireMode  mode,
const char *  pat,
const char ***  argvp 
)

Return array of keys matching a pattern.

Parameters:
dbrpm database
tagrpm tag
modetype of pattern match
patpattern to match
Return values:
*argvparray of keys that match
Returns:
0 on success

Definition at line 1353 of file rpmdb.c.

References _rpmmi_debug, dbiMireKeys(), and tagName().

Referenced by rpmdbTriggerGlobs(), rpmtsSanityCheck(), and runImmedTriggers().

int rpmdbOpen ( const char *  prefix,
rpmdb dbp,
int  mode,
mode_t  perms 
)

Open rpm database.

Parameters:
prefixpath to top of install tree
Return values:
dbpaddress of rpm database
Parameters:
modeopen(2) flags: O_RDWR or O_RDONLY (O_CREAT also)
permsdatabase permissions
Returns:
0 on success

Definition at line 1052 of file rpmdb.c.

References rpmdbOpenDatabase(), and rpmExpandNumeric().

Referenced by rpmtsFindPubkey(), rpmtsOpenDB(), and rpmtsOpenSDB().

int rpmdbOpenAll ( rpmdb  db)

Open all database indices.

Parameters:
dbrpm database
Returns:
0 on success

Definition at line 671 of file rpmdb.c.

References dbiOpen(), RPMDBI_ADDED, RPMDBI_AVAILABLE, RPMDBI_BTREE, RPMDBI_DEPENDS, RPMDBI_HASH, RPMDBI_QUEUE, RPMDBI_RECNO, and RPMDBI_REMOVED.

Referenced by rpmtsPrepare().

int rpmdbRemove ( rpmdb  db,
int  rid,
uint32_t  hdrNum,
rpmts  ts 
)

Remove package header from rpm database and indices.

Parameters:
dbrpm database
rid(unused) remove transaction id (rid = 0 or -1 to skip)
hdrNumpackage instance number in database
ts(unused) transaction set (or NULL)
Returns:
0 on success

Definition at line 2543 of file rpmdb.c.

References _, _free(), _hton_ui(), alloca(), blockSignals(), __db_dbt::data, DB_SET, DB_WRITECURSOR, dbiOpen(), headerFree(), headerGet(), headerLink(), _HE_s::p, rpmDataType_u::ptr, RPMDBI_ADDED, RPMDBI_AVAILABLE, RPMDBI_DEPENDS, RPMDBI_PACKAGES, RPMDBI_REMOVED, RPMDBI_SEQNO, rpmlog(), RPMLOG_DEBUG, RPMLOG_ERR, rpmmiFree(), rpmmiInit(), rpmmiNext(), RPMRC_FAIL, RPMRC_OK, __db_dbt::size, rpmDataType_u::str, _HE_s::tag, UINT32_T, and unblockSignals().

Referenced by rpmpsmStage(), and rpmtsRollback().

rpmdb rpmdbUnlink ( rpmdb  db,
const char *  msg 
)

Unreference a database instance.

Parameters:
dbrpm database
msg
Returns:
NULL always
int rpmmiAddPattern ( rpmmi  mi,
rpmTag  tag,
rpmMireMode  mode,
const char *  pattern 
)

Add pattern to iterator selector.

Parameters:
mirpm database iterator
tagrpm tag
modetype of pattern match
patternpattern to match
Returns:
0 on success

Definition at line 1772 of file rpmdb.c.

References _free(), _mire_debug, _mirePool, _rpmmi_debug, rpmmi_s::mi_nre, rpmmi_s::mi_re, mireCmp(), mireDup(), mireFree(), mireGetPool(), mireLink(), mireNew(), mireRegcomp(), rpmExpand(), RPMMIRE_DEFAULT, RPMMIRE_GLOB, RPMMIRE_REGEX, RPMMIRE_STRCMP, tagName(), and xrealloc().

Referenced by IDTXload(), rpmgiInitFilter(), rpmmi_Pattern(), and rpmpsmStage().

uint32_t rpmmiBNTag ( rpmmi  mi)

Return basename tag for current position of rpmdb iterator.

Parameters:
mirpm database iterator
Returns:
current basename tag

Definition at line 1623 of file rpmdb.c.

References _rpmmi_debug, and rpmmi_s::mi_bntag.

Referenced by rpmtsCheckInstalledFiles().

unsigned int rpmmiCount ( rpmmi  mi)

Return number of elements in rpm database iterator.

Parameters:
mirpm database iterator
Returns:
number of elements

Definition at line 1630 of file rpmdb.c.

References _rpmmi_debug, __db_dbt::data, DB_SET, dbiOpen(), rpmmi_s::mi_cflags, rpmmi_s::mi_count, rpmmi_s::mi_db, rpmmi_s::mi_dbc, rpmmi_s::mi_keylen, rpmmi_s::mi_keyp, rpmmi_s::mi_primary, rpmmi_s::mi_rpmtag, __db_dbt::size, and UINT32_T.

Referenced by ftsCacheUpdate(), rpmcliInstall(), rpmmi_Count(), rpmQueryVerify(), rpmts_AddErase(), and runImmedTriggers().

rpmmi rpmmiFree ( rpmmi  mi)
int rpmmiGrow ( rpmmi  mi,
const uint32_t *  hdrNums,
int  nHdrNums 
)

Append items to set of package instances to iterate.

Parameters:
mirpm database iterator
hdrNumsarray of package instances
nHdrNumsnumber of elements in array
Returns:
0 on success, 1 on failure (bad args)

Definition at line 2338 of file rpmdb.c.

References _rpmmi_debug, dbiAppendSet(), rpmmi_s::mi_set, and xcalloc().

int rpmmiGrowBasename ( rpmmi  mi,
const char *  bn 
)

Append packages containing common basename to iterator.

Parameters:
mirpm database iterator
bnbasename key
Returns:
0 on success, 1 on failure (bad args)

Definition at line 1362 of file rpmdb.c.

References _rpmmi_debug, dbiAppendSet(), dbiFreeIndexSet(), dbiMireKeys(), hashFunctionString(), rpmmi_s::mi_db, rpmmi_s::mi_rpmtag, rpmmi_s::mi_set, RPMMIRE_STRCMP, set(), and xcalloc().

Referenced by rpmtsFindBaseNamesInDB().

rpmmi rpmmiInit ( rpmdb  db,
rpmTag  tag,
const void *  keyp,
size_t  keylen 
)
uint32_t rpmmiInstance ( rpmmi  mi)

Return header instance for current position of rpmdb iterator.

Parameters:
mirpm database iterator
Returns:
current header instance

Definition at line 1614 of file rpmdb.c.

References _ntoh_ui(), _rpmmi_debug, and rpmmi_s::mi_offset.

Referenced by IDTXload(), nwlookupTag(), rpmcliEraseElement(), rpmErase(), rpmgiNext(), rpmmi_Instance(), rpmpsmStage(), rpmts_AddErase(), rpmtsAddObsoletes(), rpmtsAddUpgrades(), rpmtsCheckInstalledFiles(), rpmtsEraseDebuginfo(), rpmtsFindPubkey(), runImmedTriggers(), runTriggersLoop(), and wnlookupTag().

rpmmi rpmmiLink ( rpmmi  mi)

Reference a rpm database iterator.

Parameters:
mirpm database iterator
Returns:
NULL on last dereference
Header rpmmiNext ( rpmmi  mi)
int rpmmiPrune ( rpmmi  mi,
uint32_t *  hdrNums,
int  nHdrNums,
int  sorted 
)

Remove items from set of package instances to iterate.

Note:
Sorted hdrNums are always passed in rpmlib.
Parameters:
mirpm database iterator
hdrNumsarray of package instances
nHdrNumsnumber of elements in array
sortedis the array sorted? (array will be sorted on return)
Returns:
0 on success, 1 on failure (bad args)

Definition at line 2312 of file rpmdb.c.

References _hton_ui(), _rpmmi_debug, and rpmmi_s::mi_bf.

Referenced by checkPackageSet(), nwlookupTag(), rpmtsAddObsoletes(), rpmtsEraseDebuginfo(), runImmedTriggers(), runTriggersLoop(), unsatisfiedDepend(), and wnlookupTag().

int rpmmiSetModified ( rpmmi  mi,
int  modified 
)

Modify iterator to mark header for lazy write on release.

Parameters:
mirpm database iterator
modifiednew value of modified
Returns:
previous value

Definition at line 2042 of file rpmdb.c.

References rpmmi_s::mi_modified.

int rpmmiSetRewrite ( rpmmi  mi,
int  rewrite 
)

Prepare iterator for lazy writes.

Note:
Must be called before rpmmiNext() with CDB model database.
Parameters:
mirpm database iterator
rewritenew value of rewrite
Returns:
previous value

Definition at line 2029 of file rpmdb.c.

References DB_WRITECURSOR, and rpmmi_s::mi_cflags.

int rpmmiSort ( rpmmi  mi)

Sort iterator instances.

Parameters:
mirpm database iterator
Returns:
0 on success

Definition at line 2279 of file rpmdb.c.

References hdrNumCmp(), rpmmi_s::mi_set, rpmmi_s::mi_sorted, and rpm_mergesort().

Referenced by rpmtsFindBaseNamesInDB().

rpmmi rpmmiUnlink ( rpmmi  mi)

Unreference a rpm database iterator.

Parameters:
mirpm database iterator
Returns:
NULL on last dereference