Skip to content

Commit a597588

Browse files
committed
Fix 4K DML RETURNING strings with Oracle DB 11.2
1 parent 22dc387 commit a597588

File tree

3 files changed

+9
-31
lines changed

3 files changed

+9
-31
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## node-oracledb v1.3.0 (DD Mon YYYY)
44

5+
- Fixed 11.2.0.4 DB-specific NULL output with DML RETURNING when string value is of size 4k.
6+
57
## node-oracledb v1.2.0 (25 Sep 2015)
68

79
- Added support for RAW data type.

src/njs/src/njsConnection.cpp

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,6 @@ void Connection::Async_Execute (uv_work_t *req)
10611061
*/
10621062
void Connection::PrepareAndBind (eBaton* executeBaton)
10631063
{
1064-
DPI_SZ_TYPE maxSize = 0; // maxSize for out bind; add 1 for dml returning
10651064
executeBaton->dpistmt = executeBaton->dpiconn->getStmt(executeBaton->sql);
10661065
executeBaton->st = executeBaton->dpistmt->stmtType ();
10671066
executeBaton->stmtIsReturning = executeBaton->dpistmt->isReturning ();
@@ -1110,26 +1109,15 @@ void Connection::PrepareAndBind (eBaton* executeBaton)
11101109
Connection::UpdateDateValue ( executeBaton, index ) ;
11111110
}
11121111

1113-
/*
1114-
* In case of DML Returning, add 1 extra byte, to check for
1115-
* more data
1116-
*/
1117-
if ( ( executeBaton->binds[index]->type == dpi::DpiVarChar) &&
1118-
( executeBaton->stmtIsReturning ) )
1119-
{
1120-
maxSize = executeBaton->binds[index]->maxSize + 1;
1121-
}
1122-
else
1123-
{
1124-
maxSize = executeBaton->binds[index]->maxSize;
1125-
}
11261112
// Bind by name
11271113
executeBaton->dpistmt->bind(
11281114
(const unsigned char*)executeBaton->binds[index]->key.c_str(),
11291115
(int) executeBaton->binds[index]->key.length(), index,
11301116
executeBaton->binds[index]->type,
11311117
executeBaton->binds[index]->value,
1132-
(executeBaton->binds[index]->type == dpi::DpiVarChar ) ?
1118+
(executeBaton->stmtIsReturning &&
1119+
executeBaton->binds[index]->isOut &&
1120+
(executeBaton->binds[index]->type == dpi::DpiVarChar))?
11331121
(executeBaton->binds[index]->maxSize + 1) :
11341122
executeBaton->binds[index]->maxSize,
11351123
executeBaton->binds[index]->ind,
@@ -1168,25 +1156,13 @@ void Connection::PrepareAndBind (eBaton* executeBaton)
11681156
Connection::UpdateDateValue ( executeBaton, index ) ;
11691157
}
11701158

1171-
/*
1172-
* In case of DML Returning, add 1 extra byte, to check for
1173-
* more data
1174-
*/
1175-
1176-
if ( ( executeBaton->binds[index]->type == dpi::DpiVarChar) &&
1177-
( executeBaton->stmtIsReturning ) )
1178-
{
1179-
maxSize = executeBaton->binds[index]->maxSize + 1;
1180-
}
1181-
else
1182-
{
1183-
maxSize = executeBaton->binds[index]->maxSize;
1184-
}
11851159
// Bind by position
11861160
executeBaton->dpistmt->bind(
11871161
index+1,executeBaton->binds[index]->type,
11881162
executeBaton->binds[index]->value,
1189-
(executeBaton->binds[index]->type == dpi::DpiVarChar ) ?
1163+
(executeBaton->stmtIsReturning &&
1164+
executeBaton->binds[index]->isOut &&
1165+
(executeBaton->binds[index]->type == dpi::DpiVarChar))?
11901166
(executeBaton->binds[index]->maxSize + 1) :
11911167
executeBaton->binds[index]->maxSize,
11921168
executeBaton->binds[index]->ind,

test/binding.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ describe('4. binding.js', function() {
675675
);
676676
})
677677

678-
it.skip('4.4.3 Negative - bind out data exceeds default length', function(done) {
678+
it('4.4.3 Negative - bind out data exceeds default length', function(done) {
679679
connection.execute(
680680
"BEGIN :o := lpad('A',201,'x'); END;",
681681
{ o: { type: oracledb.STRING, dir : oracledb.BIND_OUT } },

0 commit comments

Comments
 (0)