summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/pdo/tests/pdo_017.phpt14
-rw-r--r--ext/pdo/tests/pdo_test.inc9
2 files changed, 18 insertions, 5 deletions
diff --git a/ext/pdo/tests/pdo_017.phpt b/ext/pdo/tests/pdo_017.phpt
index 36bdb029c8..def132e569 100644
--- a/ext/pdo/tests/pdo_017.phpt
+++ b/ext/pdo/tests/pdo_017.phpt
@@ -7,15 +7,19 @@ $dir = getenv('REDIR_TEST_DIR');
if (false == $dir) die('skip no driver');
require_once $dir . 'pdo_test.inc';
PDOTest::skip();
-/* TODO:
+
$db = PDOTest::factory();
try {
$db->beginTransaction();
} catch (PDOException $e) {
- # check sqlstate to see if transactions
- # are not implemented; if so, skip
+ die('skip no working transactions: ' . $e->getMessage());
+}
+
+if ($db->getAttribute(PDO_ATTR_DRIVER_NAME) == 'mysql') {
+ if (false === PDOTest::detect_transactional_mysql_engine($db)) {
+ die('skip your mysql configuration does not support working transactions');
+ }
}
-*/
?>
--FILE--
<?php
@@ -23,7 +27,7 @@ require getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory();
if ($db->getAttribute(PDO_ATTR_DRIVER_NAME) == 'mysql') {
- $suf = ' Type=InnoDB';
+ $suf = ' Type=' . PDOTest::detect_transactional_mysql_engine($db);
} else {
$suf = '';
}
diff --git a/ext/pdo/tests/pdo_test.inc b/ext/pdo/tests/pdo_test.inc
index 13ab1c1d5f..79b2a9d168 100644
--- a/ext/pdo/tests/pdo_test.inc
+++ b/ext/pdo/tests/pdo_test.inc
@@ -43,6 +43,15 @@ class PDOTest {
die("skip " . $e->getMessage());
}
}
+
+ static function detect_transactional_mysql_engine($db) {
+ foreach ($db->query('show engines') as $row) {
+ if ($row[1] == 'YES' && ($row[0] == 'INNOBASE' || $row[0] == 'BDB')) {
+ return $row[0];
+ }
+ }
+ return false;
+ }
}