Skip to content

Bump minimum libpq version to 10.0 #14628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,12 @@ PHP 8.4 UPGRADE NOTES
- PDO:
. The class constants are typed now.

- pdo_pgsql:
. The pdo_pgsql extension now requires at least libpq 10.0.

- pgsql:
. The pgsql extension now requires at least libpq 10.0.

- Reflection:
. The class constants are typed now.

Expand Down
6 changes: 3 additions & 3 deletions build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ found_pgsql=no
dnl Set PostgreSQL installation directory if given from the configure argument.
AS_CASE([$4], [yes], [pgsql_dir=""], [pgsql_dir=$4])
AS_VAR_IF([pgsql_dir],,
[PKG_CHECK_MODULES([PGSQL], [libpq >= 9.3],
[PKG_CHECK_MODULES([PGSQL], [libpq >= 10.0],
[found_pgsql=yes],
[found_pgsql=no])])

Expand Down Expand Up @@ -2000,8 +2000,8 @@ AS_VAR_IF([found_pgsql], [yes], [dnl
PHP_EVAL_INCLINE([$PGSQL_CFLAGS])
PHP_EVAL_LIBLINE([$PGSQL_LIBS], [$1])
dnl PostgreSQL minimum version sanity check.
PHP_CHECK_LIBRARY([pq], [PQlibVersion],, [AC_MSG_ERROR([m4_normalize([
PostgreSQL check failed: libpq 9.1 or later is required, please see
PHP_CHECK_LIBRARY([pq], [PQencryptPasswordConn],, [AC_MSG_ERROR([m4_normalize([
PostgreSQL check failed: libpq 10.0 or later is required, please see
config.log for details.
])])],
[$PGSQL_LIBS])
Expand Down
4 changes: 0 additions & 4 deletions ext/pdo_pgsql/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ if (PHP_PDO_PGSQL != "no") {
CHECK_HEADER_ADD_INCLUDE("libpq-fe.h", "CFLAGS_PDO_PGSQL", PHP_PDO_PGSQL + "\\include;" + PHP_PHP_BUILD + "\\include\\pgsql;" + PHP_PHP_BUILD + "\\include\\libpq;")) {
EXTENSION("pdo_pgsql", "pdo_pgsql.c pgsql_driver.c pgsql_statement.c pgsql_sql_parser.c");

if (X64) {
ADD_FLAG('CFLAGS_PDO_PGSQL', "/D HAVE_PG_LO64=1");
}

AC_DEFINE('HAVE_PDO_PGSQL', 1, 'Have PostgreSQL library');

ADD_EXTENSION_DEP('pdo_pgsql', 'pdo');
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_pgsql/pgsql_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static int pgsql_lob_seek(php_stream *stream, zend_off_t offset, int whence,
zend_off_t *newoffset)
{
struct pdo_pgsql_lob_self *self = (struct pdo_pgsql_lob_self*)stream->abstract;
#if defined(HAVE_PG_LO64) && defined(ZEND_ENABLE_ZVAL_LONG64)
#ifdef ZEND_ENABLE_ZVAL_LONG64
zend_off_t pos = lo_lseek64(self->conn, self->lfd, offset, whence);
#else
zend_off_t pos = lo_lseek(self->conn, self->lfd, offset, whence);
Expand Down
6 changes: 0 additions & 6 deletions ext/pgsql/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ if test "$PHP_PGSQL" != "no"; then

AC_DEFINE(HAVE_PGSQL,1,[Whether to build PostgreSQL support or not])

PHP_CHECK_LIBRARY([pq], [lo_truncate64],
[AC_DEFINE([HAVE_PG_LO64], [1], [PostgreSQL 9.3 or later])],,
[$PGSQL_LIBS])
PHP_CHECK_LIBRARY([pq], [PQsetErrorContextVisibility],
[AC_DEFINE([HAVE_PG_CONTEXT_VISIBILITY], [1], [PostgreSQL 9.6 or later])],,
[$PGSQL_LIBS])
PHP_CHECK_LIBRARY([pq], [PQresultMemorySize],
[AC_DEFINE([HAVE_PG_RESULT_MEMORY_SIZE], [1], [PostgreSQL 12 or later])],,
[$PGSQL_LIBS])
Expand Down
2 changes: 1 addition & 1 deletion ext/pgsql/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (PHP_PGSQL != "no") {
CHECK_HEADER_ADD_INCLUDE("libpq-fe.h", "CFLAGS_PGSQL", PHP_PGSQL + "\\include;" + PHP_PHP_BUILD + "\\include\\pgsql;" + PHP_PHP_BUILD + "\\include\\libpq;" + PHP_PGSQL)) {
EXTENSION("pgsql", "pgsql.c", PHP_PGSQL_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
AC_DEFINE('HAVE_PGSQL', 1, 'Have PostgreSQL library');
ADD_FLAG("CFLAGS_PGSQL", "/D PGSQL_EXPORTS" + (X64 ? " /D HAVE_PG_LO64" : "") + " ");
ADD_FLAG("CFLAGS_PGSQL", "/D PGSQL_EXPORTS");
ADD_EXTENSION_DEP('pgsql', 'pcre');
} else {
WARNING("pgsql not enabled; libraries and headers not found");
Expand Down
7 changes: 1 addition & 6 deletions ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -2934,15 +2934,12 @@ PHP_FUNCTION(pg_lo_seek)
pgsql = Z_PGSQL_LOB_P(pgsql_id);
CHECK_PGSQL_LOB(pgsql);

#ifdef HAVE_PG_LO64
if (PQserverVersion((PGconn *)pgsql->conn) >= 90300) {
result = lo_lseek64((PGconn *)pgsql->conn, pgsql->lofd, offset, (int)whence);
} else {
result = lo_lseek((PGconn *)pgsql->conn, pgsql->lofd, (int)offset, (int)whence);
}
#else
result = lo_lseek((PGconn *)pgsql->conn, pgsql->lofd, offset, whence);
#endif

if (result > -1) {
RETURN_TRUE;
} else {
Expand Down Expand Up @@ -3046,7 +3043,6 @@ PHP_FUNCTION(pg_set_error_verbosity)
}
/* }}} */

#ifdef HAVE_PG_CONTEXT_VISIBILITY
PHP_FUNCTION(pg_set_error_context_visibility)
{
zval *pgsql_link = NULL;
Expand All @@ -3071,7 +3067,6 @@ PHP_FUNCTION(pg_set_error_context_visibility)
RETURN_THROWS();
}
}
#endif

#ifdef HAVE_PG_RESULT_MEMORY_SIZE
PHP_FUNCTION(pg_result_memory_size)
Expand Down
4 changes: 0 additions & 4 deletions ext/pgsql/pgsql.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@
const PGSQL_TRACE_REGRESS_MODE = UNKNOWN;
#endif

#ifdef HAVE_PG_CONTEXT_VISIBILITY
/* For pg_set_error_context_visibility() */

/**
Expand All @@ -465,7 +464,6 @@
* @cvalue PQSHOW_CONTEXT_ALWAYS
*/
const PGSQL_SHOW_CONTEXT_ALWAYS = UNKNOWN;
#endif

function pg_connect(string $connection_string, int $flags = 0): PgSql\Connection|false {}

Expand Down Expand Up @@ -953,9 +951,7 @@ function pg_delete(PgSql\Connection $connection, string $table_name, array $cond
*/
function pg_select(PgSql\Connection $connection, string $table_name, array $conditions = [], int $flags = PGSQL_DML_EXEC, int $mode = PGSQL_ASSOC): array|string|false {}

#ifdef HAVE_PG_CONTEXT_VISIBILITY
function pg_set_error_context_visibility(PgSql\Connection $connection, int $visibility): int {}
#endif

#ifdef HAVE_PG_RESULT_MEMORY_SIZE
function pg_result_memory_size(PgSql\Result $result): int {}
Expand Down
14 changes: 1 addition & 13 deletions ext/pgsql/pgsql_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions ext/pgsql/tests/02connection.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ if (pg_connection_busy($db))
{
echo "pg_connection_busy() error\n";
}
if (function_exists('pg_transaction_status')) {
if (pg_transaction_status($db) != PGSQL_TRANSACTION_IDLE)
{
echo "pg_transaction_status() error\n";
}
if (pg_transaction_status($db) != PGSQL_TRANSACTION_IDLE)
{
echo "pg_transaction_status() error\n";
}
if (false === pg_host($db))
{
Expand Down
38 changes: 19 additions & 19 deletions ext/pgsql/tests/03sync_query.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,26 @@ try {
}

pg_result_error($result);
if (function_exists('pg_result_error_field')) {
pg_result_error_field($result, PGSQL_DIAG_SEVERITY);
pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT);
pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION);
if (defined('PGSQL_DIAG_INTERNAL_POSITION'))
{
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION);
}
if (defined('PGSQL_DIAG_INTERNAL_QUERY'))
{
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY);
}
pg_result_error_field($result, PGSQL_DIAG_CONTEXT);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FUNCTION);

pg_result_error_field($result, PGSQL_DIAG_SEVERITY);
pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT);
pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION);
if (defined('PGSQL_DIAG_INTERNAL_POSITION'))
{
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION);
}
if (defined('PGSQL_DIAG_INTERNAL_QUERY'))
{
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY);
}
pg_result_error_field($result, PGSQL_DIAG_CONTEXT);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FUNCTION);

pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
pg_field_name($result, 0);
Expand Down
20 changes: 9 additions & 11 deletions ext/pgsql/tests/07optional.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ $enc = pg_client_encoding($db);

pg_set_client_encoding($db, $enc);

if (function_exists('pg_set_error_verbosity')) {
pg_set_error_verbosity($db, PGSQL_ERRORS_TERSE);
pg_set_error_verbosity($db, PGSQL_ERRORS_DEFAULT);
pg_set_error_verbosity($db, PGSQL_ERRORS_VERBOSE);
pg_set_error_verbosity($db, PGSQL_ERRORS_SQLSTATE);
}
if (function_exists('pg_set_error_context_visibility')) {
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_NEVER);
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_ERRORS);
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_ALWAYS);
}
pg_set_error_verbosity($db, PGSQL_ERRORS_TERSE);
pg_set_error_verbosity($db, PGSQL_ERRORS_DEFAULT);
pg_set_error_verbosity($db, PGSQL_ERRORS_VERBOSE);
pg_set_error_verbosity($db, PGSQL_ERRORS_SQLSTATE);

pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_NEVER);
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_ERRORS);
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_ALWAYS);

echo "OK";
?>
--EXPECT--
Expand Down
1 change: 0 additions & 1 deletion ext/pgsql/tests/23sync_query_params.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pgsql
--SKIPIF--
<?php
include("inc/skipif.inc");
if (!function_exists('pg_query_params')) die('skip function pg_query_params() does not exist');
?>
--FILE--
<?php
Expand Down
1 change: 0 additions & 1 deletion ext/pgsql/tests/24sync_query_prepared.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pgsql
--SKIPIF--
<?php
include("inc/skipif.inc");
if (!function_exists('pg_prepare')) die('skip function pg_prepare() does not exist');
?>
--FILE--
<?php
Expand Down
1 change: 0 additions & 1 deletion ext/pgsql/tests/25async_query_params.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pgsql
--SKIPIF--
<?php
include("inc/skipif.inc");
if (!function_exists('pg_send_query_params')) die('skip function pg_send_query_params() does not exist');
?>
--FILE--
<?php
Expand Down
1 change: 0 additions & 1 deletion ext/pgsql/tests/26async_query_prepared.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pgsql
--SKIPIF--
<?php
include("inc/skipif.inc");
if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() does not exist');
?>
--FILE--
<?php
Expand Down
1 change: 0 additions & 1 deletion ext/pgsql/tests/30nb_async_query_params.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pgsql
--SKIPIF--
<?php
include("inc/skipif.inc");
if (!function_exists('pg_send_query_params')) die('skip function pg_send_query_params() does not exist');
?>
--FILE--
<?php
Expand Down
1 change: 0 additions & 1 deletion ext/pgsql/tests/31nb_async_query_prepared.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pgsql
--SKIPIF--
<?php
include("inc/skipif.inc");
if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() does not exist');
?>
--FILE--
<?php
Expand Down
1 change: 0 additions & 1 deletion ext/pgsql/tests/32nb_async_query.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pgsql
--SKIPIF--
<?php
include("inc/skipif.inc");
if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() does not exist');
?>
--FILE--
<?php
Expand Down
Loading