[gnome-db] sybase provider patch



Hello all!

Please apply this patch for the Sybase provider.

it does the following:
- changes the provider to use the standard GdaError method of reporting
errors to libgda
- add support for more result types ( CS_MSG_RESULT, CS_STATUS_RESULT )
- adds support for the print transact-SQL statement
- adds support for index schema
- adds support for triggers schema
- adds support for begin/commit/rollback of transactions
- adds support for getting the current database

I've done all my testing against Sybase ASE 12.5 ( I can't get 
11.9.2 to install on Redhat 8.0 ) 

Mike
Index: providers/sybase/gda-sybase-provider.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-provider.c,v
retrieving revision 1.13
diff -u -u -r1.13 gda-sybase-provider.c
--- providers/sybase/gda-sybase-provider.c	16 Dec 2002 22:29:41 -0000	1.13
+++ providers/sybase/gda-sybase-provider.c	30 Dec 2002 02:14:11 -0000
@@ -41,12 +41,12 @@
 static void gda_sybase_provider_finalize (GObject *object);
 
 static gboolean gda_sybase_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_sybase_provider_close_connection (GdaServerProvider *provider,
-						      GdaConnection *cnc);
+																																																						GdaConnection *cnc);
 
 
 static gboolean gda_sybase_provider_begin_transaction (GdaServerProvider *provider,
@@ -75,7 +75,7 @@
                                                      GdaConnectionSchema schema,
                                                      GdaParameterList *params);
 static const gchar *gda_sybase_provider_get_server_version (GdaServerProvider *provider,
-                                        GdaConnection *cnc);
+																																																												GdaConnection *cnc);
 static const gchar *gda_sybase_provider_get_version (GdaServerProvider *provider);
 static gboolean gda_sybase_provider_rollback_transaction (GdaServerProvider *provider,
                                                           GdaConnection *cnc,
@@ -90,7 +90,6 @@
                                                const gchar *sql);
 static gboolean gda_sybase_execute_cmd (GdaConnection *cnc, const gchar *sql);
 
-
 static GObjectClass *parent_class = NULL;
 
 /*
@@ -127,7 +126,7 @@
 
 static void
 gda_sybase_provider_init (GdaSybaseProvider *myprv, 
-			  GdaSybaseProviderClass *klass)
+																										GdaSybaseProviderClass *klass)
 {
 }
 
@@ -159,8 +158,8 @@
 			(GInstanceInitFunc) gda_sybase_provider_init
 		};
 		type = g_type_register_static (PARENT_TYPE,
-					       "GdaSybaseProvider",
-					       &info, 0);
+																																	"GdaSybaseProvider",
+																																	&info, 0);
 	}
 
 	return type;
@@ -173,6 +172,9 @@
 
 	provider = g_object_new (gda_sybase_provider_get_type (), NULL);
 
+
+	g_print("loading sybase provider!\n");
+
 	return GDA_SERVER_PROVIDER (provider);
 }
 
@@ -181,6 +183,16 @@
 {
 	GdaSybaseConnectionData *sconn = g_new0 (GdaSybaseConnectionData, 1);
 
+	if ( !sconn) 
+		return NULL;
+
+	sconn->server_version = NULL;
+	sconn->gda_cnc = NULL;
+	sconn->context = NULL;
+	sconn->cmd = NULL;
+	sconn->connection = NULL;
+	sconn->mempool = NULL;
+
 	return sconn;
 }
 
@@ -196,7 +208,7 @@
 			// we do not check if the handle is the same,
 			// because it must be identical (connection_open)
 			g_object_set_data (G_OBJECT (sconn->gda_cnc), 
-			                   OBJECT_DATA_SYBASE_HANDLE, NULL);
+																						OBJECT_DATA_SYBASE_HANDLE, NULL);
 			// is just a reference copy
 			sconn->gda_cnc = NULL;
 		}
@@ -229,10 +241,10 @@
 /* open_connection handler for the GdaSybaseProvider class */
 static gboolean
 gda_sybase_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)
 {
 		
 	GdaSybaseConnectionData *sconn = NULL;
@@ -248,7 +260,7 @@
 		
 	/* the logic to connect to the database */
 
-	sybase_debug_msg(_("about to open connection"));
+	//sybase_debug_msg(_("about to open connection"));
 	
 	if (username)
 		t_user = g_strdup(username);
@@ -268,98 +280,100 @@
 
 	t_locale = gda_quark_list_find (params, "LOCALE");
 
-	sybase_debug_msg ("username: '%s', password '%s'",
-	                  (t_user != NULL) ? t_user : "(NULL)",
-	                  (t_password != NULL) ? "XXXXXXXX" : "(NULL)");
+	//sybase_debug_msg ("username: '%s', password '%s'",
+	//																	(t_user != NULL) ? t_user : "(NULL)",
+	//																		(t_password != NULL) ? "XXXXXXXX" : "(NULL)");
 	
-	sconn = g_new0 (GdaSybaseConnectionData, 1);
+	//		sconn = g_new0 (GdaSybaseConnectionData, 1);
+	sconn = gda_sybase_connection_data_new();
+
 	if (!sconn) {
 		sybase_debug_msg (_("Out of memory. Allocating connection structure failed."));
 		return FALSE;
 	}
 
 	/* CS_GDA_VERSION is set to the latest CS_VERSION available
-	 * alloc context */
+		* alloc context */
 	sconn->ret = cs_ctx_alloc (CS_GDA_VERSION, &sconn->context);
 	if (sconn->ret != CS_SUCCEED) {
 		g_free (sconn);
 		sconn = NULL;
 		return FALSE;
 	}
-	sybase_debug_msg(_("Context allocated."));
+	//sybase_debug_msg(_("Context allocated."));
 	/* init client-lib */
 	sconn->ret = ct_init (sconn->context, CS_GDA_VERSION);
 	if (sconn->ret != CS_SUCCEED) {
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Client library initialized."));
+	//sybase_debug_msg(_("Client library initialized."));
 
 	/* apply locale before connection */
 	if (t_locale) {
 		sconn->ret = cs_loc_alloc (sconn->context, &locale);
 		/* locale setting should not make connection fail
-		 * 
-		 * avoid nested if clauses because of same condition */
+			* 
+			* avoid nested if clauses because of same condition */
 		if (sconn->ret == CS_SUCCEED) {
 			sconn->ret = cs_locale (sconn->context,
-			                        CS_SET,
-			                        locale,
-			                        CS_LC_ALL,
-			                        (CS_CHAR *) t_locale,
-			                        CS_NULLTERM,
-			                        NULL);
+																											CS_SET,
+																											locale,
+																											CS_LC_ALL,
+																											(CS_CHAR *) t_locale,
+																											CS_NULLTERM,
+																											NULL);
 		}
 		if (sconn->ret == CS_SUCCEED) {
 			sconn->ret = cs_config (sconn->context,
-			                        CS_SET,
-			                        CS_LOC_PROP,
-			                        locale,
-			                        CS_UNUSED,
-			                        NULL);
+																											CS_SET,
+																											CS_LOC_PROP,
+																											locale,
+																											CS_UNUSED,
+																											NULL);
 		}
 		if (sconn->ret == CS_SUCCEED) {
 			sybase_debug_msg (_("Locale set to '%s'."), t_locale);
 		}
 		if (locale) {
 			sconn->ret = cs_loc_drop (sconn->context,
-			                          locale);
+																													locale);
 			locale = NULL;
 		}
 	}
 
 	/* Initialize callback handlers */
 	/*   cs */
-	sconn->ret = cs_config (sconn->context, CS_SET, CS_MESSAGE_CB,
-	                        (CS_VOID *) gda_sybase_csmsg_callback,
-	                         CS_UNUSED, NULL);
-	if (sconn->ret != CS_SUCCEED) {
-		sybase_debug_msg(_("Could not initialize cslib callback"));
-		gda_sybase_connection_data_free (sconn);
-		return FALSE;
-	}
-	sybase_debug_msg(_("CS-lib callback initialized."));
+/*  	sconn->ret = cs_config (sconn->context, CS_SET, CS_MESSAGE_CB, */
+/*  																									(CS_VOID *) gda_sybase_csmsg_callback, */
+/*  																									CS_UNUSED, NULL); */
+/*  	if (sconn->ret != CS_SUCCEED) { */
+/*  		sybase_debug_msg(_("Could not initialize cslib callback")); */
+/*  		gda_sybase_connection_data_free (sconn); */
+/*  		return FALSE; */
+/*  	} */
+/*  	sybase_debug_msg(_("CS-lib callback initialized.")); */
 	/*   ct-cli */
-	sconn->ret = ct_callback (sconn->context, NULL, CS_SET,
-	                          CS_CLIENTMSG_CB,
-	                          (CS_VOID *) gda_sybase_clientmsg_callback);
-	if (sconn->ret != CS_SUCCEED) {
-		sybase_debug_msg(_("Could not initialize ct-client callback"));
-		gda_sybase_connection_data_free (sconn);
-		return FALSE;
-	}
-	sybase_debug_msg(_("CT-Client callback initialized."));
+/*  	sconn->ret = ct_callback (sconn->context, NULL, CS_SET, */
+/*  																											CS_CLIENTMSG_CB, */
+/*  																											(CS_VOID *) gda_sybase_clientmsg_callback); */
+/*  	if (sconn->ret != CS_SUCCEED) { */
+/*  		sybase_debug_msg(_("Could not initialize ct-client callback")); */
+/*  		gda_sybase_connection_data_free (sconn); */
+/*  		return FALSE; */
+/*  	} */
+/*  	sybase_debug_msg(_("CT-Client callback initialized.")); */
 	
 	/*   ct-srv */
-	sconn->ret = ct_callback (sconn->context, NULL, CS_SET, 
-	                          CS_SERVERMSG_CB,
-	                          (CS_VOID *) gda_sybase_servermsg_callback);
-	if (sconn->ret != CS_SUCCEED) {
-		sybase_debug_msg(_("Could not initialize ct-server callback"));
-		gda_sybase_connection_data_free (sconn);
-		return FALSE;
-	}
-	sybase_debug_msg(_("CT-Server callback initialized."));
+/*  	sconn->ret = ct_callback (sconn->context, NULL, CS_SET,  */
+/*  																											CS_SERVERMSG_CB, */
+/*  																											(CS_VOID *) gda_sybase_servermsg_callback); */
+/*  	if (sconn->ret != CS_SUCCEED) { */
+/*  		sybase_debug_msg(_("Could not initialize ct-server callback")); */
+/*  		gda_sybase_connection_data_free (sconn); */
+/*  		return FALSE; */
+/*  	} */
+/*  	sybase_debug_msg(_("CT-Server callback initialized.")); */
 
 	/* allocate the connection structure */
 	sconn->ret = ct_con_alloc(sconn->context, &sconn->connection);
@@ -367,114 +381,127 @@
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Connection allocated."));
+	//sybase_debug_msg(_("Connection allocated."));
 	/* init inline error handling for cs-lib */
-/*	sconn->ret = cs_diag (sconn->context, 
-	                      CS_INIT, 
-	                      CS_UNUSED, 
-	                      CS_UNUSED,
-	                      NULL);		
-	if (sconn->ret != CS_SUCCEED) {
-		gda_sybase_connection_data_free (sconn);
-		return FALSE;
-	}
-	sybase_debug_msg(_("Error handling for cs-lib initialized.")); */
+	sconn->ret = cs_diag (sconn->context, 
+				CS_INIT, 
+				CS_UNUSED, 
+				CS_UNUSED,
+				NULL);		
+				if (sconn->ret != CS_SUCCEED) {
+				gda_sybase_connection_data_free (sconn);
+				return FALSE;
+				}
+				//sybase_debug_msg(_("Error handling for cs-lib initialized.")); 
 	/* init inline error handling for ct-lib */
-/*	sconn->ret = ct_diag (sconn->connection, 
-	                      CS_INIT, 
-	                      CS_UNUSED, 
-	                      CS_UNUSED,
-	                      NULL);
-	if (sconn->ret != CS_SUCCEED) {
-		gda_sybase_connection_data_free (sconn);
-		return FALSE;
-	}
-	sybase_debug_msg(_("Error handling for ct-lib initialized.")); */
+		sconn->ret = ct_diag (sconn->connection, 
+				CS_INIT, 
+				CS_UNUSED, 
+				CS_UNUSED,
+				NULL);
+				if (sconn->ret != CS_SUCCEED) {
+				gda_sybase_connection_data_free (sconn);
+				return FALSE;
+				}
+				//sybase_debug_msg(_("Error handling for ct-lib initialized.")); 
 
 	/* set object data for error handling routines */
 	sconn->gda_cnc = cnc; /* circular reference for freeing */
+
 	g_object_set_data (G_OBJECT (cnc), OBJECT_DATA_SYBASE_HANDLE, sconn);
+
 	/* now first check possible, do so */
 	
 	/* set appname */
 	sconn->ret = ct_con_props (sconn->connection, 
-	                           CS_SET, 
-	                           CS_APPNAME, 
-	                           (CS_CHAR *) "gda-sybase provider", 
-	                           CS_NULLTERM, 
-	                           NULL);
+																												CS_SET, 
+																												CS_APPNAME, 
+																												(CS_CHAR *) "gda-sybase provider", 
+																												CS_NULLTERM, 
+																												NULL);
 	if (sconn->ret != CS_SUCCEED) {
+		sybase_check_messages(cnc);
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Appname set."));
+	//sybase_debug_msg(_("Appname set."));
 
 	/* set username */
 	sconn->ret = ct_con_props (sconn->connection, 
-	                           CS_SET, 
-	                           CS_USERNAME, 
-	                           (CS_CHAR *) t_user,
-	                           CS_NULLTERM, 
-	                           NULL);
+																												CS_SET, 
+																												CS_USERNAME, 
+																												(CS_CHAR *) t_user,
+																												CS_NULLTERM, 
+																												NULL);
 	if (sconn->ret != CS_SUCCEED) {
+		sybase_check_messages(cnc);
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Username set."));
+	//sybase_debug_msg(_("Username set."));
 
 	/* assume null-length passwords as passwordless logins */
 	if ((t_password != NULL) && (strlen(t_password) > 0)) {
 		sconn->ret = ct_con_props (sconn->connection, 
-		                           CS_SET, 
-		                           CS_PASSWORD, 
-		                           (CS_CHAR *) t_password,
-		                           CS_NULLTERM, 
-		                           NULL);
+																													CS_SET, 
+																													CS_PASSWORD, 
+																													(CS_CHAR *) t_password,
+																													CS_NULLTERM, 
+																													NULL);
 		if (sconn->ret != CS_SUCCEED) {
+			sybase_check_messages(cnc);
 			gda_sybase_connection_data_free (sconn);
 			return FALSE;
 		}
-		sybase_debug_msg(_("Password set."));
+		//sybase_debug_msg(_("Password set."));
 	} else {
 		sconn->ret = ct_con_props (sconn->connection, 
-		                           CS_SET, 
-		                           CS_PASSWORD, 
-		                           (CS_CHAR *) "",
-		                           CS_NULLTERM, 
-		                           NULL);
+																													CS_SET, 
+																													CS_PASSWORD, 
+																													(CS_CHAR *) "",
+																													CS_NULLTERM, 
+																													NULL);
 		if (sconn->ret != CS_SUCCEED) {
+			sybase_check_messages(cnc);
 			gda_sybase_connection_data_free (sconn);
 			return FALSE;
 		}
-		sybase_debug_msg(_("Empty password set."));
+		//sybase_debug_msg(_("Empty password set."));
 	}
 	sconn->ret = ct_connect (sconn->connection, 
-	                         (t_host) ? ((CS_CHAR *) t_host)
-	                                  : ((CS_CHAR *) NULL), 
-	                         (t_host) ? strlen(t_host) : 0);
+																										(t_host) ? ((CS_CHAR *) t_host)
+																										: ((CS_CHAR *) NULL), 
+																										(t_host) ? strlen(t_host) : 0);
 	if (sconn->ret != CS_SUCCEED) {
+		sybase_check_messages(cnc);
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Connected."));
+
+	//sybase_debug_msg(_("Connected."));
 
 	if (t_db) 
 		gda_sybase_provider_change_database (provider, cnc, t_db);
 	
 	/* get the hostname from SQL server as a test */
 	sconn->ret = ct_con_props (sconn->connection, 
-	                           CS_GET, 
-	                           CS_SERVERNAME, 
-	                           &buf,
-	                           CS_MAX_CHAR, 
-	                           NULL);
+																												CS_GET, 
+																												CS_SERVERNAME, 
+																												&buf,
+																												CS_MAX_CHAR, 
+																												NULL);
 	if (sconn->ret != CS_SUCCEED) {
+		sybase_check_messages(cnc);
 		gda_sybase_connection_data_free (sconn);
-		
 		return FALSE;
 	}
 
-	sybase_debug_msg (_("Finally connected."));
+	//sybase_debug_msg (_("Finally connected."));
+
+	// get rid of the initial change database context to... messages
+	sybase_check_messages(cnc);
+
+	//sybase_debug_msg (_("done emptying junk messages."));
 
 	return TRUE;
 }
@@ -482,7 +509,7 @@
 /* close_connection handler for the GdaSybaseProvider class */
 static gboolean
 gda_sybase_provider_close_connection (GdaServerProvider *provider, 
-				      GdaConnection *cnc)
+																																						GdaConnection *cnc)
 {
 	GdaSybaseConnectionData *sconn;
 	g_return_val_if_fail (GDA_IS_SYBASE_PROVIDER (provider), FALSE);
@@ -505,7 +532,7 @@
                                       GdaConnection *cnc,
                                       GdaTransaction *xaction)
 {
-	return FALSE;
+	return ( gda_sybase_execute_cmd(cnc,"begin transaction") );
 }
 
 static gboolean
@@ -523,7 +550,7 @@
 	sql_cmd = g_strdup_printf("USE %s", name);
 	ret = gda_sybase_execute_cmd(cnc, sql_cmd);
 	g_free(sql_cmd);
-	
+
 	return ret;
 }
 
@@ -532,7 +559,7 @@
                                         GdaConnection *cnc,
                                         GdaTransaction *xaction)
 {
-	return FALSE;
+	return ( gda_sybase_execute_cmd(cnc,"commit transaction") );		
 }
 
 static gboolean 
@@ -567,27 +594,27 @@
 	g_return_val_if_fail (cmd != NULL, NULL);
 
 	switch (gda_command_get_command_type (cmd)) {
-		case GDA_COMMAND_TYPE_SQL:
-			reclist = gda_sybase_provider_process_sql_commands (reclist, cnc, gda_command_get_text (cmd));
-			break;
-		case GDA_COMMAND_TYPE_TABLE:
-			query = g_strdup_printf ("SELECT * FROM %s", gda_command_get_text (cmd));
-			reclist = gda_sybase_provider_process_sql_commands (reclist, cnc, query);
-			if (reclist && GDA_IS_DATA_MODEL (reclist->data)) {
-				gda_data_model_set_command_text (GDA_DATA_MODEL (reclist->data),
-				                                 gda_command_get_text (cmd));
-				gda_data_model_set_command_type (GDA_DATA_MODEL (reclist->data),
-				                                 GDA_COMMAND_TYPE_TABLE);
-			}
-			g_free(query);
-			query = NULL;
-			break;
-		case GDA_COMMAND_TYPE_XML:
-		case GDA_COMMAND_TYPE_PROCEDURE:
-		case GDA_COMMAND_TYPE_SCHEMA:
-		case GDA_COMMAND_TYPE_INVALID:
-			return reclist;
-			break;
+	case GDA_COMMAND_TYPE_SQL:
+		reclist = gda_sybase_provider_process_sql_commands (reclist, cnc, gda_command_get_text (cmd));
+		break;
+	case GDA_COMMAND_TYPE_TABLE:
+		query = g_strdup_printf ("SELECT * FROM %s", gda_command_get_text (cmd));
+		reclist = gda_sybase_provider_process_sql_commands (reclist, cnc, query);
+		if (reclist && GDA_IS_DATA_MODEL (reclist->data)) {
+			gda_data_model_set_command_text (GDA_DATA_MODEL (reclist->data),
+																																				gda_command_get_text (cmd));
+			gda_data_model_set_command_type (GDA_DATA_MODEL (reclist->data),
+																																				GDA_COMMAND_TYPE_TABLE);
+		}
+		g_free(query);
+		query = NULL;
+		break;
+	case GDA_COMMAND_TYPE_XML:
+	case GDA_COMMAND_TYPE_PROCEDURE:
+	case GDA_COMMAND_TYPE_SCHEMA:
+	case GDA_COMMAND_TYPE_INVALID:
+		return reclist;
+		break;
 	}
 
 	return reclist;
@@ -601,7 +628,11 @@
 	GdaSybaseConnectionData *scnc;
 	GdaError                *error;
 	gchar                   **arr;
-	
+	GdaSybaseRecordset      *srecset = NULL;	
+	CS_RETCODE              ret;
+	CS_INT                  msgcnt = 0;
+
+
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 	scnc = g_object_get_data (G_OBJECT (cnc), OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (scnc != NULL, NULL);
@@ -623,104 +654,179 @@
 			scnc->ret = ct_cmd_alloc (scnc->connection, &scnc->cmd);
 			if (scnc->ret != CS_SUCCEED) {
 				sybase_debug_msg(_("Failed allocating a command structure in %s()"),
-				                 __FUNCTION__);
+																					__FUNCTION__);
+				sybase_check_messages(cnc);
 				return NULL;
 			}
 
-
 			// execute _single_ sql query (one stmt)
-			scnc->ret = ct_command (scnc->cmd, CS_LANG_CMD,
-			                        arr[n], CS_NULLTERM, CS_UNUSED);
+			scnc->ret = ct_command (scnc->cmd, 
+																											CS_LANG_CMD,
+																											arr[n], 
+																											CS_NULLTERM, 
+																											CS_UNUSED);
 			if (scnc->ret != CS_SUCCEED) {
 				error = gda_sybase_make_error (scnc,
-					_("Could not prepare command structure."));
+																																			_("Could not prepare command structure."));
 				gda_connection_add_error (cnc, error);
 				ct_cmd_drop (scnc->cmd);
 				scnc->cmd = NULL;
+				sybase_check_messages(cnc);
 				return reclist;
 			}
 			scnc->ret = ct_send(scnc->cmd);
 			if (scnc->ret != CS_SUCCEED) {
 				error = gda_sybase_make_error (scnc,
-					_("Sending sql-command failed."));
+																																			_("Sending sql-command failed."));
 				gda_connection_add_error (cnc, error);
 				ct_cmd_drop (scnc->cmd);
 				scnc->cmd = NULL;
+				sybase_check_messages(cnc);
 				return reclist;
 			}
 
-			// now comes the ugly part: 
-			//   dealing with multiple resultsets
-			
 			// part 1: process results in while-loop
-			while ((scnc->rret = ct_results (scnc->cmd,
-			                                 &scnc->res_type
-                                                        )
-			       ) == CS_SUCCEED) {
-				// gda_sybase_recordset_new ()
-				// just returns a datamodel, 
-				// if we have a query with results...
-				recset = gda_sybase_recordset_new (cnc, TRUE);
-				
-				if (GDA_IS_SYBASE_RECORDSET (recset)) {
-					gda_data_model_set_command_text (recset, arr[n]);
-					gda_data_model_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
-					reclist = g_list_append (reclist, recset);
-	                        } else {
-				}
-
-				// this is done within gda_sybase_recordset_new()
-/*				switch (scnc->res_type) {
-					case CS_ROW_RESULT:
-						break;
-					case CS_CURSOR_RESULT:
-						break;
-					case CS_PARAM_RESULT:
-						break;
-					case CS_STATUS_RESULT:
-						break;
-					case CS_COMPUTE_RESULT:
-						break;
-					case CS_MSG_RESULT:
-						break;
-					case CS_DESCRIBE_RESULT:
-						break;
-					case CS_ROWFMT_RESULT:
-						break;
-					case CS_COMPUTEFMT_RESULT:
-						break;
-					case CS_CMD_DONE:
-						break;
-					case CS_CMD_SUCCEED:
-						break;
-					case CS_CMD_FAIL:
-						break;
-				}
-*/
-			}
-
-			// part 2: have a look at the final returncode
-			switch (scnc->rret) {
-				case CS_END_RESULTS:
+			while ((scnc->rret = 
+											ct_results (scnc->cmd,&scnc->res_type)) == CS_SUCCEED){
+				switch (scnc->res_type) {
+				case CS_ROW_RESULT:
+					// the query returned a result set!
+					//sybase_debug_msg (_("CS_ROW_RESULT!"));
+
+					srecset = gda_sybase_process_row_result (cnc, 
+																																														scnc,
+																																														TRUE);
+					recset = GDA_DATA_MODEL(srecset);
+					if (GDA_IS_SYBASE_RECORDSET (recset)) {
+						gda_data_model_set_command_text (recset, arr[n]);
+						gda_data_model_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
+						reclist = g_list_append (reclist, recset);
+					}
+					else
+						sybase_debug_msg (_("GDA_IS_SYBASE_RECORDSET != TRUE"));						
 					break;
-				case CS_CANCELED:
+				case CS_STATUS_RESULT:
+					// when you execute a stored procedure through openclient, this 
+					// part of the result set loop is where you fetch the return status
+					// of the executed stored procedure.  You fetch it like a CS_ROW_RESULT
+					sybase_debug_msg (_("CS_STATUS_RESULT!"));
+
+					srecset = gda_sybase_process_row_result (cnc, 
+																																														scnc,
+																																														TRUE);
+					recset = GDA_DATA_MODEL(srecset);
+					if (GDA_IS_SYBASE_RECORDSET (recset)) {
+						gda_data_model_set_command_text (recset, arr[n]);
+						gda_data_model_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
+						reclist = g_list_append (reclist, recset);
+					}
+					else
+						sybase_debug_msg (_("GDA_IS_SYBASE_RECORDSET != TRUE"));						
+				case CS_COMPUTE_RESULT:
+					// FIXME - figure this out
 					break;
-				case CS_FAIL:
+					// you should not hit any of these.  If you do, cancel the result set.
+ 			case CS_CURSOR_RESULT:
+				case CS_PARAM_RESULT:
+				case CS_DESCRIBE_RESULT:
+				case CS_ROWFMT_RESULT:
+				case CS_COMPUTEFMT_RESULT:
+					sybase_debug_msg (_("Hit unsupported result type"));
+					
+					scnc->ret = ct_cancel (NULL, scnc->cmd,
+																												CS_CANCEL_CURRENT);
 					break;
-			}
+				case CS_CMD_DONE:
+					// the command executed successfully.  
+					//sybase_debug_msg (_("CS_CMD_DONE!"));
+					break;
+				case CS_CMD_SUCCEED:
+					// this case is when you execute a query, but no rows where returned.
+					//sybase_debug_msg (_("CS_CMD_SUCCEED!"));
+					
+					// wierd workaround...  when you use the transact sql statement
+					// 'print' in the console, it does not indicate any results where returned. 
+					// it used to go to CS_MSG_RESULT.  handle it here.
+					
+					// check the number of msgs...
+					// see if there is a message
+					ret = ct_diag (scnc->connection,
+																				CS_STATUS, 
+																				CS_ALLMSG_TYPE, 
+																				CS_UNUSED,
+																				&msgcnt);
+					
+					if ( ret != CS_SUCCEED ) {
+						error = gda_error_new();
+						g_return_val_if_fail (error != NULL, FALSE);
+						gda_error_set_description (error, _("an error occured when calling ct_diag attempting to test if there is a server message for resultset"));
+						gda_error_set_number (error, -1);
+						gda_error_set_source (error, "gda-sybase");
+						gda_error_set_sqlstate (error, _("Not available"));					
+						gda_connection_add_error (cnc, error);		
+						return NULL;
+					}			
+					// if there are no messages, then the command didn't return any results.
+					// create an empty resultset.
+					if ( msgcnt == 0 ) {
+						srecset = g_object_new (GDA_TYPE_SYBASE_RECORDSET, NULL);
+						if ((srecset != NULL) && (srecset->priv != NULL)
+										&& (srecset->priv->columns != NULL) 
+										&& (srecset->priv->rows != NULL)) {
+							srecset->priv->cnc = cnc;
+							srecset->priv->scnc = scnc;
+						}
+					}
+					else
+						srecset = gda_sybase_process_msg_result(cnc,scnc); 
+
+					recset = GDA_DATA_MODEL(srecset);
+					if (GDA_IS_SYBASE_RECORDSET (recset)) {
+						gda_data_model_set_command_text (recset, arr[n]);
+						gda_data_model_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
+						reclist = g_list_append (reclist, recset);
+					}
+					else
+						sybase_debug_msg (_("GDA_IS_SYBASE_RECORDSET != TRUE"));						
+					break;
+				case CS_CMD_FAIL:
+					sybase_debug_msg (_("%s returned %s"),
+																							"ct_results()", "CS_CMD_FAIL");
+					sybase_check_messages(cnc);
+					break;
+				case CS_MSG_RESULT:
+					// when you use the 'print' SQL statement in a stored procedure,
+					// you will hit this case. 
+					//sybase_debug_msg (_("CS_MSG_RESULT!"));
+		
+					srecset = gda_sybase_process_msg_result(cnc,scnc);
+
+					recset = GDA_DATA_MODEL(srecset);
+					if (GDA_IS_SYBASE_RECORDSET (recset)) {
+						gda_data_model_set_command_text (recset, arr[n]);
+						gda_data_model_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
+						reclist = g_list_append (reclist, recset);
+					}
+					else
+						sybase_debug_msg (_("GDA_IS_SYBASE_RECORDSET != TRUE"));						
+					break;
+				default:
+					break;
+				} // switch
+			} // while ct_results()
 
 			scnc->ret = ct_cmd_drop (scnc->cmd);
 			if (scnc->ret != CS_SUCCEED) {
 				sybase_debug_msg(_("Failed dropping command structure."));
-			} else {
+				sybase_check_messages(cnc);
+			} 
+			else {
 				scnc->cmd = NULL;
 			}
-			
-                        n++;
-		}
+				n++;
+		} // while arr[n] != NULL
 		g_strfreev(arr);
 	}
-
 	return reclist;
 }
 
@@ -742,7 +848,7 @@
 	
 	if (scnc->cmd != NULL) {
 		error = gda_sybase_make_error (scnc, _("Command structure already in use. %s failed."),
-		                               __FUNCTION__);
+																																	__FUNCTION__);
 		gda_connection_add_error (cnc, error);
 		return FALSE;
 	}
@@ -751,15 +857,17 @@
 	if (scnc->ret != CS_SUCCEED) {
 		error = gda_sybase_make_error (scnc, _("Could not allocate command structure."));
 		gda_connection_add_error (cnc, error);
+		sybase_check_messages(cnc);
 		return FALSE;
 	}
 
 	scnc->ret = ct_command (scnc->cmd, CS_LANG_CMD, (CS_CHAR *) sql, 
-	                        CS_NULLTERM, CS_UNUSED);
+																									CS_NULLTERM, CS_UNUSED);
 	if (scnc->ret != CS_SUCCEED) {
 		error = gda_sybase_make_error (scnc, _("Could not prepare command structure with %s."), "ct_command()");
 		gda_connection_add_error (cnc, error);
 		ct_cmd_drop (scnc->cmd);
+		sybase_check_messages(cnc);
 		scnc->cmd = NULL;
 		return FALSE;
 	}
@@ -769,6 +877,7 @@
 		error = gda_sybase_make_error (scnc, _("Sending command failed."));
 		gda_connection_add_error (cnc, error);
 		ct_cmd_drop (scnc->cmd);
+		sybase_check_messages(cnc);
 		scnc->cmd = NULL;
 		return FALSE;
 	}
@@ -776,38 +885,40 @@
 	// proceed result codes, ct_cancel unexpected resultsets
 	while ((scnc->ret = ct_results (scnc->cmd, &res_type)) == CS_SUCCEED) {
 		switch (res_type) {
-			case CS_CMD_SUCCEED:
-			case CS_CMD_DONE:
-				break;
-
-			case CS_CMD_FAIL:
-				ret = FALSE;
-				break;
+		case CS_CMD_SUCCEED:
+		case CS_CMD_DONE:
+			break;
 
-			case CS_STATUS_RESULT:
-				scnc->ret = ct_cancel (NULL, scnc->cmd,
-				                       CS_CANCEL_CURRENT);
-				if (scnc->ret != CS_SUCCEED) {
-					error = gda_sybase_make_error (
-						scnc,
-						_("%s: %s failed"), __FUNCTION__, "ct_cancel");
-					gda_connection_add_error (cnc, error);
-					ret = FALSE;
-				}
-				break;
+		case CS_CMD_FAIL:
+			ret = FALSE;
+			break;
 
-			default:
+		case CS_STATUS_RESULT:
+			scnc->ret = ct_cancel (NULL, scnc->cmd,
+																										CS_CANCEL_CURRENT);
+			if (scnc->ret != CS_SUCCEED) {
+				error = gda_sybase_make_error (
+																																			scnc,
+																																			_("%s: %s failed"), __FUNCTION__, "ct_cancel");
+				gda_connection_add_error (cnc, error);
+				sybase_check_messages(cnc);
 				ret = FALSE;
+			}
+			break;
+
+		default:
+			ret = FALSE;
 		}
 		// cancel all result processing on failure
 		if (!ret) {
 			scnc->ret = ct_cancel (NULL, scnc->cmd,
-			                       CS_CANCEL_ALL);
+																										CS_CANCEL_ALL);
 			if (scnc->ret != CS_SUCCEED) {
 				error = gda_sybase_make_error (
-					scnc,
-					_("%s: %s failed"), __FUNCTION__, "ct_cancel");
+																																			scnc,
+																																			_("%s: %s failed"), __FUNCTION__, "ct_cancel");
 				gda_connection_add_error (cnc, error);
+				sybase_check_messages(cnc);
 			}
 		}
 	}
@@ -816,9 +927,10 @@
 		scnc->ret = ct_cmd_drop (scnc->cmd);
 		if (scnc->ret != CS_SUCCEED) {
 			error = gda_sybase_make_error (scnc,
-			            _("%s: %s failed"),
-			            __FUNCTION__, "ct_cmd_drop()");
+																																		_("%s: %s failed"),
+																																		__FUNCTION__, "ct_cmd_drop()");
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 			ret = FALSE;
 		} else {
 			scnc->cmd = NULL;
@@ -837,42 +949,122 @@
                                   GdaConnection *cnc)
 {
 	GdaSybaseConnectionData *sconn = NULL;
-	CS_COMMAND *cmd = NULL;
+	CS_RETCODE ret,ret1,ret2,result_type;
+	CS_CHAR current_db[256];
+	CS_COMMAND     *cmd;
+	CS_DATAFMT column;
+	CS_INT datalen;
+	CS_SMALLINT indicator;
+	CS_INT count;
 
 	g_return_val_if_fail (provider != NULL, NULL);
 	g_return_val_if_fail (cnc != NULL, NULL);
 
-	sconn = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                                       OBJECT_DATA_SYBASE_HANDLE);
+	memset(current_db,'\0',256);
 
+	sconn = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
+																																																								OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (sconn != NULL, NULL);
-	g_return_val_if_fail (sconn-> connection != NULL, NULL);
+	g_return_val_if_fail (sconn->connection != NULL, NULL);
+	g_return_val_if_fail (sconn->context != NULL, NULL);
+
+	ret = ct_cmd_alloc(sconn->connection, &cmd);
 	
-	sconn->ret = ct_cmd_alloc (sconn->connection, &cmd);
-	if (sconn->ret != CS_SUCCEED) {
-		if (sconn->ret == CS_BUSY) {
-			sybase_debug_msg (_("Connection already in use. Could not allocate command structure in %s()."), __FUNCTION__);
-		} else {
-			sybase_debug_msg (_("Could not allocate command structure."));
-		}
+	if ( ret != CS_SUCCEED ) {
+		sybase_debug_msg (_("could not allocate cmd structure to find current database."));
+		return NULL;
+	}
+	
+ ret = ct_command(cmd, 
+																		CS_LANG_CMD,
+																		TDS_QUERY_CURRENT_DATABASE,
+																		CS_NULLTERM, 
+																		CS_UNUSED); 	
+
+	if ( ret != CS_SUCCEED ) {
+		sybase_debug_msg (_("could not execute command to get current database."));
+		sybase_check_messages(cnc);
 		return NULL;
 	}
 
+	ret = ct_send(cmd);
+	
+	if ( ret != CS_SUCCEED ) {
+		sybase_debug_msg (_("could not send command to get current database."));
+		sybase_check_messages(cnc);
+		return NULL;
+	}
+
+	while( (ret2 = ct_results(cmd, &result_type)) == CS_SUCCEED)
+		{
+			switch((int)result_type)
+				{
+				case CS_ROW_RESULT:
+					column.datatype = CS_CHAR_TYPE;
+					column.format = CS_FMT_NULLTERM;
+					column.maxlength = 255;
+					column.count = 1;
+					column.locale = NULL;
+					ret = ct_bind(cmd, 
+																			1, 
+																			&column,
+																			current_db, 
+																			&datalen,
+																			&indicator);
+
+					if ( ret != CS_SUCCEED ) {
+						sybase_debug_msg (_("could not bind variable to get current database."));
+						sybase_check_messages(cnc);
+						return NULL;
+					}
+
+					ret1 = ct_fetch(cmd, 
+																					CS_UNUSED, 
+																					CS_UNUSED,
+																					CS_UNUSED, 
+																					&count);
+
+
+					if ( ret != CS_SUCCEED ) {
+						sybase_debug_msg (_("could not fetch data to find current database."));
+						sybase_check_messages(cnc);
+						return NULL;
+					}
+
+					while(ret1 == CS_SUCCEED)
+						{
+							ret1 = ct_fetch(cmd, 
+																							CS_UNUSED, 
+																							CS_UNUSED,
+																							CS_UNUSED, 
+																							&count);							
+						}
+
+					if ( ret != CS_SUCCEED ) {
+						sybase_debug_msg (_("could not fetch data to find current database."));
+						sybase_check_messages(cnc);
+						return NULL;
+					}
 
+					break;
+				default:
+					break;
+				}
+		}
 	
-//	ret = ct_send(sconn->connection, cmd);
+	ret = ct_cmd_drop(cmd);
 
-	sconn->ret = ct_cmd_drop (cmd);
-	if (sconn->ret != CS_SUCCEED) {
-		sybase_debug_msg (_("Failed dropping command structure in %s()."),
-		                  __FUNCTION__);
+	if ( ret != CS_SUCCEED ) {
+		sybase_debug_msg (_("could not drop cmd structure to find current database."));
+		sybase_check_messages(cnc);
 		return NULL;
 	}
-	cmd = NULL;
-	
-	return NULL;
+
+	return ( g_strdup(current_db) );
 }
 
+
+// FIXME : implement this
 static GdaDataModel *
 gda_sybase_get_fields (GdaConnection *cnc,
                        GdaParameterList *params)
@@ -880,7 +1072,7 @@
 	GdaSybaseConnectionData *scnc = NULL;
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 	scnc = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                      OBJECT_DATA_SYBASE_HANDLE);
+																																																							OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (scnc != NULL, NULL);
 
 	return NULL;
@@ -896,38 +1088,38 @@
 	
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 	scnc = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                      OBJECT_DATA_SYBASE_HANDLE);
+																																																							OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (scnc != NULL, NULL);
 
 	recset = (GdaDataModelArray *) gda_data_model_array_new (4);
 	gda_data_model_set_column_title (GDA_DATA_MODEL (recset),
-	                                 0, _("Type"));
+																																		0, _("Type"));
 	gda_data_model_set_column_title (GDA_DATA_MODEL (recset),
-	                                 1, _("Owner"));
+																																		1, _("Owner"));
 	gda_data_model_set_column_title (GDA_DATA_MODEL (recset),
-	                                 2, _("Comments"));
+																																		2, _("Comments"));
 	gda_data_model_set_column_title (GDA_DATA_MODEL (recset),
-	                                 3, _("GDA type"));
+																																		3, _("GDA type"));
 
 	for (i = 0; i < GDA_SYBASE_TYPE_CNT; i++) {
 		if (gda_sybase_type_list[i].name != NULL) {
 			GList *value_list = NULL;
 
 			value_list = g_list_append (value_list,
-			               gda_value_new_string (gda_sybase_type_list[i].name));
+																															gda_value_new_string (gda_sybase_type_list[i].name));
 			// FIXME: owner
-	                value_list = g_list_append (value_list,
-			               gda_value_new_string (""));
-	                value_list = g_list_append (value_list, 
-			               gda_value_new_string (""));
-	                value_list = g_list_append (value_list,
-			               gda_value_new_type (gda_sybase_type_list[i].gda_type));
-
-	                gda_data_model_append_row (GDA_DATA_MODEL (recset), value_list);
-	                g_list_foreach (value_list, (GFunc) gda_value_free, NULL);
-	                g_list_free (value_list);
+			value_list = g_list_append (value_list,
+																															gda_value_new_string (""));
+			value_list = g_list_append (value_list, 
+																															gda_value_new_string (""));
+			value_list = g_list_append (value_list,
+																															gda_value_new_type (gda_sybase_type_list[i].gda_type));
+
+			gda_data_model_append_row (GDA_DATA_MODEL (recset), value_list);
+			g_list_foreach (value_list, (GFunc) gda_value_free, NULL);
+			g_list_free (value_list);
 		}
-        }
+	}
 	
 	return GDA_DATA_MODEL (recset);
 }
@@ -939,62 +1131,71 @@
                                 GdaParameterList *params)
 {
 	GdaSybaseProvider *syb_prov = (GdaSybaseProvider *) provider;
-	gchar        *query = NULL;
 	GdaDataModel *recset = NULL;
 	
 	g_return_val_if_fail (GDA_IS_SYBASE_PROVIDER (syb_prov), NULL);
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
 	switch (schema) {
-		case GDA_CONNECTION_SCHEMA_DATABASES:
-			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_DATABASES);
-			TDS_FIXMODEL_SCHEMA_DATABASES (recset);
-
-			return recset;
-			break;
-		case GDA_CONNECTION_SCHEMA_FIELDS:
-			return gda_sybase_get_fields (cnc, params);
-			break;
-		case GDA_CONNECTION_SCHEMA_PROCEDURES:
-			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_PROCEDURES);
-			TDS_FIXMODEL_SCHEMA_PROCEDURES (recset)
+	case GDA_CONNECTION_SCHEMA_DATABASES:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_DATABASES);
+		TDS_FIXMODEL_SCHEMA_DATABASES (recset);
+
+		return recset;
+		break;
+	case GDA_CONNECTION_SCHEMA_FIELDS:
+		return gda_sybase_get_fields (cnc, params);
+		break;
+	case GDA_CONNECTION_SCHEMA_PROCEDURES:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_PROCEDURES);
+		TDS_FIXMODEL_SCHEMA_PROCEDURES (recset)
 			
 			return recset;
-			break;
-		case GDA_CONNECTION_SCHEMA_TABLES:
-			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_TABLES);
-			TDS_FIXMODEL_SCHEMA_TABLES (recset)
+		break;
+	case GDA_CONNECTION_SCHEMA_TABLES:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_TABLES);
+		TDS_FIXMODEL_SCHEMA_TABLES (recset)
 			
 			return recset;
-			break;
-		case GDA_CONNECTION_SCHEMA_TYPES:
-//			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_TYPES);
-//			TDS_FIXMODEL_SCHEMA_TYPES (recset)
-			recset = gda_sybase_provider_get_types (cnc, params);
-	
-			return recset;
-			break;
-		case GDA_CONNECTION_SCHEMA_USERS:
-			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_USERS);
-			TDS_FIXMODEL_SCHEMA_USERS (recset)
+		break;
+	case GDA_CONNECTION_SCHEMA_TYPES:
+		recset = gda_sybase_provider_get_types (cnc, params);
+
+		return recset;
+		break;
+	case GDA_CONNECTION_SCHEMA_USERS:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_USERS);
+		TDS_FIXMODEL_SCHEMA_USERS (recset)
 				
 			return recset;
-			break;
-		case GDA_CONNECTION_SCHEMA_VIEWS:
-			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_VIEWS);
-			TDS_FIXMODEL_SCHEMA_VIEWS (recset)
+		break;
+	case GDA_CONNECTION_SCHEMA_VIEWS:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_VIEWS);
+		TDS_FIXMODEL_SCHEMA_VIEWS (recset)
 
 			return recset;
-			break;
+		break;
+	case GDA_CONNECTION_SCHEMA_INDEXES:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_INDEXES);
+		TDS_FIXMODEL_SCHEMA_INDEXES (recset);
+		
+		return recset;
+		break;				
+	case GDA_CONNECTION_SCHEMA_TRIGGERS:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_TRIGGERS);
+		TDS_FIXMODEL_SCHEMA_TRIGGERS (recset);
+		
+		return recset;
+		break;				
 
-		// FIXME: Implement aggregates, indexes, sequences and triggers
-		case GDA_CONNECTION_SCHEMA_AGGREGATES:
-		case GDA_CONNECTION_SCHEMA_INDEXES:
-		case GDA_CONNECTION_SCHEMA_PARENT_TABLES:
-		case GDA_CONNECTION_SCHEMA_SEQUENCES:
-		case GDA_CONNECTION_SCHEMA_TRIGGERS:
-			return NULL;
-			break;
+		// FIXME: Implement aggregates, sequences 
+	case GDA_CONNECTION_SCHEMA_AGGREGATES:
+	case GDA_CONNECTION_SCHEMA_PARENT_TABLES:
+	case GDA_CONNECTION_SCHEMA_SEQUENCES:
+	case GDA_CONNECTION_SCHEMA_LANGUAGES:
+	case	GDA_CONNECTION_SCHEMA_NAMESPACES:
+		return NULL;
+		break;
 	}
 	
 	return NULL;
@@ -1012,7 +1213,7 @@
 	g_return_val_if_fail (sql != NULL, NULL);
 
 	scnc = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                       OBJECT_DATA_SYBASE_HANDLE);
+																																																							OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (scnc != NULL, NULL);
 
 	model_list = gda_sybase_provider_process_sql_commands (NULL, cnc, sql);
@@ -1036,17 +1237,17 @@
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 	
 	scnc = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                       OBJECT_DATA_SYBASE_HANDLE);
+																																																							OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (scnc != NULL, NULL);
 	if (!scnc->server_version) {
 		model = gda_sybase_execute_query (cnc, TDS_QUERY_SERVER_VERSION);
 		if (model) {
 			if ((gda_data_model_get_n_columns (model) == 1)
-			     && (gda_data_model_get_n_rows (model) == 1)) {
+							&& (gda_data_model_get_n_rows (model) == 1)) {
 				GdaValue *value;
 				
 				value = (GdaValue *) gda_data_model_get_value_at (model, 
-				                                                  0, 0);
+																																																						0, 0);
 				scnc->server_version = gda_value_stringify ((GdaValue *) value);
 			}
 			g_object_unref (model);
@@ -1072,7 +1273,7 @@
                                           GdaConnection *cnc,
                                           GdaTransaction *xaction)
 {
-	return FALSE;
+	return ( gda_sybase_execute_cmd(cnc,"rollback transaction") );		
 }
 
 static gboolean 
@@ -1085,23 +1286,23 @@
 	g_return_val_if_fail (GDA_IS_SYBASE_PROVIDER (syb_prov), FALSE);
 
 	switch (feature) {
-		case GDA_CONNECTION_FEATURE_PROCEDURES:
-		case GDA_CONNECTION_FEATURE_USERS:
-		case GDA_CONNECTION_FEATURE_VIEWS:
-		case GDA_CONNECTION_FEATURE_SQL:
-			return TRUE;
-
-	//FIXME: Implement missing 
-		case GDA_CONNECTION_FEATURE_AGGREGATES:
-		case GDA_CONNECTION_FEATURE_INDEXES:
-		case GDA_CONNECTION_FEATURE_INHERITANCE:
-		case GDA_CONNECTION_FEATURE_SEQUENCES:
-		case GDA_CONNECTION_FEATURE_TRANSACTIONS:
-		case GDA_CONNECTION_FEATURE_TRIGGERS:
-		case GDA_CONNECTION_FEATURE_XML_QUERIES:
-			return FALSE;
+	case GDA_CONNECTION_FEATURE_PROCEDURES:
+	case GDA_CONNECTION_FEATURE_USERS:
+	case GDA_CONNECTION_FEATURE_VIEWS:
+	case GDA_CONNECTION_FEATURE_SQL:
+	case GDA_CONNECTION_FEATURE_TRANSACTIONS:
+	case GDA_CONNECTION_FEATURE_INDEXES:
+	case GDA_CONNECTION_FEATURE_TRIGGERS:
+		return TRUE;
+
+		//FIXME: Implement missing 
+	case GDA_CONNECTION_FEATURE_AGGREGATES:
+	case GDA_CONNECTION_FEATURE_INHERITANCE:
+	case GDA_CONNECTION_FEATURE_SEQUENCES:
+	case GDA_CONNECTION_FEATURE_XML_QUERIES:
+	case GDA_CONNECTION_FEATURE_NAMESPACES:
+		return FALSE;
 	}
 	
 	return FALSE;
 }
-
Index: providers/sybase/gda-sybase-recordset.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-recordset.c,v
retrieving revision 1.3
diff -u -u -r1.3 gda-sybase-recordset.c
--- providers/sybase/gda-sybase-recordset.c	19 Dec 2002 12:30:02 -0000	1.3
+++ providers/sybase/gda-sybase-recordset.c	30 Dec 2002 02:14:13 -0000
@@ -281,7 +281,7 @@
 	return type;
 }
 
-static GdaSybaseRecordset *
+GdaSybaseRecordset *
 gda_sybase_process_row_result (GdaConnection           *cnc,
                                GdaSybaseConnectionData *scnc,
                                gboolean                fetchall)
@@ -316,6 +316,7 @@
 		scnc->ret = ct_cancel (NULL, scnc->cmd, CS_CANCEL_CURRENT);
 		if (scnc->ret != CS_SUCCEED) {
 			sybase_error_msg (_("ct_cancel() failed."));
+			sybase_check_messages(cnc);
 		}
 		return NULL;
 	}
@@ -330,6 +331,7 @@
 		                               _("%s failed while processing a row result."),
 		                               "ct_res_info()");
 		gda_connection_add_error (cnc, error);
+		sybase_check_messages(cnc);
 		return NULL;
 	}
 	if (srecset->priv->colcnt <= 0) {
@@ -360,6 +362,7 @@
 		if (scnc->ret != CS_SUCCEED) {
 			sybase_error_msg (_("Could not call %s while processing row resultset."),
 			                  "ct_cancel()");
+			sybase_check_messages(cnc);
 		}
 		return srecset;
 	}
@@ -378,6 +381,7 @@
 			error = gda_sybase_make_error (scnc, 
 			                               _("Could not run %s on column %d"), "ct_describe()", i);
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 			break;
 		}
 
@@ -386,6 +390,7 @@
 			error = gda_sybase_make_error (scnc,
 			                               _("Could not allocate data placeholder for column %d"), i);
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 			break;
 		}
 
@@ -397,6 +402,7 @@
 			error = gda_sybase_make_error (scnc,
 			                               _("Could not run %s on column %d"), "ct_bind()", i);
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 			break;
 		}
 
@@ -415,6 +421,7 @@
 		if (scnc->ret != CS_SUCCEED) {
 			error = gda_sybase_make_error (scnc, _("Could not run %s to cancel processing row resultset."), "ct_cancel");
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 		}
 		
 		return srecset;
@@ -430,6 +437,7 @@
 		if (scnc->ret == CS_ROW_FAIL) {
 			error = gda_sybase_make_error (scnc, _("%s failed on row %d"), "ct_fetch()", row_cnt);
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 		}
 		
 		// srecset->columns contains the data;
@@ -456,85 +464,136 @@
 		default:
 			error = gda_sybase_make_error (scnc, _("%s terminated with unexpected return code."), "ct_fetch()");
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 	}
 	
 	return srecset;
 }
 
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-// gda_sybase_recordset_new is a general result-processing routine
-// for processing a single ct_results() step.
-// 
-// Therefore it may also return no result, e.g. if the resulttype is
-// CS_CMD_DONE, i.e. we finished processing a command.
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-GdaDataModel *
-gda_sybase_recordset_new (GdaConnection *cnc,
-                          gboolean fetchall)
+
+GdaSybaseRecordset *
+gda_sybase_process_msg_result(GdaConnection *cnc,
+																														GdaSybaseConnectionData *scnc)
 {
-	GdaSybaseConnectionData *scnc = NULL;
-	GdaSybaseRecordset      *srecset = NULL;
-//	GdaSybaseField          *sfield = NULL;
-//	GdaRow                  *row = NULL;
-	GdaError                *error = NULL;
-//	gboolean                columns_set = FALSE;
-//	gint                    i = 0;
-
-	g_return_val_if_fail (GDA_IS_CONNECTION(cnc), NULL);
-	scnc = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                           OBJECT_DATA_SYBASE_HANDLE);
-	g_return_val_if_fail (scnc != NULL, NULL);
-	g_return_val_if_fail (scnc->cmd != NULL, NULL);
-
-	// now nothing may fail;
-	// a result not processed may block the entire connection
-	// each process_* routine must check if recset is valid,
-	// otherwise alt. a) too process the results (eventually discard)
-	//           alt. b) call ct_cancel, dropping _all_ results of
-	//                   the entire query
 	
+	// in ASE when a stored procedure uses the print statement, it 
+	// generates a CS_MSG_RESULT result code, treat it like another result set.
+
+	GdaSybaseRecordset *srecset = NULL;
+	GdaSybaseField *sfield = NULL;
+	//	gboolean sfields_allocated = TRUE;
+	GdaRow *row = NULL;
+	GdaValue *val = NULL;
+	gchar *message;
+	CS_INT msgcnt = 0;
+	GdaError *error;
+	CS_SERVERMSG msg; 
+	CS_RETCODE ret;
+
+	// called within gda_sybase_recordset_new
+	srecset = g_object_new (GDA_TYPE_SYBASE_RECORDSET, NULL);
+
+	srecset->priv->cnc = cnc;
+	srecset->priv->scnc = scnc;
+
+	// see if there is a message
+	ret = ct_diag (scnc->connection,
+																								CS_STATUS, 
+																								CS_ALLMSG_TYPE, 
+																								CS_UNUSED,
+																								&msgcnt);
 	
-	// we are within the resultset processing loop,
-	// ct_results (scnc->cmd, &scnc->res_type) = CS_SUCCEED
+	if ( ret != CS_SUCCEED ) {
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error, _("an error occured when calling ct_diag attempting to retrieve a server message count for resultset"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);		
+		return NULL;
+	}
 
-	switch (scnc->res_type) {
-		case CS_ROW_RESULT:
-			srecset = gda_sybase_process_row_result (cnc, scnc,
-			                                         TRUE);
-			break;
-	// FIXME: implement CS_CURSOR_RESULT .. CS_COMPUTEFMT_RESULT
-		case CS_CURSOR_RESULT:
-		case CS_PARAM_RESULT:
-		case CS_STATUS_RESULT:
-		case CS_COMPUTE_RESULT:
-		case CS_MSG_RESULT:
-		case CS_DESCRIBE_RESULT:
-		case CS_ROWFMT_RESULT:
-		case CS_COMPUTEFMT_RESULT:
-			scnc->ret = ct_cancel (NULL, scnc->cmd,
-			                       CS_CANCEL_CURRENT);
-			break;
-		case CS_CMD_DONE:
-//			sybase_debug_msg (_("Done with resultset."));
-			break;
-		case CS_CMD_SUCCEED:
-//			sybase_debug_msg (_("Command returned no rows."));
-			srecset = g_object_new (GDA_TYPE_SYBASE_RECORDSET, NULL);
-			if ((srecset != NULL) && (srecset->priv != NULL)
-			    && (srecset->priv->columns != NULL) 
-			    && (srecset->priv->rows != NULL)) {
-				srecset->priv->cnc = cnc;
-				srecset->priv->scnc = scnc;
-			}
-			break;
-		case CS_CMD_FAIL:
-			sybase_debug_msg (_("%s returned %s"),
-			                  "ct_results()", "CS_CMD_FAIL");
-			break;
+	if ( msgcnt < 1 ){
+			sybase_debug_msg (_("attempting to make recordset and msg count != 1 !"));
+			return NULL;
 	}
 
-	if (srecset) 
-		return GDA_DATA_MODEL (srecset);
-	else
-		return NULL;
+	ret = ct_diag (scnc->connection, 
+																CS_GET, 
+																CS_SERVERMSG_TYPE, 
+																1, 
+																&msg); 
+	if ( ret != CS_SUCCEED ) { 
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error, _("an error occured when calling ct_diag attempting to retrieve a server message for recordset"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);
+		return NULL;					
+	} 	
+
+	srecset->priv->colcnt = 1;
+
+	sfield = g_new0 (GdaSybaseField, 1);
+
+	if (sfield != NULL) {
+		g_ptr_array_add (srecset->priv->columns, sfield);
+	} 
+	else {
+		g_object_unref (srecset);
+		srecset = NULL;
+		sybase_error_msg (_("Could not allocate structure for column metainformation."));
+		
+		scnc->ret = ct_cancel (NULL, scnc->cmd, CS_CANCEL_ALL);
+		if (scnc->ret != CS_SUCCEED) {
+			sybase_error_msg (_("Could not call %s while processing row resultset."),
+			                  "ct_cancel()");
+			sybase_check_messages(cnc);
+		}
+		return srecset;
+	}		
+
+	memset (&sfield->fmt, 0, sizeof(sfield->fmt));
+	sfield->fmt.namelen = 0;
+	sfield->fmt.datatype = CS_CHAR_TYPE;
+	sfield->fmt.scale = 0;
+	sfield->fmt.precision = 0;
+	sfield->fmt.status = CS_CANBENULL;
+	sfield->fmt.count = 1;
+	sfield->fmt.locale = NULL;
+
+	row = gda_row_new(1);
+	val = gda_row_get_value(row,0);
+
+	message = g_strdup_printf("%s",
+																											(msg.text) ? msg.text : "");
+
+	sfield->fmt.maxlength = strlen(message);
+
+	srecset->priv->rowcnt = 1;	
+ gda_value_set_string(val,(gchar *)message);
+	g_ptr_array_add(srecset->priv->rows, row);
+
+	// clear the message so we don't get bugged by it later
+	ret = ct_diag (scnc->connection, 
+																CS_CLEAR, 
+																CS_SERVERMSG_TYPE, 
+																CS_UNUSED, 
+																NULL);   
+	if ( ret != CS_SUCCEED ) { 
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, _("call to ct_diag failed when attempting to clear the server messages"));
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);
+			return NULL;
+		} 	
+
+	return srecset;
 }
+																														
Index: providers/sybase/gda-sybase-recordset.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-recordset.h,v
retrieving revision 1.1
diff -u -u -r1.1 gda-sybase-recordset.h
--- providers/sybase/gda-sybase-recordset.h	9 Dec 2002 05:45:01 -0000	1.1
+++ providers/sybase/gda-sybase-recordset.h	30 Dec 2002 02:14:13 -0000
@@ -74,8 +74,17 @@
 };
 
 GType           gda_sybase_recordset_get_type (void);
-GdaDataModel   *gda_sybase_recordset_new (GdaConnection *cnc,
-                                          gboolean fetchall);
+
+GdaSybaseRecordset *
+gda_sybase_process_row_result (GdaConnection           *cnc,
+                               GdaSybaseConnectionData *scnc,
+                               gboolean                fetchall);
+
+
+GdaSybaseRecordset *
+gda_sybase_process_msg_result(GdaConnection *cnc,
+																														GdaSybaseConnectionData *scnc);
+
 
 G_END_DECLS
 
Index: providers/sybase/gda-sybase-schemas.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-schemas.h,v
retrieving revision 1.1
diff -u -u -r1.1 gda-sybase-schemas.h
--- providers/sybase/gda-sybase-schemas.h	19 Dec 2002 11:16:00 -0000	1.1
+++ providers/sybase/gda-sybase-schemas.h	30 Dec 2002 02:14:13 -0000
@@ -31,7 +31,7 @@
 G_BEGIN_DECLS
 
 #define TDS_QUERY_CURRENT_DATABASE \
-	"SELECT db_name() AS database"
+	"SELECT db_name()"
 #define TDS_QUERY_SERVER_VERSION \
 	"SELECT (@@version) AS version"
 
@@ -207,6 +207,32 @@
 	" ORDER BY name"
 
 G_END_DECLS
+
+
+#define TDS_SCHEMA_INDEXES \
+ "SELECT name from sysindexes " \
+ "order by name"
+
+
+#define TDS_FIXMODEL_SCHEMA_INDEXES(model) \
+	if (model) { \
+		gda_data_model_set_column_title (GDA_DATA_MODEL (model),  0, \
+		                                 _("Indexes")); \
+	}
+
+#define TDS_SCHEMA_TRIGGERS \
+ "SELECT name " \
+ "from sysobjects " \
+ "where type = 'TR' "\
+ "order by name"
+
+#define TDS_FIXMODEL_SCHEMA_TRIGGERS(model) \
+	if (model) { \
+		gda_data_model_set_column_title (GDA_DATA_MODEL (model),  0, \
+		                                 _("Triggers")); \
+	}
+
+
 
 #endif
 
Index: providers/sybase/gda-sybase-types.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-types.c,v
retrieving revision 1.1
diff -u -u -r1.1 gda-sybase-types.c
--- providers/sybase/gda-sybase-types.c	9 Dec 2002 05:45:01 -0000	1.1
+++ providers/sybase/gda-sybase-types.c	30 Dec 2002 02:14:14 -0000
@@ -81,7 +81,6 @@
                           GdaValue *value, GdaSybaseField *field)
 {
 	GdaError   *error = NULL;
-	GdaNumeric numeric;
 	gboolean   success = FALSE;
 	
 	g_return_val_if_fail (value != NULL, FALSE);
@@ -224,6 +223,7 @@
 		        _("data conversion failed for type %d"),
 			field->fmt.datatype);
 		gda_connection_add_error (scnc->gda_cnc, error);
+		sybase_check_messages(scnc->gda_cnc);
 		return FALSE;
 	}
 	
Index: providers/sybase/gda-sybase.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase.h,v
retrieving revision 1.7
diff -u -u -r1.7 gda-sybase.h
--- providers/sybase/gda-sybase.h	19 Dec 2002 11:16:00 -0000	1.7
+++ providers/sybase/gda-sybase.h	30 Dec 2002 02:14:14 -0000
@@ -35,33 +35,15 @@
 #include <glib/gmacros.h>
 #include <libgda/gda-intl.h>
 #include <libgda/gda-server-provider.h>
-
 #include <ctpublic.h>
 #include <cspublic.h>
-
 #include "gda-sybase-provider.h"
-
-// share schema queries with freetds provider
-//#include "../freetds/gda-tds-schemas.h"
 #include "gda-sybase-schemas.h"
 
 #define GDA_SYBASE_PROVIDER_ID		"GDA sybase provider"
 
 G_BEGIN_DECLS
 
-typedef struct _sybaseError
-{
-		gchar *error_msg;
-} sybase_error;
-
-
-typedef struct _sybaseConnection
-{
-		CS_CONTEXT    *context;
-		CS_CONNECTION *connection;
-		sybase_error err;
-} sybase_connection; 
-
 #define PARENT_TYPE GDA_TYPE_SERVER_PROVIDER
 #define OBJECT_DATA_SYBASE_HANDLE "GDA_Sybase_SybaseHandle"
 #define GDA_SYBASE_COMPONENT_FACTORY_ID "OAFIID:GNOME_Database_Sybase_ComponentFactory"
@@ -70,24 +52,6 @@
  * Utility functions
  */
 
-/*
-GdaError *gda_sybase_make_error (sybase_connection *);
-
-gboolean sybase_check_messages(GdaServerConnection *);
-
-gboolean sybase_check_clientmsg(GdaServerConnection *);
-
-gboolean sybase_check_servermsg(GdaServerConnection *);
-
-gboolean sybase_check_cmsg(GdaServerConnection *);
-
-gchar *sprintf_clientmsg(const gchar *, 
-																									CS_CLIENTMSG *);
-
-gchar *sprintf_servermsg(const gchar *,
-																									CS_SERVERMSG *);
-*/
-
 gboolean sybase_check_messages(GdaConnection *cnc);
 
 CS_RETCODE CS_PUBLIC gda_sybase_csmsg_callback (CS_CONTEXT *context,
@@ -103,7 +67,6 @@
 
 void sybase_debug_msg(gchar *fmt, ...);
 void sybase_error_msg(gchar *fmt, ...);
-
 
 G_END_DECLS
 
Index: providers/sybase/utils.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/utils.c,v
retrieving revision 1.5
diff -u -u -r1.5 utils.c
--- providers/sybase/utils.c	16 Dec 2002 20:50:04 -0000	1.5
+++ providers/sybase/utils.c	30 Dec 2002 02:14:15 -0000
@@ -32,6 +32,16 @@
 
 #include "gda-sybase.h"
 
+
+G_BEGIN_DECLS
+                             
+gboolean sybase_add_server_errors_to_list(GdaConnection *cnc);
+gboolean sybase_add_client_errors_to_list(GdaConnection *cnc);
+gboolean sybase_make_errors_from_list(GdaConnection *cnc);
+gboolean sybase_add_cmsg_errors_to_list(GdaConnection *cnc);
+
+G_END_DECLS
+
 CS_RETCODE CS_PUBLIC
 gda_sybase_csmsg_callback(CS_CONTEXT *context, CS_CLIENTMSG *msg)
 {
@@ -102,9 +112,14 @@
 gboolean
 sybase_check_messages(GdaConnection *cnc)
 {
+	/* when inline error handling is enabled, this function */
+	/* will return TRUE if there are any messages where generated */
+	/* by open client or the server. */
+
+
 	GdaSybaseConnectionData *sconn;
 	
-	CS_CLIENTMSG msg;
+	//	CS_CLIENTMSG msg;
 	CS_INT       msgcnt = 0;
 	CS_INT       msgcur = 0;
 
@@ -120,12 +135,13 @@
 		                       CS_ALLMSG_TYPE, 
 		                       CS_UNUSED,
 		                       &msgcnt);
-	} else {
+	} 
+	else {
 		sconn->mret = cs_diag (sconn->context,
 		                       CS_STATUS,
-				       CS_CLIENTMSG_TYPE,
-				       CS_UNUSED,
-				       &msgcnt);
+																									CS_CLIENTMSG_TYPE,
+																									CS_UNUSED,
+																									&msgcnt);
 	}
 	if (sconn->mret != CS_SUCCEED) {
 		sybase_debug_msg (_("ct_diag() failed determining # of client messages."));
@@ -136,8 +152,362 @@
 		msgcur++;
 	}
 
-	sybase_debug_msg (_("%d messages fetched."), msgcnt);
-	return TRUE;
+	//sybase_debug_msg (_("%d messages fetched."), msgcnt);
+
+	/* add any messages to the GdaConnection error list*/
+	/* there are some messages we can safely ignore, so */
+	/* use the return of sybase_make_errors_from_list() */
+	/* to determine if there was an error or not */
+	return (sybase_make_errors_from_list(cnc));
+}
+
+gboolean sybase_make_errors_from_list(GdaConnection *cnc)
+{
+	gboolean cmsg_errors = FALSE;
+	gboolean server_errors = FALSE;
+	gboolean client_errors = FALSE;
+
+	cmsg_errors = sybase_add_cmsg_errors_to_list(cnc);
+	client_errors = sybase_add_client_errors_to_list(cnc);
+	server_errors = sybase_add_server_errors_to_list(cnc);
+
+	if ( cmsg_errors || server_errors || client_errors ) 
+		return TRUE;
+	else
+		return FALSE;
+}
+
+gboolean sybase_add_cmsg_errors_to_list(GdaConnection *cnc)
+{
+	CS_RETCODE ret; 
+	CS_INT msgcnt = 0; 
+	CS_INT msgcur = 0; 
+	CS_CLIENTMSG msg; 
+	char *tempspace = NULL; 
+	GdaError *error;
+	gboolean returner = FALSE;
+	GdaSybaseConnectionData *sconn;
+
+	sconn = g_object_get_data (G_OBJECT (cnc), OBJECT_DATA_SYBASE_HANDLE);
+	g_return_val_if_fail (sconn != NULL, FALSE);
+
+	ret = cs_diag (sconn->context, 
+																CS_STATUS, 
+																CS_CLIENTMSG_TYPE, 
+																CS_UNUSED, 
+																&msgcnt);   
+	if ( ret != CS_SUCCEED ) { 
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error, _("call to cs_diag failed when attempting to the amount of client messages"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);
+		return TRUE;
+	} 
+	while ( msgcur < msgcnt ) { 
+		msgcur++;            
+		ret = cs_diag (sconn->context, 
+																	CS_GET, 
+																	CS_CLIENTMSG_TYPE, 
+																	msgcur, 
+																	&msg); 
+		if ( ret != CS_SUCCEED ) 
+			{ 
+				error = gda_error_new();
+				g_return_val_if_fail (error != NULL, FALSE);
+				gda_error_set_description (error, _("an error occured when calling cs_diag attempting to retrieve a client message"));
+				gda_error_set_number (error, -1);
+				gda_error_set_source (error, "gda-sybase");
+				gda_error_set_sqlstate (error, _("Not available"));					
+				gda_connection_add_error (cnc, error);
+				return TRUE;
+			} 
+		else { 
+			if (msg.osstringlen > 0) {
+				tempspace = g_strdup_printf("%s %ld %s %s",
+																																_("OS_Error:("),
+																																msg.osnumber,
+																																_(") Message: "),
+																																msg.osstring);
+				error = gda_error_new();
+				g_return_val_if_fail (error != NULL, FALSE);
+				gda_error_set_description (error,tempspace);
+				gda_error_set_number (error, -1);
+				gda_error_set_source (error, "gda-sybase");
+				gda_error_set_sqlstate (error, _("Not available"));					
+				gda_connection_add_error (cnc, error);
+				returner = TRUE;
+			}
+			else {
+				tempspace = g_strdup_printf("%s %ld %s %ld %s %ld %s %ld : %s",
+																																_("Sybase OpenClient Msg: severity("),
+																																(long) CS_SEVERITY(msg.severity), 																																		
+																																_("), number("),
+																																(long) CS_NUMBER(msg.msgnumber),
+																																_("), origin("),
+																																(long) CS_ORIGIN(msg.msgnumber), 
+																																_("), layer("),
+																																(long) CS_LAYER(msg.msgnumber),
+																																(msg.msgstring) ? msg.msgstring : "");
+				error = gda_error_new();
+				g_return_val_if_fail (error != NULL, FALSE);
+				gda_error_set_description (error,tempspace);
+				gda_error_set_number (error, -1);
+				gda_error_set_source (error, "gda-sybase");
+				gda_error_set_sqlstate (error, _("Not available"));					
+				gda_connection_add_error (cnc, error);
+				returner = TRUE;
+			} 
+		}
+	} 
+	g_free((gpointer)tempspace); 
+
+	if ( returner ) {
+		ret = cs_diag (sconn->context, 
+																	CS_CLEAR, 
+																	CS_CLIENTMSG_TYPE, 
+																	CS_UNUSED, 
+																	NULL);   
+		if ( ret != CS_SUCCEED ) { 
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, _("call to cs_diag failed when attempting to clear the client messages"));
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);
+			return TRUE;
+		} 
+	}
+	return returner; 
+}
+
+gboolean sybase_add_server_errors_to_list(GdaConnection *cnc)
+{
+	CS_RETCODE ret; 
+	CS_INT msgcnt = 0; 
+	CS_INT msgcur = 0; 
+	char *error_msg;
+	CS_SERVERMSG msg; 
+	char *servername = NULL; 
+	char *procname = NULL; 
+	char *messagenumber = NULL; 
+	char *severity = NULL; 
+	char *state = NULL; 
+	char *line = NULL; 
+	gboolean returner = FALSE;
+	gboolean stupid_5701_message = FALSE;
+	GdaSybaseConnectionData *sconn;
+	GdaError *error;
+	
+
+	sconn = g_object_get_data (G_OBJECT (cnc), OBJECT_DATA_SYBASE_HANDLE);
+	g_return_val_if_fail (sconn != NULL, FALSE);
+
+	ret = ct_diag (sconn->connection, 
+																CS_STATUS, 
+																CS_SERVERMSG_TYPE, 
+																CS_UNUSED, 
+																&msgcnt);   
+	if ( ret != CS_SUCCEED ) { 
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error, _("call to ct_diag failed when attempting to the amount of server messages"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);
+		return TRUE;			
+	} 
+	while ( msgcur < msgcnt ) { 
+		msgcur++;            
+		ret = ct_diag (sconn->connection, 
+																	CS_GET, 
+																	CS_SERVERMSG_TYPE, 
+																	msgcur, 
+																	&msg); 
+		if ( ret != CS_SUCCEED ) { 
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, _("an error occured when calling ct_diag attempting to retrieve a server message"));
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);
+			return TRUE;					
+		} 
+		else { 
+			if ( msg.msgnumber != 5701 ) {
+				returner = TRUE;
+				if (msg.svrnlen > 0) 
+					servername = g_strdup_printf("%s %s",
+																																		_("Server:"),
+																																		msg.svrname); 
+				if (msg.proclen > 0) 
+					procname = g_strdup_printf("%s %s",
+																																_("Stored Procedure:"),
+																																msg.proc);
+					
+				messagenumber = g_strdup_printf("%s (%ld)",
+																																				_("Number"),
+																																				msg.msgnumber); 
+				severity = g_strdup_printf("%s (%ld)",
+																															_("Severity"),
+																															msg.severity); 
+				state = g_strdup_printf("%s (%ld)",
+																												_("State"),
+																												msg.state); 
+				line = g_strdup_printf("%s (%ld)",
+																											_("Line"),
+																											msg.line);
+				if ( procname)
+					error_msg = 
+						g_strdup_printf("Sybase Server Message:%s %s %s %s %s %s %s", 
+																						servername, 
+																						severity, 
+																						state, 
+																						procname, 
+																						messagenumber, 
+																						line,
+																						msg.text);           
+				else
+					error_msg = 
+						g_strdup_printf("Sybase Server Message:%s %s %s %s %s %s", 
+																						servername, 
+																						severity, 
+																						state, 
+																						messagenumber, 
+																						line,
+																						msg.text);           
+				error = gda_error_new();
+				g_return_val_if_fail (error != NULL, FALSE);
+				gda_error_set_description (error, error_msg);
+				gda_error_set_number (error, -1);
+				gda_error_set_source (error, "gda-sybase");
+				gda_error_set_sqlstate (error, _("Not available"));					
+				gda_connection_add_error (cnc, error);
+			}
+			else
+				stupid_5701_message = TRUE;
+		} 
+	} 
+	g_free((gpointer)servername); 
+	g_free((gpointer)procname); 
+	g_free((gpointer)messagenumber); 
+	g_free((gpointer)severity); 
+	g_free((gpointer)state); 
+	g_free((gpointer)line); 
+
+	if ( ( returner ) || ( stupid_5701_message ) ) {
+		ret = ct_diag (sconn->connection, 
+																	CS_CLEAR, 
+																	CS_SERVERMSG_TYPE, 
+																	CS_UNUSED, 
+																	NULL);   
+		if ( ret != CS_SUCCEED ) { 
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, _("call to ct_diag failed when attempting to clear the server messages"));
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);
+			return TRUE;
+		} 
+	}
+	return returner; 
+}
+
+gboolean sybase_add_client_errors_to_list(GdaConnection *cnc)
+{
+	CS_RETCODE ret; 
+	CS_INT msgcnt = 0; 
+	CS_INT msgcur = 0; 
+	CS_CLIENTMSG msg; 
+	char *tempspace = NULL; 
+	GdaSybaseConnectionData *sconn;
+	GdaError *error;
+	gboolean returner= FALSE;
+
+	sconn = g_object_get_data (G_OBJECT (cnc), OBJECT_DATA_SYBASE_HANDLE);
+	g_return_val_if_fail (sconn != NULL, FALSE);
+
+
+	ret = ct_diag (sconn->connection, 
+																CS_STATUS, 
+																CS_CLIENTMSG_TYPE, 
+																CS_UNUSED, 
+																&msgcnt);   
+	if ( ret != CS_SUCCEED ) { 
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error, _("call to ct_diag failed when attempting to the amount of client messages"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);
+		return TRUE;			
+	} 
+	while ( msgcur < msgcnt ) { 
+		msgcur++;            
+		ret = ct_diag (sconn->connection, 
+																	CS_GET, 
+																	CS_CLIENTMSG_TYPE, 
+																	msgcur, 
+																	&msg); 
+		if ( ret != CS_SUCCEED ) { 
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, _("an error occured when calling ct_diag attempting to retrieve a client message"));
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);
+			return TRUE;					
+		} 
+		else { 
+			returner = TRUE;
+
+			tempspace = g_strdup_printf("%s %ld %s %ld %s %ld %s %ld : %s %s",
+																															_("Severity"),
+																															(long) CS_SEVERITY (msg.msgnumber),
+																															_("Layer"),
+																															(long) CS_LAYER (msg.msgnumber),
+																															_("Origin"),
+																															(long) CS_ORIGIN (msg.msgnumber),
+																															_("Message Number"),
+																															(long) CS_NUMBER (msg.msgnumber),
+																															msg.msgstring,
+																															msg.osstring);
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, tempspace);
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);					
+		} 
+	} 
+
+	ret = ct_diag (sconn->connection, 
+																CS_CLEAR, 
+																CS_CLIENTMSG_TYPE, 
+																CS_UNUSED, 
+																NULL);   
+	if ( ret != CS_SUCCEED ) { 
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error, _("call to ct_diag failed when attempting to clear the client messages"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);
+		return TRUE;
+	} 
+
+	return returner; 
 }
 
 GdaError *
@@ -150,8 +520,8 @@
 
 	if (scnc != NULL) {
 		switch (scnc->ret) {
-			case CS_BUSY:	sybase_error_msg(_("Operation not possible, connection busy."));
-					break;
+		case CS_BUSY:	sybase_error_msg(_("Operation not possible, connection busy."));
+			break;
 		}
 	}
 	
@@ -163,7 +533,8 @@
 			va_end(args);
 
 			gda_error_set_description (error, fmt);
-		} else {
+		} 
+		else {
 			gda_error_set_description (error, _("NO DESCRIPTION"));
 		}
 
@@ -178,8 +549,8 @@
 void
 sybase_debug_msg(gchar *fmt, ...)
 {
-// FIXME: remove comment after reviewing error code
-//#ifdef SYBASE_DEBUG
+	// FIXME: remove comment after reviewing error code
+	//#ifdef SYBASE_DEBUG
 	va_list args;
 	const size_t buf_size = 4096;
 	char buf[buf_size + 1];
@@ -189,8 +560,8 @@
 	va_end(args);
 	
 	gda_log_message("Sybase: %s", buf);
-// FIXME: remove comment after reviewing error code
-//#endif
+	// FIXME: remove comment after reviewing error code
+	//#endif
 }
 
 void
Index: testing/sybase-test.c
===================================================================
RCS file: /cvs/gnome/libgda/testing/sybase-test.c,v
retrieving revision 1.1
diff -u -u -r1.1 sybase-test.c
--- testing/sybase-test.c	9 Dec 2002 05:44:59 -0000	1.1
+++ testing/sybase-test.c	30 Dec 2002 02:14:16 -0000
@@ -102,9 +102,13 @@
 	GdaCommand *select_command;
 	GList *list;
 
-	select_command = gda_command_new ( "select * from gda_sybase_test",
+	//select_command = gda_command_new ( "select * from gda_sybase_test",
+	//				GDA_COMMAND_TYPE_SQL, STOP_ON_ERR);
+
+	select_command = gda_command_new ( "print 'this is a print statement!'",
 					GDA_COMMAND_TYPE_SQL, STOP_ON_ERR);
 
+	
 	list = gda_connection_execute_command (cnc, select_command,
 						NULL);
 	gda_command_free (select_command);
@@ -112,15 +116,26 @@
 	return list;
 }
 
+
+
+
 /* sybase provider tests */
 void
 do_sybase_test (GdaConnection *cnc)
 {
 	GList *list;
+	gchar *current_db;
+
 
 	g_return_if_fail (GDA_IS_CONNECTION (cnc));
 
 	g_print ("\tSybase provider specific tests...\n");
+
+	/* tests current get_database method */
+	current_db = gda_connection_get_database(cnc);
+	g_print("\t current database is.... %s\n",current_db);
+	g_free(current_db);
+
 
 	/* Drops the gda_sybase_test table. Fail if not exists. */
 	g_print ("\t\tDrop table: %s\n",


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