Closed RedChops closed 2 years ago
I've been able to temporarily mitigate this issue by using this in my code:
if (($response = $connection->fetchAll($result)) === false) {
if (!(in_array($connection->resultStatus, [0, 1, 2]))) {
throw new Exception($connection->error, $connection->errCode);
}
$response = [];
}
But since Swoole does not package the postgres PQresultStatus enums as constants, I had to look up the numeric values from the postgres source to get an acceptable (but maybe incomplete) list of success integers.
Fix these issues at https://github.com/openswoole/swoole-src/pull/187
Please answer these questions before submitting your issue.
If I run a query which otherwise returns successfully, but does not return rows, fetchAll() will return false. A basic example could be to create a new table, we can define it like:
Then run
$pg->query('SELECT * from test_empty');
I would expect to see an empty array returned, showing that the request was successful but returned an empty set. This command in pgsql returns:
false
is returned, which across the rest of the extension indicates that there was an error with the command, except$pg->error
is null, suggesting that the command was successful. I believe that the conditional mentioned in the title of the ticket is the cause of this, since if that conditional passes (0 rows returned, but otherwise successful), swoole_pgsql_result2array will improperly return FAILURE.php --ri openswoole
)?uname -a
&php -v
&gcc -v
) ?uname: Linux 50d1a3fdb76e 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 GNU/Linux Note: running in a debian-bullseye Docker container
php : PHP 8.1.3 (cli) (built: Mar 11 2022 02:58:22) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.3, Copyright (c) Zend Technologies with Zend OPcache v8.1.3, Copyright (c), by Zend Technologies
gcc is not installed in this container.