libgda r3371 - in trunk: . installers/WindowsWix libgda libgda/sqlite providers/mysql providers/postgres providers/skel-implementation/capi tools



Author: vivien
Date: Fri Mar 27 20:25:00 2009
New Revision: 3371
URL: http://svn.gnome.org/viewvc/libgda?rev=3371&view=rev

Log:
2009-03-27  Vivien Malerba <malerba gnome-db org>

        Merged changes from LIBGDA_4.0 branch between revisions 3362 and 3370


Added:
   trunk/libgda/gda-connection-sqlite.h
      - copied unchanged from r3370, /branches/LIBGDA_4.0/libgda/gda-connection-sqlite.h
   trunk/libgda/gda-server-operation-private.h
      - copied unchanged from r3370, /branches/LIBGDA_4.0/libgda/gda-server-operation-private.h
   trunk/libgda/sqlite/gen_emb_string.c
      - copied unchanged from r3370, /branches/LIBGDA_4.0/libgda/sqlite/gen_emb_string.c
Modified:
   trunk/   (props changed)
   trunk/ChangeLog
   trunk/NEWS
   trunk/installers/WindowsWix/   (props changed)
   trunk/installers/WindowsWix/make-zip-exe.sh
   trunk/libgda/Makefile.am
   trunk/libgda/gda-config.c
   trunk/libgda/gda-connection.c
   trunk/libgda/gda-meta-store.c
   trunk/libgda/gda-server-operation.c
   trunk/libgda/gda-types.c   (props changed)
   trunk/libgda/gda-types.h   (props changed)
   trunk/libgda/libgda.symbols
   trunk/libgda/sqlite/   (props changed)
   trunk/libgda/sqlite/Makefile.am
   trunk/libgda/sqlite/gda-sqlite-provider.c
   trunk/providers/mysql/gda-mysql-provider.c
   trunk/providers/postgres/gda-postgres-provider.c
   trunk/providers/skel-implementation/capi/gda-capi-provider.c
   trunk/tools/gda-sql.c
   trunk/tools/gda-threader.c   (props changed)
   trunk/tools/gda-threader.h   (props changed)

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Fri Mar 27 20:25:00 2009
@@ -1,3 +1,9 @@
+libgda 4.0.1, 2009-03-27
+
+ - make sure Libgda's GdaMetaStore object behaves correctly even if the
+   SQLite provider is not installed
+ - misc. corrections
+
 libgda 4.0.0, 2009-03-16
 
 libgda 3.99.14, 2009-03-15

Modified: trunk/installers/WindowsWix/make-zip-exe.sh
==============================================================================
--- trunk/installers/WindowsWix/make-zip-exe.sh	(original)
+++ trunk/installers/WindowsWix/make-zip-exe.sh	Fri Mar 27 20:25:00 2009
@@ -14,10 +14,11 @@
 # $version is the current Libgda's version
 #
 
-cross_path=/fillme
+cross_path=/local/Win32/gtk
 depend_path=/local/Win32
-prefix=/fillme
-version=`date +%Y%m%d`
+prefix=/local/Win32/gtk
+version=4.0.1
+
 
 
 #
@@ -85,9 +86,12 @@
 #
 # Libgda's files
 #
-files=(bdb_specs_dsn.xml information_schema.xml mdb_specs_dsn.xml mysql_specs_add_column.xml mysql_specs_create_db.xml mysql_specs_create_index.xml mysql_specs_create_table.xml mysql_specs_create_view.xml mysql_specs_drop_column.xml mysql_specs_drop_db.xml mysql_specs_drop_index.xml mysql_specs_drop_table.xml mysql_specs_drop_view.xml mysql_specs_dsn.xml mysql_specs_rename_table.xml postgres_specs_add_column.xml postgres_specs_create_db.xml postgres_specs_create_index.xml postgres_specs_create_table.xml postgres_specs_create_view.xml postgres_specs_drop_column.xml postgres_specs_drop_db.xml postgres_specs_drop_index.xml postgres_specs_drop_table.xml postgres_specs_drop_view.xml postgres_specs_dsn.xml postgres_specs_rename_table.xml sqlite_specs_add_column.xml sqlite_specs_create_db.xml sqlite_specs_create_index.xml sqlite_specs_create_table.xml sqlite_specs_create_view.xml sqlite_specs_drop_db.xml sqlite_specs_drop_index.xml sqlite_specs_drop_table.xml sqlite_specs_drop_view
 .xml sqlite_specs_dsn.xml sqlite_specs_rename_table.xml)
+files=(bdb_specs_dsn.xml information_schema.xml mdb_specs_dsn.xml mysql_specs_add_column.xml mysql_specs_create_db.xml mysql_specs_create_index.xml mysql_specs_create_table.xml mysql_specs_create_view.xml mysql_specs_drop_column.xml mysql_specs_drop_db.xml mysql_specs_drop_index.xml mysql_specs_drop_table.xml mysql_specs_drop_view.xml mysql_specs_dsn.xml mysql_specs_rename_table.xml postgres_specs_add_column.xml postgres_specs_create_db.xml postgres_specs_create_index.xml postgres_specs_create_table.xml postgres_specs_create_view.xml postgres_specs_drop_column.xml postgres_specs_drop_db.xml postgres_specs_drop_index.xml postgres_specs_drop_table.xml postgres_specs_drop_view.xml postgres_specs_dsn.xml postgres_specs_rename_table.xml sqlite_specs_add_column.xml sqlite_specs_create_db.xml sqlite_specs_create_index.xml sqlite_specs_create_table.xml sqlite_specs_create_view.xml sqlite_specs_drop_db.xml sqlite_specs_drop_index.xml sqlite_specs_drop_table.xml sqlite_specs_drop_view
 .xml sqlite_specs_dsn.xml sqlite_specs_rename_table.xml jdbc_specs_dsn.xml)
 add_files_to_zip $archive $prefix share/libgda-4.0 $files
 
+files=(cnc.js md5.js jquery.js mouseapp_2.js mouseirb_2.js irb.js gda.css gda-print.css irb.css)
+add_files_to_zip $archive $prefix share/libgda-4.0/web $files
+
 files=(libgda-paramlist.dtd libgda-array.dtd libgda-server-operation.dtd)
 add_files_to_zip $archive $prefix share/libgda-4.0/dtd $files
 
@@ -97,13 +101,13 @@
 files=(gda-sql-4.0.exe gda-test-connection-4.0.exe libgda-4.0-4.dll libgda-report-4.0-4.dll)
 add_files_to_zip $archive $prefix bin $files
 
-files=(libgda-sqlite.dll libgda-postgres.dll libgda-mysql.dll libgda-mdb.dll libgda-bdb.dll)
+files=(libgda-sqlite.dll libgda-postgres.dll libgda-mysql.dll libgda-mdb.dll libgda-bdb.dll gdaprovider-4.0.jar libgda-jdbc.dll)
 add_files_to_zip $archive $prefix lib/libgda-4.0/providers $files
 
 #
 # includes
 #
-files=(gda-batch.h gda-blob-op.h gda-column.h gda-config.h gda-connection-event.h gda-connection.h gda-connection-private.h gda-data-access-wrapper.h gda-data-comparator.h gda-data-handler.h gda-data-model-array.h gda-data-model-bdb.h gda-data-model-dir.h gda-data-model-extra.h gda-data-model.h gda-data-model-import.h gda-data-model-iter-extra.h gda-data-model-iter.h gda-data-model-private.h gda-data-proxy.h gda-data-select.h gda-debug-macros.h gda-decl.h gda-easy.h gda-enums.h gda-enum-types.h gda-holder.h gda-lockable.h gda-log.h gda-marshal.h gda-meta-store.h gda-meta-struct.h gda-mutex.h gda-quark-list.h gda-row.h gda-server-operation.h gda-server-provider-extra.h gda-server-provider.h gda-server-provider-private.h gda-set.h gda-statement-extra.h gda-statement.h gda-threader.h gda-transaction-status.h gda-transaction-status-private.h gda-util.h gda-value.h gda-xa-transaction.h libgda.h)
+files=(gda-attributes-manager.h gda-batch.h gda-binreloc.h gda-blob-op.h gda-column.h gda-config.h gda-connection-event.h gda-connection.h gda-connection-private.h gda-data-access-wrapper.h gda-data-comparator.h gda-data-handler.h gda-data-model-array.h gda-data-model-bdb.h gda-data-model-dir.h gda-data-model-extra.h gda-data-model.h gda-data-model-import.h gda-data-model-iter-extra.h gda-data-model-iter.h gda-data-model-private.h gda-data-proxy.h gda-data-select.h gda-debug-macros.h gda-decl.h gda-easy.h gda-enums.h gda-enum-types.h gda-error.h gda-holder.h gda-lockable.h gda-log.h gda-marshal.h gda-meta-store.h gda-meta-struct.h gda-mutex.h gda-quark-list.h gda-row.h gda-server-operation.h gda-server-provider-extra.h gda-server-provider.h gda-server-provider-private.h gda-set.h gda-statement-extra.h gda-statement.h gda-transaction-status.h gda-transaction-status-private.h gda-util.h gda-value.h gda-xa-transaction.h libgda.h)
 add_files_to_zip $archive_dev $prefix include/libgda-4.0/libgda $files
 
 files=(gda-sqlite-provider.h)
@@ -133,7 +137,7 @@
 #
 # static libs
 #
-files=(libgda-4.0.a libgda-4.0.dll.a libgda-report-4.0.a libgda-report-4.0.dll.a)
+files=(libgda-4.0.a libgda-4.0.dll.a libgda-4.0.lib libgda-4.0.def libgda-report-4.0.a libgda-report-4.0.dll.a libgda-report-4.0.lib libgda-report-4.0.def)
 add_files_to_zip $archive_dev $prefix lib $files
 
 #
@@ -143,6 +147,13 @@
 add_files_to_zip $archive_dev $prefix share/gtk-doc/html/libgda-4.0 $files
 
 #
+# translations
+#
+files=(ga/LC_MESSAGES/libgda-4.0.mo nb/LC_MESSAGES/libgda-4.0.mo gl/LC_MESSAGES/libgda-4.0.mo tr/LC_MESSAGES/libgda-4.0.mo ru/LC_MESSAGES/libgda-4.0.mo ne/LC_MESSAGES/libgda-4.0.mo fi/LC_MESSAGES/libgda-4.0.mo sk/LC_MESSAGES/libgda-4.0.mo sl/LC_MESSAGES/libgda-4.0.mo lt/LC_MESSAGES/libgda-4.0.mo el/LC_MESSAGES/libgda-4.0.mo zh_CN/LC_MESSAGES/libgda-4.0.mo eu/LC_MESSAGES/libgda-4.0.mo ml/LC_MESSAGES/libgda-4.0.mo ms/LC_MESSAGES/libgda-4.0.mo sr Latn/LC_MESSAGES/libgda-4.0.mo mk/LC_MESSAGES/libgda-4.0.mo fr/LC_MESSAGES/libgda-4.0.mo pl/LC_MESSAGES/libgda-4.0.mo pa/LC_MESSAGES/libgda-4.0.mo ko/LC_MESSAGES/libgda-4.0.mo vi/LC_MESSAGES/libgda-4.0.mo da/LC_MESSAGES/libgda-4.0.mo oc/LC_MESSAGES/libgda-4.0.mo en_GB/LC_MESSAGES/libgda-4.0.mo sr/LC_MESSAGES/libgda-4.0.mo es/LC_MESSAGES/libgda-4.0.mo zh_TW/LC_MESSAGES/libgda-4.0.mo ar/LC_MESSAGES/libgda-4.0.mo nl/LC_MESSAGES/libgda-4.0.mo it/LC_MESSAGES/libgda-4.0.mo en_CA/LC_MESSAGES/libgda-4.0.mo rw/LC_MESSAGES/libgda-4.0.mo hr/LC_ME
 SSAGES/libgda-4.0.mo az/LC_MESSAGES/libgda-4.0.mo ca/LC_MESSAGES/libgda-4.0.mo hu/LC_MESSAGES/libgda-4.0.mo pt/LC_MESSAGES/libgda-4.0.mo uk/LC_MESSAGES/libgda-4.0.mo ja/LC_MESSAGES/libgda-4.0.mo zh_HK/LC_MESSAGES/libgda-4.0.mo sq/LC_MESSAGES/libgda-4.0.mo sv/LC_MESSAGES/libgda-4.0.mo dz/LC_MESSAGES/libgda-4.0.mo fa/LC_MESSAGES/libgda-4.0.mo de/LC_MESSAGES/libgda-4.0.mo cs/LC_MESSAGES/libgda-4.0.mo pt_BR/LC_MESSAGES/libgda-4.0.mo)
+add_files_to_zip $archive $prefix share/locale $files
+
+
+#
 # The End
 #
 echo "Archives written to:"

Modified: trunk/libgda/Makefile.am
==============================================================================
--- trunk/libgda/Makefile.am	(original)
+++ trunk/libgda/Makefile.am	Fri Mar 27 20:25:00 2009
@@ -99,6 +99,7 @@
 	gda-config.c \
 	gda-connection.c \
 	gda-connection-event.c \
+	gda-connection-sqlite.h \
 	gda-custom-marshal.c \
 	gda-custom-marshal.h \
 	gda-data-comparator.c \
@@ -133,6 +134,7 @@
 	gda-row.c \
 	gda-set.c \
 	gda-server-operation.c \
+	gda-server-operation-private.h \
 	gda-server-provider.c \
 	gda-server-provider-extra.c \
 	gda-statement.c \

Modified: trunk/libgda/gda-config.c
==============================================================================
--- trunk/libgda/gda-config.c	(original)
+++ trunk/libgda/gda-config.c	Fri Mar 27 20:25:00 2009
@@ -34,6 +34,8 @@
 #include <libgda/gda-holder.h>
 #include <libgda/gda-log.h>
 #include <libgda/gda-util.h>
+#include <libgda/sqlite/gda-sqlite-provider.h>
+
 #ifdef HAVE_GIO
   #ifdef HAVE_FAM
     #error Impossible to have GIO and FAM at the same time
@@ -64,6 +66,7 @@
 	gboolean system_config_allowed;
 	GSList *dsn_list; /* list of GdaDsnInfo structures */
 	GSList *prov_list; /* list of InternalProvider structures */
+	gboolean providers_loaded; /* TRUE if providers list has already been scanned */
 };
 
 static void gda_config_class_init (GdaConfigClass *klass);
@@ -145,6 +148,11 @@
 #define GDA_CONFIG_LOCK() g_static_rec_mutex_lock(&gda_mutex)
 #define GDA_CONFIG_UNLOCK() g_static_rec_mutex_unlock(&gda_mutex)
 
+/* GdaServerProvider for SQLite as a shortcut, available
+ * even if the SQLite provider is not installed
+ */
+GdaServerProvider *_gda_config_sqlite_provider = NULL;
+
 /*
  * GdaConfig class implementation
  * @klass:
@@ -249,6 +257,7 @@
 	conf->priv->system_config_allowed = FALSE;
 	conf->priv->prov_list = NULL;
 	conf->priv->dsn_list = NULL;
+	conf->priv->providers_loaded = FALSE;
 }
 
 static void
@@ -1128,7 +1137,7 @@
 	if (!unique_instance)
 		gda_config_get ();
 
-	if (!unique_instance->priv->prov_list) 
+	if (!unique_instance->priv->providers_loaded) 
 		load_all_providers ();
 
 	if (!g_ascii_strcasecmp (provider_name, "MS Access")) {
@@ -1241,7 +1250,7 @@
 	if (!unique_instance)
 		gda_config_get ();
 
-	if (!unique_instance->priv->prov_list) 
+	if (!unique_instance->priv->providers_loaded) 
 		load_all_providers ();
 
 	model = gda_data_model_array_new_with_g_types (5,
@@ -1340,6 +1349,14 @@
 		load_providers_from_dir (str, FALSE);
 		g_free (str);
 	}
+	unique_instance->priv->providers_loaded = TRUE;
+
+	/* find SQLite provider, and instanciate it if not installed */
+	_gda_config_sqlite_provider = gda_config_get_provider ("SQLite", NULL);
+	if (!_gda_config_sqlite_provider) {
+		_gda_config_sqlite_provider = (GdaServerProvider*) 
+			g_object_new (GDA_TYPE_SQLITE_PROVIDER, NULL);
+	}
 }
 
 static InternalProvider *
@@ -1616,8 +1633,8 @@
 	if (event_type != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)
 		return;
 
-	gboolean is_system = (mon == mon_conf_global) ? TRUE : FALSE;
 #ifdef GDA_DEBUG_NO
+	gboolean is_system = (mon == mon_conf_global) ? TRUE : FALSE;
 	g_print ("Reloading config files (%s config has changed)\n", is_system ? "global" : "user");
 	GSList *list;
 	for (list = unique_instance->priv->dsn_list; list; list = list->next) {

Modified: trunk/libgda/gda-connection.c
==============================================================================
--- trunk/libgda/gda-connection.c	(original)
+++ trunk/libgda/gda-connection.c	Fri Mar 27 20:25:00 2009
@@ -119,6 +119,7 @@
 };
 
 static GObjectClass *parent_class = NULL;
+extern GdaServerProvider *_gda_config_sqlite_provider; /* defined in gda-config.c */
 
 /*
  * GdaConnection class implementation
@@ -801,6 +802,50 @@
 	return cnc;
 }
 
+/*
+ * Uses _gda_config_sqlite_provider to open a connection
+ */
+GdaConnection *
+_gda_open_internal_sqlite_connection (const gchar *cnc_string)
+{
+	GdaConnection *cnc;
+	GdaServerProvider *prov = _gda_config_sqlite_provider;
+	gchar *user, *pass, *real_cnc, *real_provider;
+
+	g_print ("%s(%s)\n", __FUNCTION__, cnc_string);
+	gda_connection_string_split (cnc_string, &real_cnc, &real_provider, &user, &pass);
+        if (!real_cnc) {
+                g_free (user);
+                g_free (pass);
+                g_free (real_provider);
+                return NULL;
+        }
+	if (PROV_CLASS (prov)->create_connection) {
+		cnc = PROV_CLASS (prov)->create_connection (prov);
+		if (cnc)
+			g_object_set (G_OBJECT (cnc),
+				      "provider", prov,
+				      "cnc-string", real_cnc,
+				      NULL);
+	}
+	else
+		cnc = (GdaConnection *) g_object_new (GDA_TYPE_CONNECTION,
+						      "provider", prov,
+						      "cnc-string", real_cnc,
+						      NULL);
+	
+	g_free (real_cnc);
+        g_free (user);
+        g_free (pass);
+        g_free (real_provider);
+
+	/* open the connection */
+	if (!gda_connection_open (cnc, NULL)) {
+		g_object_unref (cnc);
+		cnc = NULL;
+	}
+	return cnc;
+}
 
 /**
  * gda_connection_open

Modified: trunk/libgda/gda-meta-store.c
==============================================================================
--- trunk/libgda/gda-meta-store.c	(original)
+++ trunk/libgda/gda-meta-store.c	Fri Mar 27 20:25:00 2009
@@ -39,6 +39,7 @@
 #include <libgda/gda-util.h>
 #include <libgda/gda-meta-struct.h>
 #include <libgda/gda-connection.h>
+#include <libgda/gda-connection-sqlite.h>
 #include "gda-types.h"
 
 /*
@@ -699,6 +700,13 @@
 				if (cnc_string) {
 					GdaConnection *cnc;
 					cnc = gda_connection_open_from_string (NULL, cnc_string, NULL, 0, NULL);
+					if (!cnc) {
+						if (g_ascii_strcasecmp (cnc_string, "sqlite")) {
+							/* use _gda_config_sqlite_provider */
+							
+							cnc = _gda_open_internal_sqlite_connection (cnc_string);
+						}
+					}
 					store->priv->cnc = cnc;
 				}
 			}

Modified: trunk/libgda/gda-server-operation.c
==============================================================================
--- trunk/libgda/gda-server-operation.c	(original)
+++ trunk/libgda/gda-server-operation.c	Fri Mar 27 20:25:00 2009
@@ -519,6 +519,7 @@
 }
 
 static void xml_validity_error_func (void *ctx, const char *msg, ...);
+static gboolean use_xml_spec (GdaServerOperation *op, xmlDocPtr doc, const gchar *xmlfile);
 
 static void
 gda_server_operation_set_property (GObject *object,
@@ -567,7 +568,6 @@
 			const gchar *xmlfile;
 			static GHashTable *doc_hash = NULL; /* key = file name, value = xmlDocPtr */
 
-			xmlDtdPtr old_dtd = NULL;
 			xmlfile = g_value_get_string (value);
 			if (!xmlfile)
 				return;
@@ -590,52 +590,8 @@
 			
 			doc = xmlParseFile (xmlfile);
 			if (doc) {
-				/* doc validation */
-				xmlValidCtxtPtr validc;
-				int xmlcheck;
-				
-				validc = g_new0 (xmlValidCtxt, 1);
-				validc->userData = op;
-				validc->error = xml_validity_error_func;
-				validc->warning = NULL;
-				
-				xmlcheck = xmlDoValidityCheckingDefaultValue;
-				xmlDoValidityCheckingDefaultValue = 1;
-				
-				/* replace the DTD with ours */
-				if (gda_server_op_dtd) {
-					old_dtd = doc->intSubset;
-					doc->intSubset = gda_server_op_dtd;
-				}
-#ifndef G_OS_WIN32
-				if (doc->intSubset && !xmlValidateDocument (validc, doc)) {
-					gchar *str;
-					
-					if (gda_server_op_dtd)
-						doc->intSubset = old_dtd;
-					xmlFreeDoc (doc);
-					g_free (validc);
-					str = g_object_get_data (G_OBJECT (op), "xmlerror");
-					if (str) {
-						g_warning (_("GdaServerOperation: file '%s' does not conform to DTD:\n%s"),
-							   xmlfile, str);
-						g_free (str);
-						g_object_set_data (G_OBJECT (op), "xmlerror", NULL);
-					}
-					else
-						g_warning (_("GdaServerOperation: file '%s' does not conform to DTD"),
-							   xmlfile);
-					
-					xmlDoValidityCheckingDefaultValue = xmlcheck;
+				if (!use_xml_spec (op, doc, xmlfile))
 					return;
-				}
-#endif
-				
-				xmlDoValidityCheckingDefaultValue = xmlcheck;
-				g_free (validc);
-				if (gda_server_op_dtd)
-					doc->intSubset = old_dtd;
-				op->priv->xml_spec_doc = doc;
 				g_hash_table_insert (doc_hash, g_strdup (xmlfile), doc);
 			}
 			else {
@@ -661,7 +617,7 @@
 		}
 	}
 }
-
+	
 static void
 gda_server_operation_get_property (GObject *object,
 				   guint param_id,
@@ -687,6 +643,73 @@
 }
 
 /*
+ * Steals @doc (it is freed if necessary)
+ */
+static gboolean
+use_xml_spec (GdaServerOperation *op, xmlDocPtr doc, const gchar *xmlfile)
+{
+	/* doc validation */
+	xmlValidCtxtPtr validc;
+	int xmlcheck;
+	xmlDtdPtr old_dtd = NULL;
+	
+	validc = g_new0 (xmlValidCtxt, 1);
+	validc->userData = op;
+	validc->error = xml_validity_error_func;
+	validc->warning = NULL;
+	
+	xmlcheck = xmlDoValidityCheckingDefaultValue;
+	xmlDoValidityCheckingDefaultValue = 1;
+	
+	/* replace the DTD with ours */
+	if (gda_server_op_dtd) {
+		old_dtd = doc->intSubset;
+		doc->intSubset = gda_server_op_dtd;
+	}
+#ifndef G_OS_WIN32
+	if (doc->intSubset && !xmlValidateDocument (validc, doc)) {
+		gchar *str;
+		
+		if (gda_server_op_dtd)
+			doc->intSubset = old_dtd;
+		xmlFreeDoc (doc);
+		g_free (validc);
+		str = g_object_get_data (G_OBJECT (op), "xmlerror");
+		if (str) {
+			if (xmlfile)
+				g_warning (_("GdaServerOperation: file '%s' does not conform to DTD:\n%s"),
+					   xmlfile, str);
+			else
+				g_warning (_("GdaServerOperation specification does not conform to DTD:\n%s"),
+					   str);
+			g_free (str);
+			g_object_set_data (G_OBJECT (op), "xmlerror", NULL);
+		}
+		else {
+			if (xmlfile)
+				g_warning (_("GdaServerOperation: file '%s' does not conform to DTD"),
+					   xmlfile);
+			else
+				g_warning (_("GdaServerOperation specification does not conform to DTD\n"));
+		}
+		
+		xmlDoValidityCheckingDefaultValue = xmlcheck;
+		xmlFreeDoc (doc);
+		return FALSE;
+	}
+#endif
+	
+	xmlDoValidityCheckingDefaultValue = xmlcheck;
+	g_free (validc);
+	if (gda_server_op_dtd)
+		doc->intSubset = old_dtd;
+	op->priv->xml_spec_doc = doc;
+
+	return TRUE;
+}
+
+
+/*
  * function called when an error occurred during the document validation
  */
 static void
@@ -953,6 +976,41 @@
 	return retlist;
 }
 
+/*
+ * @xml_spec: the specifications for the GdaServerOperation object to create as a string
+ * Internal function
+ */
+GdaServerOperation *
+_gda_server_operation_new_from_string (GdaServerOperationType op_type, 
+				       const gchar *xml_spec)
+{
+	GObject *obj;
+	xmlDocPtr doc;
+	GdaServerOperation *op;
+
+	doc = xmlParseMemory (xml_spec, strlen (xml_spec) + 1);
+	if (!doc)
+		return NULL;
+	obj = g_object_new (GDA_TYPE_SERVER_OPERATION, "op-type", op_type, NULL);
+	op = GDA_SERVER_OPERATION (obj);
+	use_xml_spec (op, doc, NULL);
+
+	if (!op->priv->topnodes && op->priv->xml_spec_doc && op->priv->cnc_set && op->priv->prov_set) {
+		/* load XML file */
+		GError *lerror = NULL;
+		op->priv->topnodes = load_xml_spec (op, xmlDocGetRootElement (op->priv->xml_spec_doc), NULL, &lerror);
+		if (!op->priv->topnodes) {
+			g_warning (_("Could not load XML specifications: %s"),
+				   lerror && lerror->message ? lerror->message : _("No detail"));
+			if (lerror)
+				g_error_free (lerror);
+		}
+	}
+
+	return op;
+}
+
+
 /**
  * gda_server_operation_new
  * @op_type: type of operation
@@ -974,7 +1032,8 @@
 {
 	GObject *obj;
 
-	obj = g_object_new (GDA_TYPE_SERVER_OPERATION, "op-type", op_type, "spec-filename", xml_file, NULL);
+	obj = g_object_new (GDA_TYPE_SERVER_OPERATION, "op-type", op_type, 
+			    "spec-filename", xml_file, NULL);
 #ifdef GDA_DEBUG_NO
 	{
 		g_print ("New GdaServerOperation:\n");

Modified: trunk/libgda/libgda.symbols
==============================================================================
--- trunk/libgda/libgda.symbols	(original)
+++ trunk/libgda/libgda.symbols	Fri Mar 27 20:25:00 2009
@@ -713,7 +713,6 @@
 	gda_transaction_status_add_event_sql
 	gda_transaction_status_add_event_sub
 	gda_transaction_status_add_event_svp
-	gda_transaction_status_dump
 	gda_transaction_status_event_type_get_type
 	gda_transaction_status_find
 	gda_transaction_status_find_current

Modified: trunk/libgda/sqlite/Makefile.am
==============================================================================
--- trunk/libgda/sqlite/Makefile.am	(original)
+++ trunk/libgda/sqlite/Makefile.am	Fri Mar 27 20:25:00 2009
@@ -20,8 +20,16 @@
 	$(SQLITE_CFLAGS) \
 	$(sqliteinc) 
 
+gen_emb_string$(EXEEXT_FOR_BUILD): gen_emb_string.c
+	$(CC_FOR_BUILD) -o gen_emb_string$(EXEEXT_FOR_BUILD) $<
+
+xml_embedded.h: gen_emb_string$(EXEEXT_FOR_BUILD) $(top_srcdir)/providers/sqlite/*.xml.in
+	./gen_emb_string$(EXEEXT_FOR_BUILD) $(top_srcdir)/providers/sqlite/*.xml.in > xml_embedded.h
 
 sqliteheaders = gda-sqlite-provider.h
+
+$(libgda_sqlite_la_OBJECTS): xml_embedded.h
+
 libgda_sqlite_la_SOURCES = \
 	$(sqliteheaders) \
 	gda-sqlite-blob-op.c \
@@ -38,7 +46,7 @@
 	gda-sqlite-recordset.c \
 	gda-sqlite-recordset.h \
 	gda-sqlite.h \
-	utils.c 
+	utils.c
 
 libgda_sqlite_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED)
 libgda_sqlite_la_LIBADD = \
@@ -49,3 +57,6 @@
 gdaincludedir=$(includedir)/libgda-$(GDA_ABI_MAJOR_VERSION).$(GDA_ABI_MINOR_VERSION)/libgda/sqlite
 gdainclude_HEADERS=$(sqliteheaders)
 
+EXTRA_DIST = gen_emb_string.c
+
+CLEANFILES = gen_emb_string$(EXEEXT_FOR_BUILD) xml_embedded.h

Modified: trunk/libgda/sqlite/gda-sqlite-provider.c
==============================================================================
--- trunk/libgda/sqlite/gda-sqlite-provider.c	(original)
+++ trunk/libgda/sqlite/gda-sqlite-provider.c	Fri Mar 27 20:25:00 2009
@@ -31,6 +31,7 @@
 #include <libgda/gda-data-model-private.h>
 #include <libgda/gda-util.h>
 #include <libgda/gda-server-provider-extra.h>
+#include <libgda/gda-server-operation-private.h>
 #include "gda-sqlite.h"
 #include "gda-sqlite-provider.h"
 #include "gda-sqlite-recordset.h"
@@ -44,6 +45,7 @@
 #include <libgda/gda-statement-extra.h>
 #include <sql-parser/gda-sql-parser.h>
 #include <stdio.h>
+#include "xml_embedded.h" /* this one is dynamically generated */
 #ifndef G_OS_WIN32
 #define __USE_GNU
 #include <dlfcn.h>
@@ -955,13 +957,23 @@
 	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
         file = gda_server_provider_find_file (provider, dir, str);
 	g_free (dir);
-        g_free (str);
 
         if (! file) {
-                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), file);
-                return NULL;
+		const gchar *contents;
+		contents = emb_get_file (str);
+		if (contents) {
+			op = _gda_server_operation_new_from_string (type, contents);
+			return op;
+		}
+		else {
+			g_set_error (error, 0, 0, _("Missing spec. file '%s'"), str);
+			g_free (str);
+			return NULL;
+		}
         }
 
+        g_free (str);
+
         op = gda_server_operation_new (type, file);
         g_free (file);
 
@@ -988,17 +1000,25 @@
 	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
         file = gda_server_provider_find_file (provider, dir, str);
 	g_free (dir);
-        g_free (str);
 
         if (! file) {
-                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), file);
-                return NULL;
-        }
-        if (!gda_server_operation_is_valid (op, file, error)) {
-                g_free (file);
-                return NULL;
+		const gchar *contents;
+		contents = emb_get_file (str);
+		if (!contents) {
+			g_set_error (error, 0, 0, _("Missing spec. file '%s'"), str);
+			g_free (str);
+			return NULL;
+		}
+		/* else: TO_IMPLEMENT */
         }
-        g_free (file);
+	else {
+		g_free (str);
+		if (!gda_server_operation_is_valid (op, file, error)) {
+			g_free (file);
+			return NULL;
+		}
+		g_free (file);
+	}
 
 	/* actual rendering */
         switch (gda_server_operation_get_op_type (op)) {

Modified: trunk/providers/mysql/gda-mysql-provider.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-provider.c	(original)
+++ trunk/providers/mysql/gda-mysql-provider.c	Fri Mar 27 20:25:00 2009
@@ -753,12 +753,13 @@
 	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
         file = gda_server_provider_find_file (provider, dir, str);
 	g_free (dir);
-        g_free (str);
 
         if (! file) {
-                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), file);
+                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), str);
+		g_free (str);
                 return NULL;
         }
+        g_free (str);
 
         op = gda_server_operation_new (type, file);
         g_free (file);
@@ -793,12 +794,13 @@
 	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
         file = gda_server_provider_find_file (provider, dir, str);
 	g_free (dir);
-        g_free (str);
 
         if (! file) {
-                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), file);
+                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), str);
+		g_free (str);
                 return NULL;
         }
+        g_free (str);
         if (!gda_server_operation_is_valid (op, file, error)) {
                 g_free (file);
                 return NULL;

Modified: trunk/providers/postgres/gda-postgres-provider.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-provider.c	(original)
+++ trunk/providers/postgres/gda-postgres-provider.c	Fri Mar 27 20:25:00 2009
@@ -908,12 +908,13 @@
 	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
         file = gda_server_provider_find_file (provider, dir, str);
 	g_free (dir);
-        g_free (str);
 
         if (! file) {
-                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), file);
+                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), str);
+		g_free (str);
                 return NULL;
         }
+        g_free (str);
 
         op = gda_server_operation_new (type, file);
         g_free (file);
@@ -946,12 +947,13 @@
 	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
         file = gda_server_provider_find_file (provider, dir, str);
 	g_free (dir);
-        g_free (str);
 
         if (! file) {
-                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), file);
+                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), str);
+		g_free (str);
                 return NULL;
         }
+        g_free (str);
         if (!gda_server_operation_is_valid (op, file, error)) {
                 g_free (file);
                 return NULL;

Modified: trunk/providers/skel-implementation/capi/gda-capi-provider.c
==============================================================================
--- trunk/providers/skel-implementation/capi/gda-capi-provider.c	(original)
+++ trunk/providers/skel-implementation/capi/gda-capi-provider.c	Fri Mar 27 20:25:00 2009
@@ -504,12 +504,13 @@
 	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
         file = gda_server_provider_find_file (provider, dir, str);
 	g_free (dir);
-        g_free (str);
 
         if (! file) {
-                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), file);
+                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), str);
+		g_free (str);
                 return NULL;
         }
+        g_free (str);
 
         op = gda_server_operation_new (type, file);
         g_free (file);
@@ -542,12 +543,13 @@
 	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
         file = gda_server_provider_find_file (provider, dir, str);
 	g_free (dir);
-        g_free (str);
 
         if (! file) {
-                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), file);
+                g_set_error (error, 0, 0, _("Missing spec. file '%s'"), str);
+		g_free (str);
                 return NULL;
         }
+        g_free (str);
         if (!gda_server_operation_is_valid (op, file, error)) {
                 g_free (file);
                 return NULL;

Modified: trunk/tools/gda-sql.c
==============================================================================
--- trunk/tools/gda-sql.c	(original)
+++ trunk/tools/gda-sql.c	Fri Mar 27 20:25:00 2009
@@ -1404,7 +1404,8 @@
 		}
 		else {
 			store = gda_meta_store_new (NULL);
-			update_store = TRUE;
+			if (store)
+				update_store = TRUE;
 		}
 
 		g_object_set (G_OBJECT (cs->cnc), "meta-store", store, NULL);
@@ -1450,7 +1451,8 @@
 						g_print (_("Done.\n"));
 			}
 		}
-		g_object_unref (store);
+		if (store)
+			g_object_unref (store);
 	}
 
 	return cs;



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