You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the README says it will be taken as a unix socket if PGHOST has a 1st char of /.
that doesn't work because the code (describe_connection) only does the check on ~host parameter values, not both.
so, in fact, pgocaml's interception of PGHOST prevents it from being set with a socket directory since an exception is raised trying to open it as a network address.
here's my fix:
diff --git a/src/PGOCaml_generic.ml b/src/PGOCaml_generic.ml
index a1a0567..536ee79 100644
--- a/src/PGOCaml_generic.ml
+++ b/src/PGOCaml_generic.ml
@@ -291,0 +291,0 @@ type uuid = string
@@ -1022,7 +1019,11 @@ let describe_connection ?host ?port ?user ?password ?database
`Unix_domain_socket_dir s
| None, None ->
try
- `Hostname (Sys.getenv "PGHOST")
+ let h=Sys.getenv "PGHOST" in
+ if String.length h > 0 && String.get h 0 = '/' then
+ `Unix_domain_socket_dir h
+ else
+ `Hostname h
with
Not_found -> (* fall back on Unix domain socket. *)
`Unix_domain_socket_dir PGOCaml_config.default_unix_domain_socket_dir
I also found a problem in my installation with the generated cfg file
PGOCaml_config.ml which confounded the above issue.
installing via opam gave this:
let default_unix_domain_socket_dir = "/tmp"
bizarre as the /var/run/postgresql directory does exist.
deleting this cfg file in the dune _build directory under opam and rebuilding/reinstalling regenerated it correctly!
on another note a source of great frustration was the unchanging behaviour of the test executable when changing PGXXX vars.
even after I grokked it I still tripped up again and again.
eventually I added this to the test dune stanza:
... and the ppx stage of db access worked reliably during experimentation/dev/test without further stumbling! I recommend this or a cut-down version is added to the test case and highlighted to potential users!
lastly, note the PGCOMMENT_SRC_LOC - the README.md lists it without the PG prefix incorrectly.
The text was updated successfully, but these errors were encountered:
progman1
changed the title
PGHOST doc/code mistmatch
PGHOST doc/code mismatch
Mar 1, 2022
the README says it will be taken as a unix socket if PGHOST has a 1st char of /.
that doesn't work because the code (describe_connection) only does the check on ~host parameter values, not both.
so, in fact, pgocaml's interception of PGHOST prevents it from being set with a socket directory since an exception is raised trying to open it as a network address.
here's my fix:
I also found a problem in my installation with the generated cfg file
PGOCaml_config.ml which confounded the above issue.
installing via opam gave this:
bizarre as the /var/run/postgresql directory does exist.
deleting this cfg file in the dune _build directory under opam and rebuilding/reinstalling regenerated it correctly!
on another note a source of great frustration was the unchanging behaviour of the test executable when changing PGXXX vars.
even after I grokked it I still tripped up again and again.
eventually I added this to the test dune stanza:
... and the ppx stage of db access worked reliably during experimentation/dev/test without further stumbling! I recommend this or a cut-down version is added to the test case and highlighted to potential users!
lastly, note the PGCOMMENT_SRC_LOC - the README.md lists it without the PG prefix incorrectly.
The text was updated successfully, but these errors were encountered: