Skip to content

Commit 9980a79

Browse files
committed
Fixed bug which threw an error when a pool is created with SYSDBA privilege (Issue #1657)
1 parent d909a3a commit 9980a79

File tree

11 files changed

+146
-49
lines changed

11 files changed

+146
-49
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# node-oracledb version 6.5.1-dev
2-
3-
**This release is under development and information may be incomplete**
1+
# node-oracledb version 6.5.1
42

53
The node-oracledb add-on for Node.js powers high performance Oracle Database
64
applications. Applications can be written in TypeScript, or directly in
75
JavaScript.
86

9-
Use node-oracledb 6.5.1-dev to connect Node.js 14.6, or later, to Oracle
7+
Use node-oracledb 6.5.1 to connect Node.js 14.6, or later, to Oracle
108
Database. Older versions of node-oracledb may work with older versions of
119
Node.js.
1210

doc/src/release_notes.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ For deprecated and desupported features, see :ref:`Deprecations and desupported
1010
node-oracledb `v6.5.1 <https://github.com/oracle/node-oracledb/compare/v6.5.0...v6.5.1>`__ (TBD)
1111
-------------------------------------------------------------------------------------------------------
1212

13+
Common Changes
14+
++++++++++++++
15+
16+
#) Test and documentation updates.
17+
1318
Thin Mode Changes
1419
+++++++++++++++++
1520
#) Fixed issue which throws the `ORA-00932` error, when the same SELECT SQL
@@ -19,6 +24,18 @@ Thin Mode Changes
1924
#) Fixed exponent check condition for out-of-bounds number.
2025
See `Issue #1659 <https://github.com/oracle/node-oracledb/issues/1659>`__.
2126

27+
#) Fixed bug which threw an ``ORA-28009`` error when a pool is created with
28+
SYSDBA privilege.
29+
See `Issue #1657 <https://github.com/oracle/node-oracledb/issues/1657>`__.
30+
31+
#) Added internal code change to improve network packet handling.
32+
33+
Thick Mode Changes
34+
+++++++++++++++++++
35+
36+
#) Fixed bug that ignored the ``privilege`` parameter, when it was passed in
37+
the ``pool.getConnection()`` call.
38+
2239
node-oracledb `v6.5.0 <https://github.com/oracle/node-oracledb/compare/v6.4.0...v6.5.0>`__ (2 May 2024)
2340
-------------------------------------------------------------------------------------------------------
2441

@@ -628,7 +645,6 @@ Thin Mode Changes
628645

629646
- Improved network packet handling.
630647

631-
632648
node-oracledb `v6.0.0 <https://github.com/oracle/node-oracledb/compare/v5.5.0...v6.0.0>`__ (24 May 2023)
633649
--------------------------------------------------------------------------------------------------------
634650

@@ -705,7 +721,6 @@ node-oracledb `v6.0.0 <https://github.com/oracle/node-oracledb/compare/v5.5.0...
705721

706722
#) Test and documentation improvements.
707723

708-
709724
node-oracledb `v5.5.0 <https://github.com/oracle/node-oracledb/compare/v5.4.0...v5.5.0>`__ (7 Sep 2022)
710725
-------------------------------------------------------------------------------------------------------
711726

lib/oracledb.js

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -118,33 +118,6 @@ function _initializeThinDriver() {
118118
require('./thin');
119119
}
120120

121-
//---------------------------------------------------------------------------
122-
// _isPrivilege()
123-
//
124-
// Returns a boolean indicating if the supplied value is a valid privilege.
125-
//---------------------------------------------------------------------------
126-
function _isPrivilege(value) {
127-
// Privileges are mutually exclusive and cannot be specified together
128-
// except SYSPRELIM, which cannot be specified alone, it is specified in a
129-
// combo with SYSOPER or SYSDBA. SYSPRELIM is used only for
130-
// startup/shutdown
131-
132-
// If SYSPRELIM specified, clear the bit
133-
if (value & constants.SYSPRELIM) {
134-
value = value ^ constants.SYSPRELIM;
135-
}
136-
137-
return (
138-
value === constants.SYSASM ||
139-
value === constants.SYSBACKUP ||
140-
value === constants.SYSDBA ||
141-
value === constants.SYSDG ||
142-
value === constants.SYSKM ||
143-
value === constants.SYSOPER ||
144-
value === constants.SYSRAC
145-
);
146-
}
147-
148121
//-----------------------------------------------------------------------------
149122
// _verifyOptions()
150123
//
@@ -331,6 +304,13 @@ async function _verifyOptions(options, inCreatePool) {
331304
outOptions.connectionIdPrefix = options.connectionIdPrefix;
332305
}
333306

307+
// privilege must be one of a set of named constants
308+
if (options.privilege !== undefined) {
309+
errors.assertParamPropValue(nodbUtil.isPrivilege(options.privilege), 1,
310+
"privilege");
311+
outOptions.privilege = options.privilege;
312+
}
313+
334314
// check pool specific options
335315
if (inCreatePool) {
336316

@@ -444,13 +424,6 @@ async function _verifyOptions(options, inCreatePool) {
444424
outOptions.newPassword = options.newPassword;
445425
}
446426

447-
// privilege must be one of a set of named constants
448-
if (options.privilege !== undefined) {
449-
errors.assertParamPropValue(_isPrivilege(options.privilege), 1,
450-
"privilege");
451-
outOptions.privilege = options.privilege;
452-
}
453-
454427
// shardingKey must be an array of values
455428
if (options.shardingKey !== undefined) {
456429
const value = options.shardingKey;

lib/pool.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ class Pool extends EventEmitter {
238238
outOptions.superShardingKey = options.superShardingKey;
239239
}
240240

241+
// privilege must be one of a set of named constants
242+
if (options.privilege !== undefined) {
243+
errors.assertParamPropValue(nodbUtil.isPrivilege(options.privilege), 1,
244+
"privilege");
245+
outOptions.privilege = options.privilege;
246+
}
247+
241248
return outOptions;
242249
}
243250

lib/util.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const errors = require('./errors.js');
3131
const process = require('process');
3232
const util = require('util');
3333
const types = require('./types.js');
34+
const constants = require('./constants.js');
3435

3536
// node-oracledb version number
3637
let packageJSON;
@@ -224,6 +225,32 @@ function isObjectOrArray(value) {
224225
return (value !== null && typeof value === 'object') || Array.isArray(value);
225226
}
226227

228+
//---------------------------------------------------------------------------
229+
// isPrivilege()
230+
//
231+
// Returns a boolean indicating if the supplied value is a valid privilege.
232+
//---------------------------------------------------------------------------
233+
function isPrivilege(value) {
234+
// Privileges are mutually exclusive and cannot be specified together
235+
// except SYSPRELIM, which cannot be specified alone, it is specified in a
236+
// combo with SYSOPER or SYSDBA. SYSPRELIM is used only for
237+
// startup/shutdown
238+
239+
// If SYSPRELIM specified, clear the bit
240+
if (value & constants.SYSPRELIM) {
241+
value = value ^ constants.SYSPRELIM;
242+
}
243+
return (
244+
value === constants.SYSASM ||
245+
value === constants.SYSBACKUP ||
246+
value === constants.SYSDBA ||
247+
value === constants.SYSDG ||
248+
value === constants.SYSKM ||
249+
value === constants.SYSOPER ||
250+
value === constants.SYSRAC
251+
);
252+
}
253+
227254
function isShardingKey(value) {
228255
if (!Array.isArray(value))
229256
return false;
@@ -369,6 +396,7 @@ module.exports = {
369396
isArrayOfStrings,
370397
isObject,
371398
isObjectOrArray,
399+
isPrivilege,
372400
isShardingKey,
373401
isSodaDocument,
374402
isTokenExpired,

lib/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ module.exports = {
3232
VERSION_MAJOR: 6,
3333
VERSION_MINOR: 5,
3434
VERSION_PATCH: 1,
35-
VERSION_SUFFIX: '-dev'
35+
VERSION_SUFFIX: ''
3636
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oracledb",
3-
"version": "6.5.1-dev",
3+
"version": "6.5.1",
44
"description": "A Node.js module for Oracle Database access from JavaScript and TypeScript",
55
"license": "(Apache-2.0 OR UPL-1.0)",
66
"homepage": "http://oracle.github.io/node-oracledb/",

src/njsPool.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ NJS_NAPI_METHOD_IMPL_ASYNC(njsPool_getConnection, 1, NULL)
352352
if (!njsUtils_getNamedPropertyString(env, args[0], "connectionClass",
353353
&baton->connectionClass, &baton->connectionClassLength))
354354
return false;
355+
if (!njsUtils_getNamedPropertyUnsignedInt(env, args[0], "privilege",
356+
&baton->privilege))
357+
return false;
355358
if (!njsUtils_getNamedPropertyString(env, args[0], "user", &baton->user,
356359
&baton->userLength))
357360
return false;
@@ -389,6 +392,8 @@ static bool njsPool_getConnectionAsync(njsBaton *baton)
389392
// populate connection creation parameters
390393
if (dpiContext_initConnCreateParams(baton->globals->context, &params) < 0)
391394
return njsBaton_setErrorDPI(baton);
395+
if (baton->privilege)
396+
params.authMode = (dpiAuthMode) baton->privilege;
392397
params.matchAnyTag = baton->matchAnyTag;
393398
params.connectionClass = baton->connectionClass;
394399
params.connectionClassLength = (uint32_t) baton->connectionClassLength;

test/connection.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,12 @@ describe('1. connection.js', function() {
353353
);
354354
});
355355

356-
it('1.7.5 gets ignored when acquiring a connection from Pool', async function() {
356+
it('1.7.5 Negative - throws error, when invalid privilege is provided for creating a Pool', async function() {
357357
const credential = {...dbConfig, privilege: null, poolMin: 1};
358-
359-
const pool = await oracledb.createPool(credential);
360-
const conn = await pool.getConnection();
361-
await conn.release();
362-
await pool.close(0);
358+
await assert.rejects(
359+
async () => await oracledb.createPool(credential),
360+
/NJS-007:/
361+
);
363362
});
364363

365364
it('1.7.6 negative test case SYSPRELIM & SYSASM', async function() {

test/list.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Overview of node-oracledb functional tests
2323
1.7.2 Negative - invalid type, a String
2424
1.7.3 Negative value - random constants
2525
1.7.4 Negative value - NaN
26-
1.7.5 gets ignored when acquiring a connection from Pool
26+
1.7.5 Negative - throws error, when invalid privilege is provided for creating a Pool
2727
1.7.6 negative test case SYSPRELIM & SYSASM
2828
1.8 Ping method
2929
1.8.1 ping() checks the connection is usable
@@ -110,6 +110,13 @@ Overview of node-oracledb functional tests
110110
2.16.5 events override to false
111111
2.16.6 externalAuth override to false
112112
2.16.7 externalAuth override to true
113+
2.17 Check execute same/different query with new/released session from pool
114+
2.17.1 same query execution from new and released session
115+
2.17.2 different query execution from new and released session
116+
2.18 pool stats
117+
2.18.1 driver mode in pool stats
118+
2.19 DBA and Non-DBA user login with SYSDBA privilege
119+
2.19.1 DBA user with SYSDBA privilege
113120

114121
3. examples.js
115122
3.1 connect.js

0 commit comments

Comments
 (0)