php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41711 Null temporary lobs not supported
Submitted: 2007-06-15 22:48 UTC Modified: 2007-06-25 18:26 UTC
From: christopher dot jones at oracle dot com Assigned:
Status: Closed Package: OCI8 related
PHP Version: 5.2.3 OS: n/a
Private report: No CVE-ID:
 [2007-06-15 22:48 UTC] christopher dot jones at oracle dot com
Description:
------------
Using NULL data for LOB "IN" bind variables gives ORA-22275: invalid LOB locator specified.  Bug discovered by Mike Simonds.

[Tony: I'll send you a complete .phpt via email]

Patch is in function php_oci_lob_write_tmp() in oci_lob.c:

--- oci8_lob.c.orig	2007-06-15 21:13:31.000000000 -0700
+++ oci8_lob.c	2007-06-15 21:58:54.000000000 -0700
@@ -859,11 +859,6 @@
 			break;
 	}

-	if (!data || data_len <= 0) {
-		/* nothing to write, silently fail */
-		return 1;
-	}
-
 	PHP_OCI_CALL_RETURN(connection->errcode, OCILobCreateTemporary,
 			(
 			 connection->svc,


Reproduce code:
---------------
<?php

$c = oci_connect("hr", "hrpwd", "//localhost/XE");

// Initialization

$s = oci_parse($c, 'drop table ctb');
oci_execute($s);
$s = oci_parse($c, 'create table ctb (id number, data clob)');
oci_execute($s);


echo "Temporary CLOB: NULL\n";
$s = oci_parse($c, "insert into ctb values (1, :b)");
$lob = oci_new_descriptor($c, OCI_D_LOB);
oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB);
$lob->writeTemporary(null);
$r = oci_execute($s);
$lob->close();

echo "Temporary CLOB: ''\n";
$s = oci_parse($c, "insert into ctb values (2, :b)");
$lob = oci_new_descriptor($c, OCI_D_LOB);
oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB);
$lob->writeTemporary('');
$r = oci_execute($s);
$lob->close();

echo "Temporary CLOB: text\n";
$s = oci_parse($c, "insert into ctb values (3, :b)");
$lob = oci_new_descriptor($c, OCI_D_LOB);
oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB);
$lob->writeTemporary('Inserted via SQL statement');
$r = oci_execute($s);
$lob->close();

$s = oci_parse ($c, 'select id, data from ctb order by id');
oci_execute($s);
oci_fetch_all($s, $res);
var_dump($res);

?>


Expected result:
----------------
Temporary CLOB: NULL
Temporary CLOB: ''
Temporary CLOB: text
array(2) {
  ["ID"]=>
  array(3) {
    [0]=>
    string(1) "1"
    [1]=>
    string(1) "2"
    [2]=>
    string(1) "3"
  }
  ["DATA"]=>
  array(3) {
    [0]=>
    string(0) ""
    [1]=>
    string(0) ""
    [2]=>
    string(26) "Inserted via SQL statement"
  }
}


Actual result:
--------------
Temporary CLOB: NULL
PHP Warning:  oci_execute(): ORA-22275: invalid LOB locator specified in /home/cjones/public_html/b.php on line 23

Warning: oci_execute(): ORA-22275: invalid LOB locator specified in /home/cjones/public_html/b.php on line 23
PHP Warning:  OCI-Lob::close(): OCI_INVALID_HANDLE in /home/cjones/public_html/b.php on line 24

Warning: OCI-Lob::close(): OCI_INVALID_HANDLE in /home/cjones/public_html/b.php on line 24
Temporary CLOB: ''
PHP Warning:  oci_execute(): ORA-22275: invalid LOB locator specified in /home/cjones/public_html/b.php on line 31

Warning: oci_execute(): ORA-22275: invalid LOB locator specified in /home/cjones/public_html/b.php on line 31
PHP Warning:  OCI-Lob::close(): OCI_INVALID_HANDLE in /home/cjones/public_html/b.php on line 32

Warning: OCI-Lob::close(): OCI_INVALID_HANDLE in /home/cjones/public_html/b.php on line 32
Temporary CLOB: text
array(2) {
  ["ID"]=>
  array(1) {
    [0]=>
    string(1) "3"
  }
  ["DATA"]=>
  array(1) {
    [0]=>
    string(26) "Inserted via SQL statement"
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-25 18:26 UTC] tony2001@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.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 16:02:22 2014 UTC