Commit:    954a0f8bf4f8779f509b8361c1bc02246bd1ea20
Author:    Christopher Jones <s...@php.net>         Mon, 30 Sep 2013 16:51:07 
-0700
Parents:   ca6a259ed1297e0b0a2c5f605587caadd1c3a7ed
Branches:  master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=954a0f8bf4f8779f509b8361c1bc02246bd1ea20

Log:
OCI8 2.0: Added a new oci_set_db_operation() user space function for the "DB 
Operation" tracing feature of Oracle DB 12c.

Currently this code is #ifdef'd out, since I can't consider the feature stable 
until an Oracle-side fix for Oracle bug 16695981 is available.  Having the code 
available in PHP OCI8 facilitates testing of any fix.

Bugs:
https://bugs.php.net/16695981

Changed paths:
  M  ext/oci8/oci8.c
  M  ext/oci8/oci8_interface.c


Diff:
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index 6723c22..eeb1ade 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -457,6 +457,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_client_info, 0, 0, 
2)
        ZEND_ARG_INFO(0, client_information)
 ZEND_END_ARG_INFO()
 
+#ifdef WAITIING_ORACLE_BUG_16695981_FIX
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_db_operation, 0, 0, 2)
+ZEND_ARG_INFO(0, connection_resource)
+ZEND_ARG_INFO(0, action)
+ZEND_END_ARG_INFO()
+#endif
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_password_change, 0, 0, 4)
        ZEND_ARG_INFO(0, connection_resource_or_connection_string)
        ZEND_ARG_INFO(0, username)
@@ -708,6 +715,9 @@ static unsigned char arginfo_oci_bind_array_by_name[] = { 
3, BYREF_NONE, BYREF_N
 #define arginfo_oci_set_module_name                                            
NULL
 #define arginfo_oci_set_action                                                 
NULL
 #define arginfo_oci_set_client_info                                            
NULL
+#ifdef WAITIING_ORACLE_BUG_16695981_FIX
+#define arginfo_oci_set_db_operation                                   NULL
+#endif
 #define arginfo_oci_password_change                                            
NULL
 #define arginfo_oci_new_cursor                                                 
NULL
 #define arginfo_oci_result                                                     
        NULL
@@ -799,6 +809,9 @@ PHP_FUNCTION(oci_statement_type);
 PHP_FUNCTION(oci_num_rows);
 PHP_FUNCTION(oci_set_prefetch);
 PHP_FUNCTION(oci_set_client_identifier);
+#ifdef WAITIING_ORACLE_BUG_16695981_FIX
+PHP_FUNCTION(oci_set_db_operation);
+#endif
 PHP_FUNCTION(oci_set_edition);
 PHP_FUNCTION(oci_set_module_name);
 PHP_FUNCTION(oci_set_action);
@@ -904,6 +917,9 @@ zend_function_entry php_oci_functions[] = {
        PHP_FE(oci_new_descriptor,                      
arginfo_oci_new_descriptor)
        PHP_FE(oci_set_prefetch,                        
arginfo_oci_set_prefetch)
        PHP_FE(oci_set_client_identifier,       
arginfo_oci_set_client_identifier)
+#ifdef WAITIING_ORACLE_BUG_16695981_FIX
+       PHP_FE(oci_set_db_operation,            arginfo_oci_set_db_operation)
+#endif
        PHP_FE(oci_set_edition,                         arginfo_oci_set_edition)
        PHP_FE(oci_set_module_name,                     
arginfo_oci_set_module_name)
        PHP_FE(oci_set_action,                          arginfo_oci_set_action)
diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c
index 0f17f93..a452c1a 100644
--- a/ext/oci8/oci8_interface.c
+++ b/ext/oci8/oci8_interface.c
@@ -1928,6 +1928,38 @@ PHP_FUNCTION(oci_set_client_info)
 }
 /* }}} */
 
+#ifdef WAITIING_ORACLE_BUG_16695981_FIX
+/* {{{ proto bool oci_set_db_operation(resource connection, string value)
+   Sets the "DB operation" on the connection for Oracle end-to-end tracing */
+PHP_FUNCTION(oci_set_db_operation)
+{
+#if (OCI_MAJOR_VERSION > 11)
+       zval *z_connection;
+       php_oci_connection *connection;
+       char *dbop_name;
+       int dbop_name_len;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", 
&z_connection, &dbop_name, &dbop_name_len) == FAILURE) {
+               return;
+       }
+
+       PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
+
+       PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) 
connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) dbop_name, (ub4) 
dbop_name_len, (ub4) OCI_ATTR_DBOP, OCI_G(err)));
+
+       if (OCI_G(errcode) != OCI_SUCCESS) {
+               php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+               RETURN_FALSE;
+       }
+       RETURN_TRUE;
+#else
+       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute 
type");
+       RETURN_FALSE;
+#endif
+}
+/* }}} */
+#endif /* WAITIING_ORACLE_BUG_16695981_FIX */
+
 /* {{{ proto bool oci_password_change(resource connection, string username, 
string old_password, string new_password)
   Changes the password of an account */
 PHP_FUNCTION(oci_password_change)


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to