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

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2025 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_enable_rules.c
      18              :  * @brief Implementation of the enable_rules 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_enable_rules.h"
      26              : #include "pg_helper.h"
      27              : 
      28              : 
      29              : enum GNUNET_GenericReturnValue
      30            0 : TEH_PG_enable_rules (
      31              :   void *cls,
      32              :   const char *schema)
      33              : {
      34            0 :   struct PostgresClosure *pg = cls;
      35              :   struct GNUNET_PQ_Context *conn;
      36              :   enum GNUNET_GenericReturnValue ret;
      37              :   char *sp;
      38              : 
      39            0 :   GNUNET_asprintf (&sp,
      40              :                    "SET search_path TO %s,exchange;",
      41              :                    schema);
      42              :   {
      43            0 :     struct GNUNET_PQ_ExecuteStatement es[] = {
      44            0 :       GNUNET_PQ_make_try_execute (sp),
      45              :       GNUNET_PQ_EXECUTE_STATEMENT_END
      46              :     };
      47              :     char *schemadash;
      48              : 
      49            0 :     GNUNET_asprintf (&schemadash,
      50              :                      "%s-",
      51              :                      schema);
      52            0 :     conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
      53              :                                        "exchangedb-postgres",
      54              :                                        schemadash,
      55              :                                        es,
      56              :                                        NULL);
      57            0 :     GNUNET_free (schemadash);
      58              :   }
      59            0 :   GNUNET_free (sp);
      60            0 :   if (NULL == conn)
      61            0 :     return GNUNET_SYSERR;
      62              :   {
      63              :     char *procfile;
      64              : 
      65            0 :     GNUNET_asprintf (&procfile,
      66              :                      "%s-procedures",
      67              :                      schema);
      68            0 :     ret = GNUNET_PQ_exec_sql (conn,
      69              :                               procfile);
      70              :     /* $SCHEMA-procedures MAY not exist, so only check for hard error */
      71            0 :     GNUNET_break (GNUNET_SYSERR != ret);
      72            0 :     if (GNUNET_NO == ret)
      73            0 :       ret = GNUNET_OK;
      74            0 :     GNUNET_free (procfile);
      75              :   }
      76            0 :   GNUNET_PQ_disconnect (conn);
      77            0 :   return ret;
      78              : }
        

Generated by: LCOV version 2.0-1