commit a01f4b56c134b43d00597d4a51b3f1c252bff98b
parent eab40982d0f84e25afead264ae222ba9ddd3e804
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 2 Apr 2026 23:07:32 +0200
preparation work for #9433
Diffstat:
3 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/src/auditordb/auditor_do_gc_auditor.sql b/src/auditordb/auditor_do_gc_auditor.sql
@@ -0,0 +1,28 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2026 Taler Systems SA
+--
+-- TALER is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+-- @author Christian Grothoff
+
+DROP FUNCTION IF EXISTS auditor_do_gc_auditor;
+CREATE OR REPLACE FUNCTION auditor_do_gc_auditor(
+ IN cutoff INT8)
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ -- FIXME-9433: GC not implemented!
+END $$;
+
+COMMENT ON FUNCTION auditor_do_gc_auditor(INT8)
+ IS 'Delete data from the auditor database that is no longer needed.';
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
@@ -458,14 +458,26 @@ static enum GNUNET_GenericReturnValue
postgres_gc (void *cls)
{
struct PostgresClosure *pg = cls;
- struct GNUNET_TIME_Absolute now = {0};
+ /* For now, we hard-code the cut-off date based on the
+ common legal requirement to keep data for 10 years.
+ Might make it configurable in the future. */
+ struct GNUNET_TIME_Absolute cutoff
+ = GNUNET_TIME_absolute_subtract (
+ GNUNET_TIME_absolute_get (),
+ GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_YEARS,
+ 10));
struct GNUNET_PQ_QueryParam params_time[] = {
- GNUNET_PQ_query_param_absolute_time (&now),
+ GNUNET_PQ_query_param_absolute_time (&cutoff),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_Context *conn;
enum GNUNET_DB_QueryStatus qs;
struct GNUNET_PQ_PreparedStatement ps[] = {
+ GNUNET_PQ_make_prepare ("do_gc_auditor",
+ "SELECT"
+ " auditor.do_gc_auditor"
+ " ($1);"),
GNUNET_PQ_PREPARED_STATEMENT_END
};
struct GNUNET_PQ_ExecuteStatement es[] = {
@@ -473,7 +485,6 @@ postgres_gc (void *cls)
GNUNET_PQ_EXECUTE_STATEMENT_END
};
- now = GNUNET_TIME_absolute_get ();
conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
"auditordb-postgres",
NULL,
@@ -481,10 +492,8 @@ postgres_gc (void *cls)
ps);
if (NULL == conn)
return GNUNET_SYSERR;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "FIXME: Auditor GC not implemented (#9433)\n");
qs = GNUNET_PQ_eval_prepared_non_select (conn,
- "gc_auditor",
+ "do_gc_auditor",
params_time);
GNUNET_PQ_disconnect (conn);
if (0 > qs)
diff --git a/src/auditordb/procedures.sql.in b/src/auditordb/procedures.sql.in
@@ -20,5 +20,6 @@ SET search_path TO auditor;
#include "auditor_do_get_auditor_progress.sql"
#include "auditor_do_get_balance.sql"
+#include "auditor_do_gc_auditor.sql"
COMMIT;