LCOV - code coverage report
Current view: top level - backenddb - plugin_merchantdb_postgres.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 203 210 96.7 %
Date: 2025-06-23 16:22:09 Functions: 10 10 100.0 %

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   (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 Lesser 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_merchantdb_postgres.c
      18             :  * @brief database helper functions for postgres used by the merchant
      19             :  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
      20             :  * @author Christian Grothoff
      21             :  * @author Marcello Stanisci
      22             :  * @author Priscilla Huang
      23             :  * @author Iván Ávalos
      24             :  */
      25             : #include "platform.h"
      26             : #include <gnunet/gnunet_util_lib.h>
      27             : #include <gnunet/gnunet_pq_lib.h>
      28             : #include <taler/taler_util.h>
      29             : #include <taler/taler_pq_lib.h>
      30             : #include <taler/taler_json_lib.h>
      31             : #include <taler/taler_mhd_lib.h>
      32             : #include "taler_merchantdb_plugin.h"
      33             : #include "pg_helper.h"
      34             : #include "pg_gc.h"
      35             : #include "pg_insert_otp.h"
      36             : #include "pg_get_kyc_status.h"
      37             : #include "pg_get_kyc_limits.h"
      38             : #include "pg_delete_otp.h"
      39             : #include "pg_update_otp.h"
      40             : #include "pg_account_kyc_set_failed.h"
      41             : #include "pg_select_otp.h"
      42             : #include "pg_select_otp_serial.h"
      43             : #include "pg_insert_login_token.h"
      44             : #include "pg_delete_login_token.h"
      45             : #include "pg_select_login_token.h"
      46             : #include "pg_insert_account.h"
      47             : #include "pg_update_account.h"
      48             : #include "pg_lookup_instances.h"
      49             : #include "pg_lookup_transfers.h"
      50             : #include "pg_lookup_pending_deposits.h"
      51             : #include "pg_lookup_categories.h"
      52             : #include "pg_select_category.h"
      53             : #include "pg_update_category.h"
      54             : #include "pg_insert_category.h"
      55             : #include "pg_delete_category.h"
      56             : #include "pg_update_wirewatch_progress.h"
      57             : #include "pg_select_wirewatch_accounts.h"
      58             : #include "pg_select_open_transfers.h"
      59             : #include "pg_delete_exchange_accounts.h"
      60             : #include "pg_select_accounts_by_exchange.h"
      61             : #include "pg_insert_exchange_account.h"
      62             : #include "pg_lookup_instance_auth.h"
      63             : #include "pg_lookup_otp_devices.h"
      64             : #include "pg_update_transfer_status.h"
      65             : #include "pg_insert_instance.h"
      66             : #include "pg_account_kyc_set_status.h"
      67             : #include "pg_account_kyc_get_status.h"
      68             : #include "pg_delete_instance_private_key.h"
      69             : #include "pg_select_category_by_name.h"
      70             : #include "pg_purge_instance.h"
      71             : #include "pg_update_instance.h"
      72             : #include "pg_update_instance_auth.h"
      73             : #include "pg_inactivate_account.h"
      74             : #include "pg_activate_account.h"
      75             : #include "pg_lookup_products.h"
      76             : #include "pg_lookup_all_products.h"
      77             : #include "pg_lookup_product.h"
      78             : #include "pg_delete_product.h"
      79             : #include "pg_insert_product.h"
      80             : #include "pg_update_product.h"
      81             : #include "pg_lookup_token_family_keys.h"
      82             : #include "pg_lock_product.h"
      83             : #include "pg_expire_locks.h"
      84             : #include "pg_delete_order.h"
      85             : #include "pg_lookup_order.h"
      86             : #include "pg_lookup_order_summary.h"
      87             : #include "pg_lookup_orders.h"
      88             : #include "pg_insert_order.h"
      89             : #include "pg_unlock_inventory.h"
      90             : #include "pg_insert_order_lock.h"
      91             : #include "pg_lookup_contract_terms3.h"
      92             : #include "pg_lookup_contract_terms2.h"
      93             : #include "pg_lookup_contract_terms.h"
      94             : #include "pg_insert_contract_terms.h"
      95             : #include "pg_update_contract_terms.h"
      96             : #include "pg_delete_contract_terms.h"
      97             : #include "pg_delete_template.h"
      98             : #include "pg_insert_template.h"
      99             : #include "pg_update_template.h"
     100             : #include "pg_lookup_templates.h"
     101             : #include "pg_lookup_template.h"
     102             : #include "pg_lookup_deposits.h"
     103             : #include "pg_insert_exchange_signkey.h"
     104             : #include "pg_insert_deposit.h"
     105             : #include "pg_insert_deposit_confirmation.h"
     106             : #include "pg_lookup_refunds.h"
     107             : #include "pg_mark_contract_paid.h"
     108             : #include "pg_select_account_by_uri.h"
     109             : #include "pg_refund_coin.h"
     110             : #include "pg_lookup_order_status.h"
     111             : #include "pg_lookup_order_status_by_serial.h"
     112             : #include "pg_lookup_deposits_by_order.h"
     113             : #include "pg_lookup_transfer_details_by_order.h"
     114             : #include "pg_mark_order_wired.h"
     115             : #include "pg_lookup_refunds_detailed.h"
     116             : #include "pg_insert_refund_proof.h"
     117             : #include "pg_lookup_refund_proof.h"
     118             : #include "pg_lookup_order_by_fulfillment.h"
     119             : #include "pg_delete_transfer.h"
     120             : #include "pg_check_transfer_exists.h"
     121             : #include "pg_lookup_account.h"
     122             : #include "pg_lookup_wire_fee.h"
     123             : #include "pg_lookup_deposits_by_contract_and_coin.h"
     124             : #include "pg_lookup_transfer.h"
     125             : #include "pg_lookup_transfer_summary.h"
     126             : #include "pg_lookup_transfer_details.h"
     127             : #include "pg_lookup_webhooks.h"
     128             : #include "pg_lookup_webhook.h"
     129             : #include "pg_delete_webhook.h"
     130             : #include "pg_insert_webhook.h"
     131             : #include "pg_update_webhook.h"
     132             : #include "pg_lookup_webhook_by_event.h"
     133             : #include "pg_delete_pending_webhook.h"
     134             : #include "pg_insert_pending_webhook.h"
     135             : #include "pg_update_pending_webhook.h"
     136             : #include "pg_lookup_pending_webhooks.h"
     137             : #include "pg_update_deposit_confirmation_status.h"
     138             : #include "pg_set_transfer_status_to_confirmed.h"
     139             : #include "pg_insert_exchange_keys.h"
     140             : #include "pg_select_exchange_keys.h"
     141             : #include "pg_insert_deposit_to_transfer.h"
     142             : #include "pg_increase_refund.h"
     143             : #include "pg_select_account.h"
     144             : #include "pg_select_accounts.h"
     145             : #include "pg_insert_transfer.h"
     146             : #include "pg_insert_transfer_details.h"
     147             : #include "pg_store_wire_fee_by_exchange.h"
     148             : #include "pg_insert_token_family.h"
     149             : #include "pg_lookup_token_family.h"
     150             : #include "pg_lookup_token_families.h"
     151             : #include "pg_delete_token_family.h"
     152             : #include "pg_update_token_family.h"
     153             : #include "pg_insert_token_family_key.h"
     154             : #include "pg_lookup_token_family_key.h"
     155             : #include "pg_insert_spent_token.h"
     156             : #include "pg_insert_issued_token.h"
     157             : #include "pg_lookup_spent_tokens_by_order.h"
     158             : #include "pg_lookup_statistics_amount_by_bucket.h"
     159             : #include "pg_lookup_statistics_amount_by_interval.h"
     160             : #include "pg_lookup_statistics_counter_by_bucket.h"
     161             : #include "pg_lookup_statistics_counter_by_interval.h"
     162             : 
     163             : 
     164             : /**
     165             :  * How often do we re-try if we run into a DB serialization error?
     166             :  */
     167             : #define MAX_RETRIES 3
     168             : 
     169             : 
     170             : /**
     171             :  * Drop all Taler tables.  This should only be used by testcases.
     172             :  *
     173             :  * @param cls the `struct PostgresClosure` with the plugin-specific state
     174             :  * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
     175             :  */
     176             : static enum GNUNET_GenericReturnValue
     177          15 : postgres_drop_tables (void *cls)
     178             : {
     179          15 :   struct PostgresClosure *pc = cls;
     180             :   struct GNUNET_PQ_Context *conn;
     181             :   enum GNUNET_GenericReturnValue ret;
     182             : 
     183          15 :   conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
     184             :                                      "merchantdb-postgres",
     185             :                                      NULL,
     186             :                                      NULL,
     187             :                                      NULL);
     188          15 :   if (NULL == conn)
     189           0 :     return GNUNET_SYSERR;
     190          15 :   ret = GNUNET_PQ_exec_sql (conn,
     191             :                             "drop");
     192          15 :   GNUNET_PQ_disconnect (conn);
     193          15 :   return ret;
     194             : }
     195             : 
     196             : 
     197             : /**
     198             :  * Initialize tables.
     199             :  *
     200             :  * @param cls the `struct PostgresClosure` with the plugin-specific state
     201             :  * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
     202             :  */
     203             : static enum GNUNET_GenericReturnValue
     204          15 : postgres_create_tables (void *cls)
     205             : {
     206          15 :   struct PostgresClosure *pc = cls;
     207             :   struct GNUNET_PQ_Context *conn;
     208          15 :   struct GNUNET_PQ_ExecuteStatement es[] = {
     209          15 :     GNUNET_PQ_make_try_execute ("SET search_path TO merchant;"),
     210             :     GNUNET_PQ_EXECUTE_STATEMENT_END
     211             :   };
     212             :   enum GNUNET_GenericReturnValue ret;
     213             : 
     214          15 :   conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
     215             :                                      "merchantdb-postgres",
     216             :                                      "merchant-",
     217             :                                      es,
     218             :                                      NULL);
     219          15 :   if (NULL == conn)
     220           1 :     return GNUNET_SYSERR;
     221          14 :   ret = GNUNET_PQ_exec_sql (conn,
     222             :                             "procedures");
     223          14 :   GNUNET_PQ_disconnect (conn);
     224          14 :   return ret;
     225             : }
     226             : 
     227             : 
     228             : /**
     229             :  * Register callback to be invoked on events of type @a es.
     230             :  *
     231             :  * @param cls database context to use
     232             :  * @param es specification of the event to listen for
     233             :  * @param timeout how long to wait for the event
     234             :  * @param cb function to call when the event happens, possibly
     235             :  *         multiple times (until cancel is invoked)
     236             :  * @param cb_cls closure for @a cb
     237             :  * @return handle useful to cancel the listener
     238             :  */
     239             : static struct GNUNET_DB_EventHandler *
     240         164 : postgres_event_listen (void *cls,
     241             :                        const struct GNUNET_DB_EventHeaderP *es,
     242             :                        struct GNUNET_TIME_Relative timeout,
     243             :                        GNUNET_DB_EventCallback cb,
     244             :                        void *cb_cls)
     245             : {
     246         164 :   struct PostgresClosure *pg = cls;
     247             : 
     248         164 :   return GNUNET_PQ_event_listen (pg->conn,
     249             :                                  es,
     250             :                                  timeout,
     251             :                                  cb,
     252             :                                  cb_cls);
     253             : }
     254             : 
     255             : 
     256             : /**
     257             :  * Stop notifications.
     258             :  *
     259             :  * @param eh handle to unregister.
     260             :  */
     261             : static void
     262         164 : postgres_event_listen_cancel (struct GNUNET_DB_EventHandler *eh)
     263             : {
     264         164 :   GNUNET_PQ_event_listen_cancel (eh);
     265         164 : }
     266             : 
     267             : 
     268             : /**
     269             :  * Notify all that listen on @a es of an event.
     270             :  *
     271             :  * @param cls database context to use
     272             :  * @param es specification of the event to generate
     273             :  * @param extra additional event data provided
     274             :  * @param extra_size number of bytes in @a extra
     275             :  */
     276             : static void
     277         425 : postgres_event_notify (void *cls,
     278             :                        const struct GNUNET_DB_EventHeaderP *es,
     279             :                        const void *extra,
     280             :                        size_t extra_size)
     281             : {
     282         425 :   struct PostgresClosure *pg = cls;
     283             : 
     284         425 :   return GNUNET_PQ_event_notify (pg->conn,
     285             :                                  es,
     286             :                                  extra,
     287             :                                  extra_size);
     288             : }
     289             : 
     290             : 
     291             : void
     292        1517 : postgres_preflight (void *cls)
     293             : {
     294        1517 :   struct PostgresClosure *pg = cls;
     295             : 
     296        1517 :   if (NULL == pg->transaction_name)
     297        1517 :     return; /* all good */
     298           0 :   GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
     299             :               "BUG: Preflight check detected running transaction `%s'!\n",
     300             :               pg->transaction_name);
     301           0 :   GNUNET_assert (0);
     302             : }
     303             : 
     304             : 
     305             : void
     306        3124 : check_connection (struct PostgresClosure *pg)
     307             : {
     308        3124 :   if (NULL != pg->transaction_name)
     309        1364 :     return;
     310        1760 :   GNUNET_PQ_reconnect_if_down (pg->conn);
     311             : }
     312             : 
     313             : 
     314             : /**
     315             :  * Establish connection to the database.
     316             :  *
     317             :  * @param cls plugin context
     318             :  * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
     319             :  */
     320             : static enum GNUNET_GenericReturnValue
     321          77 : postgres_connect (void *cls)
     322             : {
     323          77 :   struct PostgresClosure *pg = cls;
     324          77 :   struct GNUNET_PQ_ExecuteStatement es[] = {
     325          77 :     GNUNET_PQ_make_try_execute ("SET search_path TO merchant;"),
     326             :     GNUNET_PQ_EXECUTE_STATEMENT_END
     327             :   };
     328             : 
     329          77 :   pg->conn = GNUNET_PQ_connect_with_cfg2 (pg->cfg,
     330             :                                           "merchantdb-postgres",
     331             :                                           "merchant-",
     332             :                                           es,
     333             :                                           NULL, /* prepared statemetns */
     334             :                                           GNUNET_PQ_FLAG_CHECK_CURRENT);
     335          77 :   pg->prep_gen++;
     336          77 :   if (NULL == pg->conn)
     337           0 :     return GNUNET_SYSERR;
     338          77 :   return GNUNET_OK;
     339             : };
     340             : 
     341             : 
     342             : /**
     343             :  * Initialize Postgres database subsystem.
     344             :  *
     345             :  * @param cls a configuration instance
     346             :  * @return NULL on error, otherwise a `struct TALER_MERCHANTDB_Plugin`
     347             :  */
     348             : void *
     349             : libtaler_plugin_merchantdb_postgres_init (void *cls);
     350             : 
     351             : /* declaration to avoid compiler warning */
     352             : void *
     353          92 : libtaler_plugin_merchantdb_postgres_init (void *cls)
     354             : {
     355          92 :   const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
     356             :   struct PostgresClosure *pg;
     357             :   struct TALER_MERCHANTDB_Plugin *plugin;
     358             : 
     359          92 :   pg = GNUNET_new (struct PostgresClosure);
     360          92 :   pg->cfg = cfg;
     361          92 :   if (GNUNET_OK !=
     362          92 :       GNUNET_CONFIGURATION_get_value_filename (cfg,
     363             :                                                "merchantdb-postgres",
     364             :                                                "SQL_DIR",
     365             :                                                &pg->sql_dir))
     366             :   {
     367           0 :     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
     368             :                                "merchantdb-postgres",
     369             :                                "SQL_DIR");
     370           0 :     GNUNET_free (pg);
     371           0 :     return NULL;
     372             :   }
     373          92 :   plugin = GNUNET_new (struct TALER_MERCHANTDB_Plugin);
     374          92 :   plugin->cls = pg;
     375          92 :   plugin->connect = &postgres_connect;
     376          92 :   plugin->create_tables = &postgres_create_tables;
     377          92 :   plugin->drop_tables = &postgres_drop_tables;
     378          92 :   plugin->event_listen = &postgres_event_listen;
     379          92 :   plugin->event_listen_cancel = &postgres_event_listen_cancel;
     380          92 :   plugin->event_notify = &postgres_event_notify;
     381          92 :   plugin->preflight = &postgres_preflight;
     382          92 :   plugin->start = &TMH_PG_start;
     383          92 :   plugin->start_read_committed = &TMH_PG_start_read_committed;
     384          92 :   plugin->rollback = &TMH_PG_rollback;
     385          92 :   plugin->commit = &TMH_PG_commit;
     386             :   plugin->insert_login_token
     387          92 :     = &TMH_PG_insert_login_token;
     388             :   plugin->delete_login_token
     389          92 :     = &TMH_PG_delete_login_token;
     390             :   plugin->select_login_token
     391          92 :     = &TMH_PG_select_login_token;
     392             :   plugin->select_account_by_uri
     393          92 :     = &TMH_PG_select_account_by_uri;
     394             :   plugin->lookup_instance_auth
     395          92 :     = &TMH_PG_lookup_instance_auth;
     396             :   plugin->insert_instance
     397          92 :     = &TMH_PG_insert_instance;
     398             :   plugin->insert_account
     399          92 :     = &TMH_PG_insert_account;
     400             :   plugin->lookup_otp_devices
     401          92 :     = &TMH_PG_lookup_otp_devices;
     402             :   plugin->delete_template
     403          92 :     = &TMH_PG_delete_template;
     404             :   plugin->insert_template
     405          92 :     = &TMH_PG_insert_template;
     406             :   plugin->update_template
     407          92 :     = &TMH_PG_update_template;
     408             :   plugin->lookup_templates
     409          92 :     = &TMH_PG_lookup_templates;
     410             :   plugin->lookup_template
     411          92 :     = &TMH_PG_lookup_template;
     412             :   plugin->update_account
     413          92 :     = &TMH_PG_update_account;
     414             :   plugin->account_kyc_set_status
     415          92 :     = &TMH_PG_account_kyc_set_status;
     416             :   plugin->account_kyc_get_status
     417          92 :     = &TMH_PG_account_kyc_get_status;
     418             :   plugin->delete_instance_private_key
     419          92 :     = &TMH_PG_delete_instance_private_key;
     420             :   plugin->purge_instance
     421          92 :     = &TMH_PG_purge_instance;
     422             :   plugin->update_instance
     423          92 :     = &TMH_PG_update_instance;
     424             :   plugin->update_instance_auth
     425          92 :     = &TMH_PG_update_instance_auth;
     426             :   plugin->activate_account
     427          92 :     = &TMH_PG_activate_account;
     428             :   plugin->inactivate_account
     429          92 :     = &TMH_PG_inactivate_account;
     430             :   plugin->update_transfer_status
     431          92 :     = &TMH_PG_update_transfer_status;
     432             :   plugin->lookup_products
     433          92 :     = &TMH_PG_lookup_products;
     434             :   plugin->lookup_all_products
     435          92 :     = &TMH_PG_lookup_all_products;
     436             :   plugin->lookup_product
     437          92 :     = &TMH_PG_lookup_product;
     438             :   plugin->delete_product
     439          92 :     = &TMH_PG_delete_product;
     440             :   plugin->insert_product
     441          92 :     = &TMH_PG_insert_product;
     442             :   plugin->update_product
     443          92 :     = &TMH_PG_update_product;
     444             :   plugin->insert_otp
     445          92 :     = &TMH_PG_insert_otp;
     446             :   plugin->delete_otp
     447          92 :     = &TMH_PG_delete_otp;
     448             :   plugin->update_otp
     449          92 :     = &TMH_PG_update_otp;
     450             :   plugin->select_otp
     451          92 :     = &TMH_PG_select_otp;
     452             :   plugin->select_otp_serial
     453          92 :     = &TMH_PG_select_otp_serial;
     454             :   plugin->lock_product
     455          92 :     = &TMH_PG_lock_product;
     456             :   plugin->expire_locks
     457          92 :     = &TMH_PG_expire_locks;
     458             :   plugin->delete_order
     459          92 :     = &TMH_PG_delete_order;
     460             :   plugin->lookup_order
     461          92 :     = &TMH_PG_lookup_order;
     462             :   plugin->lookup_order_summary
     463          92 :     = &TMH_PG_lookup_order_summary;
     464             :   plugin->lookup_orders
     465          92 :     = &TMH_PG_lookup_orders;
     466             :   plugin->insert_order
     467          92 :     = &TMH_PG_insert_order;
     468             :   plugin->unlock_inventory
     469          92 :     = &TMH_PG_unlock_inventory;
     470             :   plugin->insert_order_lock
     471          92 :     = &TMH_PG_insert_order_lock;
     472             :   plugin->lookup_contract_terms
     473          92 :     = &TMH_PG_lookup_contract_terms;
     474             :   plugin->lookup_contract_terms2
     475          92 :     = &TMH_PG_lookup_contract_terms2;
     476             :   plugin->lookup_contract_terms3
     477          92 :     = &TMH_PG_lookup_contract_terms3;
     478             :   plugin->insert_contract_terms
     479          92 :     = &TMH_PG_insert_contract_terms;
     480             :   plugin->update_contract_terms
     481          92 :     = &TMH_PG_update_contract_terms;
     482             :   plugin->delete_contract_terms
     483          92 :     = &TMH_PG_delete_contract_terms;
     484             :   plugin->lookup_deposits
     485          92 :     = &TMH_PG_lookup_deposits;
     486             :   plugin->insert_exchange_signkey
     487          92 :     = &TMH_PG_insert_exchange_signkey;
     488             :   plugin->insert_deposit_confirmation
     489          92 :     = &TMH_PG_insert_deposit_confirmation;
     490             :   plugin->insert_deposit
     491          92 :     = &TMH_PG_insert_deposit;
     492             :   plugin->lookup_refunds
     493          92 :     = &TMH_PG_lookup_refunds;
     494             :   plugin->mark_contract_paid
     495          92 :     = &TMH_PG_mark_contract_paid;
     496             :   plugin->refund_coin
     497          92 :     = &TMH_PG_refund_coin;
     498             :   plugin->lookup_order_status
     499          92 :     = &TMH_PG_lookup_order_status;
     500             :   plugin->lookup_order_status_by_serial
     501          92 :     = &TMH_PG_lookup_order_status_by_serial;
     502             :   plugin->lookup_deposits_by_order
     503          92 :     = &TMH_PG_lookup_deposits_by_order;
     504             :   plugin->lookup_transfer_details_by_order
     505          92 :     = &TMH_PG_lookup_transfer_details_by_order;
     506             :   plugin->mark_order_wired
     507          92 :     = &TMH_PG_mark_order_wired;
     508             :   plugin->increase_refund
     509          92 :     = &TMH_PG_increase_refund;
     510             :   plugin->lookup_refunds_detailed
     511          92 :     = &TMH_PG_lookup_refunds_detailed;
     512             :   plugin->insert_refund_proof
     513          92 :     = &TMH_PG_insert_refund_proof;
     514             :   plugin->lookup_refund_proof
     515          92 :     = &TMH_PG_lookup_refund_proof;
     516             :   plugin->lookup_order_by_fulfillment
     517          92 :     = &TMH_PG_lookup_order_by_fulfillment;
     518             :   plugin->delete_transfer
     519          92 :     = &TMH_PG_delete_transfer;
     520             :   plugin->check_transfer_exists
     521          92 :     = &TMH_PG_check_transfer_exists;
     522             :   plugin->lookup_account
     523          92 :     = &TMH_PG_lookup_account;
     524             :   plugin->lookup_wire_fee
     525          92 :     = &TMH_PG_lookup_wire_fee;
     526             :   plugin->lookup_deposits_by_contract_and_coin
     527          92 :     = &TMH_PG_lookup_deposits_by_contract_and_coin;
     528             :   plugin->lookup_transfer
     529          92 :     = &TMH_PG_lookup_transfer;
     530             :   plugin->set_transfer_status_to_confirmed
     531          92 :     = &TMH_PG_set_transfer_status_to_confirmed;
     532             :   plugin->lookup_transfer_summary
     533          92 :     = &TMH_PG_lookup_transfer_summary;
     534             :   plugin->lookup_transfer_details
     535          92 :     = &TMH_PG_lookup_transfer_details;
     536             :   plugin->lookup_instances
     537          92 :     = &TMH_PG_lookup_instances;
     538             :   plugin->lookup_instance
     539          92 :     = &TMH_PG_lookup_instance;
     540             :   plugin->lookup_transfers
     541          92 :     = &TMH_PG_lookup_transfers;
     542             :   plugin->update_wirewatch_progress
     543          92 :     = &TMH_PG_update_wirewatch_progress;
     544             :   plugin->select_wirewatch_accounts
     545          92 :     = &TMH_PG_select_wirewatch_accounts;
     546             :   plugin->select_account
     547          92 :     = &TMH_PG_select_account;
     548             :   plugin->select_accounts
     549          92 :     = &TMH_PG_select_accounts;
     550             :   plugin->select_open_transfers
     551          92 :     = &TMH_PG_select_open_transfers;
     552             :   plugin->insert_exchange_keys
     553          92 :     = &TMH_PG_insert_exchange_keys;
     554             :   plugin->select_exchange_keys
     555          92 :     = &TMH_PG_select_exchange_keys;
     556             :   plugin->insert_deposit_to_transfer
     557          92 :     = &TMH_PG_insert_deposit_to_transfer;
     558             :   plugin->insert_transfer
     559          92 :     = &TMH_PG_insert_transfer;
     560             :   plugin->lookup_token_family_keys
     561          92 :     = &TMH_PG_lookup_token_family_keys;
     562             :   plugin->insert_transfer_details
     563          92 :     = &TMH_PG_insert_transfer_details;
     564             :   plugin->store_wire_fee_by_exchange
     565          92 :     = &TMH_PG_store_wire_fee_by_exchange;
     566             :   plugin->lookup_webhooks
     567          92 :     = &TMH_PG_lookup_webhooks;
     568             :   plugin->lookup_webhook
     569          92 :     = &TMH_PG_lookup_webhook;
     570             :   plugin->delete_webhook
     571          92 :     = &TMH_PG_delete_webhook;
     572             :   plugin->insert_webhook
     573          92 :     = &TMH_PG_insert_webhook;
     574             :   plugin->update_webhook
     575          92 :     = &TMH_PG_update_webhook;
     576             :   plugin->lookup_pending_deposits
     577          92 :     = &TMH_PG_lookup_pending_deposits;
     578             :   plugin->lookup_webhook_by_event
     579          92 :     = &TMH_PG_lookup_webhook_by_event;
     580             :   plugin->lookup_all_webhooks
     581          92 :     = &TMH_PG_lookup_all_webhooks;
     582             :   plugin->lookup_future_webhook
     583          92 :     = &TMH_PG_lookup_future_webhook;
     584             :   plugin->lookup_pending_webhooks
     585          92 :     = &TMH_PG_lookup_pending_webhooks;
     586             :   plugin->delete_pending_webhook
     587          92 :     = &TMH_PG_delete_pending_webhook;
     588             :   plugin->insert_pending_webhook
     589          92 :     = &TMH_PG_insert_pending_webhook;
     590             :   plugin->update_pending_webhook
     591          92 :     = &TMH_PG_update_pending_webhook;
     592             :   plugin->lookup_categories
     593          92 :     = &TMH_PG_lookup_categories;
     594             :   plugin->select_category_by_name
     595          92 :     = &TMH_PG_select_category_by_name;
     596             :   plugin->get_kyc_status
     597          92 :     = &TMH_PG_get_kyc_status;
     598             :   plugin->account_kyc_set_failed
     599          92 :     = &TMH_PG_account_kyc_set_failed;
     600             :   plugin->get_kyc_limits
     601          92 :     = &TMH_PG_get_kyc_limits;
     602             :   plugin->select_category
     603          92 :     = &TMH_PG_select_category;
     604             :   plugin->update_category
     605          92 :     = &TMH_PG_update_category;
     606             :   plugin->insert_category
     607          92 :     = &TMH_PG_insert_category;
     608             :   plugin->delete_category
     609          92 :     = &TMH_PG_delete_category;
     610             :   plugin->delete_exchange_accounts
     611          92 :     = &TMH_PG_delete_exchange_accounts;
     612             :   plugin->select_accounts_by_exchange
     613          92 :     = &TMH_PG_select_accounts_by_exchange;
     614             :   plugin->insert_exchange_account
     615          92 :     = &TMH_PG_insert_exchange_account;
     616             :   plugin->insert_token_family
     617          92 :     = &TMH_PG_insert_token_family;
     618             :   plugin->lookup_token_family
     619          92 :     = &TMH_PG_lookup_token_family;
     620             :   plugin->lookup_token_families
     621          92 :     = &TMH_PG_lookup_token_families;
     622             :   plugin->delete_token_family
     623          92 :     = &TMH_PG_delete_token_family;
     624             :   plugin->update_token_family
     625          92 :     = &TMH_PG_update_token_family;
     626             :   plugin->insert_token_family_key
     627          92 :     = &TMH_PG_insert_token_family_key;
     628             :   plugin->lookup_token_family_key
     629          92 :     = &TMH_PG_lookup_token_family_key;
     630             :   plugin->update_deposit_confirmation_status
     631          92 :     = &TMH_PG_update_deposit_confirmation_status;
     632             :   plugin->insert_spent_token
     633          92 :     = &TMH_PG_insert_spent_token;
     634             :   plugin->insert_issued_token
     635          92 :     = &TMH_PG_insert_issued_token;
     636             :   plugin->lookup_spent_tokens_by_order
     637          92 :     = &TMH_PG_lookup_spent_tokens_by_order;
     638             :   plugin->lookup_statistics_amount_by_bucket
     639          92 :     = &TMH_PG_lookup_statistics_amount_by_bucket;
     640             :   plugin->lookup_statistics_counter_by_bucket
     641          92 :     = &TMH_PG_lookup_statistics_counter_by_bucket;
     642             :   plugin->lookup_statistics_counter_by_interval
     643          92 :     = &TMH_PG_lookup_statistics_counter_by_interval;
     644             :   plugin->lookup_statistics_amount_by_interval
     645          92 :     = &TMH_PG_lookup_statistics_amount_by_interval;
     646             :   plugin->gc
     647          92 :     = &TMH_PG_gc;
     648             : 
     649          92 :   return plugin;
     650             : }
     651             : 
     652             : 
     653             : /**
     654             :  * Shutdown Postgres database subsystem.
     655             :  *
     656             :  * @param cls a `struct TALER_MERCHANTDB_Plugin`
     657             :  * @return NULL (always)
     658             :  */
     659             : void *
     660             : libtaler_plugin_merchantdb_postgres_done (void *cls);
     661             : 
     662             : /* declaration to avoid compiler warning */
     663             : void *
     664          91 : libtaler_plugin_merchantdb_postgres_done (void *cls)
     665             : {
     666          91 :   struct TALER_MERCHANTDB_Plugin *plugin = cls;
     667          91 :   struct PostgresClosure *pg = plugin->cls;
     668             : 
     669          91 :   if (NULL != pg->conn)
     670             :   {
     671          77 :     GNUNET_PQ_disconnect (pg->conn);
     672          77 :     pg->conn = NULL;
     673             :   }
     674          91 :   GNUNET_free (pg->sql_dir);
     675          91 :   GNUNET_free (pg);
     676          91 :   GNUNET_free (plugin);
     677          91 :   return NULL;
     678             : }
     679             : 
     680             : 
     681             : /* end of plugin_merchantdb_postgres.c */

Generated by: LCOV version 1.16