diff --git a/cpp/src/arrow/flight/sql/odbc/CMakeLists.txt b/cpp/src/arrow/flight/sql/odbc/CMakeLists.txt index 975559c2626..9412f81a967 100644 --- a/cpp/src/arrow/flight/sql/odbc/CMakeLists.txt +++ b/cpp/src/arrow/flight/sql/odbc/CMakeLists.txt @@ -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) @@ -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) @@ -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) diff --git a/cpp/src/arrow/flight/sql/odbc/README b/cpp/src/arrow/flight/sql/odbc/README index da9857b7ecc..03f7f7390a3 100644 --- a/cpp/src/arrow/flight/sql/odbc/README +++ b/cpp/src/arrow/flight/sql/odbc/README @@ -1,4 +1,4 @@ -Steps to Register the 64-bit Apache Arrow ODBC driver on Windows +## Steps to Register the 64-bit Apache Arrow ODBC driver on Windows After the build succeeds, the ODBC DLL will be located in `build\debug\Debug` for a debug build and `build\release\Release` for a release build. @@ -18,9 +18,26 @@ After the build succeeds, the ODBC DLL will be located in If the registration is successful, then Apache Arrow Flight SQL ODBC Driver should show as an available ODBC driver in the x64 ODBC Driver Manager. -Steps to Generate Windows Installer +## Steps to Generate Windows Installer 1. Build with `ARROW_FLIGHT_SQL_ODBC=ON` and `ARROW_FLIGHT_SQL_ODBC_INSTALLER=ON`. 2. `cd` to `build` folder. 3. Run `cpack`. If the generation is successful, you will find `Apache Arrow Flight SQL ODBC--win64.msi` generated under the `build` folder. + + +## Steps to Enable Logging +Arrow Flight SQL ODBC driver uses Arrow's internal logging framework. By default, the log messages are printed to the terminal. +1. Set environment variable `ARROW_ODBC_LOG_LEVEL` to any of the following valid value. + +| LogLevel | Description | +|----------|-------------| +| -2 | TRACE | +| -1 | DEBUG | +| 0 | INFO | +| 1 | WARNING | +| 2 | ERROR | +| 3 | FATAL | +| Empty String or not set | No log messages displayed.| + +The Windows ODBC driver currently does not support writing log files. `ARROW_USE_GLOG` is required to write log files, and `ARROW_USE_GLOG` is disabled on Windows platform since plasma using `glog` is not fully tested on windows. diff --git a/cpp/src/arrow/flight/sql/odbc/entry_points.cc b/cpp/src/arrow/flight/sql/odbc/entry_points.cc index 38b4a1fc8ed..bcf93f6a983 100644 --- a/cpp/src/arrow/flight/sql/odbc/entry_points.cc +++ b/cpp/src/arrow/flight/sql/odbc/entry_points.cc @@ -35,7 +35,7 @@ #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h" #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h" -#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h" +#include "arrow/util/logging.h" SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result) { return arrow::SQLAllocHandle(type, parent, result); @@ -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); + ARROW_LOG(DEBUG) << "SQLCancel called with stmt: " << stmt; return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { throw driver::odbcabstraction::DriverException("SQLCancel is not implemented", "IM001"); @@ -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); + ARROW_LOG(DEBUG) << "SQLForeignKeysW called with stmt: " << stmt + << ", pKCatalogName: " << static_cast(pKCatalogName) + << ", pKCatalogNameLength: " << pKCatalogNameLength + << ", pKSchemaName: " << static_cast(pKSchemaName) + << ", pKSchemaNameLength: " << pKSchemaNameLength + << ", pKTableName: " << static_cast(pKTableName) + << ", pKTableNameLength: " << pKTableNameLength + << ", fKCatalogName: " << static_cast(fKCatalogName) + << ", fKCatalogNameLength: " << fKCatalogNameLength + << ", fKSchemaName: " << static_cast(fKSchemaName) + << ", fKSchemaNameLength: " << fKSchemaNameLength + << ", fKTableName: " << static_cast(fKTableName) + << ", fKTableNameLength: " << fKTableNameLength; return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { throw driver::odbcabstraction::DriverException("SQLForeignKeysW is not implemented", "IM001"); @@ -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); + ARROW_LOG(DEBUG) << "SQLPrimaryKeysW called with stmt: " << stmt + << ", catalogName: " << static_cast(catalogName) + << ", catalogNameLength: " << catalogNameLength + << ", schemaName: " << static_cast(schemaName) + << ", schemaNameLength: " << schemaNameLength + << ", tableName: " << static_cast(tableName) + << ", tableNameLength: " << tableNameLength; return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { throw driver::odbcabstraction::DriverException("SQLPrimaryKeysW is not implemented", "IM001"); diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc index c87c394fc31..527e9520dd2 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc @@ -151,6 +151,7 @@ std::shared_ptr LoadFlightSslConfigs( AsBool(connPropertyMap, FlightSqlConnection::USE_SYSTEM_TRUST_STORE) .value_or(SYSTEM_TRUST_STORE_DEFAULT); + // GH-47630: find co-located TLS certificate if `trusted certs` path is not specified auto trusted_certs_iterator = connPropertyMap.find(std::string(FlightSqlConnection::TRUSTED_CERTS)); auto trusted_certs = trusted_certs_iterator != connPropertyMap.end() diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_driver.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_driver.cc index 0736dac8486..c7d32c91adc 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_driver.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_driver.cc @@ -20,46 +20,45 @@ #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" +#include "arrow/util/logging.h" -#define DEFAULT_MAXIMUM_FILE_SIZE 16777216 -#define CONFIG_FILE_NAME "arrow-odbc.ini" -#define CONFIG_FILE_PATH "CONFIG_FILE_PATH" +#define ODBC_LOG_LEVEL "ARROW_ODBC_LOG_LEVEL" -namespace driver { -namespace flight_sql { - -using odbcabstraction::Connection; -using odbcabstraction::LogLevel; -using odbcabstraction::OdbcVersion; -using odbcabstraction::SPDLogger; +using arrow::util::ArrowLogLevel; namespace { -LogLevel ToLogLevel(int64_t level) { +/// Return the corresponding ArrowLogLevel. Debug level is returned by default. +ArrowLogLevel ToLogLevel(int64_t level) { switch (level) { + case -2: + return ArrowLogLevel::ARROW_TRACE; + case -1: + return ArrowLogLevel::ARROW_DEBUG; case 0: - return LogLevel::LogLevel_TRACE; + return ArrowLogLevel::ARROW_INFO; case 1: - return LogLevel::LogLevel_DEBUG; + return ArrowLogLevel::ARROW_WARNING; case 2: - return LogLevel::LogLevel_INFO; + return ArrowLogLevel::ARROW_ERROR; case 3: - return LogLevel::LogLevel_WARN; - case 4: - return LogLevel::LogLevel_ERROR; + return ArrowLogLevel::ARROW_FATAL; default: - return LogLevel::LogLevel_OFF; + return ArrowLogLevel::ARROW_DEBUG; } } } // namespace +namespace driver { +namespace flight_sql { + +using odbcabstraction::Connection; +using odbcabstraction::OdbcVersion; + 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()); + RegisterComputeKernels(); } std::shared_ptr FlightSqlDriver::CreateConnection(OdbcVersion odbc_version) { @@ -70,53 +69,27 @@ 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; - } +void FlightSqlDriver::RegisterComputeKernels() { + auto registry = arrow::compute::GetFunctionRegistry(); - 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; + // strptime is one of the required compute functions + auto strptime_func = registry->GetFunction("strptime"); + if (!strptime_func.ok()) { + // Register Kernel functions to library + ThrowIfNotOK(arrow::compute::Initialize()); } +} - 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) { +void FlightSqlDriver::RegisterLog() { + std::string log_level_str = arrow::internal::GetEnvVar(ODBC_LOG_LEVEL).ValueOr(""); + if (log_level_str.empty()) { return; } + auto log_level = ToLogLevel(std::stoi(log_level_str)); - 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 logger(new odbcabstraction::SPDLogger()); - - logger->init(maximum_file_quantity, maximum_file_size, log_path, log_level); - odbcabstraction::Logger::SetInstance(std::move(logger)); + // Enable driver logging. Log files are not supported on Windows yet, since GLOG is not + // tested fully on Windows. + arrow::util::ArrowLog::StartArrowLog("arrow-flight-sql-odbc", log_level); } } // namespace flight_sql diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h index 48f2a16416a..b11c52a5c38 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h @@ -38,6 +38,9 @@ class FlightSqlDriver : public odbcabstraction::Driver { void SetVersion(std::string version) override; + /// Register Arrow Compute kernels once. + void RegisterComputeKernels(); + void RegisterLog() override; }; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/win_system_dsn.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/win_system_dsn.cc index 2017936dd90..d213975cf13 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/win_system_dsn.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/win_system_dsn.cc @@ -32,7 +32,7 @@ #include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/window.h" #include "arrow/flight/sql/odbc/flight_sql/system_dsn.h" #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/exceptions.h" -#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h" +#include "arrow/util/logging.h" #include #include @@ -87,7 +87,7 @@ bool DisplayConnectionWindow(void* windowParent, Configuration& config, properties = config.GetProperties(); return true; } else { - LOG_INFO("Dialog is cancelled by user"); + ARROW_LOG(INFO) << "Dialog is cancelled by user"; return false; } } diff --git a/cpp/src/arrow/flight/sql/odbc/odbc_api.cc b/cpp/src/arrow/flight/sql/odbc/odbc_api.cc index 82a167b3c16..7dc5fdb0f41 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbc_api.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbc_api.cc @@ -21,7 +21,6 @@ #include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h" #include "arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h" #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h" -#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h" #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h" #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h" #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h" @@ -29,6 +28,7 @@ #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h" #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h" #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h" +#include "arrow/util/logging.h" #if defined _WIN32 || defined _WIN64 // For displaying DSN Window @@ -41,8 +41,9 @@ namespace arrow { SQLRETURN SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result) { - LOG_DEBUG("SQLAllocHandle called with type: {}, parent: {}, result: {}", type, parent, - fmt::ptr(result)); + ARROW_LOG(DEBUG) << "SQLAllocHandle called with type: " << type + << ", parent: " << parent + << ", result: " << static_cast(result); *result = nullptr; @@ -136,7 +137,8 @@ SQLRETURN SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result) } SQLRETURN SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle) { - LOG_DEBUG("SQLFreeHandle called with type: {}, handle: {}", type, handle); + ARROW_LOG(DEBUG) << "SQLFreeHandle called with type: " << type + << ", handle: " << handle; switch (type) { case SQL_HANDLE_ENV: { @@ -203,6 +205,9 @@ SQLRETURN SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle) { } SQLRETURN SQLFreeStmt(SQLHSTMT handle, SQLUSMALLINT option) { + ARROW_LOG(DEBUG) << "SQLAllocHandle called with handle: " << handle + << ", option: " << option; + switch (option) { case SQL_CLOSE: { using ODBC::ODBCStatement; @@ -261,11 +266,12 @@ SQLRETURN SQLGetDiagField(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT SQLSMALLINT bufferLength, SQLSMALLINT* stringLengthPtr) { // TODO: Implement additional fields types // https://github.com/apache/arrow/issues/46573 - LOG_DEBUG( - "SQLGetDiagFieldW called with handleType: {}, handle: {}, recNumber: {}, " - "diagIdentifier: {}, diagInfoPtr: {}, bufferLength: {}, stringLengthPtr: {}", - handleType, handle, recNumber, diagIdentifier, diagInfoPtr, bufferLength, - fmt::ptr(stringLengthPtr)); + ARROW_LOG(DEBUG) << "SQLGetDiagFieldW called with handleType: " << handleType + << ", handle: " << handle << ", recNumber: " << recNumber + << ", diagIdentifier: " << diagIdentifier + << ", diagInfoPtr: " << diagInfoPtr + << ", bufferLength: " << bufferLength + << ", stringLengthPtr: " << static_cast(stringLengthPtr); using driver::odbcabstraction::Diagnostics; using ODBC::GetStringAttribute; @@ -520,12 +526,13 @@ SQLRETURN SQLGetDiagRec(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT re SQLWCHAR* sqlState, SQLINTEGER* nativeErrorPtr, SQLWCHAR* messageText, SQLSMALLINT bufferLength, SQLSMALLINT* textLengthPtr) { - LOG_DEBUG( - "SQLGetDiagRecW called with handleType: {}, handle: {}, recNumber: {}, " - "sqlState: {}, nativeErrorPtr: {}, messageText: {}, bufferLength: {}, " - "textLengthPtr: {}", - handleType, handle, recNumber, fmt::ptr(sqlState), fmt::ptr(nativeErrorPtr), - fmt::ptr(messageText), bufferLength, fmt::ptr(textLengthPtr)); + ARROW_LOG(DEBUG) << "SQLGetDiagRecW called with handleType: " << handleType + << ", handle: " << handle << ", recNumber: " << recNumber + << ", sqlState: " << static_cast(sqlState) + << ", nativeErrorPtr: " << static_cast(nativeErrorPtr) + << ", messageText: " << static_cast(messageText) + << ", bufferLength: " << bufferLength + << ", textLengthPtr: " << static_cast(textLengthPtr); using driver::odbcabstraction::Diagnostics; using ODBC::GetStringAttribute; @@ -608,10 +615,9 @@ SQLRETURN SQLGetDiagRec(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT re SQLRETURN SQLGetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER valuePtr, SQLINTEGER bufferLength, SQLINTEGER* strLenPtr) { - LOG_DEBUG( - "SQLGetEnvAttr called with env: {}, attr: {}, valuePtr: {}, " - "bufferLength: {}, strLenPtr: {}", - env, attr, valuePtr, bufferLength, fmt::ptr(strLenPtr)); + ARROW_LOG(DEBUG) << "SQLGetEnvAttr called with env: " << env << ", attr: " << attr + << ", valuePtr: " << valuePtr << ", bufferLength: " << bufferLength + << ", strLenPtr: " << static_cast(strLenPtr); using driver::odbcabstraction::DriverException; using ODBC::ODBCEnvironment; @@ -668,10 +674,8 @@ SQLRETURN SQLGetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER valuePtr, SQLRETURN SQLSetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER valuePtr, SQLINTEGER strLen) { - LOG_DEBUG( - "SQLSetEnvAttr called with env: {}, attr: {}, valuePtr: {}, " - "strLen: {}", - env, attr, valuePtr, strLen); + ARROW_LOG(DEBUG) << "SQLSetEnvAttr called with env: " << env << ", attr: " << attr + << ", valuePtr: " << valuePtr << ", strLen: " << strLen; using driver::odbcabstraction::DriverException; using ODBC::ODBCEnvironment; @@ -719,10 +723,10 @@ SQLRETURN SQLSetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER valuePtr, SQLRETURN SQLGetConnectAttr(SQLHDBC conn, SQLINTEGER attribute, SQLPOINTER valuePtr, SQLINTEGER bufferLength, SQLINTEGER* stringLengthPtr) { - LOG_DEBUG( - "SQLGetConnectAttrW called with conn: {}, attribute: {}, valuePtr: {}, " - "bufferLength: {}, stringLengthPtr: {}", - conn, attribute, valuePtr, bufferLength, fmt::ptr(stringLengthPtr)); + ARROW_LOG(DEBUG) << "SQLGetConnectAttrW called with conn: " << conn + << ", attribute: " << attribute << ", valuePtr: " << valuePtr + << ", bufferLength: " << bufferLength + << ", stringLengthPtr: " << static_cast(stringLengthPtr); using driver::odbcabstraction::Connection; using ODBC::ODBCConnection; @@ -737,9 +741,9 @@ SQLRETURN SQLGetConnectAttr(SQLHDBC conn, SQLINTEGER attribute, SQLPOINTER value SQLRETURN SQLSetConnectAttr(SQLHDBC conn, SQLINTEGER attr, SQLPOINTER valuePtr, SQLINTEGER valueLen) { - LOG_DEBUG( - "SQLSetConnectAttrW called with conn: {}, attr: {}, valuePtr: {}, valueLen: {}", - conn, attr, valuePtr, valueLen); + ARROW_LOG(DEBUG) << "SQLSetConnectAttrW called with conn: " << conn + << ", attr: " << attr << ", valuePtr: " << valuePtr + << ", valueLen: " << valueLen; using driver::odbcabstraction::Connection; using ODBC::ODBCConnection; @@ -759,13 +763,17 @@ SQLRETURN SQLDriverConnect(SQLHDBC conn, SQLHWND windowHandle, SQLSMALLINT outConnectionStringBufferLen, SQLSMALLINT* outConnectionStringLen, SQLUSMALLINT driverCompletion) { - LOG_DEBUG( - "SQLDriverConnectW called with conn: {}, windowHandle: {}, inConnectionString: {}, " - "inConnectionStringLen: {}, outConnectionString: {}, outConnectionStringBufferLen: " - "{}, outConnectionStringLen: {}, driverCompletion: {}", - conn, fmt::ptr(windowHandle), fmt::ptr(inConnectionString), inConnectionStringLen, - fmt::ptr(outConnectionString), outConnectionStringBufferLen, - fmt::ptr(outConnectionStringLen), driverCompletion); + ARROW_LOG(DEBUG) << "SQLDriverConnectW called with conn: " << conn + << ", windowHandle: " << static_cast(windowHandle) + << ", inConnectionString: " + << static_cast(inConnectionString) + << ", inConnectionStringLen: " << inConnectionStringLen + << ", outConnectionString: " + << static_cast(outConnectionString) + << ", outConnectionStringBufferLen: " << outConnectionStringBufferLen + << ", outConnectionStringLen: " + << static_cast(outConnectionStringLen) + << ", driverCompletion: " << driverCompletion; // TODO: Implement FILEDSN and SAVEFILE keywords according to the spec // https://github.com/apache/arrow/issues/46449 @@ -835,11 +843,13 @@ SQLRETURN SQLDriverConnect(SQLHDBC conn, SQLHWND windowHandle, SQLRETURN SQLConnect(SQLHDBC conn, SQLWCHAR* dsnName, SQLSMALLINT dsnNameLen, SQLWCHAR* userName, SQLSMALLINT userNameLen, SQLWCHAR* password, SQLSMALLINT passwordLen) { - LOG_DEBUG( - "SQLConnectW called with conn: {}, dsnName: {}, dsnNameLen: {}, userName: {}, " - "userNameLen: {}, password: {}, passwordLen: {}", - conn, fmt::ptr(dsnName), dsnNameLen, fmt::ptr(userName), userNameLen, - fmt::ptr(password), passwordLen); + ARROW_LOG(DEBUG) << "SQLConnectW called with conn: " << conn + << ", dsnName: " << static_cast(dsnName) + << ", dsnNameLen: " << dsnNameLen + << ", userName: " << static_cast(userName) + << ", userNameLen: " << userNameLen + << ", password: " << static_cast(password) + << ", passwordLen: " << passwordLen; using driver::flight_sql::FlightSqlConnection; using driver::flight_sql::config::Configuration; @@ -873,7 +883,7 @@ SQLRETURN SQLConnect(SQLHDBC conn, SQLWCHAR* dsnName, SQLSMALLINT dsnNameLen, } SQLRETURN SQLDisconnect(SQLHDBC conn) { - LOG_DEBUG("SQLDisconnect called with conn: {}", conn); + ARROW_LOG(DEBUG) << "SQLDisconnect called with conn: " << conn; using ODBC::ODBCConnection; @@ -888,10 +898,10 @@ SQLRETURN SQLDisconnect(SQLHDBC conn) { SQLRETURN SQLGetInfo(SQLHDBC conn, SQLUSMALLINT infoType, SQLPOINTER infoValuePtr, SQLSMALLINT bufLen, SQLSMALLINT* stringLengthPtr) { - LOG_DEBUG( - "SQLGetInfo called with conn: {}, infoType: {}, infoValuePtr: {}, bufLen: {}, " - "stringLengthPtr: {}", - conn, infoType, infoValuePtr, bufLen, fmt::ptr(stringLengthPtr)); + ARROW_LOG(DEBUG) << "SQLGetInfo called with conn: " << conn + << ", infoType: " << infoType << ", infoValuePtr: " << infoValuePtr + << ", bufLen: " << bufLen + << ", stringLengthPtr: " << static_cast(stringLengthPtr); using ODBC::ODBCConnection; @@ -912,10 +922,11 @@ SQLRETURN SQLGetInfo(SQLHDBC conn, SQLUSMALLINT infoType, SQLPOINTER infoValuePt SQLRETURN SQLGetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER valuePtr, SQLINTEGER bufferLength, SQLINTEGER* stringLengthPtr) { - LOG_DEBUG( - "SQLGetStmtAttrW called with stmt: {}, attribute: {}, valuePtr: {}, " - "bufferLength: {}, stringLengthPtr: {}", - stmt, attribute, valuePtr, bufferLength, fmt::ptr(stringLengthPtr)); + ARROW_LOG(DEBUG) << "SQLGetStmtAttrW called with stmt: " << stmt + << ", attribute: " << attribute << ", valuePtr: " << valuePtr + << ", bufferLength: " << bufferLength + << ", stringLengthPtr: " << static_cast(stringLengthPtr); + using ODBC::ODBCStatement; return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { @@ -931,10 +942,10 @@ SQLRETURN SQLGetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER valuePt SQLRETURN SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER valuePtr, SQLINTEGER stringLength) { - LOG_DEBUG( - "SQLSetStmtAttrW called with stmt: {}, attribute: {}, valuePtr: {}, " - "stringLength: {}", - stmt, attribute, valuePtr, stringLength); + ARROW_LOG(DEBUG) << "SQLSetStmtAttrW called with stmt: " << stmt + << ", attribute: " << attribute << ", valuePtr: " << valuePtr + << ", stringLength: " << stringLength; + using ODBC::ODBCStatement; return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { @@ -949,8 +960,10 @@ SQLRETURN SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER valuePt } SQLRETURN SQLExecDirect(SQLHSTMT stmt, SQLWCHAR* queryText, SQLINTEGER textLength) { - LOG_DEBUG("SQLExecDirectW called with stmt: {}, queryText: {}, textLength: {}", stmt, - fmt::ptr(queryText), textLength); + ARROW_LOG(DEBUG) << "SQLExecDirectW called with stmt: " << stmt + << ", queryText: " << static_cast(queryText) + << ", textLength: " << textLength; + using ODBC::ODBCStatement; // The driver is built to handle SELECT statements only. return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { @@ -965,8 +978,10 @@ SQLRETURN SQLExecDirect(SQLHSTMT stmt, SQLWCHAR* queryText, SQLINTEGER textLengt } SQLRETURN SQLPrepare(SQLHSTMT stmt, SQLWCHAR* queryText, SQLINTEGER textLength) { - LOG_DEBUG("SQLPrepareW called with stmt: {}, queryText: {}, textLength: {}", stmt, - fmt::ptr(queryText), textLength); + ARROW_LOG(DEBUG) << "SQLPrepareW called with stmt: " << stmt + << ", queryText: " << static_cast(queryText) + << ", textLength: " << textLength; + using ODBC::ODBCStatement; // The driver is built to handle SELECT statements only. return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { @@ -980,7 +995,7 @@ SQLRETURN SQLPrepare(SQLHSTMT stmt, SQLWCHAR* queryText, SQLINTEGER textLength) } SQLRETURN SQLExecute(SQLHSTMT stmt) { - LOG_DEBUG("SQLExecute called with stmt: {}", stmt); + ARROW_LOG(DEBUG) << "SQLExecute called with stmt: " << stmt; using ODBC::ODBCStatement; // The driver is built to handle SELECT statements only. @@ -994,7 +1009,7 @@ SQLRETURN SQLExecute(SQLHSTMT stmt) { } SQLRETURN SQLFetch(SQLHSTMT stmt) { - LOG_DEBUG("SQLFetch called with stmt: {}", stmt); + ARROW_LOG(DEBUG) << "SQLFetch called with stmt: " << stmt; using ODBC::ODBCDescriptor; using ODBC::ODBCStatement; @@ -1020,11 +1035,12 @@ SQLRETURN SQLExtendedFetch(SQLHSTMT stmt, SQLUSMALLINT fetchOrientation, SQLUSMALLINT* rowStatusArray) { // GH-47110: SQLExtendedFetch should return SQL_SUCCESS_WITH_INFO for certain diag // states - LOG_DEBUG( - "SQLExtendedFetch called with stmt: {}, fetchOrientation: {}, fetchOffset: {}, " - "rowCountPtr: {}, rowStatusArray: {}", - stmt, fetchOrientation, fetchOffset, fmt::ptr(rowCountPtr), - fmt::ptr(rowStatusArray)); + ARROW_LOG(DEBUG) << "SQLExtendedFetch called with stmt: " << stmt + << ", fetchOrientation: " << fetchOrientation + << ", fetchOffset: " << fetchOffset + << ", rowCountPtr: " << static_cast(rowCountPtr) + << ", rowStatusArray: " << static_cast(rowStatusArray); + using ODBC::ODBCDescriptor; using ODBC::ODBCStatement; return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { @@ -1038,7 +1054,8 @@ SQLRETURN SQLExtendedFetch(SQLHSTMT stmt, SQLUSMALLINT fetchOrientation, // The SQL_ROWSET_SIZE statement attribute specifies the number of rows in the // rowset. SQLULEN rowSetSize = statement->GetRowsetSize(); - LOG_DEBUG("SQL_ROWSET_SIZE value for SQLExtendedFetch: {}", rowSetSize); + ARROW_LOG(DEBUG) << "SQL_ROWSET_SIZE value for SQLExtendedFetch: " << rowSetSize; + if (statement->Fetch(static_cast(rowSetSize), rowCountPtr, rowStatusArray)) { return SQL_SUCCESS; } else { @@ -1050,8 +1067,10 @@ SQLRETURN SQLExtendedFetch(SQLHSTMT stmt, SQLUSMALLINT fetchOrientation, SQLRETURN SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT fetchOrientation, SQLLEN fetchOffset) { - LOG_DEBUG("SQLFetchScroll called with stmt: {}, fetchOrientation: {}, fetchOffset: {}", - stmt, fetchOrientation, fetchOffset); + ARROW_LOG(DEBUG) << "SQLFetchScroll called with stmt: " << stmt + << ", fetchOrientation: " << fetchOrientation + << ", fetchOffset: " << fetchOffset; + using ODBC::ODBCDescriptor; using ODBC::ODBCStatement; return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { @@ -1077,10 +1096,11 @@ SQLRETURN SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT fetchOrientation, SQLRETURN SQLBindCol(SQLHSTMT stmt, SQLUSMALLINT recordNumber, SQLSMALLINT cType, SQLPOINTER dataPtr, SQLLEN bufferLength, SQLLEN* indicatorPtr) { - LOG_DEBUG( - "SQLBindCol called with stmt: {}, recordNumber: {}, cType: {}, " - "dataPtr: {}, bufferLength: {}, strLen_or_IndPtr: {}", - stmt, recordNumber, cType, dataPtr, bufferLength, fmt::ptr(indicatorPtr)); + ARROW_LOG(DEBUG) << "SQLBindCol called with stmt: " << stmt + << ", recordNumber: " << recordNumber << ", cType: " << cType + << ", dataPtr: " << dataPtr << ", bufferLength: " << bufferLength + << ", strLen_or_IndPtr: " << static_cast(indicatorPtr); + using ODBC::ODBCDescriptor; using ODBC::ODBCStatement; return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { @@ -1093,7 +1113,8 @@ SQLRETURN SQLBindCol(SQLHSTMT stmt, SQLUSMALLINT recordNumber, SQLSMALLINT cType } SQLRETURN SQLCloseCursor(SQLHSTMT stmt) { - LOG_DEBUG("SQLCloseCursor called with stmt: {}", stmt); + ARROW_LOG(DEBUG) << "SQLCloseCursor called with stmt: " << stmt; + using ODBC::ODBCStatement; return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { ODBCStatement* statement = reinterpret_cast(stmt); @@ -1110,10 +1131,10 @@ SQLRETURN SQLGetData(SQLHSTMT stmt, SQLUSMALLINT recordNumber, SQLSMALLINT cType // GH-46979: support SQL_C_GUID data type // GH-46980: support Interval data types // GH-46985: return warning message instead of error on float truncation case - LOG_DEBUG( - "SQLGetData called with stmt: {}, recordNumber: {}, cType: {}, " - "dataPtr: {}, bufferLength: {}, indicatorPtr: {}", - stmt, recordNumber, cType, dataPtr, bufferLength, fmt::ptr(indicatorPtr)); + ARROW_LOG(DEBUG) << "SQLGetData called with stmt: " << stmt + << ", recordNumber: " << recordNumber << ", cType: " << cType + << ", dataPtr: " << dataPtr << ", bufferLength: " << bufferLength + << ", indicatorPtr: " << static_cast(indicatorPtr); using ODBC::ODBCStatement; @@ -1124,7 +1145,8 @@ SQLRETURN SQLGetData(SQLHSTMT stmt, SQLUSMALLINT recordNumber, SQLSMALLINT cType } SQLRETURN SQLMoreResults(SQLHSTMT stmt) { - LOG_DEBUG("SQLMoreResults called with stmt: {}", stmt); + ARROW_LOG(DEBUG) << "SQLMoreResults called with stmt: " << stmt; + using ODBC::ODBCStatement; // Multiple result sets not supported. Return SQL_NO_DATA by default. return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { @@ -1134,8 +1156,9 @@ SQLRETURN SQLMoreResults(SQLHSTMT stmt) { } SQLRETURN SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT* columnCountPtr) { - LOG_DEBUG("SQLNumResultCols called with stmt: {}, columnCountPtr: {}", stmt, - fmt::ptr(columnCountPtr)); + ARROW_LOG(DEBUG) << "SQLNumResultCols called with stmt: " << stmt + << ", columnCountPtr: " << static_cast(columnCountPtr); + using ODBC::ODBCStatement; return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { ODBCStatement* statement = reinterpret_cast(stmt); @@ -1145,8 +1168,9 @@ SQLRETURN SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT* columnCountPtr) { } SQLRETURN SQLRowCount(SQLHSTMT stmt, SQLLEN* rowCountPtr) { - LOG_DEBUG("SQLRowCount called with stmt: {}, columnCountPtr: {}", stmt, - fmt::ptr(rowCountPtr)); + ARROW_LOG(DEBUG) << "SQLRowCount called with stmt: " << stmt + << ", columnCountPtr: " << static_cast(rowCountPtr); + using ODBC::ODBCStatement; return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { ODBCStatement* statement = reinterpret_cast(stmt); @@ -1159,15 +1183,16 @@ SQLRETURN SQLTables(SQLHSTMT stmt, SQLWCHAR* catalogName, SQLSMALLINT catalogNam SQLWCHAR* schemaName, SQLSMALLINT schemaNameLength, SQLWCHAR* tableName, SQLSMALLINT tableNameLength, SQLWCHAR* tableType, SQLSMALLINT tableTypeLength) { - LOG_DEBUG( - "SQLTables called with stmt: {}, catalogName: {}, catalogNameLength: " - "{}, " - "schemaName: {}, schemaNameLength: {}, tableName: {}, tableNameLength: {}, " - "tableType: {}, " - "tableTypeLength: {}", - stmt, fmt::ptr(catalogName), catalogNameLength, fmt::ptr(schemaName), - schemaNameLength, fmt::ptr(tableName), tableNameLength, fmt::ptr(tableType), - tableTypeLength); + ARROW_LOG(DEBUG) << "SQLTables called with stmt: " << stmt + << ", catalogName: " << static_cast(catalogName) + << ", catalogNameLength: " << catalogNameLength + << ", schemaName: " << static_cast(schemaName) + << ", schemaNameLength: " << schemaNameLength + << ", tableName: " << static_cast(tableName) + << ", tableNameLength: " << tableNameLength + << ", tableType: " << static_cast(tableType) + << ", tableTypeLength: " << tableTypeLength; + using ODBC::ODBCStatement; using ODBC::SqlWcharToString; @@ -1192,15 +1217,15 @@ SQLRETURN SQLColumns(SQLHSTMT stmt, SQLWCHAR* catalogName, SQLSMALLINT catalogNa SQLWCHAR* columnName, SQLSMALLINT columnNameLength) { // GH-47159: Return NUM_PREC_RADIX based on whether COLUMN_SIZE contains number of // digits or bits - LOG_DEBUG( - "SQLColumnsW called with stmt: {}, catalogName: {}, catalogNameLength: " - "{}, " - "schemaName: {}, schemaNameLength: {}, tableName: {}, tableNameLength: {}, " - "columnName: {}, " - "columnNameLength: {}", - stmt, fmt::ptr(catalogName), catalogNameLength, fmt::ptr(schemaName), - schemaNameLength, fmt::ptr(tableName), tableNameLength, fmt::ptr(columnName), - columnNameLength); + ARROW_LOG(DEBUG) << "SQLColumnsW called with stmt: " << stmt + << ", catalogName: " << static_cast(catalogName) + << ", catalogNameLength: " << catalogNameLength + << ", schemaName: " << static_cast(schemaName) + << ", schemaNameLength: " << schemaNameLength + << ", tableName: " << static_cast(tableName) + << ", tableNameLength: " << tableNameLength + << ", columnName: " << static_cast(columnName) + << ", columnNameLength: " << columnNameLength; using ODBC::ODBCStatement; using ODBC::SqlWcharToString; @@ -1225,12 +1250,15 @@ SQLRETURN SQLColAttribute(SQLHSTMT stmt, SQLUSMALLINT recordNumber, SQLUSMALLINT fieldIdentifier, SQLPOINTER characterAttributePtr, SQLSMALLINT bufferLength, SQLSMALLINT* outputLength, SQLLEN* numericAttributePtr) { - LOG_DEBUG( - "SQLColAttributeW called with stmt: {}, recordNumber: {}, " - "fieldIdentifier: {}, characterAttributePtr: {}, bufferLength: {}, " - "outputLength: {}, numericAttributePtr: {}", - stmt, recordNumber, fieldIdentifier, characterAttributePtr, bufferLength, - fmt::ptr(outputLength), fmt::ptr(numericAttributePtr)); + ARROW_LOG(DEBUG) << "SQLColAttributeW called with stmt: " << stmt + << ", recordNumber: " << recordNumber + << ", fieldIdentifier: " << fieldIdentifier + << ", characterAttributePtr: " << characterAttributePtr + << ", bufferLength: " << bufferLength + << ", outputLength: " << static_cast(outputLength) + << ", numericAttributePtr: " + << static_cast(numericAttributePtr); + using ODBC::ODBCDescriptor; using ODBC::ODBCStatement; return ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { @@ -1319,7 +1347,9 @@ SQLRETURN SQLColAttribute(SQLHSTMT stmt, SQLUSMALLINT recordNumber, SQLRETURN SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT dataType) { // GH-47237 return SQL_PRED_CHAR and SQL_PRED_BASIC for // appropriate data types in `SEARCHABLE` field - LOG_DEBUG("SQLGetTypeInfoW called with stmt: {} dataType: {}", stmt, dataType); + ARROW_LOG(DEBUG) << "SQLGetTypeInfoW called with stmt: " << stmt + << " dataType: " << dataType; + using ODBC::ODBCStatement; return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { ODBCStatement* statement = reinterpret_cast(stmt); @@ -1378,12 +1408,12 @@ SQLRETURN SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT dataType) { SQLRETURN SQLNativeSql(SQLHDBC connectionHandle, SQLWCHAR* inStatementText, SQLINTEGER inStatementTextLength, SQLWCHAR* outStatementText, SQLINTEGER bufferLength, SQLINTEGER* outStatementTextLength) { - LOG_DEBUG( - "SQLNativeSqlW called with connectionHandle: {}, inStatementText: {}, " - "inStatementTextLength: {}, outStatementText: {}, bufferLength: {}, " - "outStatementTextLength: {}", - connectionHandle, fmt::ptr(inStatementText), inStatementTextLength, - fmt::ptr(outStatementText), bufferLength, fmt::ptr(outStatementTextLength)); + ARROW_LOG(DEBUG) << "SQLNativeSqlW called with connectionHandle: " << connectionHandle + << ", inStatementText: " << static_cast(inStatementText) + << ", inStatementTextLength: " << inStatementTextLength + << ", outStatementText: " << static_cast(outStatementText) + << ", bufferLength: " << bufferLength << ", outStatementTextLength: " + << static_cast(outStatementTextLength); using driver::odbcabstraction::Diagnostics; using ODBC::GetAttributeSQLWCHAR; @@ -1407,13 +1437,16 @@ SQLRETURN SQLDescribeCol(SQLHSTMT stmt, SQLUSMALLINT columnNumber, SQLWCHAR* col SQLSMALLINT bufferLength, SQLSMALLINT* nameLengthPtr, SQLSMALLINT* dataTypePtr, SQLULEN* columnSizePtr, SQLSMALLINT* decimalDigitsPtr, SQLSMALLINT* nullablePtr) { - LOG_DEBUG( - "SQLDescribeColW called with stmt: {}, columnNumber: {}, " - "columnName: {}, bufferLength: {}, nameLengthPtr: {}, dataTypePtr: {}, " - "columnSizePtr: {}, decimalDigitsPtr: {}, nullablePtr: {}", - stmt, columnNumber, fmt::ptr(columnName), bufferLength, fmt::ptr(nameLengthPtr), - fmt::ptr(dataTypePtr), fmt::ptr(columnSizePtr), fmt::ptr(decimalDigitsPtr), - fmt::ptr(nullablePtr)); + ARROW_LOG(DEBUG) << "SQLDescribeColW called with stmt: " << stmt + << ", columnNumber: " << columnNumber + << ", columnName: " << static_cast(columnName) + << ", bufferLength: " << bufferLength + << ", nameLengthPtr: " << static_cast(nameLengthPtr) + << ", dataTypePtr: " << static_cast(dataTypePtr) + << ", columnSizePtr: " << static_cast(columnSizePtr) + << ", decimalDigitsPtr: " << static_cast(decimalDigitsPtr) + << ", nullablePtr: " << static_cast(nullablePtr); + using ODBC::ODBCDescriptor; using ODBC::ODBCStatement; diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt index dd8b6dd2f1e..530388a877e 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/CMakeLists.txt @@ -22,9 +22,7 @@ add_library(odbcabstraction include/odbcabstraction/diagnostics.h include/odbcabstraction/error_codes.h include/odbcabstraction/exceptions.h - include/odbcabstraction/logger.h include/odbcabstraction/platform.h - include/odbcabstraction/spd_logger.h include/odbcabstraction/types.h include/odbcabstraction/utils.h include/odbcabstraction/odbc_impl/attribute_utils.h @@ -44,8 +42,6 @@ add_library(odbcabstraction diagnostics.cc encoding.cc exceptions.cc - logger.cc - spd_logger.cc utils.cc ../../../../vendored/whereami/whereami.cc odbc_impl/odbc_connection.cc @@ -62,5 +58,3 @@ set_target_properties(odbcabstraction ${CMAKE_BINARY_DIR}/$/lib RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$/lib) - -target_link_libraries(odbcabstraction PUBLIC spdlog::spdlog) diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h deleted file mode 100644 index 6249df98834..00000000000 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include - -#include - -// The logger using spdlog is deprecated and will be replaced. -// TODO: mirgate logging to use Arrow's internal logging system - -#define __LAZY_LOG(LEVEL, ...) \ - do { \ - driver::odbcabstraction::Logger* logger = \ - driver::odbcabstraction::Logger::GetInstance(); \ - if (logger) { \ - logger->log(driver::odbcabstraction::LogLevel::LogLevel_##LEVEL, \ - [&]() { return fmt::format(__VA_ARGS__); }); \ - } \ - } while (0) -#define LOG_DEBUG(...) __LAZY_LOG(DEBUG, __VA_ARGS__) -#define LOG_INFO(...) __LAZY_LOG(INFO, __VA_ARGS__) -#define LOG_ERROR(...) __LAZY_LOG(ERROR, __VA_ARGS__) -#define LOG_TRACE(...) __LAZY_LOG(TRACE, __VA_ARGS__) -#define LOG_WARN(...) __LAZY_LOG(WARN, __VA_ARGS__) - -namespace driver { -namespace odbcabstraction { - -enum LogLevel { - LogLevel_TRACE, - LogLevel_DEBUG, - LogLevel_INFO, - LogLevel_WARN, - LogLevel_ERROR, - LogLevel_OFF -}; - -class Logger { - protected: - Logger() = default; - - public: - static Logger* GetInstance(); - static void SetInstance(std::unique_ptr logger); - - virtual ~Logger() = default; - - virtual void log(LogLevel level, - const std::function& build_message) = 0; -}; - -} // namespace odbcabstraction -} // namespace driver diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spd_logger.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spd_logger.h deleted file mode 100644 index 08672b9e7c2..00000000000 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spd_logger.h +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include "odbcabstraction/logger.h" - -#include -#include - -#include - -namespace driver { -namespace odbcabstraction { - -class SPDLogger : public Logger { - protected: - std::shared_ptr logger_; - - public: - static constexpr std::string_view LOG_LEVEL = "LogLevel"; - static constexpr std::string_view LOG_PATH = "LogPath"; - static constexpr std::string_view MAXIMUM_FILE_SIZE = "MaximumFileSize"; - static constexpr std::string_view FILE_QUANTITY = "FileQuantity"; - static constexpr std::string_view LOG_ENABLED = "LogEnabled"; - - SPDLogger() = default; - ~SPDLogger() = default; - SPDLogger(SPDLogger& other) = delete; - - void operator=(const SPDLogger&) = delete; - void init(int64_t fileQuantity, int64_t maxFileSize, const std::string& fileNamePrefix, - LogLevel level); - - void log(LogLevel level, - const std::function& build_message) override; -}; - -} // namespace odbcabstraction -} // namespace driver diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h index 6e1fe5739be..5e541a1d45f 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h @@ -17,9 +17,7 @@ #pragma once -#include #include -#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h" #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h" namespace driver { @@ -51,9 +49,5 @@ boost::optional AsBool(const Connection::ConnPropertyMap& connPropertyMap, boost::optional AsInt32(int32_t min_value, const Connection::ConnPropertyMap& connPropertyMap, const std::string_view& property_name); - -void ReadConfigFile(PropertyMap& properties, const std::string& configPath, - const std::string& configFileName); - } // namespace odbcabstraction } // namespace driver diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/logger.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/logger.cc deleted file mode 100644 index 8b105a2f0b6..00000000000 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/logger.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h" - -namespace driver { -namespace odbcabstraction { - -static std::unique_ptr odbc_logger_ = nullptr; - -Logger* Logger::GetInstance() { return odbc_logger_.get(); } - -void Logger::SetInstance(std::unique_ptr logger) { - odbc_logger_ = std::move(logger); -} - -} // namespace odbcabstraction -} // namespace driver diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/spd_logger.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/spd_logger.cc deleted file mode 100644 index 322ae5e5da1..00000000000 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/spd_logger.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include "odbcabstraction/spd_logger.h" - -#include "odbcabstraction/logger.h" - -#include -#include -#include - -#include - -namespace driver { -namespace odbcabstraction { -namespace { -inline spdlog::level::level_enum ToSpdLogLevel(LogLevel level) { - switch (level) { - case LogLevel_TRACE: - return spdlog::level::trace; - case LogLevel_DEBUG: - return spdlog::level::debug; - case LogLevel_INFO: - return spdlog::level::info; - case LogLevel_WARN: - return spdlog::level::warn; - case LogLevel_ERROR: - return spdlog::level::err; - default: - return spdlog::level::off; - } -} -} // namespace - -void SPDLogger::init(int64_t fileQuantity, int64_t maxFileSize, - const std::string& fileNamePrefix, LogLevel level) { - logger_ = spdlog::rotating_logger_mt( - "ODBC Logger", fileNamePrefix, maxFileSize, fileQuantity); - - logger_->set_level(ToSpdLogLevel(level)); -} - -void SPDLogger::log(LogLevel level, - const std::function& build_message) { - auto level_set = logger_->level(); - spdlog::level::level_enum spdlog_level = ToSpdLogLevel(level); - if (level_set == spdlog::level::off || level_set > spdlog_level) { - return; - } - - const std::string& message = build_message(); - logger_->log(spdlog_level, message); -} - -} // namespace odbcabstraction -} // namespace driver diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc index 6feb7ff3be2..09b5980d345 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc @@ -19,13 +19,7 @@ #include "arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h" -#include -#include - #include -#include -#include -#include namespace driver { namespace odbcabstraction { @@ -81,35 +75,5 @@ std::string GetModulePath() { return std::string(path.begin(), path.begin() + dirname_length); } -void ReadConfigFile(PropertyMap& properties, const std::string& config_path, - const std::string& config_file_name) { - std::ifstream config_file; - auto config_file_path = config_path + "/" + config_file_name; - config_file.open(config_file_path); - - if (config_file.fail()) { - auto error_msg = "Arrow Flight SQL ODBC driver config file not found on \"" + - config_file_path + "\""; - std::cerr << error_msg << std::endl; - - throw DriverException(error_msg); - } - - std::string temp_config; - - boost::char_separator separator("="); - while (config_file.good()) { - config_file >> temp_config; - boost::tokenizer> tokenizer(temp_config, separator); - - auto iterator = tokenizer.begin(); - - std::string key = *iterator; - std::string value = *++iterator; - - properties[key] = std::move(value); - } -} - } // namespace odbcabstraction } // namespace driver diff --git a/cpp/vcpkg.json b/cpp/vcpkg.json index 95e6ac83071..68f20663b59 100644 --- a/cpp/vcpkg.json +++ b/cpp/vcpkg.json @@ -54,7 +54,6 @@ "rapidjson", "re2", "snappy", - "spdlog", "sqlite3", "thrift", "utf8proc",