[libgda] meta-data: improved internal error reporting



commit 3e4d80f545e6f30d3bff940852b3e3fa99b75218
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date:   Mon Jan 7 19:48:54 2019 -0600

    meta-data: improved internal error reporting

 libgda/gda-connection.c            | 46 ++++++++++++++++++++++----------------
 libgda/gda-server-provider.c       | 22 ++++++++++--------
 libgda/gda-value.c                 |  2 +-
 tests/providers/prov-test-common.c |  7 +++---
 4 files changed, 45 insertions(+), 32 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 22da09cbd..b5ead7a37 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -4232,13 +4232,18 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                                              &catalog, G_TYPE_STRING,
                                              &schema, G_TYPE_STRING, NULL,
                                              "domain_catalog", &catalog, "domain_schema", &schema, NULL);
-                       if (i < 0)
-                               return FALSE;
-                       
+
                        ASSERT_TABLE_NAME (tname, "domains");
-                       retval = _gda_server_provider_meta_2arg (provider, cnc, store, context,
-                                                                GDA_SERVER_META_DOMAINS, catalog, schema, 
error);
-                       WARN_META_UPDATE_FAILURE (retval, "domains");
+                       if (i < 0) {
+                               g_clear_error (error);
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META__DOMAINS, error);
+                               WARN_META_UPDATE_FAILURE (retval, "domains");
+                       } else {
+                               retval = _gda_server_provider_meta_2arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META_DOMAINS, catalog, 
schema, error);
+                               WARN_META_UPDATE_FAILURE (retval, "domains");
+                       }
                        return retval;
                }
                else {
@@ -4294,16 +4299,14 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                        i = check_parameters (context, error, 1,
                                              &name, G_TYPE_STRING, NULL,
                                              "specific_name", &name, NULL);
-                       if (error && *error) {
-                               return FALSE;
-                       }
+
                        ASSERT_TABLE_NAME (tname, "element_types");
                        if (i < 0) {
+                               g_clear_error (error);
                                retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
                                                                         GDA_SERVER_META__EL_TYPES, error);
                                WARN_META_UPDATE_FAILURE (retval, "_el_types");
-                       }
-                       else {
+                       } else {
                                retval = _gda_server_provider_meta_1arg (provider, cnc, store, context,
                                                                         GDA_SERVER_META_EL_TYPES, name, 
error);
                                WARN_META_UPDATE_FAILURE (retval, "el_types");
@@ -4337,7 +4340,7 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
 
                        if (i < 0)
                                return FALSE;
-                       
+
                        ASSERT_TABLE_NAME (tname, "index_column_usage");
                        retval = _gda_server_provider_meta_4arg (provider, cnc, store, context,
                                                                 GDA_SERVER_META_INDEX_COLS, catalog, schema, 
name, iname, error);
@@ -4609,13 +4612,17 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                                              &schema, G_TYPE_STRING,
                                              &name, G_TYPE_STRING, NULL,
                                              "udt_catalog", &catalog, "udt_schema", &schema, "udt_name", 
&name, NULL);
-                       if (i < 0)
-                               return FALSE;
-                       
-                       ASSERT_TABLE_NAME (tname, "udt_columns");
-                       retval = _gda_server_provider_meta_3arg (provider, cnc, store, context,
-                                                                GDA_SERVER_META_UDT_COLS, catalog, schema, 
name, error);
-                       WARN_META_UPDATE_FAILURE (retval, "udt_cols");
+                       if (i < 0) {
+                               g_clear_error (error);
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META__UDT_COLS, error);
+                               WARN_META_UPDATE_FAILURE (retval, "_el_types");
+                       } else {
+                               ASSERT_TABLE_NAME (tname, "udt_columns");
+                               retval = _gda_server_provider_meta_3arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META_UDT_COLS, catalog, 
schema, name, error);
+                               WARN_META_UPDATE_FAILURE (retval, "udt_cols");
+                       }
                        return retval;
                }
                break;
@@ -4987,6 +4994,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
                for (i = 0; i < nb; i++) {
                        /*g_print ("%s() %s(cnc=>%p store=>%p)\n", __FUNCTION__, rmeta [i].func_name, cnc, 
store);*/
                        lcontext.table_name = rmeta [i].table_name;
+      g_message ("Updating FULL mata store at table: %s", gda_meta_context_get_table (&lcontext));
                        if (! _gda_server_provider_meta_0arg (provider, cnc, store, &lcontext,
                                                              rmeta[i].func_type, error)) {
                                /*
diff --git a/libgda/gda-server-provider.c b/libgda/gda-server-provider.c
index e4f58fabf..9ce94d67e 100644
--- a/libgda/gda-server-provider.c
+++ b/libgda/gda-server-provider.c
@@ -2900,7 +2900,7 @@ meta_finalize_result (gpointer retval, GError **call_error, GError **loc_error)
                             (*loc_error)->message);
   } else {
                g_set_error (call_error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_INTERNAL_ERROR,
-                            _("Internal error please report bug to 
https://gitlab.gnome.org/GNOME/libgda/issues";));
+                            _("Internal error please report bug to 
https://gitlab.gnome.org/GNOME/libgda/issues No error was reported"));
        }
        g_clear_error (loc_error);
        return FALSE;
@@ -3017,10 +3017,11 @@ _gda_server_provider_meta_1arg (GdaServerProvider *provider, GdaConnection *cnc,
        data.values[2] = NULL;
        data.values[3] = NULL;
 
+       GError *lerror = NULL;
        if (cnc)
                gda_connection_increase_usage (cnc); /* USAGE ++ */
        gda_worker_do_job (worker, context, 0, &retval, NULL,
-                          (GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, NULL);
+                          (GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, &lerror);
        if (context)
                g_main_context_unref (context);
 
@@ -3032,7 +3033,7 @@ _gda_server_provider_meta_1arg (GdaServerProvider *provider, GdaConnection *cnc,
        gda_worker_unref (worker);
 
  out:
-       return meta_finalize_result (retval, error, NULL);
+       return meta_finalize_result (retval, error, &lerror);
 }
 
 gboolean
@@ -3081,10 +3082,11 @@ _gda_server_provider_meta_2arg (GdaServerProvider *provider, GdaConnection *cnc,
        data.values[2] = NULL;
        data.values[3] = NULL;
 
+       GError *lerror = NULL;
        if (cnc)
                gda_connection_increase_usage (cnc); /* USAGE -- */
        gda_worker_do_job (worker, context, 0, &retval, NULL,
-                          (GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, NULL);
+                          (GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, &lerror);
        if (context)
                g_main_context_unref (context);
 
@@ -3096,7 +3098,7 @@ _gda_server_provider_meta_2arg (GdaServerProvider *provider, GdaConnection *cnc,
        gda_worker_unref (worker);
 
  out:
-       return meta_finalize_result (retval, error, NULL);
+       return meta_finalize_result (retval, error, &lerror);
 }
 
 gboolean
@@ -3146,10 +3148,11 @@ _gda_server_provider_meta_3arg (GdaServerProvider *provider, GdaConnection *cnc,
        data.values[2] = value2;
        data.values[3] = NULL;
 
+       GError *lerror = NULL;
        if (cnc)
                gda_connection_increase_usage (cnc); /* USAGE ++ */
        gda_worker_do_job (worker, context, 0, &retval, NULL,
-                          (GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, NULL);
+                          (GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, &lerror);
        if (context)
                g_main_context_unref (context);
 
@@ -3160,7 +3163,7 @@ _gda_server_provider_meta_3arg (GdaServerProvider *provider, GdaConnection *cnc,
 
        gda_worker_unref (worker);
  out:
-       return meta_finalize_result (retval, error, NULL);
+       return meta_finalize_result (retval, error, &lerror);
 }
 
 gboolean
@@ -3210,10 +3213,11 @@ _gda_server_provider_meta_4arg (GdaServerProvider *provider, GdaConnection *cnc,
        data.values[2] = value2;
        data.values[3] = value3;
 
+       GError *lerror = NULL;
        if (cnc)
                gda_connection_increase_usage (cnc); /* USAGE ++ */
        gda_worker_do_job (worker, context, 0, &retval, NULL,
-                          (GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, NULL);
+                          (GdaWorkerFunc) worker_meta, (gpointer) &data, NULL, NULL, &lerror);
        if (context)
                g_main_context_unref (context);
 
@@ -3225,7 +3229,7 @@ _gda_server_provider_meta_4arg (GdaServerProvider *provider, GdaConnection *cnc,
        gda_worker_unref (worker);
 
  out:
-       return meta_finalize_result (retval, error, NULL);
+       return meta_finalize_result (retval, error, &lerror);
 }
 
 /***********************************************************************************************************/
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index cfc80f905..0271969c4 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -3093,7 +3093,7 @@ gda_value_compare (const GValue *value1, const GValue *value2)
                str1 = g_value_get_string (value1);
                str2 = g_value_get_string (value2);
                if (str1 && str2)
-                       retval = strcmp (str1, str2);
+                       retval = g_strcmp0 (str1, str2);
                else {
                        if (str1)
                                return 1;
diff --git a/tests/providers/prov-test-common.c b/tests/providers/prov-test-common.c
index a3d0432d1..11e719f26 100644
--- a/tests/providers/prov-test-common.c
+++ b/tests/providers/prov-test-common.c
@@ -145,7 +145,7 @@ prov_test_common_check_meta (void)
        if (! gda_connection_update_meta_store (cnc, NULL, &gerror)) {
 #ifdef CHECK_EXTRA_INFO
                g_warning ("Can't update meta store (1): %s\n",
-                          gerror && gerror->message ? gerror->message : "???");
+                          gerror && gerror->message ? gerror->message : "No error was set");
 #endif
                g_error_free (gerror);
                number_failed++;
@@ -366,8 +366,9 @@ prov_test_common_check_meta_identifiers (gboolean case_sensitive, gboolean updat
        g_object_unref (store);
        if (! gda_connection_update_meta_store (cnc, update_all ? NULL : &mcontext, &error)) {
 #ifdef CHECK_EXTRA_INFO
-               g_warning ("Can't FULL update meta store: %s\n",
-                          error && error->message ? error->message : "???");
+               g_warning ("Can't %s update meta store: %s\n",
+         update_all ? "FULL" : "PARTIAL",
+                          error && error->message ? error->message : "No error message was set");
 #endif
                g_clear_error (&error);
                g_object_set (G_OBJECT (cnc), "options", options, NULL);


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