exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

pg_inject_auditor_triggers.c (1959B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 2022 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  * @file exchangedb/pg_inject_auditor_triggers.c
     18  * @brief Implementation of the inject_auditor_triggers function for Postgres
     19  * @author Christian Grothoff
     20  */
     21 #include "taler/taler_pq_lib.h"
     22 #include "taler/exchange-database/gc.h"
     23 #include "helper.h"
     24 #include "taler/exchange-database/inject_auditor_triggers.h"
     25 
     26 
     27 /**
     28  * Function called to inject auditor triggers into the
     29  * database, triggering the real-time auditor upon
     30  * relevant INSERTs.
     31  *
     32  * @param pg the database context
     33  * @return #GNUNET_OK on success,
     34  *         #GNUNET_SYSERR on DB errors
     35  */
     36 enum GNUNET_GenericReturnValue
     37 TALER_EXCHANGEDB_inject_auditor_triggers (struct
     38                                           TALER_EXCHANGEDB_PostgresContext *pg)
     39 {
     40   struct GNUNET_PQ_Context *conn;
     41   struct GNUNET_PQ_ExecuteStatement es[] = {
     42     GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"),
     43     GNUNET_PQ_EXECUTE_STATEMENT_END
     44   };
     45 
     46   conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
     47                                      "exchangedb-postgres",
     48                                      "auditor-triggers-",
     49                                      es,
     50                                      NULL);
     51   if (NULL == conn)
     52     return GNUNET_SYSERR;
     53   GNUNET_PQ_disconnect (conn);
     54   return GNUNET_OK;
     55 }