alinaliBQ commented on code in PR #47771:
URL: https://github.com/apache/arrow/pull/47771#discussion_r2430783228


##########
cpp/src/arrow/flight/sql/odbc/odbc_impl/config/configuration.cc:
##########
@@ -35,23 +36,27 @@ static const char DEFAULT_DISABLE_CERT_VERIFICATION[] = 
FALSE_STR;
 namespace {
 std::string ReadDsnString(const std::string& dsn, const std::string_view& key,
                           const std::string& dflt = "") {
-#define BUFFER_SIZE (1024)
-  std::vector<char> buf(BUFFER_SIZE);
+  std::wstring wdsn = arrow::util::UTF8ToWideString(dsn).ValueOr(L"");

Review Comment:
   You raise a good point, these errors should not be ignored. I have added 
throws for the Result errors.
   The caller will catch the exceptions thrown



##########
cpp/src/arrow/flight/sql/odbc/odbc_impl/config/configuration.cc:
##########
@@ -68,28 +73,32 @@ void RemoveAllKnownKeys(std::vector<std::string>& keys) {
 }
 
 std::vector<std::string> ReadAllKeys(const std::string& dsn) {

Review Comment:
   Same as above comment, I have added throws



##########
cpp/src/arrow/flight/sql/odbc/odbc_impl/config/configuration.cc:
##########
@@ -153,6 +162,11 @@ const std::string& Configuration::Get(const 
std::string_view& key) const {
   return itr->second;
 }
 
+void Configuration::Set(const std::string_view& key, const std::wstring& 
wvalue) {

Review Comment:
   Same as above comment, I have added throws



##########
cpp/src/arrow/flight/sql/odbc/odbc_impl/config/configuration.cc:
##########
@@ -35,23 +36,27 @@ static const char DEFAULT_DISABLE_CERT_VERIFICATION[] = 
FALSE_STR;
 namespace {
 std::string ReadDsnString(const std::string& dsn, const std::string_view& key,
                           const std::string& dflt = "") {
-#define BUFFER_SIZE (1024)
-  std::vector<char> buf(BUFFER_SIZE);
+  std::wstring wdsn = arrow::util::UTF8ToWideString(dsn).ValueOr(L"");
+  std::wstring wkey = arrow::util::UTF8ToWideString(key).ValueOr(L"");
+  std::wstring wdflt = arrow::util::UTF8ToWideString(dflt).ValueOr(L"");
 
-  std::string key_str = std::string(key);
+#define BUFFER_SIZE (1024)
+  std::vector<wchar_t> buf(BUFFER_SIZE);
   int ret =
-      SQLGetPrivateProfileString(dsn.c_str(), key_str.c_str(), dflt.c_str(), 
buf.data(),
-                                 static_cast<int>(buf.size()), "ODBC.INI");
+      SQLGetPrivateProfileString(wdsn.c_str(), wkey.c_str(), wdflt.c_str(), 
buf.data(),
+                                 static_cast<int>(buf.size()), L"ODBC.INI");
 
   if (ret > BUFFER_SIZE) {
     // If there wasn't enough space, try again with the right size buffer.
     buf.resize(ret + 1);
     ret =
-        SQLGetPrivateProfileString(dsn.c_str(), key_str.c_str(), dflt.c_str(), 
buf.data(),
-                                   static_cast<int>(buf.size()), "ODBC.INI");
+        SQLGetPrivateProfileString(wdsn.c_str(), wkey.c_str(), wdflt.c_str(), 
buf.data(),
+                                   static_cast<int>(buf.size()), L"ODBC.INI");
   }
 
-  return std::string(buf.data(), ret);
+  std::wstring wresult = std::wstring(buf.data(), ret);
+  std::string result = arrow::util::WideStringToUTF8(wresult).ValueOr("");

Review Comment:
   Same as above comment, I have added throws



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to