Annotation of embedaddon/php/ext/pdo_pgsql/tests/bug46274.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, true);
! 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($res->fetch());
! 48:
! 49: // Empty string
! 50: var_dump($res->fetch());
! 51:
! 52: // Empty string
! 53: var_dump($res->fetch());
! 54:
! 55: // NULL
! 56: var_dump($res->fetch());
! 57:
! 58: $db->query('DROP TABLE test_one_blob');
! 59:
! 60: ?>
! 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: }
! 74: array(2) {
! 75: ["blob1"]=>
! 76: string(0) ""
! 77: [0]=>
! 78: string(0) ""
! 79: }
! 80: array(2) {
! 81: ["blob1"]=>
! 82: NULL
! 83: [0]=>
! 84: NULL
! 85: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>