From 0e6c4ba898b0f4c7e53b02a65f99cc4b6b066ad7 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 15 Jun 2017 22:10:12 +0200 Subject: [PATCH] work on #5010 --- src/auditordb/plugin_auditordb_postgres.c | 25 +++++-------------- src/auditordb/test_auditordb.c | 3 ++- src/exchange/taler-exchange-httpd_keystate.c | 10 ++++---- src/exchange/test_taler_exchange_aggregator.c | 2 +- .../perf_taler_exchangedb_interpreter.c | 6 ++--- src/exchangedb/plugin_exchangedb_postgres.c | 10 ++++---- src/exchangedb/test_exchangedb.c | 2 +- src/include/taler_auditordb_plugin.h | 4 +-- src/include/taler_exchangedb_plugin.h | 4 +-- 9 files changed, 27 insertions(+), 39 deletions(-) diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index f144746ac..57f9e89c9 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -1159,16 +1159,13 @@ postgres_gc (void *cls) * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use * @param issue issuing information with value, fees and other info about the denomination - * @return #GNUNET_OK on success; #GNUNET_SYSERR on failure + * @return operation status result */ -static int +static enum GNUNET_DB_QueryStatus postgres_insert_denomination_info (void *cls, struct TALER_AUDITORDB_Session *session, const struct TALER_DenominationKeyValidityPS *issue) { - PGresult *result; - int ret; - struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&issue->denom_hash), GNUNET_PQ_query_param_auto_from_type (&issue->master), @@ -1198,20 +1195,9 @@ postgres_insert_denomination_info (void *cls, TALER_amount_cmp_currency_nbo (&issue->value, &issue->fee_refund)); - result = GNUNET_PQ_exec_prepared (session->conn, - "auditor_denominations_insert", - params); - if (PGRES_COMMAND_OK != PQresultStatus (result)) - { - ret = GNUNET_SYSERR; - BREAK_DB_ERR (result); - } - else - { - ret = GNUNET_OK; - } - PQclear (result); - return ret; + return GNUNET_PQ_eval_prepared_non_select (session->conn, + "auditor_denominations_insert", + params); } @@ -1237,6 +1223,7 @@ postgres_select_denomination_info (void *cls, GNUNET_PQ_query_param_end }; PGresult *result; + result = GNUNET_PQ_exec_prepared (session->conn, "auditor_denominations_select", params); diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c index bc23f1160..858e6bd91 100644 --- a/src/auditordb/test_auditordb.c +++ b/src/auditordb/test_auditordb.c @@ -19,6 +19,7 @@ * @author Gabor X Toth */ #include "platform.h" +#include #include "taler_auditordb_lib.h" #include "taler_auditordb_plugin.h" @@ -193,7 +194,7 @@ run (void *cls) TALER_amount_hton (&issue.fee_refresh, &fee_refresh); TALER_amount_hton (&issue.fee_refund, &fee_refund); - FAILIF (GNUNET_OK != + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_denomination_info (plugin->cls, session, &issue)); diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c index 6fc55a0b0..7c499b00b 100644 --- a/src/exchange/taler-exchange-httpd_keystate.c +++ b/src/exchange/taler-exchange-httpd_keystate.c @@ -485,11 +485,11 @@ reload_keys_denom_iter (void *cls, session); break; } - res = TEH_plugin->insert_denomination_info (TEH_plugin->cls, - session, - &dki->denom_pub, - &dki->issue); - if (GNUNET_OK != res) + qs = TEH_plugin->insert_denomination_info (TEH_plugin->cls, + session, + &dki->denom_pub, + &dki->issue); + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { /* Insert failed!? Very bad error, log and retry */ GNUNET_break (0); diff --git a/src/exchange/test_taler_exchange_aggregator.c b/src/exchange/test_taler_exchange_aggregator.c index db22613b7..7f9ea41da 100644 --- a/src/exchange/test_taler_exchange_aggregator.c +++ b/src/exchange/test_taler_exchange_aggregator.c @@ -1143,7 +1143,7 @@ run (void *cls) if ( (GNUNET_OK != plugin->start (plugin->cls, session)) || - (GNUNET_OK != + (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_denomination_info (plugin->cls, session, &dpk, diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c index 0a8efbb5d..2e4307547 100644 --- a/src/exchangedb/perf_taler_exchangedb_interpreter.c +++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015 GNUnet e.V. + Copyright (C) 2014-2017 GNUnet e.V. TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1446,7 +1446,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) case PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION: { unsigned int denom_index; - int ret; + enum GNUNET_DB_QueryStatus ret; struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki ; denom_index = state->cmd[state->i].details.insert_denomination.index_denom; @@ -1455,7 +1455,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) state->session, &dki->denom_pub, &dki->issue); - GNUNET_assert (GNUNET_SYSERR != ret); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == ret); } break; diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index a97d19701..510f8cec8 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -1775,9 +1775,9 @@ execute_prepared_non_select (struct TALER_EXCHANGEDB_Session *session, * @param session connection to use * @param denom_pub the public key used for signing coins of this denomination * @param issue issuing information with value, fees and other info about the coin - * @return #GNUNET_OK on success; #GNUNET_SYSERR on failure + * @return status of the query */ -static int +static enum GNUNET_DB_QueryStatus postgres_insert_denomination_info (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct TALER_DenominationPublicKey *denom_pub, @@ -1814,9 +1814,9 @@ postgres_insert_denomination_info (void *cls, TALER_amount_cmp_currency_nbo (&issue->properties.value, &issue->properties.fee_refund)); - return execute_prepared_non_select (session, - "denomination_insert", - params); + return GNUNET_PQ_eval_prepared_non_select (session->conn, + "denomination_insert", + params); } diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index fb52ddf92..adb723757 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -259,7 +259,7 @@ create_denom_key_pair (unsigned int size, dki.issue.properties.purpose.size = htonl (sizeof (struct TALER_DenominationKeyValidityPS)); dki.issue.properties.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY); - if (GNUNET_OK != + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_denomination_info (plugin->cls, session, &dki.denom_pub, diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index 170a68fdd..e4e6f343d 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -275,9 +275,9 @@ struct TALER_AUDITORDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use * @param issue issuing information with value, fees and other info about the denomination - * @return #GNUNET_OK on success; #GNUNET_SYSERR on failure + * @return status of database operation */ - int + enum GNUNET_DB_QueryStatus (*insert_denomination_info)(void *cls, struct TALER_AUDITORDB_Session *session, const struct TALER_DenominationKeyValidityPS *issue); diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 03020f2cc..924bfe7bb 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -1135,9 +1135,9 @@ struct TALER_EXCHANGEDB_Plugin * @param session connection to use * @param denom_pub the public key used for signing coins of this denomination * @param issue issuing information with value, fees and other info about the denomination - * @return #GNUNET_OK on success; #GNUNET_SYSERR on failure + * @return status of the query */ - int + enum GNUNET_DB_QueryStatus (*insert_denomination_info) (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct TALER_DenominationPublicKey *denom_pub,