diff options
author | Matteo Beccati <mbeccati@php.net> | 2009-04-23 13:22:12 +0000 |
---|---|---|
committer | Matteo Beccati <mbeccati@php.net> | 2009-04-23 13:22:12 +0000 |
commit | 7db1207d477547bfb5cf71b6c0b17334e5e0893c (patch) | |
tree | 1df56ac7d20f1b676cf256bed036b1ce41ab2845 /ext/pdo_oci/tests | |
parent | 763248af6865bfaddccf68f2a7393a1ff201cfd2 (diff) | |
download | php-git-7db1207d477547bfb5cf71b6c0b17334e5e0893c.tar.gz |
- Reverted previous fix for bug #46274 and properly fixed it
- Fixed bug #48060
# Also added tests for pdo_oci as it's the only other driver currently
# using streams: no regression found
Diffstat (limited to 'ext/pdo_oci/tests')
-rw-r--r-- | ext/pdo_oci/tests/bug46274.phpt | 71 | ||||
-rw-r--r-- | ext/pdo_oci/tests/bug46274_2.phpt | 77 |
2 files changed, 148 insertions, 0 deletions
diff --git a/ext/pdo_oci/tests/bug46274.phpt b/ext/pdo_oci/tests/bug46274.phpt new file mode 100644 index 0000000000..23ee8ee20f --- /dev/null +++ b/ext/pdo_oci/tests/bug46274.phpt @@ -0,0 +1,71 @@ +--TEST-- +Bug #46274 (pdo_pgsql - Segfault when using PDO::ATTR_STRINGIFY_FETCHES and blob) +--SKIPIF-- +<?php +if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) +die('skip not loaded'); +require dirname(__FILE__).'/../../pdo/tests/pdo_test.inc'; +PDOTest::skip(); +?> +--FILE-- +<?php +require 'ext/pdo/tests/pdo_test.inc'; +$db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt'); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + +try { + $db->exec("DROP TABLE test_one_blob"); +} catch (Exception $e) { +} + +$db->beginTransaction(); + +$db->query('CREATE TABLE test_one_blob (id INT NOT NULL, blob1 BLOB)'); + +$stmt = $db->prepare("INSERT INTO test_one_blob (id, blob1) VALUES (:id, EMPTY_BLOB()) RETURNING blob1 INTO :foo"); + +$data = 'foo'; +$blob = fopen('php://memory', 'a'); +fwrite($blob, $data); +rewind($blob); + +$id = 1; +$stmt->bindparam(':id', $id); +$stmt->bindparam(':foo', $blob, PDO::PARAM_LOB); +$stmt->execute(); + +$data = ''; +$blob = fopen('php://memory', 'a'); +fwrite($blob, $data); +rewind($blob); + +$id = 1; +$stmt->bindparam(':id', $id); +$stmt->bindparam(':foo', $blob, PDO::PARAM_LOB); +$stmt->execute(); + +$res = $db->query("SELECT blob1 from test_one_blob"); +// Resource +var_dump($res->fetch()); + +// Empty string +var_dump($res->fetch()); + +$db->exec("DROP TABLE test_one_blob"); + +?> +--EXPECTF-- +array(2) { + ["blob1"]=> + string(3) "foo" + [0]=> + string(3) "foo" +} +array(2) { + ["blob1"]=> + string(0) "" + [0]=> + string(0) "" +} diff --git a/ext/pdo_oci/tests/bug46274_2.phpt b/ext/pdo_oci/tests/bug46274_2.phpt new file mode 100644 index 0000000000..cbadcef4f8 --- /dev/null +++ b/ext/pdo_oci/tests/bug46274_2.phpt @@ -0,0 +1,77 @@ +--TEST-- +Bug #46274 (pdo_pgsql - Segfault when using PDO::ATTR_STRINGIFY_FETCHES and blob) +--SKIPIF-- +<?php +if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) +die('skip not loaded'); +require dirname(__FILE__).'/../../pdo/tests/pdo_test.inc'; +PDOTest::skip(); +?> +--FILE-- +<?php +require 'ext/pdo/tests/pdo_test.inc'; +$db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt'); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + +try { + $db->exec("DROP TABLE test_one_blob"); +} catch (Exception $e) { +} + +$db->beginTransaction(); + +$db->query('CREATE TABLE test_one_blob (id INT NOT NULL, blob1 BLOB)'); + +$stmt = $db->prepare("INSERT INTO test_one_blob (id, blob1) VALUES (:id, EMPTY_BLOB()) RETURNING blob1 INTO :foo"); + +$data = 'foo'; +$blob = fopen('php://memory', 'a'); +fwrite($blob, $data); +rewind($blob); + +$id = 1; +$stmt->bindparam(':id', $id); +$stmt->bindparam(':foo', $blob, PDO::PARAM_LOB); +$stmt->execute(); + +$data = ''; +$blob = fopen('php://memory', 'a'); +fwrite($blob, $data); +rewind($blob); + +$id = 1; +$stmt->bindparam(':id', $id); +$stmt->bindparam(':foo', $blob, PDO::PARAM_LOB); +$stmt->execute(); + +$res = $db->query("SELECT blob1 from test_one_blob"); +// Resource +var_dump($row = $res->fetch()); +var_dump(fread($row[0], 1024)); +fclose($row[0]); + +// Empty string +var_dump($row = $res->fetch()); +var_dump(fread($row[0], 1024)); +fclose($row[0]); + +$db->exec("DROP TABLE test_one_blob"); + +?> +--EXPECTF-- +array(2) { + ["blob1"]=> + resource(%d) of type (stream) + [0]=> + resource(%d) of type (stream) +} +string(3) "foo" +array(2) { + ["blob1"]=> + resource(%d) of type (stream) + [0]=> + resource(%d) of type (stream) +} +string(0) "" |