db_op_1.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. --TEST--
  2. oci_set_db_operation: basic test for end-to-end tracing
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('oci8')) die ("skip no oci8 extension");
  6. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  7. require(dirname(__FILE__).'/skipif.inc');
  8. if (strcasecmp($user, "system") && strcasecmp($user, "sys")) {
  9. die("skip needs to be run as a DBA user");
  10. }
  11. preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
  12. if (!(isset($matches[0]) && $matches[1] >= 12)) {
  13. die("skip expected output only valid when using Oracle Database 12c or greater");
  14. }
  15. preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
  16. if (!(isset($matches[0]) && $matches[0] >= 12)) {
  17. die("skip works only with Oracle 12c or greater version of Oracle client libraries");
  18. }
  19. if (!function_exists('oci_set_db_operation'))
  20. {
  21. die("skip function oci_set_db_operation() does not exist");
  22. }
  23. ?>
  24. --FILE--
  25. <?php
  26. require(dirname(__FILE__).'/connect.inc');
  27. // Run Test
  28. echo "Test 1\n";
  29. // Test setting the "DB operation" used by Oracle DB for end-to-end application tracing
  30. function dq($c, $q)
  31. {
  32. $s = oci_parse($c, $q);
  33. oci_execute($s);
  34. var_dump(oci_fetch_assoc($s));
  35. }
  36. oci_set_db_operation($c, "db_op_1");
  37. dq($c, 'select * from dual');
  38. dq($c, 'select dbop_name from v$sql_monitor where dbop_name is not null order by dbop_exec_id desc');
  39. ?>
  40. ===DONE===
  41. <?php exit(0); ?>
  42. --EXPECTF--
  43. Test 1
  44. array(1) {
  45. ["DUMMY"]=>
  46. string(1) "X"
  47. }
  48. array(1) {
  49. ["DBOP_NAME"]=>
  50. string(7) "db_op_1"
  51. }
  52. ===DONE===