Fix the non-keyed match iteration case wrt DB_NOTFOUND
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 9 Jun 2011 09:45:42 +0000 (12:45 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 9 Jun 2011 09:45:42 +0000 (12:45 +0300)
- This broke in commit 7e4415fcc5e11cfd4cd9d0dfe19568be73f15d74,
  the cases are not identical afterall: With non-keyed cursor
  retrievals DB_NOTFOUND is returned when there's nothing more to
  get, this is not an error situation.

lib/rpmdb.c

index 613b8a4..e89fef9 100644 (file)
@@ -1989,6 +1989,10 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, rpmDbiTagVal rpmtag,
                rc = dbiCursorGetToSet(dbc, NULL, 0, &set);
            } while (rc == 0);
 
+           /* If we got some results, not found is not an error */
+           if (rc == DB_NOTFOUND && set != NULL)
+               rc = 0;
+
            dbiCursorFree(dbc);
         }