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