exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit ee73b3a775c148e5d190ce0af5a9e8e0a7ecb470
parent a01f4b56c134b43d00597d4a51b3f1c252bff98b
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu,  2 Apr 2026 23:47:59 +0200

implement #9433

Diffstat:
Msrc/auditordb/0002-auditor_amount_arithmetic_inconsistency.sql | 10+++++++---
Msrc/auditordb/0002-auditor_bad_sig_losses.sql | 8++++++--
Msrc/auditordb/0002-auditor_closure_lags.sql | 6+++++-
Msrc/auditordb/0002-auditor_coin_inconsistency.sql | 6+++++-
Msrc/auditordb/0002-auditor_denomination_key_validity_withdraw_inconsistency.sql | 6+++++-
Msrc/auditordb/0002-auditor_denominations_without_sigs.sql | 6+++++-
Msrc/auditordb/0002-auditor_early_aggregation.sql | 6+++++-
Msrc/auditordb/0002-auditor_emergency.sql | 6+++++-
Msrc/auditordb/0002-auditor_emergency_by_count.sql | 6+++++-
Msrc/auditordb/0002-auditor_fee_time_inconsistency.sql | 6+++++-
Msrc/auditordb/0002-auditor_misattribution_in_inconsistency.sql | 6+++++-
Msrc/auditordb/0002-auditor_pending_deposits.sql | 6+++++-
Msrc/auditordb/0002-auditor_purse_not_closed_inconsistencies.sql | 6+++++-
Msrc/auditordb/0002-auditor_refreshes_hanging.sql | 6+++++-
Msrc/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql | 6+++++-
Msrc/auditordb/0002-auditor_reserve_balance_summary_wrong_inconsistency.sql | 6+++++-
Msrc/auditordb/0002-auditor_reserve_in_inconsistency.sql | 6+++++-
Msrc/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql | 6+++++-
Msrc/auditordb/0002-auditor_row_inconsistency.sql | 6+++++-
Msrc/auditordb/0002-auditor_row_minor_inconsistencies.sql | 6+++++-
Msrc/auditordb/0002-auditor_wire_format_inconsistency.sql | 6+++++-
Msrc/auditordb/auditor_do_gc_auditor.sql | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Msrc/auditordb/plugin_auditordb_postgres.c | 4++--
23 files changed, 192 insertions(+), 30 deletions(-)

diff --git a/src/auditordb/0002-auditor_amount_arithmetic_inconsistency.sql b/src/auditordb/0002-auditor_amount_arithmetic_inconsistency.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2014--2024 Taler Systems SA +-- Copyright (C) 2014--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 @@ -22,7 +22,11 @@ CREATE TABLE auditor_amount_arithmetic_inconsistency exchange_amount taler_amount NOT NULL, auditor_amount taler_amount NOT NULL, profitable BOOLEAN NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_amount_arithmetic_inconsistency - IS 'Report a (serious) inconsistency in the exchange''s database with respect to calculations involving amounts'; + IS 'Report a (serious) inconsistency in the exchange''s database with respect to calculations involving amounts'; +COMMENT ON COLUMN auditor_amount_arithmetic_inconsistency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_bad_sig_losses.sql b/src/auditordb/0002-auditor_bad_sig_losses.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2014--2024 Taler Systems SA +-- Copyright (C) 2014--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 @@ -21,7 +21,11 @@ CREATE TABLE IF NOT EXISTS auditor_bad_sig_losses operation TEXT NOT NULL, loss taler_amount NOT NULL, operation_specific_pub BYTEA NOT NULL CHECK (LENGTH(operation_specific_pub)=32), - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_bad_sig_losses IS 'Report a (serious) inconsistency with losses due to bad signatures'; +COMMENT ON COLUMN auditor_bad_sig_losses.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_closure_lags.sql b/src/auditordb/0002-auditor_closure_lags.sql @@ -22,7 +22,11 @@ CREATE TABLE IF NOT EXISTS auditor_closure_lags deadline BIGINT NOT NULL, wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32), account TEXT NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_closure_lags IS 'Report closure lags.'; +COMMENT ON COLUMN auditor_closure_lags.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_coin_inconsistency.sql b/src/auditordb/0002-auditor_coin_inconsistency.sql @@ -23,7 +23,11 @@ CREATE TABLE IF NOT EXISTS auditor_coin_inconsistency auditor_amount taler_amount NOT NULL, coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32), profitable BOOLEAN NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_coin_inconsistency IS 'Report a (serious) inconsistency in the exchange''s database with respect to calculations involving amounts'; +COMMENT ON COLUMN auditor_coin_inconsistency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_denomination_key_validity_withdraw_inconsistency.sql b/src/auditordb/0002-auditor_denomination_key_validity_withdraw_inconsistency.sql @@ -21,7 +21,11 @@ CREATE TABLE IF NOT EXISTS auditor_denomination_key_validity_withdraw_inconsiste execution_date BIGINT NOT NULL, reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32), denompub_h BYTEA NOT NULL CHECK (LENGTH(denompub_h)=64), - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_denomination_key_validity_withdraw_inconsistency IS 'Report a (serious) denomination key validity withdraw inconsistency in the exchange''s database'; +COMMENT ON COLUMN auditor_denomination_key_validity_withdraw_inconsistency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_denominations_without_sigs.sql b/src/auditordb/0002-auditor_denominations_without_sigs.sql @@ -21,7 +21,11 @@ CREATE TABLE IF NOT EXISTS auditor_denominations_without_sigs value taler_amount NOT NULL, start_time BIGINT NOT NULL, end_time BIGINT, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_denominations_without_sigs IS 'Report encountered denomination that auditor is not auditing.'; +COMMENT ON COLUMN auditor_denominations_without_sigs.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_early_aggregation.sql b/src/auditordb/0002-auditor_early_aggregation.sql @@ -20,7 +20,9 @@ CREATE TABLE IF NOT EXISTS auditor_early_aggregations batch_deposit_serial_id BIGINT UNIQUE NOT NULL, tracking_serial_id BIGINT UNIQUE NOT NULL, amount taler_amount NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_early_aggregations @@ -36,3 +38,5 @@ COMMENT ON COLUMN auditor_early_aggregations.amount IS 'Total transaction amount impacted'; COMMENT ON COLUMN auditor_early_aggregations.suppressed IS 'True if the report was suppressed by an administrator'; +COMMENT ON COLUMN auditor_early_aggregations.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_emergency.sql b/src/auditordb/0002-auditor_emergency.sql @@ -23,7 +23,11 @@ CREATE TABLE IF NOT EXISTS auditor_emergency deposit_start BIGINT NOT NULL, deposit_end BIGINT NOT NULL, value taler_amount NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_emergency IS 'Report an emergency denomination.'; +COMMENT ON COLUMN auditor_emergency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_emergency_by_count.sql b/src/auditordb/0002-auditor_emergency_by_count.sql @@ -24,7 +24,11 @@ CREATE TABLE IF NOT EXISTS auditor_emergency_by_count start BIGINT NOT NULL, deposit_end BIGINT NOT NULL, value taler_amount NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_emergency_by_count IS 'Report an emergency denomination.'; +COMMENT ON COLUMN auditor_emergency_by_count.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_fee_time_inconsistency.sql b/src/auditordb/0002-auditor_fee_time_inconsistency.sql @@ -21,7 +21,11 @@ CREATE TABLE IF NOT EXISTS auditor_fee_time_inconsistency fee_type TEXT NOT NULL, fee_time BIGINT NOT NULL, diagnostic TEXT NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_fee_time_inconsistency IS 'Report a (serious) fee time inconsistency in the exchange''s database'; +COMMENT ON COLUMN auditor_fee_time_inconsistency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_misattribution_in_inconsistency.sql b/src/auditordb/0002-auditor_misattribution_in_inconsistency.sql @@ -21,7 +21,11 @@ CREATE TABLE IF NOT EXISTS auditor_misattribution_in_inconsistency amount taler_amount NOT NULL, bank_row BIGINT NOT NULL, reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32), - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_misattribution_in_inconsistency IS 'Report wire transfer that was smaller than it should have been.'; +COMMENT ON COLUMN auditor_misattribution_in_inconsistency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_pending_deposits.sql b/src/auditordb/0002-auditor_pending_deposits.sql @@ -21,7 +21,9 @@ CREATE TABLE IF NOT EXISTS auditor_pending_deposits wire_target_h_payto BYTEA NOT NULL CHECK (LENGTH(wire_target_h_payto)=32), batch_deposit_serial_id BIGINT NOT NULL, deadline BIGINT NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_pending_deposits @@ -37,3 +39,5 @@ COMMENT ON COLUMN auditor_pending_deposits.total_amount IS 'Total transaction amount impacted'; COMMENT ON COLUMN auditor_pending_deposits.suppressed IS 'True if the report was suppressed by an administrator'; +COMMENT ON COLUMN auditor_pending_deposits.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_purse_not_closed_inconsistencies.sql b/src/auditordb/0002-auditor_purse_not_closed_inconsistencies.sql @@ -21,7 +21,11 @@ CREATE TABLE IF NOT EXISTS auditor_purse_not_closed_inconsistencies purse_pub BYTEA NOT NULL CHECK (LENGTH(purse_pub)=32), amount taler_amount NOT NULL, expiration_date BIGINT NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_purse_not_closed_inconsistencies IS 'Report expired purses'; +COMMENT ON COLUMN auditor_purse_not_closed_inconsistencies.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_refreshes_hanging.sql b/src/auditordb/0002-auditor_refreshes_hanging.sql @@ -20,7 +20,11 @@ CREATE TABLE IF NOT EXISTS auditor_refreshes_hanging row_id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, problem_row_id BIGINT NOT NULL, amount taler_amount NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_refreshes_hanging IS 'Report a hanging refresh.'; +COMMENT ON COLUMN auditor_refreshes_hanging.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql b/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql @@ -20,7 +20,11 @@ CREATE TABLE IF NOT EXISTS auditor_reserve_balance_insufficient_inconsistency reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32), inconsistency_gain BOOLEAN NOT NULL, inconsistency_amount taler_amount NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_reserve_balance_insufficient_inconsistency IS 'Report a (serious) balance insufficiency in the exchange''s database'; +COMMENT ON COLUMN auditor_reserve_balance_insufficient_inconsistency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_reserve_balance_summary_wrong_inconsistency.sql b/src/auditordb/0002-auditor_reserve_balance_summary_wrong_inconsistency.sql @@ -21,7 +21,11 @@ CREATE TABLE IF NOT EXISTS auditor_reserve_balance_summary_wrong_inconsistency reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32), exchange_amount taler_amount NOT NULL, auditor_amount taler_amount NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_reserve_balance_summary_wrong_inconsistency IS 'Report a (serious) reserve balance insufficiency.'; +COMMENT ON COLUMN auditor_reserve_balance_summary_wrong_inconsistency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_reserve_in_inconsistency.sql b/src/auditordb/0002-auditor_reserve_in_inconsistency.sql @@ -25,7 +25,11 @@ CREATE TABLE IF NOT EXISTS auditor_reserve_in_inconsistency timestamp BIGINT NOT NULL, account TEXT NOT NULL, diagnostic TEXT NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_reserve_in_inconsistency IS 'Report an incoming wire transfer claimed by exchange not found.'; +COMMENT ON COLUMN auditor_reserve_in_inconsistency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql b/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql @@ -21,7 +21,11 @@ CREATE TABLE IF NOT EXISTS auditor_reserve_not_closed_inconsistency balance taler_amount NOT NULL, expiration_time BIGINT, diagnostic TEXT, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_reserve_not_closed_inconsistency IS 'Report a (serious) reserve balance insufficiency.'; +COMMENT ON COLUMN auditor_reserve_not_closed_inconsistency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_row_inconsistency.sql b/src/auditordb/0002-auditor_row_inconsistency.sql @@ -21,7 +21,11 @@ CREATE TABLE IF NOT EXISTS auditor_row_inconsistency row_table TEXT NOT NULL, diagnostic TEXT NOT NULL, problem_row_id INT8 NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_row_inconsistency IS 'Report a (serious) row inconsistency in the exchange''s database'; +COMMENT ON COLUMN auditor_row_inconsistency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_row_minor_inconsistencies.sql b/src/auditordb/0002-auditor_row_minor_inconsistencies.sql @@ -20,7 +20,11 @@ CREATE TABLE IF NOT EXISTS auditor_row_minor_inconsistencies row_table TEXT NOT NULL, problem_row BIGINT NOT NULL, diagnostic TEXT NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_row_minor_inconsistencies IS 'Report a (minor) row inconsistency in the exchange''s database.'; +COMMENT ON COLUMN auditor_row_minor_inconsistencies.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/0002-auditor_wire_format_inconsistency.sql b/src/auditordb/0002-auditor_wire_format_inconsistency.sql @@ -21,7 +21,11 @@ CREATE TABLE IF NOT EXISTS auditor_wire_format_inconsistency amount taler_amount NOT NULL, wire_offset BIGINT NOT NULL, diagnostic TEXT NOT NULL, - suppressed BOOLEAN NOT NULL DEFAULT FALSE + suppressed BOOLEAN NOT NULL DEFAULT FALSE, + creation_date INT8 NOT NULL + DEFAULT (EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT ); COMMENT ON TABLE auditor_wire_format_inconsistency IS 'Report a (serious) format inconsistency.'; +COMMENT ON COLUMN auditor_wire_format_inconsistency.creation_date + IS 'for garbage collection'; diff --git a/src/auditordb/auditor_do_gc_auditor.sql b/src/auditordb/auditor_do_gc_auditor.sql @@ -15,14 +15,92 @@ -- -- @author Christian Grothoff -DROP FUNCTION IF EXISTS auditor_do_gc_auditor; -CREATE OR REPLACE FUNCTION auditor_do_gc_auditor( +DROP PROCEDURE IF EXISTS auditor_do_gc_auditor; +CREATE OR REPLACE PROCEDURE auditor_do_gc_auditor( IN cutoff INT8) LANGUAGE plpgsql AS $$ BEGIN - -- FIXME-9433: GC not implemented! + + -- Standard cases + DELETE FROM auditor_amount_arithmetic_inconsistency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_bad_sig_losses + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_closure_lags + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_coin_inconsistency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_denomination_key_validity_withdraw_inconsistency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_denominations_without_sigs + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_emergency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_emergency_by_count + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_fee_time_inconsistency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_misattribution_in_inconsistency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_purse_not_closed_inconsistencies + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_refreshes_hanging + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_reserve_balance_insufficient_inconsistency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_reserve_balance_summary_wrong_inconsistency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_reserve_in_inconsistency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_reserve_not_closed_inconsistency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_row_inconsistency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_row_minor_inconsistencies + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_wire_format_inconsistency + WHERE suppressed + AND creation_date < cutoff; + DELETE FROM auditor_early_aggregations + WHERE suppressed + AND creation_date < cutoff; + + -- special cases + DELETE FROM auditor_deposit_confirmations + WHERE suppressed + AND exchange_timestamp < cutoff; + DELETE FROM auditor_exchange_signkeys + WHERE ep_expire_legal<(EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT + AND ep_expire_sign < cutoff; + DELETE FROM auditor_purses + WHERE expiration_date < cutoff; + DELETE FROM auditor_reserves + WHERE expiration_date < cutoff; + DELETE FROM auditor_pending_deposits + WHERE suppressed + AND creation_date < cutoff + AND deadline < cutoff; + END $$; -COMMENT ON FUNCTION auditor_do_gc_auditor(INT8) +COMMENT ON PROCEDURE 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 @@ -475,8 +475,8 @@ postgres_gc (void *cls) enum GNUNET_DB_QueryStatus qs; struct GNUNET_PQ_PreparedStatement ps[] = { GNUNET_PQ_make_prepare ("do_gc_auditor", - "SELECT" - " auditor.do_gc_auditor" + "CALL" + " auditor.auditor_do_gc_auditor" " ($1);"), GNUNET_PQ_PREPARED_STATEMENT_END };