php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44113 New collection creation can fail with OCI-22303
Submitted: 2008-02-13 21:30 UTC Modified: 2008-02-15 23:49 UTC
From: christopher dot jones at oracle dot com Assigned: sixd
Status: Closed Package: OCI8 related
PHP Version: 5.2.5 OS: n/a
Private report: No CVE-ID:
 [2008-02-13 21:30 UTC] christopher dot jones at oracle dot com
Description:
------------
In some circumstances oci_new_collection() can fail. The problem
was reported to me as occurring from at least PHP 5.1.2 onwards.

The cause appears to be lack of a describe-handle free in the
OCI8 extension; this is under investigation.

Reproduce code:
---------------
create or replace type ut_num_list_t as table of number;
create or replace procedure test_load( 
    p_list_1                    ut_num_list_t) 
as
begin 
    for i in 1..p_list_1.count()
    loop
        null; 
    end loop;
end; 
/ 
show errors 


<?php

    $dbh = oci_pconnect('hr', 'hrpwd', '//localhost/XE');

    for ($x = 0; $x < 100000; $x++)
    {
        //print "$x\n";

        $list = array();
        for ($i = 0; $i < mt_rand(0, 15); $i++)
        {
            $list[] = mt_rand(0, 30);
        }

        $sql = "
            begin
                test_load(
                    p_list_1 => :list_1);
            end;";

        $sth = oci_parse($dbh, $sql);

        $type = 'UT_NUM_LIST_T';
        $placeholder = ':list_1';

        if (!($var = oci_new_collection($dbh, $type)))
        {
                print "Failed new collection creation on $x\n";
        }

        foreach ($list as $list_item)
        {
            $var->append($list_item);
        }

        oci_bind_by_name($sth, $placeholder, $var, -1, OCI_B_NTY);

        try
        {
          oci_execute($sth);
          $var->free();
          oci_free_statement($sth);
        }
        catch (Exception $e)
        {
          print "Failed on $x\n";
          throw $e;
        }
    }

print "Completed $x\n";


oci_close($dbh);
?>


Expected result:
----------------
Completed 100000

Actual result:
--------------
Warning: oci_new_collection(): OCI-22303: type ""."UT_NUM_LIST_T" not found in /home/cjones/public_html/t1.php on line 26
Failed new collection creation on 65464

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-14 23:03 UTC] sixd@php.net
Try this patch for 5.2.5:
--- php-5.2.5/php-5.2.5/ext/oci8/oci8_collection.c	2007-07-31 12:21:08.000000000 -0700
+++ oci8_collection.c	2008-02-14 01:56:15.000000000 -0800
@@ -219,11 +219,17 @@
 		goto CLEANUP;
 	}
 
+	/* free the describe handle */
+	PHP_OCI_CALL(OCIHandleFree, ((dvoid *) dschp1, OCI_HTYPE_DESCRIBE));
 	PHP_OCI_REGISTER_RESOURCE(collection, le_collection);
 	return collection;
 	
 CLEANUP:
 
+	if (dschp1) {
+		PHP_OCI_CALL(OCIHandleFree, ((dvoid *) dschp1, OCI_HTYPE_DESCRIBE));
+	}
 	php_oci_error(connection->err, connection->errcode TSRMLS_CC);
 	php_oci_collection_close(collection TSRMLS_CC);	
 	return NULL;

 [2008-02-15 23:49 UTC] sixd@php.net
The above patch (+ variable initialization) from Haneef has been merged.

 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 04:01:57 2014 UTC