oracledb 3.0.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +135 -8
  2. package/README.md +6 -4
  3. package/build/Release/oracledb-abi48-darwin-x64.node +0 -0
  4. package/build/Release/oracledb-abi48-darwin-x64.node-buildinfo.txt +1 -0
  5. package/build/Release/oracledb-abi48-linux-x64.node +0 -0
  6. package/build/Release/oracledb-abi48-linux-x64.node-buildinfo.txt +1 -0
  7. package/build/Release/oracledb-abi48-win32-x64.node +0 -0
  8. package/build/Release/oracledb-abi48-win32-x64.node-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-abi57-darwin-x64.node +0 -0
  10. package/build/Release/oracledb-abi57-darwin-x64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-abi57-linux-x64.node +0 -0
  12. package/build/Release/oracledb-abi57-linux-x64.node-buildinfo.txt +1 -0
  13. package/build/Release/oracledb-abi57-win32-x64.node +0 -0
  14. package/build/Release/oracledb-abi57-win32-x64.node-buildinfo.txt +1 -0
  15. package/build/Release/oracledb-abi64-darwin-x64.node +0 -0
  16. package/build/Release/oracledb-abi64-darwin-x64.node-buildinfo.txt +1 -0
  17. package/build/Release/oracledb-abi64-linux-x64.node +0 -0
  18. package/build/Release/oracledb-abi64-linux-x64.node-buildinfo.txt +1 -0
  19. package/build/Release/oracledb-abi64-win32-x64.node +0 -0
  20. package/build/Release/oracledb-abi64-win32-x64.node-buildinfo.txt +1 -0
  21. package/build/Release/oracledb-abi67-darwin-x64.node +0 -0
  22. package/build/Release/oracledb-abi67-darwin-x64.node-buildinfo.txt +1 -0
  23. package/build/Release/oracledb-abi67-linux-x64.node +0 -0
  24. package/build/Release/oracledb-abi67-linux-x64.node-buildinfo.txt +1 -0
  25. package/build/Release/oracledb-abi67-win32-x64.node +0 -0
  26. package/build/Release/oracledb-abi67-win32-x64.node-buildinfo.txt +1 -0
  27. package/lib/connection.js +18 -4
  28. package/lib/oracledb.js +44 -92
  29. package/lib/pool.js +36 -2
  30. package/lib/sodaCollection.js +1 -1
  31. package/lib/sodaDatabase.js +1 -1
  32. package/lib/util.js +82 -5
  33. package/package/README.md +32 -101
  34. package/package/install.js +139 -0
  35. package/package/prunebinaries.js +51 -0
  36. package/package.json +4 -11
  37. package/binding.gyp +0 -162
  38. package/lib/rel.txt +0 -1
  39. package/odpi/.npmignore +0 -4
  40. package/odpi/LICENSE.md +0 -218
  41. package/odpi/README.md +0 -61
  42. package/odpi/embed/README.md +0 -4
  43. package/odpi/embed/dpi.c +0 -50
  44. package/odpi/include/dpi.h +0 -1748
  45. package/odpi/src/dpiConn.c +0 -2089
  46. package/odpi/src/dpiContext.c +0 -296
  47. package/odpi/src/dpiData.c +0 -797
  48. package/odpi/src/dpiDebug.c +0 -184
  49. package/odpi/src/dpiDeqOptions.c +0 -370
  50. package/odpi/src/dpiEnqOptions.c +0 -174
  51. package/odpi/src/dpiEnv.c +0 -189
  52. package/odpi/src/dpiError.c +0 -204
  53. package/odpi/src/dpiErrorMessages.h +0 -86
  54. package/odpi/src/dpiGen.c +0 -303
  55. package/odpi/src/dpiGlobal.c +0 -292
  56. package/odpi/src/dpiHandleList.c +0 -117
  57. package/odpi/src/dpiHandlePool.c +0 -118
  58. package/odpi/src/dpiImpl.h +0 -1707
  59. package/odpi/src/dpiLob.c +0 -506
  60. package/odpi/src/dpiMsgProps.c +0 -386
  61. package/odpi/src/dpiObject.c +0 -897
  62. package/odpi/src/dpiObjectAttr.c +0 -115
  63. package/odpi/src/dpiObjectType.c +0 -326
  64. package/odpi/src/dpiOci.c +0 -3527
  65. package/odpi/src/dpiOracleType.c +0 -492
  66. package/odpi/src/dpiPool.c +0 -549
  67. package/odpi/src/dpiRowid.c +0 -136
  68. package/odpi/src/dpiSodaColl.c +0 -685
  69. package/odpi/src/dpiSodaCollCursor.c +0 -143
  70. package/odpi/src/dpiSodaDb.c +0 -432
  71. package/odpi/src/dpiSodaDoc.c +0 -230
  72. package/odpi/src/dpiSodaDocCursor.c +0 -143
  73. package/odpi/src/dpiStmt.c +0 -1797
  74. package/odpi/src/dpiSubscr.c +0 -674
  75. package/odpi/src/dpiUtils.c +0 -410
  76. package/odpi/src/dpiVar.c +0 -1794
  77. package/package/MAKEPKG.BAT +0 -156
  78. package/package/Makefile +0 -85
  79. package/package/createpackage.js +0 -186
  80. package/package/extractpackage.js +0 -76
  81. package/package/getversion.js +0 -37
  82. package/package/oracledbinstall.js +0 -497
  83. package/package/package.json +0 -54
  84. package/package/util.js +0 -286
  85. package/src/njsCommon.cpp +0 -1055
  86. package/src/njsCommon.h +0 -484
  87. package/src/njsConnection.cpp +0 -2926
  88. package/src/njsConnection.h +0 -227
  89. package/src/njsIntLob.cpp +0 -618
  90. package/src/njsIntLob.h +0 -179
  91. package/src/njsMessages.cpp +0 -122
  92. package/src/njsMessages.h +0 -118
  93. package/src/njsOracle.cpp +0 -1274
  94. package/src/njsOracle.h +0 -237
  95. package/src/njsPool.cpp +0 -482
  96. package/src/njsPool.h +0 -132
  97. package/src/njsResultSet.cpp +0 -478
  98. package/src/njsResultSet.h +0 -120
  99. package/src/njsSodaCollection.cpp +0 -507
  100. package/src/njsSodaCollection.h +0 -128
  101. package/src/njsSodaDatabase.cpp +0 -335
  102. package/src/njsSodaDatabase.h +0 -108
  103. package/src/njsSodaDocCursor.cpp +0 -203
  104. package/src/njsSodaDocCursor.h +0 -94
  105. package/src/njsSodaDocument.cpp +0 -412
  106. package/src/njsSodaDocument.h +0 -105
  107. package/src/njsSodaOperation.cpp +0 -557
  108. package/src/njsSodaOperation.h +0 -123
  109. package/src/njsSubscription.cpp +0 -388
  110. package/src/njsSubscription.h +0 -111
  111. package/src/njsUtils.cpp +0 -158
  112. package/src/njsUtils.h +0 -68
package/CHANGELOG.md CHANGED
@@ -1,8 +1,135 @@
1
1
  # Change Log
2
2
 
3
+ ## node-oracledb v3.1.2 (22 Feb 2019)
4
+
5
+ - Fixed a bug causing CQN crashes when multiple queries are registered
6
+ ([ODPI-C change](https://github.com/oracle/odpi/issues/96)).
7
+
8
+ - Fixed a CQN race condition to prevent a crash when a multiple
9
+ `conn.unsubscribe()` calls are made on the same subscription.
10
+
11
+ - Improved validation of `executeMany()` arguments to prevent a crash.
12
+
13
+ - Standardized error message for SODA `createCollection()` with
14
+ invalid metadata.
15
+
16
+ - Correct the DPI-1050 error text displayed when the Oracle Client
17
+ libraries are too old ([ODPI-C change](https://github.com/oracle/odpi/commit/d2fea3801286d054e18b0102e60a69907b7faa9a)).
18
+
19
+ - Allow `npm run buildbinary` to succeed even if `git` is not
20
+ available.
21
+
22
+ - Use a relative URL for the ODPI-C submodule to make cloning from
23
+ oss.oracle.com also use ODPI-C from oss.oracle.com
24
+
25
+ ## node-oracledb v3.1.1 (25 Jan 2019)
26
+
27
+ - Rebuild npm package to resolve Linux binary build issue.
28
+
29
+ ## node-oracledb v3.1.0 (22 Jan 2019)
30
+
31
+ - Support tagging of pooled connections when releasing them to the
32
+ connection pool. When using Oracle Client libraries 12.2 or later,
33
+ Oracle's multi-property tagging is used, and a PL/SQL "session"
34
+ state fix-up procedure can be called when a requested connection tag
35
+ does not match the actual tag. This removes the need to reset
36
+ connection session state after every `pool.getConnection()` call.
37
+
38
+ - Support a Node.js callback function for connection pools. It is
39
+ called when a connection is newly created and has never been
40
+ acquired from the pool before, or when a requested connection tag
41
+ does not match the actual tag.
42
+
43
+ - Support explicit dropping of connections from connection pools.
44
+
45
+ - Support passing parameters in `oracledb.getConnection()` (such as
46
+ `poolAlias`, `tag` and proxy authentication credentials) for use
47
+ with the pool cache.
48
+
49
+ - Support the combination of a user proxy and external authentication
50
+ with standalone connections (ODPI-C change).
51
+
52
+ - Defer initialization of the Oracle Client libraries until the first
53
+ use of `oracledb.getConnection()`, `oracledb.createPool()`,
54
+ `oracledb.oracleClientVersion`, or
55
+ `oracledb.oracleClientVersionString`.
56
+
57
+ If the Oracle Client cannot be loaded, `getConnection()` and
58
+ `createPool()` will return an error via the callback. Accessing
59
+ `oracledb.oracleClientVersion` or
60
+ `oracledb.oracleClientVersionString` with throw an error.
61
+
62
+ This change allows `require('oracledb')` to always succeed, allowing
63
+ node-oracledb constants and other attributes to be accessed even if
64
+ the Oracle Client is not installed.
65
+
66
+ This makes it easier to include node-oracledb in multi-database
67
+ applications where not all users will be accessing Oracle Database.
68
+
69
+ It allows code generation tools to access node-oracledb constants
70
+ without needing Oracle Client installed (see
71
+ [#983](https://github.com/oracle/node-oracledb/issues/983)).
72
+
73
+ Applications now have more scope to alter Oracle environment
74
+ variables referenced by the Oracle Client layer. Note it is still
75
+ recommended that the environment be set before Node.js is executed
76
+ due to potential for confusion or unexpected behavior due to
77
+ order-of-execution issues.
78
+
79
+ - Support fetching XMLTYPE columns in queries. They will return as
80
+ String limited to the VARCHAR2 length.
81
+
82
+ - Updated install processes by bundling all pre-built binaries into
83
+ the https://www.npmjs.com/package/oracledb package, removing the
84
+ need for a separate binary package download from GitHub. At runtime
85
+ an appropriate binary is loaded by `require()`, if it exists,
86
+ allowing one `node_modules/oracledb` install to be usable in
87
+ different environments.
88
+
89
+ Source code is no longer included in the npm package. It is still
90
+ available from GitHub and oss.oracle.com.
91
+
92
+ The steps for self-hosting a node-oracledb package have changed, see
93
+ [INSTALL](https://github.com/oracle/node-oracledb/blob/master/INSTALL.md#selfhost).
94
+
95
+ - Fixed a crash with high frequency notifications from CQN
96
+ ([#1009](https://github.com/oracle/node-oracledb/issues/1009)).
97
+
98
+ - Fixed `poolPingInterval` with Oracle client libraries 12.2 or later
99
+ (ODPI-C change).
100
+
101
+ - Fixed an issue with `poolPingInterval` that could cause usable
102
+ pooled connections to be unnecessarily dropped by
103
+ `connection.close()`. (ODPI-C change).
104
+
105
+ - Fixed a memory leak under certain cirumstances when pooled
106
+ connections are released back to the pool. (ODPI-C change)
107
+
108
+ - Display correct error message for SODA `createIndex()` when no
109
+ parameter is passed.
110
+
111
+ - Fixed some SODA stability issues (node-oracledb and ODPI-C changes).
112
+
113
+ - Improved the statement error white list to avoid unnecessarily
114
+ dropping statements from the statement cache (ODPI-C change).
115
+
116
+ - Made internal changes to fix V8 deprecation compilation warnings
117
+ with Node.js 10.12, and fixed other static analysis warnings.
118
+
119
+ ## node-oracledb v3.0.1 (15 Nov 2018)
120
+
121
+ - Improve validation for SODA `createDocument()` arguments.
122
+
123
+ - Stated compatibility is now for Node.js 6, 8, 10, and 11.
124
+
125
+ - Upgraded NAN dependency from 2.10 to 2.11.1.
126
+
3
127
  ## node-oracledb v3.0.0 (1 Oct 2018)
4
128
 
5
- - Added new APIs for Simple Oracle Document Access ([SODA](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#sodaoverview)), available when using Oracle Database 18.1 and Oracle client libraries version 18.3, or later.
129
+ - Added new APIs for Simple Oracle Document Access
130
+ ([SODA](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#sodaoverview)),
131
+ available when using Oracle Database 18.3 and Oracle client
132
+ libraries version 18.3, or later.
6
133
 
7
134
  - Added a `drainTime` argument to
8
135
  [`pool.close()`](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#poolclose),
@@ -68,9 +195,9 @@
68
195
  support in connection pools. This allows each connection in the
69
196
  pool to use different database credentials.
70
197
 
71
- - Added support for Oracle Database Continuous Query Notifications,
72
- allowing JavaScript methods to be called when database changes are
73
- committed.
198
+ - Added support for Oracle Database Continuous Query Notifications
199
+ (CQN), allowing JavaScript methods to be called when database
200
+ changes are committed.
74
201
 
75
202
  - Added support to `fetchAsString` and `fetchInfo` for fetching RAW
76
203
  columns as STRING (hex-encoded).
@@ -171,8 +298,8 @@
171
298
 
172
299
  ## node-oracledb v2.1.1 (16 Feb 2018)
173
300
 
174
- - Fixed regression with querystream() in Node 4 & 6.
175
- https://github.com/oracle/node-oracledb/issues/847
301
+ - Fixed regression with `queryStream()` in Node 4 & 6
302
+ ([#847](https://github.com/oracle/node-oracledb/issues/847)).
176
303
 
177
304
  ## node-oracledb v2.1.0 (15 Feb 2018)
178
305
 
@@ -365,7 +492,7 @@
365
492
  the asynchronous portion of the `close()` method, so that all other
366
493
  attempts are no-ops.
367
494
 
368
- - Relaxed the restriction preventing `oracledb.connnectionClass` being
495
+ - Relaxed the restriction preventing `oracledb.connectionClass` being
369
496
  used with dedicated connections; it previously gave ORA-56609. Now
370
497
  DRCP can now be used with dedicated connections but the
371
498
  `CLIENT_DRIVER` value in `V$SESSION_CONNECT_INFO` will not be set in
@@ -481,7 +608,7 @@
481
608
  - Move operations on REF CURSORS out of the main thread in order to
482
609
  improve performance and memory usage.
483
610
 
484
- - Relaxed the restriction preventing `oracledb.connnectionClass` being
611
+ - Relaxed the restriction preventing `oracledb.connectionClass` being
485
612
  used with dedicated connections; it previously gave ORA-56609. Now
486
613
  DRCP can now be used with dedicated connections but the
487
614
  `CLIENT_DRIVER` value in `V$SESSION_CONNECT_INFO` will not be set in
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # node-oracledb version 3.0
1
+ # node-oracledb version 3.1
2
2
 
3
3
  The node-oracledb add-on for Node.js powers high performance Oracle
4
4
  Database applications.
5
5
 
6
- Use node-oracledb to connect Node.js 6, 8 and 10 to Oracle Database.
6
+ Use node-oracledb to connect Node.js 6, 8, 10 and 11 to Oracle Database.
7
7
 
8
8
  Node-oracledb supports basic and advanced features of Oracle Database
9
9
  and Oracle Client. See the
@@ -27,8 +27,8 @@ See the [examples][30] directory. Start with
27
27
 
28
28
  ## <a name="help"></a> Help
29
29
 
30
- Issues and questions can be raised with the node-oracledb community on
31
- [GitHub][3].
30
+ Issues and questions about node-oracledb can be posted on [GitHub][3] or
31
+ [Slack][5] ([link to join Slack][6]).
32
32
 
33
33
  ## <a name="testing"></a> Tests
34
34
 
@@ -64,6 +64,8 @@ limitations under the License.
64
64
  [2]: https://oracle.github.io/node-oracledb/INSTALL.html#quickstart
65
65
  [3]: https://github.com/oracle/node-oracledb/issues
66
66
  [4]: https://oracle.github.io/node-oracledb
67
+ [5]: https://node-oracledb.slack.com/
68
+ [6]: https://node-oracledb.slack.com/join/shared_invite/enQtNDU4Mjc2NzM5OTA2LTdkMzczODY3OGY3MGI0Yjk3NmQ4NDU4MTI2OGVjNTYzMjE5OGY5YzVkNDY4MWNkNjFiMDM2ZDMwOWRjNWVhNTg
67
69
  [30]: https://github.com/oracle/node-oracledb/blob/master/examples
68
70
  [31]: https://github.com/oracle/node-oracledb/blob/master/examples/example.js#L32
69
71
  [32]: https://oracle.github.io/node-oracledb/doc/api.html
@@ -0,0 +1 @@
1
+ oracledb-abi48-darwin-x64.node v6.16.0 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Tue, 19 Feb 2019 22:43:26 GMT
@@ -0,0 +1 @@
1
+ oracledb-abi48-linux-x64.node v6.16.0 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Tue, 19 Feb 2019 23:04:20 GMT
@@ -0,0 +1 @@
1
+ oracledb-abi48-win32-x64.node v6.16.0 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Wed, 20 Feb 2019 05:36:36 GMT
@@ -0,0 +1 @@
1
+ oracledb-abi57-darwin-x64.node v8.15.0 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Tue, 19 Feb 2019 22:44:49 GMT
@@ -0,0 +1 @@
1
+ oracledb-abi57-linux-x64.node v8.15.0 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Tue, 19 Feb 2019 23:04:59 GMT
@@ -0,0 +1 @@
1
+ oracledb-abi57-win32-x64.node v8.15.0 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Wed, 20 Feb 2019 05:36:45 GMT
@@ -0,0 +1 @@
1
+ oracledb-abi64-darwin-x64.node v10.15.1 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Tue, 19 Feb 2019 22:45:35 GMT
@@ -0,0 +1 @@
1
+ oracledb-abi64-linux-x64.node v10.15.1 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Tue, 19 Feb 2019 23:06:02 GMT
@@ -0,0 +1 @@
1
+ oracledb-abi64-win32-x64.node v10.15.0 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Wed, 20 Feb 2019 05:36:58 GMT
@@ -0,0 +1 @@
1
+ oracledb-abi67-darwin-x64.node v11.10.0 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Tue, 19 Feb 2019 22:46:26 GMT
@@ -0,0 +1 @@
1
+ oracledb-abi67-linux-x64.node v11.10.0 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Tue, 19 Feb 2019 23:06:38 GMT
@@ -0,0 +1 @@
1
+ oracledb-abi67-win32-x64.node v11.10.0 e70199aedd8542402cb2c5f8d75c2f8aa621df76 5768d8f93ef9ba42e8d4a6d701ace16504debc90 Wed, 20 Feb 2019 05:37:10 GMT
package/lib/connection.js CHANGED
@@ -273,13 +273,27 @@ rollbackPromisified = nodbUtil.promisify(rollback);
273
273
 
274
274
  // This close function is used to override the close method of the Connection
275
275
  // class, which is defined in the C layer.
276
- function close(closeCb) {
276
+ function close(a1, a2) {
277
277
  var self = this;
278
+ var options = {};
279
+ var closeCb;
278
280
 
279
- nodbUtil.assert(arguments.length === 1, 'NJS-009');
280
- nodbUtil.assert(typeof closeCb === 'function', 'NJS-006', 1);
281
+ nodbUtil.assert(arguments.length >= 1 && arguments.length <= 2, 'NJS-009');
282
+
283
+ switch (arguments.length) {
284
+ case 1:
285
+ nodbUtil.assert(typeof a1 === 'function', 'NJS-006', 1);
286
+ closeCb = a1;
287
+ break;
288
+ case 2:
289
+ nodbUtil.assert(nodbUtil.isObject(a1), 'NJS-006', 1);
290
+ nodbUtil.assert(typeof a2 === 'function', 'NJS-006', 2);
291
+ options = a1;
292
+ closeCb = a2;
293
+ break;
294
+ }
281
295
 
282
- self._close(function(err) {
296
+ self._close(options, function(err) {
283
297
  if (!err) {
284
298
  self.emit('_after_close');
285
299
  }
package/lib/oracledb.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. */
1
+ /* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. */
2
2
 
3
3
  /******************************************************************************
4
4
  *
@@ -30,112 +30,45 @@ var getConnectionPromisified;
30
30
  var poolCache = {};
31
31
  var tempUsedPoolAliases = {};
32
32
  var defaultPoolAlias = 'default';
33
- var binaryReleasePath = '../build/Release/oracledb.node';
34
- var binaryDebugPath = '../build/Debug/oracledb.node';
35
-
36
- // Load the node-oracledb binary add-on that was built when 'npm
37
- // install' invoked node-gyp.
38
- // The Debug version of node-oracledb will only exist if 'npm install
39
- // --debug oracledb' was used. Typically only the maintainers of
40
- // node-oracledb do this.
41
- try {
42
- oracledbCLib = require(binaryReleasePath);
43
- } catch (err) {
44
- var nodeInfo = process.versions.node + ' (' + process.platform + ', ' + process.arch +')\n';
45
- var fullReleasePath = require('path').resolve(__dirname, binaryReleasePath);
46
- if (err.code === 'MODULE_NOT_FOUND') {
47
- try {
48
- oracledbCLib = require(binaryDebugPath);
49
- } catch (err) {
33
+
34
+ // Load the Oracledb binary
35
+
36
+ var binaryLocations = [
37
+ '../' + nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE, // pre-built binary
38
+ '../' + nodbUtil.RELEASE_DIR + '/' + 'oracledb.node', // binary built from source
39
+ '../build/Debug/oracledb.node' // debug binary
40
+ ];
41
+
42
+ for (var i = 0; i < binaryLocations.length; i++) {
43
+ try {
44
+ oracledbCLib = require(binaryLocations[i]);
45
+ break;
46
+ } catch(err) {
47
+ if (err.code !== 'MODULE_NOT_FOUND' || i == binaryLocations.length - 1) {
48
+ var nodeInfo;
50
49
  if (err.code === 'MODULE_NOT_FOUND') {
51
- // Neither Release or Debug binary was found but assume users wanted Release binary
52
- nodeInfo += 'Cannot find module ' + fullReleasePath + '\n' + getInfo();
53
- throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
50
+ // none of the three binaries could be found
51
+ nodeInfo = `\n Looked for ${binaryLocations.map(x => require('path').resolve(__dirname, x)).join(', ')}\n ${nodbUtil.getInstallURL()}\n`;
54
52
  } else {
55
- nodeInfo += 'Cannot load ' + binaryDebugPath + '\n';
56
- nodeInfo += 'Node.js require() error was: \n ' + err.message + '\n' + getInfo();
57
- throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
53
+ nodeInfo = `\n Node.js require('oracledb') error was:\n ${err.message}\n ${nodbUtil.getInstallHelp()}\n`;
58
54
  }
59
- }
60
- } else {
61
- if (err.message.startsWith('DPI-1047:')) {
62
- // Release add-on binary loaded OK, but ODPI-C can't load Oracle client
63
- nodeInfo += 'Node.js require() error was: \n ' + err.message + '\n';
64
- nodeInfo += 'Node.js require() mapped to ' + fullReleasePath + '\n' + getInfo();
65
- throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
66
- } else {
67
- nodeInfo += 'Cannot load ' + fullReleasePath + '\n' + err.message + '\n' + getInfo();
68
55
  throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
69
56
  }
70
57
  }
71
58
  }
72
59
 
60
+ // Oracledb functions and classes
61
+
73
62
  oracledbCLib.Oracledb.prototype.newLob = function(iLob) {
74
63
  return new Lob(iLob, null, oracledbInst);
75
64
  };
76
65
 
77
-
78
- // Return a string with installation usage tips that may be helpful
79
- function getInfo() {
80
- var arch, url, mesg = '';
81
- mesg = 'Node-oracledb installation instructions: ';
82
- mesg += 'https://oracle.github.io/node-oracledb/INSTALL.html\n';
83
- if (process.platform === 'linux') {
84
- if (process.arch === 'x64') {
85
- url = 'http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html\n';
86
- arch = '64-bit';
87
- } else if (process.arch === 'x32') {
88
- url = 'http://www.oracle.com/technetwork/topics/linuxsoft-082809.html\n';
89
- arch = '32-bit';
90
- } else {
91
- url = 'http://www.oracle.com/technetwork/database/database-technologies/instant-client/overview/index.html\n';
92
- arch = process.arch;
93
- }
94
- mesg += 'You must have ' + arch + ' Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.\n';
95
- mesg += 'If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from \n';
96
- mesg += url;
97
- } else if (process.platform === 'darwin') {
98
- if (process.arch === 'x64') {
99
- url = 'http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html';
100
- arch = '64-bit';
101
- } else if (process.arch === 'x32') {
102
- url = 'http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html';
103
- arch = '32-bit';
104
- } else {
105
- url = 'http://www.oracle.com/technetwork/database/database-technologies/instant-client/overview/index.html\n';
106
- arch = process.arch;
107
- }
108
- mesg += 'You must have the ' + arch + ' Oracle Instant Client Basic or Basic Light package in ~/lib or /usr/local/lib\n';
109
- mesg += 'They can be downloaded from ' + url;
110
- } else if (process.platform === 'win32') {
111
- if (process.arch === 'x64') {
112
- url = 'http://www.oracle.com/technetwork/topics/winx64soft-089540.html\n';
113
- arch = '64-bit';
114
- } else if (process.arch === 'x32') {
115
- url = 'http://www.oracle.com/technetwork/topics/winsoft-085727.html\n';
116
- arch = '32-bit';
117
- } else {
118
- url = 'http://www.oracle.com/technetwork/database/database-technologies/instant-client/overview/index.html\n';
119
- arch = process.arch;
120
- }
121
- mesg += 'You must have ' + arch + ' Oracle client libraries in your PATH environment variable.\n';
122
- mesg += 'If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from\n';
123
- mesg += url;
124
- mesg += 'A Microsoft Visual Studio Redistributable suitable for your Oracle client library version must be available.\n';
125
- } else {
126
- url = 'http://www.oracle.com/technetwork/database/database-technologies/instant-client/overview/index.html\n';
127
- mesg += 'You must have ' + process.arch + ' Oracle client libraries in your operating system library search path.\n';
128
- mesg += 'If you do not have Oracle Database on this computer, then install an Instant Client Basic or Basic Light package from: \n';
129
- mesg += url;
130
- }
131
- return mesg;
132
- }
133
-
134
66
  // This createPool function is used the override the createPool method of the
135
67
  // Oracledb class, which is defined in the C layer. The override allows us to do
136
68
  // things like extend out the pool instance prior to passing it to the caller.
137
69
  function createPool(poolAttrs, createPoolCb) {
138
70
  var self = this;
71
+ var sessionCallback;
139
72
  var poolAlias;
140
73
 
141
74
  // Initial argument count and type checks are done first and throw in the same
@@ -170,6 +103,18 @@ function createPool(poolAttrs, createPoolCb) {
170
103
  return;
171
104
  }
172
105
 
106
+ // Retain local callback for fixing up tags on connections acquired from the
107
+ // pool, if applicable; this value can either be a function which will be
108
+ // called when a connection is acquired from the pool which doesn't have the
109
+ // requested tag or will be a string defining a PL/SQL procedure which will
110
+ // be called by the database when a connection acquired from the pool doesn't
111
+ // have the requested tag
112
+ sessionCallback = poolAttrs.sessionCallback;
113
+ if (typeof poolAttrs.sessionCallback === 'function') {
114
+ poolAttrs = Object.assign({}, poolAttrs);
115
+ delete poolAttrs.sessionCallback;
116
+ }
117
+
173
118
  // Need to prevent another call in the same stack from succeeding, otherwise
174
119
  // two pools could be created with the same poolAlias and the second one that
175
120
  // comes back would overwrite the first in the cache.
@@ -184,6 +129,9 @@ function createPool(poolAttrs, createPoolCb) {
184
129
  delete tempUsedPoolAliases[poolAlias];
185
130
  }
186
131
 
132
+ if (err.message.match(/DPI-1047/)) {
133
+ err.message += "\n" + nodbUtil.getInstallHelp();
134
+ }
187
135
  createPoolCb(err);
188
136
 
189
137
  return;
@@ -196,6 +144,7 @@ function createPool(poolAttrs, createPoolCb) {
196
144
  delete tempUsedPoolAliases[poolAlias];
197
145
  }
198
146
 
147
+ poolAttrs.sessionCallback = sessionCallback;
199
148
  pool.extend(poolInst, poolAttrs, poolAlias, self);
200
149
 
201
150
  poolInst.on('_after_close', function() {
@@ -241,7 +190,7 @@ function getConnection(a1, a2) {
241
190
  var self = this;
242
191
  var pool;
243
192
  var poolAlias;
244
- var connAttrs;
193
+ var connAttrs = {};
245
194
  var getConnectionCb;
246
195
 
247
196
  nodbUtil.assert(arguments.length < 3, 'NJS-009');
@@ -285,7 +234,7 @@ function getConnection(a1, a2) {
285
234
  return;
286
235
  }
287
236
 
288
- pool.getConnection(getConnectionCb);
237
+ pool.getConnection(connAttrs, getConnectionCb);
289
238
  } else {
290
239
  // Allow user to use connectionString as an alias for connectString.
291
240
  if (connAttrs.connectString === undefined) {
@@ -294,6 +243,9 @@ function getConnection(a1, a2) {
294
243
 
295
244
  self._getConnection(connAttrs, function(err, connInst) {
296
245
  if (err) {
246
+ if (err.message.match(/DPI-1047/)) {
247
+ err.message += "\n" + nodbUtil.getInstallHelp();
248
+ }
297
249
  getConnectionCb(err);
298
250
  return;
299
251
  }
package/lib/pool.js CHANGED
@@ -34,7 +34,7 @@ function completeConnectionRequest(config, getConnectionCb) {
34
34
  // to prevent other connection requests from exceeding the poolMax.
35
35
  self._connectionsOut += 1;
36
36
 
37
- self._getConnection(config, function(err, connInst) {
37
+ self._getConnection(config, function(err, connInst, newSession) {
38
38
  if (err) {
39
39
  // Decrementing _connectionsOut if we didn't actually get a connection
40
40
  // and then rechecking the queue.
@@ -63,7 +63,28 @@ function completeConnectionRequest(config, getConnectionCb) {
63
63
  checkRequestQueue.call(self);
64
64
  });
65
65
 
66
- getConnectionCb(null, connInst);
66
+ // Invoke tag fixup callback method if one has been specified and
67
+ // the actual tag on the connection doesn't match the one
68
+ // requested, or the connection is freshly created.
69
+ let requestedTag = config.tag || "";
70
+ if (typeof self.sessionCallback === 'function' &&
71
+ (newSession || connInst.tag != requestedTag)) {
72
+ self.sessionCallback(connInst, requestedTag,
73
+ function(err) {
74
+ if (err) {
75
+ connInst.close({drop: true}, function() {
76
+ getConnectionCb(err);
77
+ });
78
+ return;
79
+ }
80
+ getConnectionCb(null, connInst);
81
+ }
82
+ );
83
+
84
+ // otherwise, simply invoke the user's callback immediately
85
+ } else {
86
+ getConnectionCb(null, connInst);
87
+ }
67
88
  });
68
89
  }
69
90
 
@@ -326,6 +347,9 @@ function logStats() {
326
347
  console.log('...poolIncrement:', self.poolIncrement);
327
348
  console.log('...poolTimeout (seconds):', self.poolTimeout);
328
349
  console.log('...poolPingInterval:', self.poolPingInterval);
350
+ console.log('...sessionCallback:',
351
+ typeof self.sessionCallback === 'function' ? self.sessionCallback.name :
352
+ (typeof self.sessionCallback === 'string' ? '"' + self.sessionCallback + '"' : self.sessionCallback));
329
353
  console.log('...stmtCacheSize:', self.stmtCacheSize);
330
354
  console.log('Pool status:');
331
355
  console.log('...status:', self.status);
@@ -465,6 +489,16 @@ function extend(pool, poolAttrs, poolAlias, oracledb) {
465
489
  writable: true,
466
490
  enumerable: true,
467
491
  value: oracledb.POOL_STATUS_OPEN
492
+ },
493
+ sessionCallback: { // session callback
494
+ enumerable: true,
495
+ get: function() {
496
+ return poolAttrs.sessionCallback;
497
+ },
498
+ set: function() {
499
+ throw new Error(nodbUtil.getErrorMessage('NJS-014',
500
+ 'sessionCallback'));
501
+ }
468
502
  }
469
503
  }
470
504
  );
@@ -92,7 +92,7 @@ insertOneAndGetPromisified = nodbUtil.promisify(insertOneAndGet);
92
92
  function createIndex(spec, cb) {
93
93
  var self = this;
94
94
 
95
- nodbUtil.assert(arguments.length === 2, 'NUS-009', 1);
95
+ nodbUtil.assert(arguments.length === 2, 'NJS-009', 1);
96
96
  nodbUtil.assert(nodbUtil.isObject(spec), 'NJS-006', 1);
97
97
  nodbUtil.assert(typeof cb === 'function', 'NJS-006', 2);
98
98
 
@@ -49,7 +49,7 @@ function createCollection(name, a2, a3) {
49
49
  createCollCb = a3;
50
50
  if (options.metaData) {
51
51
  if (!nodbUtil.isObject(options.metaData)) {
52
- createCollCb(Error(nodbUtil.getErrorMessage('NJS-006', 3)));
52
+ createCollCb(Error(nodbUtil.getErrorMessage('NJS-006', 2)));
53
53
  return;
54
54
  }
55
55
  options.metaData = JSON.stringify(options.metaData);