Revert incomplete PG pipeline addition

Closes GH-12735
This commit is contained in:
Jakub Zelenka 2023-11-20 14:06:34 +00:00
parent ff2b50889c
commit 1e66e6ae73
No known key found for this signature in database
GPG key ID: 1C0779DC5C0A9DE4
6 changed files with 44 additions and 438 deletions

View file

@ -3595,9 +3595,6 @@ PHP_FUNCTION(pg_send_query)
char *query;
size_t len;
PGconn *pgsql;
#ifdef LIBPQ_HAS_PIPELINING
bool is_pipeline_mode;
#endif
int is_non_blocking;
int ret;
@ -3609,40 +3606,23 @@ PHP_FUNCTION(pg_send_query)
CHECK_PGSQL_LINK(link);
pgsql = link->conn;
#ifdef LIBPQ_HAS_PIPELINING
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
if (is_pipeline_mode) {
is_non_blocking = 1;
} else {
#endif
is_non_blocking = PQisnonblocking(pgsql);
is_non_blocking = PQisnonblocking(pgsql);
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
if (_php_pgsql_link_has_results(pgsql)) {
php_error_docref(NULL, E_NOTICE,
"There are results on this connection. Call pg_get_result() until it returns FALSE");
}
#ifdef LIBPQ_HAS_PIPELINING
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
if (_php_pgsql_link_has_results(pgsql)) {
php_error_docref(NULL, E_NOTICE,
"There are results on this connection. Call pg_get_result() until it returns FALSE");
}
#endif
if (is_non_blocking) {
if (!PQsendQuery(pgsql, query)) {
RETURN_FALSE;
}
#ifdef LIBPQ_HAS_PIPELINING
if (is_pipeline_mode) {
ret = 0;
} else {
#endif
ret = PQflush(pgsql);
#ifdef LIBPQ_HAS_PIPELINING
}
#endif
ret = PQflush(pgsql);
} else {
if (!PQsendQuery(pgsql, query)) {
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
@ -3687,9 +3667,6 @@ PHP_FUNCTION(pg_send_query_params)
char *query;
size_t query_len;
PGconn *pgsql;
#ifdef LIBPQ_HAS_PIPELINING
bool is_pipeline_mode;
#endif
int is_non_blocking;
int ret;
@ -3701,26 +3678,17 @@ PHP_FUNCTION(pg_send_query_params)
CHECK_PGSQL_LINK(link);
pgsql = link->conn;
#ifdef LIBPQ_HAS_PIPELINING
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
if (is_pipeline_mode) {
is_non_blocking = 1;
} else {
#endif
is_non_blocking = PQisnonblocking(pgsql);
is_non_blocking = PQisnonblocking(pgsql);
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
if (_php_pgsql_link_has_results(pgsql)) {
php_error_docref(NULL, E_NOTICE,
"There are results on this connection. Call pg_get_result() until it returns FALSE");
}
#ifdef LIBPQ_HAS_PIPELINING
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
if (_php_pgsql_link_has_results(pgsql)) {
php_error_docref(NULL, E_NOTICE,
"There are results on this connection. Call pg_get_result() until it returns FALSE");
}
#endif
num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr));
if (num_params > 0) {
@ -3759,15 +3727,7 @@ PHP_FUNCTION(pg_send_query_params)
}
if (is_non_blocking) {
#ifdef LIBPQ_HAS_PIPELINING
if (is_pipeline_mode) {
ret = 0;
} else {
#endif
ret = PQflush(pgsql);
#ifdef LIBPQ_HAS_PIPELINING
}
#endif
ret = PQflush(pgsql);
} else {
/* Wait to finish sending buffer */
while ((ret = PQflush(pgsql))) {
@ -3801,9 +3761,6 @@ PHP_FUNCTION(pg_send_prepare)
char *query, *stmtname;
size_t stmtname_len, query_len;
PGconn *pgsql;
#ifdef LIBPQ_HAS_PIPELINING
bool is_pipeline_mode;
#endif
int is_non_blocking;
int ret;
@ -3815,26 +3772,17 @@ PHP_FUNCTION(pg_send_prepare)
CHECK_PGSQL_LINK(link);
pgsql = link->conn;
#ifdef LIBPQ_HAS_PIPELINING
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
if (is_pipeline_mode) {
is_non_blocking = 1;
} else {
#endif
is_non_blocking = PQisnonblocking(pgsql);
is_non_blocking = PQisnonblocking(pgsql);
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
if (_php_pgsql_link_has_results(pgsql)) {
php_error_docref(NULL, E_NOTICE,
"There are results on this connection. Call pg_get_result() until it returns FALSE");
}
#ifdef LIBPQ_HAS_PIPELINING
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
if (_php_pgsql_link_has_results(pgsql)) {
php_error_docref(NULL, E_NOTICE,
"There are results on this connection. Call pg_get_result() until it returns FALSE");
}
#endif
if (!PQsendPrepare(pgsql, stmtname, query, 0, NULL)) {
if (is_non_blocking) {
@ -3850,15 +3798,7 @@ PHP_FUNCTION(pg_send_prepare)
}
if (is_non_blocking) {
#ifdef LIBPQ_HAS_PIPELINING
if (is_pipeline_mode) {
ret = 0;
} else {
#endif
ret = PQflush(pgsql);
#ifdef LIBPQ_HAS_PIPELINING
}
#endif
ret = PQflush(pgsql);
} else {
/* Wait to finish sending buffer */
while ((ret = PQflush(pgsql))) {
@ -3894,9 +3834,6 @@ PHP_FUNCTION(pg_send_execute)
char *stmtname;
size_t stmtname_len;
PGconn *pgsql;
#ifdef LIBPQ_HAS_PIPELINING
bool is_pipeline_mode;
#endif
int is_non_blocking;
int ret;
@ -3908,26 +3845,17 @@ PHP_FUNCTION(pg_send_execute)
CHECK_PGSQL_LINK(link);
pgsql = link->conn;
#ifdef LIBPQ_HAS_PIPELINING
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
if (is_pipeline_mode) {
is_non_blocking = 1;
} else {
#endif
is_non_blocking = PQisnonblocking(pgsql);
is_non_blocking = PQisnonblocking(pgsql);
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
if (_php_pgsql_link_has_results(pgsql)) {
php_error_docref(NULL, E_NOTICE,
"There are results on this connection. Call pg_get_result() until it returns FALSE");
}
#ifdef LIBPQ_HAS_PIPELINING
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
RETURN_FALSE;
}
if (_php_pgsql_link_has_results(pgsql)) {
php_error_docref(NULL, E_NOTICE,
"There are results on this connection. Call pg_get_result() until it returns FALSE");
}
#endif
num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr));
if (num_params > 0) {
@ -3968,15 +3896,7 @@ PHP_FUNCTION(pg_send_execute)
}
if (is_non_blocking) {
#ifdef LIBPQ_HAS_PIPELINING
if (is_pipeline_mode) {
ret = 0;
} else {
#endif
ret = PQflush(pgsql);
#ifdef LIBPQ_HAS_PIPELINING
}
#endif
ret = PQflush(pgsql);
} else {
/* Wait to finish sending buffer */
while ((ret = PQflush(pgsql))) {
@ -5958,85 +5878,4 @@ PHP_FUNCTION(pg_select)
}
/* }}} */
#ifdef LIBPQ_HAS_PIPELINING
PHP_FUNCTION(pg_enter_pipeline_mode)
{
zval *pgsql_link;
pgsql_link_handle *pgsql_handle;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
RETURN_THROWS();
}
pgsql_handle = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(pgsql_handle);
PQsetnonblocking(pgsql_handle->conn, 1);
RETURN_BOOL(PQenterPipelineMode(pgsql_handle->conn));
}
PHP_FUNCTION(pg_exit_pipeline_mode)
{
zval *pgsql_link;
pgsql_link_handle *pgsql_handle;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
RETURN_THROWS();
}
pgsql_handle = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(pgsql_handle);
PQsetnonblocking(pgsql_handle->conn, 0);
RETURN_BOOL(PQexitPipelineMode(pgsql_handle->conn));
}
PHP_FUNCTION(pg_send_flush_request)
{
zval *pgsql_link;
pgsql_link_handle *pgsql_handle;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
RETURN_THROWS();
}
pgsql_handle = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(pgsql_handle);
RETURN_BOOL(PQsendFlushRequest(pgsql_handle->conn));
}
PHP_FUNCTION(pg_pipeline_sync)
{
zval *pgsql_link;
pgsql_link_handle *pgsql_handle;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
RETURN_THROWS();
}
pgsql_handle = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(pgsql_handle);
RETURN_BOOL(PQpipelineSync(pgsql_handle->conn));
}
PHP_FUNCTION(pg_pipeline_status)
{
zval *pgsql_link;
pgsql_link_handle *pgsql_handle;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
RETURN_THROWS();
}
pgsql_handle = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(pgsql_handle);
RETURN_LONG(PQpipelineStatus(pgsql_handle->conn));
}
#endif
#endif