Skip to content

Check for PQERRORS_SQLSTATE in PGVerbosity enum #14519

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 9, 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
15 changes: 15 additions & 0 deletions ext/pgsql/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,30 @@ if test "$PHP_PGSQL" != "no"; then
old_LIBS=$LIBS
old_LDFLAGS=$LDFLAGS
LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
old_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -I$PGSQL_INCLUDE"
AC_CHECK_LIB(pq, PQlibVersion,, AC_MSG_ERROR([Unable to build the PostgreSQL extension: at least libpq 9.1 is required]))
AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibyte]))
AC_CHECK_LIB(pq, lo_truncate64, AC_DEFINE(HAVE_PG_LO64,1,[PostgreSQL 9.3 or later]))
AC_CHECK_LIB(pq, PQsetErrorContextVisibility, AC_DEFINE(HAVE_PG_CONTEXT_VISIBILITY,1,[PostgreSQL 9.6 or later]))
AC_CHECK_LIB(pq, PQresultMemorySize, AC_DEFINE(HAVE_PG_RESULT_MEMORY_SIZE,1,[PostgreSQL 12 or later]))
AC_CHECK_LIB(pq, PQchangePassword, AC_DEFINE(HAVE_PG_CHANGE_PASSWORD,1,[PostgreSQL 17 or later]))
AC_CHECK_LIB(pq, PQsocketPoll, AC_DEFINE(HAVE_PG_SOCKET_POLL,1,[PostgreSQL 17 or later]))

dnl Available since PostgreSQL 12.
AC_CACHE_CHECK([if PGVerbosity enum has PQERRORS_SQLSTATE],
[php_cv_enum_pgverbosity_pqerrors_sqlstate],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <libpq-fe.h>],
[PGVerbosity e = PQERRORS_SQLSTATE; (void)e;])],
[php_cv_enum_pgverbosity_pqerrors_sqlstate=yes],
[php_cv_enum_pgverbosity_pqerrors_sqlstate=no])])
AS_VAR_IF([php_cv_enum_pgverbosity_pqerrors_sqlstate], [yes],
[AC_DEFINE([HAVE_PQERRORS_SQLSTATE], [1],
[Define to 1 if PGVerbosity enum has PQERRORS_SQLSTATE.])])

LIBS=$old_LIBS
LDFLAGS=$old_LDFLAGS
CFLAGS=$old_CFLAGS

PHP_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR, PGSQL_SHARED_LIBADD)
PHP_SUBST(PGSQL_SHARED_LIBADD)
Expand Down
2 changes: 1 addition & 1 deletion ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ char pgsql_libpq_version[16];
#define PQfreemem free
#endif

#if PG_VERSION_NUM < 120000
#ifndef HAVE_PQERRORS_SQLSTATE
#define PQERRORS_SQLSTATE 0
#endif

Expand Down
2 changes: 1 addition & 1 deletion ext/pgsql/pgsql.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
* @cvalue PQERRORS_VERBOSE
*/
const PGSQL_ERRORS_VERBOSE = UNKNOWN;
#if PG_VERSION_NUM > 110000
#ifdef HAVE_PQERRORS_SQLSTATE
/**
* @var int
* @cvalue PQERRORS_SQLSTATE
Expand Down
6 changes: 3 additions & 3 deletions ext/pgsql/pgsql_arginfo.h

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

Loading