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