Index: ext/pdo_pgsql/pgsql_statement.c
===================================================================
RCS file: /repository/php-src/ext/pdo_pgsql/pgsql_statement.c,v
retrieving revision 1.31.2.12.2.7.2.8
diff -u -r1.31.2.12.2.7.2.8 pgsql_statement.c
--- ext/pdo_pgsql/pgsql_statement.c	31 Dec 2008 11:15:41 -0000	1.31.2.12.2.7.2.8
+++ ext/pdo_pgsql/pgsql_statement.c	4 Feb 2009 18:33:03 -0000
@@ -408,6 +408,12 @@
 			break;
 	
 		case OIDOID:
+			/* Note: the following code is run when execute is called(),
+				 therefore it will fail if the column is bound after
+				 $stmt->execute() is called. In that case the OID
+				 is always returned as int
+			*/
+
 			/* did the user bind the column as a LOB ? */
 			if (stmt->bound_columns && (
 					SUCCESS == zend_hash_index_find(stmt->bound_columns,
Index: ext/pdo_pgsql/tests/large_objects.phpt
===================================================================
RCS file: /repository/php-src/ext/pdo_pgsql/tests/large_objects.phpt,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 large_objects.phpt
--- ext/pdo_pgsql/tests/large_objects.phpt	29 Nov 2005 02:11:39 -0000	1.1.2.1
+++ ext/pdo_pgsql/tests/large_objects.phpt	4 Feb 2009 18:33:04 -0000
@@ -19,7 +19,7 @@
 $db->beginTransaction();
 $oid = $db->pgsqlLOBCreate();
 try {
-$stm = $db->pgsqlLOBOpen($oid);
+$stm = $db->pgsqlLOBOpen($oid, 'w+b');
 fwrite($stm, "Hello dude\n");
 
 $stmt = $db->prepare("INSERT INTO test (blobid, bloboid) values (?, ?)");
@@ -34,14 +34,37 @@
 
 /* Pull it out */
 $stmt = $db->prepare("SELECT * from test");
-$stmt->execute();
 $stmt->bindColumn('bloboid', $lob, PDO::PARAM_LOB);
+$stmt->execute();
 echo "Fetching:\n";
 while (($row = $stmt->fetch(PDO::FETCH_ASSOC))) {
 	var_dump($row['blobid']);
 	var_dump(stream_get_contents($lob));
 }
 echo "Fetched!\n";
+
+/* Try again, with late bind */
+$stmt = $db->prepare("SELECT * from test");
+$stmt->execute();
+$stmt->bindColumn('bloboid', $lob, PDO::PARAM_LOB);
+echo "Fetching late bind:\n";
+while (($row = $stmt->fetch(PDO::FETCH_ASSOC))) {
+	var_dump($row['blobid']);
+	var_dump(is_int($row['bloboid']));
+}
+echo "Fetched!\n";
+
+/* Try again, with NO  bind */
+$stmt = $db->prepare("SELECT * from test");
+$stmt->execute();
+$stmt->bindColumn('bloboid', $lob, PDO::PARAM_LOB);
+echo "Fetching NO bind:\n";
+while (($row = $stmt->fetch(PDO::FETCH_ASSOC))) {
+	var_dump($row['blobid']);
+	var_dump(is_int($row['bloboid']));
+}
+echo "Fetched!\n";
+
 } catch (Exception $e) {
 	/* catch exceptions so that we can guarantee to clean
 	 * up the LOB */
@@ -53,9 +76,18 @@
  * linger and clutter up the storage */
 $db->pgsqlLOBUnlink($oid);
 
+?>
 --EXPECT--
 Fetching:
 int(1)
 string(11) "Hello dude
 "
 Fetched!
+Fetching late bind:
+int(1)
+bool(true)
+Fetched!
+Fetching NO bind:
+int(1)
+bool(true)
+Fetched!
