[libgda] meta-store: added utility method to stringify GdaMetaContext



commit 4683f3e833a6706d24aed0fa5158593776ed6a0d
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date:   Tue Jan 8 12:16:45 2019 -0600

    meta-store: added utility method to stringify GdaMetaContext

 libgda/gda-connection.c                          | 25 ++--------------------
 libgda/gda-meta-store.c                          | 27 ++++++++++++++++++++++++
 libgda/gda-meta-store.h                          |  1 +
 providers/reuseable/postgres/gda-postgres-meta.c |  4 +++-
 4 files changed, 33 insertions(+), 24 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index b5ead7a37..ccf5b8c1c 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -3976,34 +3976,13 @@ build_downstream_context_templates (GdaMetaStore *store, GdaMetaContext *context
        }
 }
 
-static gchar *
-meta_context_stringify (GdaMetaContext *context)
-{
-       gint i;
-       gchar *str;
-       GString *string = g_string_new ("");
-
-       for (i = 0; i < context->size; i++) {
-               if (i > 0)
-                       g_string_append_c (string, ' ');
-               str = gda_value_stringify (context->column_values[i]);
-               g_string_append_printf (string, " [%s => %s]", context->column_names[i], str);
-               g_free (str);
-       }
-       if (i == 0)
-               g_string_append (string, "no constraint in context");
-       str = string->str;
-       g_string_free (string, FALSE);
-       return str;
-}
-
 /*#define GDA_DEBUG_META_STORE_UPDATE*/
 #ifdef GDA_DEBUG_META_STORE_UPDATE
 static void
 meta_context_dump (GdaMetaContext *context)
 {
        gchar *str;
-       str = meta_context_stringify (context);
+       str = gda_meta_context_stringify (context);
        g_print ("GdaMetaContext for table %s: %s\n", context->table_name, str);
        g_free (str);
 }
@@ -4076,7 +4055,7 @@ check_parameters (GdaMetaContext *context, GError **error, gint nb, ...)
        }
        else {
                gchar *str;
-               str = meta_context_stringify (context);
+               str = gda_meta_context_stringify (context);
                g_set_error (error, GDA_CONNECTION_ERROR,
                             GDA_CONNECTION_META_DATA_CONTEXT_ERROR,
                             _("Missing or wrong arguments for table '%s': %s"),
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index fdb2fe347..eac17d70a 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -430,6 +430,33 @@ gda_meta_context_free (GdaMetaContext *ctx)
        // REMIND: ctx->column_names and ctx->column_values must not be freed
 }
 
+/**
+ * gda_meta_context_stringify:
+ * @ctx: a #GdaMetaContext
+ *
+ * Creates a string representation of given context.
+ */
+gchar*
+gda_meta_context_stringify (GdaMetaContext *ctx)
+{
+       gint i;
+       gchar *str;
+       GString *string = g_string_new ("");
+
+       for (i = 0; i < ctx->size; i++) {
+               if (i > 0)
+                       g_string_append_c (string, ' ');
+               str = gda_value_stringify (ctx->column_values[i]);
+               g_string_append_printf (string, " [%s => %s]", ctx->column_names[i], str);
+               g_free (str);
+       }
+       if (i == 0)
+               g_string_append (string, "no constraint in context");
+       str = string->str;
+       g_string_free (string, FALSE);
+       return str;
+}
+
 
 G_DEFINE_BOXED_TYPE(GdaMetaContext, gda_meta_context, gda_meta_context_copy, gda_meta_context_free)
 
diff --git a/libgda/gda-meta-store.h b/libgda/gda-meta-store.h
index 1f028d9fe..6398a8a74 100644
--- a/libgda/gda-meta-store.h
+++ b/libgda/gda-meta-store.h
@@ -218,6 +218,7 @@ void              gda_meta_context_set_column             (GdaMetaContext *ctx,
 void              gda_meta_context_set_columns            (GdaMetaContext *ctx, GHashTable *columns,
                                                           GdaConnection *cnc);
 void              gda_meta_context_free                   (GdaMetaContext *ctx);
+gchar            *gda_meta_context_stringify              (GdaMetaContext *ctx);
 
 G_END_DECLS
 
diff --git a/providers/reuseable/postgres/gda-postgres-meta.c 
b/providers/reuseable/postgres/gda-postgres-meta.c
index b35bb5df3..80972e941 100644
--- a/providers/reuseable/postgres/gda-postgres-meta.c
+++ b/providers/reuseable/postgres/gda-postgres-meta.c
@@ -590,7 +590,9 @@ _gda_postgres_meta__domains (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnectio
                                                              _col_types_domains, error);
        if (!model)
                return FALSE;
-
+  gchar *s = gda_meta_context_stringify (context);
+  g_message ("Context used to update: %s", s);
+  g_free (s);
        gda_meta_store_set_reserved_keywords_func (store, _gda_postgres_reuseable_get_reserved_keywords_func
                                                   ((GdaProviderReuseable*) rdata));
        retval = gda_meta_store_modify_with_context (store, context, model, error);


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