tony2001                Mon Jun 25 18:26:52 2007 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/oci8/tests     lob_null.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/oci8   oci8_lob.c 
  Log:
  MFH: fix #41711 (Null temporary lobs not supported)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.797&r2=1.2027.2.547.2.798&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.797 php-src/NEWS:1.2027.2.547.2.798
--- php-src/NEWS:1.2027.2.547.2.797     Mon Jun 25 16:01:29 2007
+++ php-src/NEWS        Mon Jun 25 18:26:52 2007
@@ -41,6 +41,8 @@
 - Fixed bug #41724 (libxml_get_last_error() - errors service request scope).
   (thekid at php dot net, Ilia)
 - Fixed bug #41717 (imagepolygon does not respect thickness). (Pierre)
+- Fixed bug #41711 (NULL temporary lobs not supported in OCI8). 
+  (Chris Jones, Tony)
 - Fixed bug #41686 (Omitting length param in array_slice not possible).
   (Ilia)
 - Fixed bug #41685 (array_push() fails to warn when next index is already
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_lob.c?r1=1.7.2.6.2.11&r2=1.7.2.6.2.12&diff_format=u
Index: php-src/ext/oci8/oci8_lob.c
diff -u php-src/ext/oci8/oci8_lob.c:1.7.2.6.2.11 
php-src/ext/oci8/oci8_lob.c:1.7.2.6.2.12
--- php-src/ext/oci8/oci8_lob.c:1.7.2.6.2.11    Thu Mar 29 09:33:03 2007
+++ php-src/ext/oci8/oci8_lob.c Mon Jun 25 18:26:52 2007
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8_lob.c,v 1.7.2.6.2.11 2007/03/29 09:33:03 tony2001 Exp $ */
+/* $Id: oci8_lob.c,v 1.7.2.6.2.12 2007/06/25 18:26:52 tony2001 Exp $ */
 
 
 
@@ -859,8 +859,7 @@
                        break;
        }
 
-       if (!data || data_len <= 0) {
-               /* nothing to write, silently fail */
+       if (data_len < 0) {
                return 1;
        }
 

http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/lob_null.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/lob_null.phpt
+++ php-src/ext/oci8/tests/lob_null.phpt
--TEST--
Test null data for CLOBs
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php

require dirname(__FILE__).'/connect.inc';

// Initialization

$s = oci_parse($c, 'drop table lob_null_tab');
@oci_execute($s);

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

$s = oci_parse($c, 
'create or replace procedure lob_null_proc_in (pid in number, pdata in CLOB)
 as begin
   insert into lob_null_tab (id, data) values (pid, pdata);
 end;');
oci_execute($s);

$s = oci_parse($c, 
'create or replace procedure lob_null_proc_out (pid in number, pdata out clob)
   as begin
     select data into pdata from lob_null_tab where id = pid;
 end;');
oci_execute($s);

// TEMPORARY CLOB

echo "Temporary CLOB: NULL\n";
$s = oci_parse($c, "insert into lob_null_tab 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);
if (!$r) {
    $m = oci_error($s);
    echo $m['message'], "\n";
}   
else {
    $lob->close();
}

echo "Temporary CLOB: ''\n";
$s = oci_parse($c, "insert into lob_null_tab 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);
if (!$r) {
    $m = oci_error($s);
    echo $m['message'], "\n";
}   
else {
    $lob->close();
}

echo "Temporary CLOB: text\n";
$s = oci_parse($c, "insert into lob_null_tab 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);
if (!$r) {
    $m = oci_error($s);
    echo $m['message'], "\n";
}   
else {
    $lob->close();
}

// PROCEDURE PARAMETER

echo "Procedure parameter: NULL\n";
$s = oci_parse($c, "call lob_null_proc_in(4, :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);
if (!$r) {
    $m = oci_error($s);
    echo $m['message'], "\n";
}   
else {
    $lob->close();
}

echo "Procedure parameter: ''\n";
$s = oci_parse($c, "call lob_null_proc_in(5, :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);
if (!$r) {
    $m = oci_error($s);
    echo $m['message'], "\n";
}   
else {
    $lob->close();
}

echo "Procedure parameter: text\n";
$s = oci_parse($c, "call lob_null_proc_in(6, :b)");
$lob = oci_new_descriptor($c, OCI_D_LOB);
oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB);
$lob->writeTemporary('Inserted via procedure parameter');
$r = @oci_execute($s);
if (!$r) {
    $m = oci_error($s);
    echo $m['message'], "\n";
}   
else {
    $lob->close();
}

// RETURNING INTO

echo "RETURNING INTO: null\n";
$s = oci_parse($c, "insert into lob_null_tab values (7, empty_clob()) returning 
data into :b");
$lob = oci_new_descriptor($c, OCI_D_LOB);
oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB);
oci_execute($s, OCI_DEFAULT);  // Must have OCI_DEFAULT here so locator is 
still valid
$lob->save(null);

echo "RETURNING INTO: ''\n";
$s = oci_parse($c, "insert into lob_null_tab values (8, empty_clob()) returning 
data into :b");
$lob = oci_new_descriptor($c, OCI_D_LOB);
oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB);
oci_execute($s, OCI_DEFAULT);  // Must have OCI_DEFAULT here so locator is 
still valid
$lob->save('');

echo "RETURNING INTO: text\n";
$s = oci_parse($c, "insert into lob_null_tab values (9, empty_clob()) returning 
data into :b");
$lob = oci_new_descriptor($c, OCI_D_LOB);
oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB);
oci_execute($s, OCI_DEFAULT);  // Must have OCI_DEFAULT here so locator is 
still valid
$lob->save('Inserted with RETURNING INTO');

echo "Fetch as string\n";
$s = oci_parse ($c, 'select id, data from lob_null_tab order by id');
oci_execute($s);
oci_fetch_all($s, $res);
var_dump($res);

echo "\nFetch as a descriptor\n";
$s = oci_parse ($c, 'select id, data from lob_null_tab order by id');
oci_execute($s);
while ($arr = oci_fetch_assoc($s)) {
    if (is_object($arr['DATA'])) {
        echo $arr['ID'] . " is an object: ";
        $r = $arr['DATA']->load();
        var_dump($r);
    }
    else {
        echo $arr['ID'] . " is not an object\n";
    }
}

echo "\nFetch via the procedure parameter\n";
for ($i = 1; $i <= 9; $i++)
{
    $s = oci_parse ($c, "call lob_null_proc_out($i, :b)");
    $lob = oci_new_descriptor($c, OCI_D_LOB);
    oci_bind_by_name($s, ':b', $lob, -1, OCI_B_CLOB);
    oci_execute($s);
    if (is_object($lob)) {
        echo $i . " is an object: ";
        $r = $lob->load();
        var_dump($r);
    }
    else {
        echo $i . " is not an object\n";
    }
}

// Cleanup

$s = oci_parse($c, 'drop table lob_null_tab');
@oci_execute($s);

echo "Done\n";

?>
--EXPECTF-- 
Temporary CLOB: NULL
Temporary CLOB: ''
Temporary CLOB: text
Procedure parameter: NULL
Procedure parameter: ''
Procedure parameter: text
RETURNING INTO: null
RETURNING INTO: ''
RETURNING INTO: text
Fetch as string
array(2) {
  ["ID"]=>
  array(9) {
    [0]=>
    string(1) "1"
    [1]=>
    string(1) "2"
    [2]=>
    string(1) "3"
    [3]=>
    string(1) "4"
    [4]=>
    string(1) "5"
    [5]=>
    string(1) "6"
    [6]=>
    string(1) "7"
    [7]=>
    string(1) "8"
    [8]=>
    string(1) "9"
  }
  ["DATA"]=>
  array(9) {
    [0]=>
    string(0) ""
    [1]=>
    string(0) ""
    [2]=>
    string(26) "Inserted via SQL statement"
    [3]=>
    string(0) ""
    [4]=>
    string(0) ""
    [5]=>
    string(32) "Inserted via procedure parameter"
    [6]=>
    string(0) ""
    [7]=>
    string(0) ""
    [8]=>
    string(28) "Inserted with RETURNING INTO"
  }
}

Fetch as a descriptor
1 is an object: string(0) ""
2 is an object: string(0) ""
3 is an object: string(26) "Inserted via SQL statement"
4 is an object: string(0) ""
5 is an object: string(0) ""
6 is an object: string(32) "Inserted via procedure parameter"
7 is an object: string(0) ""
8 is an object: string(0) ""
9 is an object: string(28) "Inserted with RETURNING INTO"

Fetch via the procedure parameter
1 is an object: string(0) ""
2 is an object: string(0) ""
3 is an object: string(26) "Inserted via SQL statement"
4 is an object: string(0) ""
5 is an object: string(0) ""
6 is an object: string(32) "Inserted via procedure parameter"
7 is an object: string(0) ""
8 is an object: string(0) ""
9 is an object: string(28) "Inserted with RETURNING INTO"
Done
--UEXPECTF--
Temporary CLOB: NULL
Temporary CLOB: ''
Temporary CLOB: text
Procedure parameter: NULL
Procedure parameter: ''
Procedure parameter: text
RETURNING INTO: null
RETURNING INTO: ''
RETURNING INTO: text
Fetch as string
array(2) {
  [u"ID"]=>
  array(9) {
    [0]=>
    unicode(1) "1"
    [1]=>
    unicode(1) "2"
    [2]=>
    unicode(1) "3"
    [3]=>
    unicode(1) "4"
    [4]=>
    unicode(1) "5"
    [5]=>
    unicode(1) "6"
    [6]=>
    unicode(1) "7"
    [7]=>
    unicode(1) "8"
    [8]=>
    unicode(1) "9"
  }
  [u"DATA"]=>
  array(9) {
    [0]=>
    unicode(0) ""
    [1]=>
    unicode(0) ""
    [2]=>
    unicode(26) "Inserted via SQL statement"
    [3]=>
    unicode(0) ""
    [4]=>
    unicode(0) ""
    [5]=>
    unicode(32) "Inserted via procedure parameter"
    [6]=>
    unicode(0) ""
    [7]=>
    unicode(0) ""
    [8]=>
    unicode(28) "Inserted with RETURNING INTO"
  }
}

Fetch as a descriptor
1 is an object: unicode(0) ""
2 is an object: unicode(0) ""
3 is an object: unicode(26) "Inserted via SQL statement"
4 is an object: unicode(0) ""
5 is an object: unicode(0) ""
6 is an object: unicode(32) "Inserted via procedure parameter"
7 is an object: unicode(0) ""
8 is an object: unicode(0) ""
9 is an object: unicode(28) "Inserted with RETURNING INTO"

Fetch via the procedure parameter
1 is an object: unicode(0) ""
2 is an object: unicode(0) ""
3 is an object: unicode(26) "Inserted via SQL statement"
4 is an object: unicode(0) ""
5 is an object: unicode(0) ""
6 is an object: unicode(32) "Inserted via procedure parameter"
7 is an object: unicode(0) ""
8 is an object: unicode(0) ""
9 is an object: unicode(28) "Inserted with RETURNING INTO"
Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to