pg_insert_kyc_requirement_process.c (3259B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2022 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_insert_kyc_requirement_process.c 18 * @brief Implementation of the insert_kyc_requirement_process 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_insert_kyc_requirement_process.h" 26 #include "pg_helper.h" 27 #include <gnunet/gnunet_pq_lib.h> 28 29 30 enum GNUNET_DB_QueryStatus 31 TEH_PG_insert_kyc_requirement_process ( 32 void *cls, 33 const struct TALER_NormalizedPaytoHashP *h_payto, 34 uint32_t measure_index, 35 uint64_t legitimization_measure_serial_id, 36 const char *provider_name, 37 const char *provider_account_id, 38 const char *provider_legitimization_id, 39 uint64_t *process_row) 40 { 41 struct PostgresClosure *pg = cls; 42 struct GNUNET_TIME_Absolute now 43 = GNUNET_TIME_absolute_get (); 44 struct GNUNET_PQ_QueryParam params[] = { 45 GNUNET_PQ_query_param_auto_from_type (h_payto), 46 GNUNET_PQ_query_param_absolute_time (&now), 47 GNUNET_PQ_query_param_string (provider_name), 48 (NULL != provider_account_id) 49 ? GNUNET_PQ_query_param_string (provider_account_id) 50 : GNUNET_PQ_query_param_null (), 51 (NULL != provider_legitimization_id) 52 ? GNUNET_PQ_query_param_string (provider_legitimization_id) 53 : GNUNET_PQ_query_param_null (), 54 GNUNET_PQ_query_param_uint64 (&legitimization_measure_serial_id), 55 GNUNET_PQ_query_param_uint32 (&measure_index), 56 GNUNET_PQ_query_param_end 57 }; 58 struct GNUNET_PQ_ResultSpec rs[] = { 59 GNUNET_PQ_result_spec_uint64 ("legitimization_process_serial_id", 60 process_row), 61 GNUNET_PQ_result_spec_end 62 }; 63 64 PREPARE (pg, 65 "insert_kyc_requirement_process", 66 "INSERT INTO legitimization_processes" 67 " (h_payto" 68 " ,start_time" 69 " ,provider_name" 70 " ,provider_user_id" 71 " ,provider_legitimization_id" 72 " ,legitimization_measure_serial_id" 73 " ,measure_index" 74 " ) VALUES " 75 " ($1, $2, $3, $4, $5, $6, $7)" 76 " ON CONFLICT (legitimization_measure_serial_id,measure_index)" 77 " DO UPDATE" 78 " SET h_payto=$1" 79 " ,start_time=$2" 80 " ,provider_name=$3" 81 " ,provider_user_id=$4" 82 " ,provider_legitimization_id=$5" 83 " RETURNING legitimization_process_serial_id"); 84 return GNUNET_PQ_eval_prepared_singleton_select ( 85 pg->conn, 86 "insert_kyc_requirement_process", 87 params, 88 rs); 89 }