Skip to content

Commit 0ffb4a5

Browse files
committed
Boolify do_exec()
1 parent fabcfd6 commit 0ffb4a5

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
@@ -5250,27 +5250,26 @@ PHP_FUNCTION(pg_convert)
52505250
}
52515251
/* }}} */
52525252

5253-
static int do_exec(smart_str *querystr, ExecStatusType expect, PGconn *pg_link, zend_ulong opt) /* {{{ */
5253+
static bool do_exec(smart_str *querystr, ExecStatusType expect, PGconn *pg_link, zend_ulong opt) /* {{{ */
52545254
{
52555255
if (opt & PGSQL_DML_ASYNC) {
52565256
if (PQsendQuery(pg_link, ZSTR_VAL(querystr->s))) {
5257-
return 0;
5257+
return true;
52585258
}
5259-
}
5260-
else {
5259+
} else {
52615260
PGresult *pg_result;
52625261

52635262
pg_result = PQexec(pg_link, ZSTR_VAL(querystr->s));
52645263
if (PQresultStatus(pg_result) == expect) {
52655264
PQclear(pg_result);
5266-
return 0;
5265+
return true;
52675266
} else {
52685267
php_error_docref(NULL, E_WARNING, "%s", PQresultErrorMessage(pg_result));
52695268
PQclear(pg_result);
52705269
}
52715270
}
52725271

5273-
return -1;
5272+
return false;
52745273
}
52755274
/* }}} */
52765275

@@ -5400,7 +5399,7 @@ PHP_PGSQL_API zend_result php_pgsql_insert(PGconn *pg_link, const char *table, z
54005399
smart_str_0(&querystr);
54015400

54025401
if ((opt & (PGSQL_DML_EXEC|PGSQL_DML_ASYNC)) &&
5403-
do_exec(&querystr, PGRES_COMMAND_OK, pg_link, (opt & PGSQL_CONV_OPTS)) == 0) {
5402+
do_exec(&querystr, PGRES_COMMAND_OK, pg_link, (opt & PGSQL_CONV_OPTS))) {
54045403
ret = SUCCESS;
54055404
}
54065405
else if (opt & PGSQL_DML_STRING) {
@@ -5619,7 +5618,7 @@ PHP_PGSQL_API zend_result php_pgsql_update(PGconn *pg_link, const char *table, z
56195618
smart_str_appendc(&querystr, ';');
56205619
smart_str_0(&querystr);
56215620

5622-
if ((opt & PGSQL_DML_EXEC) && do_exec(&querystr, PGRES_COMMAND_OK, pg_link, opt) == 0) {
5621+
if ((opt & PGSQL_DML_EXEC) && do_exec(&querystr, PGRES_COMMAND_OK, pg_link, opt)) {
56235622
ret = SUCCESS;
56245623
} else if (opt & PGSQL_DML_STRING) {
56255624
ret = SUCCESS;
@@ -5716,7 +5715,7 @@ PHP_PGSQL_API zend_result php_pgsql_delete(PGconn *pg_link, const char *table, z
57165715
smart_str_appendc(&querystr, ';');
57175716
smart_str_0(&querystr);
57185717

5719-
if ((opt & PGSQL_DML_EXEC) && do_exec(&querystr, PGRES_COMMAND_OK, pg_link, opt) == 0) {
5718+
if ((opt & PGSQL_DML_EXEC) && do_exec(&querystr, PGRES_COMMAND_OK, pg_link, opt)) {
57205719
ret = SUCCESS;
57215720
} else if (opt & PGSQL_DML_STRING) {
57225721
ret = SUCCESS;

0 commit comments

Comments
 (0)