xref: /PHP-7.0/ext/pdo_pgsql/tests/bug70861.phpt (revision 1184f0ac)
1--TEST--
2Bug #70861 Segmentation fault in pdo_parse_params() during Drupal 8 test suite
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
6require dirname(__FILE__) . '/config.inc';
7require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
8PDOTest::skip();
9?>
10--FILE--
11<?php
12require 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
17try {
18	@$db->query("SET bytea_output = 'escape'");
19} catch (Exception $e) {
20}
21
22$db->query('DROP TABLE IF EXISTS test_blob_crash CASCADE');
23$db->query('CREATE TABLE test_blob_crash (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 test_one_blob (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--EXPECTF--
45%a
46+++DONE+++
47