1--TEST--
2PECL Bug #7976 (Calling stored procedure several times)
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once __DIR__ . '/inc/mysql_pdo_test.inc';
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12require_once __DIR__ . '/inc/mysql_pdo_test.inc';
13$db = MySQLPDOTest::factory();
14
15function bug_pecl_7976($db) {
16    $procedure = 'bug_pecl_7976_pdo_mysql_p';
17    $db->exec("DROP PROCEDURE IF EXISTS {$procedure}");
18    $db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT '1' AS _one; END;");
19
20    $stmt = $db->query("CALL {$procedure}()");
21    var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
22    $stmt->closeCursor();
23
24    $stmt = $db->query("CALL {$procedure}()");
25    var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
26    $stmt->closeCursor();
27}
28
29printf("Emulated...\n");
30$db = MySQLPDOTest::factory();
31$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
32bug_pecl_7976($db);
33
34printf("Native...\n");
35$db = MySQLPDOTest::factory();
36$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
37bug_pecl_7976($db);
38
39print "done!";
40?>
41--CLEAN--
42<?php
43require_once __DIR__ . '/inc/mysql_pdo_test.inc';
44$db = MySQLPDOTest::factory();
45$db->exec('DROP PROCEDURE IF EXISTS bug_pecl_7976_pdo_mysql_p');
46?>
47--EXPECT--
48Emulated...
49array(1) {
50  [0]=>
51  array(1) {
52    ["_one"]=>
53    string(1) "1"
54  }
55}
56array(1) {
57  [0]=>
58  array(1) {
59    ["_one"]=>
60    string(1) "1"
61  }
62}
63Native...
64array(1) {
65  [0]=>
66  array(1) {
67    ["_one"]=>
68    string(1) "1"
69  }
70}
71array(1) {
72  [0]=>
73  array(1) {
74    ["_one"]=>
75    string(1) "1"
76  }
77}
78done!
79