Add optional pkg-config support for PostgreSQL#14540
Conversation
I think we can move up the minimal requirement a "tad", 9.3 is already 10 years+. |
We could probably, yes. According to Wikipedia PostgreSQL 11 is EOL and 12 will be EOL in November 2024. Something between 9.3 and 11, I guess: https://pkgs.org/search/?q=libpq Which version would it be? @remicollet do you have any concerns/suggestions about bumping minimum PostgreSQL version for PHP? P.S.: Windows version is I think at the moment 11.4: https://github.com/winlibs/postgresql |
|
a029549 to
6b18540
Compare
Maybe we can based on Centos 8 version (since 7 will be EOL soon), 9.6 or even 10.0. |
Yes, I think 10 it is quite a good pick. It's EOL for 2 years now so it's pretty safe pick in case of CentOS 8. I'll post it to internals mailing list also in case people still forget to open GitHub here. :D Edit: Posted at https://news-web.php.net/php.internals/123609 |
4281ebc to
e5fcd13
Compare
|
Here, one last thing remaining for the time being is the priority of the passed --with-*pgsql=DIR argument over the pkg-config. For example, if there is libpq library installed on the system and user wants to override the check with DIR argument (--with-pgsql=/custom/path/to/libpq/installation) then the pkg-config check should be done after the DIR check. I'd also split the minimum version bump to a separate PR so the changes are more clear. For the PostgreSQL 10.0 check there is ideal function Coming up in the near future... |
There was a problem hiding this comment.
If you aim for 10.0, perhaps checks and ifdefs for HAVE_PG_LO64 and HAVE_PG_CONTEXT_VISIBILITY can be removed?
There was a problem hiding this comment.
Yes, this will be cleaned up. In this PR I'd only refactor the check into a separate macro. In the follow up PR, this would be bumped to 10.0 and these conditions removed. And also the PQlibVersion check would be replaced there with PQencryptPasswordConn (added in 10.0).
2efb2da to
9720927
Compare
|
This is now wrapped up. Tested with installed libpq on the system, with pkg-config, without pkg-config, libpq installed in a custom directory, shared extensions, configure directory argument, PGSQL_CFLAGS and PGSQL_LIBS environment variables. So, this is ready for merge coming up then in the near future. The minimum libpq version bump to 10.0 will follow also shortly in a new PR... |
The pkg-config (libpq.pc file) was added in PostgreSQL 9.3. This adds a
common setup M4 macro PHP_SETUP_PGSQL to find client PostgreSQL library
libpq on the system with pkg-config. If not found, check falls back to
pg_config to find the libpq and its headers in common locations as
before.
The PGSQL_CFLAGS and PGSQL_LIBS environment variables can override the
libpq installation paths:
./configure --with-pgsql --with-pdo-pgsql \
PGSQL_CFLAGS=-I/path/to/libpq \
PGSQL_LIBS="-L/path/to/libpq -lpq"
Passing manual, non-standard PostgreSQL installation path can be done
with configure option arguments:
./configure \
--with-pgsql=/any/path/to/postgresql \
--with-pdo-postgresql=/any/path/to/postgresql
If this DIR argument (PostgreSQL installation directory or path to the
pg_config) is passed, it takes precedence over the pkg-config, when
installed on the system.
This also removes the unused HAVE_LIBPQ symbol and passing the
PGSQL_INCLUDE and PGSQL_LIBDIR environment variable to configure in
favor of PGSQL_CFLAGS and PGSQL_LIBS.
Instead of the obsolete backticks the recommended $(...) is used when
invoking the pg_config.
Follow-up of phpGH-4235 (Use PKG_CHECK_MODULES to detect the pq library)
9720927 to
88c91c6
Compare
|
Branch rebased against master. Merging this and adjusting it further for the version bump. |
This bumps the libpq client-side PostgreSQL library minimum required version from 9.1 to 10.0. - Sanity check: PQlibVersion -> PQencryptPasswordConn (available since libpq 10.0) - PQsetErrorContextVisibility (available since libpq 9.6) - lo_truncate64 (available since libpq 9.3), if 32-bit system doesn't support lo_*64 functions, error is returned and functions are always available Additionally, the conditional functions usages in pdo_pgsql and pgsql extensions that got piled up are cleaned and synced: - pg_prepare (PQprepare available since libpq 7.4) - pg_query_params (PQexecParams available since libpq 7.4) - pg_result_error_field (PQresultErrorField available since libpq 7.4) - pg_send_prepare (PQsendPrepare available since libpq 7.4) - pg_send_query_params (PQsendQueryParams available since libpq 7.4) - pg_set_error_verbosity (PQsetErrorVerbosity available since libpq 7.4) - pg_transaction_status (PQtransactionStatus available since libpq 7.4) The Windows libpq version is currently at version 11.4: https://github.com/winlibs/postgresql Discussion: https://news-web.php.net/php.internals/123609 Follow-up of phpGH-14540
This bumps the libpq client-side PostgreSQL library minimum required version from 9.1 to 10.0. - Sanity check: PQlibVersion -> PQencryptPasswordConn (available since libpq 10.0) - PQsetErrorContextVisibility (available since libpq 9.6) - lo_truncate64 (available since libpq 9.3), if 32-bit system doesn't support lo_*64 functions, error is returned and functions are always available Additionally, the conditional functions usages in pdo_pgsql and pgsql extensions that got piled up are cleaned and synced: - pg_prepare (PQprepare available since libpq 7.4) - pg_query_params (PQexecParams available since libpq 7.4) - pg_result_error_field (PQresultErrorField available since libpq 7.4) - pg_send_prepare (PQsendPrepare available since libpq 7.4) - pg_send_query_params (PQsendQueryParams available since libpq 7.4) - pg_set_error_verbosity (PQsetErrorVerbosity available since libpq 7.4) - pg_transaction_status (PQtransactionStatus available since libpq 7.4) The Windows libpq version is currently at version 11.4: https://github.com/winlibs/postgresql Discussion: https://news-web.php.net/php.internals/123609 Follow-up of GH-14540
The pkg-config (libpq.pc file) was added in PostgreSQL 9.3. This adds a common setup M4 macro PHP_SETUP_PGSQL to find libpq on the system with pkg-config. If not found, it falls back to pg_config to find the libpq library and its headers in common locations as before.
When using pkg-config, the PGSQL_CFLAGS and PGSQL_LIBS environment variables can override the paths to libpq installation:
Follow-up of GH-4235 (Use PKG_CHECK_MODULES to detect the pq library)