Annotation of embedaddon/php/ext/oci8/tests/bug38173.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Bug #38173 (Freeing nested cursors causes OCI8 to segfault)
        !             3: --SKIPIF--
        !             4: <?php
        !             5: $target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
        !             6: require(dirname(__FILE__).'/skipif.inc');
        !             7: ?> 
        !             8: --FILE--
        !             9: <?php
        !            10: 
        !            11: require dirname(__FILE__)."/connect.inc";
        !            12: 
        !            13: $create_1 = "CREATE TABLE t1 (id INTEGER)";
        !            14: $create_2 = "CREATE TABLE t2 (id INTEGER)";
        !            15: $drop_1 = "DROP TABLE t1";
        !            16: $drop_2 = "DROP TABLE t2";
        !            17: 
        !            18: $s1 = oci_parse($c, $drop_1);
        !            19: $s2 = oci_parse($c, $drop_2);
        !            20: @oci_execute($s1);
        !            21: @oci_execute($s2);
        !            22: 
        !            23: $s1 = oci_parse($c, $create_1);
        !            24: $s2 = oci_parse($c, $create_2);
        !            25: oci_execute($s1);
        !            26: oci_execute($s2);
        !            27: 
        !            28: for($i=0; $i < 5; $i++) {
        !            29:        $insert = "INSERT INTO t1 VALUES(".$i.")";
        !            30:        $s = oci_parse($c, $insert);
        !            31:        oci_execute($s);
        !            32: }
        !            33: 
        !            34: for($i=0; $i < 5; $i++) {
        !            35:        $insert = "INSERT INTO t2 VALUES(".$i.")";
        !            36:        $s = oci_parse($c, $insert);
        !            37:        oci_execute($s);
        !            38: }
        !            39: 
        !            40: $query ="
        !            41: SELECT
        !            42:   t1.*,
        !            43:   CURSOR( SELECT * FROM t2 ) as cursor
        !            44: FROM
        !            45:   t1
        !            46: ";
        !            47: 
        !            48: $sth = oci_parse($c, $query);
        !            49: oci_execute($sth);
        !            50: 
        !            51: // dies on oci_free_statement on 2nd pass through loop
        !            52: while ( $row = oci_fetch_assoc($sth) ) {
        !            53:   print "Got row!\n";
        !            54:   var_dump(oci_execute($row['CURSOR']));
        !            55:   var_dump(oci_free_statement($row['CURSOR']));
        !            56: }
        !            57: 
        !            58: $s1 = oci_parse($c, $drop_1);
        !            59: $s2 = oci_parse($c, $drop_2);
        !            60: @oci_execute($s1);
        !            61: @oci_execute($s2);
        !            62: 
        !            63: echo "Done\n";
        !            64: 
        !            65: ?>
        !            66: --EXPECT--
        !            67: Got row!
        !            68: bool(true)
        !            69: bool(true)
        !            70: Got row!
        !            71: bool(true)
        !            72: bool(true)
        !            73: Got row!
        !            74: bool(true)
        !            75: bool(true)
        !            76: Got row!
        !            77: bool(true)
        !            78: bool(true)
        !            79: Got row!
        !            80: bool(true)
        !            81: bool(true)
        !            82: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>