Skip to content

Commit 14654e5

Browse files
committed
Added oracledb.oracleClientVersion and connection.oracleServerVersion
1 parent ad3838f commit 14654e5

17 files changed

+300
-45
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## node-oracledb v1.3.0 (DD Mon YYYY)
44

5+
- Added oracledb.oracleClientVersion property giving the version of the Oracle
6+
client library, and connection.oracleServerVersion property giving the Oracle
7+
Database Server version.
8+
59
- BIND_IN is default when not specified.
610

711
- Fixed 11.2.0.4 DB-specific NULL output with DML RETURNING when string value is of size 4k.

binding.gyp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"src/dpi/src/dpiPoolImpl.cpp",
1919
"src/dpi/src/dpiStmtImpl.cpp",
2020
"src/dpi/src/dpiUtils.cpp",
21-
"src/dpi/src/dpiLob.cpp"
21+
"src/dpi/src/dpiLob.cpp",
22+
"src/dpi/src/dpiCommon.cpp"
2223
],
2324
"conditions" : [
2425
[

doc/api.md

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ limitations under the License.
4242
- 3.2.4 [fetchAsString](#propdbfetchasstring)
4343
- 3.2.5 [lobPrefetchSize](#propdblobprefetchsize)
4444
- 3.2.6 [maxRows](#propdbmaxrows)
45-
- 3.2.7 [outFormat](#propdboutformat)
46-
- 3.2.8 [poolIncrement](#propdbpoolincrement)
47-
- 3.2.9 [poolMax](#propdbpoolmax)
48-
- 3.2.10 [poolMin](#propdbpoolmin)
49-
- 3.2.11 [poolTimeout](#propdbpooltimeout)
50-
- 3.2.12 [prefetchRows](#propdbprefetchrows)
51-
- 3.2.13 [stmtCacheSize](#propdbstmtcachesize)
52-
- 3.2.14 [version](#propdbversion)
45+
- 3.2.7 [oracleClientVersion](#propdboracleClientVersion)
46+
- 3.2.8 [outFormat](#propdboutformat)
47+
- 3.2.9 [poolIncrement](#propdbpoolincrement)
48+
- 3.2.10 [poolMax](#propdbpoolmax)
49+
- 3.2.11 [poolMin](#propdbpoolmin)
50+
- 3.2.12 [poolTimeout](#propdbpooltimeout)
51+
- 3.2.13 [prefetchRows](#propdbprefetchrows)
52+
- 3.2.14 [stmtCacheSize](#propdbstmtcachesize)
53+
- 3.2.15 [version](#propdbversion)
5354
- 3.3 [Oracledb Methods](#oracledbmethods)
5455
- 3.3.1 [createPool()](#createpool)
5556
- 3.3.2 [getConnection()](#getconnectiondb)
@@ -58,7 +59,8 @@ limitations under the License.
5859
- 4.1.1 [action](#propconnaction)
5960
- 4.1.2 [clientId](#propconnclientid)
6061
- 4.1.3 [module](#propconnmodule)
61-
- 4.1.4 [stmtCacheSize](#propconnstmtcachesize)
62+
- 4.1.4 [oracleServerVersion](#propconnoracleserverversion)
63+
- 4.1.5 [stmtCacheSize](#propconnstmtcachesize)
6264
- 4.2 [Connection Methods](#connectionmethods)
6365
- 4.2.1 [break()](#break)
6466
- 4.2.2 [commit()](#commit)
@@ -504,7 +506,23 @@ var oracledb = require('oracledb');
504506
oracledb.lobPrefetchSize = 16384;
505507
```
506508

507-
#### <a name="propdboutformat"></a> 3.2.7 outFormat
509+
#### <a name="propdboracleClientVersion"></a> 3.2.7 oracleClientVersion
510+
511+
```
512+
readonly Number oracleClientVersion
513+
```
514+
515+
This readonly property gives a numeric representation of the Oracle client library version.
516+
For version *a.b.c.d.e*, this property gives the number: `(100000000 * a) + (1000000 * b) + (10000 * c) + (100 * d) + e`
517+
518+
##### Example
519+
520+
```javascript
521+
var oracledb = require('oracledb');
522+
console.log("Oracle client library version number is " + oracledb.oracleClientVersion);
523+
```
524+
525+
#### <a name="propdboutformat"></a> 3.2.8 outFormat
508526

509527
```
510528
Number outFormat
@@ -534,7 +552,7 @@ var oracledb = require('oracledb');
534552
oracledb.outFormat = oracledb.ARRAY;
535553
```
536554

537-
#### <a name="propdbpoolincrement"></a> 3.2.8 poolIncrement
555+
#### <a name="propdbpoolincrement"></a> 3.2.9 poolIncrement
538556

539557
```
540558
Number poolIncrement
@@ -554,7 +572,7 @@ var oracledb = require('oracledb');
554572
oracledb.poolIncrement = 1;
555573
```
556574

557-
#### <a name="propdbpoolmax"></a> 3.2.9 poolMax
575+
#### <a name="propdbpoolmax"></a> 3.2.10 poolMax
558576

559577
```
560578
Number poolMax
@@ -573,7 +591,7 @@ var oracledb = require('oracledb');
573591
oracledb.poolMax = 4;
574592
```
575593

576-
#### <a name="propdbpoolmin"></a> 3.2.10 poolMin
594+
#### <a name="propdbpoolmin"></a> 3.2.11 poolMin
577595

578596
```
579597
Number poolMin
@@ -593,7 +611,7 @@ var oracledb = require('oracledb');
593611
oracledb.poolMin = 0;
594612
```
595613

596-
#### <a name="propdbpooltimeout"></a> 3.2.11 poolTimeout
614+
#### <a name="propdbpooltimeout"></a> 3.2.12 poolTimeout
597615

598616
```
599617
Number poolTimeout
@@ -615,7 +633,7 @@ var oracledb = require('oracledb');
615633
oracledb.poolTimeout = 60;
616634
```
617635

618-
#### <a name="propdbprefetchrows"></a> 3.2.12 prefetchRows
636+
#### <a name="propdbprefetchrows"></a> 3.2.13 prefetchRows
619637

620638
```
621639
Number prefetchRows
@@ -645,7 +663,7 @@ var oracledb = require('oracledb');
645663
oracledb.prefetchRows = 100;
646664
```
647665

648-
#### <a name="propdbstmtcachesize"></a> 3.2.13 stmtCacheSize
666+
#### <a name="propdbstmtcachesize"></a> 3.2.14 stmtCacheSize
649667

650668
```
651669
Number stmtCacheSize
@@ -672,12 +690,12 @@ var oracledb = require('oracledb');
672690
oracledb.stmtCacheSize = 30;
673691
```
674692

675-
#### <a name="propdbversion"></a> 3.2.14 version
693+
#### <a name="propdbversion"></a> 3.2.15 version
676694
```
677695
readonly Number version
678696
```
679697

680-
This readonly property gives a numeric representation of the node-oracledb's version.
698+
This readonly property gives a numeric representation of the node-oracledb version.
681699
For version *x.y.z*, this property gives the number: `(10000 * x) + (100 * y) + z`
682700

683701
##### Example
@@ -994,7 +1012,16 @@ This is a write-only property. Displaying a Connection object will
9941012
show a value of `null` for this attribute. See
9951013
[End-to-end Tracing, Mid-tier Authentication, and Auditing](#endtoend).
9961014

997-
#### <a name="propconnstmtcachesize"></a> 4.1.4 stmtCacheSize
1015+
#### <a name="propconnoracleserverversion"></a> 4.1.4 oracleServerVersion
1016+
1017+
```
1018+
readonly Number oracleServerVersion
1019+
```
1020+
1021+
This readonly property gives a numeric representation of the Oracle database version.
1022+
For version *a.b.c.d.e*, this property gives the number: `(100000000 * a) + (1000000 * b) + (10000 * c) + (100 * d) + e`
1023+
1024+
#### <a name="propconnstmtcachesize"></a> 4.1.5 stmtCacheSize
9981025

9991026
```
10001027
readonly Number stmtCacheSize

examples/connect.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ oracledb.getConnection(
3939
console.error(err.message);
4040
return;
4141
}
42-
4342
console.log('Connection was successful!');
4443

4544
connection.release(

examples/version.js

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,51 @@
1919
* version.js
2020
*
2121
* DESCRIPTION
22-
* Shows the oracledb version attribute
22+
* Shows the oracledb version attributes
2323
*
2424
*****************************************************************************/
2525

2626
var oracledb = require('oracledb');
27+
var dbConfig = require('./dbconfig.js');
2728

28-
console.log("Driver version number is " + oracledb.version);
29+
var addonVer, clientVer, serverVer;
30+
var major, minor, update, port, portUpdate;
2931

30-
major = Math.floor(oracledb.version/10000);
31-
minor = Math.floor(oracledb.version/100) % 100;
32-
patch = oracledb.version % 100;
33-
console.log("Driver version text is " + major + "." + minor + "." + patch);
32+
addonVer = oracledb.version
33+
major = Math.floor(addonVer / 10000);
34+
minor = Math.floor(addonVer / 100) % 100;
35+
update = addonVer % 100;
36+
console.log("Node-oracledb version: " + addonVer);
37+
console.log("Node-oracledb text format: " + major + "." + minor + "." + update);
38+
39+
clientVer = oracledb.oracleClientVersion;
40+
major = Math.floor (clientVer / 100000000);
41+
minor = Math.floor (clientVer / 1000000) % 100 ;
42+
update = Math.floor (clientVer / 10000) % 100 ;
43+
port = Math.floor (clientVer / 100) % 100 ;
44+
portUpdate = clientVer % 100 ;
45+
console.log("Oracle Client library version: " +clientVer);
46+
console.log("Oracle Client library text format: " + major + "." + minor + "." + update + "." + port + "." + portUpdate);
47+
48+
oracledb.getConnection(
49+
{
50+
user : dbConfig.user,
51+
password : dbConfig.password,
52+
connectString : dbConfig.connectString
53+
},
54+
function(err, connection)
55+
{
56+
if (err) {
57+
console.error(err.message);
58+
return;
59+
}
60+
61+
serverVer = connection.oracleServerVersion;
62+
major = Math.floor (serverVer / 100000000);
63+
minor = Math.floor (serverVer / 1000000) % 100 ;
64+
update = Math.floor (serverVer / 10000) % 100 ;
65+
port = Math.floor (serverVer / 100) % 100 ;
66+
portUpdate = serverVer % 100 ;
67+
console.log ("Oracle Database version: " + serverVer);
68+
console.log("Oracle Database text format: " + major + "." + minor + "." + update + "." + port + "." + portUpdate);
69+
});

src/dpi/include/dpiCommon.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ enum DescriptorType
5656
struct DpiHandle;
5757
struct Descriptor;
5858

59+
60+
/* Utiltiy class containing common functions */
61+
class Common
62+
{
63+
public:
64+
// To obtain the Oracle Client Library Version
65+
static void clientVersion (int *majorv, int *minorv, int *patchv,
66+
int *portv, int *portUpdv );
67+
};
68+
69+
70+
5971
/*----------------------------------------------------------------------------
6072
PUBLIC METHODS
6173
----------------------------------------------------------------------------*/

src/dpi/include/dpiConn.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class Conn
8888

8989
virtual DpiHandle *getErrh () = 0;
9090

91+
virtual unsigned int getServerVersion () = 0;
92+
9193
protected:
9294
// clients cannot do new and delete
9395
Conn(){};

src/dpi/include/dpiEnv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class Env
8686
virtual void externalAuth(bool externalAuth) = 0;
8787
virtual bool externalAuth() const = 0;
8888

89+
8990
// methods
9091
virtual SPool * createPool(const string &user, const string &password,
9192
const string &connString,

src/dpi/include/dpiException.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ enum DpiError // error type
5454
DpiOciInvalidHandle,
5555
// "Invalid OCI Handle/Descriptor or invalid parameter for OCI handle/descriptor allocation call"
5656
DpiErrMemAllocFail, // "Memory allocatio failed"
57+
DpiErrNullValue, // "Unexpected NULL value"
5758
};
5859

5960

src/dpi/src/dpiConnImpl.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
#define DPI_CONNERR_ORA_NOT_LOGGED_ON 1012
5757
#define DPI_CONNERR_MAX_IDLE_TIMEOUT 2396
5858

59+
#define DPI_MAX_VERSION_SIZE 512
60+
5961
using namespace std;
6062

6163

@@ -130,7 +132,8 @@ ConnImpl::ConnImpl(PoolImpl *pool, OCIEnv *envh, bool externalAuth,
130132

131133
try : env_(NULL), pool_(pool),
132134
envh_(envh), errh_(NULL), auth_(NULL),
133-
svch_(NULL), sessh_(NULL), hasTxn_(false), srvh_(NULL), dropConn_(false)
135+
svch_(NULL), sessh_(NULL), hasTxn_(false), srvh_(NULL),
136+
dropConn_(false)
134137
{
135138
this->initConnImpl ( true, externalAuth, connClass, poolName, poolNameLen,
136139
"", "" );
@@ -525,6 +528,31 @@ void ConnImpl::setErrState ( int errNum )
525528
}
526529

527530

531+
/*****************************************************************************/
532+
/*
533+
DESCRIPTION
534+
To obtain the Oracle Database Server version
535+
536+
PARAMETERS
537+
-None-
538+
539+
RETURNS
540+
version
541+
*/
542+
unsigned int ConnImpl::getServerVersion ()
543+
{
544+
ub4 oraServerVer = 0;
545+
char verbuf[ DPI_MAX_VERSION_SIZE ];
546+
547+
ociCall ( OCIServerRelease ( svch_, errh_, (OraText *)verbuf,
548+
(ub4) sizeof ( verbuf ),
549+
(ub1) OCI_HTYPE_SVCCTX, &oraServerVer ),
550+
errh_ ) ;
551+
552+
return oraServerVer;
553+
}
554+
555+
528556
/*---------------------------------------------------------------------------
529557
PRIVATE METHODS
530558
---------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)