int verifyonly = (flags & RPMDB_FLAG_VERIFYONLY);
DB * db = NULL;
+ DBTYPE dbtype = DB_UNKNOWN;
uint32_t oflags;
static int _lockdbfd = 0;
free(dbfs);
rc = (db->open)(db, NULL, dbi->dbi_file, NULL,
- dbi->dbi_dbtype, oflags, rdb->db_perms);
+ dbtype, oflags, rdb->db_perms);
/* Attempt to create if missing, discarding DB_RDONLY (!) */
if (rc == ENOENT) {
oflags |= DB_CREATE;
oflags &= ~DB_RDONLY;
+ dbtype = (dbiType(dbi) == DBI_PRIMARY) ? DB_HASH : DB_BTREE;
retry_open--;
} else {
retry_open = 0;
}
- if (rc == 0 && dbi->dbi_dbtype == DB_UNKNOWN) {
- DBTYPE dbi_dbtype = DB_UNKNOWN;
- xx = db->get_type(db, &dbi_dbtype);
- if (xx == 0)
- dbi->dbi_dbtype = dbi_dbtype;
- }
-
/* XXX return rc == errno without printing */
_printit = (rc > 0 ? 0 : _debug);
xx = cvtdberr(dbi, "db->open", rc, _printit);
+ /* Validate the index type is something we can support */
+ if ((rc == 0) && (dbtype == DB_UNKNOWN)) {
+ db->get_type(db, &dbtype);
+ if (dbtype != DB_HASH && dbtype != DB_BTREE) {
+ rpmlog(RPMLOG_ERR, _("invalid index type %x on %s/%s\n"),
+ dbtype, dbhome, dbi->dbi_file);
+ rc = 1;
+ }
+ }
+
if (rc != 0) {
db->close(db, 0);
db = NULL;
{ "nommap", 0,POPT_BIT_SET, &staticdbi.dbi_oflags, DB_NOMMAP,
NULL, NULL },
- { "btree", 0,POPT_ARG_VAL, &staticdbi.dbi_dbtype, DB_BTREE,
- NULL, NULL },
- { "hash", 0,POPT_ARG_VAL, &staticdbi.dbi_dbtype, DB_HASH,
- NULL, NULL },
- { "unknown", 0,POPT_ARG_VAL, &staticdbi.dbi_dbtype, DB_UNKNOWN,
- NULL, NULL },
-
{ "nodbsync", 0,POPT_ARG_NONE, &staticdbi.dbi_no_dbsync, 0,
NULL, NULL },
{ "lockdbfd", 0,POPT_ARG_NONE, &staticdbi.dbi_lockdbfd, 0,
return dbi;
}
-/** @todo Set a reasonable "last gasp" default db config. */
-static const char * const dbi_config_default =
- "hash:cdb:verbose";
-
dbiIndex dbiNew(rpmdb rdb, rpmTag rpmtag)
{
dbiIndex dbi = xcalloc(1, sizeof(*dbi));
dbOpts = _free(dbOpts);
dbOpts = rpmExpand("%{_dbi_config}", NULL);
if (!(dbOpts && *dbOpts && *dbOpts != '%')) {
- dbOpts = rpmExpand(dbi_config_default, NULL);
+ dbOpts = _free(dbOpts);
}
}
struct _dbiIndex {
const char * dbi_file; /*!< file component of path */
- DBTYPE dbi_dbtype; /*!< db index type */
int dbi_oflags; /*!< db->open flags */
int dbi_permit_dups; /*!< permit duplicate entries? */
int dbi_no_dbsync; /*!< don't call dbiSync */
# I believe that you will find pagesize=512 "best".
# 3) Adding nofsync increases speed, but risks total data loss. Fiddle shared
# and/or mp_size instead.
-# 4) btree is faster than hash, but would require some painful rpm release
-# engineering to convert everbody's databases to btree, not gonna happen
-# soon.
#
# token works? Berkeley db flag or value
#==================================================
# cachesize=1Mb DBENV->set_cachesize, DB->set_cachesize
#---------------------- DB->open bits:
# nommap ??? DB_NOMMAP
-#---------------------- DB->open types:
-# btree DB_BTREE
-# hash DB_HASH
-# unknown +++ DB_UNKNOWN
#----------------------- rpmdb specific configuration:
# lockdbfd (always on for Packages) Use fcntl(2) locking ?
# nofsync Disable fsync(2) call performed after db3 writes?
# Misc BDB tuning options
%__dbi_other mp_mmapsize=16Mb mp_size=1Mb
-#
-#--- Hash database configuration
-%__dbi_htconfig \
- hash \
- %{__dbi_other}\
-%{nil}
-
-%_dbi_htconfig %{__dbi_htconfig}
-
-#
-#--- Btree database configuration
-%__dbi_btconfig \
- btree \
- %{__dbi_other}\
-%{nil}
-
-%_dbi_btconfig %{__dbi_btconfig}
+%_dbi_config %{?__dbi_other}
# "Packages" should have shared/exclusive fcntl(2) lock using "lockdbfd".
-%_dbi_config_Packages %{_dbi_htconfig} lockdbfd
-
-%_dbi_config_Dirnames %{_dbi_btconfig}
-%_dbi_config_Installtid %{_dbi_btconfig}
-
-%_dbi_config %{_dbi_htconfig}
+%_dbi_config_Packages %{?_dbi_config} lockdbfd
# XXX legacy configuration.
# Choose db interface: