db_op_2.phpt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. --TEST--
  2. oci_set_db_operation: test DBOP for end-to-end tracing
  3. --EXTENSIONS--
  4. oci8
  5. --SKIPIF--
  6. <?php
  7. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  8. require(__DIR__.'/skipif.inc');
  9. if (strcasecmp($user, "system") && strcasecmp($user, "sys")) {
  10. die("skip needs to be run as a DBA user");
  11. }
  12. preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
  13. if (!(isset($matches[0]) && $matches[1] >= 12)) {
  14. die("skip expected output only valid when using Oracle Database 12c or greater");
  15. }
  16. preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
  17. if (!(isset($matches[0]) && $matches[0] >= 12)) {
  18. die("skip works only with Oracle 12c or greater version of Oracle client libraries");
  19. }
  20. if (!function_exists('oci_set_db_operation'))
  21. {
  22. die("skip function oci_set_db_operation() does not exist");
  23. }
  24. ?>
  25. --FILE--
  26. <?php
  27. require(__DIR__.'/connect.inc');
  28. function dq($c, $q)
  29. {
  30. $s = oci_parse($c, $q);
  31. oci_execute($s);
  32. var_dump(oci_fetch_assoc($s));
  33. }
  34. echo "Test 1\n";
  35. oci_set_db_operation($c, "db_op_2_a");
  36. dq($c, 'select /*+ MONITOR */ * from dual');
  37. oci_set_db_operation($c, "db_op_2_b");
  38. dq($c, 'select /*+ MONITOR */ * from dual');
  39. dq($c, 'select dbop_name from v$sql_monitor where dbop_name like \'db_op_2%\' order by dbop_exec_id desc');
  40. echo "Test 2\n";
  41. oci_set_db_operation($c, "");
  42. dq($c, 'select /*+ MONITOR */ \'dboptest\' from dual');
  43. dq($c, 'select sql_text, dbop_name from v$sql_monitor where sql_text like \'%dboptest%\' order by dbop_exec_id desc');
  44. ?>
  45. --EXPECT--
  46. Test 1
  47. array(1) {
  48. ["DUMMY"]=>
  49. string(1) "X"
  50. }
  51. array(1) {
  52. ["DUMMY"]=>
  53. string(1) "X"
  54. }
  55. array(1) {
  56. ["DBOP_NAME"]=>
  57. string(9) "db_op_2_b"
  58. }
  59. Test 2
  60. array(1) {
  61. ["'DBOPTEST'"]=>
  62. string(8) "dboptest"
  63. }
  64. array(2) {
  65. ["SQL_TEXT"]=>
  66. string(42) "select /*+ MONITOR */ 'dboptest' from dual"
  67. ["DBOP_NAME"]=>
  68. NULL
  69. }