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/src/njsConnection.h
CHANGED
|
@@ -72,12 +72,13 @@ public:
|
|
|
72
72
|
static Local<Value> GetMetaData(njsVariable *vars, uint32_t numVars,
|
|
73
73
|
bool extendedMetaData);
|
|
74
74
|
static bool GetScalarValueFromVar(njsBaton *baton, njsVariable *var,
|
|
75
|
-
uint32_t pos, Local<Value> &value);
|
|
75
|
+
njsVariableBuffer *buffer, uint32_t pos, Local<Value> &value);
|
|
76
|
+
static bool ProcessExecuteBinds(Local<Object> binds, njsBaton *baton);
|
|
76
77
|
static bool ProcessQueryVars(njsBaton* baton, dpiStmt *dpiStmtHandle,
|
|
77
78
|
njsVariable *vars, uint32_t numVars);
|
|
78
79
|
static bool ProcessVars(njsBaton *baton, njsVariable *vars,
|
|
79
80
|
uint32_t numVars, uint32_t numElements);
|
|
80
|
-
static void Init(
|
|
81
|
+
static void Init(Local<Object> target);
|
|
81
82
|
bool IsValid() const { return (dpiConnHandle) ? true : false; }
|
|
82
83
|
njsErrorType GetInvalidErrorType() const { return errInvalidConnection; }
|
|
83
84
|
|
|
@@ -98,10 +99,21 @@ private:
|
|
|
98
99
|
static void Async_Execute(njsBaton *baton);
|
|
99
100
|
static void Async_AfterExecute(njsBaton *baton, Local<Value> argv[]);
|
|
100
101
|
|
|
101
|
-
//
|
|
102
|
-
static NAN_METHOD(
|
|
103
|
-
static void
|
|
104
|
-
static void
|
|
102
|
+
// ExecuteMany Method on Connection class
|
|
103
|
+
static NAN_METHOD(ExecuteMany);
|
|
104
|
+
static void Async_ExecuteMany(njsBaton *baton);
|
|
105
|
+
static void Async_AfterExecuteMany(njsBaton *baton, Local<Value> argv[]);
|
|
106
|
+
|
|
107
|
+
// GetStatementInfo Method on Connection class
|
|
108
|
+
static NAN_METHOD(GetStatementInfo);
|
|
109
|
+
static void Async_GetStatementInfo(njsBaton *baton);
|
|
110
|
+
static void Async_AfterGetStatementInfo(njsBaton *baton,
|
|
111
|
+
Local<Value> argv[]);
|
|
112
|
+
|
|
113
|
+
// Close Method on Connection class
|
|
114
|
+
static NAN_METHOD(Close);
|
|
115
|
+
static void Async_Close(njsBaton *baton);
|
|
116
|
+
static void Async_AfterClose(njsBaton *baton, Local<Value> argv[]);
|
|
105
117
|
|
|
106
118
|
// Commit Method on Connection class
|
|
107
119
|
static NAN_METHOD(Commit);
|
|
@@ -120,12 +132,30 @@ private:
|
|
|
120
132
|
static void Async_CreateLob(njsBaton *baton);
|
|
121
133
|
static void Async_AfterCreateLob(njsBaton *baton, Local<Value> argv[]);
|
|
122
134
|
|
|
135
|
+
// ChangePassword Method on Connection class
|
|
136
|
+
static NAN_METHOD(ChangePassword);
|
|
137
|
+
static void Async_ChangePassword(njsBaton *baton);
|
|
138
|
+
|
|
139
|
+
// Ping Method on Connection class
|
|
140
|
+
static NAN_METHOD(Ping);
|
|
141
|
+
static void Async_Ping(njsBaton *baton);
|
|
142
|
+
|
|
143
|
+
// Subscribe Method on Connection class
|
|
144
|
+
static NAN_METHOD(Subscribe);
|
|
145
|
+
static void Async_Subscribe(njsBaton *baton);
|
|
146
|
+
static void Async_AfterSubscribe(njsBaton *baton, Local<Value> argv[]);
|
|
147
|
+
|
|
148
|
+
// Unsubscribe Method on Connection class
|
|
149
|
+
static NAN_METHOD(Unsubscribe);
|
|
150
|
+
static void Async_Unsubscribe(njsBaton *baton);
|
|
151
|
+
|
|
123
152
|
// Define Getter Accessors to properties
|
|
124
153
|
static NAN_GETTER(GetStmtCacheSize);
|
|
125
154
|
static NAN_GETTER(GetClientId);
|
|
126
155
|
static NAN_GETTER(GetModule);
|
|
127
156
|
static NAN_GETTER(GetAction);
|
|
128
157
|
static NAN_GETTER(GetOracleServerVersion);
|
|
158
|
+
static NAN_GETTER(GetOracleServerVersionString);
|
|
129
159
|
|
|
130
160
|
// Define Setter Accessors to properties
|
|
131
161
|
static NAN_SETTER(SetStmtCacheSize);
|
|
@@ -133,34 +163,53 @@ private:
|
|
|
133
163
|
static NAN_SETTER(SetModule);
|
|
134
164
|
static NAN_SETTER(SetAction);
|
|
135
165
|
static NAN_SETTER(SetOracleServerVersion);
|
|
166
|
+
static NAN_SETTER(SetOracleServerVersionString);
|
|
136
167
|
|
|
137
168
|
// internal methods
|
|
169
|
+
static bool CreateVarBuffer(njsVariable *var, njsBaton *baton);
|
|
138
170
|
static bool GetBindTypeAndSizeFromValue(njsVariable *var,
|
|
139
|
-
Local<Value> value,
|
|
171
|
+
Local<Value> value, njsDataType *bindType, uint32_t *maxSize,
|
|
140
172
|
njsBaton *baton, bool scalarOnly = false);
|
|
141
|
-
static Local<Value>
|
|
142
|
-
static bool
|
|
143
|
-
|
|
173
|
+
static bool GetExecuteOutBinds(Local<Value> &outBinds, njsBaton *baton);
|
|
174
|
+
static bool GetExecuteManyOutBinds(Local<Value> &outBinds,
|
|
175
|
+
uint32_t numOutBinds, njsBaton *baton);
|
|
176
|
+
static bool GetOutBinds(Local<Value> &outBinds, uint32_t numOutBinds,
|
|
177
|
+
uint32_t pos, njsBaton *baton);
|
|
178
|
+
static bool GetArrayValueFromVar(njsBaton *baton, njsVariable *var,
|
|
179
|
+
uint32_t pos, Local<Value> &value);
|
|
180
|
+
static bool InitBindVars(Local<Object> bindObj, Local<Array> bindNames,
|
|
181
|
+
njsBaton *baton);
|
|
144
182
|
static bool MapByName(njsBaton *baton, dpiQueryInfo *queryInfo,
|
|
145
183
|
dpiOracleTypeNum &targetType);
|
|
146
184
|
static bool MapByType(njsBaton *baton, dpiQueryInfo *queryInfo,
|
|
147
185
|
dpiOracleTypeNum &targetType);
|
|
148
186
|
static bool PrepareAndBind(njsBaton* baton);
|
|
149
|
-
static bool ProcessBinds(Nan::NAN_METHOD_ARGS_TYPE args,
|
|
150
|
-
unsigned int index, njsBaton *baton);
|
|
151
|
-
static bool ProcessBindsByName(Handle<Object> bindObj, njsBaton *baton);
|
|
152
|
-
static bool ProcessBindsByPos(Handle<Array> bindarray, njsBaton *baton);
|
|
153
|
-
static bool ProcessBind(Local<Value> bindTypes, njsVariable *var,
|
|
154
|
-
bool byPosition, njsBaton *baton);
|
|
155
187
|
static bool ProcessBindValue(Local<Value> bindValue, njsVariable *var,
|
|
156
188
|
njsBaton *baton);
|
|
189
|
+
static bool ProcessExecuteManyBinds(Local<Array> binds,
|
|
190
|
+
Local<Object> options, njsBaton *baton);
|
|
191
|
+
static bool ProcessExecuteOptions(Local<Object> options, njsBaton *baton);
|
|
192
|
+
static bool ProcessExecuteManyOptions(Local<Object> options,
|
|
193
|
+
njsBaton *baton);
|
|
157
194
|
static bool ProcessScalarBindValue(Local<Value> bindValue,
|
|
158
|
-
njsVariable *var, uint32_t pos,
|
|
159
|
-
|
|
160
|
-
|
|
195
|
+
njsVariable *var, uint32_t pos, bool inExecuteMany,
|
|
196
|
+
njsBaton *baton);
|
|
197
|
+
static bool ProcessSubscriptionOptions(Local<Object> options,
|
|
198
|
+
njsBaton *baton);
|
|
199
|
+
static bool ProcessVarBuffer(njsBaton *baton, njsVariable *var,
|
|
200
|
+
njsVariableBuffer *buffer);
|
|
201
|
+
static bool ScanExecuteBinds(Local<Object> binds, Local<Array> bindNames,
|
|
202
|
+
njsBaton *baton);
|
|
203
|
+
static bool ScanExecuteBindUnit(Local<Object> bindUnit, njsVariable *var,
|
|
204
|
+
bool inExecuteMany, njsBaton *baton);
|
|
205
|
+
static bool ScanExecuteManyBinds(Local<Array> binds,
|
|
206
|
+
Local<Array> bindNames, njsBaton *baton);
|
|
161
207
|
static void SetTextAttribute(Nan::NAN_SETTER_ARGS_TYPE args,
|
|
162
208
|
const char *attributeName, Local<Value> value,
|
|
163
209
|
int (*setter)(dpiConn*, const char*, uint32_t));
|
|
210
|
+
static bool TransferExecuteManyBinds(Local<Array> binds,
|
|
211
|
+
Local<Array> bindNames, njsBaton *baton);
|
|
212
|
+
|
|
164
213
|
static Nan::Persistent<FunctionTemplate> connectionTemplate_s;
|
|
165
214
|
|
|
166
215
|
dpiConn *dpiConnHandle;
|
package/src/njsIntLob.cpp
CHANGED
|
@@ -70,7 +70,7 @@ Nan::Persistent<FunctionTemplate> njsILob::iLobTemplate_s;
|
|
|
70
70
|
// Initialization function of ILob class. Maps functions and properties from
|
|
71
71
|
// JS to C++.
|
|
72
72
|
//-----------------------------------------------------------------------------
|
|
73
|
-
void njsILob::Init(
|
|
73
|
+
void njsILob::Init(Local<Object> target)
|
|
74
74
|
{
|
|
75
75
|
Nan::HandleScope scope;
|
|
76
76
|
|
|
@@ -189,6 +189,10 @@ bool njsILob::ClearDPILobHandle(njsBaton *baton)
|
|
|
189
189
|
baton->GetDPIError();
|
|
190
190
|
return false;
|
|
191
191
|
}
|
|
192
|
+
if (dpiLob_release(dpiLobHandle) < 0) {
|
|
193
|
+
baton->GetDPIError();
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
192
196
|
dpiLobHandle = NULL;
|
|
193
197
|
return true;
|
|
194
198
|
}
|
package/src/njsIntLob.h
CHANGED
|
@@ -102,7 +102,7 @@ protected:
|
|
|
102
102
|
//-----------------------------------------------------------------------------
|
|
103
103
|
class njsILob : public njsCommon {
|
|
104
104
|
public:
|
|
105
|
-
static void Init(
|
|
105
|
+
static void Init(Local<Object> target);
|
|
106
106
|
static Local<Object> CreateFromProtoLob(njsProtoILob *protoLob);
|
|
107
107
|
bool IsValid() const { return (dpiLobHandle) ? true : false; }
|
|
108
108
|
njsErrorType GetInvalidErrorType() const { return errInvalidLob; }
|
package/src/njsMessages.cpp
CHANGED
|
@@ -55,7 +55,6 @@ static const char *errMsg[] = {
|
|
|
55
55
|
"NJS-017: concurrent operations on ResultSet are not allowed", // errBusyResultSet
|
|
56
56
|
"NJS-018: invalid ResultSet", // errInvalidResultSet
|
|
57
57
|
"NJS-019: ResultSet cannot be returned for non-query statements", // errInvalidNonQueryExecution
|
|
58
|
-
"NJS-020: empty array was specified to fetch values as string", // errEmptyArrayForFetchAs
|
|
59
58
|
"NJS-021: invalid type for conversion specified", // errInvalidTypeForConversion
|
|
60
59
|
"NJS-022: invalid Lob", // errInvalidLob
|
|
61
60
|
"NJS-023: concurrent operations on LOB are not allowed", // errBusyLob
|
|
@@ -63,7 +62,6 @@ static const char *errMsg[] = {
|
|
|
63
62
|
"NJS-025: overflow when calculating results area size", // errResultsTooLarge
|
|
64
63
|
"NJS-026: maxRows must be greater than zero", // errInvalidmaxRows
|
|
65
64
|
"NJS-027: unexpected SQL parsing error", // errSQLSyntaxError
|
|
66
|
-
"NJS-028: raw database type is not supported with DML Returning statements", // errBufferReturningInvalid
|
|
67
65
|
"NJS-029: invalid object from JavaScript", // errInvalidJSObject
|
|
68
66
|
"NJS-030: connection cannot be released because Lob operations are in progress", // errBusyConnLOB
|
|
69
67
|
"NJS-031: connection cannot be released because ResultSet operations are in progress", // errBusyConnRS
|
|
@@ -85,6 +83,15 @@ static const char *errMsg[] = {
|
|
|
85
83
|
"NJS-052: invalid data type at array index %d for bind position %d", // errIncompatibleTypeArrayIndexBind
|
|
86
84
|
"NJS-053: array value expected, a non-array value provided", //errNonArrayProvided
|
|
87
85
|
"NJS-054: Binary build/Release/oracledb.node was not installed from %s", // errNoBinaryInstalled
|
|
86
|
+
"NJS-055: Binding by position and name cannot be mixed", // errMixedBind
|
|
87
|
+
"NJS-056: maxSize must be specified and not zero for bind position %u", // errMissingMaxSizeByPos
|
|
88
|
+
"NJS-057: maxSize must be specified and not zero for bind \"%s\"", // errMissingMaxSizeByName
|
|
89
|
+
"NJS-058: maxSize of %u is too small for value of length %u in row %u", // errMaxSizeTooSmall
|
|
90
|
+
"NJS-059: type must be specified for bind position %u", // errMissingTypeByPos
|
|
91
|
+
"NJS-060: type must be specified for bind \"%s\"", // errMissingTypeByName
|
|
92
|
+
"NJS-061: invalid subscription", // errInvalidSubscription
|
|
93
|
+
"NJS-062: subscription notification callback missing", // errMissingSubscrCallback
|
|
94
|
+
"NJS-063: subscription notification SQL missing", // errMissingSubscrSql
|
|
88
95
|
};
|
|
89
96
|
|
|
90
97
|
|
package/src/njsMessages.h
CHANGED
|
@@ -58,7 +58,6 @@ typedef enum {
|
|
|
58
58
|
errBusyResultSet,
|
|
59
59
|
errInvalidResultSet,
|
|
60
60
|
errInvalidNonQueryExecution,
|
|
61
|
-
errEmptyArrayForFetchAs,
|
|
62
61
|
errInvalidTypeForConversion,
|
|
63
62
|
errInvalidLob,
|
|
64
63
|
errBusyLob,
|
|
@@ -66,7 +65,6 @@ typedef enum {
|
|
|
66
65
|
errResultsTooLarge,
|
|
67
66
|
errInvalidmaxRows,
|
|
68
67
|
errSQLSyntaxError,
|
|
69
|
-
errBufferReturningInvalid,
|
|
70
68
|
errInvalidJSObject,
|
|
71
69
|
errBusyConnLOB,
|
|
72
70
|
errBusyConnRS,
|
|
@@ -88,6 +86,15 @@ typedef enum {
|
|
|
88
86
|
errIncompatibleTypeArrayIndexBind,
|
|
89
87
|
errNonArrayProvided,
|
|
90
88
|
errNoBinaryInstalled,
|
|
89
|
+
errMixedBind,
|
|
90
|
+
errMissingMaxSizeByPos,
|
|
91
|
+
errMissingMaxSizeByName,
|
|
92
|
+
errMaxSizeTooSmall,
|
|
93
|
+
errMissingTypeByPos,
|
|
94
|
+
errMissingTypeByName,
|
|
95
|
+
errInvalidSubscription,
|
|
96
|
+
errMissingSubscrCallback,
|
|
97
|
+
errMissingSubscrSql,
|
|
91
98
|
|
|
92
99
|
// New ones should be added here
|
|
93
100
|
|
package/src/njsOracle.cpp
CHANGED
|
@@ -56,17 +56,18 @@
|
|
|
56
56
|
#include "njsResultSet.h"
|
|
57
57
|
#include "njsMessages.h"
|
|
58
58
|
#include "njsIntLob.h"
|
|
59
|
+
#include "njsSubscription.h"
|
|
59
60
|
#include <sstream>
|
|
60
61
|
|
|
61
62
|
// peristent Oracledb class handle
|
|
62
63
|
Nan::Persistent<FunctionTemplate> njsOracledb::oracledbTemplate_s;
|
|
63
64
|
|
|
65
|
+
// persistent handle for subscriptions
|
|
66
|
+
Nan::Persistent<Object> njsOracledb::subscriptions;
|
|
67
|
+
|
|
64
68
|
// DPI context
|
|
65
69
|
dpiContext *njsOracledb::globalDPIContext = NULL;
|
|
66
70
|
|
|
67
|
-
// common pool/standalone connection creation parameters (fixed)
|
|
68
|
-
dpiCommonCreateParams njsCommonCreateParams;
|
|
69
|
-
|
|
70
71
|
|
|
71
72
|
//-----------------------------------------------------------------------------
|
|
72
73
|
// njsOracledb::njsOracledb()
|
|
@@ -85,10 +86,12 @@ njsOracledb::njsOracledb()
|
|
|
85
86
|
poolTimeout = NJS_POOL_TIMEOUT;
|
|
86
87
|
fetchArraySize = DPI_DEFAULT_FETCH_ARRAY_SIZE;
|
|
87
88
|
connClass = "";
|
|
89
|
+
edition = "";
|
|
88
90
|
externalAuth = false;
|
|
89
91
|
lobPrefetchSize = NJS_LOB_PREFETCH_SIZE;
|
|
90
92
|
poolPingInterval = NJS_POOL_DEFAULT_PING_INTERVAL;
|
|
91
93
|
oraClientVer = 0;
|
|
94
|
+
events = false;
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
|
|
@@ -96,7 +99,7 @@ njsOracledb::njsOracledb()
|
|
|
96
99
|
// njsOracledb::Init()
|
|
97
100
|
// Initialization function. Maps functions and properties from JS to C++.
|
|
98
101
|
//-----------------------------------------------------------------------------
|
|
99
|
-
void njsOracledb::Init(
|
|
102
|
+
void njsOracledb::Init(Local<Object> target)
|
|
100
103
|
{
|
|
101
104
|
Nan::HandleScope scope;
|
|
102
105
|
dpiErrorInfo errorInfo;
|
|
@@ -108,20 +111,6 @@ void njsOracledb::Init(Handle<Object> target)
|
|
|
108
111
|
return;
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
// initialize common creation parameters for pools/standalone connections
|
|
112
|
-
if (dpiContext_initCommonCreateParams(globalDPIContext,
|
|
113
|
-
&njsCommonCreateParams) < 0) {
|
|
114
|
-
dpiContext_getError(globalDPIContext, &errorInfo);
|
|
115
|
-
Nan::ThrowError(errorInfo.message);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
njsCommonCreateParams.createMode = DPI_MODE_CREATE_THREADED;
|
|
119
|
-
njsCommonCreateParams.encoding = "UTF-8";
|
|
120
|
-
njsCommonCreateParams.nencoding = "UTF-8";
|
|
121
|
-
njsCommonCreateParams.driverName = NJS_DRIVER_NAME;
|
|
122
|
-
njsCommonCreateParams.driverNameLength =
|
|
123
|
-
(uint32_t) strlen(njsCommonCreateParams.driverName);
|
|
124
|
-
|
|
125
114
|
Local<FunctionTemplate> temp = Nan::New<FunctionTemplate>(New);
|
|
126
115
|
temp->InstanceTemplate()->SetInternalFieldCount(1);
|
|
127
116
|
temp->SetClassName(Nan::New<v8::String>("Oracledb").ToLocalChecked());
|
|
@@ -172,6 +161,9 @@ void njsOracledb::Init(Handle<Object> target)
|
|
|
172
161
|
Nan::SetAccessor(temp->InstanceTemplate(),
|
|
173
162
|
Nan::New<v8::String>("connectionClass").ToLocalChecked(),
|
|
174
163
|
njsOracledb::GetConnectionClass, njsOracledb::SetConnectionClass);
|
|
164
|
+
Nan::SetAccessor(temp->InstanceTemplate(),
|
|
165
|
+
Nan::New<v8::String>("edition").ToLocalChecked(),
|
|
166
|
+
njsOracledb::GetEdition, njsOracledb::SetEdition);
|
|
175
167
|
Nan::SetAccessor(temp->InstanceTemplate(),
|
|
176
168
|
Nan::New<v8::String>("externalAuth").ToLocalChecked(),
|
|
177
169
|
njsOracledb::GetExternalAuth, njsOracledb::SetExternalAuth);
|
|
@@ -188,14 +180,24 @@ void njsOracledb::Init(Handle<Object> target)
|
|
|
188
180
|
Nan::New<v8::String>("oracleClientVersion").ToLocalChecked(),
|
|
189
181
|
njsOracledb::GetOracleClientVersion,
|
|
190
182
|
njsOracledb::SetOracleClientVersion);
|
|
183
|
+
Nan::SetAccessor(temp->InstanceTemplate (),
|
|
184
|
+
Nan::New<v8::String>("oracleClientVersionString").ToLocalChecked(),
|
|
185
|
+
njsOracledb::GetOracleClientVersionString,
|
|
186
|
+
njsOracledb::SetOracleClientVersionString);
|
|
191
187
|
Nan::SetAccessor(temp->InstanceTemplate (),
|
|
192
188
|
Nan::New<v8::String>("poolPingInterval").ToLocalChecked(),
|
|
193
189
|
njsOracledb::GetPoolPingInterval,
|
|
194
190
|
njsOracledb::SetPoolPingInterval);
|
|
191
|
+
Nan::SetAccessor(temp->InstanceTemplate (),
|
|
192
|
+
Nan::New<v8::String>("events").ToLocalChecked(),
|
|
193
|
+
njsOracledb::GetEvents, njsOracledb::SetEvents);
|
|
195
194
|
|
|
196
195
|
oracledbTemplate_s.Reset(temp);
|
|
197
196
|
Nan::Set(target, Nan::New<v8::String>("Oracledb").ToLocalChecked(),
|
|
198
197
|
temp->GetFunction());
|
|
198
|
+
|
|
199
|
+
Local<Object> obj = Nan::New<v8::Object>();
|
|
200
|
+
subscriptions.Reset(obj);
|
|
199
201
|
}
|
|
200
202
|
|
|
201
203
|
|
|
@@ -223,6 +225,30 @@ NAN_METHOD(njsOracledb::New)
|
|
|
223
225
|
}
|
|
224
226
|
|
|
225
227
|
|
|
228
|
+
//-----------------------------------------------------------------------------
|
|
229
|
+
// njsOracledb::InitCommonCreateParams()
|
|
230
|
+
// Initialize common creation parameters for pools and standalone
|
|
231
|
+
// connection creation.
|
|
232
|
+
//-----------------------------------------------------------------------------
|
|
233
|
+
bool njsOracledb::InitCommonCreateParams(njsBaton *baton,
|
|
234
|
+
dpiCommonCreateParams *params)
|
|
235
|
+
{
|
|
236
|
+
if (dpiContext_initCommonCreateParams(globalDPIContext, params) < 0) {
|
|
237
|
+
baton->GetDPIError();
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
params->createMode = DPI_MODE_CREATE_THREADED;
|
|
241
|
+
if (baton->events)
|
|
242
|
+
params->createMode = (dpiCreateMode)
|
|
243
|
+
((int) params->createMode | DPI_MODE_CREATE_EVENTS);
|
|
244
|
+
params->encoding = "UTF-8";
|
|
245
|
+
params->nencoding = "UTF-8";
|
|
246
|
+
params->driverName = NJS_DRIVER_NAME;
|
|
247
|
+
params->driverNameLength = (uint32_t) strlen(params->driverName);
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
|
|
226
252
|
//-----------------------------------------------------------------------------
|
|
227
253
|
// njsOracledb::GetPoolMin()
|
|
228
254
|
// Get accessor of "poolMin" property.
|
|
@@ -589,6 +615,32 @@ NAN_SETTER(njsOracledb::SetConnectionClass)
|
|
|
589
615
|
"connectionClass");
|
|
590
616
|
}
|
|
591
617
|
|
|
618
|
+
//-----------------------------------------------------------------------------
|
|
619
|
+
// njsOracledb::GetEdition()
|
|
620
|
+
// Get accessor of "edition" property.
|
|
621
|
+
//-----------------------------------------------------------------------------
|
|
622
|
+
NAN_GETTER(njsOracledb::GetEdition)
|
|
623
|
+
{
|
|
624
|
+
njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
|
|
625
|
+
if (!oracledb)
|
|
626
|
+
return;
|
|
627
|
+
Local<String> value =
|
|
628
|
+
Nan::New<v8::String>(oracledb->edition).ToLocalChecked();
|
|
629
|
+
info.GetReturnValue().Set(value);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
//-----------------------------------------------------------------------------
|
|
633
|
+
// njsOracledb::SetEdition()
|
|
634
|
+
// Set accessor of "edition" property.
|
|
635
|
+
//-----------------------------------------------------------------------------
|
|
636
|
+
NAN_SETTER(njsOracledb::SetEdition)
|
|
637
|
+
{
|
|
638
|
+
njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
|
|
639
|
+
if (oracledb)
|
|
640
|
+
oracledb->SetPropString(value, &oracledb->edition,
|
|
641
|
+
"edition");
|
|
642
|
+
}
|
|
643
|
+
|
|
592
644
|
|
|
593
645
|
//-----------------------------------------------------------------------------
|
|
594
646
|
// njsOracledb::GetExternalAuth()
|
|
@@ -684,6 +736,7 @@ NAN_SETTER(njsOracledb::SetFetchAsString)
|
|
|
684
736
|
switch (type) {
|
|
685
737
|
case NJS_DATATYPE_NUM:
|
|
686
738
|
case NJS_DATATYPE_DATE:
|
|
739
|
+
case NJS_DATATYPE_BUFFER:
|
|
687
740
|
case NJS_DATATYPE_CLOB:
|
|
688
741
|
break;
|
|
689
742
|
default:
|
|
@@ -792,6 +845,66 @@ NAN_SETTER(njsOracledb::SetOracleClientVersion)
|
|
|
792
845
|
}
|
|
793
846
|
|
|
794
847
|
|
|
848
|
+
//-----------------------------------------------------------------------------
|
|
849
|
+
// njsOracledb::GetOracleClientVersionString()
|
|
850
|
+
// Get accessor of "oracleClientVersionString" property.
|
|
851
|
+
//-----------------------------------------------------------------------------
|
|
852
|
+
NAN_GETTER(njsOracledb::GetOracleClientVersionString)
|
|
853
|
+
{
|
|
854
|
+
dpiVersionInfo versionInfo;
|
|
855
|
+
char versionString[40];
|
|
856
|
+
Local<String> value;
|
|
857
|
+
|
|
858
|
+
njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
|
|
859
|
+
if (!oracledb)
|
|
860
|
+
return;
|
|
861
|
+
|
|
862
|
+
if (dpiContext_getClientVersion(globalDPIContext, &versionInfo) < 0) {
|
|
863
|
+
ThrowDPIError();
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
(void) sprintf(versionString, "%d.%d.%d.%d.%d", versionInfo.versionNum,
|
|
868
|
+
versionInfo.releaseNum, versionInfo.updateNum,
|
|
869
|
+
versionInfo.portReleaseNum, versionInfo.portUpdateNum);
|
|
870
|
+
value = Nan::New<v8::String>(versionString).ToLocalChecked();
|
|
871
|
+
info.GetReturnValue().Set(value);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
//-----------------------------------------------------------------------------
|
|
876
|
+
// njsOracledb::SetOracleClientVersionString()
|
|
877
|
+
// Set accessor of "oracleClientVersionString" property.
|
|
878
|
+
//-----------------------------------------------------------------------------
|
|
879
|
+
NAN_SETTER(njsOracledb::SetOracleClientVersionString)
|
|
880
|
+
{
|
|
881
|
+
PropertyIsReadOnly("oracleClientVersionString");
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
// njsOracledb::GetEvents()
|
|
886
|
+
// Get accessor of "events" property.
|
|
887
|
+
//-----------------------------------------------------------------------------
|
|
888
|
+
NAN_GETTER(njsOracledb::GetEvents)
|
|
889
|
+
{
|
|
890
|
+
njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
|
|
891
|
+
if (oracledb)
|
|
892
|
+
info.GetReturnValue().Set(oracledb->events);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
//-----------------------------------------------------------------------------
|
|
897
|
+
// njsOracledb::SetEvents()
|
|
898
|
+
// Set accessor of "events" property.
|
|
899
|
+
//-----------------------------------------------------------------------------
|
|
900
|
+
NAN_SETTER(njsOracledb::SetEvents)
|
|
901
|
+
{
|
|
902
|
+
njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
|
|
903
|
+
if (oracledb)
|
|
904
|
+
oracledb->SetPropBool(value, &oracledb->events, "events");
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
|
|
795
908
|
//-----------------------------------------------------------------------------
|
|
796
909
|
// njsOracledb::GetConnection()
|
|
797
910
|
// Establishes a standalone connection to the database using the parameters
|
|
@@ -821,14 +934,19 @@ NAN_METHOD(njsOracledb::GetConnection)
|
|
|
821
934
|
baton->GetStringFromJSON(connProps, "password", 0, baton->password);
|
|
822
935
|
baton->GetStringFromJSON(connProps, "connectString", 0,
|
|
823
936
|
baton->connectString);
|
|
937
|
+
baton->GetStringFromJSON(connProps, "newPassword", 0, baton->newPassword);
|
|
824
938
|
baton->connClass = oracledb->connClass;
|
|
939
|
+
baton->edition = oracledb->edition;
|
|
825
940
|
baton->stmtCacheSize = oracledb->stmtCacheSize;
|
|
826
941
|
baton->externalAuth = oracledb->externalAuth;
|
|
942
|
+
baton->events = oracledb->events;
|
|
943
|
+
baton->GetStringFromJSON(connProps, "edition", 0, baton->edition);
|
|
827
944
|
baton->GetUnsignedIntFromJSON(connProps, "stmtCacheSize", 0,
|
|
828
945
|
&baton->stmtCacheSize);
|
|
829
946
|
baton->GetUnsignedIntFromJSON(connProps, "privilege", 0,
|
|
830
947
|
&baton->privilege);
|
|
831
948
|
baton->GetBoolFromJSON(connProps, "externalAuth", 0, &baton->externalAuth);
|
|
949
|
+
baton->GetBoolFromJSON(connProps, "events", 0, &baton->events);
|
|
832
950
|
baton->lobPrefetchSize = oracledb->lobPrefetchSize;
|
|
833
951
|
|
|
834
952
|
baton->QueueWork("GetConnection", Async_GetConnection,
|
|
@@ -843,6 +961,7 @@ NAN_METHOD(njsOracledb::GetConnection)
|
|
|
843
961
|
//-----------------------------------------------------------------------------
|
|
844
962
|
void njsOracledb::Async_GetConnection(njsBaton *baton)
|
|
845
963
|
{
|
|
964
|
+
dpiCommonCreateParams commonParams;
|
|
846
965
|
dpiConnCreateParams params;
|
|
847
966
|
|
|
848
967
|
if (dpiContext_initConnCreateParams(globalDPIContext, ¶ms) < 0) {
|
|
@@ -856,11 +975,23 @@ void njsOracledb::Async_GetConnection(njsBaton *baton)
|
|
|
856
975
|
params.connectionClass = baton->connClass.c_str();
|
|
857
976
|
params.connectionClassLength = baton->connClass.length();
|
|
858
977
|
}
|
|
978
|
+
|
|
979
|
+
if(!baton->newPassword.empty()) {
|
|
980
|
+
params.newPassword = baton->newPassword.c_str();
|
|
981
|
+
params.newPasswordLength = baton->newPassword.length();
|
|
982
|
+
}
|
|
983
|
+
if (!InitCommonCreateParams(baton, &commonParams))
|
|
984
|
+
return;
|
|
985
|
+
if (!baton->edition.empty()) {
|
|
986
|
+
commonParams.edition = baton->edition.c_str();
|
|
987
|
+
commonParams.editionLength = baton->edition.length();
|
|
988
|
+
}
|
|
989
|
+
|
|
859
990
|
if (dpiConn_create(globalDPIContext, baton->user.c_str(),
|
|
860
991
|
(uint32_t) baton->user.length(), baton->password.c_str(),
|
|
861
992
|
(uint32_t) baton->password.length(), baton->connectString.c_str(),
|
|
862
|
-
(uint32_t) baton->connectString.length(), &
|
|
863
|
-
&
|
|
993
|
+
(uint32_t) baton->connectString.length(), &commonParams, ¶ms,
|
|
994
|
+
&baton->dpiConnHandle) < 0)
|
|
864
995
|
baton->GetDPIError();
|
|
865
996
|
else if (dpiConn_setStmtCacheSize(baton->dpiConnHandle,
|
|
866
997
|
baton->stmtCacheSize) < 0)
|
|
@@ -916,6 +1047,8 @@ NAN_METHOD(njsOracledb::CreatePool)
|
|
|
916
1047
|
baton->poolPingInterval = oracledb->poolPingInterval;
|
|
917
1048
|
baton->stmtCacheSize = oracledb->stmtCacheSize;
|
|
918
1049
|
baton->externalAuth = oracledb->externalAuth;
|
|
1050
|
+
baton->edition = oracledb->edition;
|
|
1051
|
+
baton->events = oracledb->events;
|
|
919
1052
|
baton->GetUnsignedIntFromJSON(poolProps, "poolMax", 0, &baton->poolMax);
|
|
920
1053
|
baton->GetUnsignedIntFromJSON(poolProps, "poolMin", 0, &baton->poolMin);
|
|
921
1054
|
baton->GetUnsignedIntFromJSON(poolProps, "poolIncrement", 0,
|
|
@@ -927,6 +1060,9 @@ NAN_METHOD(njsOracledb::CreatePool)
|
|
|
927
1060
|
baton->GetIntFromJSON(poolProps, "poolPingInterval", 0,
|
|
928
1061
|
&baton->poolPingInterval);
|
|
929
1062
|
baton->GetBoolFromJSON(poolProps, "externalAuth", 0, &baton->externalAuth);
|
|
1063
|
+
baton->GetBoolFromJSON(poolProps, "homogeneous", 0, &baton->homogeneous);
|
|
1064
|
+
baton->GetBoolFromJSON(poolProps, "events", 0, &baton->events);
|
|
1065
|
+
baton->GetStringFromJSON(poolProps, "edition", 0, baton->edition);
|
|
930
1066
|
baton->lobPrefetchSize = oracledb->lobPrefetchSize;
|
|
931
1067
|
baton->jsOracledb.Reset(info.Holder());
|
|
932
1068
|
|
|
@@ -941,6 +1077,7 @@ NAN_METHOD(njsOracledb::CreatePool)
|
|
|
941
1077
|
//-----------------------------------------------------------------------------
|
|
942
1078
|
void njsOracledb::Async_CreatePool(njsBaton *baton)
|
|
943
1079
|
{
|
|
1080
|
+
dpiCommonCreateParams commonParams;
|
|
944
1081
|
dpiPoolCreateParams params;
|
|
945
1082
|
|
|
946
1083
|
if (dpiContext_initPoolCreateParams(globalDPIContext, ¶ms) < 0) {
|
|
@@ -951,14 +1088,22 @@ void njsOracledb::Async_CreatePool(njsBaton *baton)
|
|
|
951
1088
|
params.maxSessions = baton->poolMax;
|
|
952
1089
|
params.sessionIncrement = baton->poolIncrement;
|
|
953
1090
|
params.externalAuth = baton->externalAuth;
|
|
1091
|
+
params.homogeneous = baton->homogeneous;
|
|
1092
|
+
|
|
954
1093
|
if (params.externalAuth)
|
|
955
1094
|
params.homogeneous = 0;
|
|
956
1095
|
params.pingInterval = baton->poolPingInterval;
|
|
1096
|
+
if (!InitCommonCreateParams(baton, &commonParams))
|
|
1097
|
+
return;
|
|
1098
|
+
if (!baton->edition.empty()) {
|
|
1099
|
+
commonParams.edition = baton->edition.c_str();
|
|
1100
|
+
commonParams.editionLength = baton->edition.length();
|
|
1101
|
+
}
|
|
957
1102
|
if (dpiPool_create(globalDPIContext, baton->user.c_str(),
|
|
958
1103
|
(uint32_t) baton->user.length(), baton->password.c_str(),
|
|
959
1104
|
(uint32_t) baton->password.length(), baton->connectString.c_str(),
|
|
960
|
-
(uint32_t) baton->connectString.length(), &
|
|
961
|
-
&
|
|
1105
|
+
(uint32_t) baton->connectString.length(), &commonParams, ¶ms,
|
|
1106
|
+
&baton->dpiPoolHandle) < 0)
|
|
962
1107
|
baton->GetDPIError();
|
|
963
1108
|
else if (dpiPool_setTimeout(baton->dpiPoolHandle, baton->poolTimeout) < 0)
|
|
964
1109
|
baton->GetDPIError();
|
|
@@ -1049,19 +1194,64 @@ void njsOracledb::ThrowDPIError(void)
|
|
|
1049
1194
|
}
|
|
1050
1195
|
|
|
1051
1196
|
|
|
1197
|
+
//-----------------------------------------------------------------------------
|
|
1198
|
+
// njsOracledb::GetSubscription()
|
|
1199
|
+
// Gets the subscription with the give name if it exists, or returns NULL if
|
|
1200
|
+
// it does not exist in the subscriptions object.
|
|
1201
|
+
//-----------------------------------------------------------------------------
|
|
1202
|
+
njsSubscription *njsOracledb::GetSubscription(std::string &name)
|
|
1203
|
+
{
|
|
1204
|
+
Nan::HandleScope scope;
|
|
1205
|
+
Local<String> nameObj = Nan::New<String>(name).ToLocalChecked();
|
|
1206
|
+
Local<Object> allSubscriptions = Nan::New(subscriptions);
|
|
1207
|
+
Local<Value> value = Nan::Get(allSubscriptions, nameObj).ToLocalChecked();
|
|
1208
|
+
if (value->IsUndefined())
|
|
1209
|
+
return NULL;
|
|
1210
|
+
return Nan::ObjectWrap::Unwrap<njsSubscription>(value.As<Object>());
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
//-----------------------------------------------------------------------------
|
|
1215
|
+
// njsOracledb::SetSubscription()
|
|
1216
|
+
// Sets the subscription in the subscriptions object for later recovery,
|
|
1217
|
+
// either to subscribe another query or to unsubscribe.
|
|
1218
|
+
//-----------------------------------------------------------------------------
|
|
1219
|
+
void njsOracledb::SetSubscription(std::string &name, Local<Value> subscription)
|
|
1220
|
+
{
|
|
1221
|
+
Nan::HandleScope scope;
|
|
1222
|
+
Local<String> nameObj = Nan::New<String>(name).ToLocalChecked();
|
|
1223
|
+
Local<Object> allSubscriptions = Nan::New(subscriptions);
|
|
1224
|
+
Nan::Set(allSubscriptions, nameObj, subscription);
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
|
|
1228
|
+
//-----------------------------------------------------------------------------
|
|
1229
|
+
// njsOracledb::ClearSubscription()
|
|
1230
|
+
// Clears the subscription from the subscriptions object.
|
|
1231
|
+
//-----------------------------------------------------------------------------
|
|
1232
|
+
void njsOracledb::ClearSubscription(std::string &name)
|
|
1233
|
+
{
|
|
1234
|
+
Nan::HandleScope scope;
|
|
1235
|
+
Local<String> nameObj = Nan::New<String>(name).ToLocalChecked();
|
|
1236
|
+
Local<Object> allSubscriptions = Nan::New(subscriptions);
|
|
1237
|
+
Nan::Delete(allSubscriptions, nameObj);
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
|
|
1052
1241
|
//-----------------------------------------------------------------------------
|
|
1053
1242
|
// init()
|
|
1054
1243
|
// Invoked when require on oracledb is called.
|
|
1055
1244
|
//-----------------------------------------------------------------------------
|
|
1056
1245
|
extern "C"
|
|
1057
1246
|
{
|
|
1058
|
-
static void init(
|
|
1247
|
+
static void init(Local<Object> target)
|
|
1059
1248
|
{
|
|
1060
1249
|
njsOracledb::Init(target);
|
|
1061
1250
|
njsConnection::Init(target);
|
|
1062
1251
|
njsPool::Init(target);
|
|
1063
1252
|
njsResultSet::Init(target);
|
|
1064
1253
|
njsILob::Init(target);
|
|
1254
|
+
njsSubscription::Init(target);
|
|
1065
1255
|
}
|
|
1066
1256
|
|
|
1067
1257
|
NODE_MODULE(oracledb, init)
|