summaryrefslogtreecommitdiff
path: root/ext/pdo_oci
diff options
context:
space:
mode:
authorMatteo Beccati <mbeccati@php.net>2009-04-23 13:26:10 (GMT)
committerMatteo Beccati <mbeccati@php.net>2009-04-23 13:26:10 (GMT)
commit0b576f6f1135479bbc466dbb29da5a352d853161 (patch)
treeb0288acc381f5ed85d9848df4a3656e39ba7f6c1 /ext/pdo_oci
parentb7747cf30c7d79ba20030d4dc9b8d897c9d1400c (diff)
downloadphp-0b576f6f1135479bbc466dbb29da5a352d853161.tar.gz
MFH:
- 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')
-rw-r--r--ext/pdo_oci/tests/bug46274.phpt71
-rw-r--r--ext/pdo_oci/tests/bug46274_2.phpt77
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 0000000..23ee8ee
--- /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 0000000..cbadcef
--- /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) ""