LCOV - code coverage report
Current view: top level - backenddb - plugin_merchantdb_postgres.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 96.8 % 219 212
Test Date: 2025-10-21 13:10:50 Functions: 100.0 % 10 10

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

Generated by: LCOV version 2.0-1