[php-src] Issue #9665: Mysqli converts TINYINT to a string after SUM() if the result of SUM is outside TINYINT, even if
MYSQLI_OPT_INT_AND_FLOAT_NATIVE is set to true.

From: Date: Tue, 04 Oct 2022 08:09:47 +0000
Subject: [php-src] Issue #9665: Mysqli converts TINYINT to a string after SUM() if the result of SUM is outside TINYINT, even if
MYSQLI_OPT_INT_AND_FLOAT_NATIVE is set to true.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242517@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9665 Author: IlyaIndigo ### Description The following code: ```sql DROP TABLE IF EXISTS table; CREATE TABLE table ( num TINYINT UNSIGNED NOT NULL PRIMARY KEY ) ENGINE=InnoDB; INSERT INTO table VALUES (250),(251),(252); ``` ```php <?php mysqli_report(MYSQLI_REPORT_ERROR); $my = mysqli_init(); $my->options(MYSQLI_OPT_CONNECT_TIMEOUT, 1); $my->options(MYSQLI_SET_CHARSET_NAME, 'utf8'); $my->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, true); $my->real_connect('localhost', 'test', 'test', 'test'); $num = $my->query('SELECT SUM(num) FROM table')->fetch_column(); echo var_export($num, true),' ',var_export(is_int($num), true),"\n"; exit(0); ``` Resulted in this output: ``` '753' false ``` But I expected this output instead: ``` 753 true ``` CAST(SUM(num) AS UNSIGNED) solves the problem, but the native console mysql-client does not have this problem and I do not understand where it came from. Documented behavior, why sum or product whose result is outside the operated column is converted to a string and not trying to convert to a maximum number, I have not found. ### PHP Version 8.1.11 ### Operating System openSUSE Tumbleweed

« previous php.bugs (#242517) next »