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

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

commit 4bbaf48f03500061a0d071e47e5741af062d1a8d
Author: Stephane Glondu <st...@glondu.net>
Date:   Wed Aug 3 15:37:18 2016 +0200

    Imported Upstream version 3.0.0
---
 CHANGES.txt         |  4 +++
 INSTALL.txt         |  6 ++--
 README.md           | 26 +++++++++++++++-
 _oasis              | 16 +++++++++-
 _tags               |  4 ++-
 lib/META            |  4 +--
 lib/sqlite3.ml      |  6 ++--
 lib/sqlite3.mli     |  3 +-
 lib/sqlite3_stubs.c |  4 +++
 setup.ml            | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 test/test_error.ml  | 20 ++++++++++++
 11 files changed, 167 insertions(+), 15 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 630ebb2..7677443 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+2015-08-29: Added user function error handling (major API change).
+
+            Thanks to Joseph Young for this patch!
+
 2015-01-29: Fixed a build problem due to Oasis/ocamlbuild inconsistency.
 
             Thanks to Leonid Rozenberg <leon...@gmail.com> for this patch!
diff --git a/INSTALL.txt b/INSTALL.txt
index 7f0aa6e..07f6f26 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -1,5 +1,5 @@
 (* OASIS_START *)
-(* DO NOT EDIT (digest: dd3cb7c4515a29aaa64bbcda8b16a781) *)
+(* DO NOT EDIT (digest: ca1786acdafc1c9f2a8fdd7a5247f689) *)
 
 This is the INSTALL file for the sqlite3 distribution.
 
@@ -11,8 +11,8 @@ Dependencies
 
 In order to compile this package, you will need:
 
-* ocaml (>= 3.12) for all, test test_agg, test test_db, test test_exec,
-  test test_fun, test test_stmt, doc API
+* ocaml (>= 3.12) for all, test test_agg, test test_db, test test_error,
+  test test_exec, test test_fun, test test_stmt, doc API
 * findlib (>= 1.3.1)
 
 Installing
diff --git a/README.md b/README.md
index 86e7193..a5ef00f 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,30 @@ SQLite3 has its own [online 
documentation](http://www.sqlite.org/docs.html).
 The `test`-directory in this distribution contains a few simple examples
 for testing various features of this library.
 
+### Build issues
+
+SQLite3-OCaml depends on `pkg-config` to locate and compile against an
+[SQLite3](http://www.sqlite.org) library.
+
+If the SQLite3 version is larger than or equal to 3.3.7, it is assumed that it
+supports [Run-Time Loadable Extensions](http://www.sqlite.org/loadext.html).
+If this feature has been explicitly disabled in the library, the build will
+fail with:
+
+```
+Undefined symbols for architecture ...:
+  "_sqlite3_enable_load_extension", referenced from:
+      _caml_sqlite3_enable_load_extension in 
libsqlite3_stubs.a(sqlite3_stubs.o)
+     (maybe you meant: _caml_sqlite3_enable_load_extension)
+```
+
+  * You can check if your library is missing loadable extensions by searching
+    it for the string `OMIT_LOAD_EXTENSION`.
+
+  * If you need to change where `pkg-config` will look for the SQLite3
+    library, set the `PKG_CONFIG_PATH` environment variable to the new
+    directory.
+
 Credits
 -------
 
@@ -59,4 +83,4 @@ Up-to-date information should be available at:
 
 Enjoy!
 
-Markus Mottl on July 10, 2012
+Markus Mottl on February 9, 2015
diff --git a/_oasis b/_oasis
index d50d156..ecdfa45 100644
--- a/_oasis
+++ b/_oasis
@@ -1,6 +1,6 @@
 OASISFormat:      0.4
 Name:             sqlite3
-Version:          2.0.9
+Version:          3.0.0
 Synopsis:         sqlite3-ocaml - SQLite3 bindings
 Description:      sqlite3-ocaml is an OCaml library with bindings to the
                   SQLite3 client API.  Sqlite3 is a self-contained, serverless,
@@ -112,6 +112,20 @@ Test test_stmt
   WorkingDirectory:   test
   PostCommand:        rm t
 
+Executable test_error
+  Path:           test
+  MainIs:         test_error.ml
+  Build$:         flag(tests)
+  Install:        false
+  BuildDepends:   sqlite3
+  CompiledObject: best
+
+Test test_error
+  Run$:               flag(tests)
+  Command:            $test_error
+  WorkingDirectory:   test
+  PostCommand:        rm t
+
 #
 
 Document API
diff --git a/_tags b/_tags
index 54423cd..89831db 100644
--- a/_tags
+++ b/_tags
@@ -1,5 +1,5 @@
 # OASIS_START
-# DO NOT EDIT (digest: 3fd9cff80b9dcdb8cdf52535e63056b7)
+# DO NOT EDIT (digest: 861fe4675b9540776aedfbf5f54a58d7)
 # Ignore VCS directories, you can use the same kind of rule outside
 # OASIS_START/STOP if you want to exclude directories that contains
 # useless stuff for the build process
@@ -36,6 +36,8 @@ true: annot, bin_annot
 <test/*.ml{,i,y}>: pkg_str
 # Executable test_stmt
 <test/test_stmt.{native,byte}>: use_sqlite3
+# Executable test_error
+<test/test_error.{native,byte}>: use_sqlite3
 <test/*.ml{,i,y}>: use_sqlite3
 # OASIS_STOP
 
diff --git a/lib/META b/lib/META
index d5cd9b6..83b8d13 100644
--- a/lib/META
+++ b/lib/META
@@ -1,6 +1,6 @@
 # OASIS_START
-# DO NOT EDIT (digest: f2411e0a0d6c8bb3fee87a6bf3f386db)
-version = "2.0.9"
+# DO NOT EDIT (digest: fc7db74acb0529e253896e714e0a428b)
+version = "3.0.0"
 description = "sqlite3-ocaml - SQLite3 bindings"
 archive(byte) = "sqlite3.cma"
 archive(byte, plugin) = "sqlite3.cma"
diff --git a/lib/sqlite3.ml b/lib/sqlite3.ml
index 3c2c53d..1eb25be 100644
--- a/lib/sqlite3.ml
+++ b/lib/sqlite3.ml
@@ -112,12 +112,13 @@ module Data = struct
     | FLOAT of float
     | TEXT of string
     | BLOB of string
+    | ERROR of string
 
   let to_string = function
     | NONE | NULL -> ""
     | INT i -> Int64.to_string i
     | FLOAT f -> string_of_float f
-    | TEXT t | BLOB t -> t
+    | TEXT t | BLOB t | ERROR t -> t
 
   let to_string_debug = function
     | NONE -> "NONE"
@@ -126,6 +127,7 @@ module Data = struct
     | FLOAT f -> sprintf "FLOAT <%f>" f
     | TEXT t -> sprintf "TEXT <%S>" t
     | BLOB b -> sprintf "BLOB <%d>" (String.length b)
+    | ERROR e -> sprintf "ERROR <%S>" e
 end
 
 type header = string
@@ -222,7 +224,7 @@ external clear_bindings : stmt -> Rc.t = 
"caml_sqlite3_clear_bindings"
 external busy_timeout : db -> int -> unit = "caml_sqlite3_busy_timeout"
 
 external enable_load_extension :
-  db -> bool -> bool = "caml_sqlite3_enable_load_extension" "noalloc"
+  db -> bool -> bool = "caml_sqlite3_enable_load_extension"
 
 let row_data stmt = Array.init (data_count stmt) (column stmt)
 let row_names stmt = Array.init (data_count stmt) (column_name stmt)
diff --git a/lib/sqlite3.mli b/lib/sqlite3.mli
index 21682cd..0cc7c6a 100644
--- a/lib/sqlite3.mli
+++ b/lib/sqlite3.mli
@@ -142,6 +142,7 @@ module Data : sig
     | FLOAT of float
     | TEXT of string
     | BLOB of string
+    | ERROR of string
 
   val to_string : t -> string
   (** [to_string data] converts [data] to a string.  Both [NONE] and
@@ -192,7 +193,7 @@ external db_close : db -> bool = "caml_sqlite3_close"
 *)
 
 external enable_load_extension :
-  db -> bool -> bool = "caml_sqlite3_enable_load_extension" "noalloc"
+  db -> bool -> bool = "caml_sqlite3_enable_load_extension"
 (** [enable_load_extension db onoff] enable/disable the sqlite3 load
     extension.  @return [false] if the operation fails, [true]
     otherwise. *)
diff --git a/lib/sqlite3_stubs.c b/lib/sqlite3_stubs.c
index d4a6bf2..2abcedb 100644
--- a/lib/sqlite3_stubs.c
+++ b/lib/sqlite3_stubs.c
@@ -847,6 +847,7 @@ CAMLprim value caml_sqlite3_bind(value v_stmt, value 
v_index, value v_data)
                                         String_val(v_field),
                                         caml_string_length(v_field),
                                         SQLITE_TRANSIENT));
+      case 4 : return Val_rc(SQLITE_ERROR);
     }
   }
   return Val_rc(SQLITE_ERROR);
@@ -1023,6 +1024,9 @@ static inline void set_sqlite3_result(sqlite3_context 
*ctx, value v_res)
         sqlite3_result_blob(
           ctx, String_val(v), caml_string_length(v), SQLITE_TRANSIENT);
         break;
+      case 4 :
+        sqlite3_result_error(ctx, String_val(v), caml_string_length(v));
+        break;
       default :
         sqlite3_result_error(ctx, "unknown value returned by callback", -1);
     }
diff --git a/setup.ml b/setup.ml
index 1cf9cd8..19c2d02 100644
--- a/setup.ml
+++ b/setup.ml
@@ -1,7 +1,7 @@
 (* setup.ml generated for the first time by OASIS v0.3.0 *)
 
 (* OASIS_START *)
-(* DO NOT EDIT (digest: 3743f09fc72577ad3af91b1ab47847de) *)
+(* DO NOT EDIT (digest: 51146b2c34f38bae10732375ae42aa0e) *)
 (*
    Regenerated by OASIS v0.4.5
    Visit http://oasis.forge.ocamlcore.org for more information and
@@ -6844,6 +6844,14 @@ let setup_t =
                    [(OASISExpr.EBool true, ("$test_stmt", []))];
                  cmd_clean = [(OASISExpr.EBool true, None)];
                  cmd_distclean = [(OASISExpr.EBool true, None)]
+              });
+          ("test_error",
+            CustomPlugin.Test.main
+              {
+                 CustomPlugin.cmd_main =
+                   [(OASISExpr.EBool true, ("$test_error", []))];
+                 cmd_clean = [(OASISExpr.EBool true, None)];
+                 cmd_distclean = [(OASISExpr.EBool true, None)]
               })
        ];
      doc =
@@ -6896,6 +6904,14 @@ let setup_t =
                    [(OASISExpr.EBool true, ("$test_stmt", []))];
                  cmd_clean = [(OASISExpr.EBool true, None)];
                  cmd_distclean = [(OASISExpr.EBool true, None)]
+              });
+          ("test_error",
+            CustomPlugin.Test.clean
+              {
+                 CustomPlugin.cmd_main =
+                   [(OASISExpr.EBool true, ("$test_error", []))];
+                 cmd_clean = [(OASISExpr.EBool true, None)];
+                 cmd_distclean = [(OASISExpr.EBool true, None)]
               })
        ];
      clean_doc =
@@ -6946,6 +6962,14 @@ let setup_t =
                    [(OASISExpr.EBool true, ("$test_stmt", []))];
                  cmd_clean = [(OASISExpr.EBool true, None)];
                  cmd_distclean = [(OASISExpr.EBool true, None)]
+              });
+          ("test_error",
+            CustomPlugin.Test.distclean
+              {
+                 CustomPlugin.cmd_main =
+                   [(OASISExpr.EBool true, ("$test_error", []))];
+                 cmd_clean = [(OASISExpr.EBool true, None)];
+                 cmd_distclean = [(OASISExpr.EBool true, None)]
               })
        ];
      distclean_doc = [];
@@ -6957,7 +6981,7 @@ let setup_t =
           alpha_features = [];
           beta_features = [];
           name = "sqlite3";
-          version = "2.0.9";
+          version = "3.0.0";
           license =
             OASISLicense.DEP5License
               (OASISLicense.DEP5Unit
@@ -7372,6 +7396,63 @@ let setup_t =
                       test_tools =
                         [ExternalTool "ocamldoc"; ExternalTool "ocamlbuild"]
                    });
+               Executable
+                 ({
+                     cs_name = "test_error";
+                     cs_data = PropList.Data.create ();
+                     cs_plugin_data = []
+                  },
+                   {
+                      bs_build =
+                        [
+                           (OASISExpr.EBool true, false);
+                           (OASISExpr.EFlag "tests", true)
+                        ];
+                      bs_install = [(OASISExpr.EBool true, false)];
+                      bs_path = "test";
+                      bs_compiled_object = Best;
+                      bs_build_depends = [InternalLibrary "sqlite3"];
+                      bs_build_tools =
+                        [ExternalTool "ocamldoc"; ExternalTool "ocamlbuild"];
+                      bs_c_sources = [];
+                      bs_data_files = [];
+                      bs_ccopt = [(OASISExpr.EBool true, [])];
+                      bs_cclib = [(OASISExpr.EBool true, [])];
+                      bs_dlllib = [(OASISExpr.EBool true, [])];
+                      bs_dllpath = [(OASISExpr.EBool true, [])];
+                      bs_byteopt = [(OASISExpr.EBool true, [])];
+                      bs_nativeopt = [(OASISExpr.EBool true, [])]
+                   },
+                   {exec_custom = false; exec_main_is = "test_error.ml"});
+               Test
+                 ({
+                     cs_name = "test_error";
+                     cs_data = PropList.Data.create ();
+                     cs_plugin_data = []
+                  },
+                   {
+                      test_type = (`Test, "custom", Some "0.4");
+                      test_command =
+                        [(OASISExpr.EBool true, ("$test_error", []))];
+                      test_custom =
+                        {
+                           pre_command = [(OASISExpr.EBool true, None)];
+                           post_command =
+                             [(OASISExpr.EBool true, Some (("rm", ["t"])))]
+                        };
+                      test_working_directory = Some "test";
+                      test_run =
+                        [
+                           (OASISExpr.ENot (OASISExpr.EFlag "tests"), false);
+                           (OASISExpr.EFlag "tests", false);
+                           (OASISExpr.EAnd
+                              (OASISExpr.EFlag "tests",
+                                OASISExpr.EFlag "tests"),
+                             true)
+                        ];
+                      test_tools =
+                        [ExternalTool "ocamldoc"; ExternalTool "ocamlbuild"]
+                   });
                Doc
                  ({
                      cs_name = "API";
@@ -7430,7 +7511,7 @@ let setup_t =
        };
      oasis_fn = Some "_oasis";
      oasis_version = "0.4.5";
-     oasis_digest = Some "\144 �N\011f�\016��BE���";
+     oasis_digest = Some "��]]�\1486t\133\000&�� M�";
      oasis_exec = None;
      oasis_setup_args = [];
      setup_update = false
@@ -7438,6 +7519,6 @@ let setup_t =
 
 let setup () = BaseSetup.setup setup_t;;
 
-# 7442 "setup.ml"
+# 7523 "setup.ml"
 (* OASIS_STOP *)
 let () = setup ();;
diff --git a/test/test_error.ml b/test/test_error.ml
new file mode 100644
index 0000000..2b805f8
--- /dev/null
+++ b/test/test_error.ml
@@ -0,0 +1,20 @@
+open Sqlite3
+
+(* Tests our ability to return an error from a user defined function *)
+let () =
+  let db = db_open "t" in
+  create_fun0 db "MYERROR" (fun () -> Data.ERROR "This function always 
errors");
+  let res = exec db "SELECT MYERROR();" in
+  match res with
+  | Rc.ERROR -> print_endline (errmsg db)
+  | x -> prerr_endline ("Should have thrown an error: " ^ Rc.to_string x)
+
+(* Insures that we can't bind an error to a query *)
+let () =
+  let db = db_open "t" in
+  let _ : Rc.t = exec db "CREATE TABLE foo (val text);" in
+  let s = Sqlite3.prepare db "INSERT INTO foo values (?);" in
+  let res = Sqlite3.bind s 1 (Sqlite3.Data.ERROR "Should be impossible") in
+  match res with
+  | Rc.ERROR -> print_endline ("Bind threw an error")
+  | x -> prerr_endline ("Should have thrown an error: " ^ Rc.to_string x)

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

_______________________________________________
Pkg-ocaml-maint-commits mailing list
Pkg-ocaml-maint-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-ocaml-maint-commits

Reply via email to