caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Patch to ocaml-mysql
@ 2002-07-06 20:02 Artem Prisyaznuk
  2002-07-07 19:19 ` Shawn Wagner
  0 siblings, 1 reply; 2+ messages in thread
From: Artem Prisyaznuk @ 2002-07-06 20:02 UTC (permalink / raw)
  To: shawnw; +Cc: caml-list

Hello 

I found in  Ocaml-MySql binding 0.1.1 some bugs. 
It broken garbage collector,
because it's not correct operate with Ocaml/C interface.
If during working program, GC run major cycle, program 
don't working properly after what. 

It's problem explained here: 

	http://caml.inria.fr/archives/200002/msg00065.html

I change some part of code, now it's working Ok.

Diff output like this:


diff -u -r ocaml-mysql-0.1.1/configure ocaml-mysql-0.1.2/configure
--- ocaml-mysql-0.1.1/configure	Mon Apr 22 22:38:01 2002
+++ ocaml-mysql-0.1.2/configure	Tue Jul  2 15:56:46 2002
@@ -2173,6 +2173,7 @@
 echo "$as_me: checking for MySQL libraries..." >&6;}
 dirs="/usr/local/lib/mysql
       /usr/local/mysql/lib
+	  /usr/local/mysql/lib/mysql
       /usr/local/lib
       /usr/lib
       /usr/lib/mysql"
diff -u -r ocaml-mysql-0.1.1/ocmysql.c ocaml-mysql-0.1.2/ocmysql.c
--- ocaml-mysql-0.1.1/ocmysql.c	Mon May  6 02:15:39 2002
+++ ocaml-mysql-0.1.2/ocmysql.c	Fri Jul  5 10:42:17 2002
@@ -99,8 +99,8 @@
     v = alloc_string(length);
     memcpy(String_val(v), s, length);
     
-    res = alloc_small(1,SOME);
-    Field(res,0) = v; 
+    res = alloc(1,SOME);
+    Store_field(res,0,v); 
   }
   CAMLreturn(res);
 }
@@ -116,8 +116,8 @@
   CAMLlocal2(res, v);
         
   v = some;
-  res = alloc_small(1,SOME);
-  Field(res,0) = v;
+  res = alloc(1,SOME);
+  Store_field(res,0,v);
 
   CAMLreturn(res);
 }
@@ -175,8 +175,8 @@
       mysqlfailwith(mysql_error(init));
     } else {
       res = alloc_final(3, conn_finalize, 100,1000);
-      Store_field(res, 1, (value)mysql);
-      Store_field(res, 2, Val_true);
+      Field(res, 1) =  (value)mysql;
+      Field(res, 2) = Val_true;
     }
   }
   CAMLreturn(res);
@@ -224,15 +224,13 @@
   dbs = alloc_tuple(n); /* Array */
   i = 0;
   while ((row = mysql_fetch_row(res)) != NULL) {
-    CAMLlocal1(s);
-    s = copy_string(row[0]);
-    Store_field(dbs, i, s);
+    Store_field(dbs, i, copy_string(row[0]));
     i++;
   }
 
   mysql_free_result(res);
-  out = alloc_small(1, SOME);
-  Field(out, 0) = dbs;
+  out = alloc(1, SOME);
+  Store_field(out, 0, dbs);
   CAMLreturn(out);
 
 }
@@ -259,8 +257,8 @@
   CAMLparam1(dbd);
   check_dbd(dbd,"disconnect");
   mysql_close(DBDmysql(dbd));
-  Store_field(dbd, 1, Val_false);
-  Store_field(dbd, 2, Val_false); /* Mark closed */
+  Field(dbd, 1) = Val_false;
+  Field(dbd, 2) = Val_false; /* Mark closed */
   CAMLreturn0;
 }
 
@@ -313,7 +311,7 @@
     
   } else {
     res = alloc_final(2, res_finalize, 1, 20);    
-    Store_field(res, 1, (value) mysql_store_result(DBDmysql(dbd)));
+    Field(res, 1) = ((value) mysql_store_result(DBDmysql(dbd)));
   }
 
   CAMLreturn(res);
@@ -354,9 +352,7 @@
   length = mysql_fetch_lengths(res);      /* length[] */
   fields = alloc_tuple(n);                    /* array */
   for (i=0;i<n;i++) {
-    CAMLlocal1(s);
-    s = val_str_option(row[i], length[i]);
-    Store_field(fields, i, s);
+    Store_field(fields, i, val_str_option(row[i], length[i]));
   }
   
   CAMLreturn(val_some(fields));
@@ -456,13 +452,13 @@
   else
     size = (int64)(mysql_num_rows(res));
   
-  return copy_int64(size);
+  CAMLreturn(copy_int64(size));
 }
 
 EXTERNAL value
 db_affected(value dbd) {
   CAMLparam1(dbd);
-  return copy_int64(mysql_affected_rows(DBDmysql(dbd)));
+  CAMLreturn(copy_int64(mysql_affected_rows(DBDmysql(dbd))));
 }
 
 EXTERNAL value
@@ -653,12 +649,10 @@
 
   f = mysql_fetch_fields(res);
   for (i = 0; i < n; i++) {
-    CAMLlocal1(fi);
-    fi = make_field(f + i);
-    Store_field(f, i, fi);
+    Store_field(fields, i, make_field(f + i) );
   }
 
-  out = alloc_small(1, SOME);
-  Field(out, SOME) = fields;
+  out = alloc(1, SOME);
+  Store_field(out, SOME, fields);
   CAMLreturn(out);
 }

-- 
Artem Prisyaznuk
tema@sit.kiev.ua
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Patch to ocaml-mysql
  2002-07-06 20:02 [Caml-list] Patch to ocaml-mysql Artem Prisyaznuk
@ 2002-07-07 19:19 ` Shawn Wagner
  0 siblings, 0 replies; 2+ messages in thread
From: Shawn Wagner @ 2002-07-07 19:19 UTC (permalink / raw)
  To: caml-list

On Sat, Jul 06, 2002 at 11:02:52PM +0300, Artem Prisyaznuk wrote:
> Hello 
> 
> I found in  Ocaml-MySql binding 0.1.1 some bugs. 

Introducing ocaml-mysql 0.1.2. :)

http://raevnos.pennmush.org/code/ocaml-mysql-0.1.2.tar.gz

-- 
Shawn Wagner
shawnw@speakeasy.org
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-07 19:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-06 20:02 [Caml-list] Patch to ocaml-mysql Artem Prisyaznuk
2002-07-07 19:19 ` Shawn Wagner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).