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