Skip to content

Commit 297817a

Browse files
committed
Bump minimum libpq version to 10.0
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
1 parent 106581b commit 297817a

19 files changed

+44
-80
lines changed

UPGRADING

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,12 @@ PHP 8.4 UPGRADE NOTES
685685
- PDO:
686686
. The class constants are typed now.
687687

688+
- pdo_pgsql:
689+
. The pdo_pgsql extension now requires at least libpq 10.0.
690+
691+
- pgsql:
692+
. The pgsql extension now requires at least libpq 10.0.
693+
688694
- Reflection:
689695
. The class constants are typed now.
690696

build/php.m4

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,7 +1957,7 @@ found_pgsql=no
19571957
dnl Set PostgreSQL installation directory if given from the configure argument.
19581958
AS_CASE([$4], [yes], [pgsql_dir=""], [pgsql_dir=$4])
19591959
AS_VAR_IF([pgsql_dir],,
1960-
[PKG_CHECK_MODULES([PGSQL], [libpq >= 9.3],
1960+
[PKG_CHECK_MODULES([PGSQL], [libpq >= 10.0],
19611961
[found_pgsql=yes],
19621962
[found_pgsql=no])])
19631963
@@ -2000,8 +2000,8 @@ AS_VAR_IF([found_pgsql], [yes], [dnl
20002000
PHP_EVAL_INCLINE([$PGSQL_CFLAGS])
20012001
PHP_EVAL_LIBLINE([$PGSQL_LIBS], [$1])
20022002
dnl PostgreSQL minimum version sanity check.
2003-
PHP_CHECK_LIBRARY([pq], [PQlibVersion],, [AC_MSG_ERROR([m4_normalize([
2004-
PostgreSQL check failed: libpq 9.1 or later is required, please see
2003+
PHP_CHECK_LIBRARY([pq], [PQencryptPasswordConn],, [AC_MSG_ERROR([m4_normalize([
2004+
PostgreSQL check failed: libpq 10.0 or later is required, please see
20052005
config.log for details.
20062006
])])],
20072007
[$PGSQL_LIBS])

ext/pdo_pgsql/config.w32

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ if (PHP_PDO_PGSQL != "no") {
77
CHECK_HEADER_ADD_INCLUDE("libpq-fe.h", "CFLAGS_PDO_PGSQL", PHP_PDO_PGSQL + "\\include;" + PHP_PHP_BUILD + "\\include\\pgsql;" + PHP_PHP_BUILD + "\\include\\libpq;")) {
88
EXTENSION("pdo_pgsql", "pdo_pgsql.c pgsql_driver.c pgsql_statement.c pgsql_sql_parser.c");
99

10-
if (X64) {
11-
ADD_FLAG('CFLAGS_PDO_PGSQL', "/D HAVE_PG_LO64=1");
12-
}
13-
1410
AC_DEFINE('HAVE_PDO_PGSQL', 1, 'Have PostgreSQL library');
1511

1612
ADD_EXTENSION_DEP('pdo_pgsql', 'pdo');

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static int pgsql_lob_seek(php_stream *stream, zend_off_t offset, int whence,
177177
zend_off_t *newoffset)
178178
{
179179
struct pdo_pgsql_lob_self *self = (struct pdo_pgsql_lob_self*)stream->abstract;
180-
#if defined(HAVE_PG_LO64) && defined(ZEND_ENABLE_ZVAL_LONG64)
180+
#ifdef ZEND_ENABLE_ZVAL_LONG64
181181
zend_off_t pos = lo_lseek64(self->conn, self->lfd, offset, whence);
182182
#else
183183
zend_off_t pos = lo_lseek(self->conn, self->lfd, offset, whence);

ext/pgsql/config.m4

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ if test "$PHP_PGSQL" != "no"; then
1212

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

15-
PHP_CHECK_LIBRARY([pq], [lo_truncate64],
16-
[AC_DEFINE([HAVE_PG_LO64], [1], [PostgreSQL 9.3 or later])],,
17-
[$PGSQL_LIBS])
18-
PHP_CHECK_LIBRARY([pq], [PQsetErrorContextVisibility],
19-
[AC_DEFINE([HAVE_PG_CONTEXT_VISIBILITY], [1], [PostgreSQL 9.6 or later])],,
20-
[$PGSQL_LIBS])
2115
PHP_CHECK_LIBRARY([pq], [PQresultMemorySize],
2216
[AC_DEFINE([HAVE_PG_RESULT_MEMORY_SIZE], [1], [PostgreSQL 12 or later])],,
2317
[$PGSQL_LIBS])

ext/pgsql/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (PHP_PGSQL != "no") {
77
CHECK_HEADER_ADD_INCLUDE("libpq-fe.h", "CFLAGS_PGSQL", PHP_PGSQL + "\\include;" + PHP_PHP_BUILD + "\\include\\pgsql;" + PHP_PHP_BUILD + "\\include\\libpq;" + PHP_PGSQL)) {
88
EXTENSION("pgsql", "pgsql.c", PHP_PGSQL_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
99
AC_DEFINE('HAVE_PGSQL', 1, 'Have PostgreSQL library');
10-
ADD_FLAG("CFLAGS_PGSQL", "/D PGSQL_EXPORTS" + (X64 ? " /D HAVE_PG_LO64" : "") + " ");
10+
ADD_FLAG("CFLAGS_PGSQL", "/D PGSQL_EXPORTS");
1111
ADD_EXTENSION_DEP('pgsql', 'pcre');
1212
} else {
1313
WARNING("pgsql not enabled; libraries and headers not found");

ext/pgsql/pgsql.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,15 +2934,12 @@ PHP_FUNCTION(pg_lo_seek)
29342934
pgsql = Z_PGSQL_LOB_P(pgsql_id);
29352935
CHECK_PGSQL_LOB(pgsql);
29362936

2937-
#ifdef HAVE_PG_LO64
29382937
if (PQserverVersion((PGconn *)pgsql->conn) >= 90300) {
29392938
result = lo_lseek64((PGconn *)pgsql->conn, pgsql->lofd, offset, (int)whence);
29402939
} else {
29412940
result = lo_lseek((PGconn *)pgsql->conn, pgsql->lofd, (int)offset, (int)whence);
29422941
}
2943-
#else
2944-
result = lo_lseek((PGconn *)pgsql->conn, pgsql->lofd, offset, whence);
2945-
#endif
2942+
29462943
if (result > -1) {
29472944
RETURN_TRUE;
29482945
} else {
@@ -3046,7 +3043,6 @@ PHP_FUNCTION(pg_set_error_verbosity)
30463043
}
30473044
/* }}} */
30483045

3049-
#ifdef HAVE_PG_CONTEXT_VISIBILITY
30503046
PHP_FUNCTION(pg_set_error_context_visibility)
30513047
{
30523048
zval *pgsql_link = NULL;
@@ -3071,7 +3067,6 @@ PHP_FUNCTION(pg_set_error_context_visibility)
30713067
RETURN_THROWS();
30723068
}
30733069
}
3074-
#endif
30753070

30763071
#ifdef HAVE_PG_RESULT_MEMORY_SIZE
30773072
PHP_FUNCTION(pg_result_memory_size)

ext/pgsql/pgsql.stub.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,6 @@
447447
const PGSQL_TRACE_REGRESS_MODE = UNKNOWN;
448448
#endif
449449

450-
#ifdef HAVE_PG_CONTEXT_VISIBILITY
451450
/* For pg_set_error_context_visibility() */
452451

453452
/**
@@ -465,7 +464,6 @@
465464
* @cvalue PQSHOW_CONTEXT_ALWAYS
466465
*/
467466
const PGSQL_SHOW_CONTEXT_ALWAYS = UNKNOWN;
468-
#endif
469467

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

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

956-
#ifdef HAVE_PG_CONTEXT_VISIBILITY
957954
function pg_set_error_context_visibility(PgSql\Connection $connection, int $visibility): int {}
958-
#endif
959955

960956
#ifdef HAVE_PG_RESULT_MEMORY_SIZE
961957
function pg_result_memory_size(PgSql\Result $result): int {}

ext/pgsql/pgsql_arginfo.h

Lines changed: 1 addition & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/pgsql/tests/02connection.phpt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ if (pg_connection_busy($db))
2525
{
2626
echo "pg_connection_busy() error\n";
2727
}
28-
if (function_exists('pg_transaction_status')) {
29-
if (pg_transaction_status($db) != PGSQL_TRANSACTION_IDLE)
30-
{
31-
echo "pg_transaction_status() error\n";
32-
}
28+
if (pg_transaction_status($db) != PGSQL_TRANSACTION_IDLE)
29+
{
30+
echo "pg_transaction_status() error\n";
3331
}
3432
if (false === pg_host($db))
3533
{

ext/pgsql/tests/03sync_query.phpt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,26 @@ try {
6363
}
6464

6565
pg_result_error($result);
66-
if (function_exists('pg_result_error_field')) {
67-
pg_result_error_field($result, PGSQL_DIAG_SEVERITY);
68-
pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);
69-
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY);
70-
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL);
71-
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT);
72-
pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION);
73-
if (defined('PGSQL_DIAG_INTERNAL_POSITION'))
74-
{
75-
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION);
76-
}
77-
if (defined('PGSQL_DIAG_INTERNAL_QUERY'))
78-
{
79-
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY);
80-
}
81-
pg_result_error_field($result, PGSQL_DIAG_CONTEXT);
82-
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE);
83-
pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE);
84-
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FUNCTION);
66+
67+
pg_result_error_field($result, PGSQL_DIAG_SEVERITY);
68+
pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);
69+
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY);
70+
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL);
71+
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT);
72+
pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION);
73+
if (defined('PGSQL_DIAG_INTERNAL_POSITION'))
74+
{
75+
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION);
8576
}
77+
if (defined('PGSQL_DIAG_INTERNAL_QUERY'))
78+
{
79+
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY);
80+
}
81+
pg_result_error_field($result, PGSQL_DIAG_CONTEXT);
82+
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE);
83+
pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE);
84+
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FUNCTION);
85+
8686
pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
8787
pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
8888
pg_field_name($result, 0);

ext/pgsql/tests/07optional.phpt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ $enc = pg_client_encoding($db);
1515

1616
pg_set_client_encoding($db, $enc);
1717

18-
if (function_exists('pg_set_error_verbosity')) {
19-
pg_set_error_verbosity($db, PGSQL_ERRORS_TERSE);
20-
pg_set_error_verbosity($db, PGSQL_ERRORS_DEFAULT);
21-
pg_set_error_verbosity($db, PGSQL_ERRORS_VERBOSE);
22-
pg_set_error_verbosity($db, PGSQL_ERRORS_SQLSTATE);
23-
}
24-
if (function_exists('pg_set_error_context_visibility')) {
25-
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_NEVER);
26-
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_ERRORS);
27-
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_ALWAYS);
28-
}
18+
pg_set_error_verbosity($db, PGSQL_ERRORS_TERSE);
19+
pg_set_error_verbosity($db, PGSQL_ERRORS_DEFAULT);
20+
pg_set_error_verbosity($db, PGSQL_ERRORS_VERBOSE);
21+
pg_set_error_verbosity($db, PGSQL_ERRORS_SQLSTATE);
22+
23+
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_NEVER);
24+
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_ERRORS);
25+
pg_set_error_context_visibility($db, PGSQL_SHOW_CONTEXT_ALWAYS);
26+
2927
echo "OK";
3028
?>
3129
--EXPECT--

ext/pgsql/tests/23sync_query_params.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pgsql
55
--SKIPIF--
66
<?php
77
include("inc/skipif.inc");
8-
if (!function_exists('pg_query_params')) die('skip function pg_query_params() does not exist');
98
?>
109
--FILE--
1110
<?php

ext/pgsql/tests/24sync_query_prepared.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pgsql
55
--SKIPIF--
66
<?php
77
include("inc/skipif.inc");
8-
if (!function_exists('pg_prepare')) die('skip function pg_prepare() does not exist');
98
?>
109
--FILE--
1110
<?php

ext/pgsql/tests/25async_query_params.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pgsql
55
--SKIPIF--
66
<?php
77
include("inc/skipif.inc");
8-
if (!function_exists('pg_send_query_params')) die('skip function pg_send_query_params() does not exist');
98
?>
109
--FILE--
1110
<?php

ext/pgsql/tests/26async_query_prepared.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pgsql
55
--SKIPIF--
66
<?php
77
include("inc/skipif.inc");
8-
if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() does not exist');
98
?>
109
--FILE--
1110
<?php

ext/pgsql/tests/30nb_async_query_params.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pgsql
55
--SKIPIF--
66
<?php
77
include("inc/skipif.inc");
8-
if (!function_exists('pg_send_query_params')) die('skip function pg_send_query_params() does not exist');
98
?>
109
--FILE--
1110
<?php

ext/pgsql/tests/31nb_async_query_prepared.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pgsql
55
--SKIPIF--
66
<?php
77
include("inc/skipif.inc");
8-
if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() does not exist');
98
?>
109
--FILE--
1110
<?php

ext/pgsql/tests/32nb_async_query.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pgsql
55
--SKIPIF--
66
<?php
77
include("inc/skipif.inc");
8-
if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() does not exist');
98
?>
109
--FILE--
1110
<?php

0 commit comments

Comments
 (0)