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