LCOV - code coverage report
Current view: top level - exchangedb - pg_select_wire_out_above_serial_id_by_account.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 30 0
Test Date: 2025-12-28 14:06:02 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2022, 2024 Taler Systems SA
       4              : 
       5              :    TALER is free software; you can redistribute it and/or modify it under the
       6              :    terms of the GNU General Public License as published by the Free Software
       7              :    Foundation; either version 3, or (at your option) any later version.
       8              : 
       9              :    TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10              :    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11              :    A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
      12              : 
      13              :    You should have received a copy of the GNU General Public License along with
      14              :    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15              :  */
      16              : /**
      17              :  * @file exchangedb/pg_select_wire_out_above_serial_id_by_account.c
      18              :  * @brief Implementation of the select_wire_out_above_serial_id_by_account function for Postgres
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "taler/platform.h"
      22              : #include "taler/taler_error_codes.h"
      23              : #include "taler/taler_dbevents.h"
      24              : #include "taler/taler_pq_lib.h"
      25              : #include "pg_select_wire_out_above_serial_id_by_account.h"
      26              : #include "pg_helper.h"
      27              : 
      28              : /**
      29              :  * Closure for #wire_out_serial_helper_cb().
      30              :  */
      31              : struct WireOutSerialContext
      32              : {
      33              : 
      34              :   /**
      35              :    * Callback to call.
      36              :    */
      37              :   TALER_EXCHANGEDB_WireTransferOutCallback cb;
      38              : 
      39              :   /**
      40              :    * Closure for @e cb.
      41              :    */
      42              :   void *cb_cls;
      43              : 
      44              :   /**
      45              :    * Plugin context.
      46              :    */
      47              :   struct PostgresClosure *pg;
      48              : 
      49              :   /**
      50              :    * Status code, set to #GNUNET_SYSERR on hard errors.
      51              :    */
      52              :   int status;
      53              : };
      54              : 
      55              : 
      56              : /**
      57              :  * Helper function to be called with the results of a SELECT statement
      58              :  * that has returned @a num_results results.
      59              :  *
      60              :  * @param cls closure of type `struct WireOutSerialContext`
      61              :  * @param result the postgres result
      62              :  * @param num_results the number of results in @a result
      63              :  */
      64              : static void
      65            0 : wire_out_serial_helper_cb (void *cls,
      66              :                            PGresult *result,
      67              :                            unsigned int num_results)
      68              : {
      69            0 :   struct WireOutSerialContext *wosc = cls;
      70            0 :   struct PostgresClosure *pg = wosc->pg;
      71              : 
      72            0 :   for (unsigned int i = 0; i<num_results; i++)
      73              :   {
      74              :     uint64_t rowid;
      75              :     struct GNUNET_TIME_Timestamp date;
      76              :     struct TALER_WireTransferIdentifierRawP wtid;
      77              :     struct TALER_FullPayto payto_uri;
      78              :     struct TALER_Amount amount;
      79            0 :     struct GNUNET_PQ_ResultSpec rs[] = {
      80            0 :       GNUNET_PQ_result_spec_uint64 ("wireout_uuid",
      81              :                                     &rowid),
      82            0 :       GNUNET_PQ_result_spec_timestamp ("execution_date",
      83              :                                        &date),
      84            0 :       GNUNET_PQ_result_spec_auto_from_type ("wtid_raw",
      85              :                                             &wtid),
      86            0 :       GNUNET_PQ_result_spec_string ("payto_uri",
      87              :                                     &payto_uri.full_payto),
      88            0 :       TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
      89              :                                    &amount),
      90              :       GNUNET_PQ_result_spec_end
      91              :     };
      92              :     int ret;
      93              : 
      94            0 :     if (GNUNET_OK !=
      95            0 :         GNUNET_PQ_extract_result (result,
      96              :                                   rs,
      97              :                                   i))
      98              :     {
      99            0 :       GNUNET_break (0);
     100            0 :       wosc->status = GNUNET_SYSERR;
     101            0 :       return;
     102              :     }
     103            0 :     ret = wosc->cb (wosc->cb_cls,
     104              :                     rowid,
     105              :                     date,
     106              :                     &wtid,
     107              :                     payto_uri,
     108              :                     &amount);
     109            0 :     GNUNET_PQ_cleanup_result (rs);
     110            0 :     if (GNUNET_OK != ret)
     111            0 :       break;
     112              :   }
     113              : }
     114              : 
     115              : 
     116              : enum GNUNET_DB_QueryStatus
     117            0 : TEH_PG_select_wire_out_above_serial_id_by_account (
     118              :   void *cls,
     119              :   const char *account_name,
     120              :   uint64_t serial_id,
     121              :   TALER_EXCHANGEDB_WireTransferOutCallback cb,
     122              :   void *cb_cls)
     123              : {
     124            0 :   struct PostgresClosure *pg = cls;
     125            0 :   struct GNUNET_PQ_QueryParam params[] = {
     126            0 :     GNUNET_PQ_query_param_uint64 (&serial_id),
     127            0 :     GNUNET_PQ_query_param_string (account_name),
     128              :     GNUNET_PQ_query_param_end
     129              :   };
     130            0 :   struct WireOutSerialContext wosc = {
     131              :     .cb = cb,
     132              :     .cb_cls = cb_cls,
     133              :     .pg = pg,
     134              :     .status = GNUNET_OK
     135              :   };
     136              :   enum GNUNET_DB_QueryStatus qs;
     137              : 
     138            0 :   PREPARE (pg,
     139              :            "select_wire_out_above_serial_id_by_account",
     140              :            "SELECT"
     141              :            " wo.wireout_uuid"
     142              :            ",wo.execution_date"
     143              :            ",wo.wtid_raw"
     144              :            ",wt.payto_uri"
     145              :            ",wo.amount"
     146              :            " FROM wire_out wo"
     147              :            " JOIN wire_targets wt"
     148              :            "   USING (wire_target_h_payto)"
     149              :            " WHERE wo.wireout_uuid>=$1 "
     150              :            "   AND wo.exchange_account_section=$2"
     151              :            " ORDER BY wo.wireout_uuid ASC;");
     152            0 :   qs = GNUNET_PQ_eval_prepared_multi_select (
     153              :     pg->conn,
     154              :     "select_wire_out_above_serial_id_by_account",
     155              :     params,
     156              :     &wire_out_serial_helper_cb,
     157              :     &wosc);
     158            0 :   if (GNUNET_OK != wosc.status)
     159            0 :     return GNUNET_DB_STATUS_HARD_ERROR;
     160            0 :   return qs;
     161              : }
        

Generated by: LCOV version 2.0-1