oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.25k stars 1.07k forks source link

Setting v$session.osuser like JDBC driver #1163

Closed kenime closed 4 years ago

kenime commented 4 years ago

In JDBC driver we can set some connection properties regarding v$session (e.g. v$session.osuser). Is it available in this package?

virt888 commented 4 years ago

In JDBC driver we can set some connection properties regarding v$session (e.g. v$session.osuser). Is it available in this package?

I have this issue also, anyone can help please...

cjbj commented 4 years ago

Can you explain what the business issue is? At a guess, you are trying to run a mixed language environment and have some monitoring etc dependent on v$session?

The connection properties you can set in node-oracledb are shown in the documentation: https://oracle.github.io/node-oracledb/doc/api.html#connectionproperties The one you would want to think about using isconnection.clientId.

I've not seen/known/needed anyway to override osuser in Oracle's C API, so there is no API to do this in node-oracledb.

cjbj commented 4 years ago

@kenime @virt888 can you explain what the business issue and requirements are?

kenime commented 4 years ago

It is mainly for monitoring and reporting purpose. As my company's reporting system will aggregate the user and program in v$session, our java based program will configure these 2 fields as meaningful names via the JDBC driver.

cjbj commented 4 years ago

@kenime request noted. (Though it sounds like a hack to alter those two particular attributes).

Use the available settings in node-oracledb and query v$session and v$session_connect_info. I have an open task to natively support setting CLIENT_INFO (i.e. OCI_ATTR_CLIENT_INFO) which would be the better place to identify your application. Currently you can set it with an explicit round trip call to DBMS_APPLICATION_INFO.SET_CLIENT_INFO()

sosoba commented 4 years ago

You can encapsulating Node inside software container ex. Docker and started it on desired user.

cjbj commented 4 years ago

We'll add attributes for setting CLIENT_INFO and DBOP in node-oracledb 4.1.

For other changes, can you work with Oracle Support to request changes to the Oracle Call Interface layer?

sosoba commented 4 years ago

We'll add attributes for setting CLIENT_INFO and DBOP in node-oracledb 4.1.

Is there a way to expose info fileds length (for example oracledb.CLIENT_INFO_LENGTH) as part of this change?

cjbj commented 4 years ago

node-oracledb is simply passing a string down, see dpiConn__setAttributeText(). These internal calls are effectively like DBMS_APPLICATION_INFO.SET_CLIENT_INFO calls. There is no initial lookup to find max lengths - that would cost a round trip.

cjbj commented 4 years ago

To follow up, node-oracledb 4.1 is out and has the new clientInfo and dbOp properties (in addition to the previous end-to-end tracing properties.