From: Cameron Porter Date: Thu, 24 Jan 2019 02:14:00 +0000 (-0600) Subject: pdo_oci: Add PDO_OCI_ATTR_ACTION and CLIENT_INFO X-Git-Tag: php-7.2.16RC1~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a095472e620a5f73c8f7bff8b6e83a559ec2511b;p=php 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. --- 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