@@ -49,34 +49,36 @@ 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.
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
56+ // It should be case-insensitive because unixodbc had been updated
57+ // I passed `Host` which is an exact match of the key, and still nothing
58+ // is returned.
5459
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.
60+ // -AL- TODO: remove the `reinterpret_cast<LPCWSTR>` cast
6061
6162#define BUFFER_SIZE (1024 )
6263 std::vector<SQLWCHAR> buf (BUFFER_SIZE);
6364 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" ));
65+ GET_SQWCHAR_PTR (wdsn), GET_SQWCHAR_PTR (wkey), GET_SQWCHAR_PTR (wdflt), buf.data (),
66+ static_cast <int >(buf.size ()), GET_SQWCHAR_PTR (std::wstring (L" ODBC.INI" )));
6767
6868 if (ret > BUFFER_SIZE) {
6969 // If there wasn't enough space, try again with the right size buffer.
7070 buf.resize (ret + 1 );
7171 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" ));
72+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wdsn)),
73+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wkey)),
74+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wdflt)), buf.data (),
75+ static_cast <int >(buf.size ()),
76+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (std::wstring (L" ODBC.INI" ))));
7577 }
7678
7779 std::string result (" " );
7880 ARROW_LOG (DEBUG) << " -AL- ReadDsnString key: " << key;
79- ARROW_LOG (DEBUG) << " -AL- ReadDsnString result before: " << result;
81+ ARROW_LOG (DEBUG) << " -AL- ReadDsnString result before: (should be empty) " << result;
8082 SetAttributeSQLWCHAR (buf.data (), ret * GetSqlWCharSize (), result);
8183 ARROW_LOG (DEBUG) << " -AL- ReadDsnString result: " << result;
8284 ARROW_LOG (DEBUG) << " -AL- ReadDsnString ret: " << ret;
@@ -102,15 +104,17 @@ std::vector<std::string> ReadAllKeys(const std::string& dsn) {
102104 std::vector<SQLWCHAR> buf (BUFFER_SIZE);
103105
104106 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" ));
107+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wdsn)), NULL ,
108+ reinterpret_cast <LPCWSTR>(L" " ), buf.data (), static_cast <int >(buf.size ()),
109+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (std::wstring (L" ODBC.INI" ))));
107110
108111 if (ret > BUFFER_SIZE) {
109112 // If there wasn't enough space, try again with the right size buffer.
110113 buf.resize (ret + 1 );
111114 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" ));
115+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (wdsn)), NULL ,
116+ reinterpret_cast <LPCWSTR>(L" " ), buf.data (), static_cast <int >(buf.size ()),
117+ reinterpret_cast <LPCWSTR>(GET_SQWCHAR_PTR (std::wstring (L" ODBC.INI" ))));
114118 }
115119
116120 // When you pass NULL to SQLGetPrivateProfileString it gives back a \0 delimited list of
0 commit comments