Skip to content

Commit e3ea426

Browse files
committed
ext/pgsql: Stop using useless convert_to_boolean() API
There are better ways of handling this than casting the zval in place
1 parent 2b22ea9 commit e3ea426

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

ext/pgsql/pgsql.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3879,7 +3879,12 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
38793879
switch(entry_type) {
38803880
case PHP_PG_ASYNC_IS_BUSY:
38813881
PQconsumeInput(pgsql);
3882-
RETVAL_LONG(PQisBusy(pgsql));
3882+
/* PQisBusy
3883+
* Returns 1 if a command is busy, that is, PQgetResult would block waiting for input.
3884+
* A 0 return indicates that PQgetResult can be called with assurance of not blocking.
3885+
* https://www.postgresql.org/docs/current/libpq-async.html#LIBPQ-PQISBUSY
3886+
*/
3887+
RETVAL_BOOL(PQisBusy(pgsql));
38833888
break;
38843889
case PHP_PG_ASYNC_REQUEST_CANCEL: {
38853890
PGcancel *c;
@@ -3893,7 +3898,8 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
38933898
* errbuf must be a char array of size errbufsize (the recommended size is 256 bytes).
38943899
* https://www.postgresql.org/docs/current/libpq-cancel.html#LIBPQ-PQCANCEL
38953900
*/
3896-
RETVAL_LONG((rc = PQcancel(c, err, sizeof(err))));
3901+
rc = PQcancel(c, err, sizeof(err));
3902+
RETVAL_BOOL(rc);
38973903
if (rc == 0) {
38983904
zend_error(E_WARNING, "cannot cancel the query: %s", err);
38993905
}
@@ -3908,7 +3914,6 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
39083914
if (PQsetnonblocking(pgsql, 0)) {
39093915
php_error_docref(NULL, E_NOTICE, "Cannot set connection to blocking mode");
39103916
}
3911-
convert_to_boolean(return_value);
39123917
}
39133918
/* }}} */
39143919

@@ -4929,8 +4934,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
49294934
break; /* break out for() */
49304935
}
49314936

4932-
convert_to_boolean(is_enum);
4933-
if (Z_TYPE_P(is_enum) == IS_TRUE) {
4937+
if (zval_is_true(is_enum)) {
49344938
/* enums need to be treated like strings */
49354939
data_type = PG_TEXT;
49364940
} else {

0 commit comments

Comments
 (0)