|
|
1a8671 |
From c5919efe898294420ec8e91e4eed5b9081e681c5 Mon Sep 17 00:00:00 2001
|
|
|
1a8671 |
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
|
|
|
1a8671 |
Date: Thu, 17 Feb 2022 18:18:16 +0100
|
|
|
1a8671 |
Subject: [PATCH 33/34] libdnf/transaction/RPMItem: Fix handling transaction id
|
|
|
1a8671 |
in resolveTransactionItemReason
|
|
|
1a8671 |
|
|
|
1a8671 |
The maxTransactionId argument was ignored, the method was always returning the
|
|
|
1a8671 |
reason from the last transaction. This is the correct result for
|
|
|
1a8671 |
maxTransactionId = -1. In a couple of places the method is called with
|
|
|
1a8671 |
maxTransactionId = -2. Fixing this would mean nontrivial changes to the
|
|
|
1a8671 |
logic which could potentially break something else, so I'm leaving this
|
|
|
1a8671 |
behavior unchanged.
|
|
|
1a8671 |
|
|
|
1a8671 |
For non-negative values of maxTransactionId (with which it's not being called
|
|
|
1a8671 |
anywhere in dnf codebase), the commit adds a condition to SELECT only
|
|
|
1a8671 |
transaction ids less than or equal to maxTransactionId.
|
|
|
1a8671 |
|
|
|
1a8671 |
= changelog =
|
|
|
1a8671 |
msg: Fix handling transaction id in resolveTransactionItemReason
|
|
|
1a8671 |
type: bugfix
|
|
|
1a8671 |
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2053014
|
|
|
1a8671 |
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2010259
|
|
|
1a8671 |
---
|
|
|
1a8671 |
libdnf/transaction/RPMItem.cpp | 21 ++++++++++++++++++---
|
|
|
1a8671 |
1 file changed, 18 insertions(+), 3 deletions(-)
|
|
|
1a8671 |
|
|
|
1a8671 |
diff --git a/libdnf/transaction/RPMItem.cpp b/libdnf/transaction/RPMItem.cpp
|
|
|
1a8671 |
index 5f667ab9..ecce789d 100644
|
|
|
1a8671 |
--- a/libdnf/transaction/RPMItem.cpp
|
|
|
1a8671 |
+++ b/libdnf/transaction/RPMItem.cpp
|
|
|
1a8671 |
@@ -255,7 +255,11 @@ RPMItem::resolveTransactionItemReason(SQLite3Ptr conn,
|
|
|
1a8671 |
const std::string &arch,
|
|
|
1a8671 |
int64_t maxTransactionId)
|
|
|
1a8671 |
{
|
|
|
1a8671 |
- const char *sql = R"**(
|
|
|
1a8671 |
+ // NOTE: All negative maxTransactionId values are treated the same. The
|
|
|
1a8671 |
+ // method is called with maxTransactionId = -2 in a couple of places, the
|
|
|
1a8671 |
+ // semantics here have been the same as with -1 for a long time. If it
|
|
|
1a8671 |
+ // ain't broke...
|
|
|
1a8671 |
+ std::string sql = R"**(
|
|
|
1a8671 |
SELECT
|
|
|
1a8671 |
ti.action as action,
|
|
|
1a8671 |
ti.reason as reason
|
|
|
1a8671 |
@@ -271,14 +275,25 @@ RPMItem::resolveTransactionItemReason(SQLite3Ptr conn,
|
|
|
1a8671 |
AND ti.action not in (3, 5, 7, 10)
|
|
|
1a8671 |
AND i.name = ?
|
|
|
1a8671 |
AND i.arch = ?
|
|
|
1a8671 |
+ )**";
|
|
|
1a8671 |
+
|
|
|
1a8671 |
+ if (maxTransactionId >= 0) {
|
|
|
1a8671 |
+ sql.append(" AND ti.trans_id <= ?");
|
|
|
1a8671 |
+ }
|
|
|
1a8671 |
+
|
|
|
1a8671 |
+ sql.append(R"**(
|
|
|
1a8671 |
ORDER BY
|
|
|
1a8671 |
ti.trans_id DESC
|
|
|
1a8671 |
LIMIT 1
|
|
|
1a8671 |
- )**";
|
|
|
1a8671 |
+ )**");
|
|
|
1a8671 |
|
|
|
1a8671 |
if (arch != "") {
|
|
|
1a8671 |
SQLite3::Query query(*conn, sql);
|
|
|
1a8671 |
- query.bindv(name, arch);
|
|
|
1a8671 |
+ if (maxTransactionId >= 0) {
|
|
|
1a8671 |
+ query.bindv(name, arch, maxTransactionId);
|
|
|
1a8671 |
+ } else {
|
|
|
1a8671 |
+ query.bindv(name, arch);
|
|
|
1a8671 |
+ }
|
|
|
1a8671 |
|
|
|
1a8671 |
if (query.step() == SQLite3::Statement::StepResult::ROW) {
|
|
|
1a8671 |
auto action = static_cast< TransactionItemAction >(query.get< int64_t >("action"));
|
|
|
1a8671 |
--
|
|
|
1a8671 |
2.31.1
|
|
|
1a8671 |
|