gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: fix row minor inconsistency tabl


From: gnunet
Subject: [taler-exchange] branch master updated: fix row minor inconsistency table and SQL
Date: Sun, 25 Aug 2024 22:54:30 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 2e70d5786 fix row minor inconsistency table and SQL
2e70d5786 is described below

commit 2e70d578621915d9b32d51f5d91f07e464d34b4a
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Aug 25 22:54:26 2024 +0200

    fix row minor inconsistency table and SQL
---
 ...r-auditor-httpd_row-minor-inconsistencies-get.c | 65 +++++++++++-----------
 src/auditor/taler-helper-auditor-wire-credit.c     | 17 +++++-
 src/auditor/taler-helper-auditor-wire-debit.c      |  6 +-
 .../0002-auditor_row_minor_inconsistencies.sql     |  5 +-
 src/auditordb/pg_get_row_minor_inconsistencies.c   |  6 +-
 .../pg_insert_row_minor_inconsistencies.c          | 10 ++--
 src/include/taler_auditordb_plugin.h               |  4 +-
 7 files changed, 61 insertions(+), 52 deletions(-)

diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.c 
b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.c
index 7585bb9cd..e734e582c 100644
--- a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.c
+++ b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-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,37 +24,37 @@
 #include "taler-auditor-httpd.h"
 #include "taler-auditor-httpd_row-minor-inconsistencies-get.h"
 
+
 /**
-* Add row-minor-inconsistencies 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 row-minor-inconsistencies 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_row_minor_inconsistencies (
   void *cls,
-  uint64_t serial_id,
   const struct TALER_AUDITORDB_RowMinorInconsistencies *dc)
 {
   json_t *list = cls;
   json_t *obj;
 
   obj = GNUNET_JSON_PACK (
-
-    GNUNET_JSON_pack_int64 ("row_id", serial_id),
-    GNUNET_JSON_pack_string ("row_table", dc->row_table),
-    GNUNET_JSON_pack_string ("diagnostic", dc->diagnostic),
-    GNUNET_JSON_pack_bool ("suppressed", dc->suppressed)
-
-
+    GNUNET_JSON_pack_int64 ("row_id",
+                            dc->row_id),
+    GNUNET_JSON_pack_string ("row_table",
+                             dc->row_table),
+    GNUNET_JSON_pack_int64 ("problem_row",
+                            dc->problem_row),
+    GNUNET_JSON_pack_string ("diagnostic",
+                             dc->diagnostic),
+    GNUNET_JSON_pack_bool ("suppressed",
+                           dc->suppressed)
     );
   GNUNET_break (0 ==
                 json_array_append_new (list,
                                        obj));
-
-
   return GNUNET_OK;
 }
 
@@ -72,6 +70,9 @@ TAH_ROW_MINOR_INCONSISTENCIES_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;
@@ -86,34 +87,32 @@ TAH_ROW_MINOR_INCONSISTENCIES_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_row_minor_inconsistencies (
     TAH_plugin->cls,
     limit,
diff --git a/src/auditor/taler-helper-auditor-wire-credit.c 
b/src/auditor/taler-helper-auditor-wire-credit.c
index d2e598f4a..2cfa4b8ee 100644
--- a/src/auditor/taler-helper-auditor-wire-credit.c
+++ b/src/auditor/taler-helper-auditor-wire-credit.c
@@ -774,7 +774,7 @@ analyze_credit (
                                  rii->credit_details.execution_date))
   {
     struct TALER_AUDITORDB_RowMinorInconsistencies rmi = {
-      .row_id = rii->rowid,
+      .problem_row = rii->rowid,
       .diagnostic = "execution date mismatch",
       .row_table = "reserves_in"
     };
@@ -784,8 +784,9 @@ analyze_credit (
       TALER_ARL_adb->cls,
       &rmi);
 
-    if (qs <= 0)
+    if (qs < 0)
     {
+      /* FIXME: this error handling sucks... */
       global_qs = qs;
       GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
       return false;
@@ -820,7 +821,17 @@ history_credit_cb (void *cls,
 
       if (! analyze_credit (wa,
                             cd))
-        return;
+      {
+        if (global_qs < 0)
+        {
+          /* FIXME: this error handling sucks,
+             doesn't retry on SOFT errors, doesn't
+             set global_ret, etc. */
+          GNUNET_SCHEDULER_shutdown ();
+          return;
+        }
+        break;
+      }
     }
     conclude_account (wa);
     return;
diff --git a/src/auditor/taler-helper-auditor-wire-debit.c 
b/src/auditor/taler-helper-auditor-wire-debit.c
index 894464586..bd99aaf79 100644
--- a/src/auditor/taler-helper-auditor-wire-debit.c
+++ b/src/auditor/taler-helper-auditor-wire-debit.c
@@ -670,9 +670,9 @@ check_time_difference (const char *table,
                                            true));
   {
     struct TALER_AUDITORDB_RowMinorInconsistencies rmi = {
-      .row_id = rowid,
-      .diagnostic = details,
-      .row_table = (char *) table
+      .row_table = (char *) table,
+      .problem_row = rowid,
+      .diagnostic = details
     };
     enum GNUNET_DB_QueryStatus qs;
 
diff --git a/src/auditordb/0002-auditor_row_minor_inconsistencies.sql 
b/src/auditordb/0002-auditor_row_minor_inconsistencies.sql
index 8cf15d2cc..cf421e37e 100644
--- a/src/auditordb/0002-auditor_row_minor_inconsistencies.sql
+++ b/src/auditordb/0002-auditor_row_minor_inconsistencies.sql
@@ -17,8 +17,9 @@
 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,
+    row_table BYTEA NOT NULL,
+    problem_row BIGINT NOT NULL
+    diagnostic BYTEA NOT NULL,
     suppressed BOOLEAN NOT NULL DEFAULT FALSE
 );
 COMMENT ON TABLE auditor_row_minor_inconsistencies
diff --git a/src/auditordb/pg_get_row_minor_inconsistencies.c 
b/src/auditordb/pg_get_row_minor_inconsistencies.c
index f1c101e30..9e2bc62e1 100644
--- a/src/auditordb/pg_get_row_minor_inconsistencies.c
+++ b/src/auditordb/pg_get_row_minor_inconsistencies.c
@@ -65,13 +65,14 @@ 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),
+                                    &dc.row_id),
       GNUNET_PQ_result_spec_auto_from_type ("row_table",
                                             &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_bool ("suppressed",
@@ -91,7 +92,6 @@ row_minor_inconsistencies_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_row_minor_inconsistencies.c 
b/src/auditordb/pg_insert_row_minor_inconsistencies.c
index 84607fa3c..37f44390f 100644
--- a/src/auditordb/pg_insert_row_minor_inconsistencies.c
+++ b/src/auditordb/pg_insert_row_minor_inconsistencies.c
@@ -28,20 +28,18 @@ TAH_PG_insert_row_minor_inconsistencies (
 {
   struct PostgresClosure *pg = cls;
   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_end
   };
 
   PREPARE (pg,
            "auditor_row_minor_inconsistencies_insert",
            "INSERT INTO auditor_row_minor_inconsistencies "
-           "( row_id,"
-           " row_table,"
-           " diagnostic"
+           "(row_table"
+           ",problem_row"
+           ",diagnostic"
            ") VALUES ($1,$2,$3);"
            );
   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
diff --git a/src/include/taler_auditordb_plugin.h 
b/src/include/taler_auditordb_plugin.h
index 2b21c6dee..176e1b45b 100644
--- a/src/include/taler_auditordb_plugin.h
+++ b/src/include/taler_auditordb_plugin.h
@@ -803,11 +803,12 @@ struct TALER_AUDITORDB_RowMinorInconsistencies
 {
   uint64_t row_id;
   char *row_table;
+  uint64_t problem_row;
   char *diagnostic;
   bool suppressed;
-
 };
 
+
 struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency
 {
   uint64_t row_id;
@@ -963,7 +964,6 @@ typedef enum GNUNET_GenericReturnValue
 typedef enum GNUNET_GenericReturnValue
 (*TALER_AUDITORDB_RowMinorInconsistenciesCallback)(
   void *cls,
-  uint64_t serial_id,
   const struct TALER_AUDITORDB_RowMinorInconsistencies *dc);
 
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]