From: Antony Dovgal Date: Mon, 25 Jun 2007 18:26:52 +0000 (+0000) Subject: MFH: fix #41711 (Null temporary lobs not supported) X-Git-Tag: php-5.2.4RC1~295 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa8a77a46632acea0e7b0587185425bd5b595d1f;p=php MFH: fix #41711 (Null temporary lobs not supported) --- diff --git a/NEWS b/NEWS index c4eb1f82dd..98f01741a5 100644 --- a/NEWS +++ b/NEWS @@ -41,6 +41,8 @@ PHP NEWS - 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 diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c index 10dcdcddbe..28b0f4e573 100644 --- a/ext/oci8/oci8_lob.c +++ b/ext/oci8/oci8_lob.c @@ -859,8 +859,7 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, ub1 type, char *data, break; } - if (!data || data_len <= 0) { - /* nothing to write, silently fail */ + if (data_len < 0) { return 1; } diff --git a/ext/oci8/tests/lob_null.phpt b/ext/oci8/tests/lob_null.phpt new file mode 100644 index 0000000000..227ebb89fb --- /dev/null +++ b/ext/oci8/tests/lob_null.phpt @@ -0,0 +1,265 @@ +--TEST-- +Test null data for CLOBs +--SKIPIF-- + +--FILE-- +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 \ No newline at end of file