Skip to content

Commit c05ba5a

Browse files
committed
Enable ODBC build on MSVC CI
Code Clean up and enable ODBC tests in CI Still need to modify ODBCUtilEnvironment if we decide to use it. Still need to add ODBC V2 support so a different env and conn is used for ODBC 2 tests. Draft enable ODBC global setup/teardown Run ODBC test once outside of test script If ODBC test is run using MinGW Shell, segfault occurs. I am not getting any seg fault on my local MSVC Windows when I run the tests without the bash script. But if Windows CI breaks from running the standalone exe then I will look into this Prepend vcpkg to search vcpkg before `<prefix>/lib/cmake` Since we are installing dependencies on vcpkg, if `lib/cmake` is searched first, then cmake will look into that directory and use the wrong paths. Convert VCPKG Windows path to MSYS path Set `VCPKG_ROOT` in test phase Fix ODBC dll name Use `arrow_flight_sql_odbc.dll` instead of `libarrow_flight_sql_odbc.dll` which is the naming convention used on MinGW Windows Link ODBC library on all platforms On my local MSVC Windows machine, Visual Studio is used to build without needing to link ` ${ODBCINST}` explicitly, its behavior might be different from Ninja which is what CI uses. `${ODBCINST}` is likely needed by Linux as well, so adding it for all platforms. Attempt to resolve `arrow-compute-grouper-benchmark` build issue I think `if(ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")` might be more appropriate here, as I am seeing build issues due to both dynamic and static linking occurring. I see in apache@59903d0, this check is used for `arrow-filesystem-s3fs-benchmark` Disable `UNITY_BUILD` for ODBC test due to conflict on `sqlite_sql_info.cc` On some workflows, unity build is set to ON to make the build faster. This is an attempt to resolve the build issue. Remove debug messages Fix lint Add `sql_info_undef.h` to sqlite_sql_info.cc Undefine duplicates in SQLGetInfo Add `#pragma once` to odbc_test_suite.h To avoid redefinition error Attempt to resolve conflict with sql/types.h Attempt to include Arrow headers before ODBC headers to avoid conflict with arrow/flight/sql/types.h [apacheGH-48084] Replace boost::optional with std::optional Addresses comment apache#40939 (comment) Replace boost::optional with std::optional in ODBC codebase apache#48084 Fix lint Remove `BOOST_SOURCE=BUNDLED` to use vcpkg's dynamic link to boost Since we need to use link to boost dynamically, we need to remove the bundled boost library flag. Add debug messages. Remove `ARROW_BOOST_USE_SHARED = OFF` Since we have a release build, can enable boost as shared. With `ARROW_BOOST_USE_SHARED = OFF`, I am getting error ``` D:\a\arrow\arrow\build\cpp\vcpkg_installed\x64-windows\include\boost/filesystem/config.hpp(96): fatal error C1189: #error: Must not define both BOOST_FILESYSTEM_DYN_LINK and BOOST_FILESYSTEM_STATIC_LINK ``` Also increased time limit, since 2 hours don't seem to be enough to finish the vcpkg build Change to release build Getting ``` orc.lib(Exceptions.cc.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in unity_2_cxx.cxx.obj orc.lib(Exceptions.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in unity_2_cxx.cxx.obj ``` when building with debug and presumably ARROW_ORC Set ARROW_BOOST_USE_SHARED to OFF `ARROW_BOOST_USE_SHARED` is restored to `OFF`, which according to Windows doc should help with the debug build now. Retore value of `ARROW_BUILD_BENCHMARKS`, though noting it is set to `OFF` in GLib MSVC workflow. Add VCPKG set up Borrowed from the Glib workflow Add `/EHsc` flag * Add back `CMAKE_CXX_STANDARD: "17"` Remove `CMAKE_CXX_STANDARD` 17 * reason: gtest can't be used with C++17. Arrow project doesn't support C++ 17 yet. Extend run-time to 2hr windows-mingw also has timeout of 2hr Empty commit to trigger CI Specify `VCPKG_BINARY_SOURCES` and `VCPKG_DEFAULT_TRIPLET` Specify VCPKG_TARGET_TRIPLET as x64 windows Set ARROW_DEPENDENCY_SOURCE to VCPKG To make it easier to manage dependencies Enable static build on MSVC `ARROW_BUILD_BENCHMARKS` prevents Flight from being built Remove `ARROW_BOOST_USE_SHARED` Having static vs. shared issue Enable Flight & Flight SQL for ODBC Enable ODBC build on MSVC CI Enable regular ctest tests
1 parent dcf56c2 commit c05ba5a

File tree

11 files changed

+194
-10
lines changed

11 files changed

+194
-10
lines changed

ci/scripts/cpp_test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ if [ "${ARROW_USE_MESON:-OFF}" = "OFF" ] && \
144144
CMAKE_PREFIX_PATH+="/lib/cmake/"
145145
;;
146146
esac
147+
# Search vcpkg before <prefix>/lib/cmake.
147148
if [ -n "${VCPKG_ROOT}" ] && [ -n "${VCPKG_DEFAULT_TRIPLET}" ]; then
148-
CMAKE_PREFIX_PATH+=";${VCPKG_ROOT}/installed/${VCPKG_DEFAULT_TRIPLET}"
149+
CMAKE_PREFIX_PATH="${VCPKG_ROOT}/installed/${VCPKG_DEFAULT_TRIPLET};${CMAKE_PREFIX_PATH}"
149150
fi
150151
cmake \
151152
-S "${source_dir}/examples/minimal_build" \

cpp/cmake_modules/SetupCxxFlags.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ if(WIN32)
186186
#
187187
# ARROW-2986: Without /EHsc we get C4530 warning
188188
set(CXX_COMMON_FLAGS "/W3 /EHsc")
189+
string(APPEND CMAKE_CXX_FLAGS " /EHsc")
189190
endif()
190191

191192
# Disable C5105 (macro expansion producing 'defined' has undefined

cpp/src/arrow/flight/sql/example/sqlite_sql_info.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "arrow/flight/sql/types.h"
2121
#include "arrow/util/config.h"
2222

23+
#include "arrow/flight/sql/sql_info_undef.h"
24+
2325
namespace arrow {
2426
namespace flight {
2527
namespace sql {

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,9 @@ if(WIN32)
129129
system_dsn.h)
130130
endif()
131131

132-
target_link_libraries(arrow_odbc_spi_impl PUBLIC arrow_flight_sql_shared
133-
arrow_compute_shared Boost::locale)
134-
135-
# Link libraries on MINGW64 and macOS
136-
if(MINGW OR APPLE)
137-
target_link_libraries(arrow_odbc_spi_impl PUBLIC ${ODBCINST})
138-
endif()
132+
target_link_libraries(arrow_odbc_spi_impl
133+
PUBLIC arrow_flight_sql_shared arrow_compute_shared Boost::locale
134+
${ODBCINST})
139135

140136
set_target_properties(arrow_odbc_spi_impl
141137
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include <optional>
2626

27+
#include <optional>
28+
2729
namespace arrow::flight::sql::odbc {
2830

2931
TEST(AttributeTests, SetAndGetAttribute) {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
#include "arrow/flight/sql/odbc/odbc_impl/platform.h"
2121

22-
#include <sql.h>
23-
#include <sqlext.h>
2422
#include "arrow/array.h"
2523
#include "arrow/array/array_nested.h"
2624
#include "arrow/flight/sql/api.h"
@@ -32,6 +30,10 @@
3230
#include "arrow/flight/sql/odbc/odbc_impl/scalar_function_reporter.h"
3331
#include "arrow/flight/sql/odbc/odbc_impl/util.h"
3432

33+
// Include ODBC headers after arrow headers to avoid conflicts with sql_info_undef.h
34+
#include <sql.h>
35+
#include <sqlext.h>
36+
3537
// Aliases for entries in SqlInfoOptions::SqlInfo that are defined here
3638
// due to causing compilation errors conflicting with ODBC definitions.
3739
#define ARROW_SQL_IDENTIFIER_CASE 503

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "arrow/flight/sql/odbc/odbc_impl/spi/statement.h"
3131
#include "arrow/flight/sql/odbc/odbc_impl/util.h"
3232

33+
// Include ODBC headers after arrow headers to avoid conflicts with sql_info_undef.h
3334
#include <odbcinst.h>
3435
#include <sql.h>
3536
#include <sqlext.h>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ add_arrow_test(flight_sql_odbc_test
4444
connection_test.cc
4545
odbc_test_suite.cc
4646
odbc_test_suite.h
47+
odbc_test_util.h
4748
# Enable Protobuf cleanup after test execution
4849
# GH-46889: move protobuf_test_util to a more common location
4950
../../../../engine/substrait/protobuf_test_util.cc
@@ -53,3 +54,6 @@ add_arrow_test(flight_sql_odbc_test
5354
${ODBCINST}
5455
${SQLite3_LIBRARIES}
5556
arrow_odbc_spi_impl)
57+
58+
# Disable unity build due to sqlite_sql_info.cc conflict with sql.h and sqlext.h headers.
59+
set_target_properties(arrow-flight-sql-odbc-test PROPERTIES UNITY_BUILD OFF)

cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.h

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

18+
#pragma once
19+
1820
#include "arrow/testing/gtest_util.h"
1921
#include "arrow/util/io_util.h"
2022
#include "arrow/util/utf8.h"
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
#pragma once
19+
20+
/// \brief Undefine the ODBC macros in sql.h and sqlext.h to avoid conflicts with ODBC
21+
/// library
22+
///
23+
/// This file is to resolve build issues from linking. Should not be used with sql.h or
24+
/// sql_ext.h
25+
26+
#ifdef SQL_IDENTIFIER_CASE
27+
# undef SQL_IDENTIFIER_CASE
28+
#endif // SQL_IDENTIFIER_CASE
29+
30+
#ifdef SQL_IDENTIFIER_QUOTE_CHAR
31+
# undef SQL_IDENTIFIER_QUOTE_CHAR
32+
#endif // SQL_IDENTIFIER_QUOTE_CHAR
33+
34+
#ifdef SQL_QUOTED_IDENTIFIER_CASE
35+
# undef SQL_QUOTED_IDENTIFIER_CASE
36+
#endif // SQL_QUOTED_IDENTIFIER_CASE
37+
38+
#ifdef SQL_KEYWORDS
39+
# undef SQL_KEYWORDS
40+
#endif // SQL_KEYWORDS
41+
42+
#ifdef SQL_NUMERIC_FUNCTIONS
43+
# undef SQL_NUMERIC_FUNCTIONS
44+
#endif // SQL_NUMERIC_FUNCTIONS
45+
46+
#ifdef SQL_STRING_FUNCTIONS
47+
# undef SQL_STRING_FUNCTIONS
48+
#endif // SQL_STRING_FUNCTIONS
49+
50+
#ifdef SQL_SYSTEM_FUNCTIONS
51+
# undef SQL_SYSTEM_FUNCTIONS
52+
#endif // SQL_SYSTEM_FUNCTIONS
53+
54+
#ifdef SQL_SCHEMA_TERM
55+
# undef SQL_SCHEMA_TERM
56+
#endif // SQL_SCHEMA_TERM
57+
58+
#ifdef SQL_PROCEDURE_TERM
59+
# undef SQL_PROCEDURE_TERM
60+
#endif // SQL_PROCEDURE_TERM
61+
62+
#ifdef SQL_CATALOG_TERM
63+
# undef SQL_CATALOG_TERM
64+
#endif // SQL_CATALOG_TERM
65+
66+
#ifdef SQL_MAX_COLUMNS_IN_GROUP_BY
67+
# undef SQL_MAX_COLUMNS_IN_GROUP_BY
68+
#endif // SQL_MAX_COLUMNS_IN_GROUP_BY
69+
70+
#ifdef SQL_MAX_COLUMNS_IN_INDEX
71+
# undef SQL_MAX_COLUMNS_IN_INDEX
72+
#endif // SQL_MAX_COLUMNS_IN_INDEX
73+
74+
#ifdef SQL_MAX_COLUMNS_IN_ORDER_BY
75+
# undef SQL_MAX_COLUMNS_IN_ORDER_BY
76+
#endif // SQL_MAX_COLUMNS_IN_ORDER_BY
77+
78+
#ifdef SQL_MAX_COLUMNS_IN_SELECT
79+
# undef SQL_MAX_COLUMNS_IN_SELECT
80+
#endif // SQL_MAX_COLUMNS_IN_SELECT
81+
82+
#ifdef SQL_MAX_COLUMNS_IN_TABLE
83+
# undef SQL_MAX_COLUMNS_IN_TABLE
84+
#endif // SQL_MAX_COLUMNS_IN_TABLE
85+
86+
#ifdef SQL_MAX_ROW_SIZE
87+
# undef SQL_MAX_ROW_SIZE
88+
#endif // SQL_MAX_ROW_SIZE
89+
90+
#ifdef SQL_MAX_TABLES_IN_SELECT
91+
# undef SQL_MAX_TABLES_IN_SELECT
92+
#endif // SQL_MAX_TABLES_IN_SELECT
93+
94+
#ifdef SQL_CONVERT_BIGINT
95+
# undef SQL_CONVERT_BIGINT
96+
#endif // SQL_CONVERT_BIGINT
97+
98+
#ifdef SQL_CONVERT_BINARY
99+
# undef SQL_CONVERT_BINARY
100+
#endif // SQL_CONVERT_BINARY
101+
102+
#ifdef SQL_CONVERT_BIT
103+
# undef SQL_CONVERT_BIT
104+
#endif // SQL_CONVERT_BIT
105+
106+
#ifdef SQL_CONVERT_CHAR
107+
# undef SQL_CONVERT_CHAR
108+
#endif // SQL_CONVERT_CHAR
109+
110+
#ifdef SQL_CONVERT_DATE
111+
# undef SQL_CONVERT_DATE
112+
#endif // SQL_CONVERT_DATE
113+
114+
#ifdef SQL_CONVERT_DECIMAL
115+
# undef SQL_CONVERT_DECIMAL
116+
#endif // SQL_CONVERT_DECIMAL
117+
118+
#ifdef SQL_CONVERT_FLOAT
119+
# undef SQL_CONVERT_FLOAT
120+
#endif // SQL_CONVERT_FLOAT
121+
122+
#ifdef SQL_CONVERT_INTEGER
123+
# undef SQL_CONVERT_INTEGER
124+
#endif // SQL_CONVERT_INTEGER
125+
126+
#ifdef SQL_CONVERT_INTERVAL_DAY_TIME
127+
# undef SQL_CONVERT_INTERVAL_DAY_TIME
128+
#endif // SQL_CONVERT_INTERVAL_DAY_TIME
129+
130+
#ifdef SQL_CONVERT_INTERVAL_YEAR_MONTH
131+
# undef SQL_CONVERT_INTERVAL_YEAR_MONTH
132+
#endif // SQL_CONVERT_INTERVAL_YEAR_MONTH
133+
134+
#ifdef SQL_CONVERT_LONGVARBINARY
135+
# undef SQL_CONVERT_LONGVARBINARY
136+
#endif // SQL_CONVERT_LONGVARBINARY
137+
138+
#ifdef SQL_CONVERT_LONGVARCHAR
139+
# undef SQL_CONVERT_LONGVARCHAR
140+
#endif // SQL_CONVERT_LONGVARCHAR
141+
142+
#ifdef SQL_CONVERT_NUMERIC
143+
# undef SQL_CONVERT_NUMERIC
144+
#endif // SQL_CONVERT_NUMERIC
145+
146+
#ifdef SQL_CONVERT_REAL
147+
# undef SQL_CONVERT_REAL
148+
#endif // SQL_CONVERT_REAL
149+
150+
#ifdef SQL_CONVERT_SMALLINT
151+
# undef SQL_CONVERT_SMALLINT
152+
#endif // SQL_CONVERT_SMALLINT
153+
154+
#ifdef SQL_CONVERT_TIME
155+
# undef SQL_CONVERT_TIME
156+
#endif // SQL_CONVERT_TIME
157+
158+
#ifdef SQL_CONVERT_TIMESTAMP
159+
# undef SQL_CONVERT_TIMESTAMP
160+
#endif // SQL_CONVERT_TIMESTAMP
161+
162+
#ifdef SQL_CONVERT_TINYINT
163+
# undef SQL_CONVERT_TINYINT
164+
#endif // SQL_CONVERT_TINYINT
165+
166+
#ifdef SQL_CONVERT_VARBINARY
167+
# undef SQL_CONVERT_VARBINARY
168+
#endif // SQL_CONVERT_VARBINARY
169+
170+
#ifdef SQL_CONVERT_VARCHAR
171+
# undef SQL_CONVERT_VARCHAR
172+
#endif // SQL_CONVERT_VARCHAR

0 commit comments

Comments
 (0)