Patch to address issue #57.
Test for PQping by attempted to link it.
What happens is that on your system you have headers that does not match your libaries.
The test only check libpq headers version on purpose.
I believe the problem is that the test program is never ran. So there is never a chance for it to return 1 to indicate that my Postgres version is too old to support PQping.
Well now i am confused.
Your saying that the test program is never run? Are you sure, if so then it will never try to include PQping.
Check your configure.log. If you want the code to work you need to have up to date postgresql headers installed.
The test program compiles when using PostgreSQL 8.4 or PostgreSQL 9.1+. As the program compiles successfully in either case, PQping is reported as supported. At least with the autotools on CentOS 6, the test program is never executed, which is what is intended to fail if PQping is not supported. As a quick test, modify the test program to return 1 all the time. PQping will still be picked up as supported when using PostgreSQL 8.4.
Send me your config.log.......
And if you have 9.x headers and you compile with 8.x lib you will get an error obviously. But i do not understand why it would not execute the test program under centos 6.. so without the generated configure and the config.log can't know whats generated.
Files can be had here:
To have the test program executed you need to do:
diff --git a/configure.in b/configure.in
index 1153dbc..9710909 100644
@@ -904,7 +904,7 @@ if test "x$with_postgresql" != "xno"; then
AC_MSG_CHECKING([PGSQL_API_VERSION for PQping support])
But that still results in HAVE_PQPING being defined, with a value of 0 which still causes PQping to be used.
Mixed headers/lib versions is not the issue.
I agree on AC_RUN_IFELSE (my bad) but if its executed and return 0 it mean that the version was ok so its the intended behavior.
And from your configure.log
configure:20307: checking PGSQL_API_VERSION for PQping support
configure:20335: gcc -o conftest -g -O2 -I/usr/include -DENABLE_POSTGRESQL -L/usr/lib conftest.c -lpq -lpcap -lnsl -lm -lm -lpq >&5
In file included from /usr/include/pg_config.h:14,
/usr/include/pg_config_x86_64.h:637:1: warning: "PACKAGE_BUGREPORT" redefined
conftest.c:7:1: warning: this is the location of the previous definition
/usr/include/pg_config_x86_64.h:640:1: warning: "PACKAGE_NAME" redefined
conftest.c:3:1: warning: this is the location of the previous definition
/usr/include/pg_config_x86_64.h:643:1: warning: "PACKAGE_STRING" redefined
conftest.c:6:1: warning: this is the location of the previous definition
/usr/include/pg_config_x86_64.h:646:1: warning: "PACKAGE_TARNAME" redefined
conftest.c:4:1: warning: this is the location of the previous definition
/usr/include/pg_config_x86_64.h:649:1: warning: "PACKAGE_VERSION" redefined
conftest.c:5:1: warning: this is the location of the previous definition
configure:20342: $? = 0
configure:20356: result: yes
Overall your fix is all kosher, also thanks for pointing that AC_RUN vs AC_LINK , meanwhile
changing it to AC_RUN give it the correct behavior.
I had used that template i wrote elsewhere before and fixed it so thanks ;)
@firnsy can we pull this and retag 2-1.11?
Can be closed , whenn pull request get integrated.