ID:               41711
 Updated by:       [EMAIL PROTECTED]
 Reported By:      christopher dot jones at oracle dot com
-Status:           Open
+Status:           Closed
 Bug Type:         OCI8 related
 Operating System: n/a
 PHP Version:      5.2.3
 New Comment:

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.




Previous Comments:
------------------------------------------------------------------------

[2007-06-15 22:48:14] 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"
  }
}


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41711&edit=1

Reply via email to