summaryrefslogtreecommitdiff
path: root/lib/backend
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-10-18 15:03:35 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-10-18 15:03:35 +0300
commitb810869a0aa7227b2faeb91b4a958b7215e94561 (patch)
tree4f3c229cbdf5f8e76841a2338a2e614a3f47ed18 /lib/backend
parente8aa50d1881b5ab2ceeb63046fc2f5ede377f1bc (diff)
downloadlibrpm-tizen-b810869a0aa7227b2faeb91b4a958b7215e94561.tar.gz
librpm-tizen-b810869a0aa7227b2faeb91b4a958b7215e94561.tar.bz2
librpm-tizen-b810869a0aa7227b2faeb91b4a958b7215e94561.zip
Generate missing database indexes automatically
- Now that we know whether backing files were created on open, we can easily detect the need for index generation too. As index generation requires expensive plowing through the entire Packages database, we to create all missing indexes at once instead of risking several loops over Packages. So if we spot a missing index, we open all our indexes and generate all the missing bits in one go. - Berkeley DB does support on-demand index generation for secondary indexes created with db->associate(), but as rpm's indexes are in a slightly different format (they store tag index besides the header number), using it would require various other changes too. Also the BDB indexing callback recieves the data in serialized format, which in rpm's case would mean either headerLoad() for every single indexed bit, or passing the in-memory header through some other indirect means.
Diffstat (limited to 'lib/backend')
-rw-r--r--lib/backend/db3.c6
-rw-r--r--lib/backend/dbi.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/backend/db3.c b/lib/backend/db3.c
index 66ba16064..bcdebea48 100644
--- a/lib/backend/db3.c
+++ b/lib/backend/db3.c
@@ -578,6 +578,12 @@ int dbiOpen(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip)
*/
if (oflags & DB_RDONLY)
dbi->dbi_verify_on_close = 0;
+
+ /* Any indexes created here mean we'll need an index rebuild */
+ if (dbiType(dbi) == DBI_SECONDARY && (oflags & DB_CREATE)) {
+ rpmlog(RPMLOG_DEBUG, "index %s needs creating\n", dbi->dbi_file);
+ rpmdb->db_buildindex++;
+ }
dbi->dbi_db = db;
dbi->dbi_oflags = oflags;
diff --git a/lib/backend/dbi.h b/lib/backend/dbi.h
index dd1ada6a9..6cb20d879 100644
--- a/lib/backend/dbi.h
+++ b/lib/backend/dbi.h
@@ -22,6 +22,7 @@ struct rpmdb_s {
void * db_dbenv; /*!< Berkeley DB_ENV handle. */
int db_ndbi; /*!< No. of tag indices. */
dbiIndex * _dbi; /*!< Tag indices. */
+ int db_buildindex; /*!< Index rebuild indicator */
struct rpmop_s db_getops;
struct rpmop_s db_putops;