exchange

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

pg_insert_records_by_table.c (81894B)


      1 /*
      2    This file is part of GNUnet
      3    Copyright (C) 2020-2025 Taler Systems SA
      4 
      5    GNUnet is free software: you can redistribute it and/or modify it
      6    under the terms of the GNU Affero General Public License as published
      7    by the Free Software Foundation, either version 3 of the License,
      8    or (at your option) any later version.
      9 
     10    GNUnet is distributed in the hope that it will be useful, but
     11    WITHOUT ANY WARRANTY; without even the implied warranty of
     12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13    Affero General Public License for more details.
     14 
     15    You should have received a copy of the GNU Affero General Public License
     16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18      SPDX-License-Identifier: AGPL3.0-or-later
     19  */
     20 /**
     21  * @file exchangedb/pg_insert_records_by_table.c
     22  * @brief replicate_records_by_table implementation
     23  * @author Christian Grothoff
     24  * @author Özgür Kesim
     25  */
     26 #include "taler/platform.h"
     27 #include "taler/taler_error_codes.h"
     28 #include "taler/taler_dbevents.h"
     29 #include "taler/taler_pq_lib.h"
     30 #include "pg_insert_records_by_table.h"
     31 #include "pg_helper.h"
     32 #include <gnunet/gnunet_pq_lib.h>
     33 
     34 
     35 /**
     36  * Signature of helper functions of #TEH_PG_insert_records_by_table().
     37  *
     38  * @param pg plugin context
     39  * @param td record to insert
     40  * @return transaction status code
     41  */
     42 typedef enum GNUNET_DB_QueryStatus
     43 (*InsertRecordCallback)(struct PostgresClosure *pg,
     44                         const struct TALER_EXCHANGEDB_TableData *td);
     45 
     46 
     47 /**
     48  * Function called with denominations records to insert into table.
     49  *
     50  * @param pg plugin context
     51  * @param td record to insert
     52  */
     53 static enum GNUNET_DB_QueryStatus
     54 irbt_cb_table_denominations (struct PostgresClosure *pg,
     55                              const struct TALER_EXCHANGEDB_TableData *td)
     56 {
     57   struct TALER_DenominationHashP denom_hash;
     58   struct GNUNET_PQ_QueryParam params[] = {
     59     GNUNET_PQ_query_param_uint64 (&td->serial),
     60     GNUNET_PQ_query_param_auto_from_type (&denom_hash),
     61     GNUNET_PQ_query_param_uint32 (
     62       &td->details.denominations.denom_type),
     63     GNUNET_PQ_query_param_uint32 (
     64       &td->details.denominations.age_mask),
     65     TALER_PQ_query_param_denom_pub (
     66       &td->details.denominations.denom_pub),
     67     GNUNET_PQ_query_param_auto_from_type (
     68       &td->details.denominations.master_sig),
     69     GNUNET_PQ_query_param_timestamp (
     70       &td->details.denominations.valid_from),
     71     GNUNET_PQ_query_param_timestamp (
     72       &td->details.denominations.expire_withdraw),
     73     GNUNET_PQ_query_param_timestamp (
     74       &td->details.denominations.expire_deposit),
     75     GNUNET_PQ_query_param_timestamp (
     76       &td->details.denominations.expire_legal),
     77     TALER_PQ_query_param_amount (
     78       pg->conn,
     79       &td->details.denominations.coin),
     80     TALER_PQ_query_param_amount (
     81       pg->conn,
     82       &td->details.denominations.fees.withdraw),
     83     TALER_PQ_query_param_amount (
     84       pg->conn,
     85       &td->details.denominations.fees.deposit),
     86     TALER_PQ_query_param_amount (
     87       pg->conn,
     88       &td->details.denominations.fees.refresh),
     89     TALER_PQ_query_param_amount (
     90       pg->conn,
     91       &td->details.denominations.fees.refund),
     92     GNUNET_PQ_query_param_end
     93   };
     94 
     95   PREPARE (pg,
     96            "insert_into_table_denominations",
     97            "INSERT INTO denominations"
     98            "(denominations_serial"
     99            ",denom_pub_hash"
    100            ",denom_type"
    101            ",age_mask"
    102            ",denom_pub"
    103            ",master_sig"
    104            ",valid_from"
    105            ",expire_withdraw"
    106            ",expire_deposit"
    107            ",expire_legal"
    108            ",coin"
    109            ",fee_withdraw"
    110            ",fee_deposit"
    111            ",fee_refresh"
    112            ",fee_refund"
    113            ") VALUES "
    114            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
    115            " $11, $12, $13, $14, $15);");
    116 
    117   TALER_denom_pub_hash (
    118     &td->details.denominations.denom_pub,
    119     &denom_hash);
    120 
    121   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    122                                              "insert_into_table_denominations",
    123                                              params);
    124 }
    125 
    126 
    127 /**
    128  * Function called with denomination_revocations records to insert into table.
    129  *
    130  * @param pg plugin context
    131  * @param td record to insert
    132  */
    133 static enum GNUNET_DB_QueryStatus
    134 irbt_cb_table_denomination_revocations (
    135   struct PostgresClosure *pg,
    136   const struct TALER_EXCHANGEDB_TableData *td)
    137 {
    138   struct GNUNET_PQ_QueryParam params[] = {
    139     GNUNET_PQ_query_param_uint64 (&td->serial),
    140     GNUNET_PQ_query_param_auto_from_type (
    141       &td->details.denomination_revocations.master_sig),
    142     GNUNET_PQ_query_param_uint64 (
    143       &td->details.denomination_revocations.denominations_serial),
    144     GNUNET_PQ_query_param_end
    145   };
    146 
    147   PREPARE (pg,
    148            "insert_into_table_denomination_revocations",
    149            "INSERT INTO denomination_revocations"
    150            "(denom_revocations_serial_id"
    151            ",master_sig"
    152            ",denominations_serial"
    153            ") VALUES "
    154            "($1, $2, $3);");
    155   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    156                                              "insert_into_table_denomination_revocations",
    157                                              params);
    158 }
    159 
    160 
    161 /**
    162  * Function called with wire target records to insert into table.
    163  *
    164  * @param pg plugin context
    165  * @param td record to insert
    166  */
    167 static enum GNUNET_DB_QueryStatus
    168 irbt_cb_table_wire_targets (struct PostgresClosure *pg,
    169                             const struct TALER_EXCHANGEDB_TableData *td)
    170 {
    171   struct TALER_NormalizedPaytoHashP normalized_payto_hash;
    172   struct TALER_FullPaytoHashP full_payto_hash;
    173   struct GNUNET_PQ_QueryParam params[] = {
    174     GNUNET_PQ_query_param_uint64 (&td->serial),
    175     GNUNET_PQ_query_param_auto_from_type (&full_payto_hash),
    176     GNUNET_PQ_query_param_auto_from_type (&normalized_payto_hash),
    177     GNUNET_PQ_query_param_string (
    178       td->details.wire_targets.full_payto_uri.full_payto),
    179     GNUNET_PQ_query_param_end
    180   };
    181 
    182   TALER_full_payto_hash (
    183     td->details.wire_targets.full_payto_uri,
    184     &full_payto_hash);
    185   TALER_full_payto_normalize_and_hash (
    186     td->details.wire_targets.full_payto_uri,
    187     &normalized_payto_hash);
    188   PREPARE (pg,
    189            "insert_into_table_wire_targets",
    190            "INSERT INTO wire_targets"
    191            "(wire_target_serial_id"
    192            ",wire_target_h_payto"
    193            ",h_normalized_payto"
    194            ",payto_uri"
    195            ") VALUES "
    196            "($1, $2, $3, $4);");
    197   return GNUNET_PQ_eval_prepared_non_select (
    198     pg->conn,
    199     "insert_into_table_wire_targets",
    200     params);
    201 }
    202 
    203 
    204 /**
    205  * Function called with kyc target records to insert into table.
    206  *
    207  * @param pg plugin context
    208  * @param td record to insert
    209  */
    210 static enum GNUNET_DB_QueryStatus
    211 irbt_cb_table_kyc_targets (struct PostgresClosure *pg,
    212                            const struct TALER_EXCHANGEDB_TableData *td)
    213 {
    214   struct GNUNET_PQ_QueryParam params[] = {
    215     GNUNET_PQ_query_param_uint64 (&td->serial),
    216     GNUNET_PQ_query_param_auto_from_type (
    217       &td->details.kyc_targets.h_normalized_payto),
    218     GNUNET_PQ_query_param_auto_from_type (
    219       &td->details.kyc_targets.access_token),
    220     td->details.kyc_targets.no_account
    221     ? GNUNET_PQ_query_param_null ()
    222     : GNUNET_PQ_query_param_auto_from_type (
    223       &td->details.kyc_targets.target_pub),
    224     GNUNET_PQ_query_param_bool (
    225       td->details.kyc_targets.is_wallet),
    226     GNUNET_PQ_query_param_end
    227   };
    228 
    229   PREPARE (pg,
    230            "insert_into_table_kyc_targets",
    231            "INSERT INTO kyc_targets"
    232            "(kyc_target_serial_id"
    233            ",h_normalized_payto"
    234            ",access_token"
    235            ",target_pub"
    236            ",is_wallet"
    237            ") VALUES "
    238            "($1, $2, $3, $4, $5);");
    239   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    240                                              "insert_into_table_kyc_targets",
    241                                              params);
    242 }
    243 
    244 
    245 /**
    246  * Function called with records to insert into table.
    247  *
    248  * @param pg plugin context
    249  * @param td record to insert
    250  */
    251 static enum GNUNET_DB_QueryStatus
    252 irbt_cb_table_legitimization_measures (
    253   struct PostgresClosure *pg,
    254   const struct TALER_EXCHANGEDB_TableData *td)
    255 {
    256   struct GNUNET_PQ_QueryParam params[] = {
    257     GNUNET_PQ_query_param_uint64 (&td->serial),
    258     GNUNET_PQ_query_param_auto_from_type (
    259       &td->details.legitimization_measures.target_token),
    260     GNUNET_PQ_query_param_timestamp (
    261       &td->details.legitimization_measures.start_time),
    262     TALER_PQ_query_param_json (
    263       td->details.legitimization_measures.measures),
    264     GNUNET_PQ_query_param_uint32 (
    265       &td->details.legitimization_measures.display_priority),
    266     GNUNET_PQ_query_param_end
    267   };
    268 
    269   PREPARE (pg,
    270            "insert_into_table_legitimization_measures",
    271            "INSERT INTO legitimization_measures"
    272            "(legitimization_measure_serial_id"
    273            ",access_token"
    274            ",start_time"
    275            ",jmeasures"
    276            ",display_priority"
    277            ") VALUES "
    278            "($1, $2, $3, $4::TEXT::JSONB, $5);");
    279   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    280                                              "insert_into_table_legitimization_measures",
    281                                              params);
    282 }
    283 
    284 
    285 /**
    286  * Function called with records to insert into table.
    287  *
    288  * @param pg plugin context
    289  * @param td record to insert
    290  */
    291 static enum GNUNET_DB_QueryStatus
    292 irbt_cb_table_legitimization_outcomes (
    293   struct PostgresClosure *pg,
    294   const struct TALER_EXCHANGEDB_TableData *td)
    295 {
    296   struct GNUNET_PQ_QueryParam params[] = {
    297     GNUNET_PQ_query_param_uint64 (&td->serial),
    298     GNUNET_PQ_query_param_auto_from_type (
    299       &td->details.legitimization_outcomes.h_payto),
    300     GNUNET_PQ_query_param_timestamp (
    301       &td->details.legitimization_outcomes.decision_time),
    302     GNUNET_PQ_query_param_timestamp (
    303       &td->details.legitimization_outcomes.expiration_time),
    304     TALER_PQ_query_param_json (
    305       td->details.legitimization_outcomes.properties),
    306     GNUNET_PQ_query_param_bool (
    307       td->details.legitimization_outcomes.to_investigate),
    308     TALER_PQ_query_param_json (
    309       td->details.legitimization_outcomes.new_rules),
    310     GNUNET_PQ_query_param_end
    311   };
    312 
    313   PREPARE (pg,
    314            "insert_into_table_legitimization_outcomes",
    315            "INSERT INTO legitimization_outcomes"
    316            "(outcome_serial_id"
    317            ",h_payto"
    318            ",decision_time"
    319            ",expiration_time"
    320            ",jproperties"
    321            ",to_investigate"
    322            ",jnew_rules"
    323            ") VALUES "
    324            "($1, $2, $3, $4, $5::TEXT::JSONB, $6, $7::TEXT::JSONB);");
    325   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    326                                              "insert_into_table_legitimization_outcomes",
    327                                              params);
    328 }
    329 
    330 
    331 /**
    332  * Function called with records to insert into table.
    333  *
    334  * @param pg plugin context
    335  * @param td record to insert
    336  */
    337 static enum GNUNET_DB_QueryStatus
    338 irbt_cb_table_legitimization_processes (
    339   struct PostgresClosure *pg,
    340   const struct TALER_EXCHANGEDB_TableData *td)
    341 {
    342   struct GNUNET_PQ_QueryParam params[] = {
    343     GNUNET_PQ_query_param_uint64 (&td->serial),
    344     GNUNET_PQ_query_param_auto_from_type (
    345       &td->details.legitimization_processes.h_payto),
    346     GNUNET_PQ_query_param_timestamp (
    347       &td->details.legitimization_processes.start_time),
    348     GNUNET_PQ_query_param_timestamp (
    349       &td->details.legitimization_processes.expiration_time),
    350     GNUNET_PQ_query_param_uint64 (
    351       &td->details.legitimization_processes.legitimization_measure_serial_id),
    352     GNUNET_PQ_query_param_uint32 (
    353       &td->details.legitimization_processes.measure_index),
    354     GNUNET_PQ_query_param_string (
    355       td->details.legitimization_processes.provider_name),
    356     GNUNET_PQ_query_param_string (
    357       td->details.legitimization_processes.provider_user_id),
    358     GNUNET_PQ_query_param_string (
    359       td->details.legitimization_processes.provider_legitimization_id),
    360     GNUNET_PQ_query_param_string (
    361       td->details.legitimization_processes.redirect_url),
    362     GNUNET_PQ_query_param_end
    363   };
    364 
    365   PREPARE (pg,
    366            "insert_into_table_legitimization_processes",
    367            "INSERT INTO legitimization_processes"
    368            "(legitimization_process_serial_id"
    369            ",h_payto"
    370            ",start_time"
    371            ",expiration_time"
    372            ",legitimization_measure_serial_id"
    373            ",measure_index"
    374            ",provider_name"
    375            ",provider_user_id"
    376            ",provider_legitimization_id"
    377            ",redirect_url"
    378            ") VALUES "
    379            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
    380   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    381                                              "insert_into_table_legitimization_processes",
    382                                              params);
    383 }
    384 
    385 
    386 /**
    387  * Function called with reserves records to insert into table.
    388  *
    389  * @param pg plugin context
    390  * @param td record to insert
    391  */
    392 static enum GNUNET_DB_QueryStatus
    393 irbt_cb_table_reserves (struct PostgresClosure *pg,
    394                         const struct TALER_EXCHANGEDB_TableData *td)
    395 {
    396   struct GNUNET_PQ_QueryParam params[] = {
    397     GNUNET_PQ_query_param_uint64 (&td->serial),
    398     GNUNET_PQ_query_param_auto_from_type (&td->details.reserves.reserve_pub),
    399     GNUNET_PQ_query_param_timestamp (&td->details.reserves.expiration_date),
    400     GNUNET_PQ_query_param_timestamp (&td->details.reserves.gc_date),
    401     GNUNET_PQ_query_param_end
    402   };
    403 
    404   PREPARE (pg,
    405            "insert_into_table_reserves",
    406            "INSERT INTO reserves"
    407            "(reserve_uuid"
    408            ",reserve_pub"
    409            ",expiration_date"
    410            ",gc_date"
    411            ") VALUES "
    412            "($1, $2, $3, $4);");
    413   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    414                                              "insert_into_table_reserves",
    415                                              params);
    416 }
    417 
    418 
    419 /**
    420  * Function called with reserves_in records to insert into table.
    421  *
    422  * @param pg plugin context
    423  * @param td record to insert
    424  */
    425 static enum GNUNET_DB_QueryStatus
    426 irbt_cb_table_reserves_in (struct PostgresClosure *pg,
    427                            const struct TALER_EXCHANGEDB_TableData *td)
    428 {
    429   struct GNUNET_PQ_QueryParam params[] = {
    430     GNUNET_PQ_query_param_uint64 (&td->serial),
    431     GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.wire_reference),
    432     TALER_PQ_query_param_amount (
    433       pg->conn,
    434       &td->details.reserves_in.credit),
    435     GNUNET_PQ_query_param_auto_from_type (
    436       &td->details.reserves_in.sender_account_h_payto),
    437     GNUNET_PQ_query_param_string (
    438       td->details.reserves_in.exchange_account_section),
    439     GNUNET_PQ_query_param_timestamp (
    440       &td->details.reserves_in.execution_date),
    441     GNUNET_PQ_query_param_auto_from_type (&td->details.reserves_in.reserve_pub),
    442     GNUNET_PQ_query_param_end
    443   };
    444 
    445   PREPARE (pg,
    446            "insert_into_table_reserves_in",
    447            "INSERT INTO reserves_in"
    448            "(reserve_in_serial_id"
    449            ",wire_reference"
    450            ",credit"
    451            ",wire_source_h_payto"
    452            ",exchange_account_section"
    453            ",execution_date"
    454            ",reserve_pub"
    455            ") VALUES "
    456            "($1, $2, $3, $4, $5, $6, $7);");
    457   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    458                                              "insert_into_table_reserves_in",
    459                                              params);
    460 }
    461 
    462 
    463 /**
    464  * Function called with kycauth_in records to insert into table.
    465  *
    466  * @param pg plugin context
    467  * @param td record to insert
    468  */
    469 static enum GNUNET_DB_QueryStatus
    470 irbt_cb_table_kycauths_in (struct PostgresClosure *pg,
    471                            const struct TALER_EXCHANGEDB_TableData *td)
    472 {
    473   struct GNUNET_PQ_QueryParam params[] = {
    474     GNUNET_PQ_query_param_uint64 (&td->serial),
    475     GNUNET_PQ_query_param_uint64 (&td->details.kycauth_in.wire_reference),
    476     TALER_PQ_query_param_amount (
    477       pg->conn,
    478       &td->details.reserves_in.credit),
    479     GNUNET_PQ_query_param_auto_from_type (
    480       &td->details.reserves_in.sender_account_h_payto),
    481     GNUNET_PQ_query_param_string (
    482       td->details.reserves_in.exchange_account_section),
    483     GNUNET_PQ_query_param_timestamp (
    484       &td->details.reserves_in.execution_date),
    485     GNUNET_PQ_query_param_auto_from_type (&td->details.kycauth_in.account_pub),
    486     GNUNET_PQ_query_param_end
    487   };
    488 
    489   PREPARE (pg,
    490            "insert_into_table_kycauth_in",
    491            "INSERT INTO kycauths_in"
    492            "(kycauth_in_serial_id"
    493            ",wire_reference"
    494            ",credit"
    495            ",wire_source_h_payto"
    496            ",exchange_account_section"
    497            ",execution_date"
    498            ",account_pub"
    499            ") VALUES "
    500            "($1, $2, $3, $4, $5, $6, $7);");
    501   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    502                                              "insert_into_table_kycauth_in",
    503                                              params);
    504 }
    505 
    506 
    507 /**
    508  * Function called with reserves_open_requests records to insert into table.
    509  *
    510  * @param pg plugin context
    511  * @param td record to insert
    512  */
    513 static enum GNUNET_DB_QueryStatus
    514 irbt_cb_table_reserves_open_requests (struct PostgresClosure *pg,
    515                                       const struct
    516                                       TALER_EXCHANGEDB_TableData *td)
    517 {
    518   struct GNUNET_PQ_QueryParam params[] = {
    519     GNUNET_PQ_query_param_uint64 (&td->serial),
    520     GNUNET_PQ_query_param_timestamp (
    521       &td->details.reserves_open_requests.expiration_date),
    522     GNUNET_PQ_query_param_auto_from_type (
    523       &td->details.reserves_open_requests.reserve_sig),
    524     TALER_PQ_query_param_amount (
    525       pg->conn,
    526       &td->details.reserves_open_requests.reserve_payment),
    527     GNUNET_PQ_query_param_uint32 (
    528       &td->details.reserves_open_requests.requested_purse_limit),
    529     GNUNET_PQ_query_param_end
    530   };
    531 
    532   PREPARE (pg,
    533            "insert_into_table_reserves_open_requests",
    534            "INSERT INTO reserves_open_requests"
    535            "(open_request_uuid"
    536            ",reserve_pub"
    537            ",request_timestamp"
    538            ",expiration_date"
    539            ",reserve_sig"
    540            ",reserve_payment"
    541            ",requested_purse_limit"
    542            ") VALUES "
    543            "($1, $2, $3, $4, $5, $6, $7);");
    544   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    545                                              "insert_into_table_reserves_open_requests",
    546                                              params);
    547 }
    548 
    549 
    550 /**
    551  * Function called with reserves_open_requests records to insert into table.
    552  *
    553  * @param pg plugin context
    554  * @param td record to insert
    555  */
    556 static enum GNUNET_DB_QueryStatus
    557 irbt_cb_table_reserves_open_deposits (
    558   struct PostgresClosure *pg,
    559   const struct TALER_EXCHANGEDB_TableData *td)
    560 {
    561   struct GNUNET_PQ_QueryParam params[] = {
    562     GNUNET_PQ_query_param_uint64 (&td->serial),
    563     GNUNET_PQ_query_param_auto_from_type (
    564       &td->details.reserves_open_deposits.coin_pub),
    565     GNUNET_PQ_query_param_auto_from_type (
    566       &td->details.reserves_open_deposits.coin_sig),
    567     GNUNET_PQ_query_param_auto_from_type (
    568       &td->details.reserves_open_deposits.reserve_sig),
    569     TALER_PQ_query_param_amount (
    570       pg->conn,
    571       &td->details.reserves_open_deposits.contribution),
    572     GNUNET_PQ_query_param_end
    573   };
    574 
    575   PREPARE (pg,
    576            "insert_into_table_reserves_open_deposits",
    577            "INSERT INTO reserves_open_deposits"
    578            "(reserve_open_deposit_uuid"
    579            ",reserve_sig"
    580            ",reserve_pub"
    581            ",coin_pub"
    582            ",coin_sig"
    583            ",contribution"
    584            ") VALUES "
    585            "($1, $2, $3, $4, $5, $6);");
    586   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    587                                              "insert_into_table_reserves_open_deposits",
    588                                              params);
    589 }
    590 
    591 
    592 /**
    593  * Function called with reserves_close records to insert into table.
    594  *
    595  * @param pg plugin context
    596  * @param td record to insert
    597  */
    598 static enum GNUNET_DB_QueryStatus
    599 irbt_cb_table_reserves_close (struct PostgresClosure *pg,
    600                               const struct TALER_EXCHANGEDB_TableData *td)
    601 {
    602   struct GNUNET_PQ_QueryParam params[] = {
    603     GNUNET_PQ_query_param_uint64 (&td->serial),
    604     GNUNET_PQ_query_param_timestamp (
    605       &td->details.reserves_close.execution_date),
    606     GNUNET_PQ_query_param_auto_from_type (
    607       &td->details.reserves_close.wtid),
    608     GNUNET_PQ_query_param_auto_from_type (
    609       &td->details.reserves_close.sender_account_h_payto),
    610     TALER_PQ_query_param_amount (
    611       pg->conn,
    612       &td->details.reserves_close.amount),
    613     TALER_PQ_query_param_amount (
    614       pg->conn,
    615       &td->details.reserves_close.closing_fee),
    616     GNUNET_PQ_query_param_auto_from_type (
    617       &td->details.reserves_close.reserve_pub),
    618     GNUNET_PQ_query_param_end
    619   };
    620 
    621   PREPARE (pg,
    622            "insert_into_table_reserves_close",
    623            "INSERT INTO reserves_close"
    624            "(close_uuid"
    625            ",execution_date"
    626            ",wtid"
    627            ",wire_target_h_payto"
    628            ",amount"
    629            ",closing_fee"
    630            ",reserve_pub"
    631            ") VALUES "
    632            "($1, $2, $3, $4, $5, $6, $7);");
    633   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    634                                              "insert_into_table_reserves_close",
    635                                              params);
    636 }
    637 
    638 
    639 /**
    640  * Function called with auditors records to insert into table.
    641  *
    642  * @param pg plugin context
    643  * @param td record to insert
    644  */
    645 static enum GNUNET_DB_QueryStatus
    646 irbt_cb_table_auditors (struct PostgresClosure *pg,
    647                         const struct TALER_EXCHANGEDB_TableData *td)
    648 {
    649   struct GNUNET_PQ_QueryParam params[] = {
    650     GNUNET_PQ_query_param_uint64 (&td->serial),
    651     GNUNET_PQ_query_param_auto_from_type (&td->details.auditors.auditor_pub),
    652     GNUNET_PQ_query_param_string (td->details.auditors.auditor_name),
    653     GNUNET_PQ_query_param_string (td->details.auditors.auditor_url),
    654     GNUNET_PQ_query_param_bool (td->details.auditors.is_active),
    655     GNUNET_PQ_query_param_timestamp (&td->details.auditors.last_change),
    656     GNUNET_PQ_query_param_end
    657   };
    658 
    659   PREPARE (pg,
    660            "insert_into_table_auditors",
    661            "INSERT INTO auditors"
    662            "(auditor_uuid"
    663            ",auditor_pub"
    664            ",auditor_name"
    665            ",auditor_url"
    666            ",is_active"
    667            ",last_change"
    668            ") VALUES "
    669            "($1, $2, $3, $4, $5, $6);");
    670   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    671                                              "insert_into_table_auditors",
    672                                              params);
    673 }
    674 
    675 
    676 /**
    677  * Function called with auditor_denom_sigs records to insert into table.
    678  *
    679  * @param pg plugin context
    680  * @param td record to insert
    681  */
    682 static enum GNUNET_DB_QueryStatus
    683 irbt_cb_table_auditor_denom_sigs (struct PostgresClosure *pg,
    684                                   const struct TALER_EXCHANGEDB_TableData *td)
    685 {
    686   struct GNUNET_PQ_QueryParam params[] = {
    687     GNUNET_PQ_query_param_uint64 (&td->serial),
    688     GNUNET_PQ_query_param_uint64 (&td->details.auditor_denom_sigs.auditor_uuid),
    689     GNUNET_PQ_query_param_uint64 (
    690       &td->details.auditor_denom_sigs.denominations_serial),
    691     GNUNET_PQ_query_param_auto_from_type (
    692       &td->details.auditor_denom_sigs.auditor_sig),
    693     GNUNET_PQ_query_param_end
    694   };
    695 
    696   PREPARE (pg,
    697            "insert_into_table_auditor_denom_sigs",
    698            "INSERT INTO auditor_denom_sigs"
    699            "(auditor_denom_serial"
    700            ",auditor_uuid"
    701            ",denominations_serial"
    702            ",auditor_sig"
    703            ") VALUES "
    704            "($1, $2, $3, $4);");
    705   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    706                                              "insert_into_table_auditor_denom_sigs",
    707                                              params);
    708 }
    709 
    710 
    711 /**
    712  * Function called with exchange_sign_keys records to insert into table.
    713  *
    714  * @param pg plugin context
    715  * @param td record to insert
    716  */
    717 static enum GNUNET_DB_QueryStatus
    718 irbt_cb_table_exchange_sign_keys (struct PostgresClosure *pg,
    719                                   const struct TALER_EXCHANGEDB_TableData *td)
    720 {
    721   struct GNUNET_PQ_QueryParam params[] = {
    722     GNUNET_PQ_query_param_uint64 (&td->serial),
    723     GNUNET_PQ_query_param_auto_from_type (
    724       &td->details.exchange_sign_keys.exchange_pub),
    725     GNUNET_PQ_query_param_auto_from_type (
    726       &td->details.exchange_sign_keys.master_sig),
    727     GNUNET_PQ_query_param_timestamp (
    728       &td->details.exchange_sign_keys.meta.start),
    729     GNUNET_PQ_query_param_timestamp (
    730       &td->details.exchange_sign_keys.meta.expire_sign),
    731     GNUNET_PQ_query_param_timestamp (
    732       &td->details.exchange_sign_keys.meta.expire_legal),
    733     GNUNET_PQ_query_param_end
    734   };
    735 
    736   PREPARE (pg,
    737            "insert_into_table_exchange_sign_keys",
    738            "INSERT INTO exchange_sign_keys"
    739            "(esk_serial"
    740            ",exchange_pub"
    741            ",master_sig"
    742            ",valid_from"
    743            ",expire_sign"
    744            ",expire_legal"
    745            ") VALUES "
    746            "($1, $2, $3, $4, $5, $6);");
    747   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    748                                              "insert_into_table_exchange_sign_keys",
    749                                              params);
    750 }
    751 
    752 
    753 /**
    754  * Function called with signkey_revocations records to insert into table.
    755  *
    756  * @param pg plugin context
    757  * @param td record to insert
    758  */
    759 static enum GNUNET_DB_QueryStatus
    760 irbt_cb_table_signkey_revocations (struct PostgresClosure *pg,
    761                                    const struct TALER_EXCHANGEDB_TableData *td)
    762 {
    763   struct GNUNET_PQ_QueryParam params[] = {
    764     GNUNET_PQ_query_param_uint64 (&td->serial),
    765     GNUNET_PQ_query_param_uint64 (&td->details.signkey_revocations.esk_serial),
    766     GNUNET_PQ_query_param_auto_from_type (
    767       &td->details.signkey_revocations.master_sig),
    768     GNUNET_PQ_query_param_end
    769   };
    770 
    771   PREPARE (pg,
    772            "insert_into_table_signkey_revocations",
    773            "INSERT INTO signkey_revocations"
    774            "(signkey_revocations_serial_id"
    775            ",esk_serial"
    776            ",master_sig"
    777            ") VALUES "
    778            "($1, $2, $3);");
    779   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    780                                              "insert_into_table_signkey_revocations",
    781                                              params);
    782 }
    783 
    784 
    785 /**
    786  * Function called with known_coins records to insert into table.
    787  *
    788  * @param pg plugin context
    789  * @param td record to insert
    790  */
    791 static enum GNUNET_DB_QueryStatus
    792 irbt_cb_table_known_coins (struct PostgresClosure *pg,
    793                            const struct TALER_EXCHANGEDB_TableData *td)
    794 {
    795   struct GNUNET_PQ_QueryParam params[] = {
    796     GNUNET_PQ_query_param_uint64 (&td->serial),
    797     GNUNET_PQ_query_param_auto_from_type (
    798       &td->details.known_coins.coin_pub),
    799     TALER_PQ_query_param_denom_sig (
    800       &td->details.known_coins.denom_sig),
    801     GNUNET_PQ_query_param_uint64 (
    802       &td->details.known_coins.denominations_serial),
    803     GNUNET_PQ_query_param_end
    804   };
    805 
    806   PREPARE (pg,
    807            "insert_into_table_known_coins",
    808            "INSERT INTO known_coins"
    809            "(known_coin_id"
    810            ",coin_pub"
    811            ",denom_sig"
    812            ",denominations_serial"
    813            ") VALUES "
    814            "($1, $2, $3, $4);");
    815   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    816                                              "insert_into_table_known_coins",
    817                                              params);
    818 }
    819 
    820 
    821 /**
    822  * Function called with refresh records to insert into table.
    823  *
    824  * @param pg plugin context
    825  * @param td record to insert
    826  */
    827 static enum GNUNET_DB_QueryStatus
    828 irbt_cb_table_refresh (struct PostgresClosure *pg,
    829                        const struct TALER_EXCHANGEDB_TableData *td)
    830 {
    831   struct GNUNET_PQ_QueryParam params[] = {
    832     GNUNET_PQ_query_param_uint64 (&td->serial),
    833     GNUNET_PQ_query_param_auto_from_type (&td->details.refresh.rc),
    834     GNUNET_PQ_query_param_auto_from_type (&td->details.refresh.execution_date),
    835     TALER_PQ_query_param_amount (
    836       pg->conn,
    837       &td->details.refresh.amount_with_fee),
    838     GNUNET_PQ_query_param_auto_from_type (
    839       &td->details.refresh.old_coin_pub),
    840     GNUNET_PQ_query_param_auto_from_type (
    841       &td->details.refresh.old_coin_sig),
    842     GNUNET_PQ_query_param_auto_from_type (
    843       &td->details.refresh.refresh_seed),
    844     GNUNET_PQ_query_param_uint32 (
    845       &td->details.refresh.noreveal_index),
    846     GNUNET_PQ_query_param_auto_from_type (
    847       &td->details.refresh.planchets_h),
    848     GNUNET_PQ_query_param_auto_from_type (
    849       &td->details.refresh.selected_h),
    850     td->details.refresh.no_blinding_seed
    851        ? GNUNET_PQ_query_param_null ()
    852        : GNUNET_PQ_query_param_auto_from_type (
    853       &td->details.refresh.blinding_seed),
    854     td->details.refresh.no_blinding_seed
    855        ? GNUNET_PQ_query_param_null ()
    856        : TALER_PQ_query_param_array_cs_r_pub (
    857       td->details.refresh.num_cs_r_values,
    858       td->details.refresh.cs_r_values,
    859       pg->conn),
    860     td->details.refresh.no_blinding_seed
    861        ? GNUNET_PQ_query_param_null ()
    862        : GNUNET_PQ_query_param_uint64 (
    863       &td->details.refresh.cs_r_choices),
    864     GNUNET_PQ_query_param_array_uint64 (
    865       td->details.refresh.num_coins,
    866       td->details.refresh.denom_serials,
    867       pg->conn),
    868     TALER_PQ_query_param_array_blinded_denom_sig (
    869       td->details.refresh.num_coins,
    870       td->details.refresh.denom_sigs,
    871       pg->conn),
    872     GNUNET_PQ_query_param_end
    873   };
    874 
    875   PREPARE (pg,
    876            "insert_into_table_refresh",
    877            "INSERT INTO refresh"
    878            "(refresh_id"
    879            ",rc"
    880            ",execution_date"
    881            ",amount_with_fee"
    882            ",old_coin_pub"
    883            ",old_coin_sig"
    884            ",refresh_seed"
    885            ",noreveal_index"
    886            ",planchets_h"
    887            ",selected_h"
    888            ",blinding_seed"
    889            ",cs_r_values"
    890            ",cs_r_choices"
    891            ",denom_serials"
    892            ",denom_sigs"
    893            ") VALUES "
    894            "($1, $2, $3, $4, $5, $6,$7,$8,$9,$10,$11,$12,$13,$14,$15);");
    895   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    896                                              "insert_into_table_refresh",
    897                                              params);
    898 }
    899 
    900 
    901 /**
    902  * Function called with batch deposits records to insert into table.
    903  *
    904  * @param pg plugin context
    905  * @param td record to insert
    906  */
    907 static enum GNUNET_DB_QueryStatus
    908 irbt_cb_table_batch_deposits (struct PostgresClosure *pg,
    909                               const struct TALER_EXCHANGEDB_TableData *td)
    910 {
    911   struct GNUNET_PQ_QueryParam params[] = {
    912     GNUNET_PQ_query_param_uint64 (&td->serial),
    913     GNUNET_PQ_query_param_uint64 (&td->details.batch_deposits.shard),
    914     GNUNET_PQ_query_param_auto_from_type (
    915       &td->details.batch_deposits.merchant_pub),
    916     GNUNET_PQ_query_param_timestamp (
    917       &td->details.batch_deposits.wallet_timestamp),
    918     GNUNET_PQ_query_param_timestamp (
    919       &td->details.batch_deposits.exchange_timestamp),
    920     GNUNET_PQ_query_param_timestamp (
    921       &td->details.batch_deposits.refund_deadline),
    922     GNUNET_PQ_query_param_timestamp (&td->details.batch_deposits.wire_deadline),
    923     GNUNET_PQ_query_param_auto_from_type (
    924       &td->details.batch_deposits.h_contract_terms),
    925     td->details.batch_deposits.no_wallet_data_hash
    926     ? GNUNET_PQ_query_param_null ()
    927     : GNUNET_PQ_query_param_auto_from_type (
    928       &td->details.batch_deposits.wallet_data_hash),
    929     GNUNET_PQ_query_param_auto_from_type (
    930       &td->details.batch_deposits.wire_salt),
    931     GNUNET_PQ_query_param_auto_from_type (
    932       &td->details.batch_deposits.wire_target_h_payto),
    933     td->details.batch_deposits.no_policy_details
    934     ? GNUNET_PQ_query_param_null ()
    935     : GNUNET_PQ_query_param_uint64 (
    936       &td->details.batch_deposits.policy_details_serial_id),
    937     GNUNET_PQ_query_param_bool (td->details.batch_deposits.policy_blocked),
    938     TALER_PQ_query_param_amount (
    939       pg->conn,
    940       &td->details.batch_deposits.total_amount),
    941     GNUNET_PQ_query_param_auto_from_type (
    942       &td->details.batch_deposits.merchant_sig),
    943     GNUNET_PQ_query_param_bool (td->details.batch_deposits.done),
    944     GNUNET_PQ_query_param_end
    945   };
    946 
    947   PREPARE (pg,
    948            "insert_into_table_batch_deposits",
    949            "INSERT INTO batch_deposits"
    950            "(batch_deposit_serial_id"
    951            ",shard"
    952            ",merchant_pub"
    953            ",wallet_timestamp"
    954            ",exchange_timestamp"
    955            ",refund_deadline"
    956            ",wire_deadline"
    957            ",h_contract_terms"
    958            ",wallet_data_hash"
    959            ",wire_salt"
    960            ",wire_target_h_payto"
    961            ",policy_details_serial_id"
    962            ",policy_blocked"
    963            ",total_amount"
    964            ",merchant_sig"
    965            ",done"
    966            ") VALUES "
    967            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
    968            " $11, $12, $13, $14, $15, $16);");
    969   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    970                                              "insert_into_table_batch_deposits",
    971                                              params);
    972 }
    973 
    974 
    975 /**
    976  * Function called with deposits records to insert into table.
    977  *
    978  * @param pg plugin context
    979  * @param td record to insert
    980  */
    981 static enum GNUNET_DB_QueryStatus
    982 irbt_cb_table_coin_deposits (struct PostgresClosure *pg,
    983                              const struct TALER_EXCHANGEDB_TableData *td)
    984 {
    985   struct GNUNET_PQ_QueryParam params[] = {
    986     GNUNET_PQ_query_param_uint64 (&td->serial),
    987     GNUNET_PQ_query_param_uint64 (
    988       &td->details.coin_deposits.batch_deposit_serial_id),
    989     GNUNET_PQ_query_param_auto_from_type (
    990       &td->details.coin_deposits.coin_pub),
    991     GNUNET_PQ_query_param_auto_from_type (
    992       &td->details.coin_deposits.coin_sig),
    993     TALER_PQ_query_param_amount (
    994       pg->conn,
    995       &td->details.coin_deposits.amount_with_fee),
    996     GNUNET_PQ_query_param_end
    997   };
    998 
    999   PREPARE (pg,
   1000            "insert_into_table_coin_deposits",
   1001            "INSERT INTO coin_deposits"
   1002            "(coin_deposit_serial_id"
   1003            ",batch_deposit_serial_id"
   1004            ",coin_pub"
   1005            ",coin_sig"
   1006            ",amount_with_fee"
   1007            ") VALUES "
   1008            "($1, $2, $3, $4, $5);");
   1009   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1010                                              "insert_into_table_coin_deposits",
   1011                                              params);
   1012 }
   1013 
   1014 
   1015 /**
   1016  * Function called with refunds records to insert into table.
   1017  *
   1018  * @param pg plugin context
   1019  * @param td record to insert
   1020  */
   1021 static enum GNUNET_DB_QueryStatus
   1022 irbt_cb_table_refunds (struct PostgresClosure *pg,
   1023                        const struct TALER_EXCHANGEDB_TableData *td)
   1024 {
   1025   struct GNUNET_PQ_QueryParam params[] = {
   1026     GNUNET_PQ_query_param_uint64 (&td->serial),
   1027     GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.coin_pub),
   1028     GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.merchant_sig),
   1029     GNUNET_PQ_query_param_uint64 (&td->details.refunds.rtransaction_id),
   1030     TALER_PQ_query_param_amount (
   1031       pg->conn,
   1032       &td->details.refunds.amount_with_fee),
   1033     GNUNET_PQ_query_param_uint64 (
   1034       &td->details.refunds.batch_deposit_serial_id),
   1035     GNUNET_PQ_query_param_end
   1036   };
   1037 
   1038   PREPARE (pg,
   1039            "insert_into_table_refunds",
   1040            "INSERT INTO refunds"
   1041            "(refund_serial_id"
   1042            ",coin_pub"
   1043            ",merchant_sig"
   1044            ",rtransaction_id"
   1045            ",amount_with_fee"
   1046            ",batch_deposit_serial_id"
   1047            ") VALUES "
   1048            "($1, $2, $3, $4, $5, $6);");
   1049   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1050                                              "insert_into_table_refunds",
   1051                                              params);
   1052 }
   1053 
   1054 
   1055 /**
   1056  * Function called with wire_out records to insert into table.
   1057  *
   1058  * @param pg plugin context
   1059  * @param td record to insert
   1060  */
   1061 static enum GNUNET_DB_QueryStatus
   1062 irbt_cb_table_wire_out (struct PostgresClosure *pg,
   1063                         const struct TALER_EXCHANGEDB_TableData *td)
   1064 {
   1065   struct GNUNET_PQ_QueryParam params[] = {
   1066     GNUNET_PQ_query_param_uint64 (&td->serial),
   1067     GNUNET_PQ_query_param_timestamp (&td->details.wire_out.execution_date),
   1068     GNUNET_PQ_query_param_auto_from_type (&td->details.wire_out.wtid_raw),
   1069     GNUNET_PQ_query_param_auto_from_type (
   1070       &td->details.wire_out.wire_target_h_payto),
   1071     GNUNET_PQ_query_param_string (
   1072       td->details.wire_out.exchange_account_section),
   1073     TALER_PQ_query_param_amount (
   1074       pg->conn,
   1075       &td->details.wire_out.amount),
   1076     GNUNET_PQ_query_param_end
   1077   };
   1078 
   1079   PREPARE (pg,
   1080            "insert_into_table_wire_out",
   1081            "INSERT INTO wire_out"
   1082            "(wireout_uuid"
   1083            ",execution_date"
   1084            ",wtid_raw"
   1085            ",wire_target_h_payto"
   1086            ",exchange_account_section"
   1087            ",amount"
   1088            ") VALUES "
   1089            "($1, $2, $3, $4, $5, $6);");
   1090   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1091                                              "insert_into_table_wire_out",
   1092                                              params);
   1093 }
   1094 
   1095 
   1096 /**
   1097  * Function called with aggregation_tracking records to insert into table.
   1098  *
   1099  * @param pg plugin context
   1100  * @param td record to insert
   1101  */
   1102 static enum GNUNET_DB_QueryStatus
   1103 irbt_cb_table_aggregation_tracking (struct PostgresClosure *pg,
   1104                                     const struct TALER_EXCHANGEDB_TableData *td)
   1105 {
   1106   struct GNUNET_PQ_QueryParam params[] = {
   1107     GNUNET_PQ_query_param_uint64 (&td->serial),
   1108     GNUNET_PQ_query_param_uint64 (
   1109       &td->details.aggregation_tracking.batch_deposit_serial_id),
   1110     GNUNET_PQ_query_param_auto_from_type (
   1111       &td->details.aggregation_tracking.wtid_raw),
   1112     GNUNET_PQ_query_param_end
   1113   };
   1114 
   1115   PREPARE (pg,
   1116            "insert_into_table_aggregation_tracking",
   1117            "INSERT INTO aggregation_tracking"
   1118            "(aggregation_serial_id"
   1119            ",batch_deposit_serial_id"
   1120            ",wtid_raw"
   1121            ") VALUES "
   1122            "($1, $2, $3);");
   1123   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1124                                              "insert_into_table_aggregation_tracking",
   1125                                              params);
   1126 }
   1127 
   1128 
   1129 /**
   1130  * Function called with wire_fee records to insert into table.
   1131  *
   1132  * @param pg plugin context
   1133  * @param td record to insert
   1134  */
   1135 static enum GNUNET_DB_QueryStatus
   1136 irbt_cb_table_wire_fee (struct PostgresClosure *pg,
   1137                         const struct TALER_EXCHANGEDB_TableData *td)
   1138 {
   1139   struct GNUNET_PQ_QueryParam params[] = {
   1140     GNUNET_PQ_query_param_uint64 (&td->serial),
   1141     GNUNET_PQ_query_param_string (td->details.wire_fee.wire_method),
   1142     GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.start_date),
   1143     GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.end_date),
   1144     TALER_PQ_query_param_amount (
   1145       pg->conn,
   1146       &td->details.wire_fee.fees.wire),
   1147     TALER_PQ_query_param_amount (
   1148       pg->conn,
   1149       &td->details.wire_fee.fees.closing),
   1150     GNUNET_PQ_query_param_auto_from_type (&td->details.wire_fee.master_sig),
   1151     GNUNET_PQ_query_param_end
   1152   };
   1153 
   1154   PREPARE (pg,
   1155            "insert_into_table_wire_fee",
   1156            "INSERT INTO wire_fee"
   1157            "(wire_fee_serial"
   1158            ",wire_method"
   1159            ",start_date"
   1160            ",end_date"
   1161            ",wire_fee"
   1162            ",closing_fee"
   1163            ",master_sig"
   1164            ") VALUES "
   1165            "($1, $2, $3, $4, $5, $6, $7);");
   1166   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1167                                              "insert_into_table_wire_fee",
   1168                                              params);
   1169 }
   1170 
   1171 
   1172 /**
   1173  * Function called with wire_fee records to insert into table.
   1174  *
   1175  * @param pg plugin context
   1176  * @param td record to insert
   1177  */
   1178 static enum GNUNET_DB_QueryStatus
   1179 irbt_cb_table_global_fee (struct PostgresClosure *pg,
   1180                           const struct TALER_EXCHANGEDB_TableData *td)
   1181 {
   1182   struct GNUNET_PQ_QueryParam params[] = {
   1183     GNUNET_PQ_query_param_uint64 (
   1184       &td->serial),
   1185     GNUNET_PQ_query_param_timestamp (
   1186       &td->details.global_fee.start_date),
   1187     GNUNET_PQ_query_param_timestamp (
   1188       &td->details.global_fee.end_date),
   1189     TALER_PQ_query_param_amount (
   1190       pg->conn,
   1191       &td->details.global_fee.fees.history),
   1192     TALER_PQ_query_param_amount (
   1193       pg->conn,
   1194       &td->details.global_fee.fees.account),
   1195     TALER_PQ_query_param_amount (
   1196       pg->conn,
   1197       &td->details.global_fee.fees.purse),
   1198     GNUNET_PQ_query_param_relative_time (
   1199       &td->details.global_fee.purse_timeout),
   1200     GNUNET_PQ_query_param_relative_time (
   1201       &td->details.global_fee.history_expiration),
   1202     GNUNET_PQ_query_param_uint32 (
   1203       &td->details.global_fee.purse_account_limit),
   1204     GNUNET_PQ_query_param_auto_from_type (
   1205       &td->details.global_fee.master_sig),
   1206     GNUNET_PQ_query_param_end
   1207   };
   1208 
   1209   PREPARE (pg,
   1210            "insert_into_table_global_fee",
   1211            "INSERT INTO global_fee"
   1212            "(global_fee_serial"
   1213            ",start_date"
   1214            ",end_date"
   1215            ",history_fee"
   1216            ",account_fee"
   1217            ",purse_fee"
   1218            ",purse_timeout"
   1219            ",history_expiration"
   1220            ",purse_account_limit"
   1221            ",master_sig"
   1222            ") VALUES "
   1223            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
   1224   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1225                                              "insert_into_table_global_fee",
   1226                                              params);
   1227 }
   1228 
   1229 
   1230 /**
   1231  * Function called with recoup records to insert into table.
   1232  *
   1233  * @param pg plugin context
   1234  * @param td record to insert
   1235  */
   1236 static enum GNUNET_DB_QueryStatus
   1237 irbt_cb_table_recoup (struct PostgresClosure *pg,
   1238                       const struct TALER_EXCHANGEDB_TableData *td)
   1239 {
   1240   struct GNUNET_PQ_QueryParam params[] = {
   1241     GNUNET_PQ_query_param_uint64 (&td->serial),
   1242     GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_sig),
   1243     GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_blind),
   1244     TALER_PQ_query_param_amount (
   1245       pg->conn,
   1246       &td->details.recoup.amount),
   1247     GNUNET_PQ_query_param_timestamp (&td->details.recoup.timestamp),
   1248     GNUNET_PQ_query_param_auto_from_type (
   1249       &td->details.recoup.coin_pub),
   1250     GNUNET_PQ_query_param_uint64 (&td->details.recoup.withdraw_serial_id),
   1251     GNUNET_PQ_query_param_end
   1252   };
   1253 
   1254   PREPARE (pg,
   1255            "insert_into_table_recoup",
   1256            "INSERT INTO recoup"
   1257            "(recoup_uuid"
   1258            ",coin_sig"
   1259            ",coin_blind"
   1260            ",amount"
   1261            ",recoup_timestamp"
   1262            ",coin_pub"
   1263            ",withdraw_serial_id"
   1264            ") VALUES "
   1265            "($1, $2, $3, $4, $5, $6, $7);");
   1266   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1267                                              "insert_into_table_recoup",
   1268                                              params);
   1269 }
   1270 
   1271 
   1272 /**
   1273  * Function called with recoup_refresh records to insert into table.
   1274  *
   1275  * @param pg plugin context
   1276  * @param td record to insert
   1277  */
   1278 static enum GNUNET_DB_QueryStatus
   1279 irbt_cb_table_recoup_refresh (struct PostgresClosure *pg,
   1280                               const struct TALER_EXCHANGEDB_TableData *td)
   1281 {
   1282   struct GNUNET_PQ_QueryParam params[] = {
   1283     GNUNET_PQ_query_param_uint64 (&td->serial),
   1284     GNUNET_PQ_query_param_auto_from_type (&td->details.recoup_refresh.coin_sig),
   1285     GNUNET_PQ_query_param_auto_from_type (
   1286       &td->details.recoup_refresh.coin_blind),
   1287     TALER_PQ_query_param_amount (
   1288       pg->conn,
   1289       &td->details.recoup_refresh.amount),
   1290     GNUNET_PQ_query_param_timestamp (&td->details.recoup_refresh.timestamp),
   1291     GNUNET_PQ_query_param_uint64 (&td->details.recoup_refresh.known_coin_id),
   1292     GNUNET_PQ_query_param_auto_from_type (
   1293       &td->details.recoup.coin_pub),
   1294     GNUNET_PQ_query_param_uint64 (&td->details.recoup_refresh.rrc_serial),
   1295     GNUNET_PQ_query_param_end
   1296   };
   1297 
   1298   PREPARE (pg,
   1299            "insert_into_table_recoup_refresh",
   1300            "INSERT INTO recoup_refresh"
   1301            "(recoup_refresh_uuid"
   1302            ",coin_sig"
   1303            ",coin_blind"
   1304            ",amount"
   1305            ",recoup_timestamp"
   1306            ",known_coin_id"
   1307            ",coin_pub"
   1308            ",rrc_serial"
   1309            ") VALUES "
   1310            "($1, $2, $3, $4, $5, $6, $7, $8);");
   1311   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1312                                              "insert_into_table_recoup_refresh",
   1313                                              params);
   1314 }
   1315 
   1316 
   1317 /**
   1318  * Function called with extensions records to insert into table.
   1319  *
   1320  * @param pg plugin context
   1321  * @param td record to insert
   1322  */
   1323 static enum GNUNET_DB_QueryStatus
   1324 irbt_cb_table_extensions (struct PostgresClosure *pg,
   1325                           const struct TALER_EXCHANGEDB_TableData *td)
   1326 {
   1327   struct GNUNET_PQ_QueryParam params[] = {
   1328     GNUNET_PQ_query_param_uint64 (&td->serial),
   1329     GNUNET_PQ_query_param_string (td->details.extensions.name),
   1330     NULL == td->details.extensions.manifest ?
   1331     GNUNET_PQ_query_param_null () :
   1332     GNUNET_PQ_query_param_string (td->details.extensions.manifest),
   1333     GNUNET_PQ_query_param_end
   1334   };
   1335 
   1336   PREPARE (pg,
   1337            "insert_into_table_extensions",
   1338            "INSERT INTO extensions"
   1339            "(extension_id"
   1340            ",name"
   1341            ",manifest"
   1342            ") VALUES "
   1343            "($1, $2, $3);");
   1344   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1345                                              "insert_into_table_extensions",
   1346                                              params);
   1347 }
   1348 
   1349 
   1350 /**
   1351  * Function called with policy_details records to insert into table.
   1352  *
   1353  * @param pg plugin context
   1354  * @param td record to insert
   1355  */
   1356 static enum GNUNET_DB_QueryStatus
   1357 irbt_cb_table_policy_details (struct PostgresClosure *pg,
   1358                               const struct TALER_EXCHANGEDB_TableData *td)
   1359 {
   1360   struct GNUNET_PQ_QueryParam params[] = {
   1361     GNUNET_PQ_query_param_uint64 (&td->serial),
   1362     GNUNET_PQ_query_param_auto_from_type (
   1363       &td->details.policy_details.hash_code),
   1364     (td->details.policy_details.no_policy_json)
   1365       ? GNUNET_PQ_query_param_null ()
   1366       : TALER_PQ_query_param_json (td->details.policy_details.policy_json),
   1367     TALER_PQ_query_param_amount (
   1368       pg->conn,
   1369       &td->details.policy_details.commitment),
   1370     TALER_PQ_query_param_amount (
   1371       pg->conn,
   1372       &td->details.policy_details.accumulated_total),
   1373     TALER_PQ_query_param_amount (
   1374       pg->conn,
   1375       &td->details.policy_details.fee),
   1376     TALER_PQ_query_param_amount (pg->conn,
   1377                                  &td->details.policy_details.transferable),
   1378     GNUNET_PQ_query_param_timestamp (&td->details.policy_details.deadline),
   1379     GNUNET_PQ_query_param_uint16 (
   1380       &td->details.policy_details.fulfillment_state),
   1381     (td->details.policy_details.no_fulfillment_id)
   1382       ? GNUNET_PQ_query_param_null ()
   1383       : GNUNET_PQ_query_param_uint64 (
   1384       &td->details.policy_details.fulfillment_id),
   1385     GNUNET_PQ_query_param_end
   1386   };
   1387 
   1388   PREPARE (pg,
   1389            "insert_into_table_policy_details",
   1390            "INSERT INTO policy_details"
   1391            "(policy_details_serial_id"
   1392            ",policy_hash_code"
   1393            ",policy_json"
   1394            ",deadline"
   1395            ",commitment"
   1396            ",accumulated_total"
   1397            ",fee"
   1398            ",transferable"
   1399            ",fulfillment_state"
   1400            ",fulfillment_id"
   1401            ") VALUES "
   1402            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
   1403   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1404                                              "insert_into_table_policy_details",
   1405                                              params);
   1406 }
   1407 
   1408 
   1409 /**
   1410  * Function called with policy_fulfillment records to insert into table.
   1411  *
   1412  * @param pg plugin context
   1413  * @param td record to insert
   1414  */
   1415 static enum GNUNET_DB_QueryStatus
   1416 irbt_cb_table_policy_fulfillments (struct PostgresClosure *pg,
   1417                                    const struct TALER_EXCHANGEDB_TableData *td)
   1418 {
   1419   struct GNUNET_PQ_QueryParam params[] = {
   1420     GNUNET_PQ_query_param_uint64 (&td->serial),
   1421     GNUNET_PQ_query_param_timestamp (
   1422       &td->details.policy_fulfillments.fulfillment_timestamp),
   1423     (NULL == td->details.policy_fulfillments.fulfillment_proof)
   1424       ? GNUNET_PQ_query_param_null ()
   1425       : GNUNET_PQ_query_param_string (
   1426       td->details.policy_fulfillments.fulfillment_proof),
   1427     GNUNET_PQ_query_param_auto_from_type (
   1428       &td->details.policy_fulfillments.h_fulfillment_proof),
   1429     GNUNET_PQ_query_param_fixed_size (
   1430       td->details.policy_fulfillments.policy_hash_codes,
   1431       td->details.policy_fulfillments.policy_hash_codes_count),
   1432     GNUNET_PQ_query_param_end
   1433   };
   1434 
   1435   PREPARE (pg,
   1436            "insert_into_table_policy_fulfillments",
   1437            "INSERT INTO policy_fulfillments "
   1438            "(fulfillment_id"
   1439            ",fulfillment_timestamp"
   1440            ",fulfillment_proof"
   1441            ",h_fulfillment_proof"
   1442            ",policy_hash_codes"
   1443            ") VALUES "
   1444            "($1, $2, $3::TEXT::JSONB, $4, $5);");
   1445   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1446                                              "insert_into_table_policy_fulfillments",
   1447                                              params);
   1448 }
   1449 
   1450 
   1451 /**
   1452  * Function called with purse_requests records to insert into table.
   1453  *
   1454  * @param pg plugin context
   1455  * @param td record to insert
   1456  */
   1457 static enum GNUNET_DB_QueryStatus
   1458 irbt_cb_table_purse_requests (struct PostgresClosure *pg,
   1459                               const struct TALER_EXCHANGEDB_TableData *td)
   1460 {
   1461   struct GNUNET_PQ_QueryParam params[] = {
   1462     GNUNET_PQ_query_param_uint64 (&td->serial),
   1463     GNUNET_PQ_query_param_auto_from_type (
   1464       &td->details.purse_requests.purse_pub),
   1465     GNUNET_PQ_query_param_auto_from_type (
   1466       &td->details.purse_requests.merge_pub),
   1467     GNUNET_PQ_query_param_timestamp (
   1468       &td->details.purse_requests.purse_creation),
   1469     GNUNET_PQ_query_param_timestamp (
   1470       &td->details.purse_requests.purse_expiration),
   1471     GNUNET_PQ_query_param_auto_from_type (
   1472       &td->details.purse_requests.h_contract_terms),
   1473     GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.age_limit),
   1474     GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.flags),
   1475     TALER_PQ_query_param_amount (
   1476       pg->conn,
   1477       &td->details.purse_requests.amount_with_fee),
   1478     TALER_PQ_query_param_amount (
   1479       pg->conn,
   1480       &td->details.purse_requests.purse_fee),
   1481     GNUNET_PQ_query_param_auto_from_type (
   1482       &td->details.purse_requests.purse_sig),
   1483     GNUNET_PQ_query_param_end
   1484   };
   1485 
   1486   PREPARE (pg,
   1487            "insert_into_table_purse_requests",
   1488            "INSERT INTO purse_requests"
   1489            "(purse_requests_serial_id"
   1490            ",purse_pub"
   1491            ",merge_pub"
   1492            ",purse_creation"
   1493            ",purse_expiration"
   1494            ",h_contract_terms"
   1495            ",age_limit"
   1496            ",flags"
   1497            ",amount_with_fee"
   1498            ",purse_fee"
   1499            ",purse_sig"
   1500            ") VALUES "
   1501            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);");
   1502   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1503                                              "insert_into_table_purse_requests",
   1504                                              params);
   1505 }
   1506 
   1507 
   1508 /**
   1509  * Function called with purse_decision records to insert into table.
   1510  *
   1511  * @param pg plugin context
   1512  * @param td record to insert
   1513  */
   1514 static enum GNUNET_DB_QueryStatus
   1515 irbt_cb_table_purse_decision (struct PostgresClosure *pg,
   1516                               const struct TALER_EXCHANGEDB_TableData *td)
   1517 {
   1518   struct GNUNET_PQ_QueryParam params[] = {
   1519     GNUNET_PQ_query_param_uint64 (&td->serial),
   1520     GNUNET_PQ_query_param_auto_from_type (
   1521       &td->details.purse_decision.purse_pub),
   1522     GNUNET_PQ_query_param_timestamp (
   1523       &td->details.purse_decision.action_timestamp),
   1524     GNUNET_PQ_query_param_bool (
   1525       td->details.purse_decision.refunded),
   1526     GNUNET_PQ_query_param_end
   1527   };
   1528 
   1529   PREPARE (pg,
   1530            "insert_into_table_purse_refunds",
   1531            "INSERT INTO purse_refunds"
   1532            "(purse_refunds_serial_id"
   1533            ",purse_pub"
   1534            ",action_timestamp"
   1535            ",refunded"
   1536            ") VALUES "
   1537            "($1, $2, $3, $4);");
   1538   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1539                                              "insert_into_table_purse_decision",
   1540                                              params);
   1541 }
   1542 
   1543 
   1544 /**
   1545  * Function called with purse_merges records to insert into table.
   1546  *
   1547  * @param pg plugin context
   1548  * @param td record to insert
   1549  */
   1550 static enum GNUNET_DB_QueryStatus
   1551 irbt_cb_table_purse_merges (struct PostgresClosure *pg,
   1552                             const struct TALER_EXCHANGEDB_TableData *td)
   1553 {
   1554   struct GNUNET_PQ_QueryParam params[] = {
   1555     GNUNET_PQ_query_param_uint64 (&td->serial),
   1556     GNUNET_PQ_query_param_uint64 (&td->details.purse_merges.partner_serial_id),
   1557     GNUNET_PQ_query_param_auto_from_type (
   1558       &td->details.purse_merges.reserve_pub),
   1559     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.purse_pub),
   1560     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.merge_sig),
   1561     GNUNET_PQ_query_param_timestamp (&td->details.purse_merges.merge_timestamp),
   1562     GNUNET_PQ_query_param_end
   1563   };
   1564 
   1565   PREPARE (pg,
   1566            "insert_into_table_purse_merges",
   1567            "INSERT INTO purse_merges"
   1568            "(purse_merge_request_serial_id"
   1569            ",partner_serial_id"
   1570            ",reserve_pub"
   1571            ",purse_pub"
   1572            ",merge_sig"
   1573            ",merge_timestamp"
   1574            ") VALUES "
   1575            "($1, $2, $3, $4, $5, $6);");
   1576   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1577                                              "insert_into_table_purse_merges",
   1578                                              params);
   1579 }
   1580 
   1581 
   1582 /**
   1583  * Function called with purse_deposits records to insert into table.
   1584  *
   1585  * @param pg plugin context
   1586  * @param td record to insert
   1587  */
   1588 static enum GNUNET_DB_QueryStatus
   1589 irbt_cb_table_purse_deposits (struct PostgresClosure *pg,
   1590                               const struct TALER_EXCHANGEDB_TableData *td)
   1591 {
   1592   struct GNUNET_PQ_QueryParam params[] = {
   1593     GNUNET_PQ_query_param_uint64 (&td->serial),
   1594     GNUNET_PQ_query_param_uint64 (
   1595       &td->details.purse_deposits.partner_serial_id),
   1596     GNUNET_PQ_query_param_auto_from_type (
   1597       &td->details.purse_deposits.purse_pub),
   1598     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_pub),
   1599     TALER_PQ_query_param_amount (
   1600       pg->conn,
   1601       &td->details.purse_deposits.amount_with_fee),
   1602     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_sig),
   1603     GNUNET_PQ_query_param_end
   1604   };
   1605 
   1606   PREPARE (pg,
   1607            "insert_into_table_purse_deposits",
   1608            "INSERT INTO purse_deposits"
   1609            "(purse_deposit_serial_id"
   1610            ",partner_serial_id"
   1611            ",purse_pub"
   1612            ",coin_pub"
   1613            ",amount_with_fee"
   1614            ",coin_sig"
   1615            ") VALUES "
   1616            "($1, $2, $3, $4, $5, $6);");
   1617   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1618                                              "insert_into_table_purse_deposits",
   1619                                              params);
   1620 }
   1621 
   1622 
   1623 /**
   1624 x * Function called with account_mergers records to insert into table.
   1625  *
   1626  * @param pg plugin context
   1627  * @param td record to insert
   1628  */
   1629 static enum GNUNET_DB_QueryStatus
   1630 irbt_cb_table_account_mergers (struct PostgresClosure *pg,
   1631                                const struct TALER_EXCHANGEDB_TableData *td)
   1632 {
   1633   struct GNUNET_PQ_QueryParam params[] = {
   1634     GNUNET_PQ_query_param_uint64 (&td->serial),
   1635     GNUNET_PQ_query_param_auto_from_type (
   1636       &td->details.account_merges.reserve_pub),
   1637     GNUNET_PQ_query_param_auto_from_type (
   1638       &td->details.account_merges.reserve_sig),
   1639     GNUNET_PQ_query_param_auto_from_type (
   1640       &td->details.account_merges.purse_pub),
   1641     GNUNET_PQ_query_param_auto_from_type (
   1642       &td->details.account_merges.wallet_h_payto),
   1643     GNUNET_PQ_query_param_end
   1644   };
   1645 
   1646   PREPARE (pg,
   1647            "insert_into_table_account_merges",
   1648            "INSERT INTO account_merges"
   1649            "(account_merge_request_serial_id"
   1650            ",reserve_pub"
   1651            ",reserve_sig"
   1652            ",purse_pub"
   1653            ",wallet_h_payto"
   1654            ") VALUES "
   1655            "($1, $2, $3, $4, $5);");
   1656   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1657                                              "insert_into_table_account_merges",
   1658                                              params);
   1659 }
   1660 
   1661 
   1662 /**
   1663  * Function called with history_requests records to insert into table.
   1664  *
   1665  * @param pg plugin context
   1666  * @param td record to insert
   1667  */
   1668 static enum GNUNET_DB_QueryStatus
   1669 irbt_cb_table_history_requests (struct PostgresClosure *pg,
   1670                                 const struct TALER_EXCHANGEDB_TableData *td)
   1671 {
   1672   struct GNUNET_PQ_QueryParam params[] = {
   1673     GNUNET_PQ_query_param_uint64 (&td->serial),
   1674     GNUNET_PQ_query_param_auto_from_type (
   1675       &td->details.history_requests.reserve_pub),
   1676     GNUNET_PQ_query_param_timestamp (
   1677       &td->details.history_requests.request_timestamp),
   1678     GNUNET_PQ_query_param_auto_from_type (
   1679       &td->details.history_requests.reserve_sig),
   1680     TALER_PQ_query_param_amount (
   1681       pg->conn,
   1682       &td->details.history_requests.history_fee),
   1683     GNUNET_PQ_query_param_end
   1684   };
   1685 
   1686   PREPARE (pg,
   1687            "insert_into_table_history_requests",
   1688            "INSERT INTO history_requests"
   1689            "(history_request_serial_id"
   1690            ",reserve_pub"
   1691            ",request_timestamp"
   1692            ",reserve_sig"
   1693            ",history_fee"
   1694            ") VALUES "
   1695            "($1, $2, $3, $4, $5);");
   1696   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1697                                              "insert_into_table_history_requests",
   1698                                              params);
   1699 }
   1700 
   1701 
   1702 /**
   1703  * Function called with close_requests records to insert into table.
   1704  *
   1705  * @param pg plugin context
   1706  * @param td record to insert
   1707  */
   1708 static enum GNUNET_DB_QueryStatus
   1709 irbt_cb_table_close_requests (struct PostgresClosure *pg,
   1710                               const struct TALER_EXCHANGEDB_TableData *td)
   1711 {
   1712   struct GNUNET_PQ_QueryParam params[] = {
   1713     GNUNET_PQ_query_param_uint64 (&td->serial),
   1714     GNUNET_PQ_query_param_auto_from_type (
   1715       &td->details.close_requests.reserve_pub),
   1716     GNUNET_PQ_query_param_timestamp (
   1717       &td->details.close_requests.close_timestamp),
   1718     GNUNET_PQ_query_param_auto_from_type (
   1719       &td->details.close_requests.reserve_sig),
   1720     TALER_PQ_query_param_amount (
   1721       pg->conn,
   1722       &td->details.close_requests.close),
   1723     TALER_PQ_query_param_amount (
   1724       pg->conn,
   1725       &td->details.close_requests.close_fee),
   1726     GNUNET_PQ_query_param_string (
   1727       td->details.close_requests.payto_uri.full_payto),
   1728     GNUNET_PQ_query_param_end
   1729   };
   1730 
   1731   PREPARE (pg,
   1732            "insert_into_table_close_requests",
   1733            "INSERT INTO close_requests"
   1734            "(close_request_serial_id"
   1735            ",reserve_pub"
   1736            ",close_timestamp"
   1737            ",reserve_sig"
   1738            ",close"
   1739            ",close_fee"
   1740            ",payto_uri"
   1741            ") VALUES "
   1742            "($1, $2, $3, $4, $5, $6, $7);");
   1743   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1744                                              "insert_into_table_close_requests",
   1745                                              params);
   1746 }
   1747 
   1748 
   1749 /**
   1750  * Function called with wads_out records to insert into table.
   1751  *
   1752  * @param pg plugin context
   1753  * @param td record to insert
   1754  */
   1755 static enum GNUNET_DB_QueryStatus
   1756 irbt_cb_table_wads_out (struct PostgresClosure *pg,
   1757                         const struct TALER_EXCHANGEDB_TableData *td)
   1758 {
   1759   struct GNUNET_PQ_QueryParam params[] = {
   1760     GNUNET_PQ_query_param_uint64 (&td->serial),
   1761     GNUNET_PQ_query_param_auto_from_type (&td->details.wads_out.wad_id),
   1762     GNUNET_PQ_query_param_uint64 (&td->details.wads_out.partner_serial_id),
   1763     TALER_PQ_query_param_amount (
   1764       pg->conn,
   1765       &td->details.wads_out.amount),
   1766     GNUNET_PQ_query_param_timestamp (&td->details.wads_out.execution_time),
   1767     GNUNET_PQ_query_param_end
   1768   };
   1769 
   1770   PREPARE (pg,
   1771            "insert_into_table_wads_out",
   1772            "INSERT INTO wads_out"
   1773            "(wad_out_serial_id"
   1774            ",wad_id"
   1775            ",partner_serial_id"
   1776            ",amount"
   1777            ",execution_time"
   1778            ") VALUES "
   1779            "($1, $2, $3, $4, $5);");
   1780   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1781                                              "insert_into_table_wads_out",
   1782                                              params);
   1783 }
   1784 
   1785 
   1786 /**
   1787  * Function called with wads_out_entries records to insert into table.
   1788  *
   1789  * @param pg plugin context
   1790  * @param td record to insert
   1791  */
   1792 static enum GNUNET_DB_QueryStatus
   1793 irbt_cb_table_wads_out_entries (struct PostgresClosure *pg,
   1794                                 const struct TALER_EXCHANGEDB_TableData *td)
   1795 {
   1796   struct GNUNET_PQ_QueryParam params[] = {
   1797     GNUNET_PQ_query_param_uint64 (&td->serial),
   1798     GNUNET_PQ_query_param_uint64 (
   1799       &td->details.wads_out_entries.wad_out_serial_id),
   1800     GNUNET_PQ_query_param_auto_from_type (
   1801       &td->details.wads_out_entries.reserve_pub),
   1802     GNUNET_PQ_query_param_auto_from_type (
   1803       &td->details.wads_out_entries.purse_pub),
   1804     GNUNET_PQ_query_param_auto_from_type (
   1805       &td->details.wads_out_entries.h_contract),
   1806     GNUNET_PQ_query_param_timestamp (
   1807       &td->details.wads_out_entries.purse_expiration),
   1808     GNUNET_PQ_query_param_timestamp (
   1809       &td->details.wads_out_entries.merge_timestamp),
   1810     TALER_PQ_query_param_amount (
   1811       pg->conn,
   1812       &td->details.wads_out_entries.amount_with_fee),
   1813     TALER_PQ_query_param_amount (
   1814       pg->conn,
   1815       &td->details.wads_out_entries.wad_fee),
   1816     TALER_PQ_query_param_amount (
   1817       pg->conn,
   1818       &td->details.wads_out_entries.deposit_fees),
   1819     GNUNET_PQ_query_param_auto_from_type (
   1820       &td->details.wads_out_entries.reserve_sig),
   1821     GNUNET_PQ_query_param_auto_from_type (
   1822       &td->details.wads_out_entries.purse_sig),
   1823     GNUNET_PQ_query_param_end
   1824   };
   1825 
   1826   PREPARE (pg,
   1827            "insert_into_table_wad_out_entries",
   1828            "INSERT INTO wad_out_entries"
   1829            "(wad_out_entry_serial_id"
   1830            ",wad_out_serial_id"
   1831            ",reserve_pub"
   1832            ",purse_pub"
   1833            ",h_contract"
   1834            ",purse_expiration"
   1835            ",merge_timestamp"
   1836            ",amount_with_fee"
   1837            ",wad_fee"
   1838            ",deposit_fees"
   1839            ",reserve_sig"
   1840            ",purse_sig"
   1841            ") VALUES "
   1842            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);");
   1843   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1844                                              "insert_into_table_wads_out_entries",
   1845                                              params);
   1846 }
   1847 
   1848 
   1849 /**
   1850  * Function called with wads_in records to insert into table.
   1851  *
   1852  * @param pg plugin context
   1853  * @param td record to insert
   1854  */
   1855 static enum GNUNET_DB_QueryStatus
   1856 irbt_cb_table_wads_in (struct PostgresClosure *pg,
   1857                        const struct TALER_EXCHANGEDB_TableData *td)
   1858 {
   1859   struct GNUNET_PQ_QueryParam params[] = {
   1860     GNUNET_PQ_query_param_uint64 (&td->serial),
   1861     GNUNET_PQ_query_param_auto_from_type (&td->details.wads_in.wad_id),
   1862     GNUNET_PQ_query_param_string (td->details.wads_in.origin_exchange_url),
   1863     TALER_PQ_query_param_amount (
   1864       pg->conn,
   1865       &td->details.wads_in.amount),
   1866     GNUNET_PQ_query_param_timestamp (&td->details.wads_in.arrival_time),
   1867     GNUNET_PQ_query_param_end
   1868   };
   1869 
   1870   PREPARE (pg,
   1871            "insert_into_table_wads_in",
   1872            "INSERT INTO wads_in"
   1873            "(wad_in_serial_id"
   1874            ",wad_id"
   1875            ",origin_exchange_url"
   1876            ",amount"
   1877            ",arrival_time"
   1878            ") VALUES "
   1879            "($1, $2, $3, $4, $5);");
   1880   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1881                                              "insert_into_table_wads_in",
   1882                                              params);
   1883 }
   1884 
   1885 
   1886 /**
   1887  * Function called with wads_in_entries records to insert into table.
   1888  *
   1889  * @param pg plugin context
   1890  * @param td record to insert
   1891  */
   1892 static enum GNUNET_DB_QueryStatus
   1893 irbt_cb_table_wads_in_entries (struct PostgresClosure *pg,
   1894                                const struct TALER_EXCHANGEDB_TableData *td)
   1895 {
   1896   struct GNUNET_PQ_QueryParam params[] = {
   1897     GNUNET_PQ_query_param_uint64 (&td->serial),
   1898     GNUNET_PQ_query_param_auto_from_type (
   1899       &td->details.wads_in_entries.reserve_pub),
   1900     GNUNET_PQ_query_param_auto_from_type (
   1901       &td->details.wads_in_entries.purse_pub),
   1902     GNUNET_PQ_query_param_auto_from_type (
   1903       &td->details.wads_in_entries.h_contract),
   1904     GNUNET_PQ_query_param_timestamp (
   1905       &td->details.wads_in_entries.purse_expiration),
   1906     GNUNET_PQ_query_param_timestamp (
   1907       &td->details.wads_in_entries.merge_timestamp),
   1908     TALER_PQ_query_param_amount (
   1909       pg->conn,
   1910       &td->details.wads_in_entries.amount_with_fee),
   1911     TALER_PQ_query_param_amount (
   1912       pg->conn,
   1913       &td->details.wads_in_entries.wad_fee),
   1914     TALER_PQ_query_param_amount (
   1915       pg->conn,
   1916       &td->details.wads_in_entries.deposit_fees),
   1917     GNUNET_PQ_query_param_auto_from_type (
   1918       &td->details.wads_in_entries.reserve_sig),
   1919     GNUNET_PQ_query_param_auto_from_type (
   1920       &td->details.wads_in_entries.purse_sig),
   1921     GNUNET_PQ_query_param_end
   1922   };
   1923 
   1924   PREPARE (pg,
   1925            "insert_into_table_wad_in_entries",
   1926            "INSERT INTO wad_in_entries"
   1927            "(wad_in_entry_serial_id"
   1928            ",wad_in_serial_id"
   1929            ",reserve_pub"
   1930            ",purse_pub"
   1931            ",h_contract"
   1932            ",purse_expiration"
   1933            ",merge_timestamp"
   1934            ",amount_with_fee"
   1935            ",wad_fee"
   1936            ",deposit_fees"
   1937            ",reserve_sig"
   1938            ",purse_sig"
   1939            ") VALUES "
   1940            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);");
   1941   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1942                                              "insert_into_table_wads_in_entries",
   1943                                              params);
   1944 }
   1945 
   1946 
   1947 /**
   1948  * Function called with profit_drains records to insert into table.
   1949  *
   1950  * @param pg plugin context
   1951  * @param td record to insert
   1952  */
   1953 static enum GNUNET_DB_QueryStatus
   1954 irbt_cb_table_profit_drains (struct PostgresClosure *pg,
   1955                              const struct TALER_EXCHANGEDB_TableData *td)
   1956 {
   1957   struct GNUNET_PQ_QueryParam params[] = {
   1958     GNUNET_PQ_query_param_uint64 (&td->serial),
   1959     GNUNET_PQ_query_param_auto_from_type (
   1960       &td->details.profit_drains.wtid),
   1961     GNUNET_PQ_query_param_string (
   1962       td->details.profit_drains.account_section),
   1963     GNUNET_PQ_query_param_string (
   1964       td->details.profit_drains.payto_uri.full_payto),
   1965     GNUNET_PQ_query_param_timestamp (
   1966       &td->details.profit_drains.trigger_date),
   1967     TALER_PQ_query_param_amount (
   1968       pg->conn,
   1969       &td->details.profit_drains.amount),
   1970     GNUNET_PQ_query_param_auto_from_type (
   1971       &td->details.profit_drains.master_sig),
   1972     GNUNET_PQ_query_param_end
   1973   };
   1974 
   1975   PREPARE (pg,
   1976            "insert_into_table_profit_drains",
   1977            "INSERT INTO profit_drains"
   1978            "(profit_drain_serial_id"
   1979            ",wtid"
   1980            ",account_section"
   1981            ",payto_uri"
   1982            ",trigger_date"
   1983            ",amount"
   1984            ",master_sig"
   1985            ") VALUES "
   1986            "($1, $2, $3, $4, $5, $6, $7);");
   1987   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   1988                                              "insert_into_table_profit_drains",
   1989                                              params);
   1990 }
   1991 
   1992 
   1993 /**
   1994  * Function called with aml_staff records to insert into table.
   1995  *
   1996  * @param pg plugin context
   1997  * @param td record to insert
   1998  */
   1999 static enum GNUNET_DB_QueryStatus
   2000 irbt_cb_table_aml_staff (struct PostgresClosure *pg,
   2001                          const struct TALER_EXCHANGEDB_TableData *td)
   2002 {
   2003   struct GNUNET_PQ_QueryParam params[] = {
   2004     GNUNET_PQ_query_param_uint64 (&td->serial),
   2005     GNUNET_PQ_query_param_auto_from_type (
   2006       &td->details.aml_staff.decider_pub),
   2007     GNUNET_PQ_query_param_auto_from_type (
   2008       &td->details.aml_staff.master_sig),
   2009     GNUNET_PQ_query_param_string (
   2010       td->details.aml_staff.decider_name),
   2011     GNUNET_PQ_query_param_bool (
   2012       td->details.aml_staff.is_active),
   2013     GNUNET_PQ_query_param_bool (
   2014       td->details.aml_staff.read_only),
   2015     GNUNET_PQ_query_param_timestamp (
   2016       &td->details.aml_staff.last_change),
   2017     GNUNET_PQ_query_param_end
   2018   };
   2019 
   2020   PREPARE (pg,
   2021            "insert_into_table_aml_staff",
   2022            "INSERT INTO aml_staff"
   2023            "(aml_staff_uuid"
   2024            ",decider_pub"
   2025            ",master_sig"
   2026            ",decider_name"
   2027            ",is_active"
   2028            ",read_only"
   2029            ",last_change"
   2030            ") VALUES "
   2031            "($1, $2, $3, $4, $5, $6, $7);");
   2032   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   2033                                              "insert_into_table_aml_staff",
   2034                                              params);
   2035 }
   2036 
   2037 
   2038 /**
   2039  * Function called with kyc_attributes records to insert into table.
   2040  *
   2041  * @param pg plugin context
   2042  * @param td record to insert
   2043  */
   2044 static enum GNUNET_DB_QueryStatus
   2045 irbt_cb_table_kyc_attributes (struct PostgresClosure *pg,
   2046                               const struct TALER_EXCHANGEDB_TableData *td)
   2047 {
   2048   struct GNUNET_PQ_QueryParam params[] = {
   2049     GNUNET_PQ_query_param_uint64 (&td->serial),
   2050     GNUNET_PQ_query_param_auto_from_type (
   2051       &td->details.kyc_attributes.h_payto),
   2052     GNUNET_PQ_query_param_uint64 (
   2053       &td->details.kyc_attributes.legitimization_serial),
   2054     GNUNET_PQ_query_param_timestamp (
   2055       &td->details.kyc_attributes.collection_time),
   2056     GNUNET_PQ_query_param_timestamp (
   2057       &td->details.kyc_attributes.expiration_time),
   2058     GNUNET_PQ_query_param_uint64 (
   2059       &td->details.kyc_attributes.trigger_outcome_serial),
   2060     GNUNET_PQ_query_param_fixed_size (
   2061       &td->details.kyc_attributes.encrypted_attributes,
   2062       td->details.kyc_attributes.encrypted_attributes_size),
   2063     GNUNET_PQ_query_param_end
   2064   };
   2065 
   2066   PREPARE (pg,
   2067            "insert_into_table_kyc_attributes",
   2068            "INSERT INTO kyc_attributes"
   2069            "(kyc_attributes_serial_id"
   2070            ",h_payto"
   2071            ",legitimization_serial"
   2072            ",collection_time"
   2073            ",expiration_time"
   2074            ",trigger_outcome_serial"
   2075            ",encrypted_attributes"
   2076            ") VALUES "
   2077            "($1, $2, $3, $4, $5, $6, $7);");
   2078   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   2079                                              "insert_into_table_kyc_attributes",
   2080                                              params);
   2081 }
   2082 
   2083 
   2084 /**
   2085  * Function called with aml_history records to insert into table.
   2086  *
   2087  * @param pg plugin context
   2088  * @param td record to insert
   2089  */
   2090 static enum GNUNET_DB_QueryStatus
   2091 irbt_cb_table_aml_history (struct PostgresClosure *pg,
   2092                            const struct TALER_EXCHANGEDB_TableData *td)
   2093 {
   2094   struct GNUNET_PQ_QueryParam params[] = {
   2095     GNUNET_PQ_query_param_uint64 (&td->serial),
   2096     GNUNET_PQ_query_param_auto_from_type (
   2097       &td->details.aml_history.h_payto),
   2098     GNUNET_PQ_query_param_uint64 (
   2099       &td->details.aml_history.outcome_serial_id),
   2100     GNUNET_PQ_query_param_string (
   2101       td->details.aml_history.justification),
   2102     GNUNET_PQ_query_param_auto_from_type (
   2103       &td->details.aml_history.decider_pub),
   2104     GNUNET_PQ_query_param_auto_from_type (
   2105       &td->details.aml_history.decider_sig),
   2106     GNUNET_PQ_query_param_end
   2107   };
   2108 
   2109   PREPARE (pg,
   2110            "insert_into_table_aml_history",
   2111            "INSERT INTO aml_history"
   2112            "(aml_history_serial_id"
   2113            ",h_payto"
   2114            ",outcome_serial_id"
   2115            ",justification"
   2116            ",decider_pub"
   2117            ",decider_sig"
   2118            ") VALUES "
   2119            "($1, $2, $3, $4, $5, $6);");
   2120   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   2121                                              "insert_into_table_aml_history",
   2122                                              params);
   2123 }
   2124 
   2125 
   2126 /**
   2127  * Function called with kyc_event records to insert into table.
   2128  *
   2129  * @param pg plugin context
   2130  * @param td record to insert
   2131  */
   2132 static enum GNUNET_DB_QueryStatus
   2133 irbt_cb_table_kyc_events (struct PostgresClosure *pg,
   2134                           const struct TALER_EXCHANGEDB_TableData *td)
   2135 {
   2136   struct GNUNET_PQ_QueryParam params[] = {
   2137     GNUNET_PQ_query_param_uint64 (&td->serial),
   2138     GNUNET_PQ_query_param_timestamp (
   2139       &td->details.kyc_events.event_timestamp),
   2140     GNUNET_PQ_query_param_string (
   2141       td->details.kyc_events.event_type),
   2142     GNUNET_PQ_query_param_end
   2143   };
   2144 
   2145   PREPARE (pg,
   2146            "insert_into_table_kyc_events",
   2147            "INSERT INTO kyc_events"
   2148            "(kyc_event_serial_id"
   2149            ",event_timestamp"
   2150            ",event_type"
   2151            ") VALUES "
   2152            "($1, $2, $3);");
   2153   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   2154                                              "insert_into_table_kyc_events",
   2155                                              params);
   2156 }
   2157 
   2158 
   2159 /**
   2160  * Function called with purse_deletion records to insert into table.
   2161  *
   2162  * @param pg plugin context
   2163  * @param td record to insert
   2164  */
   2165 static enum GNUNET_DB_QueryStatus
   2166 irbt_cb_table_purse_deletion (struct PostgresClosure *pg,
   2167                               const struct TALER_EXCHANGEDB_TableData *td)
   2168 {
   2169   struct GNUNET_PQ_QueryParam params[] = {
   2170     GNUNET_PQ_query_param_uint64 (&td->serial),
   2171     GNUNET_PQ_query_param_auto_from_type (
   2172       &td->details.purse_deletion.purse_pub),
   2173     GNUNET_PQ_query_param_auto_from_type (
   2174       &td->details.purse_deletion.purse_sig),
   2175     GNUNET_PQ_query_param_end
   2176   };
   2177 
   2178   PREPARE (pg,
   2179            "insert_into_table_purse_deletion",
   2180            "INSERT INTO purse_deletion"
   2181            "(purse_deletion_serial_id"
   2182            ",purse_pub"
   2183            ",purse_sig"
   2184            ") VALUES "
   2185            "($1, $2, $3);");
   2186   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
   2187                                              "insert_into_table_purse_deletion",
   2188                                              params);
   2189 }
   2190 
   2191 
   2192 /**
   2193  * Function called with withdraw records to insert into table.
   2194  *
   2195  * @param pg plugin context
   2196  * @param td record to insert
   2197  */
   2198 static enum GNUNET_DB_QueryStatus
   2199 irbt_cb_table_withdraw (
   2200   struct PostgresClosure *pg,
   2201   const struct TALER_EXCHANGEDB_TableData *td)
   2202 {
   2203   struct GNUNET_PQ_QueryParam params[] = {
   2204     GNUNET_PQ_query_param_uint64 (&td->serial),
   2205     GNUNET_PQ_query_param_auto_from_type (
   2206       &td->details.withdraw.planchets_h),
   2207     GNUNET_PQ_query_param_timestamp (
   2208       &td->details.withdraw.execution_date),
   2209     TALER_PQ_query_param_amount (
   2210       pg->conn,
   2211       &td->details.withdraw.amount_with_fee),
   2212     GNUNET_PQ_query_param_auto_from_type (
   2213       &td->details.withdraw.reserve_pub),
   2214     GNUNET_PQ_query_param_auto_from_type (
   2215       &td->details.withdraw.reserve_sig),
   2216     td->details.withdraw.age_proof_required
   2217     ? GNUNET_PQ_query_param_uint16 (
   2218       &td->details.withdraw.max_age)
   2219     : GNUNET_PQ_query_param_null (),
   2220     td->details.withdraw.age_proof_required
   2221     ? GNUNET_PQ_query_param_uint16 (
   2222       &td->details.withdraw.noreveal_index)
   2223     : GNUNET_PQ_query_param_null (),
   2224     td->details.withdraw.age_proof_required
   2225     ? GNUNET_PQ_query_param_auto_from_type (
   2226       &td->details.withdraw.selected_h)
   2227     : GNUNET_PQ_query_param_null (),
   2228     td->details.withdraw.no_blinding_seed
   2229     ? GNUNET_PQ_query_param_null ()
   2230     : GNUNET_PQ_query_param_auto_from_type (
   2231       &td->details.withdraw.blinding_seed),
   2232     (0 < td->details.withdraw.num_cs_r_values)
   2233     ? TALER_PQ_query_param_array_cs_r_pub (
   2234       td->details.withdraw.num_cs_r_values,
   2235       td->details.withdraw.cs_r_values,
   2236       pg->conn)
   2237     : GNUNET_PQ_query_param_null (),
   2238     (0 < td->details.withdraw.num_cs_r_values)
   2239     ? GNUNET_PQ_query_param_uint64 (
   2240       &td->details.withdraw.cs_r_choices)
   2241     : GNUNET_PQ_query_param_null (),
   2242     GNUNET_PQ_query_param_array_uint64 (
   2243       td->details.withdraw.num_coins,
   2244       td->details.withdraw.denom_serials,
   2245       pg->conn),
   2246     TALER_PQ_query_param_array_blinded_denom_sig (
   2247       td->details.withdraw.num_coins,
   2248       td->details.withdraw.denom_sigs,
   2249       pg->conn),
   2250     GNUNET_PQ_query_param_end
   2251   };
   2252   enum GNUNET_DB_QueryStatus qs;
   2253 
   2254   PREPARE (pg,
   2255            "insert_into_table_withdraw",
   2256            "INSERT INTO withdraw"
   2257            "(withdraw_id"
   2258            ",planchets_h"
   2259            ",execution_date"
   2260            ",amount_with_fee"
   2261            ",reserve_pub"
   2262            ",reserve_sig"
   2263            ",max_age"
   2264            ",noreveal_index"
   2265            ",selected_h"
   2266            ",blinding_seed"
   2267            ",cs_r_values"
   2268            ",cs_r_choices"
   2269            ",denom_serials"
   2270            ",denom_sigs"
   2271            ") VALUES "
   2272            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);");
   2273   qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
   2274                                            "insert_into_table_withdraw",
   2275                                            params);
   2276   GNUNET_PQ_cleanup_query_params_closures (params);
   2277   return qs;
   2278 }
   2279 
   2280 
   2281 enum GNUNET_DB_QueryStatus
   2282 TEH_PG_insert_records_by_table (void *cls,
   2283                                 const struct TALER_EXCHANGEDB_TableData *td)
   2284 {
   2285   struct PostgresClosure *pg = cls;
   2286   InsertRecordCallback rh = NULL;
   2287 
   2288   switch (td->table)
   2289   {
   2290   case TALER_EXCHANGEDB_RT_DENOMINATIONS:
   2291     rh = &irbt_cb_table_denominations;
   2292     break;
   2293   case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS:
   2294     rh = &irbt_cb_table_denomination_revocations;
   2295     break;
   2296   case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
   2297     rh = &irbt_cb_table_wire_targets;
   2298     break;
   2299   case TALER_EXCHANGEDB_RT_KYC_TARGETS:
   2300     rh = &irbt_cb_table_kyc_targets;
   2301     break;
   2302   case TALER_EXCHANGEDB_RT_RESERVES:
   2303     rh = &irbt_cb_table_reserves;
   2304     break;
   2305   case TALER_EXCHANGEDB_RT_RESERVES_IN:
   2306     rh = &irbt_cb_table_reserves_in;
   2307     break;
   2308   case TALER_EXCHANGEDB_RT_KYCAUTHS_IN:
   2309     rh = &irbt_cb_table_kycauths_in;
   2310     break;
   2311   case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
   2312     rh = &irbt_cb_table_reserves_close;
   2313     break;
   2314   case TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS:
   2315     rh = &irbt_cb_table_reserves_open_requests;
   2316     break;
   2317   case TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS:
   2318     rh = &irbt_cb_table_reserves_open_deposits;
   2319     break;
   2320   case TALER_EXCHANGEDB_RT_AUDITORS:
   2321     rh = &irbt_cb_table_auditors;
   2322     break;
   2323   case TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS:
   2324     rh = &irbt_cb_table_auditor_denom_sigs;
   2325     break;
   2326   case TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS:
   2327     rh = &irbt_cb_table_exchange_sign_keys;
   2328     break;
   2329   case TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS:
   2330     rh = &irbt_cb_table_signkey_revocations;
   2331     break;
   2332   case TALER_EXCHANGEDB_RT_KNOWN_COINS:
   2333     rh = &irbt_cb_table_known_coins;
   2334     break;
   2335   case TALER_EXCHANGEDB_RT_REFRESH:
   2336     rh = &irbt_cb_table_refresh;
   2337     break;
   2338   case TALER_EXCHANGEDB_RT_BATCH_DEPOSITS:
   2339     rh = &irbt_cb_table_batch_deposits;
   2340     break;
   2341   case TALER_EXCHANGEDB_RT_COIN_DEPOSITS:
   2342     rh = &irbt_cb_table_coin_deposits;
   2343     break;
   2344   case TALER_EXCHANGEDB_RT_REFUNDS:
   2345     rh = &irbt_cb_table_refunds;
   2346     break;
   2347   case TALER_EXCHANGEDB_RT_WIRE_OUT:
   2348     rh = &irbt_cb_table_wire_out;
   2349     break;
   2350   case TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING:
   2351     rh = &irbt_cb_table_aggregation_tracking;
   2352     break;
   2353   case TALER_EXCHANGEDB_RT_WIRE_FEE:
   2354     rh = &irbt_cb_table_wire_fee;
   2355     break;
   2356   case TALER_EXCHANGEDB_RT_GLOBAL_FEE:
   2357     rh = &irbt_cb_table_global_fee;
   2358     break;
   2359   case TALER_EXCHANGEDB_RT_RECOUP:
   2360     rh = &irbt_cb_table_recoup;
   2361     break;
   2362   case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
   2363     rh = &irbt_cb_table_recoup_refresh;
   2364     break;
   2365   case TALER_EXCHANGEDB_RT_EXTENSIONS:
   2366     rh = &irbt_cb_table_extensions;
   2367     break;
   2368   case TALER_EXCHANGEDB_RT_POLICY_DETAILS:
   2369     rh = &irbt_cb_table_policy_details;
   2370     break;
   2371   case TALER_EXCHANGEDB_RT_POLICY_FULFILLMENTS:
   2372     rh = &irbt_cb_table_policy_fulfillments;
   2373     break;
   2374   case TALER_EXCHANGEDB_RT_PURSE_REQUESTS:
   2375     rh = &irbt_cb_table_purse_requests;
   2376     break;
   2377   case TALER_EXCHANGEDB_RT_PURSE_DECISION:
   2378     rh = &irbt_cb_table_purse_decision;
   2379     break;
   2380   case TALER_EXCHANGEDB_RT_PURSE_MERGES:
   2381     rh = &irbt_cb_table_purse_merges;
   2382     break;
   2383   case TALER_EXCHANGEDB_RT_PURSE_DEPOSITS:
   2384     rh = &irbt_cb_table_purse_deposits;
   2385     break;
   2386   case TALER_EXCHANGEDB_RT_ACCOUNT_MERGES:
   2387     rh = &irbt_cb_table_account_mergers;
   2388     break;
   2389   case TALER_EXCHANGEDB_RT_HISTORY_REQUESTS:
   2390     rh = &irbt_cb_table_history_requests;
   2391     break;
   2392   case TALER_EXCHANGEDB_RT_CLOSE_REQUESTS:
   2393     rh = &irbt_cb_table_close_requests;
   2394     break;
   2395   case TALER_EXCHANGEDB_RT_WADS_OUT:
   2396     rh = &irbt_cb_table_wads_out;
   2397     break;
   2398   case TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES:
   2399     rh = &irbt_cb_table_wads_out_entries;
   2400     break;
   2401   case TALER_EXCHANGEDB_RT_WADS_IN:
   2402     rh = &irbt_cb_table_wads_in;
   2403     break;
   2404   case TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES:
   2405     rh = &irbt_cb_table_wads_in_entries;
   2406     break;
   2407   case TALER_EXCHANGEDB_RT_PROFIT_DRAINS:
   2408     rh = &irbt_cb_table_profit_drains;
   2409     break;
   2410   case TALER_EXCHANGEDB_RT_AML_STAFF:
   2411     rh = &irbt_cb_table_aml_staff;
   2412     break;
   2413   case TALER_EXCHANGEDB_RT_PURSE_DELETION:
   2414     rh = &irbt_cb_table_purse_deletion;
   2415     break;
   2416   case TALER_EXCHANGEDB_RT_WITHDRAW:
   2417     rh = &irbt_cb_table_withdraw;
   2418     break;
   2419   case TALER_EXCHANGEDB_RT_LEGITIMIZATION_MEASURES:
   2420     rh = &irbt_cb_table_legitimization_measures;
   2421     break;
   2422   case TALER_EXCHANGEDB_RT_LEGITIMIZATION_OUTCOMES:
   2423     rh = &irbt_cb_table_legitimization_outcomes;
   2424     break;
   2425   case TALER_EXCHANGEDB_RT_LEGITIMIZATION_PROCESSES:
   2426     rh = &irbt_cb_table_legitimization_processes;
   2427     break;
   2428   case TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES:
   2429     rh = &irbt_cb_table_kyc_attributes;
   2430     break;
   2431   case TALER_EXCHANGEDB_RT_AML_HISTORY:
   2432     rh = &irbt_cb_table_aml_history;
   2433     break;
   2434   case TALER_EXCHANGEDB_RT_KYC_EVENTS:
   2435     rh = &irbt_cb_table_kyc_events;
   2436     break;
   2437   }
   2438   if (NULL == rh)
   2439   {
   2440     GNUNET_break (0);
   2441     return GNUNET_DB_STATUS_HARD_ERROR;
   2442   }
   2443   return rh (pg,
   2444              td);
   2445 }
   2446 
   2447 
   2448 /* end of pg_insert_records_by_table.c */