summaryrefslogtreecommitdiff
path: root/src/auditordb/pg_get_row_inconsistency.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditordb/pg_get_row_inconsistency.c')
-rw-r--r--src/auditordb/pg_get_row_inconsistency.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/auditordb/pg_get_row_inconsistency.c b/src/auditordb/pg_get_row_inconsistency.c
index 922880da8..67f83f6ed 100644
--- a/src/auditordb/pg_get_row_inconsistency.c
+++ b/src/auditordb/pg_get_row_inconsistency.c
@@ -99,18 +99,20 @@ row_inconsistency_cb (void *cls,
enum GNUNET_DB_QueryStatus
TAH_PG_get_row_inconsistency (
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_RowInconsistencyCallback 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 RowInconsistencyContext dcc = {
.cb = cb,
.cb_cls = cb_cls,
@@ -120,16 +122,31 @@ TAH_PG_get_row_inconsistency (
PREPARE (pg,
- "auditor_row_inconsistency_select",
+ "auditor_row_inconsistency_select_desc",
"SELECT"
" row_id"
",row_table"
",diagnostic"
" FROM auditor_row_inconsistency"
- " WHERE row_id>$1"
+ " WHERE (row_id < $1)"
+ " AND ($2 OR suppressed is false)"
+ " ORDER BY row_id DESC"
+ " LIMIT $3"
);
+ PREPARE (pg,
+ "auditor_row_inconsistency_select_asc",
+ "SELECT"
+ " row_id"
+ ",row_table"
+ ",diagnostic"
+ " FROM auditor_row_inconsistency"
+ " WHERE (row_id > $1)"
+ " AND ($2 OR suppressed is false)"
+ " ORDER BY row_id DESC"
+ " LIMIT $3"
+ );
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- "auditor_row_inconsistency_select",
+ (limit > 0) ? "auditor_row_inconsistency_select_asc" : "auditor_row_inconsistency_select_desc",
params,
&row_inconsistency_cb,
&dcc);