com php-src: pdo_oci: Add PDO_OCI_ATTR_ACTION a nd CLIENT_INFO: ext/pdo_oci/oci_driver.c ext/pd o_oci/php_pdo_oci_int.h
| From: | Christopher Jones | Date: | Mon, 11 Feb 2019 05:10:47 +0000 |
| Subject: | com php-src: pdo_oci: Add PDO_OCI_ATTR_ACTION a nd CLIENT_INFO: ext/pdo_oci/oci_driver.c ext/pd o_oci/php_pdo_oci_int.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104527@lists.php.net to get a copy of this message | ||
Commit: a095472e620a5f73c8f7bff8b6e83a559ec2511b
Author: Cameron Porter <porterca@us.ibm.com> Wed, 23 Jan 2019 20:14:00 -0600
Committer: Christopher Jones <christopher.jones@oracle.com> Mon, 11 Feb 2019 16:10:47
+1100
Parents: 3b09123de3de656d195dd31e84668edffadcaaba
Branches: PHP-7.2 PHP-7.3 PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a095472e620a5f73c8f7bff8b6e83a559ec2511b
Log:
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.
Changed paths:
M ext/pdo_oci/oci_driver.c
M ext/pdo_oci/php_pdo_oci_int.h
Diff:
diff --git a/ext/pdo_oci/oci_driver.c b/ext/pdo_oci/oci_driver.c
index 292363f..8dddaef 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 340348f...05ad659 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