[gnome-db] patch for XML provider



The attached patch adds missing code to the XML provider to execute SQL
commands via the GdaSelect object.

Gonzalo, please, have a look at it.

cheers
? depcomp
? doc/C/tmpl/gda-blob.sgml
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/ChangeLog,v
retrieving revision 1.562
diff -u -p -r1.562 ChangeLog
--- ChangeLog	1 Sep 2003 23:24:08 -0000	1.562
+++ ChangeLog	1 Sep 2003 23:59:57 -0000
@@ -1,5 +1,10 @@
 2003-09-01  Rodrigo Moya <rodrigo gnome-db org>
 
+	* providers/xml/gda-xml-provider.c: killed warnings.
+	(process_sql_commands): added missing implementation.
+
+2003-09-01  Rodrigo Moya <rodrigo gnome-db org>
+
 	* doc/C/tmpl/*.sgml:
 	* libgda/gda-parameter.c:
 	* libgda/gda-quark-list.c: added more inline documentation.
Index: providers/oracle/gda-oracle-recordset.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/oracle/gda-oracle-recordset.c,v
retrieving revision 1.9
diff -u -p -r1.9 gda-oracle-recordset.c
--- providers/oracle/gda-oracle-recordset.c	2 Jun 2003 23:03:51 -0000	1.9
+++ providers/oracle/gda-oracle-recordset.c	1 Sep 2003 23:59:58 -0000
@@ -636,8 +636,8 @@ gda_oracle_recordset_get_type (void)
 
 GdaOracleRecordset *
 gda_oracle_recordset_new (GdaConnection *cnc, 
-				GdaOracleConnectionData *cdata,
-				OCIStmt *stmthp)
+			  GdaOracleConnectionData *cdata,
+			  OCIStmt *stmthp)
 {
 	GdaOracleRecordset *recset;
 	ub4 parcount;
@@ -646,11 +646,11 @@ gda_oracle_recordset_new (GdaConnection 
 	g_return_val_if_fail (cdata != NULL, NULL);
 
 	OCIAttrGet ((dvoid *) stmthp,
-			(ub4) OCI_HTYPE_STMT,
-			(dvoid *) &parcount, 
-			0,
-			(ub4) OCI_ATTR_PARAM_COUNT,
-			cdata->herr);
+		    (ub4) OCI_HTYPE_STMT,
+		    (dvoid *) &parcount, 
+		    0,
+		    (ub4) OCI_ATTR_PARAM_COUNT,
+		    cdata->herr);
 
 	recset = g_object_new (GDA_TYPE_ORACLE_RECORDSET, NULL);
 	recset->priv->nrows = -1;
Index: providers/xml/gda-xml-provider.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/xml/gda-xml-provider.c,v
retrieving revision 1.3
diff -u -p -r1.3 gda-xml-provider.c
--- providers/xml/gda-xml-provider.c	28 Jul 2003 11:38:01 -0000	1.3
+++ providers/xml/gda-xml-provider.c	1 Sep 2003 23:59:58 -0000
@@ -25,6 +25,7 @@
 #include <libgda/gda-data-model-array.h>
 #include <libgda/gda-intl.h>
 #include <libgda/gda-row.h>
+#include <libgda/gda-select.h>
 #include <libgda/gda-util.h>
 #include "gda-xml.h"
 #include "gda-xml-recordset.h"
@@ -36,44 +37,44 @@
 
 static void gda_xml_provider_class_init (GdaXmlProviderClass *klass);
 static void gda_xml_provider_init       (GdaXmlProvider *provider,
-					     GdaXmlProviderClass *klass);
+					 GdaXmlProviderClass *klass);
 static void gda_xml_provider_finalize   (GObject *object);
 
 static const gchar *gda_xml_provider_get_version (GdaServerProvider *provider);
 static gboolean gda_xml_provider_open_connection (GdaServerProvider *provider,
-						      GdaConnection *cnc,
-						      GdaQuarkList *params,
-						      const gchar *username,
-						      const gchar *password);
+						  GdaConnection *cnc,
+						  GdaQuarkList *params,
+						  const gchar *username,
+						  const gchar *password);
 static gboolean gda_xml_provider_close_connection (GdaServerProvider *provider,
-						       GdaConnection *cnc);
+						   GdaConnection *cnc);
 static const gchar *gda_xml_provider_get_server_version (GdaServerProvider *provider,
-							     GdaConnection *cnc);
+							 GdaConnection *cnc);
 static const gchar *gda_xml_provider_get_database (GdaServerProvider *provider,
-						       GdaConnection *cnc);
+						   GdaConnection *cnc);
 static gboolean gda_xml_provider_create_database (GdaServerProvider *provider,
-						      GdaConnection *cnc,
-						      const gchar *name);
+						  GdaConnection *cnc,
+						  const gchar *name);
 static GList *gda_xml_provider_execute_command (GdaServerProvider *provider,
-						    GdaConnection *cnc,
-						    GdaCommand *cmd,
-						    GdaParameterList *params);
+						GdaConnection *cnc,
+						GdaCommand *cmd,
+						GdaParameterList *params);
 static gboolean gda_xml_provider_begin_transaction (GdaServerProvider *provider,
-							GdaConnection *cnc,
-							GdaTransaction *xaction);
+						    GdaConnection *cnc,
+						    GdaTransaction *xaction);
 static gboolean gda_xml_provider_commit_transaction (GdaServerProvider *provider,
-							 GdaConnection *cnc,
-							 GdaTransaction *xaction);
+						     GdaConnection *cnc,
+						     GdaTransaction *xaction);
 static gboolean gda_xml_provider_rollback_transaction (GdaServerProvider *provider,
-							   GdaConnection *cnc,
-							   GdaTransaction *xaction);
+						       GdaConnection *cnc,
+						       GdaTransaction *xaction);
 static gboolean gda_xml_provider_supports (GdaServerProvider *provider,
-					       GdaConnection *cnc,
-					       GdaConnectionFeature feature);
+					   GdaConnection *cnc,
+					   GdaConnectionFeature feature);
 static GdaDataModel *gda_xml_provider_get_schema (GdaServerProvider *provider,
-						      GdaConnection *cnc,
-						      GdaConnectionSchema schema,
-						      GdaParameterList *params);
+						  GdaConnection *cnc,
+						  GdaConnectionSchema schema,
+						  GdaParameterList *params);
 
 static GObjectClass *parent_class = NULL;
 
@@ -282,12 +283,36 @@ process_sql_commands (GList *reclist, Gd
 	arr = g_strsplit (sql, ";", 0);
 	if (arr) {
 		gint n = 0;
+		GList *tables, *l;
 
+		tables = gda_xml_database_get_tables (xmldb);
 		while (arr[n]) {
+			GdaSelect *select;
+
+			/* create the GdaSelect and add the sources */
+			select = (GdaSelect *) gda_select_new ();
+			gda_select_set_sql (select, arr[n]);
+
+			for (l = tables; l != NULL; l = l->next) {
+				GdaTable *table;
+
+				table = gda_xml_database_find_table (xmldb, l->data);
+				if (table) {
+					gda_select_add_source (select,
+							       l->data,
+							       (const GdaDataModel *) table);
+				}
+			}
+
+			/* run the SQL */
+			if (gda_select_run (select))
+				reclist = g_list_append (reclist, select);
+
 			n++;
 		}
 
 		g_strfreev (arr);
+		gda_xml_database_free_table_list (tables);
 	}
 
 	return reclist;
@@ -359,22 +384,22 @@ gda_xml_provider_execute_command (GdaSer
 	g_return_val_if_fail (cmd != NULL, NULL);
 
 	switch (gda_command_get_command_type (cmd)) {
-		case GDA_COMMAND_TYPE_SQL:
-			reclist = process_sql_commands (reclist, cnc,
-							gda_command_get_text (cmd));
-			break;
-		case GDA_COMMAND_TYPE_XML:
-			/* FIXME: Implement */
-			return NULL;
-		case GDA_COMMAND_TYPE_PROCEDURE:
-			/* FIXME: Implement */
-			return NULL;
-		case GDA_COMMAND_TYPE_TABLE:
-			reclist = process_table_commands (reclist, cnc,
-							  gda_command_get_text (cmd));
-			break;
-		case GDA_COMMAND_TYPE_INVALID:
-			return NULL;
+	case GDA_COMMAND_TYPE_SQL:
+		reclist = process_sql_commands (reclist, cnc,
+						gda_command_get_text (cmd));
+		break;
+	case GDA_COMMAND_TYPE_XML:
+		/* FIXME: Implement */
+		return NULL;
+	case GDA_COMMAND_TYPE_PROCEDURE:
+		/* FIXME: Implement */
+		return NULL;
+	case GDA_COMMAND_TYPE_TABLE:
+		reclist = process_table_commands (reclist, cnc,
+						  gda_command_get_text (cmd));
+		break;
+	default:
+		return NULL;
 	}
 
 	return reclist;
@@ -498,15 +523,7 @@ get_table_fields (GdaConnection *cnc, Gd
 	/* fill in the recordset to be returned */
 	recset = GDA_DATA_MODEL_ARRAY (gda_data_model_array_new (8));
 	for (i = 0; i < sizeof (fields_desc) / sizeof (fields_desc[0]); i++) {
-		gint defined_size =  (fields_desc[i].type == GDA_VALUE_TYPE_STRING) ? 64 : 
-			(fields_desc[i].type == GDA_VALUE_TYPE_INTEGER) ? sizeof (gint) : 1;
-
-		/* gda_server_recordset_model_set_field_defined_size (recset, i, defined_size); */
 		gda_data_model_set_column_title (GDA_DATA_MODEL (recset), i, _(fields_desc[i].name));
-/*
-		gda_server_recordset_model_set_field_scale (recset, i, 0);
-		gda_server_recordset_model_set_field_gdatype (recset, i, fields_desc[i].type);
-*/
 	}
 
 	cols = gda_data_model_get_n_columns (GDA_DATA_MODEL (table));


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