php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47311 PDO::PARAM_LOB columns need to be bound before execute() on PgSQL
Submitted: 2009-02-04 18:29 UTC Modified: 2009-03-22 18:35 UTC
From: matteo at beccati dot com Assigned:
Status: Closed Package: PDO related
PHP Version: 5.3.0beta1 OS: Any
Private report: No CVE-ID: None
 [2009-02-04 18:29 UTC] matteo at beccati dot com
Description:
------------
I was trying to investigate a test failure in the pdo_pgsql extension, namely the large_objects.phpt.

The failure is caused by the fact that the LOB parameter is bound after calling execute, which seems to be unsupported. Moving the call to bindColumn() before execute() fixes the test.

I've also tried to fix it, but no matter how hard I tried I couldn't find a suitable solution that also kept backwards compatibility (i.e. returning the large object OID as int if the parameter is not explicitly bound as PDO::PARAM_LOB).

Therefore I think that the best solution would be to document such behaviour and fix the test accordingly.

Note: it doesn't look like a duplicate of #40913, as mysql and sqlite do not seem to have custom code to retrieve data as a stream.

Reproduce code:
---------------
$stmt = $db->prepare("SELECT * from test");
$stmt->bindColumn('bloboid', $lob, PDO::PARAM_LOB);
$stmt->execute();
$stmt->fetch(PDO::FETCH_ASSOC);
var_dump(is_resource($lob));

$stmt = $db->prepare("SELECT * from test");
$stmt->execute();
$stmt->bindColumn('bloboid', $lob, PDO::PARAM_LOB);
$stmt->fetch(PDO::FETCH_ASSOC);
var_dump(is_resource($lob));


Expected result:
----------------
bool(true)
bool(true)

Actual result:
--------------
bool(true)
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-04 18:31 UTC] matteo at beccati dot com
Patch is available here:

http://www.beccati.com/misc/pdo_pgsql_bug47311_php_5.3.patch

It fixes another small problem in the phpt and adds one more test case. Plus adds a note to the code.
 [2009-02-11 10:44 UTC] felipe@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2009-02-11 11:19 UTC] matteo at beccati dot com
Thanks for that. I've also created a patch for the documentation. You might want to check the wording and fixing it before applying:

http://www.beccati.com/misc/pdo_pgsql_bug47311_phpdoc.patch
 [2009-03-22 18:35 UTC] kalle@php.net
Fixed in phpdoc for the record
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 05:01:31 2024 UTC