Annotation of embedaddon/php/ext/pdo_oci/tests/bug46274_2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Bug #46274 (pdo_pgsql - Segfault when using PDO::ATTR_STRINGIFY_FETCHES and blob)
3: --SKIPIF--
4: <?php
5: if (!extension_loaded('pdo') || !extension_loaded('pdo_oci'))
6: die('skip not loaded');
7: require dirname(__FILE__).'/../../pdo/tests/pdo_test.inc';
8: PDOTest::skip();
9: ?>
10: --FILE--
11: <?php
12: require 'ext/pdo/tests/pdo_test.inc';
13: $db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt');
14: $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
15:
16: $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
17:
18: try {
19: $db->exec("DROP TABLE test_one_blob");
20: } catch (Exception $e) {
21: }
22:
23: $db->beginTransaction();
24:
25: $db->query('CREATE TABLE test_one_blob (id INT NOT NULL, blob1 BLOB)');
26:
27: $stmt = $db->prepare("INSERT INTO test_one_blob (id, blob1) VALUES (:id, EMPTY_BLOB()) RETURNING blob1 INTO :foo");
28:
29: $data = 'foo';
30: $blob = fopen('php://memory', 'a');
31: fwrite($blob, $data);
32: rewind($blob);
33:
34: $id = 1;
35: $stmt->bindparam(':id', $id);
36: $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
37: $stmt->execute();
38:
39: $data = '';
40: $blob = fopen('php://memory', 'a');
41: fwrite($blob, $data);
42: rewind($blob);
43:
44: $id = 1;
45: $stmt->bindparam(':id', $id);
46: $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
47: $stmt->execute();
48:
49: $res = $db->query("SELECT blob1 from test_one_blob");
50: // Resource
51: var_dump($row = $res->fetch());
52: var_dump(fread($row[0], 1024));
53: fclose($row[0]);
54:
55: // Empty string
56: var_dump($row = $res->fetch());
57: var_dump(fread($row[0], 1024));
58: fclose($row[0]);
59:
60: $db->exec("DROP TABLE test_one_blob");
61:
62: ?>
63: --XFAIL--
64: Corrupts memory
65: --EXPECTF--
66: array(2) {
67: ["blob1"]=>
68: resource(%d) of type (stream)
69: [0]=>
70: resource(%d) of type (stream)
71: }
72: string(3) "foo"
73: array(2) {
74: ["blob1"]=>
75: resource(%d) of type (stream)
76: [0]=>
77: resource(%d) of type (stream)
78: }
79: string(0) ""
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>