bug46274.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. --TEST--
  2. Bug #46274 (pdo_pgsql - Segfault when using PDO::ATTR_STRINGIFY_FETCHES and blob)
  3. --EXTENSIONS--
  4. pdo
  5. pdo_oci
  6. --SKIPIF--
  7. <?php
  8. require __DIR__.'/../../pdo/tests/pdo_test.inc';
  9. PDOTest::skip();
  10. ?>
  11. --FILE--
  12. <?php
  13. require 'ext/pdo/tests/pdo_test.inc';
  14. $db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt');
  15. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  16. $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
  17. try {
  18. $db->exec("DROP TABLE test_one_blob");
  19. } catch (Exception $e) {
  20. }
  21. $db->beginTransaction();
  22. $db->query('CREATE TABLE test_one_blob (id INT NOT NULL, blob1 BLOB)');
  23. $stmt = $db->prepare("INSERT INTO test_one_blob (id, blob1) VALUES (:id, EMPTY_BLOB()) RETURNING blob1 INTO :foo");
  24. $data = 'foo';
  25. $blob = fopen('php://memory', 'a');
  26. fwrite($blob, $data);
  27. rewind($blob);
  28. $id = 1;
  29. $stmt->bindparam(':id', $id);
  30. $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
  31. $stmt->execute();
  32. $data = '';
  33. $blob = fopen('php://memory', 'a');
  34. fwrite($blob, $data);
  35. rewind($blob);
  36. $id = 1;
  37. $stmt->bindparam(':id', $id);
  38. $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
  39. $stmt->execute();
  40. $res = $db->query("SELECT blob1 from test_one_blob");
  41. // Resource
  42. var_dump($res->fetch());
  43. // Empty string
  44. var_dump($res->fetch());
  45. $db->exec("DROP TABLE test_one_blob");
  46. ?>
  47. --EXPECT--
  48. array(2) {
  49. ["blob1"]=>
  50. string(3) "foo"
  51. [0]=>
  52. string(3) "foo"
  53. }
  54. array(2) {
  55. ["blob1"]=>
  56. string(0) ""
  57. [0]=>
  58. string(0) ""
  59. }