caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Toby Allsopp <toby@mi6.gen.nz>
To: caml-list@inria.fr
Cc: "Mike Lin" <mikelin@mit.edu>
Subject: Re: sqlite3 bindings
Date: Thu, 20 Jul 2006 20:45:34 +1200	[thread overview]
Message-ID: <87lkqowtox.fsf@candyboy.here> (raw)
In-Reply-To: <87psg29d0r.fsf@candyboy.here>

[-- Attachment #1: Type: text/plain, Size: 484 bytes --]

Toby Allsopp writes:

> Mike Lin writes:
>
>> Hi, does anyone know how (if) the available ocaml sqlite bindings work with
>> recent versions of sqlite (namely 3.x.x)?
>
> http://metamatix.org/~ocaml/ocaml_sqlite3.html
>
> I've used this and it works fine, although there is a minor bug that
> causes seg faults in certain situations that I can't currently
> recall.  I have a patch that I will send next week from work.

Here's the patch that I've been using to great effect.

Toby.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ocaml-sqlite3.patch --]
[-- Type: text/x-patch, Size: 1169 bytes --]

Index: sqlite3_stubs.c
===================================================================
--- sqlite3_stubs.c	(.../ocaml-sqlite3-0.2.0)	(revision 2276)
+++ sqlite3_stubs.c	(.../T-mtc-120_06)	(revision 2276)
@@ -517,8 +517,8 @@
 
    const char *str = sqlite3_bind_parameter_name(stmt,i);
    if( str ) {
+      tmp             = copy_string(str); /* tmp is needed to make GC happy! */
       result          = alloc_small(1,0);
-      tmp             = copy_string(str); /* tmp is needed to make GC happy! */
       Field(result,0) = tmp;
       CAMLreturn(result);
    } else {
@@ -745,13 +745,13 @@
    switch(sqlite3_column_type(stmt,i)) {
       /* WARNING : we need the tmp variable to make GC happy! */
    case SQLITE_INTEGER:
+      tmp    = copy_int64(sqlite3_column_int64(stmt,i));
       result = alloc_small(1,0);
-      tmp    = copy_int64(sqlite3_column_int64(stmt,i));
       Field(result,0)=tmp;
       break;
    case SQLITE_FLOAT:
+      tmp    = copy_double(sqlite3_column_double(stmt,i));
       result = alloc_small(1,1);
-      tmp    = copy_double(sqlite3_column_double(stmt,i));
       Field(result,0)=tmp;
       break;
    case SQLITE3_TEXT:

      reply	other threads:[~2006-07-20  9:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-14 23:46 Mike Lin
2006-07-15  2:05 ` [Caml-list] " Ted Kremenek
2006-07-15  2:19 ` Toby Allsopp
2006-07-20  8:45   ` Toby Allsopp [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lkqowtox.fsf@candyboy.here \
    --to=toby@mi6.gen.nz \
    --cc=caml-list@inria.fr \
    --cc=mikelin@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).