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