]> granicus.if.org Git - php/commitdiff
Fix intermittent failures in mysqli_stmt_bind_result_format.phpt
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 19 Sep 2018 09:31:42 +0000 (11:31 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 19 Sep 2018 10:27:31 +0000 (12:27 +0200)
There were two distinct issues here:
 * $trend was compared against 'NULL' using !=, which does not work
   as intended in the case where $trend==0.0.
 * current_targets was declared as double(17,0), which means that
   the fractional part was rounded, so that the same comparison in
   SQL (rounded) and in PHP (not rounded) did not necessarily
   match.

Please don't write mt_rand based tests, it takes ages to debug this
crap...

ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt

index dee5a7e0f0fa6cca514c1cf8f2ad3ecaa5a28ab0..8a1e9b16c04ca9673f05e8f1545bcde59d5aba37 100644 (file)
@@ -208,11 +208,11 @@ memory_limit=83886080
        if (mysqli_query($link, "CREATE TABLE `test` (
   `targetport` int(11) NOT NULL default '0',
   `sources` double(17,4) default NULL,
-  `current_sources` double(17,0) default NULL,
+  `current_sources` double(17,4) default NULL,
   `reports` double(17,4) default NULL,
-  `current_reports` double(17,0) default NULL,
+  `current_reports` double(17,4) default NULL,
   `targets` double(17,4) default NULL,
-  `current_targets` double(17,0) default NULL,
+  `current_targets` double(17,4) default NULL,
   `maxsources` int(11) default NULL,
   `maxtargets` int(11) default NULL,
   `maxreports` int(11) default NULL,
@@ -237,7 +237,7 @@ memory_limit=83886080
                                        printf("[301] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
                                        break 2;
                                }
-                               if ($current_targets > 0 && $trend != 'NULL')
+                               if ($current_targets > 0 && $trend !== 'NULL')
                                        $values[$trend] = $i;
                        }
                        krsort($values);