tds-fdw / tds_fdw

A PostgreSQL foreign data wrapper to connect to TDS databases (Sybase and Microsoft SQL Server)
Other
379 stars 102 forks source link

I receive error while installing tds_fdw. #319

Open yozdas opened 2 years ago

yozdas commented 2 years ago

i have a postgresql 14 installed on Debian 11 Bullseye, and i want to install tds_fdw on it, but when i run the code make USE_PGXS=1 i receive 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 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC -I./include/ -fvisibility=hidden  -I. -I./ -I/usr/include/postgresql/14/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2   -c -o src/tds_fdw.o src/tds_fdw.c
src/tds_fdw.c:32:10: fatal error: postgres.h: No such file or directory
    32 | #include "postgres.h"
       |          ^~~~~~~~~~~~
 compilation terminated.
 make: *** [<builtin>: src/tds_fdw.o] Error 1

later i tried to run; sudo make USE_PGXS=1 PG_CONFIG=/usr/lib/postgresql/14/bin/ but i receive;

make: /usr/lib/postgresql/14/bin/: Permission denied
make: Nothing to be done for 'all'.

Operating system

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Version of tds_fdw

Latest
2.0.3

Version of PostgreSQL

                                                           version                                                           
-----------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 14.5 (Debian 14.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit

Version of FreeTDS

ii  freetds-common                1.2.3-1                        all          configuration files for FreeTDS SQL client libraries
ii  freetds-dev                   1.2.3-1                        amd64        MS SQL and Sybase client library (static libs and headers)

dependencies like;

libsybdb5 freetds-dev freetds-common
gnupg gcc make

are installed.

what is wrong?

yozdas commented 2 years ago

i followed @eulerto 's suggestion and installed postgresql-server-dev-14 but i received errors below;

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 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC -I./include/ -fvisibility=hidden  -I. -I./ -I/usr/include/postgresql/14/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2   -c -o src/tds_fdw.o src/tds_fdw.c
In file included from /usr/include/postgresql/14/server/postgres.h:47,
                 from src/tds_fdw.c:32:
src/tds_fdw.c: In function ‘tdsGetRowCountShowPlanAll’:
/usr/include/postgresql/14/server/utils/elog.h:136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
  136 |  do { \
      |     ^
/usr/include/postgresql/14/server/utils/elog.h:158:2: note: in expansion of macro ‘ereport_domain’
  158 |  ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
      |  ^~~~~~~~~~~~~~
src/tds_fdw.c:808:6: note: in expansion of macro ‘ereport’
  808 |      ereport(ERROR,
      |      ^~~~~~~
src/tds_fdw.c:813:5: note: here
  813 |     case FAIL:
      |     ^~~~
In file included from /usr/include/postgresql/14/server/postgres.h:47,
                 from src/tds_fdw.c:32:
/usr/include/postgresql/14/server/utils/elog.h:136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
  136 |  do { \
      |     ^
/usr/include/postgresql/14/server/utils/elog.h:158:2: note: in expansion of macro ‘ereport_domain’
  158 |  ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
      |  ^~~~~~~~~~~~~~
src/tds_fdw.c:814:6: note: in expansion of macro ‘ereport’
  814 |      ereport(ERROR,
      |      ^~~~~~~
src/tds_fdw.c:819:5: note: here
  819 |     default:
      |     ^~~~~~~
In file included from /usr/include/postgresql/14/server/postgres.h:47,
                 from src/tds_fdw.c:32:
src/tds_fdw.c: In function ‘tdsGetRowCountExecute’:
/usr/include/postgresql/14/server/utils/elog.h:136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
  136 |  do { \
      |     ^
/usr/include/postgresql/14/server/utils/elog.h:158:2: note: in expansion of macro ‘ereport_domain’
  158 |  ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
      |  ^~~~~~~~~~~~~~
src/tds_fdw.c:973:6: note: in expansion of macro ‘ereport’
  973 |      ereport(ERROR,
      |      ^~~~~~~
src/tds_fdw.c:978:5: note: here
  978 |     case FAIL:
      |     ^~~~
In file included from /usr/include/postgresql/14/server/postgres.h:47,
                 from src/tds_fdw.c:32:
/usr/include/postgresql/14/server/utils/elog.h:136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
  136 |  do { \
      |     ^
/usr/include/postgresql/14/server/utils/elog.h:158:2: note: in expansion of macro ‘ereport_domain’
  158 |  ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
      |  ^~~~~~~~~~~~~~
src/tds_fdw.c:979:6: note: in expansion of macro ‘ereport’
  979 |      ereport(ERROR,
      |      ^~~~~~~
src/tds_fdw.c:984:5: note: here
  984 |     default:
      |     ^~~~~~~
src/tds_fdw.c: In function ‘tdsConvertToCString’:
src/tds_fdw.c:1167:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
 1167 |    if (erc == SUCCEED)
      |       ^
src/tds_fdw.c:1178:3: note: here
 1178 |   default:
      |   ^~~~~~~
In file included from /usr/include/postgresql/14/server/postgres.h:47,
                 from src/tds_fdw.c:32:
src/tds_fdw.c: In function ‘tdsImportForeignSchema’:
/usr/include/postgresql/14/server/utils/elog.h:136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
  136 |  do { \
      |     ^
/usr/include/postgresql/14/server/utils/elog.h:158:2: note: in expansion of macro ‘ereport_domain’
  158 |  ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
      |  ^~~~~~~~~~~~~~
src/tds_fdw.c:3891:5: note: in expansion of macro ‘ereport’
 3891 |     ereport(ERROR,
      |     ^~~~~~~
src/tds_fdw.c:3896:4: note: here
 3896 |    case FAIL:
      |    ^~~~
In file included from /usr/include/postgresql/14/server/postgres.h:47,
                 from src/tds_fdw.c:32:
/usr/include/postgresql/14/server/utils/elog.h:136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
  136 |  do { \
      |     ^
/usr/include/postgresql/14/server/utils/elog.h:158:2: note: in expansion of macro ‘ereport_domain’
  158 |  ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
      |  ^~~~~~~~~~~~~~
src/tds_fdw.c:3897:5: note: in expansion of macro ‘ereport’
 3897 |     ereport(ERROR,
      |     ^~~~~~~
src/tds_fdw.c:3902:4: note: here
 3902 |    default:
      |    ^~~~~~~
In file included from /usr/include/postgresql/14/server/postgres.h:47,
                 from src/tds_fdw.c:32:
src/tds_fdw.c: In function ‘tdsImportSqlServerSchema’:
/usr/include/postgresql/14/server/utils/elog.h:136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
  136 |  do { \
      |     ^
/usr/include/postgresql/14/server/utils/elog.h:158:2: note: in expansion of macro ‘ereport_domain’
  158 |  ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
      |  ^~~~~~~~~~~~~~
src/tds_fdw.c:3334:6: note: in expansion of macro ‘ereport’
 3334 |      ereport(ERROR,
      |      ^~~~~~~
src/tds_fdw.c:3339:5: note: here
 3339 |     case FAIL:
      |     ^~~~
In file included from /usr/include/postgresql/14/server/postgres.h:47,
                 from src/tds_fdw.c:32:
/usr/include/postgresql/14/server/utils/elog.h:136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
  136 |  do { \
      |     ^
/usr/include/postgresql/14/server/utils/elog.h:158:2: note: in expansion of macro ‘ereport_domain’
  158 |  ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
      |  ^~~~~~~~~~~~~~
src/tds_fdw.c:3340:6: note: in expansion of macro ‘ereport’
 3340 |      ereport(ERROR,
      |      ^~~~~~~
src/tds_fdw.c:3345:5: note: here
 3345 |     default:
      |     ^~~~~~~
In file included from /usr/include/postgresql/14/server/postgres.h:47,
                 from src/tds_fdw.c:32:
src/tds_fdw.c: In function ‘tdsImportSybaseSchema’:
/usr/include/postgresql/14/server/utils/elog.h:136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
  136 |  do { \
      |     ^
/usr/include/postgresql/14/server/utils/elog.h:158:2: note: in expansion of macro ‘ereport_domain’
  158 |  ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
      |  ^~~~~~~~~~~~~~
src/tds_fdw.c:3714:6: note: in expansion of macro ‘ereport’
 3714 |      ereport(ERROR,
      |      ^~~~~~~
src/tds_fdw.c:3719:5: note: here
 3719 |     case FAIL:
      |     ^~~~
In file included from /usr/include/postgresql/14/server/postgres.h:47,
                 from src/tds_fdw.c:32:
/usr/include/postgresql/14/server/utils/elog.h:136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
  136 |  do { \
      |     ^
/usr/include/postgresql/14/server/utils/elog.h:158:2: note: in expansion of macro ‘ereport_domain’
  158 |  ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__)
      |  ^~~~~~~~~~~~~~
src/tds_fdw.c:3720:6: note: in expansion of macro ‘ereport’
 3720 |      ereport(ERROR,
      |      ^~~~~~~
src/tds_fdw.c:3725:5: note: here
 3725 |     default:
      |     ^~~~~~~
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 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC -I./include/ -fvisibility=hidden  -I. -I./ -I/usr/include/postgresql/14/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2   -c -o src/options.o src/options.c
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 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC -I./include/ -fvisibility=hidden  -I. -I./ -I/usr/include/postgresql/14/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2   -c -o src/deparse.o src/deparse.c
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 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC -shared -o tds_fdw.so src/tds_fdw.o src/options.o src/deparse.o -L/usr/lib/x86_64-linux-gnu  -Wl,-z,relro -Wl,-z,now -L/usr/lib/llvm-11/lib  -Wl,--as-needed  -lsybdb
/usr/bin/clang-11 -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I./include/ -fvisibility=hidden  -I. -I./ -I/usr/include/postgresql/14/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -flto=thin -emit-llvm -c -o src/tds_fdw.bc src/tds_fdw.c
/usr/bin/clang-11 -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I./include/ -fvisibility=hidden  -I. -I./ -I/usr/include/postgresql/14/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -flto=thin -emit-llvm -c -o src/options.bc src/options.c
/usr/bin/clang-11 -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I./include/ -fvisibility=hidden  -I. -I./ -I/usr/include/postgresql/14/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -flto=thin -emit-llvm -c -o src/deparse.bc src/deparse.c

but i run the code second time i received no error and i created Extention without error.

                                            List of installed extensions
  Name   | Version |   Schema   |                                    Description                                    
---------+---------+------------+-----------------------------------------------------------------------------------
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
 tds_fdw | 2.0.3   | public     | Foreign data wrapper for querying a TDS database (Sybase or Microsoft SQL Server)
(2 rows)

does it means, everything is ok?

eulerto commented 2 years ago

Build succeeded. Regarding the WARNING messages, it might or might not indicate some (potential) issues. I cannot comment on the code since I know nothing about it. If the case without break instruction is ok, adding a comment saying so will ignore this warning.

/* fallthrough */

There are also other warning that may be worth taking a look. It is about uninitialized variables used in the function tdsConvertToCString. I would rearrange that code to initialize variables into the case instead of postponing it to the default instruction.

Installation instructions mention the required packages but it would be good if it uses the latest Postgres version. AFAICS it is referring to version 11.

yozdas commented 2 years ago

Thanks for reply, i don't have enough programming knowledge in order to rearrange the code, so it is not an option for me. Here it says PostgreSQL 14 is supported, so Installation instructions shouldn't change. I couldn't try to connect to MSSQL yet, but i will soon then i will see what is really wrong.