xref: /PHP-7.4/ext/oci8/tests/db_op_1.phpt (revision 26dfce7f)
1--TEST--
2oci_set_db_operation: basic test 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}
19?>
20--FILE--
21<?php
22
23require(__DIR__.'/connect.inc');
24
25// Run Test
26
27echo "Test 1\n";
28
29// Test setting the "DB operation" used by Oracle DB for end-to-end application tracing
30
31function dq($c, $q)
32{
33    $s = oci_parse($c, $q);
34    oci_execute($s);
35    var_dump(oci_fetch_assoc($s));
36}
37
38oci_set_db_operation($c, "db_op_1");
39dq($c, 'select /*+ MONITOR */ * from dual');
40
41dq($c, 'select dbop_name from v$sql_monitor where dbop_name is not null order by dbop_exec_id desc');
42
43?>
44===DONE===
45<?php exit(0); ?>
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===DONE===
57