Skip to content

Commit 7159b53

Browse files
committed
Boolify do_exec()
1 parent d0ceecc commit 7159b53

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

ext/pgsql/pgsql.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5243,27 +5243,26 @@ PHP_FUNCTION(pg_convert)
52435243
}
52445244
/* }}} */
52455245

5246-
static int do_exec(smart_str *querystr, ExecStatusType expect, PGconn *pg_link, zend_ulong opt) /* {{{ */
5246+
static bool do_exec(smart_str *querystr, ExecStatusType expect, PGconn *pg_link, zend_ulong opt) /* {{{ */
52475247
{
52485248
if (opt & PGSQL_DML_ASYNC) {
52495249
if (PQsendQuery(pg_link, ZSTR_VAL(querystr->s))) {
5250-
return 0;
5250+
return true;
52515251
}
5252-
}
5253-
else {
5252+
} else {
52545253
PGresult *pg_result;
52555254

52565255
pg_result = PQexec(pg_link, ZSTR_VAL(querystr->s));
52575256
if (PQresultStatus(pg_result) == expect) {
52585257
PQclear(pg_result);
5259-
return 0;
5258+
return true;
52605259
} else {
52615260
php_error_docref(NULL, E_WARNING, "%s", PQresultErrorMessage(pg_result));
52625261
PQclear(pg_result);
52635262
}
52645263
}
52655264

5266-
return -1;
5265+
return false;
52675266
}
52685267
/* }}} */
52695268

@@ -5392,7 +5391,7 @@ PHP_PGSQL_API zend_result php_pgsql_insert(PGconn *pg_link, const zend_string *t
53925391
smart_str_0(&querystr);
53935392

53945393
if ((opt & (PGSQL_DML_EXEC|PGSQL_DML_ASYNC)) &&
5395-
do_exec(&querystr, PGRES_COMMAND_OK, pg_link, (opt & PGSQL_CONV_OPTS)) == 0) {
5394+
do_exec(&querystr, PGRES_COMMAND_OK, pg_link, (opt & PGSQL_CONV_OPTS))) {
53965395
ret = SUCCESS;
53975396
}
53985397
else if (opt & PGSQL_DML_STRING) {
@@ -5610,7 +5609,7 @@ PHP_PGSQL_API zend_result php_pgsql_update(PGconn *pg_link, const zend_string *t
56105609
smart_str_appendc(&querystr, ';');
56115610
smart_str_0(&querystr);
56125611

5613-
if ((opt & PGSQL_DML_EXEC) && do_exec(&querystr, PGRES_COMMAND_OK, pg_link, opt) == 0) {
5612+
if ((opt & PGSQL_DML_EXEC) && do_exec(&querystr, PGRES_COMMAND_OK, pg_link, opt)) {
56145613
ret = SUCCESS;
56155614
} else if (opt & PGSQL_DML_STRING) {
56165615
ret = SUCCESS;
@@ -5706,7 +5705,7 @@ PHP_PGSQL_API zend_result php_pgsql_delete(PGconn *pg_link, const zend_string *t
57065705
smart_str_appendc(&querystr, ';');
57075706
smart_str_0(&querystr);
57085707

5709-
if ((opt & PGSQL_DML_EXEC) && do_exec(&querystr, PGRES_COMMAND_OK, pg_link, opt) == 0) {
5708+
if ((opt & PGSQL_DML_EXEC) && do_exec(&querystr, PGRES_COMMAND_OK, pg_link, opt)) {
57105709
ret = SUCCESS;
57115710
} else if (opt & PGSQL_DML_STRING) {
57125711
ret = SUCCESS;

0 commit comments

Comments
 (0)