Skip to content

Commit a095472

Browse files
camportercjbj
authored andcommitted
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.
1 parent 3b09123 commit a095472

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

ext/pdo_oci/oci_driver.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,38 @@ static int oci_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val) /
454454
} else if (attr == PDO_ATTR_PREFETCH) {
455455
H->prefetch = pdo_oci_sanitize_prefetch(lval);
456456
return 1;
457+
} else if (attr == PDO_OCI_ATTR_ACTION) {
458+
#if (OCI_MAJOR_VERSION >= 10)
459+
zend_string *action = zval_get_string(val);
460+
461+
H->last_err = OCIAttrSet(H->session, OCI_HTYPE_SESSION,
462+
(dvoid *) ZSTR_VAL(action), (ub4) ZSTR_LEN(action),
463+
OCI_ATTR_ACTION, H->err);
464+
if (H->last_err) {
465+
oci_drv_error("OCIAttrSet: OCI_ATTR_ACTION");
466+
return 0;
467+
}
468+
return 1;
469+
#else
470+
oci_drv_error("Unsupported attribute type");
471+
return 0;
472+
#endif
473+
} else if (attr == PDO_OCI_ATTR_CLIENT_INFO) {
474+
#if (OCI_MAJOR_VERSION >= 10)
475+
zend_string *client_info = zval_get_string(val);
476+
477+
H->last_err = OCIAttrSet(H->session, OCI_HTYPE_SESSION,
478+
(dvoid *) ZSTR_VAL(client_info), (ub4) ZSTR_LEN(client_info),
479+
OCI_ATTR_CLIENT_INFO, H->err);
480+
if (H->last_err) {
481+
oci_drv_error("OCIAttrSet: OCI_ATTR_CLIENT_INFO");
482+
return 0;
483+
}
484+
return 1;
485+
#else
486+
oci_drv_error("Unsupported attribute type");
487+
return 0;
488+
#endif
457489
} else {
458490
return 0;
459491
}

ext/pdo_oci/php_pdo_oci_int.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,9 @@ extern struct pdo_stmt_methods oci_stmt_methods;
100100

101101
/* Arbitrary assumed row length for prefetch memory limit calcuation */
102102
#define PDO_OCI_PREFETCH_ROWSIZE 1024
103+
104+
105+
enum {
106+
PDO_OCI_ATTR_ACTION = PDO_ATTR_DRIVER_SPECIFIC,
107+
PDO_OCI_ATTR_CLIENT_INFO,
108+
};

0 commit comments

Comments
 (0)