1--TEST-- 2PECL Bug #7976 (Calling stored procedure several times) 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 < 50000) 18 die(sprintf("skip Need MySQL Server 5.0.0+, 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$db = MySQLPDOTest::factory(); 25 26function bug_pecl_7976($db) { 27 28 $db->exec('DROP PROCEDURE IF EXISTS p'); 29 $db->exec('CREATE PROCEDURE p() BEGIN SELECT "1" AS _one; END;'); 30 31 $stmt = $db->query('CALL p()'); 32 var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); 33 $stmt->closeCursor(); 34 35 $stmt = $db->query('CALL p()'); 36 var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); 37 $stmt->closeCursor(); 38 39} 40 41printf("Emulated...\n"); 42$db = MySQLPDOTest::factory(); 43$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); 44bug_pecl_7976($db); 45 46printf("Native...\n"); 47$db = MySQLPDOTest::factory(); 48$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); 49bug_pecl_7976($db); 50 51print "done!"; 52?> 53--CLEAN-- 54<?php 55require dirname(__FILE__) . '/mysql_pdo_test.inc'; 56$db = MySQLPDOTest::factory(); 57$db->exec('DROP PROCEDURE IF EXISTS p'); 58?> 59--XFAIL-- 60Works with mysqlnd. It is not supported by libmysql. For libmysql is good enough to see no crash. 61--EXPECTF-- 62Emulated... 63array(1) { 64 [0]=> 65 array(1) { 66 [%u|b%"_one"]=> 67 %unicode|string%(1) "1" 68 } 69} 70array(1) { 71 [0]=> 72 array(1) { 73 [%u|b%"_one"]=> 74 %unicode|string%(1) "1" 75 } 76} 77Native... 78array(1) { 79 [0]=> 80 array(1) { 81 [%u|b%"_one"]=> 82 %unicode|string%(1) "1" 83 } 84} 85array(1) { 86 [0]=> 87 array(1) { 88 [%u|b%"_one"]=> 89 %unicode|string%(1) "1" 90 } 91} 92done! 93