diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-09-14 15:29:18 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-09-14 15:29:18 +0200 |
commit | 5a3d432138f722c46a2b1d6b7f1e220e9005dde7 (patch) | |
tree | 69a9877fa1465f30c88e85447639fec7dccedc08 | |
parent | 17b6f7fb7f03facbdc23be6a7f815cecd8aa3536 (diff) |
fix various ugly auditor logic bugs, including crash bugs, uninitialized memory, and memory leaks
21 files changed, 235 insertions, 271 deletions
diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c index 514422e5d..3a2b6def3 100644 --- a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c @@ -13,8 +13,6 @@ 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 <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> @@ -26,14 +24,15 @@ #include "taler-auditor-httpd.h" #include "taler-auditor-httpd_reserve-in-inconsistency-get.h" + /** -* Add reserve-in-inconsistency to the list. -* -* @param[in,out] cls a `json_t *` array to extend -* @param serial_id location of the @a dc in the database -* @param dc struct of inconsistencies -* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating -*/ + * Add reserve-in-inconsistency to the list. + * + * @param[in,out] cls a `json_t *` array to extend + * @param serial_id location of the @a dc in the database + * @param dc struct of inconsistencies + * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating + */ static enum GNUNET_GenericReturnValue process_reserve_in_inconsistency ( void *cls, @@ -44,18 +43,24 @@ process_reserve_in_inconsistency ( json_t *obj; obj = GNUNET_JSON_PACK ( - - GNUNET_JSON_pack_int64 ("row_id", serial_id), + GNUNET_JSON_pack_uint64 ("row_id", + serial_id), + GNUNET_JSON_pack_uint64 ("bank_row_id", + dc->bank_row_id), TALER_JSON_pack_amount ("amount_exchange_expected", &dc->amount_exchange_expected), - TALER_JSON_pack_amount ("amount_wired", &dc->amount_wired), - GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub), - TALER_JSON_pack_time_abs_human ("timestamp", dc->timestamp), - GNUNET_JSON_pack_string ("account", dc->account), - GNUNET_JSON_pack_string ("diagnostic", dc->diagnostic), - GNUNET_JSON_pack_bool ("suppressed", dc->suppressed) - - + TALER_JSON_pack_amount ("amount_wired", + &dc->amount_wired), + GNUNET_JSON_pack_data_auto ("reserve_pub", + &dc->reserve_pub), + TALER_JSON_pack_time_abs_human ("timestamp", + dc->timestamp), + GNUNET_JSON_pack_string ("account", + dc->account), + GNUNET_JSON_pack_string ("diagnostic", + dc->diagnostic), + GNUNET_JSON_pack_bool ("suppressed", + dc->suppressed) ); GNUNET_break (0 == json_array_append_new (list, @@ -77,6 +82,9 @@ TAH_RESERVE_IN_INCONSISTENCY_handler_get ( { json_t *ja; enum GNUNET_DB_QueryStatus qs; + int64_t limit = -20; + uint64_t offset; + bool return_suppressed = false; (void) rh; (void) connection_cls; @@ -91,34 +99,30 @@ TAH_RESERVE_IN_INCONSISTENCY_handler_get ( TALER_EC_GENERIC_DB_SETUP_FAILED, NULL); } - ja = json_array (); - GNUNET_break (NULL != ja); - - int64_t limit = -20; - uint64_t offset; - TALER_MHD_parse_request_snumber (connection, "limit", &limit); - if (limit < 0) offset = INT64_MAX; else offset = 0; - TALER_MHD_parse_request_number (connection, "offset", &offset); - - bool return_suppressed = false; - const char *ret_s = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "return_suppressed"); - if (ret_s != NULL && strcmp (ret_s, "true") == 0) { - return_suppressed = true; + const char *ret_s + = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + "return_suppressed"); + if ( (NULL != ret_s) && + (0 == strcmp (ret_s, + "true")) ) + { + return_suppressed = true; + } } - + ja = json_array (); + GNUNET_break (NULL != ja); qs = TAH_plugin->get_reserve_in_inconsistency ( TAH_plugin->cls, limit, @@ -126,7 +130,6 @@ TAH_RESERVE_IN_INCONSISTENCY_handler_get ( return_suppressed, &process_reserve_in_inconsistency, ja); - if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c index 807e6dc55..4d8bbad3f 100644 --- a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c @@ -13,8 +13,6 @@ 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 <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> @@ -26,39 +24,39 @@ #include "taler-auditor-httpd.h" #include "taler-auditor-httpd_reserve-not-closed-inconsistency-get.h" + /** -* Add reserve-not-closed-inconsistency to the list. -* -* @param[in,out] cls a `json_t *` array to extend -* @param serial_id location of the @a dc in the database -* @param dc struct of inconsistencies -* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating -*/ + * Add reserve-not-closed-inconsistency to the list. + * + * @param[in,out] cls a `json_t *` array to extend + * @param dc struct of inconsistencies + * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating + */ static enum GNUNET_GenericReturnValue process_reserve_not_closed_inconsistency ( void *cls, - uint64_t serial_id, const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc) { json_t *list = cls; json_t *obj; obj = GNUNET_JSON_PACK ( - - GNUNET_JSON_pack_int64 ("row_id", serial_id), - GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub), - TALER_JSON_pack_amount ("balance", &dc->balance), - TALER_JSON_pack_time_abs_human ("expiration_time", dc->expiration_time), - GNUNET_JSON_pack_data_auto ("diagnostic", &dc->diagnostic), - GNUNET_JSON_pack_bool ("suppressed", dc->suppressed) - - + GNUNET_JSON_pack_int64 ("row_id", + dc->row_id), + GNUNET_JSON_pack_data_auto ("reserve_pub", + &dc->reserve_pub), + TALER_JSON_pack_amount ("balance", + &dc->balance), + TALER_JSON_pack_time_abs_human ("expiration_time", + dc->expiration_time), + GNUNET_JSON_pack_data_auto ("diagnostic", + &dc->diagnostic), + GNUNET_JSON_pack_bool ("suppressed", + dc->suppressed) ); GNUNET_break (0 == json_array_append_new (list, obj)); - - return GNUNET_OK; } @@ -74,6 +72,9 @@ TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_get ( { json_t *ja; enum GNUNET_DB_QueryStatus qs; + int64_t limit = -20; + uint64_t offset; + bool return_suppressed = false; (void) rh; (void) connection_cls; @@ -88,34 +89,31 @@ TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_get ( TALER_EC_GENERIC_DB_SETUP_FAILED, NULL); } - ja = json_array (); - GNUNET_break (NULL != ja); - - int64_t limit = -20; - uint64_t offset; - TALER_MHD_parse_request_snumber (connection, "limit", &limit); - if (limit < 0) offset = INT64_MAX; else offset = 0; - TALER_MHD_parse_request_number (connection, "offset", &offset); - - bool return_suppressed = false; - const char *ret_s = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "return_suppressed"); - if (ret_s != NULL && strcmp (ret_s, "true") == 0) { - return_suppressed = true; + const char *ret_s + = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + "return_suppressed"); + if ( (NULL != ret_s) && + (0 == strcmp (ret_s, + "true")) ) + { + return_suppressed = true; + } } + ja = json_array (); + GNUNET_break (NULL != ja); qs = TAH_plugin->get_reserve_not_closed_inconsistency ( TAH_plugin->cls, limit, @@ -123,7 +121,6 @@ TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_get ( return_suppressed, &process_reserve_not_closed_inconsistency, ja); - if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c index 1c0b911a2..e529ce593 100644 --- a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c @@ -13,8 +13,6 @@ 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 <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> @@ -26,32 +24,33 @@ #include "taler-auditor-httpd.h" #include "taler-auditor-httpd_wire-format-inconsistency-get.h" + /** -* Add wire-format-inconsistency to the list. -* -* @param[in,out] cls a `json_t *` array to extend -* @param serial_id location of the @a dc in the database -* @param dc struct of inconsistencies -* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating -*/ + * Add wire-format-inconsistency to the list. + * + * @param[in,out] cls a `json_t *` array to extend + * @param dc struct of inconsistencies + * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating + */ static enum GNUNET_GenericReturnValue process_wire_format_inconsistency ( void *cls, - uint64_t serial_id, const struct TALER_AUDITORDB_WireFormatInconsistency *dc) { json_t *list = cls; json_t *obj; obj = GNUNET_JSON_PACK ( - - GNUNET_JSON_pack_int64 ("row_id", serial_id), - TALER_JSON_pack_amount ("amount", &dc->amount), - GNUNET_JSON_pack_int64 ("wire_offset", dc->wire_offset), - GNUNET_JSON_pack_data_auto ("diagnostic", dc->diagnostic), - GNUNET_JSON_pack_bool ("suppressed", dc->suppressed) - - + GNUNET_JSON_pack_uint64 ("row_id", + dc->row_id), + TALER_JSON_pack_amount ("amount", + &dc->amount), + GNUNET_JSON_pack_uint64 ("wire_offset", + dc->wire_offset), + GNUNET_JSON_pack_string ("diagnostic", + dc->diagnostic), + GNUNET_JSON_pack_bool ("suppressed", + dc->suppressed) ); GNUNET_break (0 == json_array_append_new (list, @@ -73,6 +72,9 @@ TAH_WIRE_FORMAT_INCONSISTENCY_handler_get ( { json_t *ja; enum GNUNET_DB_QueryStatus qs; + int64_t limit = -20; + uint64_t offset; + bool return_suppressed = false; (void) rh; (void) connection_cls; @@ -87,34 +89,29 @@ TAH_WIRE_FORMAT_INCONSISTENCY_handler_get ( TALER_EC_GENERIC_DB_SETUP_FAILED, NULL); } - ja = json_array (); - GNUNET_break (NULL != ja); - - int64_t limit = -20; - uint64_t offset; - TALER_MHD_parse_request_snumber (connection, "limit", &limit); - if (limit < 0) offset = INT64_MAX; else offset = 0; - TALER_MHD_parse_request_number (connection, "offset", &offset); - - bool return_suppressed = false; - const char *ret_s = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "return_suppressed"); - if (ret_s != NULL && strcmp (ret_s, "true") == 0) { - return_suppressed = true; + const char *ret_s = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + "return_suppressed"); + if ( (NULL != ret_s) && + (0 == strcmp (ret_s, "true")) ) + { + return_suppressed = true; + } } + ja = json_array (); + GNUNET_break (NULL != ja); qs = TAH_plugin->get_wire_format_inconsistency ( TAH_plugin->cls, limit, @@ -122,7 +119,6 @@ TAH_WIRE_FORMAT_INCONSISTENCY_handler_get ( return_suppressed, &process_wire_format_inconsistency, ja); - if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); diff --git a/src/auditordb/0002-auditor_closure_lags.sql b/src/auditordb/0002-auditor_closure_lags.sql index 73743e8a1..6822ef150 100644 --- a/src/auditordb/0002-auditor_closure_lags.sql +++ b/src/auditordb/0002-auditor_closure_lags.sql @@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS auditor_closure_lags amount taler_amount NOT NULL, deadline BIGINT NOT NULL, wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32), - account BYTEA NOT NULL, + account TEXT NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_closure_lags diff --git a/src/auditordb/0002-auditor_fee_time_inconsistency.sql b/src/auditordb/0002-auditor_fee_time_inconsistency.sql index b8cf3c212..c2ec60032 100644 --- a/src/auditordb/0002-auditor_fee_time_inconsistency.sql +++ b/src/auditordb/0002-auditor_fee_time_inconsistency.sql @@ -18,9 +18,9 @@ CREATE TABLE IF NOT EXISTS auditor_fee_time_inconsistency ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, problem_row_id BIGINT NOT NULL, - fee_type BYTEA NOT NULL, + fee_type TEXT NOT NULL, fee_time BIGINT NOT NULL, - diagnostic BYTEA NOT NULL, + diagnostic TEXT NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_fee_time_inconsistency diff --git a/src/auditordb/0002-auditor_reserve_in_inconsistency.sql b/src/auditordb/0002-auditor_reserve_in_inconsistency.sql index 5e14f0189..cbf695406 100644 --- a/src/auditordb/0002-auditor_reserve_in_inconsistency.sql +++ b/src/auditordb/0002-auditor_reserve_in_inconsistency.sql @@ -23,8 +23,8 @@ CREATE TABLE IF NOT EXISTS auditor_reserve_in_inconsistency amount_wired taler_amount NOT NULL, reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32), timestamp BIGINT NOT NULL, - account BYTEA NOT NULL, - diagnostic BYTEA NOT NULL, + account TEXT NOT NULL, + diagnostic TEXT NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_reserve_in_inconsistency diff --git a/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql b/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql index 82d378a44..5de538a16 100644 --- a/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql +++ b/src/auditordb/0002-auditor_reserve_not_closed_inconsistency.sql @@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS auditor_reserve_not_closed_inconsistency reserve_pub BYTEA PRIMARY KEY NOT NULL CHECK (LENGTH(reserve_pub)=32), balance taler_amount NOT NULL, expiration_time BIGINT, - diagnostic BYTEA, + diagnostic TEXT, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_reserve_not_closed_inconsistency diff --git a/src/auditordb/0002-auditor_row_minor_inconsistencies.sql b/src/auditordb/0002-auditor_row_minor_inconsistencies.sql index 9d0ee5d67..0668ef973 100644 --- a/src/auditordb/0002-auditor_row_minor_inconsistencies.sql +++ b/src/auditordb/0002-auditor_row_minor_inconsistencies.sql @@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS auditor_row_minor_inconsistencies row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, row_table BYTEA NOT NULL, problem_row BIGINT NOT NULL, - diagnostic BYTEA NOT NULL, + diagnostic TEXT NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_row_minor_inconsistencies diff --git a/src/auditordb/0002-auditor_wire_format_inconsistency.sql b/src/auditordb/0002-auditor_wire_format_inconsistency.sql index c11d8e63a..e6dff0562 100644 --- a/src/auditordb/0002-auditor_wire_format_inconsistency.sql +++ b/src/auditordb/0002-auditor_wire_format_inconsistency.sql @@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS auditor_wire_format_inconsistency row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, amount taler_amount NOT NULL, wire_offset BIGINT NOT NULL, - diagnostic BYTEA NOT NULL, + diagnostic TEXT NOT NULL, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); COMMENT ON TABLE auditor_wire_format_inconsistency diff --git a/src/auditordb/pg_get_auditor_closure_lags.c b/src/auditordb/pg_get_auditor_closure_lags.c index e92a7cb5b..443c7f9cf 100644 --- a/src/auditordb/pg_get_auditor_closure_lags.c +++ b/src/auditordb/pg_get_auditor_closure_lags.c @@ -71,6 +71,8 @@ closure_lags_cb (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + GNUNET_PQ_result_spec_uint64 ("problem_row_id", + &dc.problem_row_id), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &dc.amount), GNUNET_PQ_result_spec_absolute_time ("deadline", @@ -131,6 +133,7 @@ TAH_PG_get_auditor_closure_lags ( "auditor_closure_lags_get_desc", "SELECT" " row_id" + ",problem_row_id" ",amount" ",deadline" ",wtid" @@ -145,6 +148,7 @@ TAH_PG_get_auditor_closure_lags ( "auditor_closure_lags_get_asc", "SELECT" " row_id" + ",problem_row_id" ",amount" ",deadline" ",wtid" diff --git a/src/auditordb/pg_get_fee_time_inconsistency.c b/src/auditordb/pg_get_fee_time_inconsistency.c index ff1f570e8..51753fac9 100644 --- a/src/auditordb/pg_get_fee_time_inconsistency.c +++ b/src/auditordb/pg_get_fee_time_inconsistency.c @@ -13,16 +13,14 @@ 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_fee_time_inconsistency.h" + /** * Closure for #feetimeinconsistency_cb(). */ @@ -66,22 +64,21 @@ fee_time_inconsistency_cb (void *cls, unsigned int num_results) { struct FeeTimeInconsistencyContext *dcc = cls; - // struct PostgresClosure *pg = dcc->pg; - for (unsigned int i = 0; i < num_results; i++) { uint64_t serial_id; - struct TALER_AUDITORDB_FeeTimeInconsistency dc; - struct GNUNET_PQ_ResultSpec rs[] = { - - GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), - - GNUNET_PQ_result_spec_string ("type", &dc.type), - GNUNET_PQ_result_spec_absolute_time ("time", &dc.time), - GNUNET_PQ_result_spec_string ("diagnostic", &dc.diagnostic), - + GNUNET_PQ_result_spec_uint64 ("row_id", + &serial_id), + GNUNET_PQ_result_spec_uint64 ("problem_row_id", + &dc.problem_row_id), + GNUNET_PQ_result_spec_string ("fee_type", + &dc.type), + GNUNET_PQ_result_spec_absolute_time ("fee_time", + &dc.time), + GNUNET_PQ_result_spec_string ("diagnostic", + &dc.diagnostic), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -95,9 +92,7 @@ fee_time_inconsistency_cb (void *cls, dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; return; } - dcc->qs = i + 1; - rval = dcc->cb (dcc->cb_cls, serial_id, &dc); @@ -113,14 +108,12 @@ TAH_PG_get_fee_time_inconsistency ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, // maybe not needed + bool return_suppressed, TALER_AUDITORDB_FeeTimeInconsistencyCallback 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), @@ -138,8 +131,9 @@ TAH_PG_get_fee_time_inconsistency ( "auditor_fee_time_inconsistency_get_desc", "SELECT" " row_id" - ",type" - ",time" + ",problem_row_id" + ",fee_type" + ",fee_time" ",diagnostic" " FROM auditor_fee_time_inconsistency" " WHERE (row_id < $1)" @@ -151,8 +145,9 @@ TAH_PG_get_fee_time_inconsistency ( "auditor_fee_time_inconsistency_get_asc", "SELECT" " row_id" - ",type" - ",time" + ",problem_row_id" + ",fee_type" + ",fee_time" ",diagnostic" " FROM auditor_fee_time_inconsistency" " WHERE (row_id > $1)" @@ -160,17 +155,16 @@ TAH_PG_get_fee_time_inconsistency ( " ORDER BY row_id ASC" " LIMIT $3" ); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - (limit > 0) ? - "auditor_fee_time_inconsistency_get_asc" - : - "auditor_fee_time_inconsistency_get_desc", - params, - &fee_time_inconsistency_cb, - &dcc); - + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + (limit > 0) + ? "auditor_fee_time_inconsistency_get_asc" + : "auditor_fee_time_inconsistency_get_desc", + params, + &fee_time_inconsistency_cb, + &dcc); if (qs > 0) return dcc.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); return qs; -}
\ No newline at end of file +} diff --git a/src/auditordb/pg_get_reserve_in_inconsistency.c b/src/auditordb/pg_get_reserve_in_inconsistency.c index 017566f96..5fc128d31 100644 --- a/src/auditordb/pg_get_reserve_in_inconsistency.c +++ b/src/auditordb/pg_get_reserve_in_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_reserve_in_inconsistency.h" @@ -69,23 +66,26 @@ reserve_in_inconsistency_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { uint64_t serial_id; - struct TALER_AUDITORDB_ReserveInInconsistency 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_uint64 ("bank_row_id", + &dc.bank_row_id), TALER_PQ_RESULT_SPEC_AMOUNT ("amount_exchange_expected", &dc.amount_exchange_expected), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount_wired", &dc.amount_wired), - GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &dc.reserve_pub), - GNUNET_PQ_result_spec_absolute_time ("timestamp", &dc.timestamp), - GNUNET_PQ_result_spec_auto_from_type ("account", &dc.account), - GNUNET_PQ_result_spec_auto_from_type ("diagnostic", &dc.diagnostic), - GNUNET_PQ_result_spec_bool ("suppressed", &dc.suppressed), - - + TALER_PQ_RESULT_SPEC_AMOUNT ("amount_wired", + &dc.amount_wired), + GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", + &dc.reserve_pub), + GNUNET_PQ_result_spec_absolute_time ("timestamp", + &dc.timestamp), + GNUNET_PQ_result_spec_string ("account", + &dc.account), + GNUNET_PQ_result_spec_string ("diagnostic", + &dc.diagnostic), + GNUNET_PQ_result_spec_bool ("suppressed", + &dc.suppressed), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -117,14 +117,12 @@ TAH_PG_get_reserve_in_inconsistency ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, // maybe not needed + bool return_suppressed, TALER_AUDITORDB_ReserveInInconsistencyCallback 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), @@ -142,13 +140,14 @@ TAH_PG_get_reserve_in_inconsistency ( "auditor_reserve_in_inconsistency_get_desc", "SELECT" " row_id," - " amount_exchange_expected," - " amount_wired," - " reserve_pub," - " timestamp," - " account," - " diagnostic," - " suppressed" + ",bank_row_id" + ",amount_exchange_expected" + ",amount_wired" + ",reserve_pub" + ",timestamp" + ",account" + ",diagnostic" + ",suppressed" " FROM auditor_reserve_in_inconsistency" " WHERE (row_id < $1)" " AND ($2 OR suppressed is false)" @@ -158,30 +157,29 @@ TAH_PG_get_reserve_in_inconsistency ( PREPARE (pg, "auditor_reserve_in_inconsistency_get_asc", "SELECT" - " row_id," - " amount_exchange_expected," - " amount_wired," - " reserve_pub," - " timestamp," - " account," - " diagnostic," - " suppressed" + " row_id" + ",bank_row_id" + ",amount_exchange_expected" + ",amount_wired" + ",reserve_pub" + ",timestamp" + ",account" + ",diagnostic" + ",suppressed" " FROM auditor_reserve_in_inconsistency" " 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, - (limit > 0) - ? - "auditor_reserve_in_inconsistency_get_asc" - : - "auditor_reserve_in_inconsistency_get_desc", - params, - &reserve_in_inconsistency_cb, - &dcc); - + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + (limit > 0) + ? "auditor_reserve_in_inconsistency_get_asc" + : "auditor_reserve_in_inconsistency_get_desc", + params, + &reserve_in_inconsistency_cb, + &dcc); if (qs > 0) return dcc.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); diff --git a/src/auditordb/pg_get_reserve_not_closed_inconsistency.c b/src/auditordb/pg_get_reserve_not_closed_inconsistency.c index e5583509e..d8421b1f8 100644 --- a/src/auditordb/pg_get_reserve_not_closed_inconsistency.c +++ b/src/auditordb/pg_get_reserve_not_closed_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_reserve_not_closed_inconsistency.h" @@ -68,22 +65,20 @@ reserve_not_closed_inconsistency_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { - uint64_t serial_id; - struct TALER_AUDITORDB_ReserveNotClosedInconsistency dc; - struct GNUNET_PQ_ResultSpec rs[] = { - - GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), - - GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &dc.reserve_pub), - TALER_PQ_RESULT_SPEC_AMOUNT ("balance", &dc.balance), + GNUNET_PQ_result_spec_uint64 ("row_id", + &dc.row_id), + GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", + &dc.reserve_pub), + TALER_PQ_RESULT_SPEC_AMOUNT ("balance", + &dc.balance), GNUNET_PQ_result_spec_absolute_time ("expiration_time", &dc.expiration_time), - GNUNET_PQ_result_spec_auto_from_type ("diagnostic", &dc.diagnostic), - GNUNET_PQ_result_spec_bool ("suppressed", &dc.suppressed), - - + GNUNET_PQ_result_spec_string ("diagnostic", + &dc.diagnostic), + GNUNET_PQ_result_spec_bool ("suppressed", + &dc.suppressed), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -97,11 +92,8 @@ reserve_not_closed_inconsistency_cb (void *cls, dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; return; } - dcc->qs = i + 1; - rval = dcc->cb (dcc->cb_cls, - serial_id, &dc); GNUNET_PQ_cleanup_result (rs); if (GNUNET_OK != rval) @@ -115,14 +107,12 @@ TAH_PG_get_reserve_not_closed_inconsistency ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, // maybe not needed + bool return_suppressed, TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback 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), @@ -140,11 +130,11 @@ TAH_PG_get_reserve_not_closed_inconsistency ( "auditor_reserve_not_closed_inconsistency_get_desc", "SELECT" " row_id," - " reserve_pub," - " balance," - " expiration_time," - " diagnostic," - " suppressed" + ",reserve_pub" + ",balance" + ",expiration_time" + ",diagnostic" + ",suppressed" " FROM auditor_reserve_not_closed_inconsistency" " WHERE (row_id < $1)" " AND ($2 OR suppressed is false)" @@ -154,29 +144,26 @@ TAH_PG_get_reserve_not_closed_inconsistency ( PREPARE (pg, "auditor_reserve_not_closed_inconsistency_get_asc", "SELECT" - " row_id," - " reserve_pub," - " balance," - " expiration_time," - " diagnostic," - " suppressed" + " row_id" + ",reserve_pub" + ",balance" + ",expiration_time" + ",diagnostic" + ",suppressed" " FROM auditor_reserve_not_closed_inconsistency" " 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, - (limit > 0) - ? - "auditor_reserve_not_closed_inconsistency_get_asc" - : - "auditor_reserve_not_closed_inconsistency_get_desc", - params, - & - reserve_not_closed_inconsistency_cb, - &dcc); - + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + (limit > 0) + ? "auditor_reserve_not_closed_inconsistency_get_asc" + : "auditor_reserve_not_closed_inconsistency_get_desc", + params, + &reserve_not_closed_inconsistency_cb, + &dcc); if (qs > 0) return dcc.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); diff --git a/src/auditordb/pg_get_row_minor_inconsistencies.c b/src/auditordb/pg_get_row_minor_inconsistencies.c index 9e2bc62e1..641ea908f 100644 --- a/src/auditordb/pg_get_row_minor_inconsistencies.c +++ b/src/auditordb/pg_get_row_minor_inconsistencies.c @@ -61,7 +61,6 @@ row_minor_inconsistencies_cb (void *cls, unsigned int num_results) { struct RowMinorInconsistenciesContext *dcc = cls; - // struct PostgresClosure *pg = dcc->pg; for (unsigned int i = 0; i < num_results; i++) { @@ -73,8 +72,8 @@ row_minor_inconsistencies_cb (void *cls, &dc.row_table), GNUNET_PQ_result_spec_uint64 ("problem_row", &dc.problem_row), - GNUNET_PQ_result_spec_auto_from_type ("diagnostic", - &dc.diagnostic), + GNUNET_PQ_result_spec_string ("diagnostic", + &dc.diagnostic), GNUNET_PQ_result_spec_bool ("suppressed", &dc.suppressed), GNUNET_PQ_result_spec_end diff --git a/src/auditordb/pg_get_wire_format_inconsistency.c b/src/auditordb/pg_get_wire_format_inconsistency.c index 333f9c9c0..d3f2b8960 100644 --- a/src/auditordb/pg_get_wire_format_inconsistency.c +++ b/src/auditordb/pg_get_wire_format_inconsistency.c @@ -65,21 +65,18 @@ wire_format_inconsistency_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { - uint64_t serial_id; struct TALER_AUDITORDB_WireFormatInconsistency dc; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("row_id", - &serial_id), + &dc.row_id), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &dc.amount), GNUNET_PQ_result_spec_uint64 ("wire_offset", &dc.wire_offset), - GNUNET_PQ_result_spec_auto_from_type ("diagnostic", - &dc.diagnostic), + GNUNET_PQ_result_spec_string ("diagnostic", + &dc.diagnostic), GNUNET_PQ_result_spec_bool ("suppressed", &dc.suppressed), - - GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -95,7 +92,6 @@ wire_format_inconsistency_cb (void *cls, } dcc->qs = i + 1; rval = dcc->cb (dcc->cb_cls, - serial_id, &dc); GNUNET_PQ_cleanup_result (rs); if (GNUNET_OK != rval) diff --git a/src/auditordb/pg_insert_fee_time_inconsistency.c b/src/auditordb/pg_insert_fee_time_inconsistency.c index 852e58018..4316ba2c8 100644 --- a/src/auditordb/pg_insert_fee_time_inconsistency.c +++ b/src/auditordb/pg_insert_fee_time_inconsistency.c @@ -36,9 +36,9 @@ TAH_PG_insert_fee_time_inconsistency ( PREPARE (pg, "auditor_fee_time_inconsistency_insert", "INSERT INTO auditor_fee_time_inconsistency " - "(type" + "(fee_type" ",problem_row_id" - ",time" + ",fee_time" ",diagnostic" ") VALUES ($1,$2,$3,$4);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, diff --git a/src/auditordb/pg_insert_reserve_in_inconsistency.c b/src/auditordb/pg_insert_reserve_in_inconsistency.c index f92249049..c584a0ff4 100644 --- a/src/auditordb/pg_insert_reserve_in_inconsistency.c +++ b/src/auditordb/pg_insert_reserve_in_inconsistency.c @@ -13,14 +13,12 @@ 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_pq_lib.h" #include "pg_helper.h" - #include "pg_insert_reserve_in_inconsistency.h" + enum GNUNET_DB_QueryStatus TAH_PG_insert_reserve_in_inconsistency ( void *cls, @@ -35,8 +33,8 @@ TAH_PG_insert_reserve_in_inconsistency ( &dc->amount_wired), GNUNET_PQ_query_param_auto_from_type (&dc->reserve_pub), GNUNET_PQ_query_param_absolute_time (&dc->timestamp), - GNUNET_PQ_query_param_auto_from_type (&dc->account), - GNUNET_PQ_query_param_auto_from_type (&dc->diagnostic), + GNUNET_PQ_query_param_string (dc->account), + GNUNET_PQ_query_param_string (dc->diagnostic), GNUNET_PQ_query_param_end }; diff --git a/src/auditordb/pg_insert_reserve_not_closed_inconsistency.c b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.c index 86d1393cb..9fc0e754d 100644 --- a/src/auditordb/pg_insert_reserve_not_closed_inconsistency.c +++ b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.c @@ -13,14 +13,12 @@ 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_pq_lib.h" #include "pg_helper.h" - #include "pg_insert_reserve_not_closed_inconsistency.h" + enum GNUNET_DB_QueryStatus TAH_PG_insert_reserve_not_closed_inconsistency ( void *cls, @@ -28,20 +26,18 @@ TAH_PG_insert_reserve_not_closed_inconsistency ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (&dc->reserve_pub), - TALER_PQ_query_param_amount (pg->conn, &dc->balance), + TALER_PQ_query_param_amount (pg->conn, + &dc->balance), GNUNET_PQ_query_param_absolute_time (&dc->expiration_time), - GNUNET_PQ_query_param_auto_from_type (&dc->diagnostic), - - + GNUNET_PQ_query_param_string (dc->diagnostic), GNUNET_PQ_query_param_end }; PREPARE (pg, "auditor_reserve_not_closed_inconsistency_insert", "INSERT INTO auditor_reserve_not_closed_inconsistency " - "( reserve_pub," + "(reserve_pub," " balance," " expiration_time," " diagnostic" diff --git a/src/auditordb/pg_insert_row_minor_inconsistencies.c b/src/auditordb/pg_insert_row_minor_inconsistencies.c index 37f44390f..ee2b22423 100644 --- a/src/auditordb/pg_insert_row_minor_inconsistencies.c +++ b/src/auditordb/pg_insert_row_minor_inconsistencies.c @@ -13,14 +13,12 @@ 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_pq_lib.h" #include "pg_helper.h" - #include "pg_insert_row_minor_inconsistencies.h" + enum GNUNET_DB_QueryStatus TAH_PG_insert_row_minor_inconsistencies ( void *cls, @@ -30,7 +28,7 @@ TAH_PG_insert_row_minor_inconsistencies ( struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&dc->row_table), GNUNET_PQ_query_param_uint64 (&dc->problem_row), - GNUNET_PQ_query_param_auto_from_type (&dc->diagnostic), + GNUNET_PQ_query_param_string (dc->diagnostic), GNUNET_PQ_query_param_end }; diff --git a/src/auditordb/pg_insert_wire_format_inconsistency.c b/src/auditordb/pg_insert_wire_format_inconsistency.c index a824ae76d..0243627f9 100644 --- a/src/auditordb/pg_insert_wire_format_inconsistency.c +++ b/src/auditordb/pg_insert_wire_format_inconsistency.c @@ -29,7 +29,7 @@ TAH_PG_insert_wire_format_inconsistency ( TALER_PQ_query_param_amount (pg->conn, &dc->amount), GNUNET_PQ_query_param_uint64 (&dc->wire_offset), - GNUNET_PQ_query_param_auto_from_type (&dc->diagnostic), + GNUNET_PQ_query_param_string (dc->diagnostic), GNUNET_PQ_query_param_end }; diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index 54c38e69e..2ec09c1b7 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -893,7 +893,6 @@ typedef enum GNUNET_GenericReturnValue typedef enum GNUNET_GenericReturnValue (*TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback)( void *cls, - uint64_t serial_id, const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc); typedef enum GNUNET_GenericReturnValue @@ -949,7 +948,6 @@ typedef enum GNUNET_GenericReturnValue typedef enum GNUNET_GenericReturnValue (*TALER_AUDITORDB_WireFormatInconsistencyCallback)( void *cls, - uint64_t serial_id, const struct TALER_AUDITORDB_WireFormatInconsistency *dc); typedef enum GNUNET_GenericReturnValue |