profit_drains_get_pending.c (2905B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2022, 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 exchangedb/profit_drains_get_pending.c 18 * @brief Implementation of the profit_drains_get_pending function for Postgres 19 * @author Christian Grothoff 20 */ 21 #include "taler/taler_pq_lib.h" 22 #include "exchange-database/profit_drains_get_pending.h" 23 #include "helper.h" 24 25 26 enum GNUNET_DB_QueryStatus 27 TALER_EXCHANGEDB_profit_drains_get_pending ( 28 struct TALER_EXCHANGEDB_PostgresContext *pg, 29 uint64_t *serial, 30 struct TALER_WireTransferIdentifierRawP *wtid, 31 char **account_section, 32 struct TALER_FullPayto *payto_uri, 33 struct GNUNET_TIME_Timestamp *request_timestamp, 34 struct TALER_Amount *amount, 35 struct TALER_MasterSignatureP *master_sig) 36 { 37 struct GNUNET_PQ_QueryParam params[] = { 38 GNUNET_PQ_query_param_end 39 }; 40 struct GNUNET_PQ_ResultSpec rs[] = { 41 GNUNET_PQ_result_spec_uint64 ("profit_drain_serial_id", 42 serial), 43 GNUNET_PQ_result_spec_auto_from_type ("wtid", 44 wtid), 45 GNUNET_PQ_result_spec_string ("account_section", 46 account_section), 47 GNUNET_PQ_result_spec_string ("payto_uri", 48 &payto_uri->full_payto), 49 GNUNET_PQ_result_spec_timestamp ("trigger_date", 50 request_timestamp), 51 TALER_PQ_RESULT_SPEC_AMOUNT ("amount", 52 amount), 53 GNUNET_PQ_result_spec_auto_from_type ("master_sig", 54 master_sig), 55 GNUNET_PQ_result_spec_end 56 }; 57 /* Used in #postgres_profit_drains_get_pending() */ 58 PREPARE (pg, 59 "get_ready_profit_drain", 60 "SELECT" 61 " profit_drain_serial_id" 62 ",wtid" 63 ",account_section" 64 ",payto_uri" 65 ",trigger_date" 66 ",amount" 67 ",master_sig" 68 " FROM profit_drains" 69 " WHERE NOT executed" 70 " ORDER BY trigger_date ASC;"); 71 return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, 72 "get_ready_profit_drain", 73 params, 74 rs); 75 }