]> granicus.if.org Git - php/commitdiff
Hopefully, this is an even better way to check for InnoDB support as of MySQL 5.6.1
authorUlf Wendel <uw@php.net>
Fri, 2 Sep 2011 11:06:51 +0000 (11:06 +0000)
committerUlf Wendel <uw@php.net>
Fri, 2 Sep 2011 11:06:51 +0000 (11:06 +0000)
ext/mysqli/tests/connect.inc
ext/pdo_mysql/tests/mysql_pdo_test.inc

index ec837d64b3a04f33edcf3792ed34fbb483a2f949..ee1dce4640218b0e5d961001e0444ee153377b94 100644 (file)
                                /* MySQL 5.6.1+ */
                                if ($res = $link->query("SHOW ENGINES")) {
                                        while ($row = $res->fetch_assoc()) {
-                                               if (('InnoDB' == $row['Engine']) && ('YES' == $row['Support'])) {
+                                               if (!isset($row['Engine']) || !isset($row['Support']))
+                                                       return false;
+
+                                               if (('InnoDB' == $row['Engine']) &&
+                                                       (('YES' == $row['Support']) || ('DEFAULT' == $row['Support']))
+                                                       ) {
                                                        return true;
                                                }
                                        }
index 0af2e6df65f0370db25457961e646988f2a6fb09..115aeadc5a658c36783c79a1663771c52772018f 100644 (file)
@@ -141,12 +141,19 @@ class MySQLPDOTest extends PDOTest {
 
        }
 
-       static function detect_transactional_mysql_engine($db) {
+       static function detect_transactional_mysql_engine($db) {                
                foreach ($db->query("show variables like 'have%'") as $row) {
-                       if ($row[1] == 'YES' && ($row[0] == 'have_innodb' || $row[0] == 'have_bdb')) {
+                       if (!empty($row) && $row[1] == 'YES' && ($row[0] == 'have_innodb' || $row[0] == 'have_bdb')) {
                                return str_replace("have_", "", $row[0]);
                        }
                }
+               /* MySQL 5.6.1+ */
+               foreach ($db->query("SHOW ENGINES") as $row) {
+                       if (isset($row['engine']) && isset($row['support'])) {
+                                if ('InnoDB' == $row['engine'] && ('YES' == $row['support'] || 'DEFAULT' == $row['support']))
+                                       return 'innodb';
+                       }
+               }
                return false;
        }