merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

gen-procedures.sh (2288B)


      1 #!/bin/sh
      2 
      3 # This file is part of TALER
      4 # Copyright (C) 2026 Taler Systems SA
      5 #
      6 # TALER is free software; you can redistribute it and/or modify it under the
      7 # terms of the GNU General Public License as published by the Free Software
      8 # Foundation; either version 3, or (at your option) any later version.
      9 #
     10 # TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     13 #
     14 # You should have received a copy of the GNU General Public License along with
     15 # TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     16 
     17 set -eu
     18 
     19 if [ $# -lt 1 ]; then
     20   echo "Usage: $0 SQLFILES..." >&2
     21   exit 1
     22 fi
     23 
     24 
     25 # Output preamble
     26 
     27 cat <<'EOF'
     28 --
     29 -- This file is part of TALER
     30 -- Copyright (C) 2024-2026 Taler Systems SA
     31 --
     32 -- TALER is free software; you can redistribute it and/or modify it under the
     33 -- terms of the GNU General Public License as published by the Free Software
     34 -- Foundation; either version 3, or (at your option) any later version.
     35 --
     36 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     37 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     38 -- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     39 --
     40 -- TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     41 --
     42 
     43 BEGIN;
     44 
     45 SET search_path TO merchant;
     46 
     47 EOF
     48 
     49 # Output procedures, stripping comments
     50 
     51 for x in $@; do
     52   echo -- generated from $x
     53   # Remove SQL comments and empty lines
     54   cat $x | sed -e "s/--.*//" | awk 'NF'
     55 done
     56 
     57 # Output epilogue
     58 
     59 cat <<'EOF'
     60 -- Epilogue
     61 DROP PROCEDURE IF EXISTS merchant_do_gc;
     62 CREATE PROCEDURE merchant_do_gc(in_now INT8)
     63 LANGUAGE plpgsql
     64 AS $$
     65 BEGIN
     66   DELETE FROM merchant_instances
     67     WHERE validation_needed
     68       AND validation_expiration < in_now;
     69   CALL merchant_statistic_amount_gc ();
     70   CALL merchant_statistic_bucket_gc ();
     71   CALL merchant_statistic_counter_gc ();
     72 
     73   DELETE FROM tan_challenges
     74     WHERE expiration_date < in_now;
     75   DELETE FROM merchant_unclaim_signatures
     76     WHERE expiration_time < in_now;
     77 END $$;
     78 COMMENT ON PROCEDURE merchant_do_gc
     79   IS 'calls all other garbage collection subroutines';
     80 
     81 COMMIT;
     82 EOF