cvs: php-src /ext/pdo/tests pdo_017.phpt pdo_test.inc
| From: | Wez Furlong | Date: | Sat, 09 Jul 2005 04:28:47 +0000 |
| Subject: | cvs: php-src /ext/pdo/tests pdo_017.phpt pdo_test.inc | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-32838@lists.php.net to get a copy of this message | ||
wez Sat Jul 9 00:28:47 2005 EDT
Modified files:
/php-src/ext/pdo/tests pdo_017.phpt pdo_test.inc
Log:
for the transactions test case, detect working transactions before attempting to run the tests.
Additional ugliness required because mysql does stupid stuff like this:
mysql> CREATE TABLE foo (id int) TYPE=innodb;
Query OK, 0 rows affected, 2 warnings (0.00 sec)
mysql> SHOW CREATE TABLE foo;
CREATE TABLE
foo (
id int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
In addition, BEGIN, COMMIT and ROLLBACK all succeed, even when no tables
support transactions.
http://cvs.php.net/diff.php/php-src/ext/pdo/tests/pdo_017.phpt?r1=1.5&r2=1.6&ty=u
Index: php-src/ext/pdo/tests/pdo_017.phpt
diff -u php-src/ext/pdo/tests/pdo_017.phpt:1.5 php-src/ext/pdo/tests/pdo_017.phpt:1.6
--- php-src/ext/pdo/tests/pdo_017.phpt:1.5 Thu Jul 7 14:49:58 2005
+++ php-src/ext/pdo/tests/pdo_017.phpt Sat Jul 9 00:28:45 2005
@@ -7,15 +7,19 @@
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 @@
$db = PDOTest::factory();
if ($db->getAttribute(PDO_ATTR_DRIVER_NAME) == 'mysql') {
- $suf = ' Type=InnoDB';
+ $suf = ' Type=' . PDOTest::detect_transactional_mysql_engine($db);
} else {
$suf = '';
}
http://cvs.php.net/diff.php/php-src/ext/pdo/tests/pdo_test.inc?r1=1.7&r2=1.8&ty=u
Index: php-src/ext/pdo/tests/pdo_test.inc
diff -u php-src/ext/pdo/tests/pdo_test.inc:1.7 php-src/ext/pdo/tests/pdo_test.inc:1.8
--- php-src/ext/pdo/tests/pdo_test.inc:1.7 Fri Jul 8 22:53:07 2005
+++ php-src/ext/pdo/tests/pdo_test.inc Sat Jul 9 00:28:45 2005
@@ -43,6 +43,15 @@
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;
+ }
}