LCOV - code coverage report
Current view: top level - auditordb - start.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 84.2 % 19 16
Test Date: 2026-05-12 15:34:29 Functions: 100.0 % 3 3

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2026 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 src/auditordb/start.c
      18              :  * @brief Implementation of the start, commit and rollback functions for Postgres
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "taler/taler_pq_lib.h"
      22              : #include "auditor-database/start.h"
      23              : #include "auditor-database/preflight.h"
      24              : #include "pg_helper.h"
      25              : 
      26              : 
      27              : enum GNUNET_GenericReturnValue
      28           22 : TALER_AUDITORDB_start (struct TALER_AUDITORDB_PostgresContext *pg)
      29              : {
      30           22 :   struct GNUNET_PQ_ExecuteStatement es[] = {
      31           22 :     GNUNET_PQ_make_execute ("START TRANSACTION ISOLATION LEVEL SERIALIZABLE"),
      32              :     GNUNET_PQ_EXECUTE_STATEMENT_END
      33              :   };
      34              : 
      35           22 :   GNUNET_break (GNUNET_OK ==
      36              :                 TALER_AUDITORDB_preflight (pg));
      37           22 :   if (GNUNET_OK !=
      38           22 :       GNUNET_PQ_exec_statements (pg->conn,
      39              :                                  es))
      40              :   {
      41            0 :     TALER_LOG_ERROR ("Failed to start transaction\n");
      42            0 :     GNUNET_break (0);
      43            0 :     return GNUNET_SYSERR;
      44              :   }
      45           22 :   return GNUNET_OK;
      46              : }
      47              : 
      48              : 
      49              : void
      50            9 : TALER_AUDITORDB_rollback (struct TALER_AUDITORDB_PostgresContext *pg)
      51              : {
      52            9 :   struct GNUNET_PQ_ExecuteStatement es[] = {
      53            9 :     GNUNET_PQ_make_execute ("ROLLBACK"),
      54              :     GNUNET_PQ_EXECUTE_STATEMENT_END
      55              :   };
      56              : 
      57            9 :   GNUNET_break (GNUNET_OK ==
      58              :                 GNUNET_PQ_exec_statements (pg->conn,
      59              :                                            es));
      60            9 : }
      61              : 
      62              : 
      63              : enum GNUNET_DB_QueryStatus
      64           14 : TALER_AUDITORDB_commit (struct TALER_AUDITORDB_PostgresContext *pg)
      65              : {
      66           14 :   struct GNUNET_PQ_QueryParam params[] = {
      67              :     GNUNET_PQ_query_param_end
      68              :   };
      69              : 
      70           14 :   PREPARE (pg,
      71              :            "do_commit",
      72              :            "COMMIT");
      73           14 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
      74              :                                              "do_commit",
      75              :                                              params);
      76              : }
        

Generated by: LCOV version 2.0-1