[Pkg-ocaml-maint-commits] [mysql-ocaml] 01/04: New upstream version 1.2.1

Stéphane Glondu glondu at moszumanska.debian.org
Sat Jul 15 15:15:56 UTC 2017


This is an automated email from the git hooks/post-receive script.

glondu pushed a commit to branch master
in repository mysql-ocaml.

commit ccad0e85526bcd85e7aec3c67a47caf57e9042a8
Author: Stephane Glondu <steph at glondu.net>
Date:   Sat Jul 15 17:10:41 2017 +0200

    New upstream version 1.2.1
---
 CHANGES                      |   5 ++
 README                       |  50 ++++++-------
 config.h.in                  |   2 +-
 configure                    |  22 +++---
 configure.in => configure.ac |   2 +-
 mysql_stubs.c                | 174 ++++++++++++++++++++++---------------------
 6 files changed, 132 insertions(+), 123 deletions(-)

diff --git a/CHANGES b/CHANGES
index 78d7af2..84506a8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+* Sat Jul 23 2016 (1.2.1)
+  * Fix crash in fetch_fields
+  * Fix build with OCaml 4.03
+  * Fix error message in Mysql.Prepared.create
+
 * Tue Mar 10 2015 (1.2.0)
   * Get rid of Camlp4 dependency
   * Use mysql_config in configure
diff --git a/README b/README
index f531733..546a920 100644
--- a/README
+++ b/README
@@ -1,25 +1,24 @@
 
+                     OCaml-MySQL -- MySQL access for OCaml
+                     *************************************
 
-                 OCamlMySQL -- MySQL access for OCaml
-                 *************************************
+                    http://ocaml-mysql.forge.ocamlcore.org/
+                    =======================================
+                             Based on a release by:
+                                  Shawn Wagner
+                              shawnw at speakeasy.org
+                  http://raevnos.pennmush.org/code/ocaml-mysql
+                  ============================================
+                             Based on a release by:
+                                Christian Lindig
+                            lindig at eecs.harvard.edu
+                      http://www.eecs.harvard.edu/~lindig
+                      ===================================
 
-                  http://ocaml-mysql.forge.ocamlcore.org/
-                  =======================================
-                         Based on a release by:
-                              Shawn Wagner
-                           shawnw at speakeasy.org
-                    http://raevnos.pennmush.org/ocaml/
-                    ===============================
-                         Based on a release by:
-                            Christian Lindig
-                           lindig at eecs.harvard.edu
-                     http://www.eecs.harvard.edu/~lindig 
-                   ==================================
 
-
-  ocaml-mysql is a package for OCaml that provides access to mysql 
-databases. It consists of low level functions implemented in C and a
-module Mysql intended for application development. 
+  ocaml-mysql is a package for OCaml that provides access to mysql
+databases. It consists of low-level C bindings to libmysqlclient and a
+module Mysql intended for application development.
 
 
 1  Building
@@ -81,15 +80,15 @@ $ CPPFLAGS="-I$P/include" ./configure
 $ make all opt demos
 
 
-2  Trouble Shooting
-*=*=*=*=*=*=*=*=*=*
+2  Troubleshooting
+*=*=*=*=*=*=*=*=*=
 
 
   If compilation fails this is most probably because include or library
 files were not found. The configure looks in a number of places but may
 fail to find the files on your system. In case you have GNU Autoconf
 installed you can take a look at the configure.in and add more
-directories to search: 
+directories to search:
 
               <<
                 AC_CHECKING(for MySQL header files)
@@ -112,10 +111,10 @@ Please send a patch back to the author.
   Reading the mysql documentation should help, too.
   Two small demos are available. Build them with `make demos`.
 
-  Note: The library can now be used in multithreaded ocaml programs without
-  blocking threads during i/o with the database server. However, only one
-  thread should use mysql functions. Better support for multi-threaded servers
-  using libmysqlclient_r coming someday.
+  Note: The library can be used in multithreaded ocaml programs without
+  blocking threads during i/o with the database server.
+  Since MySQL 5.5 it is safe to share database handle between threads in most scenarios, see
+  http://dev.mysql.com/doc/refman/5.5/en/c-api-threaded-clients.html
 
 4  Copying
 *=*=*=*=*=
@@ -132,4 +131,3 @@ Please send a patch back to the author.
 
   Current maintainer:
     ygrek <ygrek at autistici.org>
-
diff --git a/config.h.in b/config.h.in
index fe14869..006275f 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,4 +1,4 @@
-/* config.h.in.  Generated from configure.in by autoheader.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
diff --git a/configure b/configure
index 8ca2f0b..934605a 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for ocaml-mysql 1.2.0.
+# Generated by GNU Autoconf 2.69 for ocaml-mysql 1.2.1.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -577,8 +577,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='ocaml-mysql'
 PACKAGE_TARNAME='ocaml-mysql'
-PACKAGE_VERSION='1.2.0'
-PACKAGE_STRING='ocaml-mysql 1.2.0'
+PACKAGE_VERSION='1.2.1'
+PACKAGE_STRING='ocaml-mysql 1.2.1'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -1228,7 +1228,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures ocaml-mysql 1.2.0 to adapt to many kinds of systems.
+\`configure' configures ocaml-mysql 1.2.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1289,7 +1289,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of ocaml-mysql 1.2.0:";;
+     short | recursive ) echo "Configuration of ocaml-mysql 1.2.1:";;
    esac
   cat <<\_ACEOF
 
@@ -1369,7 +1369,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-ocaml-mysql configure 1.2.0
+ocaml-mysql configure 1.2.1
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1667,7 +1667,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by ocaml-mysql $as_me 1.2.0, which was
+It was created by ocaml-mysql $as_me 1.2.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4044,7 +4044,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by ocaml-mysql $as_me 1.2.0, which was
+This file was extended by ocaml-mysql $as_me 1.2.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4106,7 +4106,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-ocaml-mysql config.status 1.2.0
+ocaml-mysql config.status 1.2.1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -5324,7 +5324,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by ocaml-mysql $as_me 1.2.0, which was
+This file was extended by ocaml-mysql $as_me 1.2.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5386,7 +5386,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-ocaml-mysql config.status 1.2.0
+ocaml-mysql config.status 1.2.1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.in b/configure.ac
similarity index 97%
rename from configure.in
rename to configure.ac
index a7974f5..b6ace80 100644
--- a/configure.in
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT(ocaml-mysql,1.2.0)
+AC_INIT(ocaml-mysql,1.2.1)
 
 AC_CHECKING([for ocaml compiler and tools])
 AC_CHECK_PROG(ocamlc,ocamlc,ocamlc)
diff --git a/mysql_stubs.c b/mysql_stubs.c
index e8b8703..b035552 100644
--- a/mysql_stubs.c
+++ b/mysql_stubs.c
@@ -1,14 +1,14 @@
 /*
- * This module provides access to MySQL from Objective Caml. 
+ * This module provides access to MySQL from Objective Caml.
  */
 
- 
+
 #include <stdio.h>              /* sprintf */
-#include <string.h> 
+#include <string.h>
 #include <stdarg.h>
- 
-/* OCaml runtime system */
 
+/* OCaml runtime system */
+#define CAML_NAME_SPACE
 #include <caml/mlvalues.h>
 #include <caml/memory.h>
 #include <caml/fail.h>
@@ -46,7 +46,7 @@
 #define caml_enter_blocking_section() if (1) { caml_enter_blocking_section(); sleep(1); }
 #endif
 
-/* Abstract types 
+/* Abstract types
  *
  * dbd - data base descriptor
  *
@@ -63,7 +63,7 @@
  */
 
 /* macros to access C values stored inside the abstract values */
- 
+
 #define DBDmysql(x) ((MYSQL*)(Field(x,1)))
 #define DBDopen(x) (Field(x,2))
 #define RESval(x) (*(MYSQL_RES**)Data_custom_val(x))
@@ -75,21 +75,22 @@ static void mysqlfailwith(char *err) Noreturn;
 static void mysqlfailmsg(const char *fmt, ...) Noreturn;
 
 static void
-mysqlfailwith(char *err) {
-  raise_with_string(*caml_named_value("mysql error"), err);
+mysqlfailwith(char *err)
+{
+  caml_raise_with_string(*caml_named_value("mysql error"), err);
 }
 
 static void
-mysqlfailmsg(const char *fmt, ...) {
+mysqlfailmsg(const char *fmt, ...)
+{
   char buf[1024];
   va_list args;
 
   va_start(args, fmt);
   vsnprintf(buf, sizeof buf, fmt, args);
   va_end(args);
-  
-  raise_with_string(*caml_named_value("mysql error"), buf);  
 
+  caml_raise_with_string(*caml_named_value("mysql error"), buf);
 }
 
 #define Val_none Val_int(0)
@@ -126,7 +127,7 @@ strdup_option(value v)
 {
   if (v == Val_none)
     return (char*) NULL;
-  else 
+  else
     return strdup(String_val(Some_val(v)));
 }
 
@@ -134,7 +135,7 @@ strdup_option(value v)
  * val_str_option creates a string option value from a char* (NONE for
  * NULL) -- dual to str_option().
  */
- 
+
 static value
 val_str_option(const char* s, unsigned long length)
 {
@@ -159,7 +160,7 @@ val_str_option(const char* s, unsigned long length)
 static inline MYSQL*
 check_db(value dbd, const char *fun)
 {
-  if (!Bool_val(DBDopen(dbd))) 
+  if (!Bool_val(DBDopen(dbd)))
     mysqlfailmsg("Mysql.%s called with closed connection", fun);
   return DBDmysql(dbd);
 }
@@ -168,7 +169,7 @@ check_db(value dbd, const char *fun)
 static void
 conn_finalize(value dbd)
 {
-  if (Bool_val(DBDopen(dbd))) 
+  if (Bool_val(DBDopen(dbd)))
   {
     MYSQL* db = DBDmysql(dbd);
     caml_enter_blocking_section();
@@ -185,7 +186,7 @@ static unsigned int ml_mysql_protocol_type[] = {
   MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
   MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
 };
- 
+
 #define SET_OPTION(option, p) if (0 != mysql_options(init,MYSQL_##option,p)) mysqlfailwith( "MYSQL_" #option ); break
 #define SET_OPTION_BOOL(option) option_bool = Bool_val(v); SET_OPTION(option, &option_bool)
 #define SET_OPTION_INT(option) option_int = Int_val(v); SET_OPTION(option, &option_int)
@@ -211,13 +212,13 @@ db_connect(value options, value args)
   unsigned long client_flag = 0;
 
   init = mysql_init(NULL);
-  if (!init) 
+  if (!init)
   {
     mysqlfailwith("connect failed");
-  } 
-  else 
+  }
+  else
   {
-    while (options != Val_emptylist) 
+    while (options != Val_emptylist)
     {
       if (Is_block(Field(options,0)))
       {
@@ -240,7 +241,7 @@ db_connect(value options, value args)
           case 13: SET_OPTION_STR(SET_CHARSET_NAME);
           case 14: SET_OPTION_STR(SHARED_MEMORY_BASE_NAME);
           default:
-            invalid_argument("Mysql.connect: unknown option");
+            caml_invalid_argument("Mysql.connect: unknown option");
         }
       }
       else
@@ -250,7 +251,7 @@ db_connect(value options, value args)
           case 0: SET_OPTION(OPT_COMPRESS, NULL);
           case 1: SET_OPTION(OPT_NAMED_PIPE, NULL);
           case 2: SET_CLIENT_FLAG(CLIENT_FOUND_ROWS);
-          default: invalid_argument("Mysql.connect: unknown option");
+          default: caml_invalid_argument("Mysql.connect: unknown option");
         }
       }
       options = Field(options, 1);
@@ -271,13 +272,13 @@ db_connect(value options, value args)
 
     free(host); free(db); free(pwd); free(user); free(socket);
 
-    if (!mysql) 
+    if (!mysql)
     {
       mysqlfailwith((char*)mysql_error(init));
     }
-    else 
+    else
     {
-      res = alloc_final(3, conn_finalize, 0, 1);
+      res = caml_alloc_final(3, conn_finalize, 0, 1);
       Field(res, 1) = (value)mysql;
       Field(res, 2) =  Val_true;
     }
@@ -287,7 +288,7 @@ db_connect(value options, value args)
 
 
 EXTERNAL value
-db_change_user(value v_dbd, value args) 
+db_change_user(value v_dbd, value args)
 {
   char *db;
   char *pwd;
@@ -333,17 +334,17 @@ db_list_dbs(value v_dbd, value pattern, value blah)
 
   n = mysql_num_rows(res);
 
-  if (n == 0) 
+  if (n == 0)
   {
     mysql_free_result(res);
     CAMLreturn(Val_none);
   }
 
-  dbs = alloc_tuple(n); /* Array */
+  dbs = caml_alloc_tuple(n); /* Array */
   i = 0;
-  while ((row = mysql_fetch_row(res)) != NULL) 
+  while ((row = mysql_fetch_row(res)) != NULL)
   {
-    Store_field(dbs, i, copy_string(row[0]));
+    Store_field(dbs, i, caml_copy_string(row[0]));
     i++;
   }
 
@@ -358,7 +359,7 @@ db_select_db(value v_dbd, value v_newdb)
   MYSQL* mysql = check_db(v_dbd, "select_db");
   char* newdb = strdup(String_val(v_newdb));
   my_bool ret;
- 
+
   caml_enter_blocking_section();
   ret = mysql_select_db(mysql, newdb);
   caml_leave_blocking_section();
@@ -395,7 +396,7 @@ db_ping(value dbd)
   MYSQL* db = check_db(dbd,"ping");
 
   caml_enter_blocking_section();
-  if (mysql_ping(db)) 
+  if (mysql_ping(db))
   {
     caml_leave_blocking_section();
     mysqlfailmsg("Mysql.ping: %s", mysql_error(db));
@@ -458,17 +459,17 @@ db_exec(value v_dbd, value v_sql)
   }
   else
   {
-    res = alloc_custom(&res_ops, sizeof(MYSQL_RES*), 0, 1);
+    res = caml_alloc_custom(&res_ops, sizeof(MYSQL_RES*), 0, 1);
     RESval(res) = mysql_store_result(mysql);
   }
 
   CAMLreturn(res);
 }
 
-/* 
+/*
  * db_fetch -- fetch one result tuple, represented as array of string
- * options.  In case a value is Null, the respective value is None. 
- * Returns (Some v) in case there is such a result and None otherwise. 
+ * options.  In case a value is Null, the respective value is None.
+ * Returns (Some v) in case there is such a result and None otherwise.
  * Moves the internal result cursor to the next tuple.
  */
 
@@ -481,42 +482,43 @@ db_fetch (value result)
   unsigned long *length;  /* array of long */
   MYSQL_RES *res;
   MYSQL_ROW row;
-  
+
   res = RESval(result);
-  if (!res) 
+  if (!res)
     mysqlfailwith("Mysql.fetch: result did not return fetchable data");
-  
+
   n = mysql_num_fields(res);
   if (n == 0)
     mysqlfailwith("Mysql.fetch: no columns");
-  
+
   row = mysql_fetch_row(res);
-  if (!row) 
+  if (!row)
     CAMLreturn(Val_none);
-  
+
   /* create Some([| f1; f2; .. ;fn |]) */
-  
+
   length = mysql_fetch_lengths(res);      /* length[] */
-  fields = alloc_tuple(n);                    /* array */
+  fields = caml_alloc_tuple(n);                    /* array */
   for (i=0;i<n;i++) {
     s = val_str_option(row[i], length[i]);
     Store_field(fields, i, s);
   }
-  
+
   CAMLreturn(Val_some(fields));
 }
 
 EXTERNAL value
-db_to_row(value result, value offset) {
-  int64 off = Int64_val(offset);
+db_to_row(value result, value offset)
+{
+  int64_t off = Int64_val(offset);
   MYSQL_RES *res;
 
   res = RESval(result);
-  if (!res) 
+  if (!res)
     mysqlfailwith("Mysql.to_row: result did not return fetchable data");
 
-  if (off < 0 || off > (int64)mysql_num_rows(res)-1)
-    invalid_argument("Mysql.to_row: offset out of range");
+  if (off < 0 || off > (int64_t)mysql_num_rows(res)-1)
+    caml_invalid_argument("Mysql.to_row: offset out of range");
 
   mysql_data_seek(res, off);
 
@@ -557,7 +559,7 @@ db_errmsg(value dbd)
  * db_escape - takes a string and escape all characters inside which
  * must be escaped inside MySQL strings.  This helps to construct SQL
  * statements easily.  Simply returns the new string including the
- * quotes. 
+ * quotes.
  */
 
 EXTERNAL value
@@ -568,16 +570,16 @@ db_escape(value str)
   char *buf;
   int len, esclen;
   CAMLlocal1(res);
-        
+
   s = String_val(str);
-  len = string_length(str);
-  buf = (char*) stat_alloc(2*len+1);
+  len = caml_string_length(str);
+  buf = (char*)caml_stat_alloc(2*len+1);
   esclen = mysql_escape_string(buf,s,len);
 
-  res = alloc_string(esclen);
+  res = caml_alloc_string(esclen);
   memcpy(String_val(res), buf, esclen);
-  stat_free(buf);
-  
+  caml_stat_free(buf);
+
   CAMLreturn(res);
 }
 
@@ -596,8 +598,8 @@ db_real_escape(value dbd, value str)
   s = String_val(str);
   len = caml_string_length(str);
   buf = (char*)caml_stat_alloc(2*len+1);
-  /* 
-   * mysql_real_escape doesn't perform network I/O, 
+  /*
+   * mysql_real_escape doesn't perform network I/O,
    * so no need for blocking section (and extra copying)
    * */
   esclen = mysql_real_escape_string(mysql,buf,s,len);
@@ -640,27 +642,27 @@ db_size(value result)
 {
   CAMLparam1(result);
   MYSQL_RES *res;
-  int64 size;
+  int64_t size;
 
   res = RESval(result);
   if (!res)
     size = 0;
   else
-    size = (int64)(mysql_num_rows(res));
-  
-  CAMLreturn(copy_int64(size));
+    size = (int64_t)mysql_num_rows(res);
+
+  CAMLreturn(caml_copy_int64(size));
 }
 
 EXTERNAL value
 db_affected(value dbd) {
   CAMLparam1(dbd);
-  CAMLreturn(copy_int64(mysql_affected_rows(DBDmysql(dbd))));
+  CAMLreturn(caml_copy_int64(mysql_affected_rows(DBDmysql(dbd))));
 }
 
 EXTERNAL value
 db_insert_id(value dbd) {
   CAMLparam1(dbd);
-  CAMLreturn(copy_int64(mysql_insert_id(DBDmysql(dbd))));
+  CAMLreturn(caml_copy_int64(mysql_insert_id(DBDmysql(dbd))));
 }
 
 EXTERNAL value
@@ -674,7 +676,7 @@ db_fields(value result)
     size = 0;
   else
     size = (long)(mysql_num_fields(res));
-  
+
   return Val_long(size);
 }
 
@@ -682,7 +684,7 @@ EXTERNAL value
 db_client_info(value unit) {
   CAMLparam1(unit);
   CAMLlocal1(info);
-  info = copy_string(mysql_get_client_info());
+  info = caml_copy_string(mysql_get_client_info());
   CAMLreturn(info);
 }
 
@@ -690,7 +692,7 @@ EXTERNAL value
 db_host_info(value dbd) {
   CAMLparam1(dbd);
   CAMLlocal1(info);
-  info = copy_string(mysql_get_host_info(DBDmysql(dbd)));
+  info = caml_copy_string(mysql_get_host_info(DBDmysql(dbd)));
   CAMLreturn(info);
 }
 
@@ -698,7 +700,7 @@ EXTERNAL value
 db_server_info(value dbd) {
   CAMLparam1(dbd);
   CAMLlocal1(info);
-  info = copy_string(mysql_get_server_info(DBDmysql(dbd)));
+  info = caml_copy_string(mysql_get_server_info(DBDmysql(dbd)));
   CAMLreturn(info);
 }
 
@@ -759,23 +761,23 @@ type2dbty (int type)
     {-1 /*default*/         , Val_long(UNKNOWN_TY)}
   };
   int i;
-  
+
   /* in principle using bsearch() would be better -- but how can
    * we know that the left side of the map is properly sorted? 
    */
 
   for (i=0; map[i].mysql != -1 && map[i].mysql != type; i++)
     /* empty */ ;
-  
+
   return map[i].caml;
 }
 
-value 
+value
 make_field(MYSQL_FIELD *f) {
   CAMLparam0();
   CAMLlocal5(out, data, name, table, def);
 
-  name = copy_string(f->name);
+  name = caml_copy_string(f->name);
 
   if (f->table)
     table = val_str_option(f->table, strlen(f->table));
@@ -787,7 +789,7 @@ make_field(MYSQL_FIELD *f) {
   else
     def = Val_none;
 
-  data = alloc_small(7, 0);
+  data = caml_alloc_small(7, 0);
   Field(data, 0) = name;
   Field(data, 1) = table;
   Field(data, 2) = def;
@@ -844,6 +846,9 @@ db_fetch_fields(value result) {
   MYSQL_FIELD *f;
   int i, n;
 
+  if (!res)
+    CAMLreturn(Val_none);
+
   n = mysql_num_fields(res);
 
   if (n == 0)
@@ -851,7 +856,7 @@ db_fetch_fields(value result) {
 
   f = mysql_fetch_fields(res);
 
-  fields = alloc_tuple(n);
+  fields = caml_alloc_tuple(n);
 
   for (i = 0; i < n; i++) {
     Store_field(fields, i, make_field(f+i));
@@ -863,7 +868,7 @@ db_fetch_fields(value result) {
 static void
 check_stmt(MYSQL_STMT* stmt, char *fun)
 {
-  if (!stmt) 
+  if (!stmt)
     mysqlfailmsg("Mysql.Prepared.%s called with closed statement", fun);
 }
 
@@ -915,12 +920,14 @@ caml_mysql_stmt_prepare(value v_dbd, value v_sql)
   if (ret)
   {
     const char* err = mysql_stmt_error(stmt);
+    char buf[1024];
+    snprintf(buf, sizeof buf, "Mysql.Prepared.create : mysql_stmt_prepare = %i. Query : %s. Error : %s",ret,String_val(v_sql),err);
     mysql_stmt_close(stmt);
     caml_leave_blocking_section();
-    mysqlfailmsg("Mysql.Prepared.create : mysql_stmt_prepare = %i. Query : %s. Error : %s",ret,String_val(v_sql),err);
+    mysqlfailwith(buf);
   }
   caml_leave_blocking_section();
-  res = alloc_custom(&stmt_ops, sizeof(MYSQL_STMT*), 0, 1);
+  res = caml_alloc_custom(&stmt_ops, sizeof(MYSQL_STMT*), 0, 1);
   STMTval(res) = stmt;
   CAMLreturn(res);
 }
@@ -1123,7 +1130,7 @@ caml_mysql_stmt_execute_gen(value v_stmt, value v_params, int with_null)
       mysqlfailwith("Prepared.execute : mysql_stmt_bind_result");
     }
   }
-  res = alloc_custom(&stmt_result_ops, sizeof(row_t*), 0, 1);
+  res = caml_alloc_custom(&stmt_result_ops, sizeof(row_t*), 0, 1);
   ROWval(res) = row;
   CAMLreturn(res);
 }
@@ -1164,7 +1171,7 @@ caml_mysql_stmt_affected(value stmt)
 {
   CAMLparam1(stmt);
   check_stmt(STMTval(stmt),"affected");
-  CAMLreturn(copy_int64(mysql_stmt_affected_rows(STMTval(stmt))));
+  CAMLreturn(caml_copy_int64(mysql_stmt_affected_rows(STMTval(stmt))));
 }
 
 EXTERNAL value
@@ -1172,7 +1179,7 @@ caml_mysql_stmt_insert_id(value stmt)
 {
   CAMLparam1(stmt);
   check_stmt(STMTval(stmt),"insert_id");
-  CAMLreturn(copy_int64(mysql_stmt_insert_id(STMTval(stmt))));
+  CAMLreturn(caml_copy_int64(mysql_stmt_insert_id(STMTval(stmt))));
 }
 
 EXTERNAL value
@@ -1190,9 +1197,8 @@ caml_mysql_stmt_result_metadata(value stmt)
     CAMLlocal1(res);
 
     check_stmt(STMTval(stmt), "result_metadata");
-    res = alloc_custom(&res_ops, sizeof(MYSQL_RES*), 0, 1);
+    res = caml_alloc_custom(&res_ops, sizeof(MYSQL_RES*), 0, 1);
     RESval(res) = mysql_stmt_result_metadata(STMTval(stmt));
 
     CAMLreturn(res);
 }
-

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/mysql-ocaml.git



More information about the Pkg-ocaml-maint-commits mailing list