1--TEST-- 2Bug #39858 (Lost connection to MySQL server during query by a repeated call stored proced) 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$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); 15 16function bug_39858($db) { 17 $procedure = 'bug_39858_pdo_mysql_p'; 18 19 $db->exec("DROP PROCEDURE IF EXISTS {$procedure}"); 20 $db->exec(" 21 CREATE PROCEDURE {$procedure}() 22 NOT DETERMINISTIC 23 CONTAINS SQL 24 SQL SECURITY DEFINER 25 COMMENT '' 26 BEGIN 27 SELECT 2 * 2; 28 END;"); 29 30 $stmt = $db->prepare("CALL {$procedure}()"); 31 $stmt->execute(); 32 do { 33 var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); 34 } while ($stmt->nextRowset()); 35 36 $stmt = $db->prepare("CALL {$procedure}()"); 37 $stmt->execute(); 38 do { 39 var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); 40 } while ($stmt->nextRowset()); 41 $stmt->closeCursor(); 42} 43 44printf("Emulated Prepared Statements...\n"); 45$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); 46bug_39858($db); 47 48printf("Native Prepared Statements...\n"); 49$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); 50bug_39858($db); 51 52print "done!"; 53?> 54--CLEAN-- 55<?php 56require_once __DIR__ . '/inc/mysql_pdo_test.inc'; 57$db = MySQLPDOTest::factory(); 58$db->exec("DROP PROCEDURE IF EXISTS bug_39858_pdo_mysql_p"); 59?> 60--EXPECT-- 61Emulated Prepared Statements... 62array(1) { 63 [0]=> 64 array(1) { 65 ["2 * 2"]=> 66 string(1) "4" 67 } 68} 69array(0) { 70} 71array(1) { 72 [0]=> 73 array(1) { 74 ["2 * 2"]=> 75 string(1) "4" 76 } 77} 78array(0) { 79} 80Native Prepared Statements... 81array(1) { 82 [0]=> 83 array(1) { 84 ["2 * 2"]=> 85 string(1) "4" 86 } 87} 88array(0) { 89} 90array(1) { 91 [0]=> 92 array(1) { 93 ["2 * 2"]=> 94 string(1) "4" 95 } 96} 97array(0) { 98} 99done! 100