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