sixd            Wed Mar 11 16:46:38 2009 UTC

  Added files:                 
    /php-src/ext/oci8/tests     bug46994.phpt 

  Modified files:              
    /php-src/ext/oci8   oci8_statement.c 
  Log:
  Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored 
procedure)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.61&r2=1.62&diff_format=u
Index: php-src/ext/oci8/oci8_statement.c
diff -u php-src/ext/oci8/oci8_statement.c:1.61 
php-src/ext/oci8/oci8_statement.c:1.62
--- php-src/ext/oci8/oci8_statement.c:1.61      Mon Mar  9 20:58:13 2009
+++ php-src/ext/oci8/oci8_statement.c   Wed Mar 11 16:46:37 2009
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8_statement.c,v 1.61 2009/03/09 20:58:13 sixd Exp $ */
+/* $Id: oci8_statement.c,v 1.62 2009/03/11 16:46:37 sixd Exp $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -1211,9 +1211,24 @@
                }
                retval = OCI_CONTINUE;
        } else if (Z_TYPE_P(val) == IS_OBJECT) {
+               zval **tmp;
+               php_oci_descriptor *desc;
+
                if (!phpbind->descriptor) {
                        return OCI_ERROR;
                }
+
+               /* Do not use the cached lob size if the descriptor is an
+                * out-bind as the contents would have been changed for in/out
+                * binds (Bug #46994).
+                */
+               if (zend_hash_find(Z_OBJPROP_P(val), "descriptor", 
sizeof("descriptor"), (void **)&tmp) == FAILURE) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to 
find object outbind descriptor property");
+                       return OCI_ERROR;
+               }
+               PHP_OCI_ZVAL_TO_DESCRIPTOR_EX(*tmp, desc);
+               desc->lob_size = -1;    /* force OCI8 to update cached size */
+
                *alenpp = &phpbind->dummy_len;
                *bufpp = phpbind->descriptor;
                *piecep = OCI_ONE_PIECE;

http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/bug46994.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/bug46994.phpt
+++ php-src/ext/oci8/tests/bug46994.phpt
--TEST--
Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored 
procedure)
--SKIPIF--
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
--FILE--
<?php

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

// Initialization

$stmtarray = array(
        "create or replace procedure bug46994_proc1(p1 in out nocopy clob) is
                 begin
                         dbms_lob.trim(p1, 0);
                         dbms_lob.writeappend(p1, 26, 'This should be the 
output.');
         end bug46994_proc1;",
        "create or replace procedure bug46994_proc2(p1 in out nocopy clob) is
                 begin
                         dbms_lob.trim(p1, 0);
                         dbms_lob.writeappend(p1, 37, 'The output should be 
even longer now.');
         end bug46994_proc2;"
);

foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        @oci_execute($s);
}

// Run Test

$myclob = oci_new_descriptor($c, OCI_D_LOB);
$myclob->writeTemporary("some data", OCI_TEMP_CLOB);

echo "Test 1\n";

$s = oci_parse($c, "begin bug46994_proc1(:myclob); end;");
oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB);
oci_execute($s, OCI_DEFAULT);
var_dump($myclob->load());

echo "Test 2\n";

$s = oci_parse($c, "begin bug46994_proc2(:myclob); end;");
oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB);
oci_execute($s, OCI_DEFAULT);
var_dump($myclob->load());

echo "Test 3\n";

$s = oci_parse($c, "begin bug46994_proc1(:myclob); end;");
oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB);
oci_execute($s, OCI_DEFAULT);
var_dump($myclob->load());

echo "Test 4\n";

var_dump($myclob->load());  // Use cached size code path

// Cleanup

$stmtarray = array(
        "drop procedure bug46994_proc1",
        "drop procedure bug46994_proc2"
);

foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        oci_execute($s);
}

oci_close($c);

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
Test 1
unicode(26) "This should be the output."
Test 2
unicode(37) "The output should be even longer now."
Test 3
unicode(26) "This should be the output."
Test 4
unicode(26) "This should be the output."
===DONE===



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

Reply via email to