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