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