Skip to content

Commit 8589791

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents b041352 + a7dc650 commit 8589791

File tree

4 files changed

+132
-93
lines changed

4 files changed

+132
-93
lines changed

cmake/ext/pdo_pgsql/CMakeLists.txt

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ project(
2727
LANGUAGES C
2828
)
2929

30-
include(CheckLibraryExists)
30+
include(CheckSymbolExists)
3131
include(CMakeDependentOption)
32+
include(CMakePushCheckState)
3233
include(FeatureSummary)
3334

3435
option(PHP_EXT_PDO_PGSQL "Enable the pdo_pgsql extension")
@@ -82,39 +83,45 @@ target_link_libraries(php_ext_pdo_pgsql PUBLIC PostgreSQL::PostgreSQL)
8283

8384
# Sanity check.
8485
if(TARGET PostgreSQL::PostgreSQL)
85-
# PostgreSQL library minimum version sanity check.
86-
check_library_exists(
87-
PostgreSQL::PostgreSQL
88-
PQencryptPasswordConn
89-
""
90-
_PHP_LIBPQ_CHECK
91-
)
92-
if(NOT _PHP_LIBPQ_CHECK)
93-
message(
94-
FATAL_ERROR
95-
"PostgreSQL check failed: libpq ${PHP_POSTGRESQL_MIN_VERSION} or later "
96-
"is required."
97-
)
98-
endif()
99-
100-
if(PostgreSQL_VERSION_STRING VERSION_GREATER_EQUAL 12)
101-
check_library_exists(
102-
PostgreSQL::PostgreSQL
103-
PQresultMemorySize
104-
""
105-
HAVE_PG_RESULT_MEMORY_SIZE
106-
)
107-
endif()
108-
109-
# Available since PostgreSQL 17.
110-
if(PostgreSQL_VERSION_STRING VERSION_GREATER_EQUAL 17)
111-
check_library_exists(
112-
PostgreSQL::PostgreSQL
113-
PQclosePrepared
114-
""
115-
HAVE_PQCLOSEPREPARED
116-
)
117-
endif()
86+
cmake_push_check_state(RESET)
87+
set(CMAKE_REQUIRED_LIBRARIES PostgreSQL::PostgreSQL)
88+
89+
# PostgreSQL library minimum version sanity check.
90+
check_symbol_exists(PQencryptPasswordConn "libpq-fe.h" _PHP_LIBPQ_CHECK)
91+
if(NOT _PHP_LIBPQ_CHECK)
92+
message(
93+
FATAL_ERROR
94+
"PostgreSQL check failed: libpq ${PHP_POSTGRESQL_MIN_VERSION} or later "
95+
"is required."
96+
)
97+
endif()
98+
99+
if(PostgreSQL_VERSION_STRING VERSION_GREATER_EQUAL 12)
100+
check_symbol_exists(
101+
PQresultMemorySize
102+
"libpq-fe.h"
103+
HAVE_PG_RESULT_MEMORY_SIZE
104+
)
105+
endif()
106+
107+
# Available since PostgreSQL 17.
108+
if(PostgreSQL_VERSION_STRING VERSION_GREATER_EQUAL 17)
109+
# Indicates the presence of PQclosePrepared, PQclosePortal, etc.
110+
check_symbol_exists(
111+
LIBPQ_HAS_CLOSE_PREPARED
112+
"libpq-fe.h"
113+
_PHP_HAVE_LIBPQ_HAS_CLOSE_PREPARED
114+
)
115+
check_symbol_exists(
116+
PQclosePrepared
117+
"libpq-fe.h"
118+
_PHP_HAVE_PQCLOSEPREPARED
119+
)
120+
if(_PHP_HAVE_LIBPQ_HAS_CLOSE_PREPARED AND _PHP_HAVE_PQCLOSEPREPARED)
121+
set(HAVE_PQCLOSEPREPARED TRUE)
122+
endif()
123+
endif()
124+
cmake_pop_check_state()
118125
endif()
119126

120127
################################################################################

cmake/ext/pdo_pgsql/cmake/config.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
or later). */
66
#cmakedefine HAVE_PG_RESULT_MEMORY_SIZE 1
77

8-
/* Define to 1 if libpq has the 'PQclosePrepared' function (PostgreSQL 17 or
9-
later). */
8+
/* Define to 1 if libpq has the 'PQclosePrepared', 'PQclosePortal', and other
9+
functions (PostgreSQL 17 or later). */
1010
#cmakedefine HAVE_PQCLOSEPREPARED 1

cmake/ext/pgsql/CMakeLists.txt

Lines changed: 85 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ project(
2727
LANGUAGES C
2828
)
2929

30-
include(CheckLibraryExists)
3130
include(CheckSourceCompiles)
31+
include(CheckSymbolExists)
3232
include(CMakeDependentOption)
3333
include(CMakePushCheckState)
3434
include(FeatureSummary)
@@ -85,63 +85,95 @@ set_package_properties(
8585

8686
target_link_libraries(php_ext_pgsql PUBLIC PostgreSQL::PostgreSQL)
8787

88+
# Check features of PostgreSQL library (libpq). As of PostgreSQL (and libpq)
89+
# version 14 there are features macros available in the libpq-fe.h. Additional
90+
# checks for specific symbols below are done to avoid issues present on
91+
# platforms that might package libpq development headers and PostgreSQL server
92+
# development headers into a single all-in-one package (for example,
93+
# postgresql-devel on openSUSE Linux at least on version 15), where libpq
94+
# package contains the latest library, but the development package contains the
95+
# header files of different PostgreSQL version (for example, postgresql16-devel)
96+
# Which leads to unexpected behavior if libpq would be version 17, but
97+
# libpq-fe.h would belong to the package version 16. Otherwise, ideally only
98+
# feature macros checks (LIBPQ_HAS_CHUNK_MODE, etc.) should be sufficient for
99+
# most platforms.
100+
88101
if(TARGET PostgreSQL::PostgreSQL)
89-
# PostgreSQL library minimum version sanity check.
90-
check_library_exists(
91-
PostgreSQL::PostgreSQL
92-
PQencryptPasswordConn
93-
""
94-
_PHP_LIBPQ_CHECK
95-
)
96-
if(NOT _PHP_LIBPQ_CHECK)
97-
message(
98-
FATAL_ERROR
99-
"PostgreSQL check failed: libpq ${PHP_POSTGRESQL_MIN_VERSION} or later "
100-
"is required."
101-
)
102-
endif()
103-
104-
# Available since PostgreSQL 12.
105-
if(PostgreSQL_VERSION_STRING VERSION_GREATER_EQUAL 12)
106-
check_library_exists(
107-
PostgreSQL::PostgreSQL
108-
PQresultMemorySize
109-
""
110-
HAVE_PG_RESULT_MEMORY_SIZE
111-
)
112-
113-
cmake_push_check_state(RESET)
114-
set(CMAKE_REQUIRED_LIBRARIES PostgreSQL::PostgreSQL)
102+
cmake_push_check_state(RESET)
103+
set(CMAKE_REQUIRED_LIBRARIES PostgreSQL::PostgreSQL)
104+
105+
# PostgreSQL library minimum version sanity check.
106+
check_symbol_exists(PQencryptPasswordConn "libpq-fe.h" _PHP_LIBPQ_CHECK)
107+
if(NOT _PHP_LIBPQ_CHECK)
108+
message(
109+
FATAL_ERROR
110+
"PostgreSQL check failed: libpq ${PHP_POSTGRESQL_MIN_VERSION} or later "
111+
"is required."
112+
)
113+
endif()
114+
115+
# Available since PostgreSQL 12.
116+
if(PostgreSQL_VERSION_STRING VERSION_GREATER_EQUAL 12)
117+
check_symbol_exists(
118+
PQresultMemorySize
119+
"libpq-fe.h"
120+
HAVE_PG_RESULT_MEMORY_SIZE
121+
)
122+
115123
check_source_compiles(C [[
116124
#include <libpq-fe.h>
117125
int main(void) { PGVerbosity e = PQERRORS_SQLSTATE; (void)e; return 0; }
118126
]] HAVE_PQERRORS_SQLSTATE)
119-
cmake_pop_check_state()
120-
endif()
121-
122-
# Available since PostgreSQL 17.
123-
if(PostgreSQL_VERSION_STRING VERSION_GREATER_EQUAL 17)
124-
check_library_exists(
125-
PostgreSQL::PostgreSQL
126-
PQchangePassword
127-
""
128-
HAVE_PG_CHANGE_PASSWORD
129-
)
130-
131-
check_library_exists(
132-
PostgreSQL::PostgreSQL
133-
PQsocketPoll
134-
""
135-
HAVE_PG_SOCKET_POLL
136-
)
137-
138-
check_library_exists(
139-
PostgreSQL::PostgreSQL
140-
PQsetChunkedRowsMode
141-
""
142-
HAVE_PG_SET_CHUNKED_ROWS_SIZE
143-
)
144-
endif()
127+
endif()
128+
129+
# Available since PostgreSQL 17.
130+
if(PostgreSQL_VERSION_STRING VERSION_GREATER_EQUAL 17)
131+
# Indicates the presence of PQchangePassword.
132+
check_symbol_exists(
133+
LIBPQ_HAS_CHANGE_PASSWORD
134+
"libpq-fe.h"
135+
_PHP_HAVE_LIBPQ_HAS_CHANGE_PASSWORD
136+
)
137+
check_symbol_exists(
138+
PQchangePassword
139+
"libpq-fe.h"
140+
_PHP_HAVE_PQCHANGEPASSWORD
141+
)
142+
if(_PHP_HAVE_LIBPQ_HAS_CHANGE_PASSWORD AND _PHP_HAVE_PQCHANGEPASSWORD)
143+
set(HAVE_PG_CHANGE_PASSWORD TRUE)
144+
endif()
145+
146+
# Indicates the presence of PQsocketPoll, PQgetCurrentTimeUSec.
147+
check_symbol_exists(
148+
LIBPQ_HAS_SOCKET_POLL
149+
"libpq-fe.h"
150+
_PHP_HAVE_LIBPQ_HAS_SOCKET_POLL
151+
)
152+
check_symbol_exists(
153+
PQsocketPoll
154+
"libpq-fe.h"
155+
_PHP_HAVE_PQSOCKETPOLL
156+
)
157+
if(_PHP_HAVE_LIBPQ_HAS_SOCKET_POLL AND _PHP_HAVE_PQSOCKETPOLL)
158+
set(HAVE_PG_SOCKET_POLL TRUE)
159+
endif()
160+
161+
# Indicates the presence of PQsetChunkedRowsMode and PGRES_TUPLES_CHUNK.
162+
check_symbol_exists(
163+
LIBPQ_HAS_CHUNK_MODE
164+
"libpq-fe.h"
165+
_PHP_HAVE_LIBPQ_HAS_CHUNK_MODE
166+
)
167+
check_symbol_exists(
168+
PQsetChunkedRowsMode
169+
"libpq-fe.h"
170+
_PHP_HAVE_PQSETCHUNKEDROWSMODE
171+
)
172+
if(_PHP_HAVE_LIBPQ_HAS_CHUNK_MODE AND _PHP_HAVE_PQSETCHUNKEDROWSMODE)
173+
set(HAVE_PG_SET_CHUNKED_ROWS_SIZE TRUE)
174+
endif()
175+
endif()
176+
cmake_pop_check_state()
145177
endif()
146178

147179
set(HAVE_PGSQL TRUE)

cmake/ext/pgsql/cmake/config.h.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
or later). */
1010
#cmakedefine HAVE_PG_RESULT_MEMORY_SIZE 1
1111

12-
/* Define to 1 if libpq has the 'PQsetChunkedRowsMode' function (PostgreSQL 17
13-
or later). */
12+
/* Define to 1 if libpq has the 'PQsetChunkedRowsMode' function and
13+
PGRES_TUPLES_CHUNK struct member (PostgreSQL 17 or later). */
1414
#cmakedefine HAVE_PG_SET_CHUNKED_ROWS_SIZE 1
1515

16-
/* Define to 1 if libpq has the 'PQsocketPoll' function (PostgreSQL 17 or
17-
later). */
16+
/* Define to 1 if libpq has the 'PQsocketPoll' and 'PQgetCurrentTimeUSec'
17+
functions (PostgreSQL 17 or later). */
1818
#cmakedefine HAVE_PG_SOCKET_POLL 1
1919

2020
/* Define to 1 if PGVerbosity enum has PQERRORS_SQLSTATE. */

0 commit comments

Comments
 (0)