From: Christopher Jones Date: Tue, 11 Dec 2007 06:46:16 +0000 (+0000) Subject: MFB: Fix #42496. Cursor leak fetching LOBs X-Git-Tag: RELEASE_1_3_1~530 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02ecdf0821d48e9fcb91131869ca176275c3afcd;p=php MFB: Fix #42496. Cursor leak fetching LOBs --- diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 6b03536772..c4bf10652b 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -368,7 +368,6 @@ sb4 php_oci_define_callback(dvoid *ctx, OCIDefine *define, ub4 iter, dvoid **buf if (!descr) { return OCI_ERROR; } - zend_list_addref(outcol->statement->id); outcol->descid = descr->id; descr->charset_form = outcol->charset_form; diff --git a/ext/oci8/tests/bug42496_1.phpt b/ext/oci8/tests/bug42496_1.phpt new file mode 100644 index 0000000000..4d7e2c5852 --- /dev/null +++ b/ext/oci8/tests/bug42496_1.phpt @@ -0,0 +1,61 @@ +--TEST-- +Bug #42496 (LOB fetch leaks cursors, eventually failing with ORA-1000 maximum open cursors reached) +--SKIPIF-- + +--FILE-- +free(); + $arr['C2']->free(); + } + } + oci_free_statement($s); +} + +echo "Done\n"; + +// Cleanup + +$stmtarray = array( + "DROP table bug42496_tab" +); + +foreach ($stmtarray as $stmt) { + $s = oci_parse($c, $stmt); + @oci_execute($s); +} + +oci_close($c); + +?> +--EXPECTF-- +Test 1 +Done diff --git a/ext/oci8/tests/bug42496_2.phpt b/ext/oci8/tests/bug42496_2.phpt new file mode 100644 index 0000000000..e2800bbd8a --- /dev/null +++ b/ext/oci8/tests/bug42496_2.phpt @@ -0,0 +1,59 @@ +--TEST-- +Bug #42496 (LOB fetch leaks cursors, eventually failing with ORA-1000 maximum open cursors reached) +--SKIPIF-- + +--FILE-- +free(); + $arr['C2']->free(); + } + } + oci_free_statement($s); +} + +echo "Done\n"; + +// Cleanup + +$stmtarray = array( + "DROP table bug42496_tab" +); + +foreach ($stmtarray as $stmt) { + $s = oci_parse($c, $stmt); + @oci_execute($s); +} + +oci_close($c); + +?> +--EXPECTF-- +Test 2 +Done diff --git a/ext/oci8/tests/lob_041.phpt b/ext/oci8/tests/lob_041.phpt new file mode 100644 index 0000000000..d04b43606a --- /dev/null +++ b/ext/oci8/tests/lob_041.phpt @@ -0,0 +1,92 @@ +--TEST-- +Check LOBS are valid after statement free +--SKIPIF-- + +--FILE-- +load(), "\n"; +oci_free_descriptor($desc); + +echo "\nTest 2 - implicit statement close\n"; + +$s = oci_parse($c, "SELECT C1 FROM lob_041_tab"); +$desc = oci_new_descriptor($c, OCI_DTYPE_LOB); +oci_define_by_name($s, "C1", $desc); +oci_execute($s); +$data = oci_fetch_assoc($s); +$s = null; +echo $data['C1']->load(), "\n"; +oci_free_descriptor($desc); +var_dump($desc); + +echo "\nTest 3 - no preallocated descriptor\n"; + +$s = oci_parse($c, "SELECT C1 FROM lob_041_tab"); +oci_execute($s); +$data = oci_fetch_assoc($s); +$s = null; +echo $data['C1']->load(), "\n"; +var_dump($data); + +// Cleanup + +echo "Done\n"; + +$stmtarray = array( + "DROP table lob_041_tab" +); + +foreach ($stmtarray as $stmt) { + $s = oci_parse($c, $stmt); + @oci_execute($s); +} + +oci_close($c); + +?> + +--EXPECTF-- +Test 1 - explicit statement close +test data + +Test 2 - implicit statement close +test data +object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) +} + +Test 3 - no preallocated descriptor +test data +array(1) { + ["C1"]=> + object(OCI-Lob)#%d (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +Done