Skip to content

Commit 2afc5fd

Browse files
committed
Clean up ODBC code
1 parent 0c4ee9e commit 2afc5fd

9 files changed

Lines changed: 301 additions & 294 deletions

File tree

.github/workflows/cpp_extra.yml

Lines changed: 281 additions & 252 deletions
Large diffs are not rendered by default.

compose.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,10 @@ services:
367367
volumes: &debian-volumes
368368
- .:/arrow:delegated
369369
- ${DOCKER_VOLUME_PREFIX}debian-ccache:/ccache:delegated
370-
command: &cpp-command > # -AL- &cpp-command is defined here and calls the build + test sh scripts
370+
command: &cpp-command >
371371
/bin/bash -c "
372372
/arrow/ci/scripts/cpp_build.sh /arrow /build &&
373373
/arrow/ci/scripts/cpp_test.sh /arrow /build"
374-
# -AL- so I can define a new one for odbc-cpp too.
375374

376375
ubuntu-cpp:
377376
# Usage:

cpp/src/arrow/flight/sql/odbc/install/unix/install_odbc.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ case "$(uname)" in
5050
;;
5151
esac
5252

53-
echo "-AL- USER_ODBCINST_FILE: $USER_ODBCINST_FILE"
54-
5553
DRIVER_NAME="Apache Arrow Flight SQL ODBC Driver"
5654

5755
mkdir -p "$HOME"/Library/ODBC

cpp/src/arrow/flight/sql/odbc/odbc_impl/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,7 @@ if(WIN32)
137137
PUBLIC arrow_flight_sql_shared arrow_compute_shared Boost::locale
138138
${ODBCINST})
139139
else()
140-
# -AL- Linux build. share with apple
141-
if(NOT APPLE)
142-
message(status "-AL- ODBC_INCLUDE_DIR on Linux: ${ODBC_INCLUDE_DIR}")
143-
endif()
144-
140+
# Unix
145141
target_include_directories(arrow_odbc_spi_impl SYSTEM BEFORE PUBLIC ${ODBC_INCLUDE_DIR})
146142
target_link_libraries(arrow_odbc_spi_impl
147143
PUBLIC arrow_flight_sql_static

cpp/src/arrow/flight/sql/odbc/odbc_impl/config/configuration.cc

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
#include <iterator>
3232
#include <sstream>
3333

34-
#include "arrow/util/logging.h" // -AL- TEMP
35-
3634
using ODBC::SetAttributeSQLWCHAR;
3735

3836
namespace arrow::flight::sql::odbc {
@@ -49,14 +47,7 @@ std::string ReadDsnString(const std::string& dsn, std::string_view key,
4947
CONVERT_WIDE_STR(const std::wstring wkey, key);
5048
CONVERT_WIDE_STR(const std::wstring wdflt, dflt);
5149

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.
50+
// TODO: implement proper Linux unicode support in separate PR
6051

6152
#define BUFFER_SIZE (1024)
6253
std::vector<SQLWCHAR> buf(BUFFER_SIZE);
@@ -75,11 +66,7 @@ std::string ReadDsnString(const std::string& dsn, std::string_view key,
7566
}
7667

7768
std::string result("");
78-
ARROW_LOG(DEBUG) << "-AL- ReadDsnString key: " << key;
79-
ARROW_LOG(DEBUG) << "-AL- ReadDsnString result before: " << result;
8069
SetAttributeSQLWCHAR(buf.data(), ret * GetSqlWCharSize(), result);
81-
ARROW_LOG(DEBUG) << "-AL- ReadDsnString result: " << result;
82-
ARROW_LOG(DEBUG) << "-AL- ReadDsnString ret: " << ret;
8370
return result;
8471
}
8572

@@ -127,7 +114,6 @@ std::vector<std::string> ReadAllKeys(const std::string& dsn) {
127114
SQLINTEGER key_len = cur - begin;
128115
SetAttributeSQLWCHAR(begin, key_len * GetSqlWCharSize(), key);
129116
keys.emplace_back(key);
130-
ARROW_LOG(DEBUG) << "-AL- ReadAllKeys key: " << key;
131117
begin = ++cur;
132118
}
133119
return keys;

cpp/src/arrow/flight/sql/odbc/odbc_impl/encoding_utils.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,12 @@ inline std::string SqlStringToString(const unsigned char* sql_str,
117117

118118
return res;
119119
}
120+
121+
inline std::vector<SQLWCHAR> ToSqlWCharVector(const std::wstring& ws) {
122+
std::vector<SQLWCHAR> buf;
123+
// buf.assign(ws.begin(), ws.end());
124+
// TODO implement in separate PR
125+
return buf;
126+
}
127+
120128
} // namespace ODBC

cpp/src/arrow/flight/sql/odbc/odbc_impl/get_info_cache.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,8 @@ bool GetInfoCache::LoadInfoFromServer() {
395395
// Unused by ODBC.
396396
break;
397397
case SqlInfoOptions::SQL_DDL_SCHEMA: {
398-
// bool supports_schema_ddl =
399-
// reinterpret_cast<BooleanScalar*>(scalar->child_value().get())->value;
400-
// -AL- todo raise GitHub issues for finishing this work.
398+
// GH-49500 TODO: use scalar bool to determine `SQL_CREATE_SCHEMA` and
399+
// `SQL_DROP_SCHEMA` values
401400

402401
// Note: this is a bitmask and we can't describe cascade or restrict
403402
// flags.
@@ -409,9 +408,8 @@ bool GetInfoCache::LoadInfoFromServer() {
409408
break;
410409
}
411410
case SqlInfoOptions::SQL_DDL_TABLE: {
412-
// bool supports_table_ddl =
413-
// reinterpret_cast<BooleanScalar*>(scalar->child_value().get())->value;
414-
// -AL- todo raise GitHub issues for finishing this work.
411+
// GH-49500 TODO: use scalar bool to determine `SQL_CREATE_TABLE` and
412+
// `SQL_DROP_TABLE` values
415413

416414
// This is a bitmask and we cannot describe all clauses.
417415
info_[SQL_CREATE_TABLE] = static_cast<uint32_t>(SQL_CT_CREATE_TABLE);

cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_statement.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
// platform.h platform.h includes windows.h so it needs to be included first
19-
// -AL- this is an attempt to fix the windows build
18+
// platform.h platform.h includes windows.h so it needs to be included first
2019
#include "arrow/flight/sql/odbc/odbc_impl/platform.h"
2120

2221
#include "arrow/type.h"

cpp/src/arrow/flight/sql/odbc/odbc_impl/system_dsn.cc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
#include "arrow/result.h"
2121
#include "arrow/util/utf8.h"
2222

23+
#include "arrow/flight/sql/odbc/odbc_impl/encoding_utils.h"
24+
2325
#include <sstream>
2426

2527
#ifdef __linux__
26-
# define GET_SQWCHAR_PTR(wstring_var) (ToSqlWCharVector(wstring_var).data())
28+
# define GET_SQWCHAR_PTR(wstring_var) (ODBC::ToSqlWCharVector(wstring_var).data())
2729
#else
28-
// Windows and macOS // -AL- TODO raise GitHub issues for Linux functions
29-
// Can't test it right now anyways without the tests.
30+
// Windows and macOS
3031
# define GET_SQWCHAR_PTR(wstring_var) (wstring_var.c_str())
3132
#endif
3233

@@ -71,13 +72,6 @@ void PostLastInstallerError() {
7172
PostError(code, (LPWSTR)error_msg.c_str());
7273
}
7374

74-
std::vector<SQLWCHAR> ToSqlWCharVector(const std::wstring& ws) {
75-
std::vector<SQLWCHAR> buf;
76-
// buf.assign(ws.begin(), ws.end());
77-
// -AL- GitHub issue to implement. Also need to move this function else where like encoding_utils.h?
78-
return buf;
79-
}
80-
8175
/**
8276
* Unregister specified DSN.
8377
*

0 commit comments

Comments
 (0)