mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
ext/pgsql: cleanup the 3rd protocol is supported since circa 2010. (#12465)
This commit is contained in:
parent
6518feced0
commit
045dc10b1b
8 changed files with 222 additions and 260 deletions
|
@ -362,7 +362,7 @@ static int _rollback_transactions(zval *el)
|
|||
while ((res = PQgetResult(link))) {
|
||||
PQclear(res);
|
||||
}
|
||||
if ((PQprotocolVersion(link) >= 3 && PQtransactionStatus(link) != PQTRANS_IDLE) || PQprotocolVersion(link) < 3) {
|
||||
if (PQtransactionStatus(link) != PQTRANS_IDLE) {
|
||||
int orig = PGG(ignore_notices);
|
||||
PGG(ignore_notices) = 1;
|
||||
res = PQexec(link,"ROLLBACK;");
|
||||
|
@ -614,7 +614,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
|
|||
}
|
||||
pgsql = (PGconn *) le->ptr;
|
||||
/* consider to use php_version_compare() here */
|
||||
if (PQprotocolVersion(pgsql) >= 3 && zend_strtod(PQparameterStatus(pgsql, "server_version"), NULL) >= 7.2) {
|
||||
if (zend_strtod(PQparameterStatus(pgsql, "server_version"), NULL) >= 7.2) {
|
||||
pg_result = PQexec(pgsql, "RESET ALL;");
|
||||
PQclear(pg_result);
|
||||
}
|
||||
|
@ -815,13 +815,11 @@ static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type
|
|||
case PHP_PG_HOST:
|
||||
result = PQhost(pgsql);
|
||||
break;
|
||||
case PHP_PG_VERSION:
|
||||
case PHP_PG_VERSION: {
|
||||
array_init(return_value);
|
||||
char *tmp;
|
||||
add_assoc_string(return_value, "client", pgsql_libpq_version);
|
||||
add_assoc_long(return_value, "protocol", PQprotocolVersion(pgsql));
|
||||
if (PQprotocolVersion(pgsql) >= 3) {
|
||||
/* 8.0 or grater supports protorol version 3 */
|
||||
char *tmp;
|
||||
add_assoc_string(return_value, "server", (char*)PQparameterStatus(pgsql, "server_version"));
|
||||
|
||||
#define PHP_PQ_COPY_PARAM(_x) tmp = (char*)PQparameterStatus(pgsql, _x); \
|
||||
|
@ -838,8 +836,8 @@ static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type
|
|||
PHP_PQ_COPY_PARAM("integer_datetimes");
|
||||
PHP_PQ_COPY_PARAM("standard_conforming_strings");
|
||||
PHP_PQ_COPY_PARAM("application_name");
|
||||
}
|
||||
return;
|
||||
}
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
}
|
||||
if (result) {
|
||||
|
@ -4015,7 +4013,7 @@ PHP_FUNCTION(pg_get_notify)
|
|||
add_index_string(return_value, 0, pgsql_notify->relname);
|
||||
add_index_long(return_value, 1, pgsql_notify->be_pid);
|
||||
/* consider to use php_version_compare() here */
|
||||
if (PQprotocolVersion(pgsql) >= 3 && zend_strtod(PQparameterStatus(pgsql, "server_version"), NULL) >= 9.0) {
|
||||
if (zend_strtod(PQparameterStatus(pgsql, "server_version"), NULL) >= 9.0) {
|
||||
add_index_string(return_value, 2, pgsql_notify->extra);
|
||||
}
|
||||
}
|
||||
|
@ -4023,7 +4021,7 @@ PHP_FUNCTION(pg_get_notify)
|
|||
add_assoc_string(return_value, "message", pgsql_notify->relname);
|
||||
add_assoc_long(return_value, "pid", pgsql_notify->be_pid);
|
||||
/* consider to use php_version_compare() here */
|
||||
if (PQprotocolVersion(pgsql) >= 3 && zend_strtod(PQparameterStatus(pgsql, "server_version"), NULL) >= 9.0) {
|
||||
if (zend_strtod(PQparameterStatus(pgsql, "server_version"), NULL) >= 9.0) {
|
||||
add_assoc_string(return_value, "payload", pgsql_notify->extra);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,6 @@ if (!function_exists('pg_query_params')) die('skip function pg_query_params() do
|
|||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] >= 3) {
|
||||
$result = pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100));
|
||||
if (!($rows = pg_num_rows($result)))
|
||||
{
|
||||
|
@ -52,7 +49,6 @@ if ($version['protocol'] >= 3) {
|
|||
pg_last_oid($result);
|
||||
|
||||
pg_free_result($result);
|
||||
}
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
|
|
|
@ -14,8 +14,6 @@ include('config.inc');
|
|||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] >= 3) {
|
||||
$result = pg_prepare($db, "php_test", "SELECT * FROM ".$table_name." WHERE num > \$1;");
|
||||
pg_result_error($result);
|
||||
pg_free_result($result);
|
||||
|
@ -58,7 +56,6 @@ if ($version['protocol'] >= 3) {
|
|||
pg_last_oid($result);
|
||||
|
||||
pg_free_result($result);
|
||||
}
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
|
|
|
@ -13,9 +13,6 @@ if (!function_exists('pg_send_query_params')) die('skip function pg_send_query_p
|
|||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] >= 3) {
|
||||
if (!pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))) {
|
||||
echo "pg_send_query_params() error\n";
|
||||
}
|
||||
|
@ -63,7 +60,6 @@ if ($version['protocol'] >= 3) {
|
|||
|
||||
pg_last_oid($result);
|
||||
pg_free_result($result);
|
||||
}
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
|
|
|
@ -13,9 +13,6 @@ if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() do
|
|||
include('config.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] >= 3) {
|
||||
if (!pg_send_prepare($db, 'php_test', "SELECT * FROM ".$table_name." WHERE num > \$1;")) {
|
||||
echo "pg_send_prepare() error\n";
|
||||
}
|
||||
|
@ -99,7 +96,6 @@ if ($version['protocol'] >= 3) {
|
|||
|
||||
pg_last_oid($result);
|
||||
pg_free_result($result);
|
||||
}
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
|
|
|
@ -14,13 +14,6 @@ include('config.inc');
|
|||
include('nonblocking.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] < 3) {
|
||||
echo "OK";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$db_socket = pg_socket($db);
|
||||
stream_set_blocking($db_socket, false);
|
||||
|
||||
|
|
|
@ -14,13 +14,6 @@ include('config.inc');
|
|||
include('nonblocking.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] < 3) {
|
||||
echo "OK";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$db_socket = pg_socket($db);
|
||||
stream_set_blocking($db_socket, false);
|
||||
|
||||
|
|
|
@ -14,13 +14,6 @@ include('config.inc');
|
|||
include('nonblocking.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] < 3) {
|
||||
echo "OK";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$db_socket = pg_socket($db);
|
||||
stream_set_blocking($db_socket, false);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue