Commit 4d9b1705 authored by Vivien Malerba's avatar Vivien Malerba

MySQL adaptations to make provider work correctly in case some files are missing

parent 0af77a1c
......@@ -38,6 +38,7 @@ libgda_mysql_la_SOURCES = \
gda-mysql-pstmt.c \
gda-mysql-pstmt.h \
gda-mysql.h \
mysql.gresources.c \
libmain.c
libgda_mysql_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED) $(LIBTOOL_PROV_EXPORT_OPTIONS)
......@@ -65,11 +66,23 @@ xml_in_files = \
@INTLTOOL_XML_RULE@
xml_DATA = $(xml_in_files:.xml.in=.xml)
CLEANFILES = $(genfiles)
xml_DATA = $(xml_in_files:.xml.in=.xml)
# resources
RESOURCES=$(xml_in_files:.xml.in=.raw.xml)
mysql.gresources.c: mysql.gresource.xml $(RESOURCES)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $(srcdir)/mysql.gresource.xml
%.raw.xml:%.xml.in
@echo " GEN $@"
@cat $< | sed -e 's/_\([a-zA-Z0-9]*\)=/\1=/g' -e 's/<_\([a-ZA-Z0-9_]*\)>/<\1>/g' -e 's/<\/_\([a-ZA-Z0-9_]*\)>/<\/\1>/g' -e 's/<!-- .* -->//'> $@
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libgda-mysql-6.0.pc
EXTRA_DIST = $(xml_in_files) libgda-mysql-6.0.pc.in
DISTCLEANFILES = $(xml_DATA) $(genfiles)
CLEANFILES = \
$(genfiles) \
mysql.gresources.c
......@@ -808,7 +808,7 @@ static GdaServerOperation *
gda_mysql_provider_create_operation (GdaServerProvider *provider,
GdaConnection *cnc,
GdaServerOperationType type,
G_GNUC_UNUSED GdaSet *options,
G_GNUC_UNUSED GdaSet *options,
GError **error)
{
gchar *file;
......@@ -822,23 +822,28 @@ gda_mysql_provider_create_operation (GdaServerProvider *provider,
}
file = g_utf8_strdown (gda_server_operation_op_type_to_string (type), -1);
str = g_strdup_printf ("mysql_specs_%s.xml", file);
str = g_strdup_printf ("mysql_specs_%s", file);
g_free (file);
gchar *tmp;
tmp = g_strdup_printf ("%s.xml", str);
dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
file = gda_server_provider_find_file (provider, dir, str);
file = gda_server_provider_find_file (provider, dir, tmp);
g_free (dir);
g_free (tmp);
if (!file) {
g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_FILE_NOT_FOUND_ERROR,
_("Missing spec. file '%s'"), str);
if (file) {
g_free (str);
return NULL;
op = gda_server_operation_new (type, file);
g_free (file);
}
else {
file = g_strdup_printf ("/spec/mysql/%s.raw.xml", str);
g_free (str);
op = GDA_SERVER_OPERATION (g_object_new (GDA_TYPE_SERVER_OPERATION, "op-type", type,
"spec-resource", file, NULL));
g_free (file);
}
g_free (str);
op = gda_server_operation_new (type, file);
g_free (file);
return op;
}
......@@ -864,25 +869,32 @@ gda_mysql_provider_render_operation (GdaServerProvider *provider,
/* test @op's validity */
file = g_utf8_strdown (gda_server_operation_op_type_to_string (gda_server_operation_get_op_type (op)), -1);
str = g_strdup_printf ("mysql_specs_%s.xml", file);
str = g_strdup_printf ("mysql_specs_%s", file);
g_free (file);
gchar *tmp;
tmp = g_strdup_printf ("%s.xml", str);
dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
file = gda_server_provider_find_file (provider, dir, str);
file = gda_server_provider_find_file (provider, dir, tmp);
g_free (dir);
g_free (tmp);
if (!file) {
g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_FILE_NOT_FOUND_ERROR,
_("Missing spec. file '%s'"), str);
if (file) {
g_free (str);
return NULL;
}
g_free (str);
if (!gda_server_operation_is_valid (op, file, error)) {
g_free (file);
return NULL;
if (!gda_server_operation_is_valid (op, file, error)) {
g_free (file);
return NULL;
}
}
else {
file = g_strdup_printf ("/spec/mysql/%s.raw.xml", str);
g_free (str);
if (!gda_server_operation_is_valid_from_resource (op, file, error)) {
g_free (file);
return NULL;
}
}
g_free (file);
g_free (file);
/* actual rendering */
switch (gda_server_operation_get_op_type (op)) {
......
......@@ -4,7 +4,7 @@
* Copyright (C) 2003 Gonzalo Paniagua Javier <gonzalo@gnome-db.org>
* Copyright (C) 2005 Bas Driessen <bas.driessen@xobas.com>
* Copyright (C) 2005 Stanislav Brabec <sbrabec@suse.de>
* Copyright (C) 2005 - 2011 Vivien Malerba <malerba@gnome-db.org>
* Copyright (C) 2005 - 2015 Vivien Malerba <malerba@gnome-db.org>
* Copyright (C) 2011 Murray Cumming <murrayc@murrayc.com>
*
* This library is free software; you can redistribute it and/or
......@@ -83,7 +83,10 @@ plugin_get_dsn_spec (void)
dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
ret = gda_server_provider_load_file_contents (module_path, dir, "mysql_specs_dsn.xml");
g_free (dir);
return ret;
if (ret)
return ret;
else
return gda_server_provider_load_resource_contents ("mysql", "mysql_specs_dsn.raw.xml");
}
GdaServerProvider *
......
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/spec/mysql">
<file compressed="true">mysql_specs_add_column.raw.xml</file>
<file compressed="true">mysql_specs_comment_column.raw.xml</file>
<file compressed="true">mysql_specs_comment_table.raw.xml</file>
<file compressed="true">mysql_specs_create_db.raw.xml</file>
<file compressed="true">mysql_specs_create_index.raw.xml</file>
<file compressed="true">mysql_specs_create_table.raw.xml</file>
<file compressed="true">mysql_specs_create_view.raw.xml</file>
<file compressed="true">mysql_specs_drop_column.raw.xml</file>
<file compressed="true">mysql_specs_drop_db.raw.xml</file>
<file compressed="true">mysql_specs_drop_index.raw.xml</file>
<file compressed="true">mysql_specs_drop_table.raw.xml</file>
<file compressed="true">mysql_specs_drop_view.raw.xml</file>
<file compressed="true">mysql_specs_dsn.raw.xml</file>
<file compressed="true">mysql_specs_rename_table.raw.xml</file>
</gresource>
</gresources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment