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

Generated by: LCOV version 2.0-1