LCOV - code coverage report
Current view: top level - auditordb - plugin_auditordb_postgres.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 178 222 80.2 %
Date: 2025-06-05 21:03:14 Functions: 11 13 84.6 %

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2014-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             :  * @file plugin_auditordb_postgres.c
      18             :  * @brief Low-level (statement-level) Postgres database access for the auditor
      19             :  * @author Christian Grothoff
      20             :  * @author Gabor X Toth
      21             :  */
      22             : #include "platform.h"
      23             : #include "taler_pq_lib.h"
      24             : #include <pthread.h>
      25             : #include <libpq-fe.h>
      26             : #include "pg_delete_auditor_closure_lag.h"
      27             : #include "pg_delete_early_aggregation.h"
      28             : #include "pg_delete_generic.h"
      29             : #include "pg_delete_pending_deposit.h"
      30             : #include "pg_delete_purse_info.h"
      31             : #include "pg_delete_reserve_in_inconsistency.h"
      32             : #include "pg_del_denomination_balance.h"
      33             : #include "pg_del_reserve_info.h"
      34             : #include "pg_get_auditor_progress.h"
      35             : #include "pg_get_balance.h"
      36             : #include "pg_get_balances.h"
      37             : #include "pg_get_denomination_balance.h"
      38             : #include "pg_get_deposit_confirmations.h"
      39             : #include "pg_get_purse_info.h"
      40             : #include "pg_get_reserve_info.h"
      41             : #include "pg_get_wire_fee_summary.h"
      42             : #include "pg_helper.h"
      43             : #include "pg_insert_auditor_progress.h"
      44             : #include "pg_insert_balance.h"
      45             : #include "pg_insert_denomination_balance.h"
      46             : #include "pg_insert_deposit_confirmation.h"
      47             : #include "pg_insert_early_aggregation.h"
      48             : #include "pg_insert_exchange_signkey.h"
      49             : #include "pg_insert_historic_denom_revenue.h"
      50             : #include "pg_insert_historic_reserve_revenue.h"
      51             : #include "pg_insert_pending_deposit.h"
      52             : #include "pg_insert_purse_info.h"
      53             : #include "pg_insert_reserve_info.h"
      54             : #include "pg_select_reserve_in_inconsistency.h"
      55             : #include "pg_select_historic_denom_revenue.h"
      56             : #include "pg_select_historic_reserve_revenue.h"
      57             : #include "pg_get_progress_points.h"
      58             : #include "pg_select_pending_deposits.h"
      59             : #include "pg_select_purse_expired.h"
      60             : #include "pg_update_generic_suppressed.h"
      61             : #include "pg_update_auditor_progress.h"
      62             : #include "pg_update_denomination_balance.h"
      63             : #include "pg_update_purse_info.h"
      64             : #include "pg_update_reserve_info.h"
      65             : #include "pg_update_wire_fee_summary.h"
      66             : #include "pg_get_amount_arithmetic_inconsistency.h"
      67             : #include "pg_get_coin_inconsistency.h"
      68             : #include "pg_get_row_inconsistency.h"
      69             : #include "pg_update_balance.h"
      70             : 
      71             : #include "pg_insert_coin_inconsistency.h"
      72             : #include "pg_insert_row_inconsistency.h"
      73             : #include "pg_insert_amount_arithmetic_inconsistency.h"
      74             : 
      75             : #include "pg_get_auditor_closure_lags.h"
      76             : #include "pg_insert_auditor_closure_lags.h"
      77             : 
      78             : #include "pg_get_emergency_by_count.h"
      79             : #include "pg_insert_emergency_by_count.h"
      80             : 
      81             : #include "pg_get_emergency.h"
      82             : #include "pg_insert_emergency.h"
      83             : 
      84             : #include "pg_get_bad_sig_losses.h"
      85             : #include "pg_insert_bad_sig_losses.h"
      86             : 
      87             : #include "pg_get_denomination_key_validity_withdraw_inconsistency.h"
      88             : #include "pg_insert_denomination_key_validity_withdraw_inconsistency.h"
      89             : 
      90             : #include "pg_get_fee_time_inconsistency.h"
      91             : #include "pg_insert_fee_time_inconsistency.h"
      92             : 
      93             : #include "pg_get_purse_not_closed_inconsistencies.h"
      94             : #include "pg_insert_purse_not_closed_inconsistencies.h"
      95             : 
      96             : #include "pg_get_reserve_balance_insufficient_inconsistency.h"
      97             : #include "pg_insert_reserve_balance_insufficient_inconsistency.h"
      98             : 
      99             : #include "pg_get_reserve_in_inconsistency.h"
     100             : #include "pg_lookup_reserve_in_inconsistency.h"
     101             : #include "pg_insert_reserve_in_inconsistency.h"
     102             : 
     103             : #include "pg_get_reserve_not_closed_inconsistency.h"
     104             : #include "pg_insert_reserve_not_closed_inconsistency.h"
     105             : 
     106             : #include "pg_get_denominations_without_sigs.h"
     107             : #include "pg_insert_denominations_without_sigs.h"
     108             : 
     109             : #include "pg_get_misattribution_in_inconsistency.h"
     110             : #include "pg_insert_misattribution_in_inconsistency.h"
     111             : 
     112             : #include "pg_get_reserves.h"
     113             : #include "pg_get_purses.h"
     114             : 
     115             : #include "pg_get_denomination_pending.h"
     116             : #include "pg_insert_denomination_pending.h"
     117             : 
     118             : #include "pg_get_exchange_signkeys.h"
     119             : 
     120             : #include "pg_get_wire_format_inconsistency.h"
     121             : #include "pg_insert_wire_format_inconsistency.h"
     122             : 
     123             : #include "pg_get_wire_out_inconsistency.h"
     124             : #include "pg_insert_wire_out_inconsistency.h"
     125             : #include "pg_delete_wire_out_inconsistency_if_matching.h"
     126             : 
     127             : #include "pg_get_reserve_balance_summary_wrong_inconsistency.h"
     128             : #include "pg_insert_reserve_balance_summary_wrong_inconsistency.h"
     129             : 
     130             : #include "pg_get_row_minor_inconsistencies.h"
     131             : #include "pg_insert_row_minor_inconsistencies.h"
     132             : 
     133             : #define LOG(kind,...) GNUNET_log_from (kind, "taler-auditordb-postgres", \
     134             :                                        __VA_ARGS__)
     135             : 
     136             : 
     137             : /**
     138             :  * Drop all auditor tables OR deletes recoverable auditor state.
     139             :  * This should only be used by testcases or when restarting the
     140             :  * auditor from scratch.
     141             :  *
     142             :  * @param cls the `struct PostgresClosure` with the plugin-specific state
     143             :  * @param drop_exchangelist drop all tables, including schema versioning
     144             :  *        and the exchange and deposit_confirmations table; NOT to be
     145             :  *        used when restarting the auditor
     146             :  * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
     147             :  */
     148             : static enum GNUNET_GenericReturnValue
     149          44 : postgres_drop_tables (void *cls,
     150             :                       bool drop_exchangelist)
     151             : {
     152          44 :   struct PostgresClosure *pc = cls;
     153             :   struct GNUNET_PQ_Context *conn;
     154             :   enum GNUNET_GenericReturnValue ret;
     155             : 
     156          44 :   conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
     157             :                                      "auditordb-postgres",
     158             :                                      NULL,
     159             :                                      NULL,
     160             :                                      NULL);
     161          44 :   if (NULL == conn)
     162           0 :     return GNUNET_SYSERR;
     163          44 :   ret = GNUNET_PQ_exec_sql (conn,
     164             :                             (drop_exchangelist) ? "drop" : "restart");
     165          44 :   GNUNET_PQ_disconnect (conn);
     166          44 :   return ret;
     167             : }
     168             : 
     169             : 
     170             : /**
     171             :  * Create the necessary tables if they are not present
     172             :  *
     173             :  * @param cls the `struct PostgresClosure` with the plugin-specific state
     174             :  * @param support_partitions true to support partitioning
     175             :  * @param num_partitions number of partitions to use
     176             :  * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
     177             :  */
     178             : static enum GNUNET_GenericReturnValue
     179          43 : postgres_create_tables (void *cls,
     180             :                         bool support_partitions,
     181             :                         uint32_t num_partitions)
     182             : {
     183          43 :   struct PostgresClosure *pc = cls;
     184          43 :   enum GNUNET_GenericReturnValue ret = GNUNET_OK;
     185             :   struct GNUNET_PQ_Context *conn;
     186          43 :   struct GNUNET_PQ_QueryParam params[] = {
     187             :     support_partitions
     188           0 :     ? GNUNET_PQ_query_param_uint32 (&num_partitions)
     189          43 :     : GNUNET_PQ_query_param_null (),
     190             :     GNUNET_PQ_query_param_end
     191             :   };
     192          43 :   struct GNUNET_PQ_PreparedStatement ps[] = {
     193          43 :     GNUNET_PQ_make_prepare ("create_tables",
     194             :                             "SELECT"
     195             :                             " auditor.do_create_tables"
     196             :                             " ($1);"),
     197             :     GNUNET_PQ_PREPARED_STATEMENT_END
     198             :   };
     199          43 :   struct GNUNET_PQ_ExecuteStatement es[] = {
     200          43 :     GNUNET_PQ_make_try_execute ("SET search_path TO auditor;"),
     201             :     GNUNET_PQ_EXECUTE_STATEMENT_END
     202             :   };
     203             : 
     204          43 :   conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
     205             :                                      "auditordb-postgres",
     206             :                                      "auditor-",
     207             :                                      es,
     208             :                                      ps);
     209          43 :   if (NULL == conn)
     210             :   {
     211           0 :     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
     212             :                 "Failed to connect to database\n");
     213           0 :     return GNUNET_SYSERR;
     214             :   }
     215          43 :   if (0 >
     216          43 :       GNUNET_PQ_eval_prepared_non_select (conn,
     217             :                                           "create_tables",
     218             :                                           params))
     219             :   {
     220           0 :     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
     221             :                 "Failed to run 'create_tables' prepared statement\n");
     222           0 :     ret = GNUNET_SYSERR;
     223             :   }
     224          43 :   if (GNUNET_OK == ret)
     225             :   {
     226          43 :     ret = GNUNET_PQ_exec_sql (conn,
     227             :                               "procedures");
     228          43 :     if (GNUNET_OK != ret)
     229           0 :       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
     230             :                   "Failed to load stored procedures\n");
     231             :   }
     232          43 :   GNUNET_PQ_disconnect (conn);
     233          43 :   return ret;
     234             : }
     235             : 
     236             : 
     237             : /**
     238             :  * Register callback to be invoked on events of type @a es.
     239             :  *
     240             :  * @param cls database context to use
     241             :  * @param es specification of the event to listen for
     242             :  * @param timeout how long to wait for the event
     243             :  * @param cb function to call when the event happens, possibly
     244             :  *         mulrewardle times (until cancel is invoked)
     245             :  * @param cb_cls closure for @a cb
     246             :  * @return handle useful to cancel the listener
     247             :  */
     248             : static struct GNUNET_DB_EventHandler *
     249          30 : postgres_event_listen (void *cls,
     250             :                        const struct GNUNET_DB_EventHeaderP *es,
     251             :                        struct GNUNET_TIME_Relative timeout,
     252             :                        GNUNET_DB_EventCallback cb,
     253             :                        void *cb_cls)
     254             : {
     255          30 :   struct PostgresClosure *pg = cls;
     256             : 
     257          30 :   return GNUNET_PQ_event_listen (pg->conn,
     258             :                                  es,
     259             :                                  timeout,
     260             :                                  cb,
     261             :                                  cb_cls);
     262             : }
     263             : 
     264             : 
     265             : /**
     266             :  * Stop notifications.
     267             :  *
     268             :  * @param eh handle to unregister.
     269             :  */
     270             : static void
     271          30 : postgres_event_listen_cancel (struct GNUNET_DB_EventHandler *eh)
     272             : {
     273          30 :   GNUNET_PQ_event_listen_cancel (eh);
     274          30 : }
     275             : 
     276             : 
     277             : /**
     278             :  * Notify all that listen on @a es of an event.
     279             :  *
     280             :  * @param cls database context to use
     281             :  * @param es specification of the event to generate
     282             :  * @param extra additional event data provided
     283             :  * @param extra_size number of bytes in @a extra
     284             :  */
     285             : static void
     286           0 : postgres_event_notify (void *cls,
     287             :                        const struct GNUNET_DB_EventHeaderP *es,
     288             :                        const void *extra,
     289             :                        size_t extra_size)
     290             : {
     291           0 :   struct PostgresClosure *pg = cls;
     292             : 
     293           0 :   return GNUNET_PQ_event_notify (pg->conn,
     294             :                                  es,
     295             :                                  extra,
     296             :                                  extra_size);
     297             : }
     298             : 
     299             : 
     300             : /**
     301             :  * Connect to the db if the connection does not exist yet.
     302             :  *
     303             :  * @param[in,out] pg the plugin-specific state
     304             :  * @return #GNUNET_OK on success
     305             :  */
     306             : static enum GNUNET_GenericReturnValue
     307         612 : setup_connection (struct PostgresClosure *pg)
     308             : {
     309         612 :   struct GNUNET_PQ_ExecuteStatement es[] = {
     310         612 :     GNUNET_PQ_make_try_execute ("SET search_path TO auditor;"),
     311             :     GNUNET_PQ_EXECUTE_STATEMENT_END
     312             :   };
     313             :   struct GNUNET_PQ_Context *db_conn;
     314             : 
     315         612 :   if (NULL != pg->conn)
     316             :   {
     317           0 :     GNUNET_PQ_reconnect_if_down (pg->conn);
     318           0 :     return GNUNET_OK;
     319             :   }
     320         612 :   db_conn = GNUNET_PQ_connect_with_cfg2 (pg->cfg,
     321             :                                          "auditordb-postgres",
     322             :                                          "auditor-",
     323             :                                          es,
     324             :                                          NULL, /* prepared statements */
     325             :                                          GNUNET_PQ_FLAG_CHECK_CURRENT);
     326         612 :   if (NULL == db_conn)
     327           0 :     return GNUNET_SYSERR;
     328         612 :   pg->conn = db_conn;
     329         612 :   pg->prep_gen++;
     330         612 :   return GNUNET_OK;
     331             : }
     332             : 
     333             : 
     334             : /**
     335             :  * Do a pre-flight check that we are not in an uncommitted transaction.
     336             :  * If we are, rollback the previous transaction and output a warning.
     337             :  *
     338             :  * @param cls the `struct PostgresClosure` with the plugin-specific state
     339             :  * @return #GNUNET_OK on success,
     340             :  *         #GNUNET_NO if we rolled back an earlier transaction
     341             :  *         #GNUNET_SYSERR if we have no DB connection
     342             :  */
     343             : static enum GNUNET_GenericReturnValue
     344        2516 : postgres_preflight (void *cls)
     345             : {
     346        2516 :   struct PostgresClosure *pg = cls;
     347        2516 :   struct GNUNET_PQ_ExecuteStatement es[] = {
     348        2516 :     GNUNET_PQ_make_execute ("ROLLBACK"),
     349             :     GNUNET_PQ_EXECUTE_STATEMENT_END
     350             :   };
     351             : 
     352        3128 :   if ( (NULL == pg->conn) &&
     353             :        (GNUNET_OK !=
     354         612 :         setup_connection (pg)) )
     355           0 :     return GNUNET_SYSERR;
     356        2516 :   if (NULL == pg->transaction_name)
     357        2516 :     return GNUNET_OK; /* all good */
     358           0 :   if (GNUNET_OK ==
     359           0 :       GNUNET_PQ_exec_statements (pg->conn,
     360             :                                  es))
     361             :   {
     362           0 :     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
     363             :                 "BUG: Preflight check rolled back transaction `%s'!\n",
     364             :                 pg->transaction_name);
     365             :   }
     366             :   else
     367             :   {
     368           0 :     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
     369             :                 "BUG: Preflight check failed to rollback transaction `%s'!\n",
     370             :                 pg->transaction_name);
     371             :   }
     372           0 :   pg->transaction_name = NULL;
     373           0 :   return GNUNET_NO;
     374             : }
     375             : 
     376             : 
     377             : /**
     378             :  * Start a transaction.
     379             :  *
     380             :  * @param cls the `struct PostgresClosure` with the plugin-specific state
     381             :  * @return #GNUNET_OK on success
     382             :  */
     383             : static enum GNUNET_GenericReturnValue
     384         576 : postgres_start (void *cls)
     385             : {
     386         576 :   struct PostgresClosure *pg = cls;
     387         576 :   struct GNUNET_PQ_ExecuteStatement es[] = {
     388         576 :     GNUNET_PQ_make_execute ("START TRANSACTION ISOLATION LEVEL SERIALIZABLE"),
     389             :     GNUNET_PQ_EXECUTE_STATEMENT_END
     390             :   };
     391             : 
     392         576 :   postgres_preflight (cls);
     393         576 :   if (GNUNET_OK !=
     394         576 :       GNUNET_PQ_exec_statements (pg->conn,
     395             :                                  es))
     396             :   {
     397           0 :     TALER_LOG_ERROR ("Failed to start transaction\n");
     398           0 :     GNUNET_break (0);
     399           0 :     return GNUNET_SYSERR;
     400             :   }
     401         576 :   return GNUNET_OK;
     402             : }
     403             : 
     404             : 
     405             : /**
     406             :  * Roll back the current transaction of a database connection.
     407             :  *
     408             :  * @param cls the `struct PostgresClosure` with the plugin-specific state
     409             :  */
     410             : static void
     411          67 : postgres_rollback (void *cls)
     412             : {
     413          67 :   struct PostgresClosure *pg = cls;
     414          67 :   struct GNUNET_PQ_ExecuteStatement es[] = {
     415          67 :     GNUNET_PQ_make_execute ("ROLLBACK"),
     416             :     GNUNET_PQ_EXECUTE_STATEMENT_END
     417             :   };
     418             : 
     419          67 :   GNUNET_break (GNUNET_OK ==
     420             :                 GNUNET_PQ_exec_statements (pg->conn,
     421             :                                            es));
     422          67 : }
     423             : 
     424             : 
     425             : /**
     426             :  * Commit the current transaction of a database connection.
     427             :  *
     428             :  * @param cls the `struct PostgresClosure` with the plugin-specific state
     429             :  * @return transaction status code
     430             :  */
     431             : static enum GNUNET_DB_QueryStatus
     432         510 : postgres_commit (void *cls)
     433             : {
     434         510 :   struct PostgresClosure *pg = cls;
     435         510 :   struct GNUNET_PQ_QueryParam params[] = {
     436             :     GNUNET_PQ_query_param_end
     437             :   };
     438             : 
     439         510 :   PREPARE (pg,
     440             :            "do_commit",
     441             :            "COMMIT");
     442         510 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     443             :                                              "do_commit",
     444             :                                              params);
     445             : }
     446             : 
     447             : 
     448             : /**
     449             :  * Function called to perform "garbage collection" on the
     450             :  * database, expiring records we no longer require.
     451             :  *
     452             :  * @param cls closure
     453             :  * @return #GNUNET_OK on success,
     454             :  *         #GNUNET_SYSERR on DB errors
     455             :  */
     456             : static enum GNUNET_GenericReturnValue
     457           0 : postgres_gc (void *cls)
     458             : {
     459           0 :   struct PostgresClosure *pg = cls;
     460           0 :   struct GNUNET_TIME_Absolute now = {0};
     461           0 :   struct GNUNET_PQ_QueryParam params_time[] = {
     462           0 :     GNUNET_PQ_query_param_absolute_time (&now),
     463             :     GNUNET_PQ_query_param_end
     464             :   };
     465             :   struct GNUNET_PQ_Context *conn;
     466             :   enum GNUNET_DB_QueryStatus qs;
     467           0 :   struct GNUNET_PQ_PreparedStatement ps[] = {
     468             :     GNUNET_PQ_PREPARED_STATEMENT_END
     469             :   };
     470           0 :   struct GNUNET_PQ_ExecuteStatement es[] = {
     471           0 :     GNUNET_PQ_make_try_execute ("SET search_path TO auditor;"),
     472             :     GNUNET_PQ_EXECUTE_STATEMENT_END
     473             :   };
     474             : 
     475           0 :   now = GNUNET_TIME_absolute_get ();
     476           0 :   conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
     477             :                                      "auditordb-postgres",
     478             :                                      NULL,
     479             :                                      es,
     480             :                                      ps);
     481           0 :   if (NULL == conn)
     482           0 :     return GNUNET_SYSERR;
     483           0 :   GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
     484             :               "FIXME: Auditor GC not implemented (#9433)\n");
     485           0 :   qs = GNUNET_PQ_eval_prepared_non_select (conn,
     486             :                                            "gc_auditor",
     487             :                                            params_time);
     488           0 :   GNUNET_PQ_disconnect (conn);
     489           0 :   if (0 > qs)
     490             :   {
     491           0 :     GNUNET_break (0);
     492           0 :     return GNUNET_SYSERR;
     493             :   }
     494           0 :   return GNUNET_OK;
     495             : }
     496             : 
     497             : 
     498             : /**
     499             :  * Initialize Postgres database subsystem.
     500             :  *
     501             :  * @param cls a configuration instance
     502             :  * @return NULL on error, otherwise a `struct TALER_AUDITORDB_Plugin`
     503             :  */
     504             : void *
     505             : libtaler_plugin_auditordb_postgres_init (void *cls);
     506             : 
     507             : /* Declaration used to squash compiler warning */
     508             : void *
     509         653 : libtaler_plugin_auditordb_postgres_init (void *cls)
     510             : {
     511         653 :   const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
     512             :   struct PostgresClosure *pg;
     513             :   struct TALER_AUDITORDB_Plugin *plugin;
     514             : 
     515         653 :   pg = GNUNET_new (struct PostgresClosure);
     516         653 :   pg->cfg = cfg;
     517         653 :   if (GNUNET_OK !=
     518         653 :       TALER_config_get_currency (cfg,
     519             :                                  "exchange",
     520             :                                  &pg->currency))
     521             :   {
     522           0 :     GNUNET_free (pg);
     523           0 :     return NULL;
     524             :   }
     525             : 
     526         653 :   plugin = GNUNET_new (struct TALER_AUDITORDB_Plugin);
     527         653 :   plugin->cls = pg;
     528         653 :   plugin->preflight = &postgres_preflight;
     529         653 :   plugin->drop_tables = &postgres_drop_tables;
     530         653 :   plugin->create_tables = &postgres_create_tables;
     531         653 :   plugin->event_listen = &postgres_event_listen;
     532         653 :   plugin->event_listen_cancel = &postgres_event_listen_cancel;
     533         653 :   plugin->event_notify = &postgres_event_notify;
     534         653 :   plugin->start = &postgres_start;
     535         653 :   plugin->commit = &postgres_commit;
     536         653 :   plugin->rollback = &postgres_rollback;
     537         653 :   plugin->gc = &postgres_gc;
     538             : 
     539             :   plugin->get_auditor_progress
     540         653 :     = &TAH_PG_get_auditor_progress;
     541             : 
     542         653 :   plugin->get_balance = &TAH_PG_get_balance;
     543         653 :   plugin->get_balances = &TAH_PG_get_balances;
     544             : 
     545             :   plugin->insert_auditor_progress
     546         653 :     = &TAH_PG_insert_auditor_progress;
     547             :   plugin->insert_balance
     548         653 :     = &TAH_PG_insert_balance;
     549             :   plugin->update_generic_suppressed
     550         653 :     = &TAH_PG_update_generic_suppressed;
     551             :   plugin->delete_generic
     552         653 :     = &TAH_PG_delete_generic;
     553             :   plugin->delete_wire_out_inconsistency_if_matching
     554         653 :     = &TAH_PG_delete_wire_out_inconsistency_if_matching;
     555             : 
     556             :   plugin->delete_auditor_closure_lag
     557         653 :     = &TAH_PG_delete_auditor_closure_lag;
     558             : 
     559             :   plugin->update_auditor_progress
     560         653 :     = &TAH_PG_update_auditor_progress;
     561             :   plugin->insert_deposit_confirmation
     562         653 :     = &TAH_PG_insert_deposit_confirmation;
     563             :   plugin->get_deposit_confirmations
     564         653 :     = &TAH_PG_get_deposit_confirmations;
     565             : 
     566             :   plugin->get_amount_arithmetic_inconsistency
     567         653 :     = &TAH_PG_get_amount_arithmetic_inconsistency;
     568             :   plugin->get_coin_inconsistency
     569         653 :     = &TAH_PG_get_coin_inconsistency;
     570             :   plugin->get_row_inconsistency
     571         653 :     = &TAH_PG_get_row_inconsistency;
     572             : 
     573             : 
     574             :   plugin->insert_amount_arithmetic_inconsistency
     575         653 :     = &TAH_PG_insert_amount_arithmetic_inconsistency;
     576             :   plugin->insert_coin_inconsistency
     577         653 :     = &TAH_PG_insert_coin_inconsistency;
     578             :   plugin->insert_row_inconsistency
     579         653 :     = &TAH_PG_insert_row_inconsistency;
     580             : 
     581             :   plugin->insert_reserve_info
     582         653 :     = &TAH_PG_insert_reserve_info;
     583             :   plugin->update_reserve_info
     584         653 :     = &TAH_PG_update_reserve_info;
     585             :   plugin->get_reserve_info
     586         653 :     = &TAH_PG_get_reserve_info;
     587             :   plugin->del_reserve_info
     588         653 :     = &TAH_PG_del_reserve_info;
     589             : 
     590             :   plugin->insert_pending_deposit
     591         653 :     = &TAH_PG_insert_pending_deposit;
     592             :   plugin->select_pending_deposits
     593         653 :     = &TAH_PG_select_pending_deposits;
     594             :   plugin->delete_pending_deposit
     595         653 :     = &TAH_PG_delete_pending_deposit;
     596             : 
     597             :   plugin->insert_purse_info
     598         653 :     = &TAH_PG_insert_purse_info;
     599             :   plugin->update_purse_info
     600         653 :     = &TAH_PG_update_purse_info;
     601             :   plugin->get_purse_info
     602         653 :     = &TAH_PG_get_purse_info;
     603             :   plugin->delete_purse_info
     604         653 :     = &TAH_PG_delete_purse_info;
     605             :   plugin->select_purse_expired
     606         653 :     = &TAH_PG_select_purse_expired;
     607             : 
     608             :   plugin->insert_denomination_balance
     609         653 :     = &TAH_PG_insert_denomination_balance;
     610             :   plugin->update_denomination_balance
     611         653 :     = &TAH_PG_update_denomination_balance;
     612             :   plugin->del_denomination_balance
     613         653 :     = &TAH_PG_del_denomination_balance;
     614             :   plugin->get_denomination_balance
     615         653 :     = &TAH_PG_get_denomination_balance;
     616             : 
     617             :   plugin->insert_historic_denom_revenue
     618         653 :     = &TAH_PG_insert_historic_denom_revenue;
     619             : 
     620             :   plugin->select_historic_denom_revenue
     621         653 :     = &TAH_PG_select_historic_denom_revenue;
     622             : 
     623             :   plugin->insert_historic_reserve_revenue
     624         653 :     = &TAH_PG_insert_historic_reserve_revenue;
     625             :   plugin->select_historic_reserve_revenue
     626         653 :     = &TAH_PG_select_historic_reserve_revenue;
     627             : 
     628             : 
     629         653 :   plugin->insert_emergency = &TAH_PG_insert_emergency;
     630         653 :   plugin->get_emergency = &TAH_PG_get_emergency;
     631             : 
     632         653 :   plugin->insert_emergency_by_count = &TAH_PG_insert_emergency_by_count;
     633         653 :   plugin->get_emergency_by_count = &TAH_PG_get_emergency_by_count;
     634             : 
     635             : 
     636         653 :   plugin->insert_denomination_key_validity_withdraw_inconsistency =
     637             :     &TAH_PG_insert_denomination_key_validity_withdraw_inconsistency;
     638         653 :   plugin->get_denomination_key_validity_withdraw_inconsistency =
     639             :     &TAH_PG_get_denomination_key_validity_withdraw_inconsistency;
     640             : 
     641         653 :   plugin->insert_purse_not_closed_inconsistencies =
     642             :     &TAH_PG_insert_purse_not_closed_inconsistencies;
     643         653 :   plugin->get_purse_not_closed_inconsistencies =
     644             :     &TAH_PG_get_purse_not_closed_inconsistencies;
     645             : 
     646             : 
     647         653 :   plugin->insert_reserve_balance_insufficient_inconsistency =
     648             :     &TAH_PG_insert_reserve_balance_insufficient_inconsistency;
     649         653 :   plugin->get_reserve_balance_insufficient_inconsistency =
     650             :     &TAH_PG_get_reserve_balance_insufficient_inconsistency;
     651             : 
     652         653 :   plugin->insert_bad_sig_losses = &TAH_PG_insert_bad_sig_losses;
     653         653 :   plugin->get_bad_sig_losses = &TAH_PG_get_bad_sig_losses;
     654             : 
     655         653 :   plugin->insert_auditor_closure_lags = &TAH_PG_insert_auditor_closure_lags;
     656         653 :   plugin->get_auditor_closure_lags = &TAH_PG_get_auditor_closure_lags;
     657             : 
     658         653 :   plugin->insert_reserve_in_inconsistency =
     659             :     &TAH_PG_insert_reserve_in_inconsistency;
     660             :   plugin->get_reserve_in_inconsistency
     661         653 :     = &TAH_PG_get_reserve_in_inconsistency;
     662             :   plugin->lookup_reserve_in_inconsistency
     663         653 :     = &TAH_PG_lookup_reserve_in_inconsistency;
     664             : 
     665         653 :   plugin->insert_reserve_not_closed_inconsistency =
     666             :     &TAH_PG_insert_reserve_not_closed_inconsistency;
     667         653 :   plugin->get_reserve_not_closed_inconsistency =
     668             :     &TAH_PG_get_reserve_not_closed_inconsistency;
     669             : 
     670         653 :   plugin->insert_denominations_without_sigs =
     671             :     &TAH_PG_insert_denominations_without_sigs;
     672         653 :   plugin->get_denominations_without_sigs =
     673             :     &TAH_PG_get_denominations_without_sigs;
     674             : 
     675             :   plugin->get_progress_points
     676         653 :     = &TAH_PG_get_progress_points;
     677             : 
     678             : 
     679         653 :   plugin->insert_misattribution_in_inconsistency =
     680             :     &TAH_PG_insert_misattribution_in_inconsistency;
     681         653 :   plugin->get_misattribution_in_inconsistency =
     682             :     &TAH_PG_get_misattribution_in_inconsistency;
     683             : 
     684         653 :   plugin->get_reserves = &TAH_PG_get_reserves;
     685         653 :   plugin->get_purses = &TAH_PG_get_purses;
     686             : 
     687         653 :   plugin->insert_denomination_pending = &TAH_PG_insert_denomination_pending;
     688         653 :   plugin->get_denomination_pending = &TAH_PG_get_denomination_pending;
     689             : 
     690         653 :   plugin->get_exchange_signkeys = &TAH_PG_get_exchange_signkeys;
     691             : 
     692         653 :   plugin->insert_wire_format_inconsistency =
     693             :     &TAH_PG_insert_wire_format_inconsistency;
     694         653 :   plugin->get_wire_format_inconsistency = &TAH_PG_get_wire_format_inconsistency;
     695             : 
     696             :   plugin->insert_early_aggregation
     697         653 :     = &TAH_PG_insert_early_aggregation;
     698             :   plugin->delete_early_aggregation
     699         653 :     = &TAH_PG_delete_early_aggregation;
     700             : 
     701             :   plugin->insert_wire_out_inconsistency
     702         653 :     = &TAH_PG_insert_wire_out_inconsistency;
     703             :   plugin->get_wire_out_inconsistency
     704         653 :     = &TAH_PG_get_wire_out_inconsistency;
     705             :   plugin->select_reserve_in_inconsistency
     706         653 :     = &TAH_PG_select_reserve_in_inconsistency;
     707             :   plugin->delete_reserve_in_inconsistency
     708         653 :     = &TAH_PG_delete_reserve_in_inconsistency;
     709             : 
     710         653 :   plugin->insert_reserve_balance_summary_wrong_inconsistency =
     711             :     &TAH_PG_insert_reserve_balance_summary_wrong_inconsistency;
     712         653 :   plugin->get_reserve_balance_summary_wrong_inconsistency =
     713             :     &TAH_PG_get_reserve_balance_summary_wrong_inconsistency;
     714             : 
     715             : 
     716         653 :   plugin->insert_row_minor_inconsistencies =
     717             :     &TAH_PG_insert_row_minor_inconsistencies;
     718         653 :   plugin->get_row_minor_inconsistencies = &TAH_PG_get_row_minor_inconsistencies;
     719             : 
     720         653 :   plugin->insert_fee_time_inconsistency = &TAH_PG_insert_fee_time_inconsistency;
     721         653 :   plugin->get_fee_time_inconsistency = &TAH_PG_get_fee_time_inconsistency;
     722             : 
     723             :   plugin->update_balance
     724         653 :     = &TAH_PG_update_balance;
     725             : 
     726             :   plugin->insert_exchange_signkey
     727         653 :     = &TAH_PG_insert_exchange_signkey;
     728             : 
     729         653 :   return plugin;
     730             : }
     731             : 
     732             : 
     733             : /**
     734             :  * Shutdown Postgres database subsystem.
     735             :  *
     736             :  * @param cls a `struct TALER_AUDITORDB_Plugin`
     737             :  * @return NULL (always)
     738             :  */
     739             : void *
     740             : libtaler_plugin_auditordb_postgres_done (void *cls);
     741             : 
     742             : /* Declaration used to squash compiler warning */
     743             : void *
     744         653 : libtaler_plugin_auditordb_postgres_done (void *cls)
     745             : {
     746         653 :   struct TALER_AUDITORDB_Plugin *plugin = cls;
     747         653 :   struct PostgresClosure *pg = plugin->cls;
     748             : 
     749         653 :   if (NULL != pg->conn)
     750         612 :     GNUNET_PQ_disconnect (pg->conn);
     751         653 :   GNUNET_free (pg->currency);
     752         653 :   GNUNET_free (pg);
     753         653 :   GNUNET_free (plugin);
     754         653 :   return NULL;
     755             : }
     756             : 
     757             : 
     758             : /* end of plugin_auditordb_postgres.c */

Generated by: LCOV version 1.16