From:             christopher dot jones at oracle dot com
Operating system: n/a
PHP version:      5.2.3
PHP Bug Type:     OCI8 related
Bug description:  Null temporary lobs not supported

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 bug report at http://bugs.php.net/?id=41711&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41711&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41711&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41711&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41711&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41711&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41711&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41711&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41711&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41711&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41711&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41711&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41711&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41711&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41711&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41711&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41711&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41711&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41711&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41711&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41711&r=mysqlcfg

Reply via email to