Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2280,46 +2280,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

--------------------------------------------------------------------------------
The files cpp/src/arrow/vendored/whereami/whereami.h,
cpp/src/arrow/vendored/whereami/whereami.cc are adapted from
Grégory Pakosz's whereami library (https://github.com/gpakosz/whereami)
It is dual licensed under both the WTFPLv2 and MIT licenses.

The WTFPLv2 License
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
1. Bla bla bla
2. Montesqieu et camembert, vive la France, zut alors!

The MIT License (MIT)
Copyright Gregory Pakosz

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 changes: 1 addition & 14 deletions cpp/src/arrow/flight/sql/odbc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_custom_target(arrow_flight_sql_odbc)

# Ensure fmt is loaded as header only
add_compile_definitions(FMT_HEADER_ONLY)

if(WIN32)
if(MSVC_VERSION GREATER_EQUAL 1900)
set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)
Expand All @@ -39,15 +36,6 @@ endif()

add_definitions(-DUNICODE=1)

include(FetchContent)
fetchcontent_declare(spdlog
URL https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.zip
CONFIGURE_COMMAND
""
BUILD_COMMAND
"")
fetchcontent_makeavailable(spdlog)

add_subdirectory(flight_sql)
add_subdirectory(odbcabstraction)
add_subdirectory(tests)
Expand Down Expand Up @@ -104,8 +92,7 @@ add_arrow_lib(arrow_flight_sql_odbc
${ODBC_LIBRARIES}
${ODBCINST}
odbcabstraction
arrow_odbc_spi_impl
spdlog::spdlog)
arrow_odbc_spi_impl)

foreach(LIB_TARGET ${ARROW_FLIGHT_SQL_ODBC_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_SQL_ODBC_EXPORTING)
Expand Down
40 changes: 21 additions & 19 deletions cpp/src/arrow/flight/sql/odbc/entry_points.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ SQLRETURN SQL_API SQLBindCol(SQLHSTMT stmt, SQLUSMALLINT recordNumber, SQLSMALLI
}

SQLRETURN SQL_API SQLCancel(SQLHSTMT stmt) {
LOG_DEBUG("SQLCancel called with stmt: {}", stmt);
LOG_DEBUG("SQLCancel called with stmt: " << stmt);
return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() {
throw driver::odbcabstraction::DriverException("SQLCancel is not implemented",
"IM001");
Expand Down Expand Up @@ -225,18 +225,19 @@ SQLRETURN SQL_API SQLForeignKeys(SQLHSTMT stmt, SQLWCHAR* pKCatalogName,
SQLSMALLINT fKCatalogNameLength, SQLWCHAR* fKSchemaName,
SQLSMALLINT fKSchemaNameLength, SQLWCHAR* fKTableName,
SQLSMALLINT fKTableNameLength) {
LOG_DEBUG(
"SQLForeignKeysW called with stmt: {}, pKCatalogName: {}, "
"pKCatalogNameLength: "
"{}, pKSchemaName: {}, pKSchemaNameLength: {}, pKTableName: {}, pKTableNameLength: "
"{}, "
"fKCatalogName: {}, fKCatalogNameLength: {}, fKSchemaName: {}, fKSchemaNameLength: "
"{}, "
"fKTableName: {}, fKTableNameLength : {}",
stmt, fmt::ptr(pKCatalogName), pKCatalogNameLength, fmt::ptr(pKSchemaName),
pKSchemaNameLength, fmt::ptr(pKTableName), pKTableNameLength,
fmt::ptr(fKCatalogName), fKCatalogNameLength, fmt::ptr(fKSchemaName),
fKSchemaNameLength, fmt::ptr(fKTableName), fKTableNameLength);
LOG_DEBUG("SQLForeignKeysW called with stmt: "
<< stmt << ", pKCatalogName: " << static_cast<const void*>(pKCatalogName)
<< ", pKCatalogNameLength: " << pKCatalogNameLength
<< ", pKSchemaName: " << static_cast<const void*>(pKSchemaName)
<< ", pKSchemaNameLength: " << pKSchemaNameLength
<< ", pKTableName: " << static_cast<const void*>(pKTableName)
<< ", pKTableNameLength: " << pKTableNameLength
<< ", fKCatalogName: " << static_cast<const void*>(fKCatalogName)
<< ", fKCatalogNameLength: " << fKCatalogNameLength
<< ", fKSchemaName: " << static_cast<const void*>(fKSchemaName)
<< ", fKSchemaNameLength: " << fKSchemaNameLength
<< ", fKTableName: " << static_cast<const void*>(fKTableName)
<< ", fKTableNameLength: " << fKTableNameLength);
return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() {
throw driver::odbcabstraction::DriverException("SQLForeignKeysW is not implemented",
"IM001");
Expand Down Expand Up @@ -270,12 +271,13 @@ SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT stmt, SQLWCHAR* catalogName,
SQLSMALLINT catalogNameLength, SQLWCHAR* schemaName,
SQLSMALLINT schemaNameLength, SQLWCHAR* tableName,
SQLSMALLINT tableNameLength) {
LOG_DEBUG(
"SQLPrimaryKeysW called with stmt: {}, catalogName: {}, "
"catalogNameLength: "
"{}, schemaName: {}, schemaNameLength: {}, tableName: {}, tableNameLength: {}",
stmt, fmt::ptr(catalogName), catalogNameLength, fmt::ptr(schemaName),
schemaNameLength, fmt::ptr(tableName), tableNameLength);
LOG_DEBUG("SQLPrimaryKeysW called with stmt: "
<< stmt << ", catalogName: " << static_cast<const void*>(catalogName)
<< ", catalogNameLength: " << catalogNameLength
<< ", schemaName: " << static_cast<const void*>(schemaName)
<< ", schemaNameLength: " << schemaNameLength
<< ", tableName: " << static_cast<const void*>(tableName)
<< ", tableNameLength: " << tableNameLength);
return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() {
throw driver::odbcabstraction::DriverException("SQLPrimaryKeysW is not implemented",
"IM001");
Expand Down
77 changes: 0 additions & 77 deletions cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_driver.cc
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main file to review

Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,16 @@
#include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
#include "arrow/flight/sql/odbc/flight_sql/utils.h"
#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"
#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spd_logger.h"
#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h"
#include "arrow/util/io_util.h"

#define DEFAULT_MAXIMUM_FILE_SIZE 16777216
#define CONFIG_FILE_NAME "arrow-odbc.ini"
#define CONFIG_FILE_PATH "CONFIG_FILE_PATH"

namespace driver {
namespace flight_sql {

using odbcabstraction::Connection;
using odbcabstraction::LogLevel;
using odbcabstraction::OdbcVersion;
using odbcabstraction::SPDLogger;

namespace {
LogLevel ToLogLevel(int64_t level) {
switch (level) {
case 0:
return LogLevel::LogLevel_TRACE;
case 1:
return LogLevel::LogLevel_DEBUG;
case 2:
return LogLevel::LogLevel_INFO;
case 3:
return LogLevel::LogLevel_WARN;
case 4:
return LogLevel::LogLevel_ERROR;
default:
return LogLevel::LogLevel_OFF;
}
}
} // namespace

FlightSqlDriver::FlightSqlDriver()
: diagnostics_("Apache Arrow", "Flight SQL", OdbcVersion::V_3), version_("0.9.0.0") {
RegisterLog();
// Register Kernel functions to library
ThrowIfNotOK(arrow::compute::Initialize());
}
Expand All @@ -70,54 +42,5 @@ odbcabstraction::Diagnostics& FlightSqlDriver::GetDiagnostics() { return diagnos

void FlightSqlDriver::SetVersion(std::string version) { version_ = std::move(version); }

void FlightSqlDriver::RegisterLog() {
std::string config_path = arrow::internal::GetEnvVar(CONFIG_FILE_PATH).ValueOr("");
if (config_path.empty()) {
return;
}

odbcabstraction::PropertyMap propertyMap;
driver::odbcabstraction::ReadConfigFile(propertyMap, config_path, CONFIG_FILE_NAME);

auto log_enable_iterator = propertyMap.find(std::string(SPDLogger::LOG_ENABLED));
auto log_enabled = log_enable_iterator != propertyMap.end()
? odbcabstraction::AsBool(log_enable_iterator->second)
: false;
if (!log_enabled.get()) {
return;
}

auto log_path_iterator = propertyMap.find(std::string(SPDLogger::LOG_PATH));
auto log_path = log_path_iterator != propertyMap.end() ? log_path_iterator->second : "";
if (log_path.empty()) {
return;
}

auto log_level_iterator = propertyMap.find(std::string(SPDLogger::LOG_LEVEL));
auto log_level = ToLogLevel(log_level_iterator != propertyMap.end()
? std::stoi(log_level_iterator->second)
: 1);
if (log_level == odbcabstraction::LogLevel_OFF) {
return;
}

auto maximum_file_size_iterator =
propertyMap.find(std::string(SPDLogger::MAXIMUM_FILE_SIZE));
auto maximum_file_size = maximum_file_size_iterator != propertyMap.end()
? std::stoi(maximum_file_size_iterator->second)
: DEFAULT_MAXIMUM_FILE_SIZE;

auto maximum_file_quantity_iterator =
propertyMap.find(std::string(SPDLogger::FILE_QUANTITY));
auto maximum_file_quantity = maximum_file_quantity_iterator != propertyMap.end()
? std::stoi(maximum_file_quantity_iterator->second)
: 1;

std::unique_ptr<odbcabstraction::SPDLogger> logger(new odbcabstraction::SPDLogger());

logger->init(maximum_file_quantity, maximum_file_size, log_path, log_level);
odbcabstraction::Logger::SetInstance(std::move(logger));
}

} // namespace flight_sql
} // namespace driver
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class FlightSqlDriver : public odbcabstraction::Driver {
odbcabstraction::Diagnostics& GetDiagnostics() override;

void SetVersion(std::string version) override;

void RegisterLog() override;
};

}; // namespace flight_sql
Expand Down
Loading
Loading