LCOV - code coverage report
Current view: top level - auditordb - pg_insert_auditor_progress.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 28 28
Test Date: 2025-12-28 14:06:02 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 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 pg_insert_auditor_progress.c
      18              :  * @brief Low-level (statement-level) Postgres database access for the exchange
      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_insert_auditor_progress.h"
      26              : #include "pg_helper.h"
      27              : 
      28              : 
      29              : enum GNUNET_DB_QueryStatus
      30           10 : TAH_PG_insert_auditor_progress (
      31              :   void *cls,
      32              :   const char *progress_key,
      33              :   uint64_t progress_offset,
      34              :   ...)
      35              : {
      36           10 :   struct PostgresClosure *pg = cls;
      37           10 :   unsigned int cnt = 1;
      38              :   va_list ap;
      39              : 
      40           10 :   va_start (ap,
      41              :             progress_offset);
      42           54 :   while (NULL != va_arg (ap,
      43              :                          const char *))
      44              :   {
      45           44 :     cnt++;
      46           44 :     (void) va_arg (ap,
      47              :                    uint64_t);
      48              :   }
      49           10 :   va_end (ap);
      50           10 :   {
      51           10 :     const char *keys[cnt];
      52           10 :     uint64_t offsets[cnt];
      53           10 :     unsigned int off = 1;
      54           10 :     struct GNUNET_PQ_QueryParam params[] = {
      55           10 :       GNUNET_PQ_query_param_array_ptrs_string (cnt,
      56              :                                                keys,
      57              :                                                pg->conn),
      58           10 :       GNUNET_PQ_query_param_array_uint64 (cnt,
      59              :                                           offsets,
      60              :                                           pg->conn),
      61              :       GNUNET_PQ_query_param_end
      62              :     };
      63              :     enum GNUNET_DB_QueryStatus qs;
      64              : 
      65           10 :     keys[0] = progress_key;
      66           10 :     offsets[0] = progress_offset;
      67              : 
      68           10 :     va_start (ap,
      69              :               progress_offset);
      70           54 :     while (off < cnt)
      71              :     {
      72           44 :       keys[off] = va_arg (ap,
      73              :                           const char *);
      74           44 :       offsets[off] = va_arg (ap,
      75              :                              uint64_t);
      76           44 :       off++;
      77              :     }
      78           10 :     GNUNET_assert (NULL == va_arg (ap,
      79              :                                    const char *));
      80           10 :     va_end (ap);
      81              : 
      82           10 :     PREPARE (pg,
      83              :              "auditor_progress_insert",
      84              :              "INSERT INTO auditor_progress "
      85              :              "(progress_key"
      86              :              ",progress_offset"
      87              :              ") SELECT *"
      88              :              " FROM UNNEST (CAST($1 AS TEXT[]),"
      89              :              "              CAST($2 AS INT8[]))"
      90              :              " ON CONFLICT DO NOTHING;");
      91           10 :     qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
      92              :                                              "auditor_progress_insert",
      93              :                                              params);
      94           10 :     GNUNET_PQ_cleanup_query_params_closures (params);
      95           10 :     return qs;
      96              :   }
      97              : }
        

Generated by: LCOV version 2.0-1