edition_2.phpt 7.2 KB

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