diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-08-23 23:04:55 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-08-23 23:04:55 +0200 |
commit | 79f312df5d79787feb5af591641135e8a0eeb5f1 (patch) | |
tree | d78b065e240d61aa86b62ba8592a81b5b94d640c | |
parent | ca4b2e51ba0f732ea4b10a1fc2db1e24d2e27a34 (diff) |
more SQL fixes
-rw-r--r-- | src/auditordb/0002-auditor_row_minor_inconsistencies.sql | 7 | ||||
-rw-r--r-- | src/auditordb/pg_get_row_minor_inconsistencies.c | 51 |
2 files changed, 23 insertions, 35 deletions
diff --git a/src/auditordb/0002-auditor_row_minor_inconsistencies.sql b/src/auditordb/0002-auditor_row_minor_inconsistencies.sql index d50828865..8cf15d2cc 100644 --- a/src/auditordb/0002-auditor_row_minor_inconsistencies.sql +++ b/src/auditordb/0002-auditor_row_minor_inconsistencies.sql @@ -14,13 +14,12 @@ -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -- -SET search_path TO auditor; -CREATE TABLE IF NOT EXISTS auditor_row_minor_inconsistency +CREATE TABLE IF NOT EXISTS auditor_row_minor_inconsistencies ( row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY, row_table BYTEA, diagnostic BYTEA, suppressed BOOLEAN NOT NULL DEFAULT FALSE ); -COMMENT ON TABLE auditor_row_minor_inconsistency - IS 'Report a (serious) row inconsistency in the exchange''s database.'; +COMMENT ON TABLE auditor_row_minor_inconsistencies + IS 'Report a (minor) row inconsistency in the exchange''s database.'; diff --git a/src/auditordb/pg_get_row_minor_inconsistencies.c b/src/auditordb/pg_get_row_minor_inconsistencies.c index c6a15b155..f1c101e30 100644 --- a/src/auditordb/pg_get_row_minor_inconsistencies.c +++ b/src/auditordb/pg_get_row_minor_inconsistencies.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_row_minor_inconsistencies.h" @@ -69,18 +66,16 @@ row_minor_inconsistencies_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { uint64_t serial_id; - struct TALER_AUDITORDB_RowMinorInconsistencies dc; - struct GNUNET_PQ_ResultSpec rs[] = { - - GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), - - GNUNET_PQ_result_spec_auto_from_type ("row_table", &dc.row_table), - GNUNET_PQ_result_spec_auto_from_type ("diagnostic", &dc.diagnostic), - GNUNET_PQ_result_spec_bool ("suppressed", &dc.suppressed), - - + GNUNET_PQ_result_spec_uint64 ("row_id", + &serial_id), + GNUNET_PQ_result_spec_auto_from_type ("row_table", + &dc.row_table), + GNUNET_PQ_result_spec_auto_from_type ("diagnostic", + &dc.diagnostic), + GNUNET_PQ_result_spec_bool ("suppressed", + &dc.suppressed), GNUNET_PQ_result_spec_end }; enum GNUNET_GenericReturnValue rval; @@ -94,9 +89,7 @@ row_minor_inconsistencies_cb (void *cls, dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; return; } - dcc->qs = i + 1; - rval = dcc->cb (dcc->cb_cls, serial_id, &dc); @@ -112,14 +105,12 @@ TAH_PG_get_row_minor_inconsistencies ( void *cls, int64_t limit, uint64_t offset, - bool return_suppressed, // maybe not needed + bool return_suppressed, TALER_AUDITORDB_RowMinorInconsistenciesCallback 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,7 +133,7 @@ TAH_PG_get_row_minor_inconsistencies ( " suppressed" " FROM auditor_row_minor_inconsistencies" " WHERE (row_id < $1)" - " AND ($2 OR suppressed is false)" + " AND ($2 OR NOT suppressed)" " ORDER BY row_id DESC" " LIMIT $3" ); @@ -155,20 +146,18 @@ TAH_PG_get_row_minor_inconsistencies ( " suppressed" " FROM auditor_row_minor_inconsistencies" " WHERE (row_id > $1)" - " AND ($2 OR suppressed is false)" + " AND ($2 OR NOT suppressed)" " ORDER BY row_id ASC" " LIMIT $3" ); - qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - (limit > 0) - ? - "auditor_row_minor_inconsistencies_get_asc" - : - "auditor_row_minor_inconsistencies_get_desc", - params, - &row_minor_inconsistencies_cb, - &dcc); - + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + (limit > 0) + ? "auditor_row_minor_inconsistencies_get_asc" + : "auditor_row_minor_inconsistencies_get_desc", + params, + &row_minor_inconsistencies_cb, + &dcc); if (qs > 0) return dcc.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); |