aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-06-23 14:37:53 +0200
committerChristian Grothoff <christian@grothoff.org>2017-06-23 14:37:53 +0200
commit6acb0271d6413b250cf78b42aed52a9cb0d0869c (patch)
treebad5474df053edbbe6ad877468365f6387ab9c73 /src/exchangedb
parentff8633910d90d7c5299016bce7a8ea49e12510a7 (diff)
address #5010 for wirewatch
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c52
-rw-r--r--src/exchangedb/test_exchangedb.c8
2 files changed, 16 insertions, 44 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 6758a308a..a41b19662 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -2092,56 +2092,28 @@ postgres_reserves_in_insert (void *cls,
* @param session the database session handle
* @param[out] wire_reference set to unique reference identifying the wire transfer (binary blob)
* @param[out] wire_reference_size set to number of bytes in @a wire_reference
- * @return #GNUNET_OK upon success; #GNUNET_NO if we never got any incoming transfers
- * #GNUNET_SYSERR upon failures (DB error)
+ * @return transaction status code
*/
-static int
+static enum GNUNET_DB_QueryStatus
postgres_get_latest_reserve_in_reference (void *cls,
struct TALER_EXCHANGEDB_Session *session,
void **wire_reference,
size_t *wire_reference_size)
{
- PGresult *result;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_end
};
- int ret;
-
- ret = GNUNET_SYSERR;
- result = GNUNET_PQ_exec_prepared (session->conn,
- "reserves_in_get_latest_wire_reference",
- params);
- if (PGRES_TUPLES_OK != PQresultStatus (result))
- {
- QUERY_ERR (result, session->conn);
- goto cleanup;
- }
- if (0 == PQntuples (result))
- {
- ret = GNUNET_NO;
- goto cleanup;
- }
- {
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_variable_size ("wire_reference",
- wire_reference,
- wire_reference_size),
- GNUNET_PQ_result_spec_end
- };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_variable_size ("wire_reference",
+ wire_reference,
+ wire_reference_size),
+ GNUNET_PQ_result_spec_end
+ };
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- 0))
- {
- GNUNET_break (0);
- goto cleanup;
- }
- }
- ret = GNUNET_OK;
- cleanup:
- PQclear (result);
- return ret;
+ return GNUNET_PQ_eval_prepared_singleton_select (session->conn,
+ "reserves_in_get_latest_wire_reference",
+ params,
+ rs);
}
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 701c20c79..ae0c82130 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1518,7 +1518,7 @@ run (void *cls)
result = 4;
sndr = json_loads ("{ \"account\":\"1\" }", 0, NULL);
GNUNET_assert (NULL != sndr);
- FAILIF (GNUNET_NO !=
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
plugin->get_latest_reserve_in_reference (plugin->cls,
session,
&rr,
@@ -1532,7 +1532,7 @@ run (void *cls)
sndr,
"TEST",
4));
- FAILIF (GNUNET_OK !=
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_latest_reserve_in_reference (plugin->cls,
session,
&rr,
@@ -1555,12 +1555,12 @@ run (void *cls)
sndr,
"TEST2",
5));
- FAILIF (GNUNET_OK !=
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_latest_reserve_in_reference (plugin->cls,
session,
&rr,
&rr_size));
- FAILIF (GNUNET_OK !=
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_latest_reserve_in_reference (plugin->cls,
session,
&rr,