Annotation of embedaddon/php/ext/pdo_pgsql/tests/bug46274_2.phpt, revision 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_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, false);
! 16:
! 17: $db->query('CREATE TABLE test_one_blob (id SERIAL NOT NULL, blob1 BYTEA)');
! 18:
! 19: $stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (:foo)");
! 20:
! 21: $data = 'foo';
! 22: $blob = fopen('php://memory', 'a');
! 23: fwrite($blob, $data);
! 24: rewind($blob);
! 25:
! 26: $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
! 27: $stmt->execute();
! 28:
! 29: $blob = '';
! 30: $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
! 31: $stmt->execute();
! 32:
! 33: $data = '';
! 34: $blob = fopen('php://memory', 'a');
! 35: fwrite($blob, $data);
! 36: rewind($blob);
! 37:
! 38: $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
! 39: $stmt->execute();
! 40:
! 41: $blob = NULL;
! 42: $stmt->bindparam(':foo', $blob, PDO::PARAM_LOB);
! 43: $stmt->execute();
! 44:
! 45: $res = $db->query("SELECT blob1 from test_one_blob");
! 46: // Resource
! 47: var_dump($x = $res->fetch());
! 48: var_dump(fread($x['blob1'], 10));
! 49:
! 50: // Resource
! 51: var_dump($res->fetch());
! 52: var_dump(fread($x['blob1'], 10));
! 53:
! 54: // Resource
! 55: var_dump($res->fetch());
! 56: var_dump(fread($x['blob1'], 10));
! 57:
! 58: // NULL
! 59: var_dump($res->fetch());
! 60:
! 61: $db->query('DROP TABLE test_one_blob');
! 62:
! 63: ?>
! 64: --EXPECTF--
! 65: array(2) {
! 66: ["blob1"]=>
! 67: resource(%d) of type (stream)
! 68: [0]=>
! 69: resource(%d) of type (stream)
! 70: }
! 71: string(3) "foo"
! 72: array(2) {
! 73: ["blob1"]=>
! 74: resource(%d) of type (stream)
! 75: [0]=>
! 76: resource(%d) of type (stream)
! 77: }
! 78: string(0) ""
! 79: array(2) {
! 80: ["blob1"]=>
! 81: resource(%d) of type (stream)
! 82: [0]=>
! 83: resource(%d) of type (stream)
! 84: }
! 85: string(0) ""
! 86: array(2) {
! 87: ["blob1"]=>
! 88: NULL
! 89: [0]=>
! 90: NULL
! 91: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>