return 1;
}
+static void logAddRemove(int removing, rpmtd tagdata)
+{
+ rpm_count_t c = rpmtdCount(tagdata);
+ if (c == 1 && rpmtdType(tagdata) == RPM_STRING_TYPE) {
+ rpmlog(RPMLOG_DEBUG, "%s \"%s\" %s %s index.\n",
+ removing ? "removing" : "adding", rpmtdGetString(tagdata),
+ removing ? "from" : "to",
+ rpmTagGetName(rpmtdTag(tagdata)));
+ } else if (c > 0) {
+ rpmlog(RPMLOG_DEBUG, "%s %d entries %s %s index.\n",
+ removing ? "removing" : "adding", c,
+ removing ? "from" : "to",
+ rpmTagGetName(rpmtdTag(tagdata)));
+ }
+}
+
/* XXX psm.c */
int rpmdbRemove(rpmdb db, int rid, unsigned int hdrNum,
rpmts ts,
for (dbix = 0; dbix < dbiTags.max; dbix++) {
dbiIndex dbi;
rpmTag rpmtag;
- int xx, printed = 0;
+ int xx = 0;
struct rpmtd_s tagdata;
dbi = NULL;
xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DB_WRITECURSOR);
rpmtdInit(&tagdata);
+
+ logAddRemove(1, &tagdata);
+
while (rpmtdNext(&tagdata) >= 0) {
dbiIndexSet set;
continue;
}
- if (!printed) {
- int stringvalued = (rpmtdType(&tagdata) == RPM_STRING_TYPE);
- rpm_count_t c = rpmtdCount(&tagdata);
- if (c == 1 && stringvalued) {
- rpmlog(RPMLOG_DEBUG,
- "removing \"%s\" from %s index.\n",
- (char *)key.data, rpmTagGetName(rpmtag));
- } else {
- rpmlog(RPMLOG_DEBUG,
- "removing %d entries from %s index.\n",
- c, rpmTagGetName(rpmtag));
- }
- printed++;
- }
-
/* XXX
* This is almost right, but, if there are duplicate tag
* values, there will be duplicate attempts to remove
dbi = dbiOpen(db, rpmtag, 0);
if (dbi != NULL) {
- int printed = 0;
-
xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DB_WRITECURSOR);
+ logAddRemove(0, &tagdata);
while (rpmtdNext(&tagdata) >= 0) {
dbiIndexSet set;
int i;
continue;
}
- if (!printed) {
- int stringvalued = (rpmtdType(&tagdata) == RPM_STRING_TYPE);
- rpm_count_t c = rpmtdCount(&tagdata);
- if (c == 1 && stringvalued) {
- rpmlog(RPMLOG_DEBUG,
- "adding \"%s\" to %s index.\n",
- (char *)key.data, rpmTagGetName(rpmtag));
- } else {
- rpmlog(RPMLOG_DEBUG,
- "adding %d entries to %s index.\n",
- c, rpmTagGetName(rpmtag));
- }
- printed++;
- }
-
/*
* XXX with duplicates, an accurate data value and
* DB_GET_BOTH is needed.