[libgda] mysql: fixes on meta store



commit 95eeca4b0470f347c645a27f714c62aa6e59f820
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date:   Tue Jan 15 19:20:06 2019 -0600

    mysql: fixes on meta store
    
    * Disabling MySQL from CI
    * Fixing information schema to use text type on large string
      so MySQL can use apropiate 'text' type and fix fails
    * MySQL has some missing features, so it needs its own set of
      tests, so a group 2 of tests has been added

 .gitlab-ci.yml                             | 18 +++++++++++------
 libgda/gda-connection.c                    |  2 +-
 libgda/gda-meta-store.c                    | 13 ------------
 libgda/gda-value.c                         | 13 ------------
 libgda/information_schema.xml              |  5 +++--
 providers/mysql/gda-mysql-provider.c       | 20 +++++++++----------
 providers/reuseable/mysql/gda-mysql-meta.c |  9 +++++----
 tests/meta-store/check_meta_store_mysql.c  |  2 +-
 tests/meta-store/common.c                  | 32 +++++++++++++++++++++++++++++-
 tests/meta-store/common.h                  |  1 +
 10 files changed, 64 insertions(+), 51 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8a7cd6d95..71540861f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,6 +6,7 @@ image: ubuntu:devel
 
 services:
   - postgres:latest
+  - mysql: latest
 
 stages:
   - build
@@ -14,6 +15,11 @@ variables:
   POSTGRES_DB: test
   POSTGRES_USER: test
   POSTGRES_PASSWORD: test1
+  POSTGRES_HOST: postgres
+  MYSQL_DB: test
+  MYSQL_USER: test
+  MYSQL_PASSWORD: test1
+  MYSQL_HOST: mysql
   DEPENDENCIES: gcc gettext gtk-doc-tools make autoconf
                 meson ninja-build
                 libgtk-3-dev libxml2-dev gnome-common
@@ -43,12 +49,12 @@ variables:
   GIT_SUBMODULE_STRATEGY: normal
   SQLITE_DBCREATE_PARAMS: "DB_DIR=."
   SQLITE_CNC_PARAMS: "DB_DIR=."
-  POSTGRESQL_DBCREATE_PARAMS: "HOST=postgres;ADM_LOGIN=$POSTGRES_USER;ADM_PASSWORD=$POSTGRES_PASSWORD"
-  POSTGRESQL_CNC_PARAMS: "HOST=postgres;USERNAME=$POSTGRES_USER;PASSWORD=$POSTGRES_PASSWORD"
-  POSTGRESQL_META_CNC: 
"DB_NAME=$POSTGRES_DB;HOST=postgres;USERNAME=$POSTGRES_USER;PASSWORD=$POSTGRES_PASSWORD"
-  MYSQL_DBCREATE_PARAMS: "HOST=mysql;ADM_LOGIN=$MYSQL_USER;ADM_PASSWORD=$MYSQL_PASSWORD"
-  MYSQL_CNC_PARAMS: "HOST=mysql;USERNAME=$MYSQL_USER;PASSWORD=$MYSQL_PASSWORD"
-  MYSQL_META_CNC: "DB_NAME=$MYSQL_DB;HOST=mysql;USERNAME=$MYSQL_USER;PASSWORD=$MYSQL_PASSWORD"
+  POSTGRESQL_DBCREATE_PARAMS: "HOST=$POSTGRES_HOST;ADM_LOGIN=$POSTGRES_USER;ADM_PASSWORD=$POSTGRES_PASSWORD"
+  POSTGRESQL_CNC_PARAMS: "HOST=$POSTGRES_HOST;USERNAME=$POSTGRES_USER;PASSWORD=$POSTGRES_PASSWORD"
+  POSTGRESQL_META_CNC: 
"DB_NAME=$POSTGRES_DB;HOST=$POSTGRES_HOST;USERNAME=$POSTGRES_USER;PASSWORD=$POSTGRES_PASSWORD"
+#  MYSQL_DBCREATE_PARAMS: "HOST=$MYSQL_HOST;ADM_LOGIN=$MYSQL_USER;ADM_PASSWORD=$MYSQL_PASSWORD"
+#  MYSQL_CNC_PARAMS: "HOST=$MYSQL_HOST;USERNAME=$MYSQL_USER;PASSWORD=$MYSQL_PASSWORD"
+#  MYSQL_META_CNC: "DB_NAME=$MYSQL_DB;HOST=$MYSQL_HOST;USERNAME=$MYSQL_USER;PASSWORD=$MYSQL_PASSWORD"
   
 before_script:
   - apt update && apt -y install $DEPENDENCIES
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 980bbdee8..8a993075c 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -4056,7 +4056,7 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                WARN_META_UPDATE_FAILURE (retval, "_btypes");
                return retval;
        }
-       
+       break;
        case 'c': 
                if ((tname[1] == 'o') && (tname[2] == 'l') && (tname[3] == 'u')) {
                        /* _columns,  params: 
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index 2c2001da9..53d4f8196 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -3517,19 +3517,6 @@ gda_meta_store_modify_v (GdaMetaStore *store, const gchar *table_name,
                                        if (! gda_holder_set_value (h, value, &lerror)) {
                                                g_free (pid);
                                                retval = FALSE;
-                                               g_message ("New Data: Column: '%s' : '%s' - ncol: %d - type: 
%s - Val: %s", gda_data_model_get_column_name (wrapped_data, j),
-                                                                                        
gda_data_model_get_column_title (wrapped_data, j), j, g_type_name (G_VALUE_TYPE (value)),
-                                                                                        gda_value_stringify 
(value));
-                                               g_message ("Holder: '%s' type: %s", gda_holder_get_id (h), 
g_type_name (gda_holder_get_g_type (h)));
-                                               /* if (new_data != wrapped_data) { */
-                                               /*      g_print ("NEW for table %s:\n", table_name); */
-                                               /*      gda_data_model_dump (new_data, stdout); */
-
-                                               /*      g_print ("wrapped as:\n"); */
-                                               /*      gda_data_model_dump (wrapped_data, stdout); */
-                                               /* } else { */
-                                               /*      g_message ("DATA NO WRAPPED"); */
-                                               /* } */
                                                g_object_unref (wrapped_data);
                                                g_set_error (error, GDA_META_STORE_ERROR, 
GDA_META_STORE_EXTRACT_SQL_ERROR,
                                             _("Internal error, while updating internal meta store table 
'%s': Parameter value type error: %s"),
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index 2c61e1f91..bda2e9cbc 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -295,19 +295,6 @@ set_from_string (GValue *value, const gchar *as_string)
 /*
  * Register the NULL type in the GType system
  */
-static void
-string_to_null (const GValue *src, GValue *dest)
-{
-       g_return_if_fail (G_VALUE_HOLDS_STRING (src) && GDA_VALUE_HOLDS_NULL (dest));
-       /* Do nothing just a dummy function to register */
-}
-
-static void
-null_to_string (const GValue *src, GValue *dest)
-{
-       g_return_if_fail (G_VALUE_HOLDS_STRING (dest) && GDA_VALUE_HOLDS_NULL (src));
-       g_value_set_string (dest, "NULL");
-}
 
 static gpointer
 gda_null_copy (G_GNUC_UNUSED gpointer boxed)
diff --git a/libgda/information_schema.xml b/libgda/information_schema.xml
index 90d454961..e7b5b6547 100644
--- a/libgda/information_schema.xml
+++ b/libgda/information_schema.xml
@@ -26,6 +26,7 @@
     <provider name="MySQL">
       <replace context="/FIELDS_A/@COLUMN_TYPE" expr="string" replace_with="varchar(35)"/>
       <replace context="/FIELDS_A/@COLUMN_TYPE" expr="gint" replace_with="int"/>
+      <replace context="/FIELDS_A/@COLUMN_TYPE" expr="gboolean" replace_with="boolean"/>
       <ignore context="/FKEY_S"/>
       <ignore context="/FIELDS_A/@COLUMN_PKEY"/>
     </provider>
@@ -193,7 +194,7 @@
     <column name="is_insertable_into" type="boolean" nullok="TRUE" descr="Tells if the table's contents can 
be modified"/>
     <column name="table_comments" type="text" nullok="TRUE"/>
     <column name="table_short_name" ident="TRUE"/>
-    <column name="table_full_name" ident="TRUE"/>
+    <column name="table_full_name" type="text" ident="TRUE"/>
     <column name="table_owner" nullok="TRUE"/>
     <fkey ref_table="_schemata">
       <part column="table_catalog" ref_column="catalog_name"/>
@@ -208,7 +209,7 @@
     <column name="table_catalog" pkey="TRUE" descr="Name of catalog that contains the view" ident="TRUE"/>
     <column name="table_schema" pkey="TRUE" descr="Name of schema that contains the view" ident="TRUE"/>
     <column name="table_name" pkey="TRUE" descr="Name of the view" ident="TRUE"/>
-    <column name="view_definition" nullok="TRUE" descr="View as SQL"/>
+    <column name="view_definition" type="text" nullok="TRUE" descr="View as SQL"/>
     <column name="check_option" nullok="TRUE" descr="CASCADE if the statement used to create the view 
included the WITH CHECK OPTION; otherwise, NONE"/>
     <column name="is_updatable" type="boolean" nullok="TRUE" descr="Tells if the view's contents can be 
modified"/>
     <fkey ref_table="_tables">
diff --git a/providers/mysql/gda-mysql-provider.c b/providers/mysql/gda-mysql-provider.c
index 826684fa0..4032ddbaf 100644
--- a/providers/mysql/gda-mysql-provider.c
+++ b/providers/mysql/gda-mysql-provider.c
@@ -1327,13 +1327,13 @@ gda_mysql_provider_get_default_dbms_type (GdaServerProvider  *provider,
        if (type == G_TYPE_INT64)
                return "bigint";
        if (type == G_TYPE_UINT64)
-               return "bigint unsigned";
+               return "bigint";
        if (type == GDA_TYPE_BINARY)
                return "varbinary";
        if (type == GDA_TYPE_BLOB)
-               return "blob";
+               return "longblob";
        if (type == G_TYPE_BOOLEAN)
-               return "bool";
+               return "tinyint";
        if (type == G_TYPE_DATE)
                return "date";
        if (type == G_TYPE_DOUBLE)
@@ -1345,27 +1345,27 @@ gda_mysql_provider_get_default_dbms_type (GdaServerProvider  *provider,
        if (type == G_TYPE_INT)
                return "int";
        if (type == GDA_TYPE_NUMERIC)
-               return "numeric";
+               return "decimal";
        if (type == G_TYPE_FLOAT)
                return "float";
        if (type == GDA_TYPE_SHORT)
                return "smallint";
        if (type == GDA_TYPE_USHORT)
-               return "smallint unsigned";
+               return "smallint";
        if (type == G_TYPE_STRING)
                return "varchar";
        if (type == GDA_TYPE_TIME)
                return "time";
        if (type == G_TYPE_DATE_TIME)
-               return "timestamp";
+               return "datetime";
        if (type == G_TYPE_CHAR)
-               return "tinyint";
+               return "char(1)";
        if (type == G_TYPE_UCHAR)
-               return "tinyint unsigned";
+               return "char(1)";
        if (type == G_TYPE_ULONG)
-               return "bigint unsigned";
+               return "mediumtext";
        if (type == G_TYPE_UINT)
-               return "int unsigned";
+               return "int";
 
        if ((type == GDA_TYPE_NULL) ||
            (type == G_TYPE_GTYPE))
diff --git a/providers/reuseable/mysql/gda-mysql-meta.c b/providers/reuseable/mysql/gda-mysql-meta.c
index 1f17dc229..0a95d0ad6 100644
--- a/providers/reuseable/mysql/gda-mysql-meta.c
+++ b/providers/reuseable/mysql/gda-mysql-meta.c
@@ -367,7 +367,8 @@ _gda_mysql_meta__btypes (G_GNUC_UNUSED GdaServerProvider  *prov,
                { "TINYTEXT", "GdaBinary", "A TEXT column with a maximum length of 255 (28 - 1) characters. 
The effective maximum length is less if the value contains multi-byte characters. Each TINYTEXT value is 
stored using a one-byte length prefix that indicates the number of bytes in the value.", "" },
                { "VARBINARY", "GdaBinary", "The VARBINARY type is similar to the VARCHAR type, but stores 
binary byte strings rather than non-binary character strings. M represents the maximum column length in 
bytes.", "" },
                { "VARCHAR", "gchararray", "A variable-length string. M represents the maximum column length 
in characters. In MySQL 5.0, the range of M is 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in MySQL 5.0.3 
and later. The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is subject to the maximum row 
size (65,535 bytes, which is shared among all columns) and the character set used. For example, utf8 
characters can require up to three bytes per character, so a VARCHAR column that uses the utf8 character set 
can be declared to be a maximum of 21,844 characters.", "" },
-               { "YEAR DATA TYPE", "gint", "A year in two-digit or four-digit format. The default is 
four-digit format. In four-digit format, the allowable values are 1901 to 2155, and 0000. In two-digit 
format, the allowable values are 70 to 69, representing years from 1970 to 2069. MySQL displays YEAR values 
in YYYY format, but allows you to assign values to YEAR columns using either strings or numbers.", "" } 
+               { "YEAR DATA TYPE", "gint", "A year in two-digit or four-digit format. The default is 
four-digit format. In four-digit format, the allowable values are 1901 to 2155, and 0000. In two-digit 
format, the allowable values are 70 to 69, representing years from 1970 to 2069. MySQL displays YEAR values 
in YYYY format, but allows you to assign values to YEAR columns using either strings or numbers.", "" },
+               { "POINT", "GdaGeometricPoint", "A point with x and y coordinates", "" }
        };
         GdaDataModel *model;
         gboolean retval = TRUE;
@@ -395,7 +396,7 @@ _gda_mysql_meta__btypes (G_GNUC_UNUSED GdaServerProvider  *prov,
                        g_value_set_string (tmp_value = gda_value_new (G_TYPE_STRING), data_type->gtype);
                        values = g_list_append (values, tmp_value); 
 
-                       g_value_set_string (tmp_value = gda_value_new (G_TYPE_STRING), data_type->comments);
+                       g_value_set_string (tmp_value = gda_value_new (GDA_TYPE_TEXT), data_type->comments);
                        values = g_list_append (values, tmp_value); 
 
                        if (data_type->synonyms && *(data_type->synonyms))
@@ -404,7 +405,7 @@ _gda_mysql_meta__btypes (G_GNUC_UNUSED GdaServerProvider  *prov,
                                tmp_value = gda_value_new_null ();
                        values = g_list_append (values, tmp_value); 
 
-                       g_value_set_boolean (tmp_value = gda_value_new (G_TYPE_BOOLEAN), FALSE);
+                       g_value_set_int (tmp_value = gda_value_new (G_TYPE_INT), 0);
                        values = g_list_append (values, tmp_value); 
 
                        if (gda_data_model_append_values (model, values, NULL) < 0) {
@@ -1013,7 +1014,7 @@ map_mysql_type_to_gda (const GValue *value, const gchar *vlength)
        else if (!strcmp (string, "smallint unsigned"))
                newstring = "gushort";
        else if (!strcmp (string, "text"))
-               newstring = "GdaBinary";
+               newstring = "GdaText";
        else if (!strcmp (string, "tinyint"))
                newstring = "gchar";
        else if (!strcmp (string, "tinyint unsigned"))
diff --git a/tests/meta-store/check_meta_store_mysql.c b/tests/meta-store/check_meta_store_mysql.c
index 9f9bc0cbd..44eb8a54d 100644
--- a/tests/meta-store/check_meta_store_mysql.c
+++ b/tests/meta-store/check_meta_store_mysql.c
@@ -50,7 +50,7 @@ main(int argc, char ** argv)
        g_print ("STORE: %p, version: %d\n", store, store ? gda_meta_store_get_version (store) : 0);
 
        /* Tests */
-       tests_group_1 (store);
+       tests_group_2 (store);
        g_object_unref (store);
        
        g_print ("Test Ok.\n");
diff --git a/tests/meta-store/common.c b/tests/meta-store/common.c
index e8500857a..34ab593d0 100644
--- a/tests/meta-store/common.c
+++ b/tests/meta-store/common.c
@@ -94,7 +94,7 @@ find_expected_change (const gchar *change_as_str)
        GSList *el;
        for (el = expected_changes; el; el = el->next) {
                gchar *estr = (gchar *) el->data;
-               if (!strcmp (estr, change_as_str)) {
+               if (!g_strcmp0 (estr, change_as_str)) {
                        g_free (estr);
                        expected_changes = g_slist_delete_link (expected_changes, el);
                        return TRUE;
@@ -399,6 +399,36 @@ tests_group_1 (GdaMetaStore *store)
        test_parameters (store);
 }
 
+
+/*
+ *
+ * Test groups
+ *
+ * Apply Group 2 for MySQL provider
+ *
+ */
+void
+tests_group_2 (GdaMetaStore *store)
+{
+       common_declare_meta_store (store);
+
+       test_information_schema_catalog_name (store);
+       test_schemata_1 (store);
+       test_schemata_2 (store);
+       //test_builtin_data_types (store);
+       //test_domains (store);
+       test_tables (store);
+       test_views (store);
+       test_routines (store);
+       test_triggers (store);
+       //test_columns (store);
+       test_table_constraints (store);
+       test_referential_constraints (store);
+       /*test_key_column_usage (store);*/
+       test_domain_constraints (store);
+       test_parameters (store);
+}
+
 /*
  *
  *
diff --git a/tests/meta-store/common.h b/tests/meta-store/common.h
index d3072e3df..5452ebfba 100644
--- a/tests/meta-store/common.h
+++ b/tests/meta-store/common.h
@@ -45,6 +45,7 @@ void     test_domain_constraints (GdaMetaStore *store);
 void     test_parameters (GdaMetaStore *store);
 
 void     tests_group_1 (GdaMetaStore *store);
+void     tests_group_2 (GdaMetaStore *store);
 
 gboolean test_setup (const gchar *prov_id);
 gboolean test_finish (GdaConnection *cnc);


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