EnterpriseDB / mysql_fdw

PostgreSQL foreign data wrapper for MySQL
Other
521 stars 160 forks source link

Failing to install mysql_fdw #284

Open DavidBuch1 opened 6 months ago

DavidBuch1 commented 6 months ago

Hi I am trying to install this on Ubuntu 22.04 for mysql 8.0.35, but I am getting this error: gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC -I/usr/include/mysql -D _MYSQL_LIBNAME=\"libmysqlclient.so\" -I. -I./ -I/usr/include/postgresql/15/server -I/usr/include/postgresql/internal -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -c -o connection.o connection.c make: gcc: Not a directory make: *** [: connection.o] Error 127

I have installed the c API I think - its not very clear which packages I need . (Postgres version 15)

Your help/advice would be most appreciated

thanks!

devrimgunduz commented 6 months ago

apt-get install gcc

DavidBuch1 commented 6 months ago

Hi Thanks for that. I have managed to install successfully on my development server (postgres 15), however on my production server I have both Postgres 15 and 16. We are not yet using 16 as we still need to do an upgrade. However when I try and install this, I am now getting this error sudo make USE_PGXS=1 make: mysql_config: No such file or directory make: mysql_config: No such file or directory gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC -fvisibility=hidden -D _MYSQL_LIBNAME=\"libmysqlclient.so\" -I. -I./ -I/usr/include/postgresql/16/server -I/usr/include/postgresql/internal -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -c -o connection.o connection.c connection.c:15:10: fatal error: postgres.h: No such file or directory 15 | #include "postgres.h" | ^~~~ compilation terminated. make: *** [: connection.o] Error 1

So it looks as if its confusing the two?

this is the path postgres.h does exist in /usr/include/postgresql/15/server/

/usr/include/postgresql/15/server:/usr/include/postgresql/15/server:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

thanks!!

devrimgunduz commented 6 months ago

Why don't you use PostgreSQL APT repository?

https://wiki.postgresql.org/wiki/Apt

It has mysql_fdw . No need to compile. It may even also be included in Ubuntu.

FWIW, you also need the development libraries of mysql and PostgreSQL to compile mysql_fdw. I'm not an Ubuntu user, don't remember the exact package names, but IIRC PostgreSQL package name is postgresql-server-dev or something.

DavidBuch1 commented 6 months ago

We already have postgres installed and running. This is a production server, so I cannot just reinstall stuff. we have the exact same installation on our development server apart from Postgres 16. It seems to be the fact that I have two version on the same machine thats causing a conflict I think if the script could be modified to work with a specific version only, it would help?

DavidBuch1 commented 6 months ago

ok, so I have resolved the issue by completely removing and purging postgres 16. Once I did that, then the makefile ran perfectly, so there seems to be a problem with running this script with two versions of postgres on the same machine (ubuntu 22.045)

AdamKearn commented 2 months ago

I'm getting the exact same issue... but mine is inside a docker container. Our image is based off this version supabase/postgres:15.1.0.54-rc0

We then manually install the mysql_fdw ontop of this. It has been working for well over a year and now just suddenly stopped working. ;(

FROM supabase/postgres:15.1.0.54-rc0

ARG postgresql_major=15
ARG myqld_fdw_release=2_9_1

ADD https://github.com/EnterpriseDB/mysql_fdw/archive/refs/tags/REL-${myqld_fdw_release}.tar.gz \
    /tmp/mysql-fdw.tar.gz

RUN tar -xvf /tmp/mysql-fdw.tar.gz -C /tmp --one-top-level --strip-components 1 && \
    rm -rf /tmp/mysql-fdw.tar.gz

RUN apt-get update && apt-get install -y --no-install-recommends \
    postgresql-server-dev-${postgresql_major} \
    gcc \
    build-essential \
    make \
    libmariadb-dev-compat \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /tmp/mysql-fdw

RUN export PATH=/usr/local/pgsql/bin/:$PATH && export PATH=/usr/local/mysql/bin/:$PATH
RUN make USE_PGXS=1
RUN make USE_PGXS=1 install
surajkharage19 commented 2 months ago

Hi @AdamKearn,

I am not sure what exact error you are getting here. I can see the above discussion has talked about 2 different errors. Do you have the same environment?

As Devrim suggested above, Why don't you use PostgreSQL APT repository instead of supabase/postgres:15.1.0.54-rc0?

varshamehtre commented 2 months ago

Hi @AdamKearn, I tried the dockerfile commands mentioned by you. Error which I encountered is about clang-11: SOURCE -I/usr/include/libxml2 -flto=thin -emit-llvm -c -o connection.bc connection.c 11 1.857 make: /usr/bin/clang-11: No such file or directory** 11 1.857 make: *** [/usr/lib/postgresql/15/lib/pgxs/src/makefiles/../../src/Makefile.global:1080: connection.bc] Error 127

So, I added packages for llvm-11 and clang-11 to Dockerfile and could build the image using dockerfile.

RUN apt-get update && apt-get install -y --no-install-recommends clang-11 llvm-11 \ postgresql-server-dev-${postgresql_major} \