gnucash stable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Sat Jun 21 19:44:20 EDT 2025


Updated	 via  https://github.com/Gnucash/gnucash/commit/db883f97 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c1eb5a69 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/60bc4cca (commit)
	from  https://github.com/Gnucash/gnucash/commit/b0c60fb3 (commit)



commit db883f972b022da16b107f27ae98f23a9011e084
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Jun 21 16:38:42 2025 -0700

    Bug 799623 - test-backend-dbi fails after 2038
    
    The first-line cause of the bug was that the safe save was failing on
    SQLite3 because the backup tables weren't visible inside the
    transaction and that prevented them from being dropped. Commit the
    transaction before trying to drop the backup tables.

diff --git a/libgnucash/backend/dbi/gnc-backend-dbi.cpp b/libgnucash/backend/dbi/gnc-backend-dbi.cpp
index be271f142f..e95f5efe48 100644
--- a/libgnucash/backend/dbi/gnc-backend-dbi.cpp
+++ b/libgnucash/backend/dbi/gnc-backend-dbi.cpp
@@ -976,8 +976,8 @@ GncDbiBackend<Type>::safe_sync (QofBook* book)
         LEAVE ("Failed to create new database tables");
         return;
     }
-    conn->table_operation (TableOpType::drop_backup);
     conn->commit_transaction();
+    conn->table_operation (TableOpType::drop_backup);
     LEAVE ("book=%p", m_book);
 }
 /* MySQL commits the transaction and all savepoints after the first CREATE

commit c1eb5a69803388ebd5500782904474a8e94f139c
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Jun 21 16:29:53 2025 -0700

    [DBI Backend] Preserve int size when recovering from failed save-save.
    
    Delete all rows and copy merged rows back into program-created table
    instead of renaming the merge table. See
    https://bugs.gnucash.org/show_bug.cgi?id=799623#c6 for explanation.

diff --git a/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp b/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp
index d1b8626a2a..bb26617a7c 100644
--- a/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp
+++ b/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp
@@ -628,9 +628,16 @@ GncDbiSqlConnection::merge_tables(const std::string& table,
     auto stmt = create_statement_from_sql(sql);
     if (execute_nonselect_statement(stmt) < 0)
         return false;
-    if (!drop_table(table))
+    sql = std::string("DELETE FROM ") + table;
+    stmt = create_statement_from_sql(sql);
+    if (execute_nonselect_statement(stmt) < 0)
+        return false;
+    sql = std::string("INSERT INTO ") + table +
+        " SELECT * FROM " + merge_table;
+    stmt = create_statement_from_sql(sql);
+    if (execute_nonselect_statement(stmt) < 0)
         return false;
-    if (!rename_table(merge_table, table))
+    if (!drop_table(merge_table))
         return false;
     return drop_table(other);
 }

commit 60bc4ccab01e4101eb9389aca8f57d85e696c96d
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Jun 21 16:33:51 2025 -0700

    [test-dbi-backend] Test 64-bit integer insertion explicitly.
    
    https://bugs.gnucash.org/show_bug.cgi?id=799623 identified a problem
    with int64_t storage in SQLite3 by setting a date after 2038-01-23
    whose time64 overflowed int32_t. But dates shouldn't be stored as
    time64s, they should be stored as ISO 8601 date-time strings. So fix
    the test to store the date correctly and to store the big int as an
    int64_t.

diff --git a/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp b/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp
index e7d7418de7..8923f74f77 100644
--- a/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp
+++ b/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp
@@ -117,6 +117,7 @@ setup_memory (Fixture* fixture, gconstpointer pData)
     Split* spl1, *spl2;
     gnc_commodity_table* table;
     gnc_commodity* currency;
+    Time64 now{gnc_time(nullptr)};
 
     gnc_module_init_backend_dbi();
     root = gnc_book_get_root_account (book);
@@ -131,10 +132,10 @@ setup_memory (Fixture* fixture, gconstpointer pData)
     xaccAccountSetCommodity (acct1, currency);
 
     auto frame = qof_instance_get_slots (QOF_INSTANCE (acct1));
-    frame->set ({"int64-val"}, new KvpValue (INT64_C (100)));
+    frame->set ({"int64-val"}, new KvpValue (INT64_C (2148634028)));
     frame->set ({"double-val"}, new KvpValue (3.14159));
     frame->set ({"numeric-val"}, new KvpValue (gnc_numeric_zero ()));
-    frame->set ({"time-val"}, new KvpValue (gnc_time(nullptr)));
+    frame->set ({"time-val"}, new KvpValue (now));
     frame->set ({"string-val"}, new KvpValue (g_strdup ("abcdefghijklmnop")));
     auto guid = qof_instance_get_guid (QOF_INSTANCE (acct1));
     frame->set ({"guid-val"}, new KvpValue (const_cast<GncGUID*> (guid_copy (
@@ -669,6 +670,8 @@ test_suite_gnc_backend_dbi (void)
     mysql_url.append(getenv("TEST_MYSQL_URL") ? getenv("TEST_MYSQL_URL") : "");
     pgsql_url.append(getenv("TEST_PGSQL_URL") ? getenv("TEST_PGSQL_URL") : "");
 
+    sort(drivers.begin(), drivers.end());
+
     for (auto name : drivers)
     {
         if (name == "sqlite3")



Summary of changes:
 libgnucash/backend/dbi/gnc-backend-dbi.cpp             |  2 +-
 libgnucash/backend/dbi/gnc-dbisqlconnection.cpp        | 11 +++++++++--
 libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp |  7 +++++--
 3 files changed, 15 insertions(+), 5 deletions(-)



More information about the gnucash-changes mailing list