xref: /PHP-5.6/ext/oci8/tests/db_op_1.phpt (revision 1675fd22)
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(dirname(__FILE__).'/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(dirname(__FILE__).'/connect.inc');
28
29// Run Test
30
31echo "Test 1\n";
32
33// Test setting the "DB operation" used by Oracle DB for end-to-end application tracing
34
35function dq($c, $q)
36{
37    $s = oci_parse($c, $q);
38    oci_execute($s);
39    var_dump(oci_fetch_assoc($s));
40}
41
42oci_set_db_operation($c, "db_op_1");
43dq($c, 'select * from dual');
44
45dq($c, 'select dbop_name from v$sql_monitor where dbop_name is not null order by dbop_exec_id desc');
46
47?>
48===DONE===
49<?php exit(0); ?>
50--EXPECTF--
51Test 1
52array(1) {
53  ["DUMMY"]=>
54  string(1) "X"
55}
56array(1) {
57  ["DBOP_NAME"]=>
58  string(7) "db_op_1"
59}
60===DONE===
61
62