summaryrefslogtreecommitdiff
path: root/src/auditordb/pg_get_historic_denomination_revenue.c
diff options
context:
space:
mode:
authorCedric Zwahlen <cedric.zwahlen@students.bfh.ch>2024-04-16 18:54:24 +0200
committerCedric Zwahlen <cedric.zwahlen@students.bfh.ch>2024-04-19 20:47:34 +0200
commitba725b627efe5d5a6b4131898c7ee643fce85380 (patch)
tree01aad63c0e7a12f37e026fc64d1fc8f839fda5ce /src/auditordb/pg_get_historic_denomination_revenue.c
parent962bcbc6a6bd10f3bbe80766278c36b02f53c7e4 (diff)
downloadexchange-ba725b627efe5d5a6b4131898c7ee643fce85380.tar.gz
exchange-ba725b627efe5d5a6b4131898c7ee643fce85380.tar.bz2
exchange-ba725b627efe5d5a6b4131898c7ee643fce85380.zip
Fix various CRUD bugs
Diffstat (limited to 'src/auditordb/pg_get_historic_denomination_revenue.c')
-rw-r--r--src/auditordb/pg_get_historic_denomination_revenue.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/auditordb/pg_get_historic_denomination_revenue.c b/src/auditordb/pg_get_historic_denomination_revenue.c
index ca14e88a0..d09d66b4b 100644
--- a/src/auditordb/pg_get_historic_denomination_revenue.c
+++ b/src/auditordb/pg_get_historic_denomination_revenue.c
@@ -1,6 +1,3 @@
-
-
-
/*
This file is part of TALER
Copyright (C) 2024 Taler Systems SA
@@ -63,8 +60,8 @@ struct HistoricDenominationRevenueContext
*/
static void
historic_denomination_revenue_cb (void *cls,
- PGresult *result,
- unsigned int num_results)
+ PGresult *result,
+ unsigned int num_results)
{
struct HistoricDenominationRevenueContext *dcc = cls;
struct PostgresClosure *pg = dcc->pg;
@@ -79,11 +76,12 @@ historic_denomination_revenue_cb (void *cls,
GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id),
- GNUNET_PQ_result_spec_auto_from_type("denom_pub_hash", &dc.denom_pub_hash),
-GNUNET_PQ_result_spec_int64("revenue_timestamp", &dc.revenue_timestamp),
-TALER_PQ_RESULT_SPEC_AMOUNT("revenue_balance", &dc.revenue_balance),
-TALER_PQ_RESULT_SPEC_AMOUNT("loss_balance", &dc.loss_balance),
-GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed),
+ GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
+ &dc.denom_pub_hash),
+ GNUNET_PQ_result_spec_int64 ("revenue_timestamp", &dc.revenue_timestamp),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("revenue_balance", &dc.revenue_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("loss_balance", &dc.loss_balance),
+ GNUNET_PQ_result_spec_bool ("suppressed", &dc.suppressed),
GNUNET_PQ_result_spec_end
@@ -121,12 +119,12 @@ TAH_PG_get_historic_denomination_revenue (
TALER_AUDITORDB_HistoricDenominationRevenueCallback cb,
void *cb_cls)
{
-
+ uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&offset),
GNUNET_PQ_query_param_bool (return_suppressed),
- GNUNET_PQ_query_param_int64 (&limit),
+ GNUNET_PQ_query_param_uint64 (&plimit),
GNUNET_PQ_query_param_end
};
struct HistoricDenominationRevenueContext dcc = {
@@ -139,11 +137,12 @@ TAH_PG_get_historic_denomination_revenue (
PREPARE (pg,
"auditor_historic_denomination_revenue_get_desc",
"SELECT"
+ " row_id, "
" denom_pub_hash,"
-" revenue_timestamp,"
-" revenue_balance,"
-" loss_balance,"
-" suppressed"
+ " revenue_timestamp,"
+ " revenue_balance,"
+ " loss_balance,"
+ " suppressed"
" FROM auditor_historic_denomination_revenue"
" WHERE (row_id < $1)"
" AND ($2 OR suppressed is false)"
@@ -153,11 +152,12 @@ TAH_PG_get_historic_denomination_revenue (
PREPARE (pg,
"auditor_historic_denomination_revenue_get_asc",
"SELECT"
+ " row_id, "
" denom_pub_hash,"
-" revenue_timestamp,"
-" revenue_balance,"
-" loss_balance,"
-" suppressed"
+ " revenue_timestamp,"
+ " revenue_balance,"
+ " loss_balance,"
+ " suppressed"
" FROM auditor_historic_denomination_revenue"
" WHERE (row_id > $1)"
" AND ($2 OR suppressed is false)"
@@ -166,8 +166,10 @@ TAH_PG_get_historic_denomination_revenue (
);
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
(limit > 0)
- ? "auditor_historic_denomination_revenue_get_asc"
- : "auditor_historic_denomination_revenue_get_desc",
+ ?
+ "auditor_historic_denomination_revenue_get_asc"
+ :
+ "auditor_historic_denomination_revenue_get_desc",
params,
&historic_denomination_revenue_cb,
&dcc);
@@ -177,6 +179,3 @@ TAH_PG_get_historic_denomination_revenue (
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
return qs;
}
-
-
- \ No newline at end of file