summaryrefslogtreecommitdiff
path: root/ext/oci8/oci8_interface.c
diff options
context:
space:
mode:
authorChristopher Jones <sixd@php.net>2009-10-06 22:36:32 +0000
committerChristopher Jones <sixd@php.net>2009-10-06 22:36:32 +0000
commit2769ae044457f19c2adf899f6f159087e60d1af9 (patch)
treee0b3e33b2656d5f60f5b72ee39c23822ee49142e /ext/oci8/oci8_interface.c
parentef2b799a28f1fe94874726935e14b961aaaf74b0 (diff)
downloadphp-git-2769ae044457f19c2adf899f6f159087e60d1af9.tar.gz
1. Introduce connection attribute functions:
oci_set_module_name oci_set_action oci_set_client_info oci_set_client_identifier These functions set values that are visible and used by the database. They aid tracing, authentication and auditing. 2. Introduce connection attribute function: oci_set_edition Oracle 11g R2 "editions" allow multiple versions of DB objects to exist at one time. By setting different editions, two different versions of an application can run concurrently, making upgrades or A/B testing easier. 3. Introduce OCI_NO_AUTO_COMMIT as an alias for the OCI_DEFAULT constant (which is not the default value) used by oci_execute(). 4. Allow the oci_set_prefetch value to be 0. This is important in some cases using REF CURSORS in Oracle 11gR2. 5. Set the DRIVER_NAME attribute of Oracle Database 11gR2 connections to aid application tracing. The value used is to "PHP OCI8" followed by the OCI8 version number. Note the version number may get truncated in DB views such as v$session_connect_info. 6. Generate an error if an invalid resource type is used in oci_bind_by_name [DOC] Documentation will be added for the changes
Diffstat (limited to 'ext/oci8/oci8_interface.c')
-rw-r--r--ext/oci8/oci8_interface.c150
1 files changed, 150 insertions, 0 deletions
diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c
index 151367acb4..f06384a69e 100644
--- a/ext/oci8/oci8_interface.c
+++ b/ext/oci8/oci8_interface.c
@@ -1716,6 +1716,156 @@ PHP_FUNCTION(oci_set_prefetch)
}
/* }}} */
+/* {{{ proto bool oci_set_client_identifier(resource connection, string value)
+ Sets the client identifier attribute on the connection */
+PHP_FUNCTION(oci_set_client_identifier)
+{
+ zval *z_connection;
+ php_oci_connection *connection;
+ char *client_id;
+ long client_id_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_id, &client_id_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 *) client_id, (ub4) client_id_len, (ub4) OCI_ATTR_CLIENT_IDENTIFIER, OCI_G(err)));
+
+ if (OCI_G(errcode) != OCI_SUCCESS) {
+ php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_edition(string value)
+ Sets the edition attribute for all subsequent connections created */
+PHP_FUNCTION(oci_set_edition)
+{
+#if ((OCI_MAJOR_VERSION > 11) || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION >= 2)))
+ char *edition;
+ long edition_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &edition, &edition_len) == FAILURE) {
+ return;
+ }
+
+ if (OCI_G(edition)) {
+ efree(OCI_G(edition));
+ OCI_G(edition) = NULL;
+ }
+
+ if (edition) {
+ OCI_G(edition) = (char *)safe_emalloc(edition_len+1, sizeof(text), 0);
+ memcpy(OCI_G(edition), edition, edition_len);
+ OCI_G(edition)[edition_len] = '\0';
+ }
+
+ RETURN_TRUE;
+#else
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
+ RETURN_FALSE;
+#endif
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_module_name(resource connection, string value)
+ Sets the module attribute on the connection */
+PHP_FUNCTION(oci_set_module_name)
+{
+#if (OCI_MAJOR_VERSION >= 10)
+ zval *z_connection;
+ php_oci_connection *connection;
+ char *module;
+ long module_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &module, &module_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 *) module, (ub4) module_len, (ub4) OCI_ATTR_MODULE, 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
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_action(resource connection, string value)
+ Sets the action attribute on the connection */
+PHP_FUNCTION(oci_set_action)
+{
+#if (OCI_MAJOR_VERSION >= 10)
+ zval *z_connection;
+ php_oci_connection *connection;
+ char *action;
+ long action_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &action, &action_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 *) action, (ub4) action_len, (ub4) OCI_ATTR_ACTION, 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
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_client_info(resource connection, string value)
+ Sets the client info attribute on the connection */
+PHP_FUNCTION(oci_set_client_info)
+{
+#if (OCI_MAJOR_VERSION >= 10)
+ zval *z_connection;
+ php_oci_connection *connection;
+ char *client_info;
+ long client_info_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_info, &client_info_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 *) client_info, (ub4) client_info_len, (ub4) OCI_ATTR_CLIENT_INFO, 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
+}
+/* }}} */
+
/* {{{ 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)