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