drcp_cclass1.phpt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --TEST--
  2. DRCP: Test setting connection class inline
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('oci8')) die ("skip no oci8 extension");
  6. require(dirname(__FILE__).'/connect.inc');
  7. if (!$test_drcp) die("skip testing DRCP connection class only works in DRCP mode");
  8. if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
  9. preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches_sv);
  10. // This test in Oracle 12c needs a non-CDB or the root container
  11. if (isset($matches_sv[0]) && $matches_sv[1] >= 12) {
  12. $s = oci_parse($c, "select nvl(sys_context('userenv', 'con_name'), 'notacdb') as dbtype from dual");
  13. $r = @oci_execute($s);
  14. if (!$r)
  15. die('skip could not identify container type');
  16. $r = oci_fetch_array($s);
  17. if ($r['DBTYPE'] !== 'CDB$ROOT')
  18. die('skip cannot run test using a PDB');
  19. }
  20. ?>
  21. --FILE--
  22. <?php
  23. require(dirname(__FILE__)."/details.inc");
  24. // Initialization
  25. $t = time();
  26. $cc1 = 'cc1_'.$t;
  27. $cc2 = 'cc2_'.$t;
  28. // Run Test
  29. echo "Test 1\n";
  30. ini_set('oci8.connection_class', $cc1);
  31. $c = oci_pconnect($user, $password, $dbase);
  32. $s = oci_parse($c, "select * from dual");
  33. oci_execute($s);
  34. oci_fetch_all($s, $r);
  35. var_dump($r);
  36. echo "Test 2\n";
  37. ini_set('oci8.connection_class', $cc2);
  38. $c = oci_pconnect($user, $password, $dbase);
  39. $s = oci_parse($c, "select * from dual");
  40. oci_execute($s);
  41. oci_fetch_all($s, $r);
  42. var_dump($r);
  43. echo "Test 3\n";
  44. $s = oci_parse($c, "select cclass_name from v\$cpool_cc_stats where cclass_name like '%.cc__$t' order by cclass_name");
  45. oci_execute($s);
  46. oci_fetch_all($s, $r);
  47. var_dump($r);
  48. // Cleanup
  49. echo "Done\n";
  50. ?>
  51. --EXPECTF--
  52. Test 1
  53. array(1) {
  54. ["DUMMY"]=>
  55. array(1) {
  56. [0]=>
  57. string(1) "X"
  58. }
  59. }
  60. Test 2
  61. array(1) {
  62. ["DUMMY"]=>
  63. array(1) {
  64. [0]=>
  65. string(1) "X"
  66. }
  67. }
  68. Test 3
  69. array(1) {
  70. ["CCLASS_NAME"]=>
  71. array(2) {
  72. [0]=>
  73. string(21) "%s.cc1_%d"
  74. [1]=>
  75. string(21) "%s.cc2_%d"
  76. }
  77. }
  78. Done