exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 9e127fb00d1e530c307a8df48d9325cdb6c84459
parent aa6c67546510d6a0274600cea8b06dbb87e486a9
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 29 Dec 2024 13:01:24 +0100

fix #9423

Diffstat:
Msrc/auditordb/pg_select_historic_denom_revenue.c | 36++++++++++++++++++++++++++++--------
Msrc/auditordb/pg_select_historic_reserve_revenue.c | 35+++++++++++++++++++++++++++--------
2 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/src/auditordb/pg_select_historic_denom_revenue.c b/src/auditordb/pg_select_historic_denom_revenue.c @@ -123,7 +123,10 @@ TAH_PG_select_historic_denom_revenue ( void *cb_cls) { struct PostgresClosure *pg = cls; + uint64_t ulimit = (limit > 0) ? limit : -limit; struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_uint64 (&ulimit), GNUNET_PQ_query_param_end }; struct HistoricDenomRevenueContext hrc = { @@ -133,21 +136,38 @@ TAH_PG_select_historic_denom_revenue ( }; enum GNUNET_DB_QueryStatus qs; - // FIXME: implement limit/offset! #9423 PREPARE (pg, - "auditor_historic_denomination_revenue_select", + "auditor_historic_denomination_revenue_select_inc", "SELECT" " row_id" ",denom_pub_hash" ",revenue_timestamp" ",revenue_balance" ",loss_balance" - " FROM auditor_historic_denomination_revenue;"); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_historic_denomination_revenue_select", - params, - &historic_denom_revenue_cb, - &hrc); + " FROM auditor_historic_denomination_revenue" + " WHERE row_id > $1" + " ORDER BY row_id ASC" + " LIMIT $2;"); + PREPARE (pg, + "auditor_historic_denomination_revenue_select_dec", + "SELECT" + " row_id" + ",denom_pub_hash" + ",revenue_timestamp" + ",revenue_balance" + ",loss_balance" + " FROM auditor_historic_denomination_revenue" + " WHERE row_id < $1" + " ORDER BY row_id DESC" + " LIMIT $2;"); + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + limit > 0 + ? "auditor_historic_denomination_revenue_select_inc" + : "auditor_historic_denomination_revenue_select_dec", + params, + &historic_denom_revenue_cb, + &hrc); if (qs <= 0) return qs; return hrc.qs; diff --git a/src/auditordb/pg_select_historic_reserve_revenue.c b/src/auditordb/pg_select_historic_reserve_revenue.c @@ -118,7 +118,10 @@ TAH_PG_select_historic_reserve_revenue ( void *cb_cls) { struct PostgresClosure *pg = cls; + uint64_t ulimit = (limit > 0) ? limit : -limit; struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_uint64 (&ulimit), GNUNET_PQ_query_param_end }; enum GNUNET_DB_QueryStatus qs; @@ -128,20 +131,36 @@ TAH_PG_select_historic_reserve_revenue ( .pg = pg }; - // FIXME: use limit/offset! #9423 PREPARE (pg, - "auditor_historic_reserve_summary_select", + "auditor_historic_reserve_summary_select_inc", "SELECT" " row_id" ",start_date" ",end_date" ",reserve_profits" - " FROM auditor_historic_reserve_summary"); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_historic_reserve_summary_select", - params, - &historic_reserve_revenue_cb, - &hrc); + " FROM auditor_historic_reserve_summary" + " WHERE row_id > $1" + " ORDER BY row_id ASC" + " LIMIT $2"); + PREPARE (pg, + "auditor_historic_reserve_summary_select_dec", + "SELECT" + " row_id" + ",start_date" + ",end_date" + ",reserve_profits" + " FROM auditor_historic_reserve_summary" + " WHERE row_id < $1" + " ORDER BY row_id DESC" + " LIMIT $2"); + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + limit > 0 + ? "auditor_historic_reserve_summary_select_inc" + : "auditor_historic_reserve_summary_select_dec", + params, + &historic_reserve_revenue_cb, + &hrc); if (0 >= qs) return qs; return hrc.qs;