drcp_cclass1.phpt 2.1 KB

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