UNPKG

42.9 kBJavaScriptView Raw
1// Copyright (c) 2015, 2023, Oracle and/or its affiliates.
2
3//-----------------------------------------------------------------------------
4//
5// This software is dual-licensed to you under the Universal Permissive License
6// (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
7// 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
8// either license.
9//
10// If you elect to accept the software under the Apache License, Version 2.0,
11// the following applies:
12//
13// Licensed under the Apache License, Version 2.0 (the "License");
14// you may not use this file except in compliance with the License.
15// You may obtain a copy of the License at
16//
17// https://www.apache.org/licenses/LICENSE-2.0
18//
19// Unless required by applicable law or agreed to in writing, software
20// distributed under the License is distributed on an "AS IS" BASIS,
21// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22// See the License for the specific language governing permissions and
23// limitations under the License.
24//
25//-----------------------------------------------------------------------------
26
27'use strict';
28
29const constants = require('./constants.js');
30const nodbUtil = require('./util.js');
31const errors = require('./errors.js');
32const types = require('./types.js');
33const impl = require('./impl');
34const process = require('process');
35const util = require('util');
36
37// This version of node-oracledb works with Node.js 14.6 or later.
38// Note: the checked version is the minimum required for Node-API
39// compatibility. When new Node.js versions are released, older Node.js
40// versions are dropped from the node-oracledb test plan.
41//
42// Keep this code in sync with package/install.js
43const vs = process.version.substring(1).split(".").map(Number);
44errors.assert(vs[0] > 14 || (vs[0] === 14 && vs[1] >= 6),
45 errors.ERR_NODE_TOO_OLD, nodbUtil.PACKAGE_JSON_VERSION, "14.6");
46
47const AqDeqOptions = require('./aqDeqOptions.js');
48const AqEnqOptions = require('./aqEnqOptions.js');
49const AqMessage = require('./aqMessage.js');
50const AqQueue = require('./aqQueue.js');
51const future = require('./future.js');
52const BaseDbObject = require('./dbObject.js');
53const Connection = require('./connection.js');
54const Lob = require('./lob.js');
55const Pool = require('./pool.js');
56const PoolStatistics = require('./poolStatistics.js');
57const ResultSet = require('./resultset.js');
58const settings = require('./settings.js');
59const SodaDatabase = require('./sodaDatabase.js');
60const SodaCollection = require('./sodaCollection.js');
61const SodaDocCursor = require('./sodaDocCursor.js');
62const SodaDocument = require('./sodaDocument.js');
63const SodaOperation = require('./sodaOperation.js');
64
65const poolCache = {};
66const tempUsedPoolAliases = {};
67const defaultPoolAlias = 'default';
68
69// save arguments for call to initOracleClient()
70let _initOracleClientArgs;
71
72// Load the Oracledb binary
73function _initCLib(options) {
74 /*global __non_webpack_require__*/ // quieten eslint
75 const requireBinary = (typeof __non_webpack_require__ === 'function') ? __non_webpack_require__ : require; // See Issue 1156
76 const binaryLocations = [
77 '../' + nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE, // pre-built binary
78 '../' + nodbUtil.RELEASE_DIR + '/' + nodbUtil.BUILD_FILE, // binary built from source
79 '../build/Debug/' + nodbUtil.BUILD_FILE, // debug binary
80 // Paths for Webpack.
81 // Note: to use node-oracledb Thick mode, you will need a Webpack copy plugin to
82 // copy 'node_modules/oracledb/build/' to the output directory,
83 // see https://github.com/oracle/node-oracledb/issues/1156
84 // If you want to use only node-oracledb Thin mode, a copy plugin is not needed.
85 './node_modules/oracledb/' + nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE,
86 './node_modules/oracledb/' + nodbUtil.RELEASE_DIR + '/' + nodbUtil.BUILD_FILE
87 ];
88
89 if (options.binaryDir !== undefined) {
90 binaryLocations.splice(0, 0, options.binaryDir + '/' + nodbUtil.BINARY_FILE,
91 options.binaryDir + '/' + nodbUtil.BUILD_FILE);
92 }
93 let oracledbCLib;
94 for (let i = 0; i < binaryLocations.length; i++) {
95 try {
96 oracledbCLib = requireBinary(binaryLocations[i]);
97 break;
98 } catch (err) {
99 if (err.code !== 'MODULE_NOT_FOUND' || i == binaryLocations.length - 1) {
100 let nodeInfo;
101 if (err.code === 'MODULE_NOT_FOUND') {
102 // A binary was not found in any of the search directories.
103 // Note this message may not be accurate for Webpack users since Webpack changes __dirname
104 nodeInfo = `\n Looked for ${binaryLocations.map(x => require('path').resolve(__dirname, x)).join(', ')}\n ${nodbUtil.getInstallURL()}\n`;
105 } else {
106 nodeInfo = `\n Node.js require('oracledb') error was:\n ${err.message}\n ${nodbUtil.getInstallHelp()}\n`;
107 }
108 errors.throwErr(errors.ERR_CANNOT_LOAD_BINARY, nodeInfo);
109 }
110 }
111 }
112 return oracledbCLib;
113}
114
115// top-level functions
116
117function _initializeThinDriver() {
118 require('./thin');
119}
120
121//---------------------------------------------------------------------------
122// _isPrivilege()
123//
124// Returns a boolean indicating if the supplied value is a valid privilege.
125//---------------------------------------------------------------------------
126function _isPrivilege(value) {
127 return (
128 value === constants.SYSASM ||
129 value === constants.SYSBACKUP ||
130 value === constants.SYSDBA ||
131 value === constants.SYSDG ||
132 value === constants.SYSKM ||
133 value === constants.SYSOPER ||
134 value === constants.SYSPRELIM ||
135 value === constants.SYSRAC
136 );
137}
138
139//-----------------------------------------------------------------------------
140// _verifyOptions()
141//
142// Verify that the values passed by the user for connection and pool creation
143// options are acceptable. Performs any transformations that are necessary.
144//-----------------------------------------------------------------------------
145async function _verifyOptions(options, inCreatePool) {
146
147 // define normalized options (value returned to caller)
148 const outOptions = {};
149
150 // only one of "user" and "username" may be specified (and must be strings)
151 if (options.user !== undefined) {
152 errors.assertParamPropValue(typeof options.user === 'string', 1, "user");
153 outOptions.user = options.user;
154 }
155 if (options.username !== undefined) {
156 errors.assert(outOptions.user === undefined, errors.ERR_DBL_USER);
157 errors.assertParamPropValue(typeof options.username === 'string', 1,
158 "username");
159 outOptions.user = options.username;
160 }
161
162 // password must be a string
163 if (options.password !== undefined) {
164 errors.assertParamPropValue(typeof options.password === 'string', 1,
165 "password");
166 outOptions.password = options.password;
167 }
168
169 // only one of "connectString" and "connectionString" may be specified (and
170 // must be strings)
171 if (options.connectString !== undefined) {
172 errors.assertParamPropValue(typeof options.connectString === 'string', 1,
173 "connectString");
174 outOptions.connectString = options.connectString;
175 }
176 if (options.connectionString !== undefined) {
177 errors.assert(outOptions.connectString === undefined,
178 errors.ERR_DBL_CONNECT_STRING);
179 errors.assertParamPropValue(typeof options.connectionString === 'string',
180 1, "connectionString");
181 outOptions.connectString = options.connectionString;
182 }
183
184 // wallet password must be string
185 if (options.walletPassword !== undefined) {
186 errors.assertParamPropValue(typeof options.walletPassword === 'string', 1,
187 "walletPassword");
188 outOptions.walletPassword = options.walletPassword;
189 }
190
191 //wallet location must be a string
192 if (options.walletLocation !== undefined) {
193 errors.assertParamPropValue(typeof options.walletLocation === 'string', 1,
194 "walletLocation");
195 outOptions.walletLocation = options.walletLocation;
196 }
197
198 // edition must be a string
199 if (options.edition !== undefined) {
200 errors.assertParamPropValue(typeof options.edition === 'string', 1,
201 "edition");
202 outOptions.edition = options.edition;
203 }
204
205 // stmtCacheSize must be an integer (>= 0)
206 if (options.stmtCacheSize !== undefined) {
207 errors.assertParamPropValue(Number.isInteger(options.stmtCacheSize) &&
208 options.stmtCacheSize >= 0, 1, "stmtCacheSize");
209 outOptions.stmtCacheSize = options.stmtCacheSize;
210 }
211
212 // externalAuth must be a boolean
213 outOptions.externalAuth = settings.externalAuth;
214 if (options.externalAuth !== undefined) {
215 errors.assertParamPropValue(typeof options.externalAuth === 'boolean', 1,
216 "externalAuth");
217 outOptions.externalAuth = options.externalAuth;
218 }
219
220 // events must be a boolean
221 if (options.events !== undefined) {
222 errors.assertParamPropValue(typeof options.events === 'boolean', 1,
223 "events");
224 outOptions.events = options.events;
225 }
226
227 // poolAlias must be a string
228 if (options.poolAlias !== undefined) {
229 errors.assertParamPropValue(typeof options.poolAlias === 'string' &&
230 options.poolAlias.length > 0, 1, "poolAlias");
231 outOptions.poolAlias = options.poolAlias;
232 }
233
234 // configDir must be a string
235 if (options.configDir !== undefined) {
236 errors.assertParamPropValue(typeof options.configDir === 'string',
237 1, "configDir");
238 outOptions.configDir = options.configDir;
239 }
240
241 // sslServerServerCertDN must be a string
242 if (options.sslServerCertDN !== undefined) {
243 errors.assertParamPropValue(typeof options.sslServerCertDN === 'string',
244 1, "sslServerCertDN");
245 outOptions.sslServerCertDN = options.sslServerCertDN;
246 }
247
248 // sslServerServerDNMatch must be a boolean
249 if (options.sslServerDNMatch !== undefined) {
250 errors.assertParamPropValue(typeof options.sslServerDNMatch === 'boolean',
251 1, "sslServerDNMatch");
252 outOptions.sslServerDNMatch = options.sslServerDNMatch;
253 }
254
255 // sslAllowWeakDNMatch must be a boolean
256 if (options.sslAllowWeakDNMatch !== undefined) {
257 errors.assertParamPropValue(typeof options.sslAllowWeakDNMatch === 'boolean',
258 1, "sslAllowWeakDNMatch");
259 outOptions.sslAllowWeakDNMatch = options.sslAllowWeakDNMatch;
260 }
261 // httpsProxy must be a string
262 if (options.httpsProxy !== undefined) {
263 errors.assertParamPropValue(typeof options.httpsProxy === 'string',
264 1, "httpsProxy");
265 outOptions.httpsProxy = options.httpsProxy;
266 }
267
268 // httpsProxyPort must be an integer (>= 0)
269 if (options.httpsProxyPort !== undefined) {
270 errors.assertParamPropValue(Number.isInteger(options.httpsProxyPort) &&
271 options.httpsProxyPort >= 0, 1, "httpsProxyPort");
272 outOptions.httpsProxyPort = options.httpsProxyPort;
273 }
274
275 //retryCount must be an integer (>=0)
276 if (options.retryCount !== undefined) {
277 errors.assertParamPropValue(Number.isInteger(options.retryCount) &&
278 options.retryCount >= 0, 1, "retryCount");
279 outOptions.retryCount = options.retryCount;
280 }
281
282 //retryDelay must be an integer (>=0)
283 if (options.retryDelay !== undefined) {
284 errors.assertParamPropValue(Number.isInteger(options.retryDelay) &&
285 options.retryDelay >= 0, 1, "retryDelay");
286 outOptions.retryDelay = options.retryDelay;
287 }
288
289 // connectTimeout must be an integer (>= 0)
290 if (options.connectTimeout !== undefined) {
291 errors.assertParamPropValue(Number.isInteger(options.connectTimeout) &&
292 options.connectTimeout >= 0, 1, "connectTimeout");
293 outOptions.connectTimeout = options.connectTimeout;
294 }
295
296 // transportConnectTimeout must be an integer (>= 0)
297 if (options.transportConnectTimeout !== undefined) {
298 errors.assertParamPropValue(Number.isInteger(options.transportConnectTimeout) &&
299 options.transportConnectTimeout >= 0, 1, "transportConnectTimeout");
300 outOptions.transportConnectTimeout = options.transportConnectTimeout;
301 }
302
303 // expireTime must be an integer (>= 0)
304 if (options.expireTime !== undefined) {
305 errors.assertParamPropValue(Number.isInteger(options.expireTime) &&
306 options.expireTime >= 0, 1, "expireTime");
307 outOptions.expireTime = options.expireTime;
308
309 }
310
311 // sdu must be an integer (> 0)
312 if (options.sdu !== undefined) {
313 errors.assertParamPropValue(Number.isInteger(options.sdu) &&
314 options.sdu > 0, 1, "sdu");
315 outOptions.sdu = options.sdu;
316 }
317
318 // connectionIdPrefix must be a string
319 if (options.connectionIdPrefix !== undefined) {
320 errors.assertParamPropValue(typeof options.connectionIdPrefix === 'string',
321 1, "connectionIdPrefix");
322 outOptions.connectionIdPrefix = options.connectionIdPrefix;
323 }
324
325 // check pool specific options
326 if (inCreatePool) {
327
328 // poolMax must be an integer > 0
329 if (options.poolMax !== undefined) {
330 errors.assertParamPropValue(Number.isInteger(options.poolMax) &&
331 options.poolMax > 0, 1, "poolMax");
332 outOptions.poolMax = options.poolMax;
333 }
334
335 // poolMaxPerShard must be an integer >= 0
336 if (options.poolMaxPerShard !== undefined) {
337 errors.assertParamPropValue(Number.isInteger(options.poolMaxPerShard) &&
338 options.poolMaxPerShard >= 0, 1, "poolMaxPerShard");
339 outOptions.poolMaxPerShard = options.poolMaxPerShard;
340 }
341
342 // poolMin must be an integer >= 0
343 if (options.poolMin !== undefined) {
344 errors.assertParamPropValue(Number.isInteger(options.poolMin) &&
345 options.poolMin >= 0, 1, "poolMin");
346 outOptions.poolMin = options.poolMin;
347 }
348
349 // poolIncrement must be an integer >= 0
350 if (options.poolIncrement !== undefined) {
351 errors.assertParamPropValue(Number.isInteger(options.poolIncrement) &&
352 options.poolIncrement >= 0, 1, "poolIncrement");
353 outOptions.poolIncrement = options.poolIncrement;
354 }
355
356 // poolTimeout must be an integer >= 0
357 if (options.poolTimeout !== undefined) {
358 errors.assertParamPropValue(Number.isInteger(options.poolTimeout) &&
359 options.poolTimeout >= 0, 1, "poolTimeout");
360 outOptions.poolTimeout = options.poolTimeout;
361 }
362
363 // poolPingInterval must be an integer
364 if (options.poolPingInterval !== undefined) {
365 errors.assertParamPropValue(Number.isInteger(options.poolPingInterval) &&
366 options.poolPingInterval >= -2147483648 &&
367 options.poolPingInterval <= 2147483647, 1, "poolPingInterval");
368 outOptions.poolPingInterval = options.poolPingInterval;
369 }
370
371 // poolPingTimeout must be an integer (>= 0)
372 if (options.poolPingTimeout !== undefined) {
373 errors.assertParamPropValue(Number.isInteger(options.poolPingTimeout) &&
374 options.poolPingTimeout >= 0, 1, "poolPingTimeout");
375 outOptions.poolPingTimeout = options.poolPingTimeout;
376 }
377
378 // homogeneous must be a boolean (and defaults to True)
379 outOptions.homogeneous = true;
380 if (options.homogeneous !== undefined) {
381 errors.assertParamPropValue(typeof options.homogeneous === 'boolean', 1,
382 "homogeneous");
383 outOptions.homogeneous = options.homogeneous;
384 }
385
386 // queueTimeout must be an integer >= 0
387 if (options.queueTimeout !== undefined) {
388 errors.assertParamPropValue(Number.isInteger(options.queueTimeout) &&
389 options.queueTimeout >= 0, 1, "queueTimeout");
390 outOptions.queueTimeout = options.queueTimeout;
391 }
392
393 // queueMax must be an integer
394 if (options.queueMax !== undefined) {
395 errors.assertParamPropValue(Number.isInteger(options.queueMax), 1,
396 "queueMax");
397 outOptions.queueMax = options.queueMax;
398 }
399
400 // sodaMetaDataCache must be a boolean (and defaults to True)
401 outOptions.sodaMetaDataCache = false;
402 if (options.sodaMetaDataCache !== undefined) {
403 errors.assertParamPropValue(typeof options.sodaMetaDataCache ===
404 'boolean', 1, "sodaMetaDataCache");
405 outOptions.sodaMetaDataCache = options.sodaMetaDataCache;
406 }
407
408 // sessionCallback must be a function or a string
409 if (options.sessionCallback !== undefined) {
410 errors.assertParamPropValue(typeof options.sessionCallback === 'string' ||
411 typeof options.sessionCallback === 'function', 1, "sessionCallback");
412 outOptions.sessionCallback = options.sessionCallback;
413 }
414
415 // enableStatistics must be a boolean (_enableStats is DEPRECATED)
416 outOptions.enableStatistics = false;
417 if (options.enableStatistics !== undefined) {
418 errors.assertParamPropValue(typeof options.enableStatistics ===
419 'boolean', 1, "enableStatistics");
420 outOptions.enableStatistics = options.enableStatistics;
421 }
422 if (!outOptions.enableStatistics && options._enableStats !== undefined) {
423 errors.assertParamPropValue(typeof options._enableStats === 'boolean', 1,
424 "_enableStats");
425 outOptions.enableStatistics = options._enableStats;
426 }
427
428 // check connection creation specific options
429 } else {
430
431 // newPassword must be a string
432 if (options.newPassword !== undefined) {
433 errors.assertParamPropValue(typeof options.newPassword === 'string', 1,
434 "newPassword");
435 outOptions.newPassword = options.newPassword;
436 }
437
438 // privilege must be one of a set of named constants
439 if (options.privilege !== undefined) {
440 errors.assertParamPropValue(_isPrivilege(options.privilege), 1,
441 "privilege");
442 outOptions.privilege = options.privilege;
443 }
444
445 // shardingKey must be an array of values
446 if (options.shardingKey !== undefined) {
447 const value = options.shardingKey;
448 errors.assertParamPropValue(nodbUtil.isShardingKey(value), 1,
449 "shardingKey");
450 outOptions.shardingKey = options.shardingKey;
451 }
452
453 // superShardingKey must be an array of values
454 if (options.superShardingKey !== undefined) {
455 const value = options.superShardingKey;
456 errors.assertParamPropValue(nodbUtil.isShardingKey(value), 1,
457 "superShardingKey");
458 outOptions.superShardingKey = options.superShardingKey;
459 }
460
461 }
462
463 // check access token
464 if (options.accessToken !== undefined) {
465
466 // cannot set username or password for token based authentication
467 errors.assert(outOptions.user === undefined &&
468 outOptions.password === undefined, errors.ERR_TOKEN_BASED_AUTH);
469
470 // homogenous (for pool) and externalAuth (both) must be set
471 if (inCreatePool) {
472 errors.assert(outOptions.homogeneous && outOptions.externalAuth,
473 errors.ERR_POOL_TOKEN_BASED_AUTH);
474 } else {
475 errors.assert(outOptions.externalAuth, errors.ERR_CONN_TOKEN_BASED_AUTH);
476 }
477
478 // check the token is valid
479 let accessToken;
480 if (typeof options.accessToken === 'function') {
481 outOptions.accessTokenFn = options.accessToken;
482 outOptions.accessTokenConfig = options.accessTokenConfig;
483 accessToken = await options.accessToken(false, options.accessTokenConfig);
484 if (!nodbUtil.isTokenValid(accessToken)) {
485 accessToken = await options.accessToken(true, options.accessTokenConfig);
486 }
487 } else {
488 accessToken = options.accessToken;
489 }
490 errors.assert(nodbUtil.isTokenValid(accessToken),
491 errors.ERR_TOKEN_HAS_EXPIRED);
492 if (accessToken.privateKey !== undefined) {
493 errors.assert(typeof accessToken.privateKey === 'string', errors.ERR_TOKEN_BASED_AUTH);
494 accessToken.privateKey = nodbUtil.denormalizePrivateKey(accessToken.privateKey);
495 }
496
497 // store token and privatekey
498 if (typeof accessToken === 'string') {
499 outOptions.token = accessToken;
500 } else {
501 outOptions.token = accessToken.token;
502 outOptions.privateKey = accessToken.privateKey;
503 }
504
505 }
506
507 // Check external Auth config.
508 // Allow Session User enclosed in [] for proxy authentication.
509 if (outOptions.token === undefined && outOptions.externalAuth) {
510 if (outOptions.password) {
511 errors.throwErr(errors.ERR_WRONG_CRED_FOR_EXTAUTH);
512 }
513 if (outOptions.user) {
514 if (inCreatePool) {
515 errors.throwErr(errors.ERR_WRONG_CRED_FOR_EXTAUTH);
516 } else if (outOptions.user[0] !== '[' || outOptions.user.slice(-1) !== ']') {
517 // username is not enclosed in [].
518 errors.throwErr(errors.ERR_WRONG_USER_FORMAT_EXTAUTH_PROXY);
519 }
520 }
521 }
522
523 return outOptions;
524}
525
526
527//-----------------------------------------------------------------------------
528// createPool()
529//
530// Create a pool with the specified options and return it to the caller.
531//-----------------------------------------------------------------------------
532async function createPool(options) {
533 let poolAlias;
534
535 // check arguments
536 errors.assertArgCount(arguments, 1, 1);
537 errors.assertParamValue(nodbUtil.isObject(options), 1);
538 options = await _verifyOptions(options, true);
539 const sessionCallback = options.sessionCallback;
540 if (typeof sessionCallback === 'function')
541 delete options.sessionCallback;
542
543 // determine pool alias
544 if (options.poolAlias !== undefined) {
545 poolAlias = options.poolAlias;
546 } else if (options.poolAlias === undefined
547 && !poolCache[defaultPoolAlias]
548 && !tempUsedPoolAliases[defaultPoolAlias]) {
549 poolAlias = defaultPoolAlias;
550 }
551 if (poolCache[poolAlias] || tempUsedPoolAliases[poolAlias]) {
552 errors.throwErr(errors.ERR_POOL_WITH_ALIAS_ALREADY_EXISTS, poolAlias);
553 }
554
555 // add defaults to options, if needed
556 settings.addToOptions(options,
557 "connectionClass",
558 "edition",
559 "events",
560 "externalAuth",
561 "stmtCacheSize",
562 "poolMax",
563 "poolMaxPerShard",
564 "poolMin",
565 "poolIncrement",
566 "poolTimeout",
567 "poolPingInterval",
568 "poolPingTimeout",
569 "queueMax",
570 "queueTimeout");
571
572 // poolMax must be greater than or equal to poolMin
573 if (options.poolMin > options.poolMax) {
574 errors.throwErr(errors.ERR_INVALID_NUMBER_OF_CONNECTIONS, options.poolMax,
575 options.poolMin);
576 }
577
578 // initialize the Oracle client, if necessary
579 if (_initOracleClientArgs === undefined && !settings.thinDriverInitialized) {
580 _initializeThinDriver();
581 }
582
583 // Need to prevent another call in the same stack from succeeding, otherwise
584 // two pools could be created with the same poolAlias and the second one that
585 // comes back would overwrite the first in the cache.
586 if (poolAlias) {
587 tempUsedPoolAliases[poolAlias] = true;
588 }
589
590 // create the pool, ensuring that the temporary pool alias cache is removed
591 // once this has completed (either successfully or unsuccessfully)
592 const pool = new Pool();
593 try {
594 await pool._impl.create(options);
595 } finally {
596 if (poolAlias) {
597 delete tempUsedPoolAliases[poolAlias];
598 }
599 }
600
601 if (poolAlias) {
602 poolCache[poolAlias] = pool;
603 }
604
605 pool._setup(options, poolAlias);
606 pool._sessionCallback = sessionCallback;
607 pool.on('_afterPoolClose', () => {
608 if (pool.poolAlias) {
609 delete poolCache[pool.poolAlias];
610 }
611 });
612 if (_initOracleClientArgs === undefined) {
613 settings.thinDriverInitialized = true;
614 }
615
616 return pool;
617}
618
619
620//-----------------------------------------------------------------------------
621// getConnection()
622//
623// Gets either a standalone connection, or a connection from a pool (stored in
624// the pool cache).
625//-----------------------------------------------------------------------------
626async function getConnection(a1) {
627 let options = {};
628 let poolAlias;
629
630 // determine if the connection should be acquired from a pool
631 errors.assertArgCount(arguments, 0, 1);
632 if (arguments.length == 0) {
633 poolAlias = defaultPoolAlias;
634 } else if (typeof a1 === 'string') {
635 poolAlias = a1;
636 } else {
637 options = a1;
638 errors.assertParamValue(nodbUtil.isObject(options), 1);
639 poolAlias = options.poolAlias;
640 }
641 if (poolAlias) {
642 const pool = poolCache[poolAlias];
643 errors.assert(pool, errors.ERR_POOL_WITH_ALIAS_NOT_FOUND, poolAlias);
644 return await pool.getConnection(options);
645 }
646
647 // create a standalone connection
648 options = await _verifyOptions(options, false);
649 settings.addToOptions(options,
650 "connectionClass",
651 "edition",
652 "events",
653 "externalAuth",
654 "stmtCacheSize");
655 if (_initOracleClientArgs === undefined && !settings.thinDriverInitialized) {
656 _initializeThinDriver();
657 }
658
659 const conn = new Connection();
660 conn._impl = new impl.ConnectionImpl();
661 await conn._impl.connect(options);
662 if (_initOracleClientArgs === undefined) {
663 settings.thinDriverInitialized = true;
664 }
665 return conn;
666}
667
668//-----------------------------------------------------------------------------
669// getPool()
670//
671// Returns a pool for the given alias.
672//-----------------------------------------------------------------------------
673function getPool(poolAlias) {
674
675 errors.assertArgCount(arguments, 0, 1);
676
677 if (poolAlias) {
678 errors.assertParamValue(typeof poolAlias === 'string' ||
679 typeof poolAlias === 'number', 1);
680 }
681
682 poolAlias = poolAlias || defaultPoolAlias;
683
684 const pool = poolCache[poolAlias];
685
686 if (!pool) {
687 errors.throwErr(errors.ERR_POOL_WITH_ALIAS_NOT_FOUND, poolAlias);
688 }
689
690 return pool;
691}
692
693//-----------------------------------------------------------------------------
694// initOracleClient()
695//
696// Initializes the Oracle Client.
697//-----------------------------------------------------------------------------
698function initOracleClient(arg1) {
699 let options = {};
700 errors.assertArgCount(arguments, 0, 1);
701 if (arg1 !== undefined) {
702 errors.assertParamValue(nodbUtil.isObject(arg1), 1);
703 options = {...arg1};
704 errors.assertParamPropString(options, 1, "libDir");
705 errors.assertParamPropString(options, 1, "configDir");
706 errors.assertParamPropString(options, 1, "errorUrl");
707 errors.assertParamPropString(options, 1, "driverName");
708 errors.assertParamPropString(options, 1, "binaryDir");
709 }
710 if (settings.thinDriverInitialized) {
711 errors.throwErr(errors.ERR_THIN_CONNECTION_ALREADY_CREATED);
712 }
713 if (_initOracleClientArgs === undefined) {
714 const oracledbCLib = _initCLib(options);
715 if (options.driverName === undefined)
716 options.driverName = constants.DEFAULT_DRIVER_NAME + " thk";
717 if (options.errorUrl === undefined)
718 options.errorUrl = constants.DEFAULT_ERROR_URL;
719 try {
720 oracledbCLib.initOracleClient(options, impl, settings);
721 } catch (err) {
722 const newErr = errors.transformErr(err);
723 if (newErr.code === "DPI-1047") {
724 newErr.message += "\n" + nodbUtil.getInstallHelp();
725 }
726 throw newErr;
727 }
728 _initOracleClientArgs = arg1 || {};
729 } else if (!util.isDeepStrictEqual(_initOracleClientArgs, options)) {
730 errors.throwErr(errors.ERR_INIT_ORACLE_CLIENT_ARGS);
731 }
732
733 // driver mode initialization
734 // _initOracleClientArgs is populated and thin connection not created
735 settings.thin = false;
736}
737
738
739//-----------------------------------------------------------------------------
740// shutdown()
741//
742// Shuts down the database.
743//-----------------------------------------------------------------------------
744async function shutdown(a1, a2) {
745 let connAttr = {};
746 let shutdownMode = constants.SHUTDOWN_MODE_DEFAULT;
747
748 // verify the number and types of arguments
749 errors.assertArgCount(arguments, 0, 2);
750 if (arguments.length == 2) {
751 errors.assertParamValue(typeof a1 === 'object', 1);
752 errors.assertParamValue(typeof a2 === 'number', 2);
753 connAttr = a1;
754 shutdownMode = a2;
755 } else if (arguments.length == 1) {
756 errors.assertParamValue(typeof a1 === 'object', 1);
757 connAttr = a1;
758 }
759
760 // only look for the keys that are used for shutting down the database
761 // use SYSOPER privilege
762 const dbConfig = {
763 user: connAttr.user,
764 password: connAttr.password,
765 connectString: connAttr.connectString,
766 connectionString: connAttr.connectionString,
767 externalAuth: connAttr.externalAuth,
768 privilege: constants.SYSOPER
769 };
770
771 const conn = await this.getConnection(dbConfig);
772 await conn.shutdown(shutdownMode);
773 if (shutdownMode != this.SHUTDOWN_MODE_ABORT) {
774 await conn.execute("ALTER DATABASE CLOSE");
775 await conn.execute("ALTER DATABASE DISMOUNT");
776 await conn.shutdown(this.SHUTDOWN_MODE_FINAL);
777 }
778 await conn.close();
779}
780
781
782//-----------------------------------------------------------------------------
783// startup()
784//
785// Starts up the database.
786//-----------------------------------------------------------------------------
787async function startup(a1, a2) {
788 let connAttr = {};
789 let startupAttr = {};
790
791 // verify the number and types of arguments
792 errors.assertArgCount(arguments, 0, 2);
793 if (arguments.length == 2) {
794 errors.assertParamValue(typeof a1 === 'object', 1);
795 errors.assertParamValue(typeof a2 === 'object', 2);
796 connAttr = a1;
797 startupAttr = a2;
798 } else if (arguments.length == 1) {
799 errors.assertParamValue(typeof a1 === 'object', 1);
800 connAttr = a1;
801 }
802
803 // only look for the keys that are used for starting up the database
804 // use SYSOPER and SYSPRELIM privileges
805 const dbConfig = {
806 user: connAttr.user,
807 password: connAttr.password,
808 connectString: connAttr.connectString,
809 connectionString: connAttr.connectionString,
810 externalAuth: connAttr.externalAuth,
811 privilege: this.SYSOPER | this.SYSPRELIM
812 };
813
814 let conn = await this.getConnection(dbConfig);
815 await conn.startup(startupAttr);
816 await conn.close();
817
818 dbConfig.privilege = this.SYSOPER;
819 conn = await this.getConnection(dbConfig);
820 await conn.execute("ALTER DATABASE MOUNT");
821 await conn.execute("ALTER DATABASE OPEN");
822 await conn.close();
823}
824
825// module exports
826module.exports = {
827
828 // classes
829 AqDeqOptions,
830 AqEnqOptions,
831 AqMessage,
832 AqQueue,
833 BaseDbObject,
834 Connection,
835 Lob,
836 Pool,
837 PoolStatistics,
838 ResultSet,
839 SodaDatabase,
840 SodaCollection,
841 SodaDocCursor,
842 SodaDocument,
843 SodaOperation,
844
845 // top-level functions
846 getConnection: nodbUtil.callbackify(getConnection),
847 createPool: nodbUtil.callbackify(createPool),
848 getPool,
849 initOracleClient,
850 shutdown: nodbUtil.callbackify(shutdown),
851 startup: nodbUtil.callbackify(startup),
852
853 // CQN operation codes
854 CQN_OPCODE_ALL_OPS: constants.CQN_OPCODE_ALL_OPS,
855 CQN_OPCODE_ALL_ROWS: constants.CQN_OPCODE_ALL_ROWS,
856 CQN_OPCODE_ALTER: constants.CQN_OPCODE_ALTER,
857 CQN_OPCODE_DELETE: constants.CQN_OPCODE_DELETE,
858 CQN_OPCODE_DROP: constants.CQN_OPCODE_DROP,
859 CQN_OPCODE_INSERT: constants.CQN_OPCODE_INSERT,
860 CQN_OPCODE_UPDATE: constants.CQN_OPCODE_UPDATE,
861
862 // database types
863 DB_TYPE_BFILE: types.DB_TYPE_BFILE,
864 DB_TYPE_BINARY_DOUBLE: types.DB_TYPE_BINARY_DOUBLE,
865 DB_TYPE_BINARY_FLOAT: types.DB_TYPE_BINARY_FLOAT,
866 DB_TYPE_BINARY_INTEGER: types.DB_TYPE_BINARY_INTEGER,
867 DB_TYPE_BLOB: types.DB_TYPE_BLOB,
868 DB_TYPE_BOOLEAN: types.DB_TYPE_BOOLEAN,
869 DB_TYPE_CHAR: types.DB_TYPE_CHAR,
870 DB_TYPE_CLOB: types.DB_TYPE_CLOB,
871 DB_TYPE_CURSOR: types.DB_TYPE_CURSOR,
872 DB_TYPE_DATE: types.DB_TYPE_DATE,
873 DB_TYPE_INTERVAL_DS: types.DB_TYPE_INTERVAL_DS,
874 DB_TYPE_INTERVAL_YM: types.DB_TYPE_INTERVAL_YM,
875 DB_TYPE_JSON: types.DB_TYPE_JSON,
876 DB_TYPE_LONG: types.DB_TYPE_LONG,
877 DB_TYPE_LONG_NVARCHAR: types.DB_TYPE_LONG_NVARCHAR,
878 DB_TYPE_LONG_RAW: types.DB_TYPE_LONG_RAW,
879 DB_TYPE_NCHAR: types.DB_TYPE_NCHAR,
880 DB_TYPE_NCLOB: types.DB_TYPE_NCLOB,
881 DB_TYPE_NUMBER: types.DB_TYPE_NUMBER,
882 DB_TYPE_NVARCHAR: types.DB_TYPE_NVARCHAR,
883 DB_TYPE_OBJECT: types.DB_TYPE_OBJECT,
884 DB_TYPE_RAW: types.DB_TYPE_RAW,
885 DB_TYPE_ROWID: types.DB_TYPE_ROWID,
886 DB_TYPE_TIMESTAMP: types.DB_TYPE_TIMESTAMP,
887 DB_TYPE_TIMESTAMP_LTZ: types.DB_TYPE_TIMESTAMP_LTZ,
888 DB_TYPE_TIMESTAMP_TZ: types.DB_TYPE_TIMESTAMP_TZ,
889 DB_TYPE_VARCHAR: types.DB_TYPE_VARCHAR,
890 DB_TYPE_XMLTYPE: types.DB_TYPE_XMLTYPE,
891 DB_TYPE_VECTOR: types.DB_TYPE_VECTOR,
892
893 // fetchInfo type defaulting
894 DEFAULT: constants.DEFAULT,
895
896 // statement types
897 STMT_TYPE_UNKNOWN: constants.STMT_TYPE_UNKNOWN,
898 STMT_TYPE_SELECT: constants.STMT_TYPE_SELECT,
899 STMT_TYPE_UPDATE: constants.STMT_TYPE_UPDATE,
900 STMT_TYPE_DELETE: constants.STMT_TYPE_DELETE,
901 STMT_TYPE_INSERT: constants.STMT_TYPE_INSERT,
902 STMT_TYPE_CREATE: constants.STMT_TYPE_CREATE,
903 STMT_TYPE_DROP: constants.STMT_TYPE_DROP,
904 STMT_TYPE_ALTER: constants.STMT_TYPE_ALTER,
905 STMT_TYPE_BEGIN: constants.STMT_TYPE_BEGIN,
906 STMT_TYPE_DECLARE: constants.STMT_TYPE_DECLARE,
907 STMT_TYPE_CALL: constants.STMT_TYPE_CALL,
908 STMT_TYPE_EXPLAIN_PLAN: constants.STMT_TYPE_EXPLAIN_PLAN,
909 STMT_TYPE_MERGE: constants.STMT_TYPE_MERGE,
910 STMT_TYPE_ROLLBACK: constants.STMT_TYPE_ROLLBACK,
911 STMT_TYPE_COMMIT: constants.STMT_TYPE_COMMIT,
912
913 // shutdown modes
914 SHUTDOWN_MODE_DEFAULT: constants.SHUTDOWN_MODE_DEFAULT,
915 SHUTDOWN_MODE_TRANSACTIONAL: constants.SHUTDOWN_MODE_TRANSACTIONAL,
916 SHUTDOWN_MODE_TRANSACTIONAL_LOCAL:
917 constants.SHUTDOWN_MODE_TRANSACTIONAL_LOCAL,
918 SHUTDOWN_MODE_IMMEDIATE: constants.SHUTDOWN_MODE_IMMEDIATE,
919 SHUTDOWN_MODE_ABORT: constants.SHUTDOWN_MODE_ABORT,
920 SHUTDOWN_MODE_FINAL: constants.SHUTDOWN_MODE_FINAL,
921
922 // startup modes
923 STARTUP_MODE_DEFAULT: constants.STARTUP_MODE_DEFAULT,
924 STARTUP_MODE_FORCE: constants.STARTUP_MODE_FORCE,
925 STARTUP_MODE_RESTRICT: constants.STARTUP_MODE_RESTRICT,
926
927 // subscription event types
928 SUBSCR_EVENT_TYPE_SHUTDOWN: constants.SUBSCR_EVENT_TYPE_SHUTDOWN,
929 SUBSCR_EVENT_TYPE_SHUTDOWN_ANY: constants.SUBSCR_EVENT_TYPE_SHUTDOWN_ANY,
930 SUBSCR_EVENT_TYPE_STARTUP: constants.SUBSCR_EVENT_TYPE_STARTUP,
931 SUBSCR_EVENT_TYPE_DEREG: constants.SUBSCR_EVENT_TYPE_DEREG,
932 SUBSCR_EVENT_TYPE_OBJ_CHANGE: constants.SUBSCR_EVENT_TYPE_OBJ_CHANGE,
933 SUBSCR_EVENT_TYPE_QUERY_CHANGE: constants.SUBSCR_EVENT_TYPE_QUERY_CHANGE,
934 SUBSCR_EVENT_TYPE_AQ: constants.SUBSCR_EVENT_TYPE_AQ,
935
936 // subscription grouping classes
937 SUBSCR_GROUPING_CLASS_TIME: constants.SUBSCR_GROUPING_CLASS_TIME,
938
939 // subscription grouping types
940 SUBSCR_GROUPING_TYPE_SUMMARY: constants.SUBSCR_GROUPING_TYPE_SUMMARY,
941 SUBSCR_GROUPING_TYPE_LAST: constants.SUBSCR_GROUPING_TYPE_LAST,
942
943 // subscription namespaces
944 SUBSCR_NAMESPACE_AQ: constants.SUBSCR_NAMESPACE_AQ,
945 SUBSCR_NAMESPACE_DBCHANGE: constants.SUBSCR_NAMESPACE_DBCHANGE,
946
947 // subscription quality of service flags
948 SUBSCR_QOS_BEST_EFFORT: constants.SUBSCR_QOS_BEST_EFFORT,
949 SUBSCR_QOS_DEREG_NFY: constants.SUBSCR_QOS_DEREG_NFY,
950 SUBSCR_QOS_QUERY: constants.SUBSCR_QOS_QUERY,
951 SUBSCR_QOS_RELIABLE: constants.SUBSCR_QOS_RELIABLE,
952 SUBSCR_QOS_ROWIDS: constants.SUBSCR_QOS_ROWIDS,
953
954 // privileges
955 SYSASM: constants.SYSASM,
956 SYSBACKUP: constants.SYSBACKUP,
957 SYSDBA: constants.SYSDBA,
958 SYSDG: constants.SYSDG,
959 SYSKM: constants.SYSKM,
960 SYSOPER: constants.SYSOPER,
961 SYSPRELIM: constants.SYSPRELIM,
962 SYSRAC: constants.SYSRAC,
963
964 // bind directions
965 BIND_IN: constants.BIND_IN,
966 BIND_INOUT: constants.BIND_INOUT,
967 BIND_OUT: constants.BIND_OUT,
968
969 // outFormat values
970 OUT_FORMAT_ARRAY: constants.OUT_FORMAT_ARRAY,
971 OUT_FORMAT_OBJECT: constants.OUT_FORMAT_OBJECT,
972
973 // SODA collection creation modes
974 SODA_COLL_MAP_MODE: constants.SODA_COLL_MAP_MODE,
975
976 // pool statuses
977 POOL_STATUS_OPEN: constants.POOL_STATUS_OPEN,
978 POOL_STATUS_DRAINING: constants.POOL_STATUS_DRAINING,
979 POOL_STATUS_CLOSED: constants.POOL_STATUS_CLOSED,
980 POOL_STATUS_RECONFIGURING: constants.POOL_STATUS_RECONFIGURING,
981
982 // AQ dequeue wait options
983 AQ_DEQ_NO_WAIT: constants.AQ_DEQ_NO_WAIT,
984 AQ_DEQ_WAIT_FOREVER: constants.AQ_DEQ_WAIT_FOREVER,
985
986 // AQ dequeue modes
987 AQ_DEQ_MODE_BROWSE: constants.AQ_DEQ_MODE_BROWSE,
988 AQ_DEQ_MODE_LOCKED: constants.AQ_DEQ_MODE_LOCKED,
989 AQ_DEQ_MODE_REMOVE: constants.AQ_DEQ_MODE_REMOVE,
990 AQ_DEQ_MODE_REMOVE_NO_DATA: constants.AQ_DEQ_MODE_REMOVE_NO_DATA,
991
992 // AQ dequeue navigation flags
993 AQ_DEQ_NAV_FIRST_MSG: constants.AQ_DEQ_NAV_FIRST_MSG,
994 AQ_DEQ_NAV_NEXT_TRANSACTION: constants.AQ_DEQ_NAV_NEXT_TRANSACTION,
995 AQ_DEQ_NAV_NEXT_MSG: constants.AQ_DEQ_NAV_NEXT_MSG,
996
997 // AQ message delivery modes
998 AQ_MSG_DELIV_MODE_PERSISTENT: constants.AQ_MSG_DELIV_MODE_PERSISTENT,
999 AQ_MSG_DELIV_MODE_BUFFERED: constants.AQ_MSG_DELIV_MODE_BUFFERED,
1000 AQ_MSG_DELIV_MODE_PERSISTENT_OR_BUFFERED:
1001 constants.AQ_MSG_DELIV_MODE_PERSISTENT_OR_BUFFERED,
1002
1003 // AQ message states
1004 AQ_MSG_STATE_READY: constants.AQ_MSG_STATE_READY,
1005 AQ_MSG_STATE_WAITING: constants.AQ_MSG_STATE_WAITING,
1006 AQ_MSG_STATE_PROCESSED: constants.AQ_MSG_STATE_PROCESSED,
1007 AQ_MSG_STATE_EXPIRED: constants.AQ_MSG_STATE_EXPIRED,
1008
1009 // AQ visibility flags
1010 AQ_VISIBILITY_IMMEDIATE: constants.AQ_VISIBILITY_IMMEDIATE,
1011 AQ_VISIBILITY_ON_COMMIT: constants.AQ_VISIBILITY_ON_COMMIT,
1012
1013 // TPC/XA begin flags Constants
1014 TPC_BEGIN_JOIN: constants.TPC_BEGIN_JOIN,
1015 TPC_BEGIN_NEW: constants.TPC_BEGIN_NEW,
1016 TPC_BEGIN_PROMOTE: constants.TPC_BEGIN_PROMOTE,
1017 TPC_BEGIN_RESUME: constants.TPC_BEGIN_RESUME,
1018
1019 // TPC/XA two-phase commit flags
1020 TPC_END_NORMAL: constants.TPC_END_NORMAL,
1021 TPC_END_SUSPEND: constants.TPC_END_SUSPEND,
1022
1023 // vector types
1024 VECTOR_FORMAT_FLOAT32: constants.VECTOR_FORMAT_FLOAT32,
1025 VECTOR_FORMAT_FLOAT64: constants.VECTOR_FORMAT_FLOAT64,
1026 VECTOR_FORMAT_INT8: constants.VECTOR_FORMAT_INT8,
1027
1028 // database type aliases
1029 BLOB: types.DB_TYPE_BLOB,
1030 BUFFER: types.DB_TYPE_RAW,
1031 CLOB: types.DB_TYPE_CLOB,
1032 CURSOR: types.DB_TYPE_CURSOR,
1033 DATE: types.DB_TYPE_TIMESTAMP,
1034 NCLOB: types.DB_TYPE_NCLOB,
1035 NUMBER: types.DB_TYPE_NUMBER,
1036 STRING: types.DB_TYPE_VARCHAR,
1037
1038 // outFormat aliases
1039 ARRAY: constants.OUT_FORMAT_ARRAY,
1040 OBJECT: constants.OUT_FORMAT_OBJECT,
1041
1042 // Instances
1043 future,
1044
1045 // property getters
1046 get autoCommit() {
1047 return settings.autoCommit;
1048 },
1049
1050 get connectionClass() {
1051 return settings.connectionClass;
1052 },
1053
1054 get dbObjectAsPojo() {
1055 return settings.dbObjectAsPojo;
1056 },
1057
1058 get edition() {
1059 return settings.edition;
1060 },
1061
1062 get errorOnConcurrentExecute() {
1063 return settings.errorOnConcurrentExecute;
1064 },
1065
1066 get events() {
1067 return settings.events;
1068 },
1069
1070 get externalAuth() {
1071 return settings.externalAuth;
1072 },
1073
1074 get fetchArraySize() {
1075 return settings.fetchArraySize;
1076 },
1077
1078 get fetchAsBuffer() {
1079 return settings.fetchAsBuffer;
1080 },
1081
1082 get fetchAsString() {
1083 return settings.fetchAsString;
1084 },
1085
1086 get fetchTypeHandler() {
1087 return settings.fetchTypeHandler;
1088 },
1089
1090 get lobPrefetchSize() {
1091 return settings.lobPrefetchSize;
1092 },
1093
1094 get maxRows() {
1095 return settings.maxRows;
1096 },
1097
1098 get oracleClientVersion() {
1099 return settings.oracleClientVersion;
1100 },
1101
1102 get oracleClientVersionString() {
1103 return settings.oracleClientVersionString;
1104 },
1105
1106 get outFormat() {
1107 return settings.outFormat;
1108 },
1109
1110 get poolIncrement() {
1111 return settings.poolIncrement;
1112 },
1113
1114 get poolMax() {
1115 return settings.poolMax;
1116 },
1117
1118 get poolMaxPerShard() {
1119 return settings.poolMaxPerShard;
1120 },
1121
1122 get poolMin() {
1123 return settings.poolMin;
1124 },
1125
1126 get poolPingInterval() {
1127 return settings.poolPingInterval;
1128 },
1129
1130 get poolPingTimeout() {
1131 return settings.poolPingTimeout;
1132 },
1133
1134 get poolTimeout() {
1135 return settings.poolTimeout;
1136 },
1137
1138 get prefetchRows() {
1139 return settings.prefetchRows;
1140 },
1141
1142 get stmtCacheSize() {
1143 return settings.stmtCacheSize;
1144 },
1145
1146 get thin() {
1147 return settings.thin;
1148 },
1149
1150 get version() {
1151 return constants.VERSION_MAJOR * 10000 + constants.VERSION_MINOR * 100 +
1152 constants.VERSION_PATCH;
1153 },
1154
1155 get versionString() {
1156 return constants.VERSION_STRING;
1157 },
1158
1159 get versionSuffix() {
1160 return constants.VERSION_SUFFIX;
1161 },
1162
1163 // property setters
1164 set autoCommit(value) {
1165 errors.assertPropValue(typeof value === 'boolean', "autoCommit");
1166 settings.autoCommit = value;
1167 },
1168
1169 set connectionClass(value) {
1170 errors.assertPropValue(typeof value === 'string', "connectionClass");
1171 settings.connectionClass = value;
1172 },
1173
1174 set dbObjectAsPojo(value) {
1175 errors.assertPropValue(typeof value === 'boolean', "dbObjectAsPojo");
1176 settings.dbObjectAsPojo = value;
1177 },
1178
1179 set edition(value) {
1180 errors.assertPropValue(typeof value === 'string', "edition");
1181 settings.edition = value;
1182 },
1183
1184 set errorOnConcurrentExecute(value) {
1185 errors.assertPropValue(typeof value === 'boolean',
1186 "errorOnConcurrentExecute");
1187 settings.errorOnConcurrentExecute = value;
1188 },
1189
1190 set events(value) {
1191 errors.assertPropValue(typeof value === 'boolean', "events");
1192 settings.events = value;
1193 },
1194
1195 set externalAuth(value) {
1196 errors.assertPropValue(typeof value === 'boolean', "externalAuth");
1197 settings.externalAuth = value;
1198 },
1199
1200 set fetchArraySize(value) {
1201 errors.assertPropValue(Number.isInteger(value) && value > 0,
1202 "fetchArraySize");
1203 settings.fetchArraySize = value;
1204 },
1205
1206 set fetchAsBuffer(value) {
1207 errors.assertPropValue(Array.isArray(value), "fetchAsBuffer");
1208 settings.createFetchTypeMap(settings.fetchAsString, value);
1209 settings.fetchAsBuffer = value;
1210 },
1211
1212 set fetchAsString(value) {
1213 errors.assertPropValue(Array.isArray(value), "fetchAsString");
1214 settings.createFetchTypeMap(value, settings.fetchAsBuffer);
1215 settings.fetchAsString = value;
1216 },
1217
1218 set fetchTypeHandler(value) {
1219 if (value !== undefined) {
1220 errors.assertPropValue(typeof value === 'function', "fetchTypeHandler");
1221 }
1222 settings.fetchTypeHandler = value;
1223 },
1224
1225 set lobPrefetchSize(value) {
1226 errors.assertPropValue(Number.isInteger(value) && value >= 0,
1227 "lobPrefetchSize");
1228 settings.lobPrefetchSize = value;
1229 },
1230
1231 set maxRows(value) {
1232 errors.assertPropValue(Number.isInteger(value) && value >= 0, "maxRows");
1233 settings.maxRows = value;
1234 },
1235
1236 set outFormat(value) {
1237 if (value !== constants.OUT_FORMAT_ARRAY &&
1238 value !== constants.OUT_FORMAT_OBJECT) {
1239 errors.throwErr(errors.ERR_INVALID_PROPERTY_VALUE, "outFormat");
1240 }
1241 settings.outFormat = value;
1242 },
1243
1244 set poolIncrement(value) {
1245 errors.assertPropValue(Number.isInteger(value) && value >= 0,
1246 "poolIncrement");
1247 settings.poolIncrement = value;
1248 },
1249
1250 set poolMax(value) {
1251 errors.assertPropValue(Number.isInteger(value) && value >= 0, "poolMax");
1252 settings.poolMax = value;
1253 },
1254
1255 set poolMaxPerShard(value) {
1256 errors.assertPropValue(Number.isInteger(value) && value >= 0,
1257 "poolMaxPerShard");
1258 settings.poolMaxPerShard = value;
1259 },
1260
1261 set poolMin(value) {
1262 errors.assertPropValue(Number.isInteger(value) && value >= 0, "poolMin");
1263 settings.poolMin = value;
1264 },
1265
1266 set poolPingInterval(value) {
1267 errors.assertPropValue(Number.isInteger(value) && value < 2 ** 31 &&
1268 value >= (-2) ** 31, "poolPingInterval");
1269 settings.poolPingInterval = value;
1270 },
1271
1272 set poolPingTimeout(value) {
1273 errors.assertPropValue(Number.isInteger(value) && value >= 0,
1274 "poolPingTimeout");
1275 settings.poolPingTimeout = value;
1276 },
1277
1278 set poolTimeout(value) {
1279 errors.assertPropValue(Number.isInteger(value) && value >= 0,
1280 "poolTimeout");
1281 settings.poolTimeout = value;
1282 },
1283
1284 set prefetchRows(value) {
1285 errors.assertPropValue(Number.isInteger(value) && value >= 0,
1286 "prefetchRows");
1287 settings.prefetchRows = value;
1288 },
1289
1290 set stmtCacheSize(value) {
1291 errors.assertPropValue(Number.isInteger(value) && value >= 0,
1292 "stmtCacheSize");
1293 settings.stmtCacheSize = value;
1294 },
1295
1296};