Annotation of embedaddon/php/ext/pdo_pgsql/tests/bug46274.phpt, revision 1.1.1.2
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_pgsql')) die('skip not loaded');
6: require dirname(__FILE__) . '/config.inc';
7: require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
8: PDOTest::skip();
9: ?>
10: --FILE--
11: <?php
12: require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
13: $db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
14:
15: $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
16:
1.1.1.2 ! misho 17: try {
! 18: @$db->query("SET bytea_output = 'escape'");
! 19: } catch (Exception $e) {
! 20: }
! 21:
1.1 misho 22: $db->query('CREATE TABLE test_one_blob (id SERIAL NOT NULL, blob1 BYTEA)');
23:
24: $stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (:foo)");
25:
26: $data = 'foo';
27: $blob = fopen('php://memory', 'a');
28: fwrite($blob, $data);
29: rewind($blob);
30:
31: $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
32: $stmt->execute();
33:
34: $blob = '';
35: $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
36: $stmt->execute();
37:
38: $data = '';
39: $blob = fopen('php://memory', 'a');
40: fwrite($blob, $data);
41: rewind($blob);
42:
43: $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
44: $stmt->execute();
45:
46: $blob = NULL;
47: $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
48: $stmt->execute();
49:
50: $res = $db->query("SELECT blob1 from test_one_blob");
51: // Resource
52: var_dump($res->fetch());
53:
54: // Empty string
55: var_dump($res->fetch());
56:
57: // Empty string
58: var_dump($res->fetch());
59:
60: // NULL
61: var_dump($res->fetch());
62:
63: $db->query('DROP TABLE test_one_blob');
64:
65: ?>
66: --EXPECTF--
67: array(2) {
68: ["blob1"]=>
69: string(3) "foo"
70: [0]=>
71: string(3) "foo"
72: }
73: array(2) {
74: ["blob1"]=>
75: string(0) ""
76: [0]=>
77: string(0) ""
78: }
79: array(2) {
80: ["blob1"]=>
81: string(0) ""
82: [0]=>
83: string(0) ""
84: }
85: array(2) {
86: ["blob1"]=>
87: NULL
88: [0]=>
89: NULL
90: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>