[gnome-db] mSQL Provider Fix



Hi,
After eventually getting libgda to compile, (Wretched SuSE systems, thanks to 
Danilo for spending most of his day compiling things ;-)) I've been able to 
create this patch file to make the mSQL provider conform to the previously 
discussed standard (with respect to the handling of NON-SELECT queries). 
Since I haven't used mergeant I'm not sure how well it implements the 
handling of NON-SELECT queries? (Just making sure, since Mergeant seems to 
have quite a bit of interest recently)

Also corrected a slight error in the configure.in file (which was 
unfortunately present in the 1.0.0 release preventing configure from 
recognising --with-msql switches)

So to round up, I can vouch for the sanity of the following providers:
- MySQL
- PostgreSQL (this already worked, might need to revise some of the 
error-return codes though)
- mSQL

I've pretty much run out of database backends to test now, so I guess we'll 
see where this goes..

Cheers for now,
Chris
? out.diff
Index: configure.in
===================================================================
RCS file: /cvs/gnome/libgda/configure.in,v
retrieving revision 1.228
diff -u -p -r1.228 configure.in
--- configure.in	25 Aug 2003 21:43:05 -0000	1.228
+++ configure.in	18 Sep 2003 22:11:20 -0000
@@ -219,7 +219,7 @@ AM_CONDITIONAL(MYSQL, test x$mysqldir !=
 
 dnl Test for mSQL
 try_msql=true
-AC_ARG_WITH(mysql,
+AC_ARG_WITH(msql,
 [  --with-mSQL=<directory>	use mSQL backend in <directory>],[
 if test $withval = no
 then
Index: providers/msql/gda-msql-provider.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/msql/gda-msql-provider.c,v
retrieving revision 1.2
diff -u -p -r1.2 gda-msql-provider.c
--- providers/msql/gda-msql-provider.c	22 Jun 2003 16:49:08 -0000	1.2
+++ providers/msql/gda-msql-provider.c	18 Sep 2003 22:11:20 -0000
@@ -246,7 +246,7 @@ static GList *process_sql_commands(GList
         break;
       }
       res=msqlStoreResult();
-      rs=gda_msql_recordset_new(cnc,res,*sock);
+      rs=gda_msql_recordset_new(cnc,res,*sock,(int)rc);
       if (GDA_IS_MSQL_RECORDSET(rs)) {
         gda_data_model_set_command_text((GdaDataModel*)rs,arr[n]);
         gda_data_model_set_command_type((GdaDataModel*)rs,
@@ -429,7 +429,7 @@ static GdaDataModel 
   sock_ptr=g_object_get_data(G_OBJECT(cnc),OBJECT_DATA_MSQL_HANDLE);
   if (!sock_ptr) return NULL;
   res=msqlListDBs(*sock_ptr);
-  rs=gda_msql_recordset_new(cnc,res,*sock_ptr);
+  rs=gda_msql_recordset_new(cnc,res,*sock_ptr,(int)msqlNumRows(res));
   return (rs) ? GDA_DATA_MODEL(rs) : NULL;
 }
 
Index: providers/msql/gda-msql-recordset.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/msql/gda-msql-recordset.c,v
retrieving revision 1.2
diff -u -p -r1.2 gda-msql-recordset.c
--- providers/msql/gda-msql-recordset.c	22 Jun 2003 16:49:08 -0000	1.2
+++ providers/msql/gda-msql-recordset.c	18 Sep 2003 22:11:21 -0000
@@ -115,6 +115,7 @@ static gint gda_msql_recordset_numrows(G
   GdaMsqlRecordset *rs=(GdaMsqlRecordset*)model;
   
   if (!GDA_IS_MSQL_RECORDSET(rs)) return -1;
+  if (rs->res==NULL) return rs->n_rows;
   return msqlNumRows(rs->res);
 }
 
@@ -122,6 +123,7 @@ static gint gda_msql_recordset_numcols(G
   GdaMsqlRecordset *rs=(GdaMsqlRecordset*)model;
   
   if (!GDA_IS_MSQL_RECORDSET(rs)) return -1;
+  if (rs->res==NULL) return 0;
   return msqlNumFields(rs->res);
 }
 
@@ -342,19 +344,21 @@ GType gda_msql_recordset_get_type(void) 
 }
 
 GdaMsqlRecordset 
-*gda_msql_recordset_new(GdaConnection *cnc,m_result *res,int sock) {
+*gda_msql_recordset_new(GdaConnection *cnc,m_result *res,int sock,int n_rows) {
   GdaMsqlRecordset *rs;
   m_fdata          *fields;
   register gint     i;
 
   if (!GDA_IS_CONNECTION(cnc)) return NULL;
-  if (!res) return NULL;
-  rs=g_object_new(GDA_TYPE_MSQL_RECORDSET,NULL);
+    rs=g_object_new(GDA_TYPE_MSQL_RECORDSET,NULL);
   rs->cnc=cnc;
   rs->res=res;
   rs->sock=sock;
-  for (fields=res->fieldData,i=0;fields;fields=fields->next,i++) {
-    gda_data_model_set_column_title(GDA_DATA_MODEL(rs),i,fields->field.name);
+  rs->n_rows=n_rows;
+  if (res!=NULL) {
+    for (fields=res->fieldData,i=0;fields;fields=fields->next,i++) {
+      gda_data_model_set_column_title(GDA_DATA_MODEL(rs),i,fields->field.name);
+    }
   }
   return rs;
 }
Index: providers/msql/gda-msql-recordset.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/msql/gda-msql-recordset.h,v
retrieving revision 1.2
diff -u -p -r1.2 gda-msql-recordset.h
--- providers/msql/gda-msql-recordset.h	22 Jun 2003 16:49:08 -0000	1.2
+++ providers/msql/gda-msql-recordset.h	18 Sep 2003 22:11:21 -0000
@@ -51,6 +51,7 @@ struct _GdaMsqlRecordset {
   GdaConnection   *cnc;
   m_result        *res;
   int              sock;
+  int              n_rows;
 };
 
 struct _GdaMsqlRecordsetClass {
@@ -59,7 +60,7 @@ struct _GdaMsqlRecordsetClass {
 
 GType             gda_msql_recordset_get_type(void);
 GdaMsqlRecordset *gda_msql_recordset_new(GdaConnection *cnc,m_result *res,
-                                         int sock);
+                                         int sock,int n_rows);
 
 G_END_DECLS
 


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