procedures.sql.in (2202B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2024-2025 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 17 BEGIN; 18 19 SET search_path TO merchant; 20 21 #include "pg_insert_deposit_to_transfer.sql" 22 #include "pg_insert_product.sql" 23 #include "pg_insert_issued_token.sql" 24 #include "pg_insert_spent_token.sql" 25 #include "pg_insert_transfer_details.sql" 26 #include "pg_update_product.sql" 27 #include "pg_solve_mfa_challenge.sql" 28 #include "pg_account_kyc_set_status.sql" 29 #include "pg_account_kyc_set_failed.sql" 30 #include "pg_statistics_helpers.sql" 31 #include "pg_do_handle_inventory_changes.sql" 32 #include "pg_do_handle_category_changes.sql" 33 #include "pg_update_product_group.sql" 34 #include "pg_update_money_pot.sql" 35 #include "pg_increment_money_pots.sql" 36 #include "pg_account_kyc_get_status.sql" 37 #include "pg_insert_transfer.sql" 38 #include "pg_insert_deposit_confirmation.sql" 39 #include "pg_base32_crockford.sql" 40 #include "pg_uri_escape.sql" 41 #include "pg_merchant_kyc_trigger.sql" 42 #include "pg_merchant_send_kyc_notification.sql" 43 44 DROP PROCEDURE IF EXISTS merchant_do_gc; 45 CREATE PROCEDURE merchant_do_gc(in_now INT8) 46 LANGUAGE plpgsql 47 AS $$ 48 BEGIN 49 DELETE FROM merchant_instances 50 WHERE validation_needed 51 AND validation_expiration < in_now; 52 CALL merchant_statistic_amount_gc (); 53 CALL merchant_statistic_bucket_gc (); 54 CALL merchant_statistic_counter_gc (); 55 56 DELETE FROM tan_challenges 57 WHERE expiration_date < in_now; 58 DELETE FROM merchant_unclaim_signatures 59 WHERE expiration_time < in_now; 60 END $$; 61 COMMENT ON PROCEDURE merchant_do_gc 62 IS 'calls all other garbage collection subroutines'; 63 64 65 COMMIT;