Skip to content

Commit 243d039

Browse files
committed
Implement SQLAllocEnv
Fix cmake build
1 parent d85771f commit 243d039

3 files changed

Lines changed: 23 additions & 13 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ add_arrow_lib(arrow_flight_sql_odbc
6464
SHARED_INSTALL_INTERFACE_LIBS ArrowFlight::arrow_flight_sql_shared
6565
STATIC_LINK_LIBS arrow_flight_sql_static
6666
STATIC_INSTALL_INTERFACE_LIBS ArrowFlight::arrow_flight_sql_static
67-
SHARED_PRIVATE_LINK_LIBS ODBC::ODBC)
67+
SHARED_PRIVATE_LINK_LIBS ODBC::ODBC odbcabstraction arrow_odbc_spi_impl)
6868

6969
foreach(LIB_TARGET ${ARROW_FLIGHT_SQL_ODBC_LIBRARIES})
7070
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_SQL_ODBC_EXPORTING)

cpp/src/arrow/flight/sql/odbc/odbc_api.cc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
// under the License.
1717

1818

19-
#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
19+
#include <arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h>
20+
#include <arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h>
2021

2122
// odbc_api includes windows.h, which needs to be put behind winsock2.h.
2223
// odbc_environment.h includes winsock2.h
23-
#include "arrow/flight/sql/odbc/odbc_api.h"
24+
#include <arrow/flight/sql/odbc/odbc_api.h>
2425

2526
namespace arrow
2627
{
@@ -30,20 +31,23 @@ namespace arrow
3031

3132
switch (type)
3233
{
33-
case SQL_HANDLE_ENV:
34-
35-
// TODO: uncomment below code after flightsqlodbc is fixed
36-
// using ODBCEnvironment;
37-
// *result = reinterpret_cast< SQLHENV >(new ODBCEnvironment());
34+
case SQL_HANDLE_ENV: {
35+
using ODBC::ODBCEnvironment;
36+
using driver::flight_sql::FlightSqlDriver;
3837

39-
// return SQL_SUCCESS
40-
return SQL_INVALID_HANDLE;
41-
42-
case SQL_HANDLE_DBC:
38+
std::shared_ptr< FlightSqlDriver > odbc_driver = std::shared_ptr< FlightSqlDriver >();
39+
*result = reinterpret_cast< SQLHENV >(new ODBCEnvironment(odbc_driver));
40+
41+
return SQL_SUCCESS;
42+
}
43+
44+
case SQL_HANDLE_DBC: {
4345
return SQL_INVALID_HANDLE;
46+
}
4447

45-
case SQL_HANDLE_STMT:
48+
case SQL_HANDLE_STMT: {
4649
return SQL_INVALID_HANDLE;
50+
}
4751

4852
default:
4953
break;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ const boost::xpressive::sregex CONNECTION_STR_REGEX(
5252
// entries in the properties.
5353
void loadPropertiesFromDSN(const std::string& dsn,
5454
Connection::ConnPropertyMap& properties) {
55+
// TODO - fix build errors with configuration window
56+
/*
5557
const size_t BUFFER_SIZE = 1024 * 10;
5658
std::vector<char> outputBuffer;
5759
outputBuffer.resize(BUFFER_SIZE, '\0');
5860
SQLSetConfigMode(ODBC_BOTH_DSN);
61+
5962
SQLGetPrivateProfileString(dsn.c_str(), NULL, "", &outputBuffer[0], BUFFER_SIZE,
6063
"odbc.ini");
6164
@@ -81,14 +84,17 @@ void loadPropertiesFromDSN(const std::string& dsn,
8184
for (auto& key : keys) {
8285
outputBuffer.clear();
8386
outputBuffer.resize(BUFFER_SIZE, '\0');
87+
8488
SQLGetPrivateProfileString(dsn.c_str(), key.c_str(), "", &outputBuffer[0],
8589
BUFFER_SIZE, "odbc.ini");
90+
8691
std::string value = std::string(&outputBuffer[0]);
8792
auto propIter = properties.find(key);
8893
if (propIter == properties.end()) {
8994
properties.emplace(std::make_pair(std::move(key), std::move(value)));
9095
}
9196
}
97+
*/
9298
}
9399

94100
} // namespace

0 commit comments

Comments
 (0)