bug63185.phpt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. --TEST--
  2. Bug #63185: nextRowset() ignores MySQL errors with native prepared statements
  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. $pdo = MySQLPDOTest::factory();
  15. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  16. $pdo->exec('DROP PROCEDURE IF EXISTS test_procedure_error_at_second');
  17. $pdo->exec('CREATE PROCEDURE test_procedure_error_at_second ()
  18. BEGIN
  19. SELECT "x" as foo;
  20. SELECT * FROM no_such_table;
  21. END');
  22. $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
  23. $st = $pdo->query('CALL test_procedure_error_at_second()');
  24. var_dump($st->fetchAll());
  25. try {
  26. var_dump($st->nextRowset());
  27. } catch (PDOException $e) {
  28. echo $e->getMessage(), "\n";
  29. }
  30. unset($st);
  31. $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  32. $st = $pdo->query('CALL test_procedure_error_at_second()');
  33. var_dump($st->fetchAll());
  34. try {
  35. var_dump($st->nextRowset());
  36. } catch (PDOException $e) {
  37. echo $e->getMessage(), "\n";
  38. }
  39. var_dump($st->fetchAll());
  40. ?>
  41. --CLEAN--
  42. <?php
  43. require_once __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
  44. $pdo = MySQLPDOTest::factory();
  45. $pdo->query('DROP PROCEDURE IF EXISTS test_procedure_error_at_second');
  46. ?>
  47. --EXPECTF--
  48. array(1) {
  49. [0]=>
  50. array(2) {
  51. ["foo"]=>
  52. string(1) "x"
  53. [0]=>
  54. string(1) "x"
  55. }
  56. }
  57. SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.no_such_table' doesn't exist
  58. array(1) {
  59. [0]=>
  60. array(2) {
  61. ["foo"]=>
  62. string(1) "x"
  63. [0]=>
  64. string(1) "x"
  65. }
  66. }
  67. SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.no_such_table' doesn't exist
  68. array(0) {
  69. }