File ndbglue.diff of Package python-rpm.27835

--- ./lib/backend/ndb/glue.c.orig	2021-05-05 09:26:54.576469129 +0000
+++ ./lib/backend/ndb/glue.c	2021-05-05 09:28:37.392287727 +0000
@@ -307,26 +307,31 @@ static void setdata(dbiCursor dbc,  unsi
 
 static rpmRC ndb_pkgdbNew(dbiIndex dbi, dbiCursor dbc,  unsigned int *hdrNum)
 {
+    struct ndbEnv_s *ndbenv = dbc->dbi->dbi_rpmdb->db_dbenv;
     int rc = rpmpkgNextPkgIdx(dbc->dbi->dbi_db, hdrNum);
-    if (!rc)
+    if (!rc && ndbenv->hdrNum == *hdrNum)
 	setdata(dbc, *hdrNum, 0, 0);
     return rc;
 }
 
 static rpmRC ndb_pkgdbPut(dbiIndex dbi, dbiCursor dbc,  unsigned int hdrNum, unsigned char *hdrBlob, unsigned int hdrLen)
 {
+    struct ndbEnv_s *ndbenv = dbc->dbi->dbi_rpmdb->db_dbenv;
     int rc = rpmpkgPut(dbc->dbi->dbi_db, hdrNum, hdrBlob, hdrLen);
     if (!rc) {
 	dbc->hdrNum = hdrNum;
-	setdata(dbc, hdrNum, 0, 0);
+	if (ndbenv->hdrNum == hdrNum)
+	    setdata(dbc, hdrNum, 0, 0);
     }
     return rc;
 }
 
 static rpmRC ndb_pkgdbDel(dbiIndex dbi, dbiCursor dbc,  unsigned int hdrNum)
 {
+    struct ndbEnv_s *ndbenv = dbc->dbi->dbi_rpmdb->db_dbenv;
     dbc->hdrNum = 0;
-    setdata(dbc, 0, 0, 0);
+    if (ndbenv->hdrNum == hdrNum)
+	setdata(dbc, 0, 0, 0);
     return rpmpkgDel(dbc->dbi->dbi_db, hdrNum);
 }
 
openSUSE Build Service is sponsored by