1--TEST-- 2Set and check Oracle 11gR2 "edition" attribute 3--SKIPIF-- 4<?php 5if (!extension_loaded('oci8')) die("skip no oci8 extension"); 6require(dirname(__FILE__)."/connect.inc"); 7if (strcasecmp($user, "system") && strcasecmp($user, "sys")) 8 die("skip needs to be run as a DBA user"); 9if ($test_drcp) 10 die("skip as Output might vary with DRCP"); 11preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); 12if (!(isset($matches[0]) && 13 (($matches[1] == 11 && $matches[2] >= 2) || 14 ($matches[1] >= 12) 15 ))) { 16 die("skip expected output only valid when using Oracle 11gR2 or greater database server"); 17} 18preg_match('/^([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)/', oci_client_version(), $matches); 19if (!(isset($matches[0]) && 20 (($matches[1] == 11 && $matches[2] >= 2) || 21 ($matches[1] >= 12) 22 ))) { 23 die("skip test expected to work only with Oracle 11gR2 or greater version of client"); 24} 25 26?> 27--FILE-- 28<?php 29 30/* In 11.2, there can only be one child edition. So this test will 31 * fail to create the necessary editions if a child edition exists 32 * already 33 */ 34 35$testuser = 'testuser_ed_2'; // Used in conn_attr.inc 36$testpassword = 'testuser'; 37 38require(dirname(__FILE__)."/conn_attr.inc"); 39 40echo"**Test 1.1 - Default value for the attribute **************\n"; 41get_edit_attr($c); 42 43echo"\n\n**Test 1.2 - Set a value and get the same with different connections *********\n"; 44set_edit_attr('MYEDITION'); 45 46// With oci_connect, oci_pconnect, oci_new_connect 47$conn1 = get_conn(1); 48get_edit_attr($conn1); 49 50//pconnect 51$conn2 = get_conn(2); 52get_edit_attr($conn2); 53 54//new_connect 55$conn3 = get_conn(3); 56get_edit_attr($conn3); 57 58oci_close($conn1); 59 60// With a oci_pconnect with a different charset. 61$pc1 = oci_pconnect($testuser,$testpassword,$dbase,"utf8"); 62get_edit_attr($pc1); 63oci_close($pc1); 64 65 66echo"\n\n**Test 1.3 change the value and verify with existing conenctions.*********\n"; 67set_edit_attr('MYEDITION1'); 68get_edit_attr($conn2); 69get_edit_attr($conn3); // Old value 70oci_close($conn2); 71oci_close($conn3); 72 73//open a new connection and get the edition value . This will have the updated value. 74$c3 = get_conn(3); //oci_new_connect() 75get_edit_attr($c3); 76 77$c4 = get_conn(2); //oci_pconnect() 78get_edit_attr($c4); 79 80$c5 = get_conn(1); //oci_connect() 81get_edit_attr($c5); 82 83oci_close($c3); 84oci_close($c4); 85oci_close($c5); 86 87echo "\n\n**Test 1.4 - with different type of values *********\n"; 88$values_array = array(123,NULL,'NO EDITION','edition name which has more than thirty chars!!!edition name which has more than thirty chars!!!'); 89foreach ($values_array as $val ) { 90 set_edit_attr($val); 91 $c1 = get_conn(1); //oci_connect() 92 if ($c1) { 93 get_edit_attr($c1); 94 oci_close($c1); 95 } 96} 97 98echo "\n\n**Test 1.5 - Negative case with an invalid string value. *********\n"; 99$c1 = get_conn(3); 100$r = set_edit_attr($c1); 101 102echo"\n\n**Test 1.6 - Set Multiple times.*****\n"; 103set_edit_attr('MYEDITION'); 104set_edit_attr('MYEDITION1'); 105$c1 = get_conn(1); 106get_edit_attr($c1); 107oci_close($c1); 108 109echo "\n\n**Test 1.7 - Test with ALTER SESSION statement to change the edition *******\n"; 110// Set the edition value to MYEDITION. open a conn .get the value. 111// execute the alter system set edition ='MYEDITION' .get the value . 112// set it back to MYEDITION using oci_set_edition. and get the value. 113 114set_edit_attr('MYEDITION'); 115$c1 = get_conn(3); 116echo "get the value set to MYEDITION with oci_set_edition\n"; 117get_edit_attr($c1); 118 119$alter_stmt = "alter session set edition = MYEDITION1"; 120$s = oci_parse($c1,$alter_stmt); 121oci_execute($s); 122oci_commit($c1); 123echo "Get the value set to MYEDITION1 with alter session\n"; 124get_edit_attr($c1); 125 126echo " Get the value with a new connection\n"; 127$c2 = get_conn(1); 128get_edit_attr($c2); 129 130echo " Set the value back using oci-set_edition\n"; 131set_edit_attr('MYEDITION'); 132get_edit_attr($c2); 133 134echo " Get the value with a new conenction\n"; 135$c3 = get_conn(1); 136get_edit_attr($c3); 137 138oci_close($c1); 139oci_close($c2); 140oci_close($c3); 141 142 143echo "\n\n**Test 1.8 - Test setting the attribute with scope ends*******\n"; 144set_scope(); 145get_scope(); 146 147clean_up($c); 148echo "Done\n"; 149 150 151function set_scope() { 152 $r = set_edit_attr('MYEDITION1'); 153} 154 155function get_scope() { 156 $sc1 = oci_connect($GLOBALS['testuser'],$GLOBALS['testpassword'],$GLOBALS['dbase']); 157 if ($sc1 === false) { 158 $m = oci_error(); 159 die("Error:" . $m['message']); 160 } 161 get_edit_attr($sc1); 162 oci_close($sc1); 163} 164?> 165--EXPECTF-- 166**Test 1.1 - Default value for the attribute ************** 167The value of current EDITION is ORA$BASE 168 169 170**Test 1.2 - Set a value and get the same with different connections ********* 171 The value of edition has been successfully set 172Testing with oci_connect() 173The value of current EDITION is MYEDITION 174Testing with oci_pconnect() 175The value of current EDITION is MYEDITION 176Testing with oci_new_connect() 177The value of current EDITION is MYEDITION 178The value of current EDITION is MYEDITION 179 180 181**Test 1.3 change the value and verify with existing conenctions.********* 182 The value of edition has been successfully set 183The value of current EDITION is MYEDITION 184The value of current EDITION is MYEDITION 185Testing with oci_new_connect() 186The value of current EDITION is MYEDITION1 187Testing with oci_pconnect() 188The value of current EDITION is MYEDITION1 189Testing with oci_connect() 190The value of current EDITION is MYEDITION1 191 192 193**Test 1.4 - with different type of values ********* 194 The value of edition has been successfully set 195Testing with oci_connect() 196 197Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d 198 The value of edition has been successfully set 199Testing with oci_connect() 200The value of current EDITION is ORA$BASE 201 The value of edition has been successfully set 202Testing with oci_connect() 203 204Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d 205 The value of edition has been successfully set 206Testing with oci_connect() 207 208Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d 209 210 211**Test 1.5 - Negative case with an invalid string value. ********* 212Testing with oci_new_connect() 213 214Warning: oci_new_connect(): ORA-38801: %s ORA_EDITION in %s on line %d 215 The value of edition has been successfully set 216 217 218**Test 1.6 - Set Multiple times.***** 219 The value of edition has been successfully set 220 The value of edition has been successfully set 221Testing with oci_connect() 222The value of current EDITION is MYEDITION1 223 224 225**Test 1.7 - Test with ALTER SESSION statement to change the edition ******* 226 The value of edition has been successfully set 227Testing with oci_new_connect() 228get the value set to MYEDITION with oci_set_edition 229The value of current EDITION is MYEDITION 230Get the value set to MYEDITION1 with alter session 231The value of current EDITION is MYEDITION1 232 Get the value with a new connection 233Testing with oci_connect() 234The value of current EDITION is MYEDITION 235 Set the value back using oci-set_edition 236 The value of edition has been successfully set 237The value of current EDITION is MYEDITION 238 Get the value with a new conenction 239Testing with oci_connect() 240The value of current EDITION is MYEDITION 241 242 243**Test 1.8 - Test setting the attribute with scope ends******* 244 The value of edition has been successfully set 245The value of current EDITION is MYEDITION1 246Done 247