1. Jean-Charles Campagne
  2. postgresql-ocaml

Commits

Markus Mottl  committed d75899a

More fixes for conndefaults bindings

  • Participants
  • Parent commits 44ce43c
  • Branches default

Comments (0)

Files changed (5)

File Changelog

View file
  • Ignore whitespace
+2011-05-23:  Fixed conndefaults bindings some more due to unclear PostgreSQL
+             documentation.
+
+             Thanks to Vijai Lulla <vijaylulla@gmail.com> for the bug report!
+
 2011-05-21:  Fixed GC bug in conndefaults function.
 
              Thanks to Vijai Lulla <vijaylulla@gmail.com> for the bug report!

File lib/META

View file
  • Ignore whitespace
 name="postgresql"
-version="1.15.0"
+version="1.16.0"
 description="PostgreSQL bindings for OCaml"
 requires="unix, bigarray"
 archive(byte)="postgresql.cma"

File lib/postgresql.ml

View file
  • Ignore whitespace
 type conninfo_option =
   {
     cio_keyword : string;
-    cio_envvar : string;
+    cio_envvar : string option;
     cio_compiled : string option;
     cio_val : string option;
     cio_label : string;

File lib/postgresql.mli

View file
  • Ignore whitespace
 type conninfo_option =
   {
     cio_keyword : string;  (** Keyword of option *)
-    cio_envvar : string;  (** Fallback environment variable name *)
+    cio_envvar : string option;  (** Fallback environment variable name *)
     cio_compiled : string option;  (** Fallback compiled in default value *)
     cio_val : string option;  (** Current value of option, or NULL *)
     cio_label : string;  (** Label for field in connect dialog *)

File lib/postgresql_stubs.c

View file
  • Ignore whitespace
   while (p->keyword != NULL) p++;
 
   n = p - cios;
+  p = cios;
   v_res = caml_alloc_tuple(n);
 
-  for (i = 0; i < n; i++, cios++) {
+  for (i = 0; i < n; i++, p++) {
     value v_field;
     v_el = caml_alloc_small(7, 0);
     for (j = 0; j < 7; j++) Field(v_el, j) = v_None;
     Store_field(v_res, i, v_el);
-    v_field = caml_copy_string(cios->keyword);
+    v_field = caml_copy_string(p->keyword);
     Field(v_el, 0) = v_field;
-    v_field = caml_copy_string(cios->envvar);
-    caml_modify(&Field(v_el, 1), v_field);
-    if (cios->compiled) {
-      v_field = make_some(caml_copy_string(cios->compiled));
+    if (p->envvar) {
+      v_field = make_some(caml_copy_string(p->envvar));
+      caml_modify(&Field(v_el, 1), v_field);
+    }
+    if (p->compiled) {
+      v_field = make_some(caml_copy_string(p->compiled));
       caml_modify(&Field(v_el, 2), v_field);
     };
-    if (cios->val) {
-      v_field = make_some(caml_copy_string(cios->val));
+    if (p->val) {
+      v_field = make_some(caml_copy_string(p->val));
       caml_modify(&Field(v_el, 3), v_field);
     };
-    v_field = caml_copy_string(cios->label);
+    v_field = caml_copy_string(p->label);
     caml_modify(&Field(v_el, 4), v_field);
-    v_field = caml_copy_string(cios->dispchar);
+    v_field = caml_copy_string(p->dispchar);
     caml_modify(&Field(v_el, 5), v_field);
-    caml_modify(&Field(v_el, 6), Val_int(cios->dispsize));
+    caml_modify(&Field(v_el, 6), Val_int(p->dispsize));
   };
 
+  PQconninfoFree(cios);
+
   CAMLreturn(v_res);
 }