Skip to content

Commit 1e66e6a

Browse files
committed
Revert incomplete PG pipeline addition
Closes phpGH-12735
1 parent ff2b508 commit 1e66e6a

File tree

6 files changed

+40
-434
lines changed

6 files changed

+40
-434
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ PHP NEWS
2828
- PCRE:
2929
. Fixed bug GH-12628 (The gh11374 test fails on Alpinelinux). (nielsdos)
3030

31+
- PGSQL:
32+
. Reverted PG pipeline addition. (Jakub Zelenka)
33+
3134
- PHPDBG:
3235
. Fixed bug GH-12675 (MEMORY_LEAK in phpdbg_prompt.c). (nielsdos)
3336

UPGRADING

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,6 @@ PHP 8.3 UPGRADE NOTES
435435
- PGSQL:
436436
. Added pg_set_error_context_visibility to set the visibility of the context
437437
in error messages (with libpq >= 9.6).
438-
. Added pg_enter_pipeline_mode().
439-
. Added pg_exit_pipeline_mode().
440-
. Added pg_send_flush_request().
441-
. Added pg_pipeline_sync().
442-
. Added pg_pipeline_status().
443438

444439
- Random:
445440
. Added Randomizer::getBytesFromString().
@@ -537,10 +532,6 @@ PHP 8.3 UPGRADE NOTES
537532
. PGSQL_TRACE_SUPPRESS_TIMESTAMPS
538533
. PGSQL_TRACE_REGRESS_MODE
539534
. PGSQL_ERRORS_SQLSTATE
540-
. PGSQL_PIPELINE_SYNC
541-
. PGSQL_PIPELINE_ON
542-
. PGSQL_PIPELINE_OFF
543-
. PGSQL_PIPELINE_ABORTED
544535
. PGSQL_SHOW_CONTEXT_NEVER
545536
. PGSQL_SHOW_CONTEXT_ERRORS
546537
. PGSQL_SHOW_CONTEXT_ALWAYS

ext/pgsql/pgsql.c

Lines changed: 36 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,9 +3595,6 @@ PHP_FUNCTION(pg_send_query)
35953595
char *query;
35963596
size_t len;
35973597
PGconn *pgsql;
3598-
#ifdef LIBPQ_HAS_PIPELINING
3599-
bool is_pipeline_mode;
3600-
#endif
36013598
int is_non_blocking;
36023599
int ret;
36033600

@@ -3609,40 +3606,23 @@ PHP_FUNCTION(pg_send_query)
36093606
CHECK_PGSQL_LINK(link);
36103607
pgsql = link->conn;
36113608

3612-
#ifdef LIBPQ_HAS_PIPELINING
3613-
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
3614-
if (is_pipeline_mode) {
3615-
is_non_blocking = 1;
3616-
} else {
3617-
#endif
3618-
is_non_blocking = PQisnonblocking(pgsql);
3609+
is_non_blocking = PQisnonblocking(pgsql);
36193610

3620-
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3621-
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3622-
RETURN_FALSE;
3623-
}
3611+
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3612+
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3613+
RETURN_FALSE;
3614+
}
36243615

3625-
if (_php_pgsql_link_has_results(pgsql)) {
3626-
php_error_docref(NULL, E_NOTICE,
3627-
"There are results on this connection. Call pg_get_result() until it returns FALSE");
3628-
}
3629-
#ifdef LIBPQ_HAS_PIPELINING
3616+
if (_php_pgsql_link_has_results(pgsql)) {
3617+
php_error_docref(NULL, E_NOTICE,
3618+
"There are results on this connection. Call pg_get_result() until it returns FALSE");
36303619
}
3631-
#endif
36323620

36333621
if (is_non_blocking) {
36343622
if (!PQsendQuery(pgsql, query)) {
36353623
RETURN_FALSE;
36363624
}
3637-
#ifdef LIBPQ_HAS_PIPELINING
3638-
if (is_pipeline_mode) {
3639-
ret = 0;
3640-
} else {
3641-
#endif
3642-
ret = PQflush(pgsql);
3643-
#ifdef LIBPQ_HAS_PIPELINING
3644-
}
3645-
#endif
3625+
ret = PQflush(pgsql);
36463626
} else {
36473627
if (!PQsendQuery(pgsql, query)) {
36483628
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
@@ -3687,9 +3667,6 @@ PHP_FUNCTION(pg_send_query_params)
36873667
char *query;
36883668
size_t query_len;
36893669
PGconn *pgsql;
3690-
#ifdef LIBPQ_HAS_PIPELINING
3691-
bool is_pipeline_mode;
3692-
#endif
36933670
int is_non_blocking;
36943671
int ret;
36953672

@@ -3701,26 +3678,17 @@ PHP_FUNCTION(pg_send_query_params)
37013678
CHECK_PGSQL_LINK(link);
37023679
pgsql = link->conn;
37033680

3704-
#ifdef LIBPQ_HAS_PIPELINING
3705-
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
3706-
if (is_pipeline_mode) {
3707-
is_non_blocking = 1;
3708-
} else {
3709-
#endif
3710-
is_non_blocking = PQisnonblocking(pgsql);
3681+
is_non_blocking = PQisnonblocking(pgsql);
37113682

3712-
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3713-
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3714-
RETURN_FALSE;
3715-
}
3683+
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3684+
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3685+
RETURN_FALSE;
3686+
}
37163687

3717-
if (_php_pgsql_link_has_results(pgsql)) {
3718-
php_error_docref(NULL, E_NOTICE,
3719-
"There are results on this connection. Call pg_get_result() until it returns FALSE");
3720-
}
3721-
#ifdef LIBPQ_HAS_PIPELINING
3688+
if (_php_pgsql_link_has_results(pgsql)) {
3689+
php_error_docref(NULL, E_NOTICE,
3690+
"There are results on this connection. Call pg_get_result() until it returns FALSE");
37223691
}
3723-
#endif
37243692

37253693
num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr));
37263694
if (num_params > 0) {
@@ -3759,15 +3727,7 @@ PHP_FUNCTION(pg_send_query_params)
37593727
}
37603728

37613729
if (is_non_blocking) {
3762-
#ifdef LIBPQ_HAS_PIPELINING
3763-
if (is_pipeline_mode) {
3764-
ret = 0;
3765-
} else {
3766-
#endif
3767-
ret = PQflush(pgsql);
3768-
#ifdef LIBPQ_HAS_PIPELINING
3769-
}
3770-
#endif
3730+
ret = PQflush(pgsql);
37713731
} else {
37723732
/* Wait to finish sending buffer */
37733733
while ((ret = PQflush(pgsql))) {
@@ -3801,9 +3761,6 @@ PHP_FUNCTION(pg_send_prepare)
38013761
char *query, *stmtname;
38023762
size_t stmtname_len, query_len;
38033763
PGconn *pgsql;
3804-
#ifdef LIBPQ_HAS_PIPELINING
3805-
bool is_pipeline_mode;
3806-
#endif
38073764
int is_non_blocking;
38083765
int ret;
38093766

@@ -3815,26 +3772,17 @@ PHP_FUNCTION(pg_send_prepare)
38153772
CHECK_PGSQL_LINK(link);
38163773
pgsql = link->conn;
38173774

3818-
#ifdef LIBPQ_HAS_PIPELINING
3819-
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
3820-
if (is_pipeline_mode) {
3821-
is_non_blocking = 1;
3822-
} else {
3823-
#endif
3824-
is_non_blocking = PQisnonblocking(pgsql);
3775+
is_non_blocking = PQisnonblocking(pgsql);
38253776

3826-
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3827-
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3828-
RETURN_FALSE;
3829-
}
3777+
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3778+
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3779+
RETURN_FALSE;
3780+
}
38303781

3831-
if (_php_pgsql_link_has_results(pgsql)) {
3832-
php_error_docref(NULL, E_NOTICE,
3833-
"There are results on this connection. Call pg_get_result() until it returns FALSE");
3834-
}
3835-
#ifdef LIBPQ_HAS_PIPELINING
3782+
if (_php_pgsql_link_has_results(pgsql)) {
3783+
php_error_docref(NULL, E_NOTICE,
3784+
"There are results on this connection. Call pg_get_result() until it returns FALSE");
38363785
}
3837-
#endif
38383786

38393787
if (!PQsendPrepare(pgsql, stmtname, query, 0, NULL)) {
38403788
if (is_non_blocking) {
@@ -3850,15 +3798,7 @@ PHP_FUNCTION(pg_send_prepare)
38503798
}
38513799

38523800
if (is_non_blocking) {
3853-
#ifdef LIBPQ_HAS_PIPELINING
3854-
if (is_pipeline_mode) {
3855-
ret = 0;
3856-
} else {
3857-
#endif
3858-
ret = PQflush(pgsql);
3859-
#ifdef LIBPQ_HAS_PIPELINING
3860-
}
3861-
#endif
3801+
ret = PQflush(pgsql);
38623802
} else {
38633803
/* Wait to finish sending buffer */
38643804
while ((ret = PQflush(pgsql))) {
@@ -3894,9 +3834,6 @@ PHP_FUNCTION(pg_send_execute)
38943834
char *stmtname;
38953835
size_t stmtname_len;
38963836
PGconn *pgsql;
3897-
#ifdef LIBPQ_HAS_PIPELINING
3898-
bool is_pipeline_mode;
3899-
#endif
39003837
int is_non_blocking;
39013838
int ret;
39023839

@@ -3908,26 +3845,17 @@ PHP_FUNCTION(pg_send_execute)
39083845
CHECK_PGSQL_LINK(link);
39093846
pgsql = link->conn;
39103847

3911-
#ifdef LIBPQ_HAS_PIPELINING
3912-
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
3913-
if (is_pipeline_mode) {
3914-
is_non_blocking = 1;
3915-
} else {
3916-
#endif
3917-
is_non_blocking = PQisnonblocking(pgsql);
3848+
is_non_blocking = PQisnonblocking(pgsql);
39183849

3919-
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3920-
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3921-
RETURN_FALSE;
3922-
}
3850+
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3851+
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3852+
RETURN_FALSE;
3853+
}
39233854

3924-
if (_php_pgsql_link_has_results(pgsql)) {
3925-
php_error_docref(NULL, E_NOTICE,
3926-
"There are results on this connection. Call pg_get_result() until it returns FALSE");
3927-
}
3928-
#ifdef LIBPQ_HAS_PIPELINING
3855+
if (_php_pgsql_link_has_results(pgsql)) {
3856+
php_error_docref(NULL, E_NOTICE,
3857+
"There are results on this connection. Call pg_get_result() until it returns FALSE");
39293858
}
3930-
#endif
39313859

39323860
num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr));
39333861
if (num_params > 0) {
@@ -3968,15 +3896,7 @@ PHP_FUNCTION(pg_send_execute)
39683896
}
39693897

39703898
if (is_non_blocking) {
3971-
#ifdef LIBPQ_HAS_PIPELINING
3972-
if (is_pipeline_mode) {
3973-
ret = 0;
3974-
} else {
3975-
#endif
3976-
ret = PQflush(pgsql);
3977-
#ifdef LIBPQ_HAS_PIPELINING
3978-
}
3979-
#endif
3899+
ret = PQflush(pgsql);
39803900
} else {
39813901
/* Wait to finish sending buffer */
39823902
while ((ret = PQflush(pgsql))) {
@@ -5958,85 +5878,4 @@ PHP_FUNCTION(pg_select)
59585878
}
59595879
/* }}} */
59605880

5961-
#ifdef LIBPQ_HAS_PIPELINING
5962-
PHP_FUNCTION(pg_enter_pipeline_mode)
5963-
{
5964-
zval *pgsql_link;
5965-
pgsql_link_handle *pgsql_handle;
5966-
5967-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
5968-
RETURN_THROWS();
5969-
}
5970-
5971-
pgsql_handle = Z_PGSQL_LINK_P(pgsql_link);
5972-
CHECK_PGSQL_LINK(pgsql_handle);
5973-
5974-
PQsetnonblocking(pgsql_handle->conn, 1);
5975-
5976-
RETURN_BOOL(PQenterPipelineMode(pgsql_handle->conn));
5977-
}
5978-
5979-
PHP_FUNCTION(pg_exit_pipeline_mode)
5980-
{
5981-
zval *pgsql_link;
5982-
pgsql_link_handle *pgsql_handle;
5983-
5984-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
5985-
RETURN_THROWS();
5986-
}
5987-
5988-
pgsql_handle = Z_PGSQL_LINK_P(pgsql_link);
5989-
CHECK_PGSQL_LINK(pgsql_handle);
5990-
5991-
PQsetnonblocking(pgsql_handle->conn, 0);
5992-
5993-
RETURN_BOOL(PQexitPipelineMode(pgsql_handle->conn));
5994-
}
5995-
5996-
PHP_FUNCTION(pg_send_flush_request)
5997-
{
5998-
zval *pgsql_link;
5999-
pgsql_link_handle *pgsql_handle;
6000-
6001-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
6002-
RETURN_THROWS();
6003-
}
6004-
6005-
pgsql_handle = Z_PGSQL_LINK_P(pgsql_link);
6006-
CHECK_PGSQL_LINK(pgsql_handle);
6007-
6008-
RETURN_BOOL(PQsendFlushRequest(pgsql_handle->conn));
6009-
}
6010-
6011-
PHP_FUNCTION(pg_pipeline_sync)
6012-
{
6013-
zval *pgsql_link;
6014-
pgsql_link_handle *pgsql_handle;
6015-
6016-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
6017-
RETURN_THROWS();
6018-
}
6019-
6020-
pgsql_handle = Z_PGSQL_LINK_P(pgsql_link);
6021-
CHECK_PGSQL_LINK(pgsql_handle);
6022-
6023-
RETURN_BOOL(PQpipelineSync(pgsql_handle->conn));
6024-
}
6025-
6026-
PHP_FUNCTION(pg_pipeline_status)
6027-
{
6028-
zval *pgsql_link;
6029-
pgsql_link_handle *pgsql_handle;
6030-
6031-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
6032-
RETURN_THROWS();
6033-
}
6034-
6035-
pgsql_handle = Z_PGSQL_LINK_P(pgsql_link);
6036-
CHECK_PGSQL_LINK(pgsql_handle);
6037-
6038-
RETURN_LONG(PQpipelineStatus(pgsql_handle->conn));
6039-
}
6040-
#endif
6041-
60425881
#endif

0 commit comments

Comments
 (0)