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

1.1     ! misho       1: --TEST--
        !             2: Test piecewise fetch of CLOBs equal to, and larger than PHP_OCI_LOB_BUFFER_SIZE
        !             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: require dirname(__FILE__).'/create_table.inc';
        !            13: 
        !            14: function insert_verify($c, $tn, $id, $length)
        !            15: {
        !            16:     // Insert the data
        !            17:     $ora_sql = "INSERT INTO
        !            18:                        ".$tn." (id, clob)
        !            19:                       VALUES (".$id.", empty_clob())
        !            20:                       RETURNING
        !            21:                                clob
        !            22:                       INTO :v_clob ";
        !            23: 
        !            24:     $statement = oci_parse($c,$ora_sql);
        !            25:     $clob = oci_new_descriptor($c,OCI_D_LOB);
        !            26:     oci_bind_by_name($statement,":v_clob", $clob, -1, OCI_B_CLOB);
        !            27:     oci_execute($statement, OCI_DEFAULT);
        !            28: 
        !            29:     $data = str_pad("x", $length, "x");
        !            30:     $clob->write($data);
        !            31: 
        !            32:     // Verify the data
        !            33:     $select_sql = "SELECT clob FROM ".$tn." where id = ".$id;
        !            34:     $s = oci_parse($c, $select_sql);
        !            35:     oci_execute($s);
        !            36: 
        !            37:     $row = oci_fetch_array($s, OCI_RETURN_LOBS);
        !            38: 
        !            39:     var_dump(strlen($row[0]));
        !            40: }
        !            41: 
        !            42: echo "Test 1: A CLOB with an even number of bytes\n";
        !            43: insert_verify($c, $schema.$table_name, 1, 1050000);
        !            44: 
        !            45: echo "Test 2: A CLOB with an odd number of bytes\n";
        !            46: insert_verify($c, $schema.$table_name, 2, 1050001);
        !            47: 
        !            48: echo "Test 3: A CLOB of 1048576 bytes (== size of PHP_OCI_LOB_BUFFER_SIZE at time of test creation)\n";
        !            49: insert_verify($c, $schema.$table_name, 3, 1048576);
        !            50: 
        !            51: echo "Test 4: A CLOB of 1049028 bytes (the value used for chunks in the code)\n";
        !            52: insert_verify($c, $schema.$table_name, 4, 1049028);
        !            53: 
        !            54: echo "Test 5: A CLOB of 1049028-1 bytes\n";
        !            55: insert_verify($c, $schema.$table_name, 5, 1049028-1);
        !            56: 
        !            57: echo "Test 6: A CLOB of 1049028+1 bytes\n";
        !            58: insert_verify($c, $schema.$table_name, 6, 1049028+1);
        !            59: 
        !            60: require dirname(__FILE__).'/drop_table.inc';
        !            61: 
        !            62: echo "Done\n";
        !            63: 
        !            64: ?>
        !            65: --EXPECTF--
        !            66: Test 1: A CLOB with an even number of bytes
        !            67: int(1050000)
        !            68: Test 2: A CLOB with an odd number of bytes
        !            69: int(1050001)
        !            70: Test 3: A CLOB of 1048576 bytes (== size of PHP_OCI_LOB_BUFFER_SIZE at time of test creation)
        !            71: int(1048576)
        !            72: Test 4: A CLOB of 1049028 bytes (the value used for chunks in the code)
        !            73: int(1049028)
        !            74: Test 5: A CLOB of 1049028-1 bytes
        !            75: int(1049027)
        !            76: Test 6: A CLOB of 1049028+1 bytes
        !            77: int(1049029)
        !            78: Done

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