sync

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

syncdb_store_object_TR.sql (1577B)


      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 
     17 DROP FUNCTION IF EXISTS sync_do_store_object;
     18 CREATE FUNCTION sync_do_store_object (
     19   IN in_account_pub BYTEA,
     20   IN in_uid BYTEA,
     21   IN in_object_hash BYTEA,
     22   IN in_expiration_date INT8,
     23   IN in_data_blob BYTEA,
     24   OUT out_account_missing BOOLEAN,
     25   OUT out_inserted BOOLEAN)
     26 LANGUAGE plpgsql
     27 AS $$
     28 BEGIN
     29   out_account_missing := FALSE;
     30   out_inserted := FALSE;
     31 
     32   SELECT a.out_account_missing
     33     INTO out_account_missing
     34     FROM sync_check_account_payment(in_account_pub) AS a;
     35   IF out_account_missing
     36   THEN
     37     RETURN;
     38   END IF;
     39 
     40   INSERT INTO objects
     41     (uid
     42     ,account_pub
     43     ,object_hash
     44     ,expiration_date
     45     ,data_blob)
     46   VALUES
     47     (in_uid
     48     ,in_account_pub
     49     ,in_object_hash
     50     ,in_expiration_date
     51     ,in_data_blob)
     52   ON CONFLICT DO NOTHING;
     53 
     54   IF NOT FOUND
     55   THEN
     56     out_inserted := FALSE;
     57     RETURN;
     58   END IF;
     59 
     60   out_inserted := TRUE;
     61 END $$;