From 60e703a5fe69e2b4853a410451f3149f5ea1ada6 Mon Sep 17 00:00:00 2001 From: Dominik Przybysz Date: Wed, 12 Jun 2024 12:50:37 +0200 Subject: [PATCH] SNOW-979081: Debug windows binds with UTF-8 --- bindings.cc | 11 ++++++----- test/integration/generic/generic_test.js | 6 +----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/bindings.cc b/bindings.cc index 9bca3f686..f9f0c2021 100644 --- a/bindings.cc +++ b/bindings.cc @@ -288,7 +288,7 @@ void ExecuteQuery(const FunctionCallbackInfo& 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]); @@ -303,8 +303,8 @@ void ExecuteQuery(const FunctionCallbackInfo& args) { } else if (bindValue->IsString()) { String::Utf8Value str(isolate, bindValue.As()); 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); @@ -312,10 +312,11 @@ void ExecuteQuery(const FunctionCallbackInfo& args) { 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); diff --git a/test/integration/generic/generic_test.js b/test/integration/generic/generic_test.js index ddb53bc6f..e16bab6ed 100644 --- a/test/integration/generic/generic_test.js +++ b/test/integration/generic/generic_test.js @@ -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', () => {