sync

Backup service to store encrypted wallet databases (experimental)
Log | Files | Refs | Submodules | README | LICENSE

syncdb_lookup_account_TR.sql (1424B)


      1 --
      2 -- This file is part of TALER
      3 -- Copyright (C) 2024 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 
     18 DROP FUNCTION IF EXISTS sync_do_lookup_account;
     19 CREATE FUNCTION sync_do_lookup_account (
     20   IN in_account_pub BYTEA,
     21   OUT out_backup_hash BYTEA,
     22   OUT out_payment_required BOOLEAN,
     23   OUT out_no_backup BOOLEAN)
     24 LANGUAGE plpgsql
     25 AS $$
     26 BEGIN
     27   out_payment_required = FALSE;
     28   out_no_backup = FALSE;
     29 
     30   -- Check if backup exists
     31   SELECT backup_hash
     32     INTO out_backup_hash
     33     FROM backups
     34    WHERE account_pub=in_account_pub;
     35 
     36   IF FOUND
     37   THEN
     38     RETURN;
     39   END IF;
     40 
     41   -- No backup; check if account exists
     42   PERFORM 1
     43     FROM accounts
     44    WHERE account_pub=in_account_pub;
     45 
     46   IF NOT FOUND
     47   THEN
     48     out_payment_required = TRUE;
     49     RETURN;
     50   END IF;
     51 
     52   -- Account exists but no backup
     53   out_no_backup = TRUE;
     54 END $$;