php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41877 Trying to insert multiple BLOBs on oracle with pdo_oci hangs up Apache
Submitted: 2007-07-02 20:04 UTC Modified: 2016-03-08 01:41 UTC
From: jarismar at adplabs dot com dot br Assigned:
Status: No Feedback Package: PDO OCI
PHP Version: 5.2.3 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jarismar at adplabs dot com dot br
New email:
PHP Version: OS:

 

 [2007-07-02 20:04 UTC] jarismar at adplabs dot com dot br
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-02 20:21 UTC] jarismar at adplabs dot com dot br
Running the script from command line seems to work fine.
Apache version is 2.0.59 I'll trying an upgrade.
 [2007-07-05 13:58 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

Wrong button. sorry.
 [2007-07-13 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2016-03-08 01:41 UTC] sixd@php.net
-Package: PDO related +Package: PDO OCI
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC