Skip to content

Commit 107ed64

Browse files
committed
Merge branch 'PHP-8.3'
2 parents 594839b + 1e66e6a commit 107ed64

File tree

4 files changed

+37
-425
lines changed

4 files changed

+37
-425
lines changed

ext/pgsql/pgsql.c

Lines changed: 36 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -3593,9 +3593,6 @@ PHP_FUNCTION(pg_send_query)
35933593
char *query;
35943594
size_t len;
35953595
PGconn *pgsql;
3596-
#ifdef LIBPQ_HAS_PIPELINING
3597-
bool is_pipeline_mode;
3598-
#endif
35993596
int is_non_blocking;
36003597
int ret;
36013598

@@ -3607,40 +3604,23 @@ PHP_FUNCTION(pg_send_query)
36073604
CHECK_PGSQL_LINK(link);
36083605
pgsql = link->conn;
36093606

3610-
#ifdef LIBPQ_HAS_PIPELINING
3611-
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
3612-
if (is_pipeline_mode) {
3613-
is_non_blocking = 1;
3614-
} else {
3615-
#endif
3616-
is_non_blocking = PQisnonblocking(pgsql);
3607+
is_non_blocking = PQisnonblocking(pgsql);
36173608

3618-
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3619-
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3620-
RETURN_FALSE;
3621-
}
3609+
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3610+
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3611+
RETURN_FALSE;
3612+
}
36223613

3623-
if (_php_pgsql_link_has_results(pgsql)) {
3624-
php_error_docref(NULL, E_NOTICE,
3625-
"There are results on this connection. Call pg_get_result() until it returns FALSE");
3626-
}
3627-
#ifdef LIBPQ_HAS_PIPELINING
3614+
if (_php_pgsql_link_has_results(pgsql)) {
3615+
php_error_docref(NULL, E_NOTICE,
3616+
"There are results on this connection. Call pg_get_result() until it returns FALSE");
36283617
}
3629-
#endif
36303618

36313619
if (is_non_blocking) {
36323620
if (!PQsendQuery(pgsql, query)) {
36333621
RETURN_FALSE;
36343622
}
3635-
#ifdef LIBPQ_HAS_PIPELINING
3636-
if (is_pipeline_mode) {
3637-
ret = 0;
3638-
} else {
3639-
#endif
3640-
ret = PQflush(pgsql);
3641-
#ifdef LIBPQ_HAS_PIPELINING
3642-
}
3643-
#endif
3623+
ret = PQflush(pgsql);
36443624
} else {
36453625
if (!PQsendQuery(pgsql, query)) {
36463626
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
@@ -3685,9 +3665,6 @@ PHP_FUNCTION(pg_send_query_params)
36853665
char *query;
36863666
size_t query_len;
36873667
PGconn *pgsql;
3688-
#ifdef LIBPQ_HAS_PIPELINING
3689-
bool is_pipeline_mode;
3690-
#endif
36913668
int is_non_blocking;
36923669
int ret;
36933670

@@ -3699,26 +3676,17 @@ PHP_FUNCTION(pg_send_query_params)
36993676
CHECK_PGSQL_LINK(link);
37003677
pgsql = link->conn;
37013678

3702-
#ifdef LIBPQ_HAS_PIPELINING
3703-
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
3704-
if (is_pipeline_mode) {
3705-
is_non_blocking = 1;
3706-
} else {
3707-
#endif
3708-
is_non_blocking = PQisnonblocking(pgsql);
3679+
is_non_blocking = PQisnonblocking(pgsql);
37093680

3710-
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3711-
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3712-
RETURN_FALSE;
3713-
}
3681+
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3682+
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3683+
RETURN_FALSE;
3684+
}
37143685

3715-
if (_php_pgsql_link_has_results(pgsql)) {
3716-
php_error_docref(NULL, E_NOTICE,
3717-
"There are results on this connection. Call pg_get_result() until it returns FALSE");
3718-
}
3719-
#ifdef LIBPQ_HAS_PIPELINING
3686+
if (_php_pgsql_link_has_results(pgsql)) {
3687+
php_error_docref(NULL, E_NOTICE,
3688+
"There are results on this connection. Call pg_get_result() until it returns FALSE");
37203689
}
3721-
#endif
37223690

37233691
num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr));
37243692
if (num_params > 0) {
@@ -3757,15 +3725,7 @@ PHP_FUNCTION(pg_send_query_params)
37573725
}
37583726

37593727
if (is_non_blocking) {
3760-
#ifdef LIBPQ_HAS_PIPELINING
3761-
if (is_pipeline_mode) {
3762-
ret = 0;
3763-
} else {
3764-
#endif
3765-
ret = PQflush(pgsql);
3766-
#ifdef LIBPQ_HAS_PIPELINING
3767-
}
3768-
#endif
3728+
ret = PQflush(pgsql);
37693729
} else {
37703730
/* Wait to finish sending buffer */
37713731
while ((ret = PQflush(pgsql))) {
@@ -3799,9 +3759,6 @@ PHP_FUNCTION(pg_send_prepare)
37993759
char *query, *stmtname;
38003760
size_t stmtname_len, query_len;
38013761
PGconn *pgsql;
3802-
#ifdef LIBPQ_HAS_PIPELINING
3803-
bool is_pipeline_mode;
3804-
#endif
38053762
int is_non_blocking;
38063763
int ret;
38073764

@@ -3813,26 +3770,17 @@ PHP_FUNCTION(pg_send_prepare)
38133770
CHECK_PGSQL_LINK(link);
38143771
pgsql = link->conn;
38153772

3816-
#ifdef LIBPQ_HAS_PIPELINING
3817-
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
3818-
if (is_pipeline_mode) {
3819-
is_non_blocking = 1;
3820-
} else {
3821-
#endif
3822-
is_non_blocking = PQisnonblocking(pgsql);
3773+
is_non_blocking = PQisnonblocking(pgsql);
38233774

3824-
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3825-
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3826-
RETURN_FALSE;
3827-
}
3775+
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3776+
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3777+
RETURN_FALSE;
3778+
}
38283779

3829-
if (_php_pgsql_link_has_results(pgsql)) {
3830-
php_error_docref(NULL, E_NOTICE,
3831-
"There are results on this connection. Call pg_get_result() until it returns FALSE");
3832-
}
3833-
#ifdef LIBPQ_HAS_PIPELINING
3780+
if (_php_pgsql_link_has_results(pgsql)) {
3781+
php_error_docref(NULL, E_NOTICE,
3782+
"There are results on this connection. Call pg_get_result() until it returns FALSE");
38343783
}
3835-
#endif
38363784

38373785
if (!PQsendPrepare(pgsql, stmtname, query, 0, NULL)) {
38383786
if (is_non_blocking) {
@@ -3848,15 +3796,7 @@ PHP_FUNCTION(pg_send_prepare)
38483796
}
38493797

38503798
if (is_non_blocking) {
3851-
#ifdef LIBPQ_HAS_PIPELINING
3852-
if (is_pipeline_mode) {
3853-
ret = 0;
3854-
} else {
3855-
#endif
3856-
ret = PQflush(pgsql);
3857-
#ifdef LIBPQ_HAS_PIPELINING
3858-
}
3859-
#endif
3799+
ret = PQflush(pgsql);
38603800
} else {
38613801
/* Wait to finish sending buffer */
38623802
while ((ret = PQflush(pgsql))) {
@@ -3892,9 +3832,6 @@ PHP_FUNCTION(pg_send_execute)
38923832
char *stmtname;
38933833
size_t stmtname_len;
38943834
PGconn *pgsql;
3895-
#ifdef LIBPQ_HAS_PIPELINING
3896-
bool is_pipeline_mode;
3897-
#endif
38983835
int is_non_blocking;
38993836
int ret;
39003837

@@ -3906,26 +3843,17 @@ PHP_FUNCTION(pg_send_execute)
39063843
CHECK_PGSQL_LINK(link);
39073844
pgsql = link->conn;
39083845

3909-
#ifdef LIBPQ_HAS_PIPELINING
3910-
is_pipeline_mode = (PQpipelineStatus(pgsql) == PQ_PIPELINE_ON);
3911-
if (is_pipeline_mode) {
3912-
is_non_blocking = 1;
3913-
} else {
3914-
#endif
3915-
is_non_blocking = PQisnonblocking(pgsql);
3846+
is_non_blocking = PQisnonblocking(pgsql);
39163847

3917-
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3918-
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3919-
RETURN_FALSE;
3920-
}
3848+
if (is_non_blocking == 0 && PQsetnonblocking(pgsql, 1) == -1) {
3849+
php_error_docref(NULL, E_NOTICE, "Cannot set connection to nonblocking mode");
3850+
RETURN_FALSE;
3851+
}
39213852

3922-
if (_php_pgsql_link_has_results(pgsql)) {
3923-
php_error_docref(NULL, E_NOTICE,
3924-
"There are results on this connection. Call pg_get_result() until it returns FALSE");
3925-
}
3926-
#ifdef LIBPQ_HAS_PIPELINING
3853+
if (_php_pgsql_link_has_results(pgsql)) {
3854+
php_error_docref(NULL, E_NOTICE,
3855+
"There are results on this connection. Call pg_get_result() until it returns FALSE");
39273856
}
3928-
#endif
39293857

39303858
num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr));
39313859
if (num_params > 0) {
@@ -3966,15 +3894,7 @@ PHP_FUNCTION(pg_send_execute)
39663894
}
39673895

39683896
if (is_non_blocking) {
3969-
#ifdef LIBPQ_HAS_PIPELINING
3970-
if (is_pipeline_mode) {
3971-
ret = 0;
3972-
} else {
3973-
#endif
3974-
ret = PQflush(pgsql);
3975-
#ifdef LIBPQ_HAS_PIPELINING
3976-
}
3977-
#endif
3897+
ret = PQflush(pgsql);
39783898
} else {
39793899
/* Wait to finish sending buffer */
39803900
while ((ret = PQflush(pgsql))) {
@@ -5964,85 +5884,4 @@ PHP_FUNCTION(pg_select)
59645884
}
59655885
/* }}} */
59665886

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

ext/pgsql/pgsql.stub.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -440,29 +440,6 @@
440440
const PGSQL_TRACE_REGRESS_MODE = UNKNOWN;
441441
#endif
442442

443-
#ifdef LIBPQ_HAS_PIPELINING
444-
/**
445-
* @var int
446-
* @cvalue PGRES_PIPELINE_SYNC
447-
*/
448-
const PGSQL_PIPELINE_SYNC = UNKNOWN;
449-
/**
450-
* @var int
451-
* @cvalue PQ_PIPELINE_ON
452-
*/
453-
const PGSQL_PIPELINE_ON = UNKNOWN;
454-
/**
455-
* @var int
456-
* @cvalue PQ_PIPELINE_OFF
457-
*/
458-
const PGSQL_PIPELINE_OFF = UNKNOWN;
459-
/**
460-
* @var int
461-
* @cvalue PQ_PIPELINE_ABORTED
462-
*/
463-
const PGSQL_PIPELINE_ABORTED = UNKNOWN;
464-
#endif
465-
466443
#ifdef HAVE_PG_CONTEXT_VISIBILITY
467444
/* For pg_set_error_context_visibility() */
468445

@@ -963,14 +940,6 @@ function pg_delete(PgSql\Connection $connection, string $table_name, array $cond
963940
*/
964941
function pg_select(PgSql\Connection $connection, string $table_name, array $conditions = [], int $flags = PGSQL_DML_EXEC, int $mode = PGSQL_ASSOC): array|string|false {}
965942

966-
#ifdef LIBPQ_HAS_PIPELINING
967-
function pg_enter_pipeline_mode(PgSql\Connection $connection): bool {}
968-
function pg_exit_pipeline_mode(PgSql\Connection $connection): bool {}
969-
function pg_send_flush_request(PgSql\Connection $connection): bool {}
970-
function pg_pipeline_sync(PgSql\Connection $connection): bool {}
971-
function pg_pipeline_status(PgSql\Connection $connection): int {}
972-
#endif
973-
974943
#ifdef HAVE_PG_CONTEXT_VISIBILITY
975944
function pg_set_error_context_visibility(PgSql\Connection $connection, int $visibility): int {}
976945
#endif

0 commit comments

Comments
 (0)