bug_pecl_7976.phpt 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --TEST--
  2. PECL Bug #7976 (Calling stored procedure several times)
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
  6. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
  7. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
  8. MySQLPDOTest::skip();
  9. $db = MySQLPDOTest::factory();
  10. $row = $db->query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC);
  11. $matches = array();
  12. if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches))
  13. die(sprintf("skip Cannot determine MySQL Server version\n"));
  14. $version = $matches[0] * 10000 + $matches[1] * 100 + $matches[2];
  15. if ($version < 50000)
  16. die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n",
  17. $matches[0], $matches[1], $matches[2], $version));
  18. ?>
  19. --FILE--
  20. <?php
  21. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
  22. $db = MySQLPDOTest::factory();
  23. function bug_pecl_7976($db) {
  24. $db->exec('DROP PROCEDURE IF EXISTS p');
  25. $db->exec('CREATE PROCEDURE p() BEGIN SELECT "1" AS _one; END;');
  26. $stmt = $db->query('CALL p()');
  27. var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
  28. $stmt->closeCursor();
  29. $stmt = $db->query('CALL p()');
  30. var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
  31. $stmt->closeCursor();
  32. }
  33. printf("Emulated...\n");
  34. $db = MySQLPDOTest::factory();
  35. $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
  36. bug_pecl_7976($db);
  37. printf("Native...\n");
  38. $db = MySQLPDOTest::factory();
  39. $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
  40. bug_pecl_7976($db);
  41. print "done!";
  42. ?>
  43. --CLEAN--
  44. <?php
  45. require dirname(__FILE__) . '/mysql_pdo_test.inc';
  46. $db = MySQLPDOTest::factory();
  47. $db->exec('DROP PROCEDURE IF EXISTS p');
  48. ?>
  49. --XFAIL--
  50. Works with mysqlnd. It is not supported by libmysql. For libmysql is good enough to see no crash.
  51. --EXPECTF--
  52. Emulated...
  53. array(1) {
  54. [0]=>
  55. array(1) {
  56. [%u|b%"_one"]=>
  57. %unicode|string%(1) "1"
  58. }
  59. }
  60. array(1) {
  61. [0]=>
  62. array(1) {
  63. [%u|b%"_one"]=>
  64. %unicode|string%(1) "1"
  65. }
  66. }
  67. Native...
  68. array(1) {
  69. [0]=>
  70. array(1) {
  71. [%u|b%"_one"]=>
  72. %unicode|string%(1) "1"
  73. }
  74. }
  75. array(1) {
  76. [0]=>
  77. array(1) {
  78. [%u|b%"_one"]=>
  79. %unicode|string%(1) "1"
  80. }
  81. }
  82. done!