Annotation of embedaddon/php/ext/pdo_oci/tests/bug46274.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, true);
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($res->fetch());
52:
53: // Empty string
54: var_dump($res->fetch());
55:
56: $db->exec("DROP TABLE test_one_blob");
57:
58: ?>
59: --XFAIL--
60: Corrupts memory
61: --EXPECTF--
62: array(2) {
63: ["blob1"]=>
64: string(3) "foo"
65: [0]=>
66: string(3) "foo"
67: }
68: array(2) {
69: ["blob1"]=>
70: string(0) ""
71: [0]=>
72: string(0) ""
73: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>