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 src/auditordb/select_reserve_in_inconsistency.c
18 : * @brief Implementation of the select_reserve_in_inconsistency function for Postgres
19 : * @author Christian Grothoff
20 : */
21 : #include "taler/taler_error_codes.h"
22 : #include "taler/taler_dbevents.h"
23 : #include "taler/taler_pq_lib.h"
24 : #include "auditor-database/select_reserve_in_inconsistency.h"
25 : #include "pg_helper.h"
26 :
27 :
28 : enum GNUNET_DB_QueryStatus
29 0 : TALER_AUDITORDB_select_reserve_in_inconsistency (
30 : struct TALER_AUDITORDB_PostgresContext *pg,
31 : uint64_t bank_row_id,
32 : struct TALER_AUDITORDB_ReserveInInconsistency *dc)
33 : {
34 0 : struct GNUNET_PQ_QueryParam params[] = {
35 0 : GNUNET_PQ_query_param_uint64 (&bank_row_id),
36 : GNUNET_PQ_query_param_end
37 : };
38 0 : struct GNUNET_PQ_ResultSpec rs[] = {
39 0 : GNUNET_PQ_result_spec_uint64 ("row_id",
40 : &dc->serial_id),
41 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("amount_exchange_expected",
42 : &dc->amount_exchange_expected),
43 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("amount_wired",
44 : &dc->amount_wired),
45 0 : GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
46 : &dc->reserve_pub),
47 0 : GNUNET_PQ_result_spec_absolute_time ("timestamp",
48 : &dc->timestamp),
49 0 : GNUNET_PQ_result_spec_string ("account",
50 : &dc->account.full_payto),
51 0 : GNUNET_PQ_result_spec_string ("diagnostic",
52 : &dc->diagnostic),
53 0 : GNUNET_PQ_result_spec_bool ("suppressed",
54 : &dc->suppressed),
55 : GNUNET_PQ_result_spec_end
56 : };
57 :
58 0 : dc->bank_row_id = bank_row_id;
59 0 : PREPARE (pg,
60 : "select_reserve_in_inconsistency",
61 : "SELECT"
62 : " row_id"
63 : ",amount_exchange_expected"
64 : ",amount_wired"
65 : ",reserve_pub"
66 : ",timestamp"
67 : ",account"
68 : ",diagnostic"
69 : ",suppressed"
70 : " FROM auditor_reserve_in_inconsistency"
71 : " WHERE (bank_row_id = $1)"
72 : );
73 0 : return GNUNET_PQ_eval_prepared_singleton_select (
74 : pg->conn,
75 : "select_reserve_in_inconsistency",
76 : params,
77 : rs);
78 : }
|