xref: /PHP-5.3/ext/pdo_mysql/tests/bug_41997.phpt (revision 84878060)
1--TEST--
2PDO MySQL Bug #41997 (stored procedure call returning single rowset blocks future queries)
3--SKIPIF--
4<?php
5require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
6require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7MySQLPDOTest::skip();
8
9$db = MySQLPDOTest::factory();
10$row = $db->query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC);
11$matches = array();
12if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches))
13	die(sprintf("skip Cannot determine MySQL Server version\n"));
14
15$version = $matches[0] * 10000 + $matches[1] * 100 + $matches[2];
16if ($version < 50000)
17	die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n",
18		$matches[0], $matches[1], $matches[2], $version));
19?>
20--FILE--
21<?php
22require dirname(__FILE__) . '/mysql_pdo_test.inc';
23$db = MySQLPDOTest::factory();
24
25$db->exec('DROP PROCEDURE IF EXISTS p');
26$db->exec('CREATE PROCEDURE p() BEGIN SELECT 1 AS "one"; END');
27
28$stmt = $db->query("CALL p()");
29do {
30	var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
31} while ($stmt->nextRowset());
32var_dump($stmt->errorInfo());
33
34$stmt = $db->query('SELECT 2 AS "two"');
35var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
36var_dump($stmt->errorInfo());
37print "done!";
38?>
39--EXPECTF--
40array(1) {
41  [0]=>
42  array(1) {
43    [%u|b%"one"]=>
44    %unicode|string%(1) "1"
45  }
46}
47array(3) {
48  [0]=>
49  %unicode|string%(5) "00000"
50  [1]=>
51  NULL
52  [2]=>
53  NULL
54}
55array(1) {
56  [0]=>
57  array(1) {
58    [%u|b%"two"]=>
59    %unicode|string%(1) "2"
60  }
61}
62array(3) {
63  [0]=>
64  %unicode|string%(5) "00000"
65  [1]=>
66  NULL
67  [2]=>
68  NULL
69}
70done!
71