1--TEST-- 2Bug #39858 (Lost connection to MySQL server during query by a repeated call stored proced) 3--SKIPIF-- 4<?php 5if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded'); 6require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc'); 7require_once(__DIR__ . 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[1] * 10000 + $matches[2] * 100 + $matches[3]; 17if ($version < 50000) 18 die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n", 19 $matches[1], $matches[2], $matches[3], $version)); 20?> 21--XFAIL-- 22nextRowset() problem with stored proc & emulation mode & mysqlnd 23--FILE-- 24<?php 25require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 26$db = MySQLPDOTest::factory(); 27$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); 28 29function bug_39858($db) { 30 31 $db->exec("DROP PROCEDURE IF EXISTS p"); 32 $db->exec(" 33 CREATE PROCEDURE p() 34 NOT DETERMINISTIC 35 CONTAINS SQL 36 SQL SECURITY DEFINER 37 COMMENT '' 38 BEGIN 39 SELECT 2 * 2; 40 END;"); 41 42 $stmt = $db->prepare("CALL p()"); 43 $stmt->execute(); 44 do { 45 var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); 46 } while ($stmt->nextRowset()); 47 48 $stmt = $db->prepare("CALL p()"); 49 $stmt->execute(); 50 do { 51 var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); 52 } while ($stmt->nextRowset()); 53 $stmt->closeCursor(); 54 55} 56 57printf("Emulated Prepared Statements...\n"); 58$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); 59bug_39858($db); 60 61printf("Native Prepared Statements...\n"); 62$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); 63bug_39858($db); 64 65print "done!"; 66?> 67--CLEAN-- 68<?php 69require __DIR__ . '/mysql_pdo_test.inc'; 70$db = MySQLPDOTest::factory(); 71$db->exec("DROP PROCEDURE IF EXISTS p"); 72?> 73--EXPECT-- 74Emulated Prepared Statements... 75array(1) { 76 [0]=> 77 array(1) { 78 ["2 * 2"]=> 79 string(1) "4" 80 } 81} 82array(1) { 83 [0]=> 84 array(1) { 85 ["2 * 2"]=> 86 string(1) "4" 87 } 88} 89Native Prepared Statements... 90array(1) { 91 [0]=> 92 array(1) { 93 ["2 * 2"]=> 94 string(1) "4" 95 } 96} 97array(1) { 98 [0]=> 99 array(1) { 100 ["2 * 2"]=> 101 string(1) "4" 102 } 103} 104done! 105