bug66528.phpt 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Bug #66528: No PDOException or errorCode if database becomes unavailable before PDO::commit
  3. --EXTENSIONS--
  4. pdo
  5. pdo_mysql
  6. --SKIPIF--
  7. <?php
  8. require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
  9. MySQLPDOTest::skip();
  10. ?>
  11. --FILE--
  12. <?php
  13. require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
  14. $dbh = MySQLPDOTest::factory();
  15. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  16. $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
  17. $dbh->exec('DROP TABLE IF EXISTS test');
  18. $dbh->exec('CREATE TABLE test (a int) engine=innodb');
  19. $dbh->beginTransaction();
  20. $dbh->exec('INSERT INTO test (a) VALUES (1), (2)');
  21. $stmt = $dbh->query('SELECT * FROM test');
  22. try {
  23. $dbh->commit();
  24. } catch (PDOException $e) {
  25. echo $e->getMessage(), "\n";
  26. }
  27. try {
  28. $dbh->rollBack();
  29. } catch (PDOException $e) {
  30. echo $e->getMessage(), "\n";
  31. }
  32. try {
  33. $dbh->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
  34. } catch (PDOException $e) {
  35. echo $e->getMessage(), "\n";
  36. }
  37. ?>
  38. --CLEAN--
  39. <?php
  40. require __DIR__ . '/mysql_pdo_test.inc';
  41. MySQLPDOTest::dropTestTable();
  42. ?>
  43. --EXPECT--
  44. SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.
  45. SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.
  46. SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.