history DB: Add "persistence" column
Resolves: RHEL-99825
This commit is contained in:
parent
5425b0878f
commit
ff89fe4bf9
227
0016-history-DB-Add-persistence-column.patch
Normal file
227
0016-history-DB-Add-persistence-column.patch
Normal file
@ -0,0 +1,227 @@
|
||||
From 1f6d3284f161da1751798910d84ccd871a76a04d Mon Sep 17 00:00:00 2001
|
||||
From: Evan Goode <mail@evangoo.de>
|
||||
Date: Thu, 15 May 2025 20:44:18 +0000
|
||||
Subject: [PATCH 1/3] history DB: Add "persistence" column
|
||||
|
||||
For https://github.com/rpm-software-management/dnf/issues/2196.
|
||||
The `persistence` column is a TransactionPersistence enum, currently it
|
||||
can either be UNKNOWN, PERSIST, or TRANSIENT.
|
||||
---
|
||||
libdnf/transaction/Swdb.cpp | 8 ++++++++
|
||||
libdnf/transaction/Swdb.hpp | 1 +
|
||||
libdnf/transaction/Transaction.cpp | 2 ++
|
||||
libdnf/transaction/Transaction.hpp | 3 +++
|
||||
libdnf/transaction/Transformer.cpp | 7 +++++++
|
||||
libdnf/transaction/Transformer.hpp | 2 +-
|
||||
libdnf/transaction/Types.hpp | 6 ++++++
|
||||
libdnf/transaction/private/Transaction.cpp | 8 ++++++--
|
||||
libdnf/transaction/private/Transaction.hpp | 1 +
|
||||
libdnf/transaction/sql/migrate_tables_1_3.sql | 9 +++++++++
|
||||
10 files changed, 44 insertions(+), 3 deletions(-)
|
||||
create mode 100644 libdnf/transaction/sql/migrate_tables_1_3.sql
|
||||
|
||||
diff --git a/libdnf/transaction/Swdb.cpp b/libdnf/transaction/Swdb.cpp
|
||||
index 9626f732..3c7f84ce 100644
|
||||
--- a/libdnf/transaction/Swdb.cpp
|
||||
+++ b/libdnf/transaction/Swdb.cpp
|
||||
@@ -385,6 +385,14 @@ Swdb::setReleasever(std::string value)
|
||||
transactionInProgress->setReleasever(value);
|
||||
}
|
||||
|
||||
+void
|
||||
+Swdb::setPersistence(TransactionPersistence persistence)
|
||||
+{
|
||||
+ if (!transactionInProgress) {
|
||||
+ throw std::logic_error(_("Not in progress"));
|
||||
+ }
|
||||
+ transactionInProgress->setPersistence(persistence);
|
||||
+}
|
||||
|
||||
void
|
||||
Swdb::addConsoleOutputLine(int fileDescriptor, std::string line)
|
||||
diff --git a/libdnf/transaction/Swdb.hpp b/libdnf/transaction/Swdb.hpp
|
||||
index 5b2342c8..9ae6b52d 100644
|
||||
--- a/libdnf/transaction/Swdb.hpp
|
||||
+++ b/libdnf/transaction/Swdb.hpp
|
||||
@@ -114,6 +114,7 @@ public:
|
||||
|
||||
// misc
|
||||
void setReleasever(std::string value);
|
||||
+ void setPersistence(TransactionPersistence value);
|
||||
void addConsoleOutputLine(int fileDescriptor, std::string line);
|
||||
|
||||
/**
|
||||
diff --git a/libdnf/transaction/Transaction.cpp b/libdnf/transaction/Transaction.cpp
|
||||
index 208f6763..3aac1cb9 100644
|
||||
--- a/libdnf/transaction/Transaction.cpp
|
||||
+++ b/libdnf/transaction/Transaction.cpp
|
||||
@@ -82,6 +82,7 @@ Transaction::dbSelect(int64_t pk)
|
||||
" releasever, "
|
||||
" user_id, "
|
||||
" cmdline, "
|
||||
+ " persistence, "
|
||||
" state, "
|
||||
" comment "
|
||||
"FROM "
|
||||
@@ -100,6 +101,7 @@ Transaction::dbSelect(int64_t pk)
|
||||
releasever = query.get< std::string >("releasever");
|
||||
userId = query.get< uint32_t >("user_id");
|
||||
cmdline = query.get< std::string >("cmdline");
|
||||
+ persistence = static_cast<TransactionPersistence>(query.get<int>("persistence"));
|
||||
state = static_cast< TransactionState >(query.get< int >("state"));
|
||||
comment = query.get< std::string >("comment");
|
||||
}
|
||||
diff --git a/libdnf/transaction/Transaction.hpp b/libdnf/transaction/Transaction.hpp
|
||||
index a4aba8f3..58f4e4cd 100644
|
||||
--- a/libdnf/transaction/Transaction.hpp
|
||||
+++ b/libdnf/transaction/Transaction.hpp
|
||||
@@ -55,6 +55,8 @@ public:
|
||||
const std::string &getReleasever() const noexcept { return releasever; }
|
||||
uint32_t getUserId() const noexcept { return userId; }
|
||||
const std::string &getCmdline() const noexcept { return cmdline; }
|
||||
+ TransactionPersistence getPersistence() const noexcept { return persistence; }
|
||||
+
|
||||
TransactionState getState() const noexcept { return state; }
|
||||
const std::string &getComment() const noexcept { return comment; }
|
||||
|
||||
@@ -79,6 +81,7 @@ protected:
|
||||
std::string releasever;
|
||||
uint32_t userId = 0;
|
||||
std::string cmdline;
|
||||
+ TransactionPersistence persistence = TransactionPersistence::UNKNOWN;
|
||||
TransactionState state = TransactionState::UNKNOWN;
|
||||
std::string comment;
|
||||
};
|
||||
diff --git a/libdnf/transaction/Transformer.cpp b/libdnf/transaction/Transformer.cpp
|
||||
index ef4c0669..ba1b882d 100644
|
||||
--- a/libdnf/transaction/Transformer.cpp
|
||||
+++ b/libdnf/transaction/Transformer.cpp
|
||||
@@ -53,6 +53,10 @@ static const char * const sql_migrate_tables_1_2 =
|
||||
#include "sql/migrate_tables_1_2.sql"
|
||||
;
|
||||
|
||||
+static const char * const sql_migrate_tables_1_3 =
|
||||
+#include "sql/migrate_tables_1_3.sql"
|
||||
+ ;
|
||||
+
|
||||
void
|
||||
Transformer::createDatabase(SQLite3Ptr conn)
|
||||
{
|
||||
@@ -70,6 +74,9 @@ Transformer::migrateSchema(SQLite3Ptr conn)
|
||||
|
||||
if (schemaVersion == "1.1") {
|
||||
conn->exec(sql_migrate_tables_1_2);
|
||||
+ conn->exec(sql_migrate_tables_1_3);
|
||||
+ } else if (schemaVersion == "1.2") {
|
||||
+ conn->exec(sql_migrate_tables_1_3);
|
||||
}
|
||||
}
|
||||
else {
|
||||
diff --git a/libdnf/transaction/Transformer.hpp b/libdnf/transaction/Transformer.hpp
|
||||
index 87c0e1f4..a99ea066 100644
|
||||
--- a/libdnf/transaction/Transformer.hpp
|
||||
+++ b/libdnf/transaction/Transformer.hpp
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
static void migrateSchema(SQLite3Ptr conn);
|
||||
|
||||
static TransactionItemReason getReason(const std::string &reason);
|
||||
- static const char *getVersion() noexcept { return "1.2"; }
|
||||
+ static const char *getVersion() noexcept { return "1.3"; }
|
||||
|
||||
protected:
|
||||
void transformTrans(SQLite3Ptr swdb, SQLite3Ptr history);
|
||||
diff --git a/libdnf/transaction/Types.hpp b/libdnf/transaction/Types.hpp
|
||||
index 0003bbb7..574ed085 100644
|
||||
--- a/libdnf/transaction/Types.hpp
|
||||
+++ b/libdnf/transaction/Types.hpp
|
||||
@@ -56,6 +56,12 @@ enum class TransactionItemAction : int {
|
||||
REASON_CHANGE = 11 // a package was kept on the system but it's reason has changed
|
||||
};
|
||||
|
||||
+enum class TransactionPersistence : int {
|
||||
+ UNKNOWN = 0,
|
||||
+ PERSIST = 1,
|
||||
+ TRANSIENT = 2,
|
||||
+};
|
||||
+
|
||||
} // namespace libdnf
|
||||
/*
|
||||
Install
|
||||
diff --git a/libdnf/transaction/private/Transaction.cpp b/libdnf/transaction/private/Transaction.cpp
|
||||
index 088d6ba9..0131cbb8 100644
|
||||
--- a/libdnf/transaction/private/Transaction.cpp
|
||||
+++ b/libdnf/transaction/private/Transaction.cpp
|
||||
@@ -76,12 +76,13 @@ swdb_private::Transaction::dbInsert()
|
||||
" releasever, "
|
||||
" user_id, "
|
||||
" cmdline, "
|
||||
+ " persistence, "
|
||||
" state, "
|
||||
" comment, "
|
||||
" id "
|
||||
" ) "
|
||||
"VALUES "
|
||||
- " (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
+ " (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
SQLite3::Statement query(*conn.get(), sql);
|
||||
query.bindv(getDtBegin(),
|
||||
getDtEnd(),
|
||||
@@ -90,10 +91,11 @@ swdb_private::Transaction::dbInsert()
|
||||
getReleasever(),
|
||||
getUserId(),
|
||||
getCmdline(),
|
||||
+ static_cast<int>(getPersistence()),
|
||||
static_cast< int >(getState()),
|
||||
getComment());
|
||||
if (getId() > 0) {
|
||||
- query.bind(9, getId());
|
||||
+ query.bind(10, getId());
|
||||
}
|
||||
query.step();
|
||||
setId(conn->lastInsertRowID());
|
||||
@@ -138,6 +140,7 @@ swdb_private::Transaction::dbUpdate()
|
||||
" releasever=?, "
|
||||
" user_id=?, "
|
||||
" cmdline=?, "
|
||||
+ " persistence=?, "
|
||||
" state=?, "
|
||||
" comment=? "
|
||||
"WHERE "
|
||||
@@ -150,6 +153,7 @@ swdb_private::Transaction::dbUpdate()
|
||||
getReleasever(),
|
||||
getUserId(),
|
||||
getCmdline(),
|
||||
+ static_cast<int>(getPersistence()),
|
||||
static_cast< int >(getState()),
|
||||
getComment(),
|
||||
getId());
|
||||
diff --git a/libdnf/transaction/private/Transaction.hpp b/libdnf/transaction/private/Transaction.hpp
|
||||
index 9e0d6848..dd5ba0a0 100644
|
||||
--- a/libdnf/transaction/private/Transaction.hpp
|
||||
+++ b/libdnf/transaction/private/Transaction.hpp
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
void setReleasever(const std::string &value) { releasever = value; }
|
||||
void setUserId(uint32_t value) { userId = value; }
|
||||
void setCmdline(const std::string &value) { cmdline = value; }
|
||||
+ void setPersistence(TransactionPersistence value) { persistence = value; }
|
||||
void setState(TransactionState value) { state = value; }
|
||||
void setComment(const std::string &value) { comment = value; }
|
||||
|
||||
diff --git a/libdnf/transaction/sql/migrate_tables_1_3.sql b/libdnf/transaction/sql/migrate_tables_1_3.sql
|
||||
new file mode 100644
|
||||
index 00000000..6901874e
|
||||
--- /dev/null
|
||||
+++ b/libdnf/transaction/sql/migrate_tables_1_3.sql
|
||||
@@ -0,0 +1,9 @@
|
||||
+R"**(
|
||||
+BEGIN TRANSACTION;
|
||||
+ ALTER TABLE trans
|
||||
+ ADD persistence INTEGER DEFAULT 0;
|
||||
+ UPDATE config
|
||||
+ SET value = '1.3'
|
||||
+ WHERE key = 'version';
|
||||
+COMMIT;
|
||||
+)**"
|
||||
--
|
||||
2.49.0
|
||||
|
46
0017-MergedTransaction-listPersistences.patch
Normal file
46
0017-MergedTransaction-listPersistences.patch
Normal file
@ -0,0 +1,46 @@
|
||||
From 6d396e84cbf46386af87d829112ced8d7c1165cd Mon Sep 17 00:00:00 2001
|
||||
From: Evan Goode <mail@evangoo.de>
|
||||
Date: Mon, 19 May 2025 22:37:36 +0000
|
||||
Subject: [PATCH 2/3] MergedTransaction::listPersistences
|
||||
|
||||
---
|
||||
libdnf/transaction/MergedTransaction.cpp | 10 ++++++++++
|
||||
libdnf/transaction/MergedTransaction.hpp | 1 +
|
||||
2 files changed, 11 insertions(+)
|
||||
|
||||
diff --git a/libdnf/transaction/MergedTransaction.cpp b/libdnf/transaction/MergedTransaction.cpp
|
||||
index 75d2c1e7..8f556c02 100644
|
||||
--- a/libdnf/transaction/MergedTransaction.cpp
|
||||
+++ b/libdnf/transaction/MergedTransaction.cpp
|
||||
@@ -97,6 +97,16 @@ MergedTransaction::listCmdlines() const
|
||||
return cmdLines;
|
||||
}
|
||||
|
||||
+std::vector< TransactionPersistence >
|
||||
+MergedTransaction::listPersistences() const
|
||||
+{
|
||||
+ std::vector< TransactionPersistence > persistences;
|
||||
+ for (auto t : transactions) {
|
||||
+ persistences.push_back(t->getPersistence());
|
||||
+ }
|
||||
+ return persistences;
|
||||
+}
|
||||
+
|
||||
std::vector< TransactionState >
|
||||
MergedTransaction::listStates() const
|
||||
{
|
||||
diff --git a/libdnf/transaction/MergedTransaction.hpp b/libdnf/transaction/MergedTransaction.hpp
|
||||
index 50212159..5ef9fb30 100644
|
||||
--- a/libdnf/transaction/MergedTransaction.hpp
|
||||
+++ b/libdnf/transaction/MergedTransaction.hpp
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
std::vector< int64_t > listIds() const;
|
||||
std::vector< uint32_t > listUserIds() const;
|
||||
std::vector< std::string > listCmdlines() const;
|
||||
+ std::vector< TransactionPersistence > listPersistences() const;
|
||||
std::vector< TransactionState > listStates() const;
|
||||
std::vector< std::string > listReleasevers() const;
|
||||
std::vector< std::string > listComments() const;
|
||||
--
|
||||
2.49.0
|
||||
|
@ -56,7 +56,7 @@
|
||||
|
||||
Name: libdnf
|
||||
Version: %{libdnf_major_version}.%{libdnf_minor_version}.%{libdnf_micro_version}
|
||||
Release: 10%{?dist}
|
||||
Release: 11%{?dist}
|
||||
Summary: Library providing simplified C and Python API to libsolv
|
||||
License: LGPL-2.1-or-later
|
||||
URL: https://github.com/rpm-software-management/libdnf
|
||||
@ -76,6 +76,8 @@ Patch12: 0012-C-API-support-shell-style-variable-substitution.patch
|
||||
Patch13: 0013-C-API-test-shell-style-variable-expressions.patch
|
||||
Patch14: 0014-conf-Improve-granularity-of-ConfigParser-exceptions.patch
|
||||
Patch15: 0015-module-Warn-if-module-config-file-is-inaccessible.patch
|
||||
Patch16: 0016-history-DB-Add-persistence-column.patch
|
||||
Patch17: 0017-MergedTransaction-listPersistences.patch
|
||||
|
||||
BuildRequires: cmake
|
||||
BuildRequires: gcc
|
||||
@ -319,6 +321,9 @@ popd
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Jun 24 2025 Evan Goode <egoode@redhat.com> - 0.73.1-11
|
||||
- history DB: Add "persistence" column (RHEL-99825)
|
||||
|
||||
* Thu Mar 20 2025 Marek Blaha <mblaha@redhat.com> - 0.73.1-10
|
||||
- module: Warn if module config file is inaccessible (RHEL-83804)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user