From: Christopher Jones Date: Wed, 11 Mar 2009 16:46:38 +0000 (+0000) Subject: Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored procedure) X-Git-Tag: php-5.4.0alpha1~191^2~4167 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fdace0c5d0680fdb8423e0caa763f4c469e7a2ae;p=php Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored procedure) --- diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 4c21d2a035..eb195c8f86 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -1211,9 +1211,24 @@ sb4 php_oci_bind_out_callback( } 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; diff --git a/ext/oci8/tests/bug46994.phpt b/ext/oci8/tests/bug46994.phpt new file mode 100644 index 0000000000..6a83e73450 --- /dev/null +++ b/ext/oci8/tests/bug46994.phpt @@ -0,0 +1,86 @@ +--TEST-- +Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored procedure) +--SKIPIF-- + +--FILE-- +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=== + +--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===