@@ -2054,7 +2054,8 @@ void Connection::CLOB2String ( eBaton* executeBaton, unsigned int index )
2054
2054
unsigned long long byteAmount = 0 ;
2055
2055
// Set the charAmount to (maxSize + 1) to know whether given maxSize good
2056
2056
// enough to store PLSQL OUT data
2057
- unsigned long long charAmount = executeBaton->binds [index]->maxSize + 1 ;
2057
+ unsigned long long charAmount =
2058
+ executeBaton->extBinds [index]->fields .extLob .maxSize + 1 ;
2058
2059
2059
2060
executeBaton->binds [index]->type = DpiVarChar;
2060
2061
LOB2StringOrBuffer ( executeBaton, index, byteAmount, charAmount );
@@ -2078,7 +2079,8 @@ void Connection::BLOB2Buffer ( eBaton* executeBaton, unsigned int index )
2078
2079
{
2079
2080
// Set the charAmount to (maxSize + 1) to know whether given maxSize good
2080
2081
// enough to store PLSQL OUT data
2081
- unsigned long long byteAmount = executeBaton->binds [index]->maxSize + 1 ;
2082
+ unsigned long long byteAmount =
2083
+ executeBaton->extBinds [index]->fields .extLob .maxSize + 1 ;
2082
2084
unsigned long long charAmount = 0 ;
2083
2085
2084
2086
executeBaton->binds [index]->type = DpiRaw;
@@ -2141,7 +2143,8 @@ void Connection::LOB2StringOrBuffer ( eBaton* executeBaton, unsigned int index,
2141
2143
* of charAmount or byteAmount passed to Lob::read()
2142
2144
* If there is more data in the LOB than the maxSize, set the error
2143
2145
*/
2144
- if ( byteAmount > ( unsigned long long ) bind->maxSize )
2146
+ if ( byteAmount > ( unsigned long long )
2147
+ executeBaton->extBinds [index]->fields .extLob .maxSize )
2145
2148
{
2146
2149
executeBaton->error = NJSMessages::getErrorMsg (
2147
2150
errInsufficientBufferForBinds);
@@ -2313,7 +2316,9 @@ void Connection::Descr2StringOrBuffer ( eBaton* executeBaton )
2313
2316
}
2314
2317
else
2315
2318
{
2316
- if ( *bind->ind != -1 )
2319
+ if ( Lob::isTempLob ( executeBaton->dpienv ->envHandle (),
2320
+ executeBaton->dpiconn ->getErrh (),
2321
+ *( Descriptor** ) bind->value ) )
2317
2322
{
2318
2323
Lob::freeTempLob ( executeBaton->dpiconn ->getSvch (),
2319
2324
executeBaton->dpiconn ->getErrh (),
@@ -2355,12 +2360,14 @@ void Connection::ConvertStringOrBuffer2LOB ( eBaton* executeBaton,
2355
2360
{
2356
2361
Bind *bind = executeBaton->binds [index];
2357
2362
2358
- // In case of IN bind convert string/buffer to LOB if input data
2359
- // is not NULL and data size more than 32k
2360
- if ( !bind->isOut && *bind->ind != -1 &&
2361
- ( bind->len && *bind->len > NJS_THRESHOLD_SIZE_PLSQL_STRING_ARG ) )
2363
+ // In case of IN or INOUT bind convert string/buffer to LOB if input data
2364
+ // is not NULL and input data size more than 32k for strict IN binds or
2365
+ // maxSize more than 32k for INOUT binds
2366
+ if ( ( ( !bind->isOut || bind->isInOut ) && *bind->ind != -1 ) &&
2367
+ ( ( !bind->isOut && *bind->len > NJS_THRESHOLD_SIZE_PLSQL_STRING_ARG ) ||
2368
+ ( bind->isInOut && bind->maxSize > NJS_THRESHOLD_SIZE_PLSQL_STRING_ARG
2369
+ ) ) )
2362
2370
{
2363
- // This block is only for BIND_IN case
2364
2371
ExtBind* extBind = new ExtBind ();
2365
2372
if ( !extBind )
2366
2373
{
@@ -2369,25 +2376,24 @@ void Connection::ConvertStringOrBuffer2LOB ( eBaton* executeBaton,
2369
2376
goto exitConvertStringOrBuffer2LOB;
2370
2377
}
2371
2378
executeBaton->njsconn ->InitExtBind ( extBind, NJS_EXTBIND_LOB );
2372
- // Set a flag to know that type conversion happened
2373
- // This helps in later steps to clean LOB resources
2374
- extBind->fields .extLob .isStringBuffer2LOB = true ;
2375
- executeBaton->extBinds [index] = extBind;
2379
+ extBind->fields .extLob .maxSize = bind->maxSize ;
2376
2380
2377
2381
if ( bind->type == DpiVarChar )
2378
2382
{
2379
- // Convert String to CLOB
2380
2383
String2CLOB ( executeBaton, index );
2381
2384
}
2382
2385
else
2383
2386
{
2384
- // Convert Buffer to BLOB
2385
2387
Buffer2BLOB ( executeBaton, index );
2386
2388
}
2389
+ // Set a flag to know that type conversion happened
2390
+ // This helps in later steps to clean LOB resources
2391
+ extBind->fields .extLob .isStringBuffer2LOB = true ;
2392
+ executeBaton->extBinds [index] = extBind;
2387
2393
}
2388
- else if ( bind->maxSize > NJS_THRESHOLD_SIZE_PLSQL_STRING_ARG )
2394
+ else if ( ( bind->isOut || bind->isInOut ) &&
2395
+ bind->maxSize > NJS_THRESHOLD_SIZE_PLSQL_STRING_ARG )
2389
2396
{
2390
- // This block is only for BIND_OUT case
2391
2397
ExtBind* extBind = new ExtBind ();
2392
2398
2393
2399
if ( !extBind )
@@ -2397,6 +2403,7 @@ void Connection::ConvertStringOrBuffer2LOB ( eBaton* executeBaton,
2397
2403
goto exitConvertStringOrBuffer2LOB;
2398
2404
}
2399
2405
executeBaton->njsconn ->InitExtBind ( extBind, NJS_EXTBIND_LOB );
2406
+ extBind->fields .extLob .maxSize = bind->maxSize ;
2400
2407
2401
2408
// Set a flag to know that type conversion happened
2402
2409
// This helps in later steps for converting LOB to String/Buffer and
@@ -2476,6 +2483,7 @@ void Connection::InitExtBind ( ExtBind *extBind, ExtBindType fieldType )
2476
2483
{
2477
2484
extBind->fields .extLob .value = NULL ;
2478
2485
extBind->fields .extLob .isStringBuffer2LOB = false ;
2486
+ extBind->fields .extLob .maxSize = 0 ;
2479
2487
}
2480
2488
}
2481
2489
@@ -2514,9 +2522,8 @@ void Connection::PrepareAndBind (eBaton* executeBaton)
2514
2522
if ( ( executeBaton->st == DpiStmtBegin ||
2515
2523
executeBaton->st == DpiStmtDeclare ||
2516
2524
executeBaton->st == DpiStmtCall ) &&
2517
- ( !executeBaton->binds [index]->isInOut &&
2518
2525
( executeBaton->binds [index]->type == DpiVarChar ||
2519
- executeBaton->binds [index]->type == DpiRaw ) ) )
2526
+ executeBaton->binds [index]->type == DpiRaw ) )
2520
2527
{
2521
2528
ConvertStringOrBuffer2LOB ( executeBaton, index );
2522
2529
}
@@ -2590,9 +2597,8 @@ void Connection::PrepareAndBind (eBaton* executeBaton)
2590
2597
if ( ( executeBaton->st == DpiStmtBegin ||
2591
2598
executeBaton->st == DpiStmtDeclare ||
2592
2599
executeBaton->st == DpiStmtCall ) &&
2593
- ( !executeBaton->binds [index]->isInOut &&
2594
2600
( executeBaton->binds [index]->type == DpiVarChar ||
2595
- executeBaton->binds [index]->type == DpiRaw ) ) )
2601
+ executeBaton->binds [index]->type == DpiRaw ) )
2596
2602
{
2597
2603
ConvertStringOrBuffer2LOB ( executeBaton, index );
2598
2604
}
0 commit comments