summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--UPGRADING3
-rw-r--r--ext/pgsql/config.m422
-rw-r--r--ext/pgsql/config.w322
-rw-r--r--ext/pgsql/pgsql.c386
-rw-r--r--ext/pgsql/php_pgsql.h24
6 files changed, 29 insertions, 411 deletions
diff --git a/NEWS b/NEWS
index e27c38689c..83bdd4da16 100644
--- a/NEWS
+++ b/NEWS
@@ -95,6 +95,9 @@ PHP NEWS
- PCRE:
. Don't ignore invalid escape sequences. (sjon)
+- PGSQL:
+ . Bumped required libpq version to 7.4.
+
- PDO:
. Changed default PDO error mode to exceptions. (AllenJB)
. Fixed bug #77849 (Disable cloning of PDO handle/connection objects).
diff --git a/UPGRADING b/UPGRADING
index a3c471c319..bb4f7428bc 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -676,6 +676,9 @@ PHP 8.0 UPGRADE NOTES
. When mysqlnd is not used (which is the default and recommended option),
the minimum supported libmysqlclient version is now 5.1.
+- PGSQL:
+ . The PGSQL extension now required at least libpq 7.4.
+
========================================
10. New Global Constants
========================================
diff --git a/ext/pgsql/config.m4 b/ext/pgsql/config.m4
index aae5687cd4..479913de77 100644
--- a/ext/pgsql/config.m4
+++ b/ext/pgsql/config.m4
@@ -68,27 +68,7 @@ if test "$PHP_PGSQL" != "no"; then
old_LIBS=$LIBS
old_LDFLAGS=$LDFLAGS
LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
- AC_CHECK_LIB(pq, PQescapeString,AC_DEFINE(HAVE_PQESCAPE,1,[PostgreSQL 7.2.0 or later]))
- AC_CHECK_LIB(pq, PQunescapeBytea,AC_DEFINE(HAVE_PQUNESCAPEBYTEA,1,[PostgreSQL 7.3.0 or later]))
- AC_CHECK_LIB(pq, PQsetnonblocking,AC_DEFINE(HAVE_PQSETNONBLOCKING,1,[PostgreSQL 7.0.x or later]))
- AC_CHECK_LIB(pq, PQcmdTuples,AC_DEFINE(HAVE_PQCMDTUPLES,1,[Broken libpq under windows]))
- AC_CHECK_LIB(pq, PQoidValue,AC_DEFINE(HAVE_PQOIDVALUE,1,[Older PostgreSQL]))
- AC_CHECK_LIB(pq, PQclientEncoding,AC_DEFINE(HAVE_PQCLIENTENCODING,1,[PostgreSQL 7.0.x or later]))
- AC_CHECK_LIB(pq, PQparameterStatus,AC_DEFINE(HAVE_PQPARAMETERSTATUS,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQprotocolVersion,AC_DEFINE(HAVE_PQPROTOCOLVERSION,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQtransactionStatus,AC_DEFINE(HAVE_PGTRANSACTIONSTATUS,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQexecParams,AC_DEFINE(HAVE_PQEXECPARAMS,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQprepare,AC_DEFINE(HAVE_PQPREPARE,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQexecPrepared,AC_DEFINE(HAVE_PQEXECPREPARED,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQresultErrorField,AC_DEFINE(HAVE_PQRESULTERRORFIELD,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQsendQueryParams,AC_DEFINE(HAVE_PQSENDQUERYPARAMS,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQsendPrepare,AC_DEFINE(HAVE_PQSENDPREPARE,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQsendQueryPrepared,AC_DEFINE(HAVE_PQSENDQUERYPREPARED,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQputCopyData,AC_DEFINE(HAVE_PQPUTCOPYDATA,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQgetCopyData,AC_DEFINE(HAVE_PQGETCOPYDATA,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQfreemem,AC_DEFINE(HAVE_PQFREEMEM,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQsetErrorVerbosity,AC_DEFINE(HAVE_PQSETERRORVERBOSITY,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, PQftable,AC_DEFINE(HAVE_PQFTABLE,1,[PostgreSQL 7.4 or later]))
+ AC_CHECK_LIB(pq, PQprepare,, AC_MSG_ERROR([Unable to build the PostgreSQL extension: at least libpq 7.4 is required]))
AC_CHECK_LIB(pq, PQescapeStringConn, AC_DEFINE(HAVE_PQESCAPE_CONN,1,[PostgreSQL 8.1.4 or later]))
AC_CHECK_LIB(pq, PQescapeByteaConn, AC_DEFINE(HAVE_PQESCAPE_BYTEA_CONN,1,[PostgreSQL 8.1.4 or later]))
AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibyte]))
diff --git a/ext/pgsql/config.w32 b/ext/pgsql/config.w32
index a31361cbc4..8836191f79 100644
--- a/ext/pgsql/config.w32
+++ b/ext/pgsql/config.w32
@@ -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 HAVE_PG_CONFIG_H /D PGSQL_EXPORTS /D HAVE_PQSETNONBLOCKING /D HAVE_PQCMDTUPLES /D HAVE_PQCLIENTENCODING /D HAVE_PQESCAPE /D HAVE_PQPARAMETERSTATUS /D HAVE_PGTRANSACTIONSTATUS /D HAVE_PQEXECPARAMS /D HAVE_PQPREPARE /D HAVE_PQEXECPREPARED /D HAVE_PQRESULTERRORFIELD /D HAVE_PQSENDQUERYPARAMS /D HAVE_PQSENDPREPARE /D HAVE_PQSENDQUERYPREPARED /D HAVE_PQPUTCOPYDATA /D HAVE_PQGETCOPYDATA /D HAVE_PQSETERRORVERBOSITY /D HAVE_PQUNESCAPEBYTEA /D HAVE_PQFTABLE /D HAVE_PQESCAPE_CONN /D HAVE_PQESCAPE_BYTEA_CONN /D HAVE_PQFREEMEM /D HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT /D HAVE_PQPROTOCOLVERSION /D HAVE_PG_LO_CREATE /D HAVE_PG_LO_IMPORT_WITH_OID /D HAVE_PG_LO_TRUNCATE" + (X64 ? " /D HAVE_PG_LO64" : "") + " /D HAVE_PQESCAPELITERAL /D HAVE_PQOIDVALUE");
+ ADD_FLAG("CFLAGS_PGSQL", "/D HAVE_PG_CONFIG_H /D PGSQL_EXPORTS /D HAVE_PQESCAPE_CONN /D HAVE_PQESCAPE_BYTEA_CONN /D HAVE_PQFREEMEM /D HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT /D HAVE_PG_LO_CREATE /D HAVE_PG_LO_IMPORT_WITH_OID /D HAVE_PG_LO_TRUNCATE" + (X64 ? " /D HAVE_PG_LO64" : "") + " /D HAVE_PQESCAPELITERAL");
} else {
WARNING("pgsql not enabled; libraries and headers not found");
}
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 0a5b088c00..a009aa360d 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -74,12 +74,6 @@
#define PGSQL_RETURN_OID(oid) RETURN_LONG((zend_long)oid)
#endif
-#ifdef HAVE_PQSETNONBLOCKING
-#define PQ_SETNONBLOCKING(pg_link, flag) PQsetnonblocking(pg_link, flag)
-#else
-#define PQ_SETNONBLOCKING(pg_link, flag) 0
-#endif
-
#define CHECK_DEFAULT_LINK(x) if ((x) == NULL) { php_error_docref(NULL, E_WARNING, "No PostgreSQL link opened yet"); RETURN_FALSE; }
#define FETCH_DEFAULT_LINK() PGG(default_link)
@@ -114,12 +108,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_connect_poll, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
ZEND_END_ARG_INFO()
-#ifdef HAVE_PQPARAMETERSTATUS
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_parameter_status, 0, 0, 1)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, param_name)
ZEND_END_ARG_INFO()
-#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_close, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
@@ -162,29 +154,23 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_query, 0, 0, 0)
ZEND_ARG_INFO(0, query)
ZEND_END_ARG_INFO()
-#ifdef HAVE_PQEXECPARAMS
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_query_params, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, query)
ZEND_ARG_INFO(0, params)
ZEND_END_ARG_INFO()
-#endif
-#ifdef HAVE_PQPREPARE
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_prepare, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, stmtname)
ZEND_ARG_INFO(0, query)
ZEND_END_ARG_INFO()
-#endif
-#ifdef HAVE_PQEXECPREPARED
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_execute, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, stmtname)
ZEND_ARG_INFO(0, params)
ZEND_END_ARG_INFO()
-#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_num_rows, 0, 0, 1)
ZEND_ARG_INFO(0, result)
@@ -194,24 +180,20 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_num_fields, 0, 0, 1)
ZEND_ARG_INFO(0, result)
ZEND_END_ARG_INFO()
-#ifdef HAVE_PQCMDTUPLES
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_affected_rows, 0, 0, 1)
ZEND_ARG_INFO(0, result)
ZEND_END_ARG_INFO()
-#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_last_notice, 0, 0, 1)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, option)
ZEND_END_ARG_INFO()
-#ifdef HAVE_PQFTABLE
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_field_table, 0, 0, 2)
ZEND_ARG_INFO(0, result)
ZEND_ARG_INFO(0, field_number)
ZEND_ARG_INFO(0, oid_only)
ZEND_END_ARG_INFO()
-#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_field_name, 0, 0, 2)
ZEND_ARG_INFO(0, result)
@@ -378,14 +360,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_lo_truncate, 0, 0, 1)
ZEND_END_ARG_INFO()
#endif
-#ifdef HAVE_PQSETERRORVERBOSITY
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_set_error_verbosity, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, verbosity)
ZEND_END_ARG_INFO()
-#endif
-#ifdef HAVE_PQCLIENTENCODING
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_set_client_encoding, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, encoding)
@@ -394,7 +373,6 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_client_encoding, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
ZEND_END_ARG_INFO()
-#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_end_copy, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
@@ -420,7 +398,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_copy_from, 0, 0, 3)
ZEND_ARG_INFO(0, null_as)
ZEND_END_ARG_INFO()
-#ifdef HAVE_PQESCAPE
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_escape_string, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, data)
@@ -434,9 +411,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_unescape_bytea, 0, 0, 1)
ZEND_ARG_INFO(0, data)
ZEND_END_ARG_INFO()
-#endif
-#ifdef HAVE_PQESCAPE
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_escape_literal, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, data)
@@ -445,28 +420,23 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_escape_identifier, 0, 0, 0)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, data)
ZEND_END_ARG_INFO()
-#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_result_error, 0, 0, 1)
ZEND_ARG_INFO(0, result)
ZEND_END_ARG_INFO()
-#ifdef HAVE_PQRESULTERRORFIELD
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_result_error_field, 0, 0, 2)
ZEND_ARG_INFO(0, result)
ZEND_ARG_INFO(0, fieldcode)
ZEND_END_ARG_INFO()
-#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_connection_status, 0, 0, 1)
ZEND_ARG_INFO(0, connection)
ZEND_END_ARG_INFO()
-#ifdef HAVE_PGTRANSACTIONSTATUS
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_transaction_status, 0, 0, 1)
ZEND_ARG_INFO(0, connection)
ZEND_END_ARG_INFO()
-#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_connection_reset, 0, 0, 1)
ZEND_ARG_INFO(0, connection)
@@ -485,29 +455,23 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_send_query, 0, 0, 2)
ZEND_ARG_INFO(0, query)
ZEND_END_ARG_INFO()
-#ifdef HAVE_PQSENDQUERYPARAMS
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_send_query_params, 0, 0, 3)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, query)
ZEND_ARG_INFO(0, params)
ZEND_END_ARG_INFO()
-#endif
-#ifdef HAVE_PQSENDPREPARE
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_send_prepare, 0, 0, 3)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, stmtname)
ZEND_ARG_INFO(0, query)
ZEND_END_ARG_INFO()
-#endif
-#ifdef HAVE_PQSENDQUERYPREPARED
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_send_execute, 0, 0, 3)
ZEND_ARG_INFO(0, connection)
ZEND_ARG_INFO(0, stmtname)
ZEND_ARG_INFO(0, params)
ZEND_END_ARG_INFO()
-#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_get_result, 0, 0, 1)
ZEND_ARG_INFO(0, connection)
@@ -600,33 +564,17 @@ static const zend_function_entry pgsql_functions[] = {
PHP_FE(pg_options, arginfo_pg_options)
PHP_FE(pg_version, arginfo_pg_version)
PHP_FE(pg_ping, arginfo_pg_ping)
-#ifdef HAVE_PQPARAMETERSTATUS
PHP_FE(pg_parameter_status, arginfo_pg_parameter_status)
-#endif
-#ifdef HAVE_PGTRANSACTIONSTATUS
PHP_FE(pg_transaction_status, arginfo_pg_transaction_status)
-#endif
/* query functions */
PHP_FE(pg_query, arginfo_pg_query)
-#ifdef HAVE_PQEXECPARAMS
PHP_FE(pg_query_params, arginfo_pg_query_params)
-#endif
-#ifdef HAVE_PQPREPARE
PHP_FE(pg_prepare, arginfo_pg_prepare)
-#endif
-#ifdef HAVE_PQEXECPREPARED
PHP_FE(pg_execute, arginfo_pg_execute)
-#endif
PHP_FE(pg_send_query, arginfo_pg_send_query)
-#ifdef HAVE_PQSENDQUERYPARAMS
PHP_FE(pg_send_query_params, arginfo_pg_send_query_params)
-#endif
-#ifdef HAVE_PQSENDPREPARE
PHP_FE(pg_send_prepare, arginfo_pg_send_prepare)
-#endif
-#ifdef HAVE_PQSENDQUERYPREPARED
PHP_FE(pg_send_execute, arginfo_pg_send_execute)
-#endif
PHP_FE(pg_cancel_query, arginfo_pg_cancel_query)
/* result functions */
PHP_FE(pg_fetch_result, arginfo_pg_fetch_result)
@@ -636,9 +584,7 @@ static const zend_function_entry pgsql_functions[] = {
PHP_FE(pg_fetch_object, arginfo_pg_fetch_object)
PHP_FE(pg_fetch_all, arginfo_pg_fetch_all)
PHP_FE(pg_fetch_all_columns, arginfo_pg_fetch_all_columns)
-#ifdef HAVE_PQCMDTUPLES
PHP_FE(pg_affected_rows,arginfo_pg_affected_rows)
-#endif
PHP_FE(pg_get_result, arginfo_pg_get_result)
PHP_FE(pg_result_seek, arginfo_pg_result_seek)
PHP_FE(pg_result_status,arginfo_pg_result_status)
@@ -653,9 +599,7 @@ static const zend_function_entry pgsql_functions[] = {
PHP_FE(pg_field_type_oid, arginfo_pg_field_type_oid)
PHP_FE(pg_field_prtlen, arginfo_pg_field_prtlen)
PHP_FE(pg_field_is_null,arginfo_pg_field_is_null)
-#ifdef HAVE_PQFTABLE
PHP_FE(pg_field_table, arginfo_pg_field_table)
-#endif
/* async message function */
PHP_FE(pg_get_notify, arginfo_pg_get_notify)
PHP_FE(pg_socket, arginfo_pg_socket)
@@ -664,9 +608,7 @@ static const zend_function_entry pgsql_functions[] = {
PHP_FE(pg_get_pid, arginfo_pg_get_pid)
/* error message functions */
PHP_FE(pg_result_error, arginfo_pg_result_error)
-#ifdef HAVE_PQRESULTERRORFIELD
PHP_FE(pg_result_error_field, arginfo_pg_result_error_field)
-#endif
PHP_FE(pg_last_error, arginfo_pg_last_error)
PHP_FE(pg_last_notice, arginfo_pg_last_notice)
/* copy functions */
@@ -693,20 +635,14 @@ static const zend_function_entry pgsql_functions[] = {
PHP_FE(pg_lo_truncate, arginfo_pg_lo_truncate)
#endif
/* utility functions */
-#ifdef HAVE_PQESCAPE
PHP_FE(pg_escape_string, arginfo_pg_escape_string)
PHP_FE(pg_escape_bytea, arginfo_pg_escape_bytea)
PHP_FE(pg_unescape_bytea, arginfo_pg_unescape_bytea)
PHP_FE(pg_escape_literal, arginfo_pg_escape_literal)
PHP_FE(pg_escape_identifier, arginfo_pg_escape_identifier)
-#endif
-#ifdef HAVE_PQSETERRORVERBOSITY
PHP_FE(pg_set_error_verbosity, arginfo_pg_set_error_verbosity)
-#endif
-#ifdef HAVE_PQCLIENTENCODING
PHP_FE(pg_client_encoding, arginfo_pg_client_encoding)
PHP_FE(pg_set_client_encoding, arginfo_pg_set_client_encoding)
-#endif
/* misc function */
PHP_FE(pg_meta_data, arginfo_pg_meta_data)
PHP_FE(pg_convert, arginfo_pg_convert)
@@ -717,9 +653,7 @@ static const zend_function_entry pgsql_functions[] = {
/* aliases for downwards compatibility */
PHP_FALIAS(pg_exec, pg_query, arginfo_pg_query)
PHP_FALIAS(pg_getlastoid, pg_last_oid, arginfo_pg_last_oid)
-#ifdef HAVE_PQCMDTUPLES
PHP_FALIAS(pg_cmdtuples, pg_affected_rows, arginfo_pg_affected_rows)
-#endif
PHP_FALIAS(pg_errormessage, pg_last_error, arginfo_pg_last_error)
PHP_FALIAS(pg_numrows, pg_num_rows, arginfo_pg_num_rows)
PHP_FALIAS(pg_numfields, pg_num_fields, arginfo_pg_num_fields)
@@ -740,10 +674,8 @@ static const zend_function_entry pgsql_functions[] = {
PHP_FALIAS(pg_lowrite, pg_lo_write, arginfo_pg_lo_write)
PHP_FALIAS(pg_loimport, pg_lo_import, arginfo_pg_lo_import)
PHP_FALIAS(pg_loexport, pg_lo_export, arginfo_pg_lo_export)
-#ifdef HAVE_PQCLIENTENCODING
PHP_FALIAS(pg_clientencoding, pg_client_encoding, arginfo_pg_client_encoding)
PHP_FALIAS(pg_setclientencoding, pg_set_client_encoding, arginfo_pg_set_client_encoding)
-#endif
PHP_FE_END
};
/* }}} */
@@ -1000,7 +932,7 @@ static int _rollback_transactions(zval *el)
link = (PGconn *) rsrc->ptr;
- if (PQ_SETNONBLOCKING(link, 0)) {
+ if (PQsetnonblocking(link, 0)) {
php_error_docref("ref.pgsql", E_NOTICE, "Cannot set connection to blocking mode");
return -1;
}
@@ -1008,19 +940,10 @@ static int _rollback_transactions(zval *el)
while ((res = PQgetResult(link))) {
PQclear(res);
}
-#if defined(HAVE_PGTRANSACTIONSTATUS) && defined(HAVE_PQPROTOCOLVERSION)
- if ((PQprotocolVersion(link) >= 3 && PQtransactionStatus(link) != PQTRANS_IDLE) || PQprotocolVersion(link) < 3)
-#endif
- {
+ if ((PQprotocolVersion(link) >= 3 && PQtransactionStatus(link) != PQTRANS_IDLE) || PQprotocolVersion(link) < 3) {
int orig = PGG(ignore_notices);
PGG(ignore_notices) = 1;
-#if defined(HAVE_PGTRANSACTIONSTATUS) && defined(HAVE_PQPROTOCOLVERSION)
- res = PQexec(link,"ROLLBACK;");
-#else
- res = PQexec(link,"BEGIN;");
- PQclear(res);
res = PQexec(link,"ROLLBACK;");
-#endif
PQclear(res);
PGG(ignore_notices) = orig;
}
@@ -1143,20 +1066,16 @@ PHP_MINIT_FUNCTION(pgsql)
REGISTER_LONG_CONSTANT("PGSQL_POLLING_WRITING", PGRES_POLLING_WRITING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_POLLING_OK", PGRES_POLLING_OK, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_POLLING_ACTIVE", PGRES_POLLING_ACTIVE, CONST_CS | CONST_PERSISTENT);
-#ifdef HAVE_PGTRANSACTIONSTATUS
/* For pg_transaction_status() */
REGISTER_LONG_CONSTANT("PGSQL_TRANSACTION_IDLE", PQTRANS_IDLE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_TRANSACTION_ACTIVE", PQTRANS_ACTIVE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_TRANSACTION_INTRANS", PQTRANS_INTRANS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_TRANSACTION_INERROR", PQTRANS_INERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_TRANSACTION_UNKNOWN", PQTRANS_UNKNOWN, CONST_CS | CONST_PERSISTENT);
-#endif
-#ifdef HAVE_PQSETERRORVERBOSITY
/* For pg_set_error_verbosity() */
REGISTER_LONG_CONSTANT("PGSQL_ERRORS_TERSE", PQERRORS_TERSE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_ERRORS_DEFAULT", PQERRORS_DEFAULT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_ERRORS_VERBOSE", PQERRORS_VERBOSE, CONST_CS | CONST_PERSISTENT);
-#endif
/* For lo_seek() */
REGISTER_LONG_CONSTANT("PGSQL_SEEK_SET", SEEK_SET, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_SEEK_CUR", SEEK_CUR, CONST_CS | CONST_PERSISTENT);
@@ -1173,7 +1092,6 @@ PHP_MINIT_FUNCTION(pgsql)
REGISTER_LONG_CONSTANT("PGSQL_BAD_RESPONSE", PGRES_BAD_RESPONSE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_NONFATAL_ERROR", PGRES_NONFATAL_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_FATAL_ERROR", PGRES_FATAL_ERROR, CONST_CS | CONST_PERSISTENT);
-#ifdef HAVE_PQRESULTERRORFIELD
/* For pg_result_error_field() field codes */
REGISTER_LONG_CONSTANT("PGSQL_DIAG_SEVERITY", PG_DIAG_SEVERITY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_DIAG_SQLSTATE", PG_DIAG_SQLSTATE, CONST_CS | CONST_PERSISTENT);
@@ -1209,7 +1127,6 @@ PHP_MINIT_FUNCTION(pgsql)
#ifdef PG_DIAG_SEVERITY_NONLOCALIZED
REGISTER_LONG_CONSTANT("PGSQL_DIAG_SEVERITY_NONLOCALIZED", PG_DIAG_SEVERITY_NONLOCALIZED, CONST_CS | CONST_PERSISTENT);
#endif
-#endif
/* pg_convert options */
REGISTER_LONG_CONSTANT("PGSQL_CONV_IGNORE_DEFAULT", PGSQL_CONV_IGNORE_DEFAULT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_CONV_FORCE_NULL", PGSQL_CONV_FORCE_NULL, CONST_CS | CONST_PERSISTENT);
@@ -1421,11 +1338,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
}
pgsql = (PGconn *) le->ptr;
-#if defined(HAVE_PQPROTOCOLVERSION) && defined(HAVE_PQPARAMETERSTATUS)
if (PQprotocolVersion(pgsql) >= 3 && atof(PQparameterStatus(pgsql, "server_version")) >= 7.2) {
-#else
- if (atof(PG_VERSION) >= 7.2) {
-#endif
pg_result = PQexec(pgsql, "RESET ALL;");
PQclear(pg_result);
}
@@ -1662,9 +1575,7 @@ static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type
case PHP_PG_VERSION:
array_init(return_value);
add_assoc_string(return_value, "client", PG_VERSION);
-#ifdef HAVE_PQPROTOCOLVERSION
add_assoc_long(return_value, "protocol", PQprotocolVersion(pgsql));
-#ifdef HAVE_PQPARAMETERSTATUS
if (PQprotocolVersion(pgsql) >= 3) {
/* 8.0 or grater supports protorol version 3 */
char *tmp;
@@ -1685,8 +1596,6 @@ static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type
PHP_PQ_COPY_PARAM("standard_conforming_strings");
PHP_PQ_COPY_PARAM("application_name");
}
-#endif
-#endif
return;
default:
RETURN_FALSE;
@@ -1755,7 +1664,6 @@ PHP_FUNCTION(pg_version)
}
/* }}} */
-#ifdef HAVE_PQPARAMETERSTATUS
/* {{{ proto string|false pg_parameter_status([resource connection,] string param_name)
Returns the value of a server parameter */
PHP_FUNCTION(pg_parameter_status)
@@ -1789,7 +1697,6 @@ PHP_FUNCTION(pg_parameter_status)
}
}
/* }}} */
-#endif
/* {{{ proto bool pg_ping([resource connection])
Ping database. If connection is bad, try to reconnect. */
@@ -1859,7 +1766,7 @@ PHP_FUNCTION(pg_query)
RETURN_THROWS();
}
- if (PQ_SETNONBLOCKING(pgsql, 0)) {
+ if (PQsetnonblocking(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
@@ -1909,7 +1816,6 @@ PHP_FUNCTION(pg_query)
}
/* }}} */
-#if defined(HAVE_PQEXECPARAMS) || defined(HAVE_PQEXECPREPARED) || defined(HAVE_PQSENDQUERYPARAMS) || defined(HAVE_PQSENDQUERYPREPARED)
/* {{{ _php_pgsql_free_params */
static void _php_pgsql_free_params(char **params, int num_params)
{
@@ -1924,9 +1830,7 @@ static void _php_pgsql_free_params(char **params, int num_params)
}
}
/* }}} */
-#endif
-#ifdef HAVE_PQEXECPARAMS
/* {{{ proto resource pg_query_params([resource connection,] string query, array params)
Execute a query */
PHP_FUNCTION(pg_query_params)
@@ -1962,7 +1866,7 @@ PHP_FUNCTION(pg_query_params)
RETURN_THROWS();
}
- if (PQ_SETNONBLOCKING(pgsql, 0)) {
+ if (PQsetnonblocking(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
@@ -2043,9 +1947,7 @@ PHP_FUNCTION(pg_query_params)
}
}
/* }}} */
-#endif
-#ifdef HAVE_PQPREPARE
/* {{{ proto resource pg_prepare([resource connection,] string stmtname, string query)
Prepare a query for future execution */
PHP_FUNCTION(pg_prepare)
@@ -2078,7 +1980,7 @@ PHP_FUNCTION(pg_prepare)
RETURN_THROWS();
}
- if (PQ_SETNONBLOCKING(pgsql, 0)) {
+ if (PQsetnonblocking(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
@@ -2127,9 +2029,7 @@ PHP_FUNCTION(pg_prepare)
}
}
/* }}} */
-#endif
-#ifdef HAVE_PQEXECPREPARED
/* {{{ proto resource pg_execute([resource connection,] string stmtname, array params)
Execute a prepared query */
PHP_FUNCTION(pg_execute)
@@ -2165,7 +2065,7 @@ PHP_FUNCTION(pg_execute)
RETURN_THROWS();
}
- if (PQ_SETNONBLOCKING(pgsql, 0)) {
+ if (PQsetnonblocking(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
@@ -2240,7 +2140,6 @@ PHP_FUNCTION(pg_execute)
}
}
/* }}} */
-#endif
#define PHP_PG_NUM_ROWS 1
#define PHP_PG_NUM_FIELDS 2
@@ -2272,12 +2171,7 @@ static void php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAMETERS, int entry_ty
RETVAL_LONG(PQnfields(pgsql_result));
break;
case PHP_PG_CMD_TUPLES:
-#ifdef HAVE_PQCMDTUPLES
RETVAL_LONG(atoi(PQcmdTuples(pgsql_result)));
-#else
- php_error_docref(NULL, E_WARNING, "Not supported under this build");
- RETVAL_LONG(0);
-#endif
break;
default:
RETURN_FALSE;
@@ -2301,7 +2195,6 @@ PHP_FUNCTION(pg_num_fields)
}
/* }}} */
-#ifdef HAVE_PQCMDTUPLES
/* {{{ proto int pg_affected_rows(resource result)
Returns the number of affected tuples */
PHP_FUNCTION(pg_affected_rows)
@@ -2309,7 +2202,6 @@ PHP_FUNCTION(pg_affected_rows)
php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_CMD_TUPLES);
}
/* }}} */
-#endif
/* {{{ proto mixed pg_last_notice(resource connection [, int option])
Returns the last notice set by the backend */
@@ -2425,7 +2317,6 @@ static char *get_field_name(PGconn *pgsql, Oid oid, HashTable *list)
}
/* }}} */
-#ifdef HAVE_PQFTABLE
/* {{{ proto mixed pg_field_table(resource result, int field_number[, bool oid_only])
Returns the name of the table field belongs to, or table's oid if oid_only is true */
PHP_FUNCTION(pg_field_table)
@@ -2515,7 +2406,6 @@ PHP_FUNCTION(pg_field_table)
}
/* }}} */
-#endif
#define PHP_PG_FIELD_NAME 1
#define PHP_PG_FIELD_SIZE 2
@@ -3118,9 +3008,7 @@ PHP_FUNCTION(pg_last_oid)
zval *result;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
-#ifdef HAVE_PQOIDVALUE
Oid oid;
-#endif
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &result) == FAILURE) {
RETURN_THROWS();
@@ -3131,19 +3019,11 @@ PHP_FUNCTION(pg_last_oid)
}
pgsql_result = pg_result->result;
-#ifdef HAVE_PQOIDVALUE
oid = PQoidValue(pgsql_result);
if (oid == InvalidOid) {
RETURN_FALSE;
}
PGSQL_RETURN_OID(oid);
-#else
- Z_STRVAL_P(return_value) = (char *) PQoidStatus(pgsql_result);
- if (Z_STRVAL_P(return_value)) {
- RETURN_STRING(Z_STRVAL_P(return_value));
- }
- RETURN_EMPTY_STRING();
-#endif
}
/* }}} */
@@ -3911,7 +3791,6 @@ PHP_FUNCTION(pg_lo_truncate)
/* }}} */
#endif
-#ifdef HAVE_PQSETERRORVERBOSITY
/* {{{ proto int pg_set_error_verbosity([resource connection,] int verbosity)
Set error verbosity */
PHP_FUNCTION(pg_set_error_verbosity)
@@ -3946,9 +3825,7 @@ PHP_FUNCTION(pg_set_error_verbosity)
}
}
/* }}} */
-#endif
-#ifdef HAVE_PQCLIENTENCODING
/* {{{ proto int pg_set_client_encoding([resource connection,] string encoding)
Set client encoding */
PHP_FUNCTION(pg_set_client_encoding)
@@ -4010,11 +3887,6 @@ PHP_FUNCTION(pg_client_encoding)
RETURN_STRING((char *) pg_encoding_to_char(PQclientEncoding(pgsql)));
}
/* }}} */
-#endif
-
-#ifndef HAVE_PQGETCOPYDATA
-#define COPYBUFSIZ 8192
-#endif
/* {{{ proto bool pg_end_copy([resource connection])
Sync with backend. Completes the Copy command */
@@ -4141,13 +4013,9 @@ PHP_FUNCTION(pg_copy_to)
case PGRES_COPY_OUT:
if (pgsql_result) {
int copydone = 0;
-#ifndef HAVE_PQGETCOPYDATA
- char copybuf[COPYBUFSIZ];
-#endif
PQclear(pgsql_result);
array_init(return_value);
-#ifdef HAVE_PQGETCOPYDATA
while (!copydone)
{
int ret = PQgetCopyData(pgsql, &csv, 0);
@@ -4166,48 +4034,6 @@ PHP_FUNCTION(pg_copy_to)
break;
}
}
-#else
- while (!copydone)
- {
- if ((ret = PQgetline(pgsql, copybuf, COPYBUFSIZ))) {
- PHP_PQ_ERROR("getline failed: %s", pgsql);
- RETURN_FALSE;
- }
-
- if (copybuf[0] == '\\' &&
- copybuf[1] == '.' &&
- copybuf[2] == '\0')
- {
- copydone = 1;
- }
- else
- {
- if (csv == (char *)NULL) {
- csv = estrdup(copybuf);
- } else {
- csv = (char *)erealloc(csv, strlen(csv) + sizeof(char)*(COPYBUFSIZ+1));
- strcat(csv, copybuf);
- }
-
- switch (ret)
- {
- case EOF:
- copydone = 1;
- case 0:
- add_next_index_string(return_value, csv);
- efree(csv);
- csv = (char *)NULL;
- break;
- case 1:
- break;
- }
- }
- }
- if (PQendcopy(pgsql)) {
- PHP_PQ_ERROR("endcopy failed: %s", pgsql);
- RETURN_FALSE;
- }
-#endif
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
}
@@ -4280,7 +4106,6 @@ PHP_FUNCTION(pg_copy_from)
if (pgsql_result) {
int command_failed = 0;
PQclear(pgsql_result);
-#ifdef HAVE_PQPUTCOPYDATA
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pg_rows), value) {
zend_string *tmp = zval_try_get_string(value);
if (UNEXPECTED(!tmp)) {
@@ -4305,36 +4130,6 @@ PHP_FUNCTION(pg_copy_from)
PHP_PQ_ERROR("putcopyend failed: %s", pgsql);
RETURN_FALSE;
}
-#else
- ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pg_rows), value) {
- zend_string *tmp = zval_try_get_string(value);
- if (UNEXPECTED(!tmp)) {
- return;
- }
- query = (char *)emalloc(ZSTR_LEN(tmp) + 2);
- strlcpy(query, ZSTR_LVAL(tmp), ZSTR_LEN(tmp) + 2);
- if (ZSTR_LEN(tmp) > 0 && *(query + ZSTR_LEN(tmp) - 1) != '\n') {
- strlcat(query, "\n", ZSTR_LEN(tmp) + 2);
- }
- if (PQputline(pgsql, query)==EOF) {
- efree(query);
- zend_string_release(tmp);
- PHP_PQ_ERROR("copy failed: %s", pgsql);
- RETURN_FALSE;
- }
- efree(query);
- zend_string_release(tmp);
- } ZEND_HASH_FOREACH_END();
-
- if (PQputline(pgsql, "\\.\n") == EOF) {
- PHP_PQ_ERROR("putline failed: %s", pgsql);
- RETURN_FALSE;
- }
- if (PQendcopy(pgsql)) {
- PHP_PQ_ERROR("endcopy failed: %s", pgsql);
- RETURN_FALSE;
- }
-#endif
while ((pgsql_result = PQgetResult(pgsql))) {
if (PGRES_COMMAND_OK != PQresultStatus(pgsql_result)) {
PHP_PQ_ERROR("Copy command failed: %s", pgsql);
@@ -4360,7 +4155,6 @@ PHP_FUNCTION(pg_copy_from)
}
/* }}} */
-#ifdef HAVE_PQESCAPE
/* {{{ proto string pg_escape_string([resource connection,] string data)
Escape string for text/char type */
PHP_FUNCTION(pg_escape_string)
@@ -4448,113 +4242,6 @@ PHP_FUNCTION(pg_escape_bytea)
}
/* }}} */
-#ifndef HAVE_PQUNESCAPEBYTEA
-/* PQunescapeBytea() from PostgreSQL 7.3 to provide bytea unescape feature to 7.2 users.
- Renamed to php_pgsql_unescape_bytea() */
-/*
- * PQunescapeBytea - converts the null terminated string representation
- * of a bytea, strtext, into binary, filling a buffer. It returns a
- * pointer to the buffer which is NULL on error, and the size of the
- * buffer in retbuflen. The pointer may subsequently be used as an
- * argument to the function free(3). It is the reverse of PQescapeBytea.
- *
- * The following transformations are reversed:
- * '\0' == ASCII 0 == \000
- * '\'' == ASCII 39 == \'
- * '\\' == ASCII 92 == \\
- *
- * States:
- * 0 normal 0->1->2->3->4
- * 1 \ 1->5
- * 2 \0 1->6
- * 3 \00
- * 4 \000
- * 5 \'
- * 6 \\
- */
-static unsigned char * php_pgsql_unescape_bytea(unsigned char *strtext, size_t *retbuflen) /* {{{ */
-{
- size_t buflen;
- unsigned char *buffer,
- *sp,
- *bp;
- unsigned int state = 0;
-
- if (strtext == NULL)
- return NULL;
- buflen = strlen(strtext); /* will shrink, also we discover if
- * strtext */
- buffer = (unsigned char *) emalloc(buflen); /* isn't NULL terminated */
- for (bp = buffer, sp = strtext; *sp != '\0'; bp++, sp++)
- {
- switch (state)
- {
- case 0:
- if (*sp == '\\')
- state = 1;
- *bp = *sp;
- break;
- case 1:
- if (*sp == '\'') /* state=5 */
- { /* replace \' with 39 */
- bp--;
- *bp = '\'';
- buflen--;
- state = 0;
- }
- else if (*sp == '\\') /* state=6 */
- { /* replace \\ with 92 */
- bp--;
- *bp = '\\';
- buflen--;
- state = 0;
- }
- else
- {
- if (isdigit(*sp))
- state = 2;
- else
- state = 0;
- *bp = *sp;
- }
- break;
- case 2:
- if (isdigit(*sp))
- state = 3;
- else
- state = 0;
- *bp = *sp;
- break;
- case 3:
- if (isdigit(*sp)) /* state=4 */
- {
- unsigned char *start, *end, buf[4]; /* 000 + '\0' */
-
- bp -= 3;
- memcpy(buf, sp-2, 3);
- buf[3] = '\0';
- start = buf;
- *bp = (unsigned char)strtoul(start, (char **)&end, 8);
- buflen -= 3;
- state = 0;
- }
- else
- {
- *bp = *sp;
- state = 0;
- }
- break;
- }
- }
- buffer = erealloc(buffer, buflen+1);
- buffer[buflen] = '\0';
-
- *retbuflen = buflen;
- return buffer;
-}
-/* }}} */
-#endif
-
/* {{{ proto string pg_unescape_bytea(string data)
Unescape binary for bytea type */
PHP_FUNCTION(pg_unescape_bytea)
@@ -4567,13 +4254,9 @@ PHP_FUNCTION(pg_unescape_bytea)
RETURN_THROWS();
}
-#ifdef HAVE_PQUNESCAPEBYTEA
tmp = (char *)PQunescapeBytea((unsigned char*)from, &to_len);
to = estrndup(tmp, to_len);
PQfreemem(tmp);
-#else
- to = (char *)php_pgsql_unescape_bytea((unsigned char*)from, &to_len);
-#endif
if (!to) {
php_error_docref(NULL, E_WARNING,"Invalid parameter");
RETURN_FALSE;
@@ -4582,9 +4265,7 @@ PHP_FUNCTION(pg_unescape_bytea)
efree(to);
}
/* }}} */
-#endif
-#ifdef HAVE_PQESCAPE
static void php_pgsql_escape_internal(INTERNAL_FUNCTION_PARAMETERS, int escape_literal) /* {{{ */ {
char *from = NULL;
zval *pgsql_link = NULL;
@@ -4649,7 +4330,6 @@ PHP_FUNCTION(pg_escape_identifier)
php_pgsql_escape_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
-#endif
/* {{{ proto string pg_result_error(resource result)
Get error message associated with result */
@@ -4678,7 +4358,6 @@ PHP_FUNCTION(pg_result_error)
}
/* }}} */
-#ifdef HAVE_PQRESULTERRORFIELD
/* {{{ proto string pg_result_error_field(resource result, int fieldcode)
Get error message field associated with result */
PHP_FUNCTION(pg_result_error_field)
@@ -4723,7 +4402,6 @@ PHP_FUNCTION(pg_result_error_field)
}
}
/* }}} */
-#endif
/* {{{ proto int pg_connection_status(resource connection)
Get connection status */
@@ -4746,7 +4424,6 @@ PHP_FUNCTION(pg_connection_status)
/* }}} */
-#ifdef HAVE_PGTRANSACTIONSTATUS
/* {{{ proto int pg_transaction_status(resource connection)
Get transaction status */
PHP_FUNCTION(pg_transaction_status)
@@ -4765,7 +4442,6 @@ PHP_FUNCTION(pg_transaction_status)
RETURN_LONG(PQtransactionStatus(pgsql));
}
-#endif
/* }}} */
@@ -4803,7 +4479,7 @@ static int php_pgsql_flush_query(PGconn *pgsql)
PGresult *res;
int leftover = 0;
- if (PQ_SETNONBLOCKING(pgsql, 1)) {
+ if (PQsetnonblocking(pgsql, 1)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to nonblocking mode");
return -1;
}
@@ -4811,7 +4487,7 @@ static int php_pgsql_flush_query(PGconn *pgsql)
PQclear(res);
leftover++;
}
- PQ_SETNONBLOCKING(pgsql, 0);
+ PQsetnonblocking(pgsql, 0);
return leftover;
}
/* }}} */
@@ -4833,7 +4509,7 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
RETURN_THROWS();
}
- if (PQ_SETNONBLOCKING(pgsql, 1)) {
+ if (PQsetnonblocking(pgsql, 1)) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
@@ -4852,7 +4528,7 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
php_error_docref(NULL, E_ERROR, "PostgreSQL module error, please report this error");
break;
}
- if (PQ_SETNONBLOCKING(pgsql, 0)) {
+ if (PQsetnonblocking(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to blocking mode");
}
convert_to_boolean_ex(return_value);
@@ -4907,7 +4583,7 @@ PHP_FUNCTION(pg_send_query)
is_non_blocking = PQisnonblocking(pgsql);
- if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 1) == -1) {
+ if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
@@ -4941,7 +4617,7 @@ PHP_FUNCTION(pg_send_query)
usleep(10000);
}
- if (PQ_SETNONBLOCKING(pgsql, 0)) {
+ if (PQsetnonblocking(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to blocking mode");
}
}
@@ -4956,7 +4632,6 @@ PHP_FUNCTION(pg_send_query)
}
/* }}} */
-#ifdef HAVE_PQSENDQUERYPARAMS
/* {{{ proto bool pg_send_query_params(resource connection, string query, array params)
Send asynchronous parameterized query */
PHP_FUNCTION(pg_send_query_params)
@@ -4980,7 +4655,7 @@ PHP_FUNCTION(pg_send_query_params)
is_non_blocking = PQisnonblocking(pgsql);
- if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 1) == -1) {
+ if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
@@ -5038,7 +4713,7 @@ PHP_FUNCTION(pg_send_query_params)
usleep(10000);
}
- if (PQ_SETNONBLOCKING(pgsql, 0) != 0) {
+ if (PQsetnonblocking(pgsql, 0) != 0) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to blocking mode");
}
}
@@ -5052,9 +4727,7 @@ PHP_FUNCTION(pg_send_query_params)
}
}
/* }}} */
-#endif
-#ifdef HAVE_PQSENDPREPARE
/* {{{ proto bool pg_send_prepare(resource connection, string stmtname, string query)
Asynchronously prepare a query for future execution */
PHP_FUNCTION(pg_send_prepare)
@@ -5076,7 +4749,7 @@ PHP_FUNCTION(pg_send_prepare)
is_non_blocking = PQisnonblocking(pgsql);
- if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 1) == -1) {
+ if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
@@ -5110,7 +4783,7 @@ PHP_FUNCTION(pg_send_prepare)
}
usleep(10000);
}
- if (PQ_SETNONBLOCKING(pgsql, 0) != 0) {
+ if (PQsetnonblocking(pgsql, 0) != 0) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to blocking mode");
}
}
@@ -5124,9 +4797,7 @@ PHP_FUNCTION(pg_send_prepare)
}
}
/* }}} */
-#endif
-#ifdef HAVE_PQSENDQUERYPREPARED
/* {{{ proto bool pg_send_execute(resource connection, string stmtname, array params)
Executes prevriously prepared stmtname asynchronously */
PHP_FUNCTION(pg_send_execute)
@@ -5151,7 +4822,7 @@ PHP_FUNCTION(pg_send_execute)
is_non_blocking = PQisnonblocking(pgsql);
- if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 1) == -1) {
+ if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
@@ -5210,7 +4881,7 @@ PHP_FUNCTION(pg_send_execute)
}
usleep(10000);
}
- if (PQ_SETNONBLOCKING(pgsql, 0) != 0) {
+ if (PQsetnonblocking(pgsql, 0) != 0) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to blocking mode");
}
}
@@ -5224,7 +4895,6 @@ PHP_FUNCTION(pg_send_execute)
}
}
/* }}} */
-#endif
/* {{{ proto resource pg_get_result(resource connection)
Get asynchronous query result */
@@ -5323,27 +4993,15 @@ PHP_FUNCTION(pg_get_notify)
if (result_type & PGSQL_NUM) {
add_index_string(return_value, 0, pgsql_notify->relname);
add_index_long(return_value, 1, pgsql_notify->be_pid);
-#if defined(HAVE_PQPROTOCOLVERSION) && defined(HAVE_PQPARAMETERSTATUS)
if (PQprotocolVersion(pgsql) >= 3 && atof(PQparameterStatus(pgsql, "server_version")) >= 9.0) {
-#else
- if (atof(PG_VERSION) >= 9.0) {
-#endif
-#ifdef HAVE_PQPARAMETERSTATUS
add_index_string(return_value, 2, pgsql_notify->extra);
-#endif
}
}
if (result_type & PGSQL_ASSOC) {
add_assoc_string(return_value, "message", pgsql_notify->relname);
add_assoc_long(return_value, "pid", pgsql_notify->be_pid);
-#if defined(HAVE_PQPROTOCOLVERSION) && defined(HAVE_PQPARAMETERSTATUS)
if (PQprotocolVersion(pgsql) >= 3 && atof(PQparameterStatus(pgsql, "server_version")) >= 9.0) {
-#else
- if (atof(PG_VERSION) >= 9.0) {
-#endif
-#ifdef HAVE_PQPARAMETERSTATUS
add_assoc_string(return_value, "payload", pgsql_notify->extra);
-#endif
}
}
PQfreemem(pgsql_notify);
@@ -5399,7 +5057,7 @@ static int php_pgsql_fd_set_option(php_stream *stream, int option, int value, vo
PGconn *pgsql = (PGconn *) stream->abstract;
switch (option) {
case PHP_STREAM_OPTION_BLOCKING:
- return PQ_SETNONBLOCKING(pgsql, value);
+ return PQsetnonblocking(pgsql, value);
default:
return FAILURE;
}
@@ -5494,14 +5152,14 @@ PHP_FUNCTION(pg_flush)
is_non_blocking = PQisnonblocking(pgsql);
- if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 1) == -1) {
+ if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
ret = PQflush(pgsql);
- if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 0) == -1) {
+ if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 0) == -1) {
php_error_docref(NULL, E_NOTICE, "Failed resetting connection to blocking mode");
}
@@ -6384,7 +6042,6 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
}
break;
-#ifdef HAVE_PQESCAPE
case PG_BYTEA:
switch (Z_TYPE_P(val)) {
case IS_STRING:
@@ -6432,7 +6089,6 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
}
break;
-#endif
case PG_MACADDR:
switch(Z_TYPE_P(val)) {
case IS_STRING:
diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h
index bf7b8d5221..d1509a886e 100644
--- a/ext/pgsql/php_pgsql.h
+++ b/ext/pgsql/php_pgsql.h
@@ -77,33 +77,17 @@ PHP_FUNCTION(pg_tty);
PHP_FUNCTION(pg_options);
PHP_FUNCTION(pg_version);
PHP_FUNCTION(pg_ping);
-#ifdef HAVE_PQPARAMETERSTATUS
PHP_FUNCTION(pg_parameter_status);
-#endif
-#ifdef HAVE_PGTRANSACTIONSTATUS
PHP_FUNCTION(pg_transaction_status);
-#endif
/* query functions */
PHP_FUNCTION(pg_query);
-#ifdef HAVE_PQEXECPARAMS
PHP_FUNCTION(pg_query_params);
-#endif
-#ifdef HAVE_PQPREPARE
PHP_FUNCTION(pg_prepare);
-#endif
-#ifdef HAVE_PQEXECPREPARED
PHP_FUNCTION(pg_execute);
-#endif
PHP_FUNCTION(pg_send_query);
-#ifdef HAVE_PQSENDQUERYPARAMS
PHP_FUNCTION(pg_send_query_params);
-#endif
-#ifdef HAVE_PQSENDPREPARE
PHP_FUNCTION(pg_send_prepare);
-#endif
-#ifdef HAVE_PQSENDQUERYPREPARED
PHP_FUNCTION(pg_send_execute);
-#endif
PHP_FUNCTION(pg_cancel_query);
/* result functions */
PHP_FUNCTION(pg_fetch_assoc);
@@ -113,9 +97,7 @@ PHP_FUNCTION(pg_fetch_result);
PHP_FUNCTION(pg_fetch_row);
PHP_FUNCTION(pg_fetch_all);
PHP_FUNCTION(pg_fetch_all_columns);
-#ifdef HAVE_PQCMDTUPLES
PHP_FUNCTION(pg_affected_rows);
-#endif
PHP_FUNCTION(pg_get_result);
PHP_FUNCTION(pg_result_seek);
PHP_FUNCTION(pg_result_status);
@@ -139,9 +121,7 @@ PHP_FUNCTION(pg_flush);
PHP_FUNCTION(pg_get_pid);
/* error message functions */
PHP_FUNCTION(pg_result_error);
-#ifdef HAVE_PQRESULTERRORFIELD
PHP_FUNCTION(pg_result_error_field);
-#endif
PHP_FUNCTION(pg_last_error);
PHP_FUNCTION(pg_last_notice);
/* copy functions */
@@ -172,16 +152,12 @@ PHP_FUNCTION(pg_untrace);
/* utility functions */
PHP_FUNCTION(pg_client_encoding);
PHP_FUNCTION(pg_set_client_encoding);
-#ifdef HAVE_PQSETERRORVERBOSITY
PHP_FUNCTION(pg_set_error_verbosity);
-#endif
-#ifdef HAVE_PQESCAPE
PHP_FUNCTION(pg_escape_string);
PHP_FUNCTION(pg_escape_bytea);
PHP_FUNCTION(pg_unescape_bytea);
PHP_FUNCTION(pg_escape_literal);
PHP_FUNCTION(pg_escape_identifier);
-#endif
/* misc functions */
PHP_FUNCTION(pg_meta_data);