xref: /php-src/ext/pdo_pgsql/tests/bug70861.phpt (revision 6fb81d23)
1--TEST--
2Bug #70861 Segmentation fault in pdo_parse_params() during Drupal 8 test suite
3--EXTENSIONS--
4pdo_pgsql
5--SKIPIF--
6<?php
7require __DIR__ . '/config.inc';
8require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
9PDOTest::skip();
10?>
11--FILE--
12<?php
13require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
14$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
15
16$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
17
18try {
19    @$db->query("SET bytea_output = 'escape'");
20} catch (Exception $e) {
21}
22
23$db->query('CREATE TABLE test70861 (id SERIAL NOT NULL, blob1 BYTEA)');
24
25class HelloWrapper {
26    public function stream_open() { return true; }
27    public function stream_eof() { return true; }
28    public function stream_read() { return NULL; }
29    public function stream_stat() { return array(); }
30}
31stream_wrapper_register("hello", "HelloWrapper");
32
33$f = fopen("hello://there", "r");
34
35$stmt = $db->prepare("INSERT INTO test70861 (blob1) VALUES (:foo)", array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
36
37$stmt->bindparam(':foo', $f, PDO::PARAM_LOB);
38$stmt->execute();
39
40fclose($f);
41
42?>
43+++DONE+++
44--CLEAN--
45<?php
46require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
47$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
48$db->query('DROP TABLE IF EXISTS test70861 CASCADE');
49?>
50--EXPECTF--
51%a
52+++DONE+++
53