Skip to content

Commit 5347214

Browse files
committed
Sync missed merges etc.
1 parent 9fc091d commit 5347214

File tree

12 files changed

+707
-130
lines changed

12 files changed

+707
-130
lines changed

src/njs/src/njsCommon.cpp

Lines changed: 95 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -83,30 +83,30 @@ njsVariable::~njsVariable()
8383
njsDataType njsVariable::DataType()
8484
{
8585
switch (varTypeNum) {
86-
case DPI_ORACLE_VARTYPE_VARCHAR:
87-
case DPI_ORACLE_VARTYPE_NVARCHAR:
88-
case DPI_ORACLE_VARTYPE_CHAR:
89-
case DPI_ORACLE_VARTYPE_NCHAR:
90-
case DPI_ORACLE_VARTYPE_ROWID:
91-
case DPI_ORACLE_VARTYPE_RAW:
92-
case DPI_ORACLE_VARTYPE_LONG_VARCHAR:
93-
case DPI_ORACLE_VARTYPE_LONG_NVARCHAR:
94-
case DPI_ORACLE_VARTYPE_LONG_RAW:
86+
case DPI_ORACLE_TYPE_VARCHAR:
87+
case DPI_ORACLE_TYPE_NVARCHAR:
88+
case DPI_ORACLE_TYPE_CHAR:
89+
case DPI_ORACLE_TYPE_NCHAR:
90+
case DPI_ORACLE_TYPE_ROWID:
91+
case DPI_ORACLE_TYPE_LONG_VARCHAR:
9592
return NJS_DATATYPE_STR;
96-
case DPI_ORACLE_VARTYPE_NATIVE_FLOAT:
97-
case DPI_ORACLE_VARTYPE_NATIVE_DOUBLE:
98-
case DPI_ORACLE_VARTYPE_NATIVE_INT:
99-
case DPI_ORACLE_VARTYPE_NUMBER:
93+
case DPI_ORACLE_TYPE_RAW:
94+
case DPI_ORACLE_TYPE_LONG_RAW:
95+
return NJS_DATATYPE_BUFFER;
96+
case DPI_ORACLE_TYPE_NATIVE_FLOAT:
97+
case DPI_ORACLE_TYPE_NATIVE_DOUBLE:
98+
case DPI_ORACLE_TYPE_NATIVE_INT:
99+
case DPI_ORACLE_TYPE_NUMBER:
100100
return NJS_DATATYPE_NUM;
101-
case DPI_ORACLE_VARTYPE_DATE:
102-
case DPI_ORACLE_VARTYPE_TIMESTAMP:
103-
case DPI_ORACLE_VARTYPE_TIMESTAMP_TZ:
104-
case DPI_ORACLE_VARTYPE_TIMESTAMP_LTZ:
101+
case DPI_ORACLE_TYPE_DATE:
102+
case DPI_ORACLE_TYPE_TIMESTAMP:
103+
case DPI_ORACLE_TYPE_TIMESTAMP_TZ:
104+
case DPI_ORACLE_TYPE_TIMESTAMP_LTZ:
105105
return NJS_DATATYPE_DATE;
106-
case DPI_ORACLE_VARTYPE_CLOB:
107-
case DPI_ORACLE_VARTYPE_NCLOB:
106+
case DPI_ORACLE_TYPE_CLOB:
107+
case DPI_ORACLE_TYPE_NCLOB:
108108
return NJS_DATATYPE_CLOB;
109-
case DPI_ORACLE_VARTYPE_BLOB:
109+
case DPI_ORACLE_TYPE_BLOB:
110110
return NJS_DATATYPE_BLOB;
111111
default:
112112
break;
@@ -195,6 +195,10 @@ njsBaton::~njsBaton()
195195
delete [] bindVars;
196196
bindVars = NULL;
197197
}
198+
if (protoILob) {
199+
delete protoILob;
200+
protoILob = NULL;
201+
}
198202
if (!keepQueryInfo) {
199203
if (queryVars) {
200204
delete [] queryVars;
@@ -208,6 +212,10 @@ njsBaton::~njsBaton()
208212
delete [] fetchAsStringTypes;
209213
fetchAsStringTypes = NULL;
210214
}
215+
if (fetchAsBufferTypes) {
216+
delete [] fetchAsBufferTypes;
217+
fetchAsBufferTypes = NULL;
218+
}
211219
}
212220
}
213221

@@ -267,7 +275,7 @@ void njsBaton::AsyncAfterWorkCallback(uv_work_t *req, int status)
267275
// reset all remaining parameters as undefined
268276
if (!baton->error.empty()) {
269277
callbackArgs[0] = v8::Exception::Error(Nan::New<v8::String>(
270-
baton->error.c_str()).ToLocalChecked());
278+
baton->error).ToLocalChecked());
271279
for (i = 1; i < numCallbackArgs; i++)
272280
callbackArgs[i] = Nan::Undefined();
273281
}
@@ -395,6 +403,36 @@ bool njsBaton::GetBoolFromJSON(Local<Object> obj, const char *key, int index,
395403
}
396404

397405

406+
//-----------------------------------------------------------------------------
407+
// njsBaton::GetIntFromJSON()
408+
// Gets a signed integer value from the JSON object for the given key, if
409+
// possible. If undefined, leave value alone and do not set error; otherwise,
410+
// set error. Index is the argument index in the caller.
411+
//-----------------------------------------------------------------------------
412+
bool njsBaton::GetIntFromJSON(Local<Object> obj, const char *key,
413+
int index, int32_t *value)
414+
{
415+
Nan::HandleScope scope;
416+
Local<Value> jsValue;
417+
418+
if (!error.empty())
419+
return false;
420+
jsValue = obj->Get(Nan::New<v8::String>(key).ToLocalChecked());
421+
if (jsValue->IsInt32()) {
422+
*value = Nan::To<int32_t>(jsValue).FromJust();
423+
return true;
424+
} else if (jsValue->IsUndefined() || jsValue->IsNull()) {
425+
return true;
426+
} else if (jsValue->IsNumber()) {
427+
error = njsMessages::Get(errInvalidPropertyValueInParam, key,
428+
index + 1);
429+
return false;
430+
}
431+
error = njsMessages::Get(errInvalidPropertyTypeInParam, key, index + 1);
432+
return false;
433+
}
434+
435+
398436
//-----------------------------------------------------------------------------
399437
// njsBaton::GetStringFromJSON()
400438
// Gets a string value from the JSON object for the given key, if possible.
@@ -555,6 +593,42 @@ bool njsCommon::GetUnsignedIntArg(Nan::NAN_METHOD_ARGS_TYPE args,
555593
}
556594

557595

596+
//-----------------------------------------------------------------------------
597+
// njsCommon::SetPropBool()
598+
// Sets a property to a boolean value. If the value is not a boolean, an
599+
// error is raised and false is returned.
600+
//-----------------------------------------------------------------------------
601+
bool njsCommon::SetPropBool(Local<Value> value, bool *valuePtr,
602+
const char *name)
603+
{
604+
if (!value->IsBoolean()) {
605+
string errMsg = njsMessages::Get(errInvalidPropertyValue, name);
606+
Nan::ThrowError(errMsg.c_str());
607+
return false;
608+
}
609+
*valuePtr = value->ToBoolean()->Value();
610+
return true;
611+
}
612+
613+
614+
//-----------------------------------------------------------------------------
615+
// njsCommon::SetPropInt()
616+
// Sets a property to an integer value. If the value is not an integer, an
617+
// error is raised and false is returned.
618+
//-----------------------------------------------------------------------------
619+
bool njsCommon::SetPropInt(Local<Value> value, int32_t *valuePtr,
620+
const char *name)
621+
{
622+
if (!value->IsInt32()) {
623+
string errMsg = njsMessages::Get(errInvalidPropertyValue, name);
624+
Nan::ThrowError(errMsg.c_str());
625+
return false;
626+
}
627+
*valuePtr = Nan::To<int32_t>(value).FromJust();
628+
return true;
629+
}
630+
631+
558632
//-----------------------------------------------------------------------------
559633
// njsCommon::SetPropString()
560634
// Sets a property to a string value. If the value is not a string, an error
@@ -683,22 +757,3 @@ void njsCommon::PropertyIsReadOnly(const char *name)
683757
Nan::ThrowError(errMsg.c_str());
684758
}
685759

686-
//-----------------------------------------------------------------------------
687-
// njsCommon::SetPropBool()
688-
// Sets a property to a boolean value. If the value is not a boolean, an
689-
// error is raised and false is returned.
690-
//-----------------------------------------------------------------------------
691-
bool njsCommon::SetPropBool(Local<Value> value, bool *valuePtr,
692-
const char *name)
693-
{
694-
if (!value->IsBoolean()) {
695-
string errMsg = njsMessages::Get(errInvalidPropertyValue, name);
696-
Nan::ThrowError(errMsg.c_str());
697-
return false;
698-
}
699-
*valuePtr = value->ToBoolean()->Value();
700-
return true;
701-
}
702-
703-
704-
//-----------------------------------------------------------------------------

src/njs/src/njsCommon.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ friend class njsBaton;
209209
bool GetUnsignedIntArg(Nan::NAN_METHOD_ARGS_TYPE args, int index,
210210
uint32_t *value);
211211
bool SetPropBool(Local<Value> value, bool *valuePtr, const char *name);
212+
bool SetPropInt(Local<Value> value, int32_t *valuePtr, const char *name);
212213
bool SetPropString(Local<Value> value, std::string *valuePtr,
213214
const char *name);
214215
bool SetPropUnsignedInt(Local<Value> value, uint32_t *valuePtr,
@@ -239,6 +240,7 @@ class njsBaton {
239240
uint32_t poolMax;
240241
uint32_t poolIncrement;
241242
uint32_t poolTimeout;
243+
int32_t poolPingInterval;
242244
dpiPool *dpiPoolHandle;
243245
dpiConn *dpiConnHandle;
244246
dpiStmt *dpiStmtHandle;
@@ -259,6 +261,9 @@ class njsBaton {
259261
njsFetchInfo *fetchInfo;
260262
uint32_t numFetchAsStringTypes;
261263
njsDataType *fetchAsStringTypes;
264+
uint32_t numFetchAsBufferTypes;
265+
njsDataType *fetchAsBufferTypes;
266+
njsProtoILob *protoILob;
262267
bool externalAuth;
263268
bool getRS;
264269
bool autoCommit;
@@ -282,19 +287,20 @@ class njsBaton {
282287
dpiPoolHandle(NULL), dpiConnHandle(NULL), dpiStmtHandle(NULL),
283288
dpiLobHandle(NULL), numQueryVars(0), queryVars(NULL),
284289
numBindVars(0), bindVars(NULL), numFetchInfo(0), fetchInfo(NULL),
285-
numFetchAsStringTypes(0), fetchAsStringTypes(NULL), repeat(false),
286-
keepQueryInfo(false), isReturning(false), bufferSize(0),
287-
bufferPtr(NULL)
290+
numFetchAsStringTypes(0), fetchAsStringTypes(NULL),
291+
numFetchAsBufferTypes(0), fetchAsBufferTypes(NULL),
292+
protoILob(NULL), keepQueryInfo(false), isReturning(false),
293+
bufferSize(0), bufferPtr(NULL), lobOffset(0), lobAmount(0)
288294
{
289-
jsCallback.Reset(callback);
290-
jsCallingObj.Reset(callingObj);
295+
this->jsCallback.Reset(callback);
296+
this->jsCallingObj.Reset(callingObj);
297+
this->callingObj = Nan::ObjectWrap::Unwrap<njsCommon>(callingObj);
291298
req.data = this;
292299
}
293300
~njsBaton();
294301

295302
// methods for getting information from JS objects stored on baton
296303
njsOracledb *GetOracledb();
297-
njsCommon *GetCallingObj();
298304

299305
// methods for getting DPI errors
300306
void GetDPIError(void);
@@ -310,6 +316,8 @@ class njsBaton {
310316
bool *value);
311317
bool GetStringFromJSON(Local<Object> obj, const char *key, int index,
312318
string &value);
319+
bool GetIntFromJSON(Local<Object> obj, const char *key, int index,
320+
int32_t *value);
313321
bool GetUnsignedIntFromJSON(Local<Object> obj, const char *key, int index,
314322
uint32_t *value);
315323

0 commit comments

Comments
 (0)