@@ -1304,10 +1304,7 @@ void Connection::GetInBindParamsScalar(Local<Value> v8val, Bind* bind,
1304
1304
executeBaton->njsconn ->InitExtBind ( extBind, NJS_EXTBIND_LOB );
1305
1305
1306
1306
// Store the reference to IN LOB object
1307
- extBind->fields .extLob .value =
1308
- ( void * ) malloc ( sizeof ( Descriptor * ) );
1309
- *(Descriptor **)extBind->fields .extLob .value =
1310
- reinterpret_cast <Descriptor *>(iLob);
1307
+ extBind->fields .extLob .value = (void *) iLob;
1311
1308
1312
1309
// create a persistent reference to avoid un-expected GC
1313
1310
Nan::Persistent<Object> *jsBindObj;
@@ -1987,7 +1984,6 @@ void Connection::Async_Execute (uv_work_t *req)
1987
1984
if ( !executeBaton->binds [index]->isOut )
1988
1985
{
1989
1986
Lob::freeTempLob (
1990
- executeBaton->dpienv ->envHandle (),
1991
1987
executeBaton->dpiconn ->getSvch (),
1992
1988
executeBaton->dpiconn ->getErrh (),
1993
1989
*( Descriptor** ) executeBaton->binds [index]->value );
@@ -2118,7 +2114,13 @@ void Connection::LOB2StringOrBuffer ( eBaton* executeBaton, unsigned int index,
2118
2114
*bind->len = ( DPI_BUFLEN_TYPE ) byteAmount;
2119
2115
2120
2116
exitLOB2StringOrBuffer:
2121
- // Free the allocated LOB descriptor and memory for out bind
2117
+ if ( Lob::isTempLob ( executeBaton->dpienv ->envHandle (),
2118
+ executeBaton->dpiconn ->getErrh (), lobLocator ) )
2119
+ {
2120
+ Lob::freeTempLob ( executeBaton->dpiconn ->getSvch (),
2121
+ executeBaton->dpiconn ->getErrh (),
2122
+ lobLocator );
2123
+ }
2122
2124
Env::freeDescriptor ( lobLocator, LobDescriptorType );
2123
2125
if ( !executeBaton->error .empty () )
2124
2126
{
@@ -2268,11 +2270,12 @@ void Connection::Descr2StringOrBuffer ( eBaton* executeBaton )
2268
2270
}
2269
2271
else
2270
2272
{
2271
- // Free the temp LOB created for IN bind
2272
- Lob::freeTempLob ( executeBaton->dpienv ->envHandle (),
2273
- executeBaton->dpiconn ->getSvch (),
2274
- executeBaton->dpiconn ->getErrh (),
2275
- *( Descriptor** ) bind->value );
2273
+ if ( *bind->ind != -1 )
2274
+ {
2275
+ Lob::freeTempLob ( executeBaton->dpiconn ->getSvch (),
2276
+ executeBaton->dpiconn ->getErrh (),
2277
+ *( Descriptor** ) bind->value );
2278
+ }
2276
2279
2277
2280
// Free the allocated LOB descriptor
2278
2281
Env::freeDescriptor ( *(Descriptor **) bind->value ,
@@ -2392,8 +2395,8 @@ void Connection::PrepareLOBsForBind ( eBaton* executeBaton, unsigned int index )
2392
2395
executeBaton->extBinds [index]->type == NJS_EXTBIND_LOB &&
2393
2396
!executeBaton->extBinds [index]->fields .extLob .isStringBuffer2LOB )
2394
2397
{
2395
- ILob *iLob = ( ILob * ) ( * ( static_cast <ILob**>
2396
- ( executeBaton->extBinds [index]->fields .extLob .value ) ) ) ;
2398
+ ILob *iLob = ( ILob * )
2399
+ ( executeBaton->extBinds [index]->fields .extLob .value );
2397
2400
2398
2401
if ( bind->isInOut )
2399
2402
{
@@ -3458,9 +3461,11 @@ void Connection::Async_AfterExecute(uv_work_t *req)
3458
3461
executeBaton->extBinds [index]->type == NJS_EXTBIND_LOB &&
3459
3462
!executeBaton->extBinds [index]->fields .extLob .isStringBuffer2LOB )
3460
3463
{
3461
- ILob *iLob = ( ILob * ) ( * ( static_cast <ILob**>
3462
- ( executeBaton->extBinds [index]->fields .extLob .value ) ) );
3464
+ ILob *iLob = ( ILob * )
3465
+ ( executeBaton->extBinds [index]->fields .extLob .value );
3463
3466
iLob->postBind ();
3467
+
3468
+ executeBaton->extBinds [index]->fields .extLob .value = NULL ;
3464
3469
}
3465
3470
}
3466
3471
}
@@ -4212,10 +4217,6 @@ ConnectionBusyStatus Connection::getConnectionBusyStatus ( Connection *conn )
4212
4217
connStatus = NJS_CONN_BUSY_RS;
4213
4218
else if ( conn->dbCount_ != 1 ) // 1 for Release operaion itself
4214
4219
connStatus = NJS_CONN_BUSY_DB;
4215
- else if ( conn->tempLobCount_ != 0 )
4216
- {
4217
- connStatus = NJS_CONN_BUSY_TEMPLOB;
4218
- }
4219
4220
4220
4221
return connStatus;
4221
4222
}
@@ -4275,9 +4276,6 @@ NAN_METHOD(Connection::Release)
4275
4276
case NJS_CONN_BUSY_DB:
4276
4277
releaseBaton->error = NJSMessages::getErrorMsg ( errBusyConnDB );
4277
4278
break ;
4278
- case NJS_CONN_BUSY_TEMPLOB:
4279
- releaseBaton->error = NJSMessages::getErrorMsg ( errBusyConnTEMPLOB );
4280
- break ;
4281
4279
}
4282
4280
4283
4281
exitRelease:
@@ -4347,7 +4345,19 @@ void Connection::Async_AfterRelease(uv_work_t *req)
4347
4345
argv[0 ] = v8::Exception::Error (
4348
4346
Nan::New<v8::String>(releaseBaton->error ).ToLocalChecked ());
4349
4347
else
4350
- argv[0 ] = Nan::Undefined ();
4348
+ {
4349
+ // Populate error if Temporary LOBs are still open
4350
+ if ( releaseBaton->njsconn ->tempLobCount_ != 0 )
4351
+ {
4352
+ releaseBaton->error = NJSMessages::getErrorMsg ( errBusyConnTEMPLOB );
4353
+ argv[0 ] = v8::Exception::Error (
4354
+ Nan::New<v8::String>(releaseBaton->error ).ToLocalChecked ());
4355
+ }
4356
+ else
4357
+ {
4358
+ argv[0 ] = Nan::Undefined ();
4359
+ }
4360
+ }
4351
4361
4352
4362
/*
4353
4363
* When we release the connection, we have to clear the reference of
@@ -4847,8 +4857,7 @@ void Connection::Async_AfterCreateLob (uv_work_t *req)
4847
4857
createLobBaton->lobInfo ->lobLocator ,
4848
4858
lobType );
4849
4859
4850
- // The last parameter sets isTempLob_ to true
4851
- Local<Value> value = NewLob ( createLobBaton, protoILob, true );
4860
+ Local<Value> value = NewLob ( createLobBaton, protoILob, false );
4852
4861
4853
4862
delete protoILob;
4854
4863
@@ -5344,12 +5353,13 @@ int Connection::cbDynBufferGet ( void *ctx, DPI_SZ_TYPE nRows,
5344
5353
Create a new LOB object.
5345
5354
5346
5355
PARAMETERS
5347
- executeBaton - eBaton struct containing execute context info
5348
- protoILob - ProtoILob object created using LOB locator in the process
5349
- of creating ILob object
5350
- isTempLob - boolean
5351
- true - in case of temporary LOB
5352
- false - otherwise
5356
+ executeBaton - eBaton struct containing execute context info
5357
+ protoILob - ProtoILob object created using LOB locator in the process
5358
+ of creating ILob object
5359
+ isAutoCloseLob - bool
5360
+ true - the Lob object will be closed at end of streaming
5361
+ operation
5362
+ false - otherwise
5353
5363
5354
5364
RETURNS
5355
5365
a Lob object
@@ -5372,7 +5382,7 @@ int Connection::cbDynBufferGet ( void *ctx, DPI_SZ_TYPE nRows,
5372
5382
5373
5383
v8::Local<v8::Value> Connection::NewLob ( eBaton *executeBaton,
5374
5384
ProtoILob *protoILob,
5375
- bool isTempLob )
5385
+ bool isAutoCloseLob )
5376
5386
{
5377
5387
Nan::EscapableHandleScope scope;
5378
5388
Connection *connection = executeBaton->njsconn ;
@@ -5390,7 +5400,7 @@ v8::Local<v8::Value> Connection::NewLob( eBaton *executeBaton,
5390
5400
// handles in the ILob cleanup routine.
5391
5401
5392
5402
(Nan::ObjectWrap::Unwrap<ILob>(iLob))->setILob ( executeBaton, protoILob,
5393
- isTempLob );
5403
+ isAutoCloseLob );
5394
5404
5395
5405
if (!executeBaton->error .empty ())
5396
5406
return Nan::Null ();
0 commit comments