From: keithm at aoeex dot com
Operating system: Linux
PHP version: 5.4.5
Package: PDO related
Bug Type: Bug
Bug description:nextRowset causes segfault when using libmysql
Description:
------------
Using PDO with the MySQL driver built using libmysql
pdo_mysql
PDO Driver for MySQL => enabled
Client API version => 5.5.25a
After calling a stored procedure I have the following lines to eat up the
results before running more queries:
do { try { $queueStmt->fetch(); } catch (Exception $e){} } while
($queueStmt-
>nextRowset());
When using libmysql this results in a segfault when calling nextRowset.
Test script:
---------------
<?php
$db = new PDO('mysql:host=localhost;dbname=bugtest', 'bugtest', 'bugtest',
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$sql = 'DROP TABLE IF EXISTS testtbl';
$db->exec($sql);
$sql = 'DROP PROCEDURE IF EXISTS testproc';
$db->exec($sql);
$sql = 'CREATE TABLE testtbl (pk INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
data VARCHAR(10), nextrun DATETIME)';
$db->exec($sql);
$sql = "INSERT INTO testtbl (data, nextrun) VALUES ('asdf',
UTC_TIMESTAMP()),('defg', UTC_TIMESTAMP()),('higk',
UTC_TIMESTAMP()),('lmnop', UTC_TIMESTAMP())";
$db->exec($sql);
$sql = 'CREATE PROCEDURE testproc() NOT DETERMINISTIC MODIFIES SQL DATA
BEGIN DECLARE nextId INT; SELECT pk INTO nextId FROM testtbl WHERE
nextrun=(SELECT MIN(nextrun) FROM testtbl) LIMIT 1; UPDATE testtbl SET
nextrun=UTC_TIMESTAMP()+INTERVAL 1 DAY WHERE pk=nextId; SELECT * FROM
testtbl WHERE pk=nextId; END';
$db->exec($sql);
$queueSql = 'CALL testproc()';
$queueStmt = $db->prepare($queueSql);
$queueStmt->execute();
$row=$queueStmt->fetch(PDO::FETCH_ASSOC);
do { try { $queueStmt->fetch(); } catch (Exception $e){} } while
($queueStmt->nextRowset());
echo "Success";
Expected result:
----------------
Success
Actual result:
--------------
Segmentation fault
--
Edit bug report at https://bugs.php.net/bug.php?id=62707&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62707&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62707&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=62707&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62707&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=62707&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62707&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=62707&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=62707&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=62707&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=62707&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=62707&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=62707&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=62707&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62707&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=62707&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62707&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=62707&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=62707&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=62707&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=62707&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=62707&r=mysqlcfg