@@ -49,34 +49,34 @@ std::string ReadDsnString(const std::string& dsn, std::string_view key,
4949 CONVERT_WIDE_STR (const std::wstring wkey, key);
5050 CONVERT_WIDE_STR (const std::wstring wdflt, dflt);
5151
52- // -AL- found workaround for `cannot convert 'const wchar_t*' to 'LPCWSTR' {aka
53- // 'const short unsigned int*'}` on Linux. Notes in this file for reference only.
54-
55- // Via CONVERT_WIDE_STR, Arrow correctly converts to UFT-32 on Unix systems,
56- // so the conversion from wchar_t to short unsigned int* will work on Linux.
57-
58- // -AL- I just need to wrap `reinterpret_cast<LPCWSTR>()` on all string args for
59- // SQLGetPrivateProfileString.
52+ // -AL- next up: figure out why `buf` is always empty
53+ // (buf is default value if the default value is passed)
54+ // Have tried `.odbc.ini` but it doesn't work
55+ // DSN name is correct because isql finds it
6056
6157#define BUFFER_SIZE (1024 )
6258 std::vector<SQLWCHAR> buf (BUFFER_SIZE);
6359 int ret = SQLGetPrivateProfileString (
64- reinterpret_cast <LPCWSTR>(wdsn.c_str ()), reinterpret_cast <LPCWSTR>(wkey.c_str ()),
65- reinterpret_cast <LPCWSTR>(wdflt.c_str ()), buf.data (), static_cast <int >(buf.size ()),
66- reinterpret_cast <LPCWSTR>(L" ODBC.INI" ));
60+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wdsn)),
61+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wkey)),
62+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wdflt)), buf.data (),
63+ static_cast <int >(buf.size ()),
64+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (std::wstring (L" ODBC.INI" ))));
6765
6866 if (ret > BUFFER_SIZE) {
6967 // If there wasn't enough space, try again with the right size buffer.
7068 buf.resize (ret + 1 );
7169 ret = SQLGetPrivateProfileString (
72- reinterpret_cast <LPCWSTR>(wdsn.c_str ()), reinterpret_cast <LPCWSTR>(wkey.c_str ()),
73- reinterpret_cast <LPCWSTR>(wdflt.c_str ()), buf.data (),
74- static_cast <int >(buf.size ()), reinterpret_cast <LPCWSTR>(L" ODBC.INI" ));
70+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wdsn)),
71+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wkey)),
72+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wdflt)), buf.data (),
73+ static_cast <int >(buf.size ()),
74+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (std::wstring (L" ODBC.INI" ))));
7575 }
7676
7777 std::string result (" " );
7878 ARROW_LOG (DEBUG) << " -AL- ReadDsnString key: " << key;
79- ARROW_LOG (DEBUG) << " -AL- ReadDsnString result before: " << result;
79+ ARROW_LOG (DEBUG) << " -AL- ReadDsnString result before: (should be empty) " << result;
8080 SetAttributeSQLWCHAR (buf.data (), ret * GetSqlWCharSize (), result);
8181 ARROW_LOG (DEBUG) << " -AL- ReadDsnString result: " << result;
8282 ARROW_LOG (DEBUG) << " -AL- ReadDsnString ret: " << ret;
@@ -102,15 +102,17 @@ std::vector<std::string> ReadAllKeys(const std::string& dsn) {
102102 std::vector<SQLWCHAR> buf (BUFFER_SIZE);
103103
104104 int ret = SQLGetPrivateProfileString (
105- reinterpret_cast <LPCWSTR>(wdsn.c_str ()), NULL , reinterpret_cast <LPCWSTR>(L" " ),
106- buf.data (), static_cast <int >(buf.size ()), reinterpret_cast <LPCWSTR>(L" ODBC.INI" ));
105+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wdsn)), NULL ,
106+ reinterpret_cast <LPCWSTR>(L" " ), buf.data (), static_cast <int >(buf.size ()),
107+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (std::wstring (L" ODBC.INI" ))));
107108
108109 if (ret > BUFFER_SIZE) {
109110 // If there wasn't enough space, try again with the right size buffer.
110111 buf.resize (ret + 1 );
111112 ret = SQLGetPrivateProfileString (
112- reinterpret_cast <LPCWSTR>(wdsn.c_str ()), NULL , reinterpret_cast <LPCWSTR>(L" " ),
113- buf.data (), static_cast <int >(buf.size ()), reinterpret_cast <LPCWSTR>(L" ODBC.INI" ));
113+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wdsn)), NULL ,
114+ reinterpret_cast <LPCWSTR>(L" " ), buf.data (), static_cast <int >(buf.size ()),
115+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (std::wstring (L" ODBC.INI" ))));
114116 }
115117
116118 // When you pass NULL to SQLGetPrivateProfileString it gives back a \0 delimited list of
0 commit comments