LCOV - code coverage report
Current view: top level - auditordb - update_generic_suppressed.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 19 0
Test Date: 2026-04-14 15:39:31 Functions: 0.0 % 1 0

            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              : #include "taler/taler_pq_lib.h"
      17              : #include "pg_helper.h"
      18              : #include "auditor-database/update_generic_suppressed.h"
      19              : 
      20              : struct Preparations
      21              : {
      22              :   /**
      23              :    * Database reconnect counter.
      24              :    */
      25              :   unsigned long long cnt;
      26              : 
      27              :   /**
      28              :    * Which DB did we do prepare for.
      29              :    */
      30              :   struct TALER_AUDITORDB_PostgresContext *pg;
      31              : 
      32              : };
      33              : 
      34              : 
      35              : enum GNUNET_DB_QueryStatus
      36            0 : TALER_AUDITORDB_update_generic_suppressed (struct
      37              :                                            TALER_AUDITORDB_PostgresContext *pg,
      38              :                                            enum
      39              :                                            TALER_AUDITORDB_DeletableSuppressableTables
      40              :                                            table,
      41              :                                            uint64_t row_id,
      42              :                                            bool suppressed)
      43              : {
      44            0 :   struct GNUNET_PQ_QueryParam params[] = {
      45            0 :     GNUNET_PQ_query_param_uint64 (&row_id),
      46            0 :     GNUNET_PQ_query_param_bool (suppressed),
      47              :     GNUNET_PQ_query_param_end
      48              :   };
      49              :   static struct Preparations preps[
      50              :     TALER_AUDITORDB_DELETABLESUPPRESSABLE_TABLES_MAX];
      51              : 
      52            0 :   struct Preparations *prep = &preps[table];
      53            0 :   const char *table_name = TALER_AUDITORDB_get_deletable_suppressable_table_name
      54              :                            (
      55              :     table);
      56              :   char statement_name[256];
      57              : 
      58            0 :   GNUNET_snprintf (statement_name,
      59              :                    sizeof (statement_name),
      60              :                    "update_%s",
      61              :                    table_name);
      62            0 :   if ( (pg != prep->pg) ||
      63            0 :        (prep->cnt < pg->prep_gen) )
      64              :   {
      65              :     char sql[256];
      66            0 :     struct GNUNET_PQ_PreparedStatement ps[] = {
      67            0 :       GNUNET_PQ_make_prepare (statement_name,
      68              :                               sql),
      69              :       GNUNET_PQ_PREPARED_STATEMENT_END
      70              :     };
      71              : 
      72            0 :     GNUNET_snprintf (sql,
      73              :                      sizeof (sql),
      74              :                      "UPDATE %s SET"
      75              :                      " suppressed=$2"
      76              :                      " WHERE row_id=$1",
      77              :                      table_name);
      78            0 :     if (GNUNET_OK !=
      79            0 :         GNUNET_PQ_prepare_statements (pg->conn,
      80              :                                       ps))
      81              :     {
      82            0 :       GNUNET_break (0);
      83            0 :       return GNUNET_DB_STATUS_HARD_ERROR;
      84              :     }
      85            0 :     prep->pg = pg;
      86            0 :     prep->cnt = pg->prep_gen;
      87              :   }
      88            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
      89              :                                              statement_name,
      90              :                                              params);
      91              : }
        

Generated by: LCOV version 2.0-1