anse1 / sqlsmith

A random SQL query generator
GNU General Public License v3.0
744 stars 126 forks source link

PostgreSQL use: compilation failure #15

Closed pallavisontakke closed 6 years ago

pallavisontakke commented 6 years ago

hi @anse1

When trying to use sqlsmith for PostgreSQL 11, I was facing this compilation issue:

g++ -DHAVE_CONFIG_H -I.  -I/usr/include    -Wall -Wextra   -g -O2 -std=c++11 -MT postgres.o -MD -MP -MF .deps/postgres.Tpo -c -o postgres.o postgres.cc
In file included from postgres.cc:1:0:
postgres.hh:14:22: fatal error: libpq-fe.h: No such file or directory
 #include <libpq-fe.h>
                      ^
compilation terminated.
make[1]: *** [postgres.o] Error 1
make[1]: Leaving directory `/var/lib/postgresql/sources/sqlsmith'
make: *** [all] Error 2

This was due to error in https://github.com/anse1/sqlsmith/blob/master/Makefile.am at line 26. Here POSTGRESQL_CFLAGS is erroneously mentioned as POSTGRESQL_CPPFLAGS . Replacing it fixes this issue

anse1 commented 6 years ago

pallavisontakke writes:

This was due to error in https://github.com/anse1/sqlsmith/blob/master/Makefile.am at line 26. Here POSTGRESQL_CFLAGS is erroneously mentioned as POSTGRESQL_CPPFLAGS . Replacing it fixes this issue

I don't think this can be the explanation: The autoconf macro I use does not substitute the former at all according to its documentation. See

https://www.gnu.org/software/autoconf-archive/ax_lib_postgresql.html

Having the right pg_config in $PATH, POSTGRESQL_CPPFLAGS substitutes the proper include path for my 10.1 build. Maybe ./configure picked up the wrong pg_config binary on your system? You can force a specific one using

./configure --with-postgresql=/path/to/bin/pg_config

regards, Andreas

pallavisontakke commented 6 years ago

What I meant was, in sqlsmith code , I see POSTGRESQL_CFLAGS being set to 'includedir' values, so it can get header files.

postgres@provider:~/sources/sqlsmith$ grep -rn 'POSTGRESQL_CFLAGS' *|more
aclocal.m4:559:#     AC_SUBST(POSTGRESQL_CFLAGS)
aclocal.m4:597:    POSTGRESQL_CFLAGS=""
aclocal.m4:620:            POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`"
aclocal.m4:682:    AC_SUBST([POSTGRESQL_CFLAGS])
autom4te.cache/traces.0:394:    POSTGRESQL_CFLAGS=""
autom4te.cache/traces.0:417:            POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`"
autom4te.cache/traces.0:479:    AC_SUBST([POSTGRESQL_CFLAGS])
autom4te.cache/traces.0:1497:m4trace:configure.ac:8: -1- m4_pattern_allow([^POSTGRESQL_CFLAGS$])
autom4te.cache/traces.1:333:m4trace:configure.ac:8: -1- AC_SUBST([POSTGRESQL_CFLAGS])
autom4te.cache/traces.1:334:m4trace:configure.ac:8: -1- AC_SUBST_TRACE([POSTGRESQL_CFLAGS])
autom4te.cache/traces.1:335:m4trace:configure.ac:8: -1- m4_pattern_allow([^POSTGRESQL_CFLAGS$])
autom4te.cache/output.1:614:POSTGRESQL_CFLAGS
autom4te.cache/output.1:3402:    POSTGRESQL_CFLAGS=""
autom4te.cache/output.1:3462:            POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`"
autom4te.cache/output.0:614:POSTGRESQL_CFLAGS
autom4te.cache/output.0:3402:    POSTGRESQL_CFLAGS=""
autom4te.cache/output.0:3462:            POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`"
configure:614:POSTGRESQL_CFLAGS
configure:3402:    POSTGRESQL_CFLAGS=""
configure:3462:            POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`"

However, POSTGRESQL_CPPFLAGS is only being used, but not being set anywhere:

postgres@provider:~/sources/sqlsmith$ grep -rn 'POSTGRESQL_CPPFLAGS' *|more
Makefile.am:26:AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(PQXX_CFLAGS) $(POSTGRESQL_CPPFLAGS) $(MONETDB_MAPI_CFLAGS) -Wall -Wextra

Also, PG_CONFIG is set properly in my environment during build:

postgres@provider:~/sources/sqlsmith$ echo $PG_CONFIG
/var/lib/postgresql/11/bin/pg_config

And configure is picking it up properly as well:

postgres@provider:~/sources/sqlsmith$ grep -rin 'pg_config' config.log 
178:configure:3412: checking for pg_config
179:configure:3442: result: /var/lib/postgresql/11/bin/pg_config
343:ac_cv_path_PG_CONFIG=/var/lib/postgresql/11/bin/pg_config
427:PG_CONFIG='/var/lib/postgresql/11/bin/pg_config'
anse1 commented 6 years ago

pallavisontakke writes:

postgres@provider:~/sources/sqlsmith$ grep -rn 'POSTGRESQL_CFLAGS' *|more aclocal.m4:559:# AC_SUBST(POSTGRESQL_CFLAGS) aclocal.m4:597: POSTGRESQL_CFLAGS="" aclocal.m4:620: POSTGRESQL_CFLAGS="-I$PG_CONFIG --includedir" aclocal.m4:682: AC_SUBST([POSTGRESQL_CFLAGS])

I see now: You are using an old version of autoconf-archive that comes with a AX_LIB_POSTGRESQL that substitutes POSTGRESQL_CFLAGS instead of POSTGRESQL_CPPFLAGS:

,----[ git://git.sv.gnu.org/autoconf-archive.git ] commit f6c5e7ac8c50fe2ad35aae176f518eb95f66c588 Author: Sree Harsha Totakura sreeharsha@totakura.in Date: Wed Oct 15 11:12:25 2014 +0200
AX_LIB_POSTGRESQL: substitute CPPFLAGS rather than CFLAGS

`----

If you run autoreconf with the current version of autoconf-archive, the Makefile should work as intended without changes.

pallavisontakke commented 6 years ago

ok, fine , in that case it's ok to close this Issue.