diff --git a/lib/errors.js b/lib/errors.js index 0ae3385d..1dc358a9 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -103,6 +103,7 @@ const ERR_TOKEN_CALLBACK_DUP = 88; const ERR_NOT_IMPLEMENTED = 89; const ERR_INIT_ORACLE_CLIENT_ARGS = 90; const ERR_MISSING_FILE = 91; +const ERR_INVALID_NUMBER_OF_CONNECTIONS = 92; const messages = new Map(); messages.set(ERR_INVALID_CONNECTION, @@ -256,6 +257,8 @@ messages.set(ERR_INIT_ORACLE_CLIENT_ARGS, 'initOracleClient() was already called with different arguments!'); messages.set(ERR_MISSING_FILE, 'file %s is missing'); +messages.set(ERR_INVALID_NUMBER_OF_CONNECTIONS, + 'poolMax [%d] must be greater than or equal to poolMin [%d]'); //----------------------------------------------------------------------------- // assert() @@ -487,6 +490,7 @@ module.exports = { ERR_NOT_IMPLEMENTED, ERR_INIT_ORACLE_CLIENT_ARGS, ERR_MISSING_FILE, + ERR_INVALID_NUMBER_OF_CONNECTIONS, assert, assertArgCount, assertParamPropBool, diff --git a/lib/oracledb.js b/lib/oracledb.js index 80bfe2f7..7808ec45 100644 --- a/lib/oracledb.js +++ b/lib/oracledb.js @@ -185,10 +185,10 @@ async function _verifyOptions(options, inCreatePool) { // check pool specific options if (inCreatePool) { - // poolMax must be an integer >= 0 + // poolMax must be an integer > 0 if (options.poolMax !== undefined) { errors.assertParamPropValue(Number.isInteger(options.poolMax) && - options.poolMax >= 0, 1, "poolMax"); + options.poolMax > 0, 1, "poolMax"); outOptions.poolMax = options.poolMax; } @@ -402,6 +402,12 @@ async function createPool(options) { "queueMax", "queueTimeout"); + // poolMax must be greater than or equal to poolMin + if (options.poolMin > options.poolMax) { + errors.throwErr(errors.ERR_INVALID_NUMBER_OF_CONNECTIONS, options.poolMax, + options.poolMin); + } + // initialize the Oracle client, if necessary if (_initOracleClientArgs === undefined) { initOracleClient(); diff --git a/test/pool.js b/test/pool.js index 62736e21..280009eb 100644 --- a/test/pool.js +++ b/test/pool.js @@ -138,7 +138,7 @@ describe('2. pool.js', function() { }, function(err, pool) { should.exist(err); - (err.message).should.startWith('ORA-24413:'); + (err.message).should.startWith('NJS-092:'); should.not.exist(pool); done(); @@ -213,7 +213,7 @@ describe('2. pool.js', function() { }, function(err, pool) { should.exist(err); - (err.message).should.startWith('ORA-24413:'); + (err.message).should.startWith('NJS-007:'); should.not.exist(pool); done(); @@ -1046,8 +1046,7 @@ describe('2. pool.js', function() { }, function(err, pool) { should.exist(err); - (err.message).should.startWith('ORA-24413: '); - // ORA-24413: Invalid number of sessions specified + (err.message).should.startWith('NJS-092:'); should.not.exist(pool); done(); } diff --git a/test/poolReconfigure.js b/test/poolReconfigure.js index 5d62d08f..dccd6904 100644 --- a/test/poolReconfigure.js +++ b/test/poolReconfigure.js @@ -1178,7 +1178,7 @@ describe('255. poolReconfigure.js', function() { try { await pool.reconfigure({poolMax: 0}); } catch (err) { - (err.message).startsWith ('ORA-24413'); + (err.message).startsWith ('NJS-007'); } try {