Skip to content

Commit

Permalink
fix: use passed length as buffer size for binary array insert, issue #…
Browse files Browse the repository at this point in the history
  • Loading branch information
bimalkjha committed Dec 18, 2022
1 parent 85d3246 commit 773fde8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/odbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,11 +1153,18 @@ void ODBC::GetBufferParam(Local<Value> value, Parameter * param, int num)
{
DEBUG_PRINTF("ODBC::GetBufferParam - It's a buffer.\n");
param->buffer = (char *) Buffer::Data(value);
param->size = Buffer::Length(value);
param->buffer_length = param->size;
param->length = param->buffer_length;
param->length = Buffer::Length(value);
int bufflen = param->length;
param->isBuffer = true; // Dont free it in FREE_PARAMS

if(bufflen <= param->buffer_length &&
((param->paramtype % 2 == 0) || (param->arraySize > 0)))
{
bufflen = param->buffer_length;
}
param->buffer_length = bufflen;
param->size = bufflen;

if(!param->c_type || (param->c_type == SQL_CHAR))
param->c_type = SQL_C_TCHAR;
#ifdef UNICODE
Expand Down
6 changes: 3 additions & 3 deletions test/test-binary-array-insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ async function main() {
console.log(results)

const data = [
'628bacf012d4628bacf012d4',
'628bacf012d4628bacd4',
'628bacf012d5628bacf012d5',
'628bacf012d6628bacf012d6',
'628bacf012d7628bacf012d7',
'628bacf012d6628bacf0d6',
'628bacf012d7628bacf0d7',
'628bacf012d8628bacf012d8'
]
ibmdb.debug(2);
Expand Down

0 comments on commit 773fde8

Please sign in to comment.