auditor_do_gc_auditor.sql (3625B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2026 Taler Systems SA 4 -- 5 -- TALER is free software; you can redistribute it and/or modify it under the 6 -- terms of the GNU General Public License as published by the Free Software 7 -- Foundation; either version 3, or (at your option) any later version. 8 -- 9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 -- A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 -- 13 -- You should have received a copy of the GNU General Public License along with 14 -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 -- 16 -- @author Christian Grothoff 17 18 DROP PROCEDURE IF EXISTS auditor_do_gc_auditor; 19 CREATE OR REPLACE PROCEDURE auditor_do_gc_auditor( 20 IN cutoff INT8) 21 LANGUAGE plpgsql 22 AS $$ 23 BEGIN 24 25 -- Standard cases 26 DELETE FROM auditor_amount_arithmetic_inconsistency 27 WHERE suppressed 28 AND creation_date < cutoff; 29 DELETE FROM auditor_bad_sig_losses 30 WHERE suppressed 31 AND creation_date < cutoff; 32 DELETE FROM auditor_closure_lags 33 WHERE suppressed 34 AND creation_date < cutoff; 35 DELETE FROM auditor_coin_inconsistency 36 WHERE suppressed 37 AND creation_date < cutoff; 38 DELETE FROM auditor_denomination_key_validity_withdraw_inconsistency 39 WHERE suppressed 40 AND creation_date < cutoff; 41 DELETE FROM auditor_denominations_without_sigs 42 WHERE suppressed 43 AND creation_date < cutoff; 44 DELETE FROM auditor_emergency 45 WHERE suppressed 46 AND creation_date < cutoff; 47 DELETE FROM auditor_emergency_by_count 48 WHERE suppressed 49 AND creation_date < cutoff; 50 DELETE FROM auditor_fee_time_inconsistency 51 WHERE suppressed 52 AND creation_date < cutoff; 53 DELETE FROM auditor_misattribution_in_inconsistency 54 WHERE suppressed 55 AND creation_date < cutoff; 56 DELETE FROM auditor_purse_not_closed_inconsistencies 57 WHERE suppressed 58 AND creation_date < cutoff; 59 DELETE FROM auditor_refreshes_hanging 60 WHERE suppressed 61 AND creation_date < cutoff; 62 DELETE FROM auditor_reserve_balance_insufficient_inconsistency 63 WHERE suppressed 64 AND creation_date < cutoff; 65 DELETE FROM auditor_reserve_balance_summary_wrong_inconsistency 66 WHERE suppressed 67 AND creation_date < cutoff; 68 DELETE FROM auditor_reserve_in_inconsistency 69 WHERE suppressed 70 AND creation_date < cutoff; 71 DELETE FROM auditor_reserve_not_closed_inconsistency 72 WHERE suppressed 73 AND creation_date < cutoff; 74 DELETE FROM auditor_row_inconsistency 75 WHERE suppressed 76 AND creation_date < cutoff; 77 DELETE FROM auditor_row_minor_inconsistencies 78 WHERE suppressed 79 AND creation_date < cutoff; 80 DELETE FROM auditor_wire_format_inconsistency 81 WHERE suppressed 82 AND creation_date < cutoff; 83 DELETE FROM auditor_early_aggregations 84 WHERE suppressed 85 AND creation_date < cutoff; 86 87 -- special cases 88 DELETE FROM auditor_deposit_confirmations 89 WHERE suppressed 90 AND exchange_timestamp < cutoff; 91 DELETE FROM auditor_exchange_signkeys 92 WHERE ep_expire_legal<(EXTRACT(EPOCH FROM NOW()) * 1000 * 1000)::BIGINT 93 AND ep_expire_sign < cutoff; 94 DELETE FROM auditor_purses 95 WHERE expiration_date < cutoff; 96 DELETE FROM auditor_reserves 97 WHERE expiration_date < cutoff; 98 DELETE FROM auditor_pending_deposits 99 WHERE suppressed 100 AND creation_date < cutoff 101 AND deadline < cutoff; 102 103 END $$; 104 105 COMMENT ON PROCEDURE auditor_do_gc_auditor(INT8) 106 IS 'Delete data from the auditor database that is no longer needed.';