oracledb 2.1.0 → 2.3.0
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.
- package/CHANGELOG.md +174 -54
- package/LICENSE.md +52 -18
- package/README.md +35 -68
- package/binding.gyp +5 -4
- package/lib/connection.js +164 -14
- package/lib/oracledb.js +160 -11
- package/lib/pool.js +33 -22
- package/lib/querystream.js +3 -2
- package/lib/rel.txt +1 -1
- package/odpi/LICENSE.md +1 -1
- package/odpi/README.md +25 -84
- package/odpi/embed/README.md +1 -1
- package/odpi/include/dpi.h +51 -7
- package/odpi/src/dpiConn.c +78 -9
- package/odpi/src/dpiContext.c +24 -10
- package/odpi/src/dpiEnv.c +5 -1
- package/odpi/src/dpiError.c +4 -0
- package/odpi/src/dpiErrorMessages.h +6 -4
- package/odpi/src/dpiImpl.h +125 -68
- package/odpi/src/dpiMsgProps.c +33 -0
- package/odpi/src/dpiObject.c +17 -10
- package/odpi/src/dpiObjectType.c +1 -1
- package/odpi/src/dpiOci.c +55 -40
- package/odpi/src/dpiOracleType.c +2 -2
- package/odpi/src/dpiPool.c +88 -18
- package/odpi/src/dpiStmt.c +57 -36
- package/odpi/src/dpiSubscr.c +117 -9
- package/odpi/src/dpiUtils.c +20 -9
- package/odpi/src/dpiVar.c +504 -430
- package/package/MAKEPKG.BAT +64 -1
- package/package/README.md +9 -5
- package/package/createpackage.js +2 -2
- package/package/extractpackage.js +2 -1
- package/package/oracledbinstall.js +19 -19
- package/package/package.json +4 -4
- package/package.json +4 -4
- package/src/njsCommon.cpp +94 -10
- package/src/njsCommon.h +73 -21
- package/src/njsConnection.cpp +1425 -458
- package/src/njsConnection.h +68 -19
- package/src/njsIntLob.cpp +5 -1
- package/src/njsIntLob.h +1 -1
- package/src/njsMessages.cpp +9 -2
- package/src/njsMessages.h +9 -2
- package/src/njsOracle.cpp +213 -23
- package/src/njsOracle.h +18 -2
- package/src/njsPool.cpp +32 -14
- package/src/njsPool.h +4 -4
- package/src/njsResultSet.cpp +4 -3
- package/src/njsResultSet.h +1 -1
- package/src/njsSubscription.cpp +388 -0
- package/src/njsSubscription.h +111 -0
package/package/MAKEPKG.BAT
CHANGED
|
@@ -26,7 +26,8 @@ REM ****************************************************************************
|
|
|
26
26
|
|
|
27
27
|
REM
|
|
28
28
|
REM usage: MAKEPKG.BAT [<cmd>]
|
|
29
|
-
REM : Possible values for <cmd> are: CLEANUP
|
|
29
|
+
REM : Possible values for <cmd> are: CLEANUP, CREATEBINARY
|
|
30
|
+
REM and CREATESTAGEBINARY
|
|
30
31
|
REM
|
|
31
32
|
REM expected to run this batch file from package sub-directory,
|
|
32
33
|
REM where a fresh clone is created.
|
|
@@ -38,6 +39,7 @@ if "%1" == "" GOTO usage
|
|
|
38
39
|
REM jump to appropriate sections based on <cmd>
|
|
39
40
|
if "%1" == "CLEANUP" GOTO cleanup
|
|
40
41
|
if "%1" == "CREATEBINARY" GOTO createbinary
|
|
42
|
+
if "%1" == "CREATESTAGEBINARY" GOTO createstagebinary
|
|
41
43
|
goto usage
|
|
42
44
|
|
|
43
45
|
REM cleanup section, remove file(s) created by this batch file
|
|
@@ -47,6 +49,67 @@ del ..\package-lock.json
|
|
|
47
49
|
del SHASUMS256.txt oracledb-v*-node-*.gz
|
|
48
50
|
goto exit
|
|
49
51
|
|
|
52
|
+
|
|
53
|
+
REM compile, package to gz file
|
|
54
|
+
:createstagebinary
|
|
55
|
+
echo "createstagebinary section"
|
|
56
|
+
|
|
57
|
+
REM Append SHA to LICENSE.MD
|
|
58
|
+
git checkout ..\LICENSE.md
|
|
59
|
+
setlocal enabledelayedexpansion
|
|
60
|
+
REM compose a string with commands to execute one by one
|
|
61
|
+
|
|
62
|
+
REM start with empty string
|
|
63
|
+
set CONCAT_STR=
|
|
64
|
+
REM capture SHA
|
|
65
|
+
FOR /F "tokens=* USEBACKQ" %%F IN (`git --git-dir=..\.git rev-parse HEAD`) DO (
|
|
66
|
+
SET CONCAT_STR=%%F
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
set DATE_STR=
|
|
70
|
+
FOR /F "tokens=* USEBACKQ" %%F IN (`DATE /T`) DO ( SET DATE_STR=%%F )
|
|
71
|
+
|
|
72
|
+
REM append output of other commands
|
|
73
|
+
set CMD_STR="git --git-dir=..\odpi\.git rev-parse HEAD && node --version"
|
|
74
|
+
for /f %%i in ('%CMD_STR%') do set "CONCAT_STR=!CONCAT_STR! %%i"
|
|
75
|
+
set CONCAT_STR=!CONCAT_STR! !DATE_STR!
|
|
76
|
+
echo !CONCAT_STR! >> ..\LICENSE.MD
|
|
77
|
+
|
|
78
|
+
REM Compile node-oracledb
|
|
79
|
+
cd ..
|
|
80
|
+
CALL npm install
|
|
81
|
+
echo "NODE oracledb compiled"
|
|
82
|
+
cd package
|
|
83
|
+
echo "==> Staging Binary package created for Node.js "
|
|
84
|
+
|
|
85
|
+
Set "hostname=%NODE_ORACLEDB_PACKAGE_HOSTNAME%"
|
|
86
|
+
Set "pathname=%NODE_ORACLEDB_PACKAGE_URL_PATH%"
|
|
87
|
+
Set "newname=%NODE_PKG_HOSTNAME%"
|
|
88
|
+
echo ON
|
|
89
|
+
echo %hostname%
|
|
90
|
+
echo %pathname%
|
|
91
|
+
echo %newname%
|
|
92
|
+
|
|
93
|
+
sed "s/github.com/%hostname%/g" oracledbinstall.js
|
|
94
|
+
sed "s/oracle\/node-oracledb\/releases\/download\//%pathname%/g" oracledbinstall.js
|
|
95
|
+
|
|
96
|
+
del /S *.gz
|
|
97
|
+
|
|
98
|
+
node createpackage.js
|
|
99
|
+
xcopy /Y "package.json" "../package.json"
|
|
100
|
+
npm pack
|
|
101
|
+
Setlocal enabledelayedexpansion
|
|
102
|
+
|
|
103
|
+
Set "Pattern=oracledb"
|
|
104
|
+
Set "Replace=oracledb-staging"
|
|
105
|
+
|
|
106
|
+
For %%a in (*.gz) Do (
|
|
107
|
+
Set "File=%%~a"
|
|
108
|
+
Ren "%%a" "!File:%Pattern%=%Replace%!"
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
goto exit
|
|
112
|
+
|
|
50
113
|
REM compile, package to gz file
|
|
51
114
|
:createbinary
|
|
52
115
|
echo "createbinary section"
|
package/package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
This directory contains scripts for building, extracting and
|
|
4
4
|
installing binary packages of node-oracledb. Most users do not need
|
|
5
|
-
to use anything in this directory (the
|
|
6
|
-
[manual
|
|
7
|
-
install](https://github.
|
|
5
|
+
to use anything in this directory (the exceptions are when building
|
|
6
|
+
packages for self-hosting, or when doing a [manual
|
|
7
|
+
install](https://oracle.github.io/node-oracledb/INSTALL.html#manualextraction)
|
|
8
8
|
instead of using `npm`).
|
|
9
9
|
|
|
10
10
|
The binary install process requires two kinds of package:
|
|
@@ -35,7 +35,7 @@ binary.
|
|
|
35
35
|
If a suitable binary package is not available, users must compile
|
|
36
36
|
source code by installing from GitHub.
|
|
37
37
|
|
|
38
|
-
Installation is described in [INSTALL](
|
|
38
|
+
Installation is described in [INSTALL](https://oracle.github.io/node-oracledb/INSTALL.html).
|
|
39
39
|
|
|
40
40
|
# Maintainers
|
|
41
41
|
|
|
@@ -76,7 +76,7 @@ Installation is described in [INSTALL](../INSTALL.md).
|
|
|
76
76
|
before running `make`.
|
|
77
77
|
|
|
78
78
|
- `oracledb-src-X.Y.Z.tgz` which is the complete source code, mainly
|
|
79
|
-
created because older npm's (e.g. with Node 4) do not download the
|
|
79
|
+
created because older npm's (e.g. with Node.js 4) do not download the
|
|
80
80
|
opdi submodule code when installing from a GitHub tag or branch.
|
|
81
81
|
|
|
82
82
|
- The`staging-oracledb-X.Y.Z.tgz` package can be used to host binaries
|
|
@@ -98,6 +98,9 @@ Installation is described in [INSTALL](../INSTALL.md).
|
|
|
98
98
|
Remember to do `npm config delete strict-ssl` and unset the
|
|
99
99
|
environment variable when not testing.
|
|
100
100
|
|
|
101
|
+
- On Windows, MAKEPKG.BAT has command options to create binaries, and
|
|
102
|
+
also to create staged binaries and the main packages.
|
|
103
|
+
|
|
101
104
|
- At install time, setting the environment variable
|
|
102
105
|
`NODE_ORACLEDB_TRACE_INSTALL` to `TRUE` will cause `npm install` to
|
|
103
106
|
display more tracing information.
|
|
@@ -108,4 +111,5 @@ Installation is described in [INSTALL](../INSTALL.md).
|
|
|
108
111
|
- TODO
|
|
109
112
|
|
|
110
113
|
- oracledbinstall.js should cache SHASUMS256.txt so it doesn't have to be fetched twice.
|
|
114
|
+
- Add support for proxies that require authentication
|
|
111
115
|
- Improve oracledbinstall.js `no_proxy` support for domain names and wildcards.
|
package/package/createpackage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */
|
|
1
|
+
/* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
/******************************************************************************
|
|
4
4
|
*
|
|
@@ -180,7 +180,7 @@ function createPackage() {
|
|
|
180
180
|
})
|
|
181
181
|
.catch(err => {
|
|
182
182
|
console.log('Error creating package', err);
|
|
183
|
-
})
|
|
183
|
+
});
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
createPackage();
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
*
|
|
21
21
|
* DESCRIPTION
|
|
22
22
|
* This script is a command-line interface to extract node-oracledb
|
|
23
|
-
* binaries from an available binary package, see
|
|
23
|
+
* binaries from an available binary package, see
|
|
24
|
+
* https://oracle.github.io/node-oracledb/INSTALL.html
|
|
24
25
|
*
|
|
25
26
|
* USAGE
|
|
26
27
|
* Run this script like:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */
|
|
1
|
+
/* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
/******************************************************************************
|
|
4
4
|
*
|
|
@@ -38,8 +38,6 @@ const http = require('http'); // Fails in old Node.js. Use Node 4+
|
|
|
38
38
|
const https = require('https');
|
|
39
39
|
const fs = require('fs');
|
|
40
40
|
const url = require('url');
|
|
41
|
-
const stream = require('stream');
|
|
42
|
-
const zlib = require('zlib');
|
|
43
41
|
const packageUtil = require('./util.js');
|
|
44
42
|
|
|
45
43
|
packageUtil.initDynamicProps();
|
|
@@ -124,8 +122,6 @@ function verifyBinary() {
|
|
|
124
122
|
packageUtil.log('Verifying installation');
|
|
125
123
|
|
|
126
124
|
if (!fs.existsSync(packageUtil.BINARY_PATH_LOCAL)) {
|
|
127
|
-
packageUtil.log('Binary not found');
|
|
128
|
-
|
|
129
125
|
resolve(false);
|
|
130
126
|
return;
|
|
131
127
|
}
|
|
@@ -181,7 +177,7 @@ function getRemoteFileReadStream(hostname, path) {
|
|
|
181
177
|
const proxyConfig = getProxyConfig(hostname);
|
|
182
178
|
|
|
183
179
|
if (proxyConfig.useProxy) {
|
|
184
|
-
return getFileReadStreamByProxy(hostname, path, proxyConfig.hostname, proxyConfig.port)
|
|
180
|
+
return getFileReadStreamByProxy(hostname, path, proxyConfig.hostname, proxyConfig.port);
|
|
185
181
|
} else {
|
|
186
182
|
return getFileReadStreamBase(hostname, path);
|
|
187
183
|
}
|
|
@@ -200,7 +196,7 @@ function getFileReadStreamByProxy(hostname, path, proxyHostname, proxyPort) {
|
|
|
200
196
|
method: 'CONNECT',
|
|
201
197
|
path: hostname + ':' + PORT,
|
|
202
198
|
headers: {
|
|
203
|
-
'host': hostname + PORT,
|
|
199
|
+
'host': hostname + ':' + PORT,
|
|
204
200
|
}
|
|
205
201
|
});
|
|
206
202
|
|
|
@@ -211,12 +207,12 @@ function getFileReadStreamByProxy(hostname, path, proxyHostname, proxyPort) {
|
|
|
211
207
|
|
|
212
208
|
req.on('connect', function(res, socket) {
|
|
213
209
|
if (res.statusCode >= 300 && res.statusCode < 400) { // warning: proxy redirection code is untested
|
|
214
|
-
|
|
210
|
+
const redirectUrl = url.parse(res.headers.location);
|
|
215
211
|
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
proxyHostname = redirectUrl.hostname;
|
|
213
|
+
proxyPort = redirectUrl.port;
|
|
218
214
|
|
|
219
|
-
|
|
215
|
+
return getFileReadStreamByProxy(hostname, path, proxyHostname, proxyPort);
|
|
220
216
|
} else if (res.statusCode !== 200) {
|
|
221
217
|
reject(new Error('Error: HTTP proxy request for ' + hostname + path + ' failed with code ' + res.statusCode));
|
|
222
218
|
return;
|
|
@@ -339,16 +335,20 @@ function installBinary() {
|
|
|
339
335
|
|
|
340
336
|
// The done function is used to print concluding messages and quit.
|
|
341
337
|
function done(err, alreadyInstalled) {
|
|
342
|
-
const installUrl = 'https://github.
|
|
338
|
+
const installUrl = 'https://oracle.github.io/node-oracledb/INSTALL.html';
|
|
343
339
|
|
|
344
340
|
if (err) {
|
|
345
|
-
packageUtil.error('NJS-054: Binary build/Release/oracledb.node was not installed
|
|
341
|
+
packageUtil.error('NJS-054: Binary build/Release/oracledb.node was not installed.');
|
|
342
|
+
if (['darwin', 'win32', 'linux'].indexOf(process.platform) < 0) {
|
|
343
|
+
packageUtil.error('Pre-built binary packages are not available for platform="' + process.platform + '"');
|
|
344
|
+
} else if (process.arch !== 'x64') {
|
|
345
|
+
packageUtil.error('Pre-built binary packages are not available for architecture="' + process.arch + '"');
|
|
346
|
+
} else if (['48', '57', '64'].indexOf(process.versions.modules) < 0) {
|
|
347
|
+
packageUtil.error('Pre-built binary packages are not available for this version of Node.js (NODE_MODULE_VERSION="' + process.versions.modules + '")');
|
|
348
|
+
}
|
|
349
|
+
packageUtil.error('Failed to install binary package ' + packageUtil.dynamicProps.PACKAGE_FILE_NAME);
|
|
346
350
|
packageUtil.error(err.message);
|
|
347
|
-
packageUtil.error('
|
|
348
|
-
packageUtil.error('the Python 2.7 and compiler prerequisites in the installation instructions and');
|
|
349
|
-
packageUtil.error('then install from source code with: npm install oracle/node-oracledb.git#' + packageUtil.dynamicProps.GITHUB_TAG);
|
|
350
|
-
packageUtil.error('See ' + installUrl, '\n');
|
|
351
|
-
|
|
351
|
+
packageUtil.error('For help see ' + installUrl + '#troubleshooting\n');
|
|
352
352
|
process.exit(87);
|
|
353
353
|
} else {
|
|
354
354
|
let arch;
|
|
@@ -436,7 +436,7 @@ function install() {
|
|
|
436
436
|
return new Promise((resolve, reject) => {
|
|
437
437
|
installBinary()
|
|
438
438
|
.then(() => {
|
|
439
|
-
packageUtil.log('Oracledb
|
|
439
|
+
packageUtil.log('Oracledb downloaded');
|
|
440
440
|
|
|
441
441
|
return verifyBinary();
|
|
442
442
|
})
|
package/package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oracledb",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "A Node.js module for Oracle Database access",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"homepage": "http://
|
|
6
|
+
"homepage": "http://oracle.github.io/node-oracledb/",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"Oracle",
|
|
9
9
|
"Database",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"install": "node package/oracledbinstall.js",
|
|
38
38
|
"test": "mocha --opts test/opts/mocha.opts",
|
|
39
|
-
"posttest": "node
|
|
39
|
+
"posttest": "node test/opts/version.js"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=4"
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oracledb",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "A Node.js module for Oracle Database access",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"homepage": "http://
|
|
6
|
+
"homepage": "http://oracle.github.io/node-oracledb/",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"Oracle",
|
|
9
9
|
"Database",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"install": "node package/oracledbinstall.js",
|
|
38
38
|
"test": "mocha --opts test/opts/mocha.opts",
|
|
39
|
-
"posttest": "node
|
|
39
|
+
"posttest": "node test/opts/version.js"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=4"
|
package/src/njsCommon.cpp
CHANGED
|
@@ -52,11 +52,26 @@
|
|
|
52
52
|
#include "njsCommon.h"
|
|
53
53
|
#include "njsOracle.h"
|
|
54
54
|
#include "njsIntLob.h"
|
|
55
|
+
#include "njsSubscription.h"
|
|
55
56
|
|
|
56
57
|
using namespace node;
|
|
57
58
|
using namespace std;
|
|
58
59
|
using namespace v8;
|
|
59
60
|
|
|
61
|
+
//-----------------------------------------------------------------------------
|
|
62
|
+
// njsVariableBuffer::~njsVariableBuffer()
|
|
63
|
+
// Destructor.
|
|
64
|
+
//-----------------------------------------------------------------------------
|
|
65
|
+
njsVariableBuffer::~njsVariableBuffer()
|
|
66
|
+
{
|
|
67
|
+
if (lobs) {
|
|
68
|
+
delete [] lobs;
|
|
69
|
+
lobs = NULL;
|
|
70
|
+
}
|
|
71
|
+
dpiVarData = NULL;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
60
75
|
//-----------------------------------------------------------------------------
|
|
61
76
|
// njsVariable::~njsVariable()
|
|
62
77
|
// Destructor.
|
|
@@ -66,11 +81,10 @@ njsVariable::~njsVariable()
|
|
|
66
81
|
if (dpiVarHandle) {
|
|
67
82
|
dpiVar_release(dpiVarHandle);
|
|
68
83
|
dpiVarHandle = NULL;
|
|
69
|
-
dpiVarData = NULL;
|
|
70
84
|
}
|
|
71
|
-
if (
|
|
72
|
-
delete []
|
|
73
|
-
|
|
85
|
+
if (dmlReturningBuffers) {
|
|
86
|
+
delete [] dmlReturningBuffers;
|
|
87
|
+
dmlReturningBuffers = NULL;
|
|
74
88
|
}
|
|
75
89
|
if (queryVars) {
|
|
76
90
|
delete [] queryVars;
|
|
@@ -180,6 +194,7 @@ njsBaton::~njsBaton()
|
|
|
180
194
|
jsCallback.Reset();
|
|
181
195
|
jsCallingObj.Reset();
|
|
182
196
|
jsOracledb.Reset();
|
|
197
|
+
jsSubscription.Reset();
|
|
183
198
|
jsBuffer.Reset();
|
|
184
199
|
ClearAsyncData();
|
|
185
200
|
}
|
|
@@ -196,7 +211,7 @@ void njsBaton::CheckJSException(Nan::TryCatch *tryCatch)
|
|
|
196
211
|
{
|
|
197
212
|
if (tryCatch->HasCaught()) {
|
|
198
213
|
Local<String> message = tryCatch->Message()->Get();
|
|
199
|
-
|
|
214
|
+
Nan::Utf8String v8str(message->ToString());
|
|
200
215
|
error = std::string(*v8str, static_cast<size_t>(v8str.length()));
|
|
201
216
|
tryCatch->Reset();
|
|
202
217
|
}
|
|
@@ -226,6 +241,10 @@ void njsBaton::ClearAsyncData()
|
|
|
226
241
|
dpiLob_release(dpiLobHandle);
|
|
227
242
|
dpiLobHandle = NULL;
|
|
228
243
|
}
|
|
244
|
+
if (dpiSubscrHandle) {
|
|
245
|
+
dpiSubscr_release(dpiSubscrHandle);
|
|
246
|
+
dpiSubscrHandle = NULL;
|
|
247
|
+
}
|
|
229
248
|
if (bindVars) {
|
|
230
249
|
delete [] bindVars;
|
|
231
250
|
bindVars = NULL;
|
|
@@ -255,6 +274,11 @@ void njsBaton::ClearAsyncData()
|
|
|
255
274
|
fetchAsBufferTypes = NULL;
|
|
256
275
|
numFetchAsBufferTypes = 0;
|
|
257
276
|
}
|
|
277
|
+
if (batchErrorInfos) {
|
|
278
|
+
delete [] batchErrorInfos;
|
|
279
|
+
batchErrorInfos = NULL;
|
|
280
|
+
numBatchErrorInfos = 0;
|
|
281
|
+
}
|
|
258
282
|
}
|
|
259
283
|
|
|
260
284
|
|
|
@@ -339,8 +363,11 @@ void njsBaton::AsyncAfterWorkCallback(uv_work_t *req, int status)
|
|
|
339
363
|
delete baton;
|
|
340
364
|
|
|
341
365
|
// make JS callback
|
|
342
|
-
Nan::
|
|
343
|
-
|
|
366
|
+
Nan::AsyncResource *asyncResource =
|
|
367
|
+
new Nan::AsyncResource("node-oracledb");
|
|
368
|
+
asyncResource->runInAsyncScope(Nan::GetCurrentContext()->Global(),
|
|
369
|
+
callback, static_cast<int>(numCallbackArgs), callbackArgs);
|
|
370
|
+
delete asyncResource;
|
|
344
371
|
|
|
345
372
|
// we no longer need the callback args
|
|
346
373
|
delete [] callbackArgs;
|
|
@@ -422,6 +449,19 @@ void njsBaton::SetDPILobHandle(dpiLob *handle)
|
|
|
422
449
|
}
|
|
423
450
|
|
|
424
451
|
|
|
452
|
+
//-----------------------------------------------------------------------------
|
|
453
|
+
// njsBaton::SetDPISubscrHandle()
|
|
454
|
+
// Set the DPI subscription handle. This adds a reference to the DPI
|
|
455
|
+
// subscription which will be released in the destructor.
|
|
456
|
+
//-----------------------------------------------------------------------------
|
|
457
|
+
void njsBaton::SetDPISubscrHandle(dpiSubscr *handle)
|
|
458
|
+
{
|
|
459
|
+
if (dpiSubscr_addRef(handle) < 0)
|
|
460
|
+
GetDPIError();
|
|
461
|
+
else dpiSubscrHandle = handle;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
|
|
425
465
|
//-----------------------------------------------------------------------------
|
|
426
466
|
// njsBaton::GetBoolFromJSON()
|
|
427
467
|
// Gets a boolean value from the JSON object for the given key, if possible.
|
|
@@ -461,6 +501,34 @@ bool njsBaton::GetBoolFromJSON(Local<Object> obj, const char *key, int index,
|
|
|
461
501
|
}
|
|
462
502
|
|
|
463
503
|
|
|
504
|
+
//-----------------------------------------------------------------------------
|
|
505
|
+
// njsBaton::GetFunctionFromJSON()
|
|
506
|
+
// Gets a function from the JSON object for the given key, if possible. If
|
|
507
|
+
// undefined, leave value alone and do not set error; otherwise, set error.
|
|
508
|
+
// Index is the argument index in the caller.
|
|
509
|
+
//-----------------------------------------------------------------------------
|
|
510
|
+
bool njsBaton::GetFunctionFromJSON(Local<Object> obj, const char *key,
|
|
511
|
+
int index, Local<Function> *value)
|
|
512
|
+
{
|
|
513
|
+
Nan::EscapableHandleScope scope;
|
|
514
|
+
Local<Value> jsValue;
|
|
515
|
+
|
|
516
|
+
if (!error.empty())
|
|
517
|
+
return false;
|
|
518
|
+
MaybeLocal<Value> mval = Nan::Get(obj, Nan::New(key).ToLocalChecked());
|
|
519
|
+
if (!mval.ToLocal(&jsValue))
|
|
520
|
+
return false;
|
|
521
|
+
if (jsValue->IsFunction()) {
|
|
522
|
+
*value = scope.Escape(jsValue.As<Function>());
|
|
523
|
+
return true;
|
|
524
|
+
} else if (jsValue->IsUndefined()) {
|
|
525
|
+
return true;
|
|
526
|
+
}
|
|
527
|
+
error = njsMessages::Get(errInvalidPropertyTypeInParam, key, index + 1);
|
|
528
|
+
return false;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
|
|
464
532
|
//-----------------------------------------------------------------------------
|
|
465
533
|
// njsBaton::GetIntFromJSON()
|
|
466
534
|
// Gets a signed integer value from the JSON object for the given key, if
|
|
@@ -539,7 +607,7 @@ bool njsBaton::GetStringFromJSON(Local<Object> obj, const char *key, int index,
|
|
|
539
607
|
return false;
|
|
540
608
|
|
|
541
609
|
if (jsValue->IsString()) {
|
|
542
|
-
|
|
610
|
+
Nan::Utf8String utf8str(jsValue->ToString());
|
|
543
611
|
value = std::string(*utf8str, static_cast<size_t>(utf8str.length()));
|
|
544
612
|
return true;
|
|
545
613
|
} else if (jsValue->IsUndefined()) {
|
|
@@ -591,6 +659,22 @@ bool njsBaton::GetUnsignedIntFromJSON(Local<Object> obj, const char *key,
|
|
|
591
659
|
}
|
|
592
660
|
|
|
593
661
|
|
|
662
|
+
//-----------------------------------------------------------------------------
|
|
663
|
+
// njsBaton::GetNumOutBinds()
|
|
664
|
+
// Return the number of in/out and out binds created by the baton.
|
|
665
|
+
//-----------------------------------------------------------------------------
|
|
666
|
+
uint32_t njsBaton::GetNumOutBinds()
|
|
667
|
+
{
|
|
668
|
+
uint32_t numOutBinds = 0;
|
|
669
|
+
|
|
670
|
+
for (uint32_t i = 0; i < numBindVars; i++) {
|
|
671
|
+
if (bindVars[i].bindDir != NJS_BIND_IN)
|
|
672
|
+
numOutBinds++;
|
|
673
|
+
}
|
|
674
|
+
return numOutBinds;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
|
|
594
678
|
//-----------------------------------------------------------------------------
|
|
595
679
|
// njsBaton::QueueWork()
|
|
596
680
|
// Queue work on a separate thread. The baton is passed as context. If an
|
|
@@ -677,7 +761,7 @@ bool njsCommon::GetStringArg(Nan::NAN_METHOD_ARGS_TYPE args,
|
|
|
677
761
|
Nan::ThrowError(errMsg.c_str());
|
|
678
762
|
return false;
|
|
679
763
|
}
|
|
680
|
-
|
|
764
|
+
Nan::Utf8String utf8str(args[index]->ToString());
|
|
681
765
|
value = std::string(*utf8str, static_cast<size_t>(utf8str.length()));
|
|
682
766
|
return true;
|
|
683
767
|
}
|
|
@@ -772,7 +856,7 @@ bool njsCommon::SetPropString(Local<Value> value, std::string *valuePtr,
|
|
|
772
856
|
Nan::ThrowError(errMsg.c_str());
|
|
773
857
|
return false;
|
|
774
858
|
}
|
|
775
|
-
|
|
859
|
+
Nan::Utf8String utfstr(value->ToString());
|
|
776
860
|
*valuePtr = std::string(*utfstr, static_cast<size_t>(utfstr.length()));
|
|
777
861
|
return true;
|
|
778
862
|
}
|