summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Porter <porterca@us.ibm.com>2019-01-23 20:14:00 -0600
committerChristopher Jones <christopher.jones@oracle.com>2019-02-11 16:10:47 +1100
commita095472e620a5f73c8f7bff8b6e83a559ec2511b (patch)
treed9d9c56ecf608619d2e13a470e617601f3659d7c
parent3b09123de3de656d195dd31e84668edffadcaaba (diff)
downloadphp-git-a095472e620a5f73c8f7bff8b6e83a559ec2511b.tar.gz
pdo_oci: Add PDO_OCI_ATTR_ACTION and CLIENT_INFO
Add the ability to set the action and client info on the database session for PDO OCI using PDO attributes.
-rw-r--r--ext/pdo_oci/oci_driver.c32
-rw-r--r--ext/pdo_oci/php_pdo_oci_int.h6
2 files changed, 38 insertions, 0 deletions
diff --git a/ext/pdo_oci/oci_driver.c b/ext/pdo_oci/oci_driver.c
index 292363ff89..8dddaef597 100644
--- a/ext/pdo_oci/oci_driver.c
+++ b/ext/pdo_oci/oci_driver.c
@@ -454,6 +454,38 @@ static int oci_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val) /
} else if (attr == PDO_ATTR_PREFETCH) {
H->prefetch = pdo_oci_sanitize_prefetch(lval);
return 1;
+ } else if (attr == PDO_OCI_ATTR_ACTION) {
+#if (OCI_MAJOR_VERSION >= 10)
+ zend_string *action = zval_get_string(val);
+
+ H->last_err = OCIAttrSet(H->session, OCI_HTYPE_SESSION,
+ (dvoid *) ZSTR_VAL(action), (ub4) ZSTR_LEN(action),
+ OCI_ATTR_ACTION, H->err);
+ if (H->last_err) {
+ oci_drv_error("OCIAttrSet: OCI_ATTR_ACTION");
+ return 0;
+ }
+ return 1;
+#else
+ oci_drv_error("Unsupported attribute type");
+ return 0;
+#endif
+ } else if (attr == PDO_OCI_ATTR_CLIENT_INFO) {
+#if (OCI_MAJOR_VERSION >= 10)
+ zend_string *client_info = zval_get_string(val);
+
+ H->last_err = OCIAttrSet(H->session, OCI_HTYPE_SESSION,
+ (dvoid *) ZSTR_VAL(client_info), (ub4) ZSTR_LEN(client_info),
+ OCI_ATTR_CLIENT_INFO, H->err);
+ if (H->last_err) {
+ oci_drv_error("OCIAttrSet: OCI_ATTR_CLIENT_INFO");
+ return 0;
+ }
+ return 1;
+#else
+ oci_drv_error("Unsupported attribute type");
+ return 0;
+#endif
} else {
return 0;
}
diff --git a/ext/pdo_oci/php_pdo_oci_int.h b/ext/pdo_oci/php_pdo_oci_int.h
index 340348f100..05ad6597e7 100644
--- a/ext/pdo_oci/php_pdo_oci_int.h
+++ b/ext/pdo_oci/php_pdo_oci_int.h
@@ -100,3 +100,9 @@ extern struct pdo_stmt_methods oci_stmt_methods;
/* Arbitrary assumed row length for prefetch memory limit calcuation */
#define PDO_OCI_PREFETCH_ROWSIZE 1024
+
+
+enum {
+ PDO_OCI_ATTR_ACTION = PDO_ATTR_DRIVER_SPECIFIC,
+ PDO_OCI_ATTR_CLIENT_INFO,
+}; \ No newline at end of file