Skip to content

Commit

Permalink
SNOW-979081: Debug windows binds with UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dprzybysz committed Jun 12, 2024
1 parent bd37592 commit 60e703a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 6 additions & 5 deletions bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void ExecuteQuery(const FunctionCallbackInfo<Value>& args) {
GENERIC_LOG_TRACE("Number of binds is %d", number_of_binds);
SF_BIND_INPUT* input_array = (SF_BIND_INPUT*) malloc(number_of_binds * sizeof (SF_BIND_INPUT));
int64 paramInteger;
char* paramString;
char paramString[1024];
for (int64 i = 0; i < number_of_binds; ++i){
GENERIC_LOG_TRACE("Creating bind param %d", i);
snowflake_bind_input_init(&input_array[i]);
Expand All @@ -303,19 +303,20 @@ void ExecuteQuery(const FunctionCallbackInfo<Value>& args) {
} else if (bindValue->IsString()) {
String::Utf8Value str(isolate, bindValue.As<String>());
string cppStr(*str);
paramString = (char*) cppStr.c_str(); // TODO how to allow to borrow value in a correct way?
GENERIC_LOG_TRACE("Setting bind param[%d] as string to %s, length %d", i, paramString, strlen(paramString));
strcpy(paramString, cppStr.c_str()); // TODO how to allow to borrow value in a correct way?
GENERIC_LOG_ERROR("Setting bind param[%d] as string to %s, length %d", i, paramString, strlen(paramString));
input_array[i].c_type = SF_C_TYPE_STRING;
input_array[i].value = paramString;
input_array[i].len = strlen(paramString);
} else {
GENERIC_LOG_ERROR("Unknown bind parameter %s", bindValue);
}
}
GENERIC_LOG_ERROR("Param string is %s", paramString);
status = snowflake_bind_param_array(statement, input_array, number_of_binds);
GENERIC_LOG_TRACE("Passing bind params status is %d", status);
GENERIC_LOG_ERROR("Passing bind params status is %d", status);
status = snowflake_execute(statement);
GENERIC_LOG_TRACE("Execute statement status is %d", status);
GENERIC_LOG_ERROR("Execute statement status is %d", status);
free(input_array);
}
// GENERIC_LOG_TRACE("Statement metadata - first column type: %d, c_type: %d and expected type is %d", statement->desc[0].type, statement->desc[0].c_type, SF_C_TYPE_INT64);
Expand Down
6 changes: 1 addition & 5 deletions test/integration/generic/generic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ describe.only('test generic binding', () => {
};

before(() => {
if (process.platform === 'win32') {
generic.init('FATAL');
} else {
generic.init('FATAL');
}
generic.init('ERROR');
});

it('should get libsfclient version', () => {
Expand Down

0 comments on commit 60e703a

Please sign in to comment.