paurkedal / ocaml-caqti

Cooperative-threaded access to relational data
https://paurkedal.github.io/ocaml-caqti/index.html
GNU Lesser General Public License v3.0
303 stars 36 forks source link

Support PostgreSQL 12? #32

Closed koji-k closed 4 years ago

koji-k commented 4 years ago

I try to use PostgreSQL Driver with PostgreSQL 12.1 There is no problem to install the libraries. But when i execute dune utop, appear following error.

[koji:hello_opium]$ dune utop mylib
_build/default/mylib/.utop/utop.exe: symbol lookup error: _build/default/mylib/.utop/utop.exe: undefined symbol: PQresultMemorySize

When it use PostgreSQL 11.6, there is no problem. Does not yet this library support PostgreSQL 12?

My denends entry on opam file is following.

depends: [
    "dune" {build}
    "alcotest"
    "merlin"
    "ocp-indent"
    "utop"
    "ssl"
    "lwt_ssl"
    "cohttp"
    "lwt"
    "lwt_ppx"
    "caqti"
    "caqti-lwt"
    "caqti-driver-postgresql"
    "js_of_ocaml"
    "jwto"
    "mtime"
    "opium" {= "0.17.1"}
]
paurkedal commented 4 years ago

I don't think this indicates lack of support for PostgreSQL, since the PQresultMemorySize function is still present in that version according to the documentation. Some possible explanation could be that the postgresql package was compiled for a different version of the library than what is loaded by utop. You can try ldd on the .cmxs files to see what will be linked in, though this does not tell which libraries they were originally compiled against. Note that LD_LIBRARY_PATH if set will determine runtime linking, while compile-time linking may be determined by other mechanisms like pkg-config and ad-hoc environment variables.

Another explanation could be that libpq is not linked in at all, and the shown symbol just happens to be the one to trigger the error. Listing caqti-driver-postgresql in the dune libraries should be sufficient, but try to also add postgresql in case there is an issue with some of the META files involved.

koji-k commented 4 years ago

Thank you for your reply! This problem has resolved.

I had not set LD_LIBRARY_PATH. This was a reason of this problem. I compiled and installed PostgreSQL into a directory that is under the user home directory.

./configure --prefix=$HOME/opt/postgresql/12.1
make
make install

Then set $PGDATA, and install caqti via opam.

PostgreSQL 11 and 9 had no problem. But a problem occurred by 12 as i described in this issue.

Then i have set LD_LIBRARY_PATH

LD_LIBRARY_PATH=$HOME/opt/postgresql/12.1/lib 
export LD_LIBRARY_PATH 
dune utop   

Now it is working all correct! Sorry. this problem was reasoned my PostgreSQL's environment.

paurkedal commented 4 years ago

Good you got it sorted out!