From 6e1eccce4603846f83b38e74f3f53741e073af10 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 13 Jun 2023 07:32:40 +0200 Subject: [PATCH] check that needed functions exists --- config9.m4 | 2 ++ src/php_pqconn.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/config9.m4 b/config9.m4 index d3fb2b2..d845e28 100644 --- a/config9.m4 +++ b/config9.m4 @@ -99,6 +99,8 @@ if test "$PHP_PQ" != "no"; then PHP_SUBST(PQ_SHARED_LIBADD) PQ_CHECK_FUNC(PQlibVersion) + PQ_CHECK_FUNC(PQprotocolVersion) + PQ_CHECK_FUNC(PQserverVersion) PQ_CHECK_FUNC(PQconninfo) PQ_CHECK_FUNC(PQsetSingleRowMode) diff --git a/src/php_pqconn.c b/src/php_pqconn.c index 70e2c82..32cc526 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -505,12 +505,15 @@ static void php_pqconn_object_read_lib_version(void *o, zval *return_value) RETVAL_STRING(ver); } #endif +#ifdef HAVE_PQPROTOCOLVERSION static void php_pqconn_object_read_protocol_version(void *o, zval *return_value) { php_pqconn_object_t *obj = o; RETVAL_LONG(PQprotocolVersion(obj->intern->conn)); } +#endif +#ifdef HAVE_PQSERVERVERSION static void php_pqconn_object_read_server_version(void *o, zval *return_value) { php_pqconn_object_t *obj = o; @@ -524,6 +527,7 @@ static void php_pqconn_object_read_server_version(void *o, zval *return_value) } RETVAL_STRING(ver); } +#endif static ZEND_RESULT_CODE php_pqconn_update_socket(zval *zobj, php_pqconn_object_t *obj) { @@ -2171,13 +2175,17 @@ PHP_MINIT_FUNCTION(pqconn) zend_hash_str_add_mem(&php_pqconn_object_prophandlers, ZEND_STRL("libraryVersion"), (void *) &ph, sizeof(ph)); #endif +#ifdef HAVE_PQPROTOCOLVERSION zend_declare_property_null(php_pqconn_class_entry, ZEND_STRL("protocolVersion"), ZEND_ACC_PUBLIC); ph.read = php_pqconn_object_read_protocol_version; zend_hash_str_add_mem(&php_pqconn_object_prophandlers, ZEND_STRL("protocolVersion"), (void *) &ph, sizeof(ph)); +#endif +#ifdef HAVE_PQSERVERVERSION zend_declare_property_null(php_pqconn_class_entry, ZEND_STRL("serverVersion"), ZEND_ACC_PUBLIC); ph.read = php_pqconn_object_read_server_version; zend_hash_str_add_mem(&php_pqconn_object_prophandlers, ZEND_STRL("serverVersion"), (void *) &ph, sizeof(ph)); +#endif zend_declare_class_constant_long(php_pqconn_class_entry, ZEND_STRL("OK"), CONNECTION_OK); zend_declare_class_constant_long(php_pqconn_class_entry, ZEND_STRL("BAD"), CONNECTION_BAD); -- 2.30.2