From: jarismar at adplabs dot com dot br
Operating system: Windows, Linux Ubintu
PHP version: 5.2.3
PHP Bug Type: PDO related
Bug description: Trying to insert multiple BLOBs on oracle with pdo_oci hangs
up Apache.
Description:
------------
Unable to read BLOBs from a given table and insert on another one, because
php hangs up after inserting the first record on destination table.
Reproduce code:
---------------
SQL:
CREATE TABLE TBL_BLOB (id NUMBER(10), data BLOB);
CREATE TABLE TBL_BLOB2 (id NUMBER(10), data BLOB);
You will need to insert some records on TBL_BLOB.
PHP:
try {
$oPDO = new PDO($sDSN, $sUserName, $sPassword);
$oPDO->beginTransaction();
$sSQLRead = 'SELECT ID, DATA FROM TBL_BLOB';
$oStmtRead = $oPDO->prepare($sSQLRead);
$oStmtRead->execute();
$sSQLWrite = 'INSERT INTO TBL_BLOB2 (ID, DATA) VALUES (:id,
EMPTY_BLOB()) RETURNING DATA INTO :stream';
$oStmtWrite = $oPDO->prepare($sSQLWrite);
while (($aRow = $oStmtRead->fetch())) {
$iID = $aRow['ID'];
$rData = $aRow['DATA'];
if (is_resource($rData)) {
$sData = stream_get_contents($rData);
fclose($rData);
} else {
throw new Exception('Error fetching stream');
}
$oStmtWrite->bindParam(':id', $iID);
$oStmtWrite->bindParam(':stream', $resource, PDO::PARAM_LOB);
$oStmtWrite->execute();
if (is_resource($resource)) {
fwrite($resource, $sData);
fclose($resource);
} else {
throw new Exception('Error fetching stream');
}
}
$oStmtRead->closeCursor();
$oPDO->commit();
} catch (Exception $oE) {
$oPDO->rollBack();
throw $oE;
}
$oPDO = null;
Expected result:
----------------
No output, but TBL_BLOB2 should have same records from TBL_BLOB.
Actual result:
--------------
Apache hangs up, the page keeps loading forever.
Simply trying to debug the script I see no error, the script finishes
normally, but Apache does not send any response.
Uncommenting the fclose(<stream>) command then debugging, the debugger
stops after writing to TBL_BLOB2 on the second record.
--
Edit bug report at http://bugs.php.net/?id=41877&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=41877&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=41877&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=41877&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41877&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=41877&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41877&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41877&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41877&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41877&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41877&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=41877&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=41877&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41877&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41877&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41877&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41877&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41877&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41877&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41877&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41877&r=mysqlcfg