Skip to content

Commit 96110d7

Browse files
committed
Undefine duplicates in SQLGetInfo
1 parent 94e8c2f commit 96110d7

File tree

5 files changed

+181
-5
lines changed

5 files changed

+181
-5
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ add_subdirectory(tests)
3838

3939
arrow_install_all_headers("arrow/flight/sql/odbc")
4040

41-
# Include Arrow headers before ODBC headers
42-
# Compile entry_points.cc before odbc_api.cc due to conflict from sql.h and flight/sql/types.h
43-
set(ARROW_FLIGHT_SQL_ODBC_SRCS odbc_api.cc entry_points.cc)
41+
set(ARROW_FLIGHT_SQL_ODBC_SRCS entry_points.cc odbc_api.cc)
4442

4543
if(WIN32)
4644
list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def)

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
@@ -29,6 +29,7 @@
2929
#include "arrow/flight/sql/odbc/odbc_impl/spi/statement.h"
3030
#include "arrow/flight/sql/odbc/odbc_impl/util.h"
3131

32+
// Include ODBC headers after arrow headers to avoid conflicts with sql_info_undef.h
3233
#include <odbcinst.h>
3334
#include <sql.h>
3435
#include <sqlext.h>
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
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+
// ---- Conversion Info ----
95+
96+
#ifdef SQL_CONVERT_BIGINT
97+
# undef SQL_CONVERT_BIGINT
98+
#endif // SQL_CONVERT_BIGINT
99+
100+
#ifdef SQL_CONVERT_BINARY
101+
# undef SQL_CONVERT_BINARY
102+
#endif // SQL_CONVERT_BINARY
103+
104+
#ifdef SQL_CONVERT_BIT
105+
# undef SQL_CONVERT_BIT
106+
#endif // SQL_CONVERT_BIT
107+
108+
#ifdef SQL_CONVERT_CHAR
109+
# undef SQL_CONVERT_CHAR
110+
#endif // SQL_CONVERT_CHAR
111+
112+
#ifdef SQL_CONVERT_DATE
113+
# undef SQL_CONVERT_DATE
114+
#endif // SQL_CONVERT_DATE
115+
116+
#ifdef SQL_CONVERT_DECIMAL
117+
# undef SQL_CONVERT_DECIMAL
118+
#endif // SQL_CONVERT_DECIMAL
119+
120+
#ifdef SQL_CONVERT_FLOAT
121+
# undef SQL_CONVERT_FLOAT
122+
#endif // SQL_CONVERT_FLOAT
123+
124+
#ifdef SQL_CONVERT_INTEGER
125+
# undef SQL_CONVERT_INTEGER
126+
#endif // SQL_CONVERT_INTEGER
127+
128+
#ifdef SQL_CONVERT_INTERVAL_DAY_TIME
129+
# undef SQL_CONVERT_INTERVAL_DAY_TIME
130+
#endif // SQL_CONVERT_INTERVAL_DAY_TIME
131+
132+
#ifdef SQL_CONVERT_INTERVAL_YEAR_MONTH
133+
# undef SQL_CONVERT_INTERVAL_YEAR_MONTH
134+
#endif // SQL_CONVERT_INTERVAL_YEAR_MONTH
135+
136+
#ifdef SQL_CONVERT_LONGVARBINARY
137+
# undef SQL_CONVERT_LONGVARBINARY
138+
#endif // SQL_CONVERT_LONGVARBINARY
139+
140+
#ifdef SQL_CONVERT_LONGVARCHAR
141+
# undef SQL_CONVERT_LONGVARCHAR
142+
#endif // SQL_CONVERT_LONGVARCHAR
143+
144+
#ifdef SQL_CONVERT_NUMERIC
145+
# undef SQL_CONVERT_NUMERIC
146+
#endif // SQL_CONVERT_NUMERIC
147+
148+
#ifdef SQL_CONVERT_REAL
149+
# undef SQL_CONVERT_REAL
150+
#endif // SQL_CONVERT_REAL
151+
152+
#ifdef SQL_CONVERT_SMALLINT
153+
# undef SQL_CONVERT_SMALLINT
154+
#endif // SQL_CONVERT_SMALLINT
155+
156+
#ifdef SQL_CONVERT_TIME
157+
# undef SQL_CONVERT_TIME
158+
#endif // SQL_CONVERT_TIME
159+
160+
#ifdef SQL_CONVERT_TIMESTAMP
161+
# undef SQL_CONVERT_TIMESTAMP
162+
#endif // SQL_CONVERT_TIMESTAMP
163+
164+
#ifdef SQL_CONVERT_TINYINT
165+
# undef SQL_CONVERT_TINYINT
166+
#endif // SQL_CONVERT_TINYINT
167+
168+
#ifdef SQL_CONVERT_VARBINARY
169+
# undef SQL_CONVERT_VARBINARY
170+
#endif // SQL_CONVERT_VARBINARY
171+
172+
#ifdef SQL_CONVERT_VARCHAR
173+
# undef SQL_CONVERT_VARCHAR
174+
#endif // SQL_CONVERT_VARCHAR

cpp/src/arrow/flight/sql/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <vector>
2727

2828
#include "arrow/flight/sql/visibility.h"
29+
#include "arrow/flight/sql/sql_info_undef.h"
2930
#include "arrow/type_fwd.h"
3031

3132
namespace arrow {

0 commit comments

Comments
 (0)