Skip to content

Commit

Permalink
pdo_oci: Add PDO_OCI_ATTR_ACTION and CLIENT_INFO
Browse files Browse the repository at this point in the history
Add the ability to set the action and client info on the database
session for PDO OCI using PDO attributes.
  • Loading branch information
camporter authored and cjbj committed Feb 11, 2019
1 parent 3b09123 commit a095472
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
32 changes: 32 additions & 0 deletions ext/pdo_oci/oci_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions ext/pdo_oci/php_pdo_oci_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

0 comments on commit a095472

Please sign in to comment.