diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2021-03-15 13:32:05 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2021-03-22 12:04:27 +0200 |
commit | 6941a235bb466f9c319a3f55078f8481bd15d9dd (patch) | |
tree | 8a4df968cdb76575782894bbd383f155a71bb500 | |
parent | 9c5b2669c877f6de08bd81af02f859fb93d52d42 (diff) | |
download | rpm-6941a235bb466f9c319a3f55078f8481bd15d9dd.tar.gz |
Permit secondary index open to fail for bdb_ro
The other backends would want to create the missing index, but as bdb_ro
is read-only it can't do that. As the main purpose of bdb_ro is to support
migrating away from BDB for which only the primary database is needed,
it doesn't make sense to fail it for non-essential data. Let it fail
for secondary indexes - this might affect our ability to query but
that's secondary, literally, and we also do emit a warning here.
Fixes: #1576
(cherry picked from commit 190d8bdf3d61f0684f19bda0be906ae04ac957ae)
-rw-r--r-- | lib/backend/bdb_ro.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/backend/bdb_ro.c b/lib/backend/bdb_ro.c index 222e25600..2667ec845 100644 --- a/lib/backend/bdb_ro.c +++ b/lib/backend/bdb_ro.c @@ -608,10 +608,13 @@ static int bdbro_Open(rpmdb rdb, rpmDbiTagVal rpmtag, dbiIndex * dbip, int flags rpmlog(RPMLOG_DEBUG, "opening db index %s\n", path); dbi->dbi_db = bdb_open(path); if (!dbi->dbi_db) { - rpmlog(RPMLOG_ERR, "could not open %s: %s\n", path, strerror(errno)); - free(path); - dbiFree(dbi); - return 1; + int lvl = (dbi->dbi_type == DBI_PRIMARY) ? RPMLOG_ERR : RPMLOG_WARNING; + rpmlog(lvl, "could not open %s: %s\n", path, strerror(errno)); + if (dbi->dbi_type == DBI_PRIMARY) { + free(path); + dbiFree(dbi); + return 1; + } } free(path); dbi->dbi_flags |= DBI_RDONLY; @@ -646,7 +649,8 @@ static int bdbro_Ctrl(rpmdb rdb, dbCtrlOp ctrl) static dbiCursor bdbro_CursorInit(dbiIndex dbi, unsigned int flags) { - return dbi ? (void *)cur_open(dbi->dbi_db) : NULL; + /* Secondary indexes may be missing */ + return (dbi && dbi->dbi_db) ? (void *)cur_open(dbi->dbi_db) : NULL; } static dbiCursor bdbro_CursorFree(dbiIndex dbi, dbiCursor dbc) |