[gnome-db] New patch. Closes bug #68577



	Here is a patch that adds a new parameter to the executeCommand
	function in the IDL and changes some files in libgda/libgda to
	adopt the new interface along with the proper changes to the
	provider and test for psotgres.

	Bye!

Index: idl/ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/idl/ChangeLog,v
retrieving revision 1.23
diff -u -r1.23 ChangeLog
--- idl/ChangeLog	2002/01/14 23:13:29	1.23
+++ idl/ChangeLog	2002/01/17 01:38:42
@@ -1,3 +1,8 @@
+2002-01-16  Gonzalo Paniagua Javier <gonzalo gnome-db org>
+
+	* GNOME_Database.idl: added enum CommandOption and new parameter to
+	executeCommand().
+
 2002-01-14  Rodrigo Moya <rodrigo gnome-db org>
 
 	* GNOME_Database.idl: added ValueList type
Index: idl/GNOME_Database.idl
===================================================================
RCS file: /cvs/gnome/libgda/idl/GNOME_Database.idl,v
retrieving revision 1.17
diff -u -r1.17 GNOME_Database.idl
--- idl/GNOME_Database.idl	2002/01/14 23:13:29	1.17
+++ idl/GNOME_Database.idl	2002/01/17 01:38:42
@@ -118,6 +118,11 @@
 		 * The Command struct contains information about a
 		 * command to be executed on the server
 		 */
+		enum CommandOption {
+			COMMAND_OPTION_IGNORE_ERRORS,
+			COMMAND_OPTION_STOP_ON_ERRORS
+		};
+		
 		enum CommandType {
 			COMMAND_TYPE_SQL,
 			COMMAND_TYPE_XML,
@@ -168,7 +173,8 @@
 
 			/* command execution */
 			RecordsetList executeCommand (in Command cmd,
-						      in ParameterList params)
+						      in ParameterList params,
+						      in CommandOption option)
 				raises (DriverError);
 
 			/* transactions */
Index: libgda/ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/libgda/ChangeLog,v
retrieving revision 1.79
diff -u -r1.79 ChangeLog
--- libgda/ChangeLog	2002/01/15 20:12:52	1.79
+++ libgda/ChangeLog	2002/01/17 01:38:42
@@ -1,3 +1,11 @@
+2002-01-16  Gonzalo Paniagua Javier <gonzalo gnome-db org>
+
+	* gda-command.h:
+	* gda-connection.[ch]:
+	* gda-server-connection.c:
+	* gda-server-provider.[ch]: added new GdaCommandOption parameter to
+	execute_command.
+
 2002-01-15  Gonzalo Paniagua Javier <gonzalo gnome-db org>
 
 	* gda-value.c: added documentation. Corrected changed parameter value
Index: libgda/gda-command.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-command.h,v
retrieving revision 1.4
diff -u -r1.4 gda-command.h
--- libgda/gda-command.h	2002/01/11 16:37:47	1.4
+++ libgda/gda-command.h	2002/01/17 01:38:42
@@ -29,6 +29,7 @@
 G_BEGIN_DECLS
 
 typedef GNOME_Database_Command GdaCommand;
+
 typedef enum {
 	GDA_COMMAND_TYPE_SQL = GNOME_Database_COMMAND_TYPE_SQL,
 	GDA_COMMAND_TYPE_XML = GNOME_Database_COMMAND_TYPE_XML,
@@ -36,6 +37,13 @@
 	GDA_COMMAND_TYPE_TABLE = GNOME_Database_COMMAND_TYPE_TABLE,
 	GDA_COMMAND_TYPE_INVALID = GNOME_Database_COMMAND_TYPE_INVALID
 } GdaCommandType;
+
+typedef enum {
+	GDA_COMMAND_OPTION_IGNORE_ERRORS = 
+		GNOME_Database_COMMAND_OPTION_IGNORE_ERRORS,
+	GDA_COMMAND_OPTION_STOP_ON_ERRORS = 
+		GNOME_Database_COMMAND_OPTION_STOP_ON_ERRORS
+} GdaCommandOption;
 
 GdaCommand    *gda_command_new (const gchar *text, GdaCommandType type);
 void           gda_command_free (GdaCommand *cmd);
Index: libgda/gda-connection.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-connection.c,v
retrieving revision 1.14
diff -u -r1.14 gda-connection.c
--- libgda/gda-connection.c	2002/01/13 14:22:51	1.14
+++ libgda/gda-connection.c	2002/01/17 01:38:43
@@ -327,7 +327,8 @@
 GList *
 gda_connection_execute_command (GdaConnection *cnc,
 				GdaCommand *cmd,
-				GdaParameterList *params)
+				GdaParameterList *params,
+				GdaCommandOption option)
 {
 	GNOME_Database_RecordsetList *corba_reclist;
 	GNOME_Database_ParameterList *corba_params;
@@ -344,7 +345,7 @@
 	CORBA_exception_init (&ev);
 
 	corba_reclist = GNOME_Database_Connection_executeCommand (
-		cnc->priv->corba_cnc, cmd, corba_params, &ev);
+		cnc->priv->corba_cnc, cmd, corba_params, option, &ev);
 
 	CORBA_free (corba_params);
 
Index: libgda/gda-connection.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-connection.h,v
retrieving revision 1.8
diff -u -r1.8 gda-connection.h
--- libgda/gda-connection.h	2002/01/11 16:37:47	1.8
+++ libgda/gda-connection.h	2002/01/17 01:38:43
@@ -75,7 +75,8 @@
 
 GList         *gda_connection_execute_command (GdaConnection *cnc,
 					       GdaCommand *cmd,
-					       GdaParameterList *params);
+					       GdaParameterList *params,
+					       GdaCommandOption option);
 
 gboolean       gda_connection_begin_transaction (GdaConnection *cnc, const gchar *id);
 gboolean       gda_connection_commit_transaction (GdaConnection *cnc, const gchar *id);
Index: libgda/gda-server-connection.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-server-connection.c,v
retrieving revision 1.19
diff -u -r1.19 gda-server-connection.c
--- libgda/gda-server-connection.c	2002/01/15 16:23:38	1.19
+++ libgda/gda-server-connection.c	2002/01/17 01:38:43
@@ -143,6 +143,7 @@
 impl_Connection_executeCommand (PortableServer_Servant servant,
 				const GNOME_Database_Command *cmd,
 				const GNOME_Database_ParameterList *params,
+				GNOME_Database_CommandOption option,
 				CORBA_Environment *ev)
 {
 	GList *recset_list;
@@ -154,8 +155,11 @@
 
 	bonobo_return_val_if_fail (GDA_IS_SERVER_CONNECTION (cnc), NULL, ev);
 
-	recset_list = gda_server_provider_execute_command (cnc->priv->provider, cnc,
-							   (GdaCommand *) cmd, param_list);
+	recset_list = gda_server_provider_execute_command (cnc->priv->provider,
+						cnc,
+						(GdaCommand *) cmd,
+						param_list, 
+						(GdaCommandOption) option);
 	if (!recset_list) {
 		gda_error_list_to_exception (cnc->priv->errors, ev);
 		gda_server_connection_free_error_list (cnc);
Index: libgda/gda-server-provider.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-server-provider.c,v
retrieving revision 1.12
diff -u -r1.12 gda-server-provider.c
--- libgda/gda-server-provider.c	2002/01/14 15:00:53	1.12
+++ libgda/gda-server-provider.c	2002/01/17 01:38:43
@@ -199,14 +199,16 @@
 gda_server_provider_execute_command (GdaServerProvider *provider,
 				     GdaServerConnection *cnc,
 				     GdaCommand *cmd,
-				     GdaParameterList *params)
+				     GdaParameterList *params,
+				     GdaCommandOption option)
 {
 	g_return_val_if_fail (GDA_IS_SERVER_PROVIDER (provider), NULL);
 	g_return_val_if_fail (GDA_IS_SERVER_CONNECTION (cnc), NULL);
 	g_return_val_if_fail (cmd != NULL, NULL);
 	g_return_val_if_fail (CLASS (provider)->execute_command != NULL, NULL);
 
-	return CLASS (provider)->execute_command (provider, cnc, cmd, params);
+	return CLASS (provider)->execute_command (provider, cnc, cmd, params,
+						  option);
 }
 
 /**
Index: libgda/gda-server-provider.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-server-provider.h,v
retrieving revision 1.8
diff -u -r1.8 gda-server-provider.h
--- libgda/gda-server-provider.h	2002/01/14 15:00:53	1.8
+++ libgda/gda-server-provider.h	2002/01/17 01:38:43
@@ -64,7 +64,8 @@
 	GList * (* execute_command) (GdaServerProvider *provider,
 				     GdaServerConnection *cnc,
 				     GdaCommand *cmd,
-				     GdaParameterList *params);
+				     GdaParameterList *params,
+				     GdaCommandOption option);
 
 	gboolean (* begin_transaction) (GdaServerProvider *provider,
 					GdaServerConnection *cnc,
@@ -98,7 +99,8 @@
 GList   *gda_server_provider_execute_command (GdaServerProvider *provider,
 					      GdaServerConnection *cnc,
 					      GdaCommand *cmd,
-					      GdaParameterList *params);
+					      GdaParameterList *params,
+					      GdaCommandOption option);
 
 gboolean gda_server_provider_begin_transaction (GdaServerProvider *provider,
 						GdaServerConnection *cnc,
Index: providers/postgres/ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/providers/postgres/ChangeLog,v
retrieving revision 1.12
diff -u -r1.12 ChangeLog
--- providers/postgres/ChangeLog	2002/01/15 01:53:25	1.12
+++ providers/postgres/ChangeLog	2002/01/17 01:38:44
@@ -1,3 +1,8 @@
+2002-01-16  Gonzalo Paniagua Javier <gonzalo gnome-db org>
+
+	* gda-postgres-provider.c: added support for GdaCommandOption in
+	execute_command.
+
 2002-01-15  Gonzalo Paniagua Javier <gonzalo gnome-db org>
 
 	* gda-postgres-provider.c:
Index: providers/postgres/gda-postgres-provider.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/postgres/gda-postgres-provider.c,v
retrieving revision 1.7
diff -u -r1.7 gda-postgres-provider.c
--- providers/postgres/gda-postgres-provider.c	2002/01/15 01:53:25	1.7
+++ providers/postgres/gda-postgres-provider.c	2002/01/17 01:38:45
@@ -42,7 +42,8 @@
 static GList *gda_postgres_provider_execute_command (GdaServerProvider *provider,
 						  GdaServerConnection *cnc,
 						  GdaCommand *cmd,
-						  GdaParameterList *params);
+						  GdaParameterList *params,
+						  GdaCommandOption option);
 
 static gboolean gda_postgres_provider_begin_transaction (GdaServerProvider *provider,
 						     GdaServerConnection *cnc,
@@ -305,7 +306,8 @@
 }
 
 static GList *
-process_sql_commands (GList *reclist, GdaServerConnection *cnc, const gchar *sql)
+process_sql_commands (GList *reclist, GdaServerConnection *cnc, const gchar *sql, 
+		GdaCommandOption option)
 {
 	GdaPostgresConnectionPrivate *priv_data;
 	PGconn *pconn;
@@ -339,7 +341,8 @@
 			} 
 			
 			status = PQresultStatus(pg_res);
-			if (status == PGRES_TUPLES_OK ||
+			if (option == GDA_COMMAND_OPTION_IGNORE_ERRORS	||
+			    status == PGRES_TUPLES_OK 			||
 			    status == PGRES_COMMAND_OK) {
 				recset = gda_postgres_recordset_new (cnc, pg_res);
 				if (GDA_IS_SERVER_RECORDSET (recset))
@@ -367,7 +370,8 @@
 gda_postgres_provider_execute_command (GdaServerProvider *provider,
 				       GdaServerConnection *cnc,
 				       GdaCommand *cmd,
-				       GdaParameterList *params)
+				       GdaParameterList *params,
+				       GdaCommandOption option)
 {
 	GList *reclist = NULL;
 	gchar *str;
@@ -379,11 +383,11 @@
 
 	switch (gda_command_get_command_type (cmd)) {
 	case GDA_COMMAND_TYPE_SQL :
-		reclist = process_sql_commands (reclist, cnc, gda_command_get_text (cmd));
+		reclist = process_sql_commands (reclist, cnc, gda_command_get_text (cmd), option);
 		break;
 	case GDA_COMMAND_TYPE_TABLE :
 		str = g_strdup_printf ("SELECT * FROM %s", gda_command_get_text (cmd));
-		reclist = process_sql_commands (reclist, cnc, str);
+		reclist = process_sql_commands (reclist, cnc, str, option);
 		g_free (str);
 		break;
 	default:
@@ -489,7 +493,8 @@
 	g_return_val_if_fail (GDA_IS_SERVER_CONNECTION (cnc), NULL);
 
 	reclist = process_sql_commands (NULL, cnc, 
-			"SELECT proname FROM pg_proc ORDER BY proname");
+			"SELECT proname FROM pg_proc ORDER BY proname",
+			GDA_COMMAND_OPTION_STOP_ON_ERRORS);
 
 	if (!reclist)
 		return NULL;
@@ -510,7 +515,8 @@
 
 	reclist = process_sql_commands (NULL, cnc, 
 			"SELECT relname FROM pg_class WHERE relkind = 'r' AND "
-			"relname !~ '^pg_' ORDER BY relname");
+			"relname !~ '^pg_' ORDER BY relname",
+			GDA_COMMAND_OPTION_STOP_ON_ERRORS);
 
 	if (!reclist)
 		return NULL;
@@ -577,7 +583,8 @@
 
 	reclist = process_sql_commands (NULL, cnc, 
 			"SELECT relname FROM pg_class WHERE relkind = 'v' AND "
-			"relname !~ '^pg_' ORDER BY relname");
+			"relname !~ '^pg_' ORDER BY relname",
+			GDA_COMMAND_OPTION_STOP_ON_ERRORS);
 
 	if (!reclist)
 		return NULL;
Index: testing/ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/testing/ChangeLog,v
retrieving revision 1.26
diff -u -r1.26 ChangeLog
--- testing/ChangeLog	2002/01/15 20:23:54	1.26
+++ testing/ChangeLog	2002/01/17 01:38:45
@@ -1,3 +1,7 @@
+2002-01-16  Gonzalo Paniagua Javier <gonzalo gnome-db org>
+
+	* postgres-test.c: added support of new parameter in execute_command.
+	
 2002-01-15  Gonzalo Paniagua Javier <gonzalo gnome-db org>
 
 	* models.h: added declaration of display_recordset_data().
Index: testing/postgres-test.c
===================================================================
RCS file: /cvs/gnome/libgda/testing/postgres-test.c,v
retrieving revision 1.3
diff -u -r1.3 postgres-test.c
--- testing/postgres-test.c	2002/01/14 23:40:15	1.3
+++ testing/postgres-test.c	2002/01/17 01:38:46
@@ -22,6 +22,9 @@
 
 #include "postgres-test.h"
 
+#define IGNORE_ERR	GDA_COMMAND_OPTION_IGNORE_ERRORS
+#define STOP_ON_ERR	GDA_COMMAND_OPTION_STOP_ON_ERRORS
+
 static gboolean
 create_table (GdaConnection *cnc)
 {
@@ -48,7 +51,8 @@
 				")",
 				GDA_COMMAND_TYPE_SQL);
 
-	list = gda_connection_execute_command (cnc, create_command, NULL);
+	list = gda_connection_execute_command (cnc, create_command, 
+						NULL, STOP_ON_ERR);
 	retval = list == NULL ? FALSE : TRUE;
 	g_list_foreach (list, (GFunc) g_object_unref, NULL);
 	g_list_free (list);
@@ -67,7 +71,8 @@
 	drop_command = gda_command_new ( "drop table gda_postgres_test",
 					GDA_COMMAND_TYPE_SQL);
 
-	list = gda_connection_execute_command (cnc, drop_command, NULL);
+	list = gda_connection_execute_command (cnc, drop_command,
+						NULL, IGNORE_ERR);
 	retval = list == NULL ? FALSE : TRUE;
 	g_list_foreach (list, (GFunc) g_object_unref, NULL);
 	g_list_free (list);
@@ -115,7 +120,8 @@
 				")",
 				GDA_COMMAND_TYPE_SQL);
 
-	list = gda_connection_execute_command (cnc, insert_command, NULL);
+	list = gda_connection_execute_command (cnc, insert_command,
+						NULL, STOP_ON_ERR);
 	gda_command_free (insert_command);
 
 	return list;
@@ -130,7 +136,8 @@
 	select_command = gda_command_new ( "select * from gda_postgres_test",
 					GDA_COMMAND_TYPE_SQL);
 
-	list = gda_connection_execute_command (cnc, select_command, NULL);
+	list = gda_connection_execute_command (cnc, select_command,
+						NULL, STOP_ON_ERR);
 	gda_command_free (select_command);
 
 	return list;


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