Skip to content

Commit 4246702

Browse files
committed
Enable Oracle Database DBOP tracing attribute
1 parent 465c149 commit 4246702

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

ext/oci8/oci8.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_client_info, 0, 0, 2)
423423
ZEND_ARG_INFO(0, client_information)
424424
ZEND_END_ARG_INFO()
425425

426-
#ifdef WAITIING_ORACLE_BUG_16695981_FIX
427426
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_db_operation, 0, 0, 2)
428427
ZEND_ARG_INFO(0, connection_resource)
429428
ZEND_ARG_INFO(0, action)
430429
ZEND_END_ARG_INFO()
431-
#endif
432430

433431
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_password_change, 0, 0, 4)
434432
ZEND_ARG_INFO(0, connection_resource_or_connection_string)
@@ -672,9 +670,7 @@ PHP_FUNCTION(oci_statement_type);
672670
PHP_FUNCTION(oci_num_rows);
673671
PHP_FUNCTION(oci_set_prefetch);
674672
PHP_FUNCTION(oci_set_client_identifier);
675-
#ifdef WAITIING_ORACLE_BUG_16695981_FIX
676673
PHP_FUNCTION(oci_set_db_operation);
677-
#endif
678674
PHP_FUNCTION(oci_set_edition);
679675
PHP_FUNCTION(oci_set_module_name);
680676
PHP_FUNCTION(oci_set_action);
@@ -777,9 +773,7 @@ static const zend_function_entry php_oci_functions[] = {
777773
PHP_FE(oci_new_descriptor, arginfo_oci_new_descriptor)
778774
PHP_FE(oci_set_prefetch, arginfo_oci_set_prefetch)
779775
PHP_FE(oci_set_client_identifier, arginfo_oci_set_client_identifier)
780-
#ifdef WAITIING_ORACLE_BUG_16695981_FIX
781776
PHP_FE(oci_set_db_operation, arginfo_oci_set_db_operation)
782-
#endif
783777
PHP_FE(oci_set_edition, arginfo_oci_set_edition)
784778
PHP_FE(oci_set_module_name, arginfo_oci_set_module_name)
785779
PHP_FE(oci_set_action, arginfo_oci_set_action)

ext/oci8/oci8_interface.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,9 +2027,9 @@ PHP_FUNCTION(oci_set_client_info)
20272027
}
20282028
/* }}} */
20292029

2030-
#ifdef WAITIING_ORACLE_BUG_16695981_FIX
20312030
/* {{{ proto bool oci_set_db_operation(resource connection, string value)
2032-
Sets the "DB operation" on the connection for Oracle end-to-end tracing */
2031+
Sets the "DB operation" on the connection for Oracle end-to-end tracing.
2032+
For history, see Oracle bug 16695981 */
20332033
PHP_FUNCTION(oci_set_db_operation)
20342034
{
20352035
#if (OCI_MAJOR_VERSION > 11)
@@ -2058,7 +2058,6 @@ PHP_FUNCTION(oci_set_db_operation)
20582058
#endif
20592059
}
20602060
/* }}} */
2061-
#endif /* WAITIING_ORACLE_BUG_16695981_FIX */
20622061

20632062
/* {{{ proto bool oci_password_change(resource connection, string username, string old_password, string new_password)
20642063
Changes the password of an account */

ext/oci8/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Interoperability Support" (ID 207303.1) for details.
6767
<notes>
6868
This version is for PHP 7 only.
6969
Fixed bug #76804 (oci_pconnect with OCI_CRED_EXT not working). (KoenigsKind)
70+
Support setting Oracle Database 'DBOP' end-to-end-tracing attribute. (Requires Oracle 12.2 or later)
7071
Fixed installation on 7.3.
7172
Internal change: Convert some parameter parsing to the Fast Parameter Parsing API.
7273
</notes>

ext/oci8/tests/db_op_1.phpt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
1616
if (!(isset($matches[0]) && $matches[0] >= 12)) {
1717
die("skip works only with Oracle 12c or greater version of Oracle client libraries");
1818
}
19-
if (!function_exists('oci_set_db_operation'))
20-
{
21-
die("skip function oci_set_db_operation() does not exist");
22-
}
2319
?>
2420
--FILE--
2521
<?php
@@ -40,7 +36,7 @@ function dq($c, $q)
4036
}
4137

4238
oci_set_db_operation($c, "db_op_1");
43-
dq($c, 'select * from dual');
39+
dq($c, 'select /*+ MONITOR */ * from dual');
4440

4541
dq($c, 'select dbop_name from v$sql_monitor where dbop_name is not null order by dbop_exec_id desc');
4642

ext/oci8/tests/db_op_2.phpt

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
oci_set_db_operation: basic test for end-to-end tracing
2+
oci_set_db_operation: test DBOP for end-to-end tracing
33
--SKIPIF--
44
<?php
55
if (!extension_loaded('oci8')) die ("skip no oci8 extension");
@@ -35,34 +35,45 @@ function dq($c, $q)
3535

3636
echo "Test 1\n";
3737
oci_set_db_operation($c, "db_op_2_a");
38-
dq($c, 'select * from dual');
38+
dq($c, 'select /*+ MONITOR */ * from dual');
3939

40-
echo "Test 2\n";
4140
oci_set_db_operation($c, "db_op_2_b");
42-
dq($c, 'select * from dual');
41+
dq($c, 'select /*+ MONITOR */ * from dual');
42+
43+
dq($c, 'select dbop_name from v$sql_monitor where dbop_name like \'db_op_2%\' order by dbop_exec_id desc');
44+
45+
echo "Test 2\n";
46+
oci_set_db_operation($c, "");
47+
dq($c, 'select /*+ MONITOR */ \'dboptest\' from dual');
4348

44-
echo "Test 3\n";
45-
dq($c, 'select dbop_name from v$sql_monitor where dbop_name like \'db_op2%\' order by dbop_exec_id desc');
49+
dq($c, 'select sql_text, dbop_name from v$sql_monitor where sql_text like \'%dboptest2%\' order by dbop_exec_id desc');
4650

4751
?>
4852
===DONE===
4953
<?php exit(0); ?>
50-
--XFAIL--
51-
Fails due to Oracle Bug 16695981
5254
--EXPECT--
5355
Test 1
5456
array(1) {
5557
["DUMMY"]=>
5658
string(1) "X"
5759
}
58-
Test 2
5960
array(1) {
6061
["DUMMY"]=>
6162
string(1) "X"
6263
}
63-
Test 3
64+
array(1) {
65+
["DBOP_NAME"]=>
66+
string(9) "db_op_2_b"
67+
}
68+
Test 2
69+
array(1) {
70+
["'DBOPTEST'"]=>
71+
string(8) "dboptest"
72+
}
6473
array(2) {
74+
["SQL_TEXT"]=>
75+
string(121) "select /*+ MONITOR */ sql_text, dbop_name from v$sql_monitor where sql_text like '%dboptest2%' order by dbop_exec_id desc"
6576
["DBOP_NAME"]=>
66-
string(7) "db_op_2a"
77+
NULL
6778
}
6879
===DONE===

0 commit comments

Comments
 (0)