diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-08-23 22:59:29 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-08-23 22:59:29 +0200 |
commit | ca4b2e51ba0f732ea4b10a1fc2db1e24d2e27a34 (patch) | |
tree | 328f593016b42de6d80323051d02a5197ebe0a7b /src/auditordb | |
parent | 61e8d2fbfa1a546aa0af13cacaa05c34ce80a931 (diff) |
misc bugfixes, DCE
Diffstat (limited to 'src/auditordb')
-rw-r--r-- | src/auditordb/0002-auditor_denomination_pending.sql | 4 | ||||
-rw-r--r-- | src/auditordb/Makefile.am | 2 | ||||
-rw-r--r-- | src/auditordb/pg_del_purses.c | 42 | ||||
-rw-r--r-- | src/auditordb/pg_del_purses.h | 36 | ||||
-rw-r--r-- | src/auditordb/pg_del_reserves.c | 42 | ||||
-rw-r--r-- | src/auditordb/pg_del_reserves.h | 36 | ||||
-rw-r--r-- | src/auditordb/pg_get_auditor_closure_lags.c | 44 | ||||
-rw-r--r-- | src/auditordb/pg_get_balances.c | 62 | ||||
-rw-r--r-- | src/auditordb/pg_get_balances.h | 16 | ||||
-rw-r--r-- | src/auditordb/pg_get_denomination_pending.c | 48 | ||||
-rw-r--r-- | src/auditordb/pg_get_denomination_pending.h | 8 | ||||
-rw-r--r-- | src/auditordb/pg_get_purses.c | 30 | ||||
-rw-r--r-- | src/auditordb/pg_get_purses.h | 8 | ||||
-rw-r--r-- | src/auditordb/pg_get_reserves.c | 45 | ||||
-rw-r--r-- | src/auditordb/pg_get_reserves.h | 8 | ||||
-rw-r--r-- | src/auditordb/pg_get_wire_out_inconsistency.c | 9 | ||||
-rw-r--r-- | src/auditordb/plugin_auditordb_postgres.c | 8 |
17 files changed, 122 insertions, 326 deletions
diff --git a/src/auditordb/0002-auditor_denomination_pending.sql b/src/auditordb/0002-auditor_denomination_pending.sql index 00ed18145..2b1ee99a5 100644 --- a/src/auditordb/0002-auditor_denomination_pending.sql +++ b/src/auditordb/0002-auditor_denomination_pending.sql @@ -15,8 +15,8 @@ -- CREATE TABLE auditor_denomination_pending - (row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE, - denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64) + (row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE + ,denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64) ,denom_balance taler_amount NOT NULL ,denom_loss taler_amount NOT NULL ,num_issued BIGINT NOT NULL diff --git a/src/auditordb/Makefile.am b/src/auditordb/Makefile.am index de6a7cd99..3f43a5492 100644 --- a/src/auditordb/Makefile.am +++ b/src/auditordb/Makefile.am @@ -152,9 +152,7 @@ pg_insert_misattribution_in_inconsistency.c pg_insert_misattribution_in_inconsis pg_update_misattribution_in_inconsistency.c pg_update_misattribution_in_inconsistency.h \ pg_update_balance.c pg_update_balance.h \ pg_get_reserves.c pg_get_reserves.h \ -pg_del_reserves.c pg_del_reserves.h \ pg_get_purses.c pg_get_purses.h \ -pg_del_purses.c pg_del_purses.h \ pg_insert_historic_denom_revenue.c pg_insert_historic_denom_revenue.h \ pg_get_denomination_pending.c pg_get_denomination_pending.h \ pg_del_denomination_pending.c pg_del_denomination_pending.h \ diff --git a/src/auditordb/pg_del_purses.c b/src/auditordb/pg_del_purses.c deleted file mode 100644 index aeeaac88a..000000000 --- a/src/auditordb/pg_del_purses.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "pg_del_purses.h" - -#include "taler_pq_lib.h" -#include "pg_helper.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_del_purses ( - void *cls, - uint64_t row_id) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&row_id), - GNUNET_PQ_query_param_end - }; - - PREPARE (pg, - "auditor_delete_purses", - "DELETE" - " FROM auditor_purses" - " WHERE row_id=$1;"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "auditor_delete_purses", - params); -} diff --git a/src/auditordb/pg_del_purses.h b/src/auditordb/pg_del_purses.h deleted file mode 100644 index e4f4566ad..000000000 --- a/src/auditordb/pg_del_purses.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_DEL_PURSES_H -#define SRC_PG_DEL_PURSES_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -/** - * Delete a row from the bad sig losses table. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param row_id row to delete - * @return query transaction status - */ -enum GNUNET_DB_QueryStatus -TAH_PG_del_purses ( - void *cls, - uint64_t row_id); - -#endif // SRC_PG_DEL_PURSES_H diff --git a/src/auditordb/pg_del_reserves.c b/src/auditordb/pg_del_reserves.c deleted file mode 100644 index 731cec48f..000000000 --- a/src/auditordb/pg_del_reserves.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#include "pg_del_reserves.h" - -#include "taler_pq_lib.h" -#include "pg_helper.h" - -enum GNUNET_DB_QueryStatus -TAH_PG_del_reserves ( - void *cls, - uint64_t row_id) -{ - struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&row_id), - GNUNET_PQ_query_param_end - }; - - PREPARE (pg, - "auditor_delete_reserves", - "DELETE" - " FROM auditor_reserves" - " WHERE row_id=$1;"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "auditor_delete_reserves", - params); -} diff --git a/src/auditordb/pg_del_reserves.h b/src/auditordb/pg_del_reserves.h deleted file mode 100644 index 3e3136a69..000000000 --- a/src/auditordb/pg_del_reserves.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2024 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - - -#ifndef SRC_PG_DEL_RESERVES_H -#define SRC_PG_DEL_RESERVES_H - -#include "taler_util.h" -#include "taler_auditordb_plugin.h" - -/** - * Delete a row from the bad sig losses table. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param row_id row to delete - * @return query transaction status - */ -enum GNUNET_DB_QueryStatus -TAH_PG_del_reserves ( - void *cls, - uint64_t row_id); - -#endif // SRC_PG_DEL_RESERVES_H diff --git a/src/auditordb/pg_get_auditor_closure_lags.c b/src/auditordb/pg_get_auditor_closure_lags.c index e13fe1319..e92a7cb5b 100644 --- a/src/auditordb/pg_get_auditor_closure_lags.c +++ b/src/auditordb/pg_get_auditor_closure_lags.c @@ -19,7 +19,6 @@ #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_helper.h" - #include "pg_get_auditor_closure_lags.h" @@ -68,16 +67,18 @@ closure_lags_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { uint64_t serial_id; - struct TALER_AUDITORDB_ClosureLags dc; - struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &dc.amount), - GNUNET_PQ_result_spec_absolute_time ("deadline", &dc.deadline), - GNUNET_PQ_result_spec_auto_from_type ("wtid", &dc.wtid), - GNUNET_PQ_result_spec_string ("account", &dc.account), - + GNUNET_PQ_result_spec_uint64 ("row_id", + &serial_id), + TALER_PQ_RESULT_SPEC_AMOUNT ("amount", + &dc.amount), + GNUNET_PQ_result_spec_absolute_time ("deadline", + &dc.deadline), + GNUNET_PQ_result_spec_auto_from_type ("wtid", + &dc.wtid), + GNUNET_PQ_result_spec_string ("account", + &dc.account), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -91,9 +92,7 @@ closure_lags_cb (void *cls, dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; return; } - dcc->qs = i + 1; - rval = dcc->cb (dcc->cb_cls, serial_id, &dc); @@ -109,21 +108,18 @@ TAH_PG_get_auditor_closure_lags ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, // maybe not needed + bool return_suppressed, TALER_AUDITORDB_ClosureLagsCallback cb, void *cb_cls) { - - uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); - struct PostgresClosure *pg = cls; + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&offset), GNUNET_PQ_query_param_bool (return_suppressed), GNUNET_PQ_query_param_uint64 (&plimit), GNUNET_PQ_query_param_end }; - struct ClosureLagsContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -159,14 +155,14 @@ TAH_PG_get_auditor_closure_lags ( " ORDER BY row_id ASC" " LIMIT $3" ); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - (limit > 0) ? - "auditor_auditor_closure_lags_get_asc" - : - "auditor_auditor_closure_lags_get_desc", - params, - &closure_lags_cb, - &dcc); + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + (limit > 0) + ? "auditor_closure_lags_get_asc" + : "auditor_closure_lags_get_desc", + params, + &closure_lags_cb, + &dcc); if (qs > 0) return dcc.qs; diff --git a/src/auditordb/pg_get_balances.c b/src/auditordb/pg_get_balances.c index 8f8f2d682..da729bf38 100644 --- a/src/auditordb/pg_get_balances.c +++ b/src/auditordb/pg_get_balances.c @@ -13,14 +13,11 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - #include "platform.h" #include "taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_helper.h" - #include "pg_get_balances.h" @@ -69,17 +66,14 @@ balances_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { uint64_t serial_id; - struct TALER_AUDITORDB_Balances dc; - struct GNUNET_PQ_ResultSpec rs[] = { - - GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), - - GNUNET_PQ_result_spec_string ("balance_key", &dc.balance_key), - TALER_PQ_RESULT_SPEC_AMOUNT ("balance_value", &dc.balance_value), - - + GNUNET_PQ_result_spec_uint64 ("row_id", + &serial_id), + GNUNET_PQ_result_spec_string ("balance_key", + &dc.balance_key), + TALER_PQ_RESULT_SPEC_AMOUNT ("balance_value", + &dc.balance_value), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -93,9 +87,7 @@ balances_cb (void *cls, dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; return; } - dcc->qs = i + 1; - rval = dcc->cb (dcc->cb_cls, serial_id, &dc); @@ -111,30 +103,14 @@ TAH_PG_get_balances ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, const char *balance_key, TALER_AUDITORDB_BalancesCallback cb, void *cb_cls) { - - - /*if true, does not filter for a specific balance*/ - bool any_balance = true; - const char *bk; - - if (balance_key != NULL) - { - any_balance = false; - bk = balance_key; - } - else - { - bk = ""; - } - - uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); - struct PostgresClosure *pg = cls; + bool any_balance = (NULL == balance_key); + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); + const char *bk = (any_balance) ? "" : balance_key; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&offset), GNUNET_PQ_query_param_uint64 (&plimit), @@ -157,7 +133,7 @@ TAH_PG_get_balances ( " balance_value" " FROM auditor_balances" " WHERE (row_id < $1)" - " AND ($3 OR balance_key = $4)" + " AND ($3 OR balance_key = $4)" " ORDER BY row_id DESC" " LIMIT $2" ); @@ -169,18 +145,18 @@ TAH_PG_get_balances ( " balance_value" " FROM auditor_balances" " WHERE (row_id > $1)" - " AND ($3 OR balance_key = $4)" + " AND ($3 OR balance_key = $4)" " ORDER BY row_id ASC" " LIMIT $2" ); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - (limit > 0) - ? "auditor_balances_get_asc" - : "auditor_balances_get_desc", - params, - &balances_cb, - &dcc); - + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + (limit > 0) + ? "auditor_balances_get_asc" + : "auditor_balances_get_desc", + params, + &balances_cb, + &dcc); if (qs > 0) return dcc.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); diff --git a/src/auditordb/pg_get_balances.h b/src/auditordb/pg_get_balances.h index e2883ad8f..e4dc8911d 100644 --- a/src/auditordb/pg_get_balances.h +++ b/src/auditordb/pg_get_balances.h @@ -13,24 +13,21 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - -#ifndef SRC_PG_GET_BALANCES_H -#define SRC_PG_GET_BALANCES_H +#ifndef PG_GET_BALANCES_H +#define PG_GET_BALANCES_H #include "taler_util.h" #include "taler_json_lib.h" #include "taler_auditordb_plugin.h" - /** * Get information about balances from the database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param limit number of records to return, negative for descending - * @param offset table row to start from, exclusive, direction determined by @a limit - * @param return_suppressed should suppressed rows be returned anyway? - * @param balance_key key to look for + * @param limit number of balances to return at most, + * negative value to descend from @a offset + * @param offset row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) * @param cb function to call with results * @param cb_cls closure for @a cb * @return query result status @@ -40,7 +37,6 @@ TAH_PG_get_balances ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, const char *balance_key, TALER_AUDITORDB_BalancesCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_denomination_pending.c b/src/auditordb/pg_get_denomination_pending.c index 02ef99fe2..09276962c 100644 --- a/src/auditordb/pg_get_denomination_pending.c +++ b/src/auditordb/pg_get_denomination_pending.c @@ -13,14 +13,11 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - #include "platform.h" #include "taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_helper.h" - #include "pg_get_denomination_pending.h" @@ -71,14 +68,20 @@ denomination_pending_cb (void *cls, uint64_t serial_id; struct TALER_AUDITORDB_DenominationPending dc; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + GNUNET_PQ_result_spec_uint64 ("row_id", + &serial_id), GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &dc.denom_pub_hash), - TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance", &dc.denom_balance), - TALER_PQ_RESULT_SPEC_AMOUNT ("denom_loss", &dc.denom_loss), - GNUNET_PQ_result_spec_uint64 ("num_issued", &dc.num_issued), - TALER_PQ_RESULT_SPEC_AMOUNT ("denom_risk", &dc.denom_risk), - TALER_PQ_RESULT_SPEC_AMOUNT ("recoup_loss", &dc.recoup_loss), + TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance", + &dc.denom_balance), + TALER_PQ_RESULT_SPEC_AMOUNT ("denom_loss", + &dc.denom_loss), + GNUNET_PQ_result_spec_uint64 ("num_issued", + &dc.num_issued), + TALER_PQ_RESULT_SPEC_AMOUNT ("denom_risk", + &dc.denom_risk), + TALER_PQ_RESULT_SPEC_AMOUNT ("recoup_loss", + &dc.recoup_loss), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -108,14 +111,11 @@ TAH_PG_get_denomination_pending ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, // maybe not needed TALER_AUDITORDB_DenominationPendingCallback cb, void *cb_cls) { - - uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); - struct PostgresClosure *pg = cls; + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&offset), GNUNET_PQ_query_param_uint64 (&plimit), @@ -141,7 +141,7 @@ TAH_PG_get_denomination_pending ( " FROM auditor_denomination_pending" " WHERE (row_id < $1)" " ORDER BY row_id DESC" - " LIMIT $3" + " LIMIT $2" ); PREPARE (pg, "auditor_denomination_pending_get_asc", @@ -156,18 +156,16 @@ TAH_PG_get_denomination_pending ( " FROM auditor_denomination_pending" " WHERE (row_id > $1)" " ORDER BY row_id ASC" - " LIMIT $3" + " LIMIT $2" ); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - (limit > 0) - ? - "auditor_denomination_pending_get_asc" - : - "auditor_denomination_pending_get_desc", - params, - &denomination_pending_cb, - &dcc); - + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + (limit > 0) + ? "auditor_denomination_pending_get_asc" + : "auditor_denomination_pending_get_desc", + params, + &denomination_pending_cb, + &dcc); if (qs > 0) return dcc.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); diff --git a/src/auditordb/pg_get_denomination_pending.h b/src/auditordb/pg_get_denomination_pending.h index 478c3248c..f951a2c1b 100644 --- a/src/auditordb/pg_get_denomination_pending.h +++ b/src/auditordb/pg_get_denomination_pending.h @@ -13,10 +13,8 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - -#ifndef SRC_PG_GET_DENOMINATION_PENDING_H -#define SRC_PG_GET_DENOMINATION_PENDING_H +#ifndef PG_GET_DENOMINATION_PENDING_H +#define PG_GET_DENOMINATION_PENDING_H #include "taler_util.h" #include "taler_json_lib.h" @@ -28,7 +26,6 @@ * @param cls the @e cls of this struct with the plugin-specific state * @param limit number of records to return, negative for descending * @param offset table row to start from, exclusive, direction determined by @a limit - * @param return_suppressed should suppressed rows be returned anyway? * @param cb function to call with results * @param cb_cls closure for @a cb * @return query result status @@ -38,7 +35,6 @@ TAH_PG_get_denomination_pending ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, TALER_AUDITORDB_DenominationPendingCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_purses.c b/src/auditordb/pg_get_purses.c index b415d9aad..922e5c2a1 100644 --- a/src/auditordb/pg_get_purses.c +++ b/src/auditordb/pg_get_purses.c @@ -106,12 +106,11 @@ TAH_PG_get_purses ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, // maybe not needed TALER_AUDITORDB_PursesCallback cb, void *cb_cls) { - uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); struct PostgresClosure *pg = cls; + uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&offset), GNUNET_PQ_query_param_uint64 (&plimit), @@ -133,9 +132,9 @@ TAH_PG_get_purses ( " target," " expiration_date" " FROM auditor_purses" - " WHERE (row_id < $1)" - " ORDER BY row_id DESC" - " LIMIT $3" + " WHERE (auditor_purses_rowid < $1)" + " ORDER BY auditor_purses_rowid DESC" + " LIMIT $2" ); PREPARE (pg, "auditor_purses_get_asc", @@ -146,17 +145,18 @@ TAH_PG_get_purses ( " target," " expiration_date" " FROM auditor_purses" - " WHERE (row_id > $1)" - " ORDER BY row_id ASC" - " LIMIT $3" + " WHERE (auditor_purses_rowid > $1)" + " ORDER BY auditor_purses_rowid ASC" + " LIMIT $2" ); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - (limit > 0) - ? "auditor_purses_get_asc" - : "auditor_purses_get_desc", - params, - &purses_cb, - &dcc); + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + (limit > 0) + ? "auditor_purses_get_asc" + : "auditor_purses_get_desc", + params, + &purses_cb, + &dcc); if (qs > 0) return dcc.qs; diff --git a/src/auditordb/pg_get_purses.h b/src/auditordb/pg_get_purses.h index 5ee19bf2e..6f6d6659c 100644 --- a/src/auditordb/pg_get_purses.h +++ b/src/auditordb/pg_get_purses.h @@ -13,10 +13,8 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - -#ifndef SRC_PG_GET_PURSES_H -#define SRC_PG_GET_PURSES_H +#ifndef PG_GET_PURSES_H +#define PG_GET_PURSES_H #include "taler_util.h" #include "taler_json_lib.h" @@ -28,7 +26,6 @@ * @param cls the @e cls of this struct with the plugin-specific state * @param limit number of records to return, negative for descending * @param offset table row to start from, exclusive, direction determined by @a limit - * @param return_suppressed should suppressed rows be returned anyway? * @param cb function to call with results * @param cb_cls closure for @a cb * @return query result status @@ -38,7 +35,6 @@ TAH_PG_get_purses ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, TALER_AUDITORDB_PursesCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_reserves.c b/src/auditordb/pg_get_reserves.c index 32247c4ec..222fec908 100644 --- a/src/auditordb/pg_get_reserves.c +++ b/src/auditordb/pg_get_reserves.c @@ -69,19 +69,26 @@ reserves_cb (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("auditor_reserves_rowid", &dc.auditor_reserves_rowid), - GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &dc.reserve_pub), - TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance", &dc.reserve_balance), - TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_loss", &dc.reserve_loss), + GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", + &dc.reserve_pub), + TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance", + &dc.reserve_balance), + TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_loss", + &dc.reserve_loss), TALER_PQ_RESULT_SPEC_AMOUNT ("withdraw_fee_balance", &dc.withdraw_fee_balance), - TALER_PQ_RESULT_SPEC_AMOUNT ("close_fee_balance", &dc.close_fee_balance), - TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance", &dc.purse_fee_balance), - TALER_PQ_RESULT_SPEC_AMOUNT ("open_fee_balance", &dc.open_fee_balance), + TALER_PQ_RESULT_SPEC_AMOUNT ("close_fee_balance", + &dc.close_fee_balance), + TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance", + &dc.purse_fee_balance), + TALER_PQ_RESULT_SPEC_AMOUNT ("open_fee_balance", + &dc.open_fee_balance), TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee_balance", &dc.history_fee_balance), GNUNET_PQ_result_spec_absolute_time ("expiration_date", &dc.expiration_date), - GNUNET_PQ_result_spec_string ("origin_account", &dc.origin_account), + GNUNET_PQ_result_spec_string ("origin_account", + &dc.origin_account), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -111,7 +118,6 @@ TAH_PG_get_reserves ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, // maybe not needed TALER_AUDITORDB_ReservesCallback cb, void *cb_cls) { @@ -145,8 +151,8 @@ TAH_PG_get_reserves ( " origin_account" " FROM auditor_reserves" " WHERE (auditor_reserves_rowid < $1)" - " ORDER BY row_id DESC" - " LIMIT $3" + " ORDER BY auditor_reserves_rowid DESC" + " LIMIT $2" ); PREPARE (pg, "auditor_reserves_get_asc", @@ -164,16 +170,17 @@ TAH_PG_get_reserves ( " origin_account" " FROM auditor_reserves" " WHERE (auditor_reserves_rowid > $1)" - " ORDER BY row_id ASC" - " LIMIT $3" + " ORDER BY auditor_reserves_rowid ASC" + " LIMIT $2" ); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - (limit > 0) - ? "auditor_reserves_get_asc" - : "auditor_reserves_get_desc", - params, - &reserves_cb, - &dcc); + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + (limit > 0) + ? "auditor_reserves_get_asc" + : "auditor_reserves_get_desc", + params, + &reserves_cb, + &dcc); if (qs > 0) return dcc.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); diff --git a/src/auditordb/pg_get_reserves.h b/src/auditordb/pg_get_reserves.h index 6c07233b3..f6fe0776e 100644 --- a/src/auditordb/pg_get_reserves.h +++ b/src/auditordb/pg_get_reserves.h @@ -13,10 +13,8 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - -#ifndef SRC_PG_GET_RESERVES_H -#define SRC_PG_GET_RESERVES_H +#ifndef PG_GET_RESERVES_H +#define PG_GET_RESERVES_H #include "taler_util.h" #include "taler_json_lib.h" @@ -28,7 +26,6 @@ * @param cls the @e cls of this struct with the plugin-specific state * @param limit number of records to return, negative for descending * @param offset table row to start from, exclusive, direction determined by @a limit - * @param return_suppressed should suppressed rows be returned anyway? * @param cb function to call with results * @param cb_cls closure for @a cb * @return query result status @@ -38,7 +35,6 @@ TAH_PG_get_reserves ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, TALER_AUDITORDB_ReservesCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_wire_out_inconsistency.c b/src/auditordb/pg_get_wire_out_inconsistency.c index b875f6051..4e9ca905f 100644 --- a/src/auditordb/pg_get_wire_out_inconsistency.c +++ b/src/auditordb/pg_get_wire_out_inconsistency.c @@ -13,14 +13,11 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ - - #include "platform.h" #include "taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_helper.h" - #include "pg_get_wire_out_inconsistency.h" @@ -76,7 +73,7 @@ wire_out_inconsistency_cb (void *cls, &dc.destination_account), GNUNET_PQ_result_spec_string ("diagnostic", &dc.diagnostic), - GNUNET_PQ_result_spec_uint64 ("wire_out_row_id", + GNUNET_PQ_result_spec_uint64 ("wire_out_serial_id", &dc.wire_out_row_id), TALER_PQ_RESULT_SPEC_AMOUNT ("expected", &dc.expected), @@ -137,7 +134,7 @@ TAH_PG_get_wire_out_inconsistency ( " row_id" ",destination_account" ",diagnostic" - ",wire_out_row_id" + ",wire_out_serial_id" ",expected" ",claimed" ",suppressed" @@ -153,7 +150,7 @@ TAH_PG_get_wire_out_inconsistency ( " row_id" ",destination_account" ",diagnostic" - ",wire_out_row_id" + ",wire_out_serial_id" ",expected" ",claimed" ",suppressed" diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index 5dc8251c9..5c55e65e6 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -30,6 +30,7 @@ #include "pg_del_reserve_info.h" #include "pg_get_auditor_progress.h" #include "pg_get_balance.h" +#include "pg_get_balances.h" #include "pg_get_denomination_balance.h" #include "pg_get_deposit_confirmations.h" #include "pg_get_purse_info.h" @@ -141,10 +142,7 @@ #include "pg_update_misattribution_in_inconsistency.h" #include "pg_get_reserves.h" -#include "pg_del_reserves.h" - #include "pg_get_purses.h" -#include "pg_del_purses.h" #include "pg_get_denomination_pending.h" #include "pg_del_denomination_pending.h" @@ -588,6 +586,7 @@ libtaler_plugin_auditordb_postgres_init (void *cls) = &TAH_PG_get_auditor_progress; plugin->get_balance = &TAH_PG_get_balance; + plugin->get_balances = &TAH_PG_get_balances; plugin->insert_auditor_progress = &TAH_PG_insert_auditor_progress; @@ -777,10 +776,7 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->update_misattribution_in_inconsistency = &TAH_PG_update_misattribution_in_inconsistency; - plugin->delete_reserves = &TAH_PG_del_reserves; plugin->get_reserves = &TAH_PG_get_reserves; - - plugin->delete_purses = &TAH_PG_del_purses; plugin->get_purses = &TAH_PG_get_purses; plugin->delete_denomination_pending = &TAH_PG_del_denomination_pending; |