xref: /PHP-5.3/ext/pdo_mysql/tests/bug_61411.phpt (revision b42d0004)
1--TEST--
2Bug #61411 (PDO Segfaults with PERSISTENT == TRUE && EMULATE_PREPARES == FALSE)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
6require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
7require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
8MySQLPDOTest::skip();
9$db = MySQLPDOTest::factory();
10
11$row = $db->query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC);
12$matches = array();
13if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches))
14	die(sprintf("skip Cannot determine MySQL Server version\n"));
15
16$version = $matches[0] * 10000 + $matches[1] * 100 + $matches[2];
17if ($version < 40106)
18	die(sprintf("skip Need MySQL Server 4.1.6+, found %d.%02d.%02d (%d)\n",
19		$matches[0], $matches[1], $matches[2], $version));
20?>
21--FILE--
22<?php
23require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
24
25$attr	= getenv('PDOTEST_ATTR');
26if (!$attr) {
27	$attr = array();
28} else {
29	$attr = unserialize($attr);
30}
31$attr[PDO::ATTR_PERSISTENT] = true;
32$attr[PDO::ATTR_EMULATE_PREPARES] = false;
33putenv('PDOTEST_ATTR='.serialize($attr));
34
35$db = MySQLPDOTest::factory();
36
37$stmt = $db->prepare("SELECT 1");
38$stmt->execute();
39
40foreach ($stmt as $line) {
41	var_dump($line);
42}
43
44print "done!";
45?>
46--EXPECTF--
47array(2) {
48  [1]=>
49  int(1)
50  [2]=>
51  int(1)
52}
53done!
54