diff options
Diffstat (limited to 'src/auditordb/pg_get_refreshes_hanging.c')
-rw-r--r-- | src/auditordb/pg_get_refreshes_hanging.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/auditordb/pg_get_refreshes_hanging.c b/src/auditordb/pg_get_refreshes_hanging.c index 5c88966f4..d4dd83b67 100644 --- a/src/auditordb/pg_get_refreshes_hanging.c +++ b/src/auditordb/pg_get_refreshes_hanging.c @@ -98,18 +98,20 @@ refreshes_hanging_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_refreshes_hanging ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_RefreshesHangingCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + 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_end + }; struct RefreshesHangingContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -118,16 +120,31 @@ TAH_PG_get_refreshes_hanging ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_refreshes_hanging_get", + "auditor_refreshes_hanging_get_desc", "SELECT" " row_id" ",amount" ",coin_pub" " FROM auditor_refreshes_hanging" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_refreshes_hanging_get_asc", + "SELECT" + " row_id" + ",amount" + ",coin_pub" + " FROM auditor_refreshes_hanging" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_refreshes_hanging_get", + (limit > 0) ? "auditor_refreshes_hanging_get_asc" : "auditor_refreshes_hanging_get_desc", params, &refreshes_hanging_cb, &dcc); |