From b11e8ad38279a1e9dbcd3d25fd8b19382e16deef Mon Sep 17 00:00:00 2001 From: YANGDB Date: Wed, 14 Dec 2022 12:52:33 -0800 Subject: [PATCH] As part of SQL repo split - ODBC was missing the 2.X branch This cherry-picking if intended to sync the ODBC new repo to the existing 2.X state of the unified SQL repo see :: Update MacOS Version for ODBC Driver #987 Origin PR: https://github.com/opensearch-project/sql/pull/987 Done by: https://github.com/forestmvey Signed-off-by: YANGDB --- .github/workflows/sql-odbc-main.yml | 1 + CONTRIBUTING.md | 4 +- aws_sdk_cpp_setup.sh | 5 -- build_mac_debug64.sh | 12 ++-- build_mac_release64.sh | 12 ++-- build_win_debug32.ps1 | 4 ++ build_win_debug64.ps1 | 4 ++ build_win_release32.ps1 | 4 ++ build_win_release64.ps1 | 4 ++ docs/dev/BUILD_INSTRUCTIONS.md | 4 +- docs/dev/run_tests.md | 2 +- docs/user/windows_configure_dsn.md | 2 +- libraries/rabbit/include/rabbit.hpp | 4 -- scripts/build_aws-sdk-cpp.ps1 | 45 --------------- scripts/build_driver.ps1 | 8 ++- scripts/build_installer.ps1 | 4 ++ scripts/build_windows.ps1 | 30 ++-------- src/CMakeLists.txt | 26 +++------ .../ITODBCAwsAuth/CMakeLists.txt | 5 +- .../ITODBCCatalog/CMakeLists.txt | 5 +- .../ITODBCCatalog/test_odbc_catalog.cpp | 1 + .../ITODBCConnection/CMakeLists.txt | 5 +- .../ITODBCDescriptors/CMakeLists.txt | 5 +- .../ITODBCExecution/CMakeLists.txt | 5 +- .../ITODBCHelper/CMakeLists.txt | 5 +- .../ITODBCInfo/CMakeLists.txt | 5 +- .../ITODBCPagination/CMakeLists.txt | 5 +- .../ITODBCResults/CMakeLists.txt | 5 +- .../ITODBCTableauQueries/CMakeLists.txt | 5 +- .../PTODBCInfo/CMakeLists.txt | 5 +- .../PTODBCResults/CMakeLists.txt | 5 +- .../performance_odbc_results.cpp | 5 +- src/UnitTests/UTAwsSdkCpp/CMakeLists.txt | 5 +- src/UnitTests/UTConn/CMakeLists.txt | 5 +- .../UTCriticalSection/CMakeLists.txt | 5 +- src/UnitTests/UTHelper/CMakeLists.txt | 5 +- src/UnitTests/UTRabbit/CMakeLists.txt | 5 +- src/gtest/googletest-download.cmake | 20 ------- src/gtest/googletest.cmake | 32 ----------- src/installer/CMakeLists.txt | 17 ------ src/installer/Resources/README.txt | 2 +- src/sqlodbc/info.c | 3 - src/sqlodbc/odbcapiw.c | 22 ------- src/sqlodbc/opensearch_communication.cpp | 6 +- src/sqlodbc/options.c | 5 -- src/sqlodbc/results.c | 7 --- src/sqlodbc/unicode_support.h | 1 - src/sqlodbc/win_unicode.c | 57 ------------------- src/vcpkg.json | 12 ++++ 49 files changed, 146 insertions(+), 304 deletions(-) delete mode 100755 aws_sdk_cpp_setup.sh delete mode 100644 scripts/build_aws-sdk-cpp.ps1 delete mode 100644 src/gtest/googletest-download.cmake delete mode 100644 src/gtest/googletest.cmake create mode 100644 src/vcpkg.json diff --git a/.github/workflows/sql-odbc-main.yml b/.github/workflows/sql-odbc-main.yml index 1d0bb17..f8a46e8 100644 --- a/.github/workflows/sql-odbc-main.yml +++ b/.github/workflows/sql-odbc-main.yml @@ -1,6 +1,7 @@ name: OpenSearch ODBC Driver on: + workflow_dispatch: pull_request: push: branches-ignore: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b993d78..7911e57 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,7 +89,7 @@ Looking at the existing issues is a great way to find something to contribute on ## Code of Conduct -This project has adopted an [Open Source Code of Conduct](CODE_OF_CONDUCT.md). +This project has adopted an [Open Source Code of Conduct](./CODE_OF_CONDUCT.md). ## Security issue notifications @@ -98,6 +98,6 @@ If you discover a potential security issue in this project we ask that you notif ## Licensing -See the [LICENSE](LICENSE.txt) file for our project's licensing. We will ask you to confirm the licensing of your contribution. +See the [LICENSE](./LICENSE.txt) file for our project's licensing. We will ask you to confirm the licensing of your contribution. We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. diff --git a/aws_sdk_cpp_setup.sh b/aws_sdk_cpp_setup.sh deleted file mode 100755 index b75cc01..0000000 --- a/aws_sdk_cpp_setup.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -cd src -git clone -b "1.7.329" "https://github.com/aws/aws-sdk-cpp.git" -cd .. diff --git a/build_mac_debug64.sh b/build_mac_debug64.sh index 3522137..784aead 100755 --- a/build_mac_debug64.sh +++ b/build_mac_debug64.sh @@ -1,14 +1,18 @@ -# Build AWS SDK -# $BITNESS=64 +#!/bin/bash cd src -git clone -b "1.7.329" "https://github.com/aws/aws-sdk-cpp.git" +vcpkg install cd .. +vcpkg_installed_dir='x64-osx' +if [[ $MACHTYPE == 'arm64-apple-darwin'* ]]; then + vcpkg_installed_dir='arm64-osx' +fi + PREFIX_PATH=$(pwd) mkdir cmake-build64 cd cmake-build64 -cmake ../src -DCMAKE_INSTALL_PREFIX=${PREFIX_PATH}/AWSSDK/ -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY="core" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_RTTI="OFF" -DENABLE_TESTING="OFF" +cmake ../src -DCMAKE_INSTALL_PREFIX=${PREFIX_PATH}/src/vcpkg_installed/${vcpkg_installed_dir}/ -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY="core" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_RTTI="OFF" -DENABLE_TESTING="OFF" cd .. cmake --build cmake-build64 -- -j 4 diff --git a/build_mac_release64.sh b/build_mac_release64.sh index 707a0ee..8fab73e 100755 --- a/build_mac_release64.sh +++ b/build_mac_release64.sh @@ -1,14 +1,18 @@ -# Build AWS SDK -# $BITNESS=64 +#!/bin/bash cd src -git clone -b "1.7.329" "https://github.com/aws/aws-sdk-cpp.git" +vcpkg install cd .. +vcpkg_installed_dir='x64-osx' +if [[ $MACHTYPE == 'arm64-apple-darwin'* ]]; then + vcpkg_installed_dir='arm64-osx' +fi + PREFIX_PATH=$(pwd) mkdir cmake-build64 cd cmake-build64 -cmake ../src -DCMAKE_INSTALL_PREFIX=${PREFIX_PATH}/AWSSDK/ -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="core" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_RTTI="OFF" -DENABLE_TESTING="OFF" +cmake ../src -DCMAKE_INSTALL_PREFIX=${PREFIX_PATH}/src/vcpkg_installed/${vcpkg_installed_dir}/ -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="core" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_RTTI="OFF" -DENABLE_TESTING="OFF" cd .. cmake --build cmake-build64 -- -j 4 diff --git a/build_win_debug32.ps1 b/build_win_debug32.ps1 index 7e23ada..2717064 100644 --- a/build_win_debug32.ps1 +++ b/build_win_debug32.ps1 @@ -1,2 +1,6 @@ $WORKING_DIR = (Get-Location).Path +$env:VCPKG_DEFAULT_TRIPLET = 'x86-windows' +cd src +vcpkg install +cd .. .\scripts\build_windows.ps1 $WORKING_DIR Debug 32 diff --git a/build_win_debug64.ps1 b/build_win_debug64.ps1 index ea7084b..98a9a24 100644 --- a/build_win_debug64.ps1 +++ b/build_win_debug64.ps1 @@ -1,2 +1,6 @@ $WORKING_DIR = (Get-Location).Path +$env:VCPKG_DEFAULT_TRIPLET = 'x64-windows' +cd src +vcpkg install +cd .. .\scripts\build_windows.ps1 $WORKING_DIR Debug 64 diff --git a/build_win_release32.ps1 b/build_win_release32.ps1 index 4bcf4bd..c7e41da 100644 --- a/build_win_release32.ps1 +++ b/build_win_release32.ps1 @@ -1,2 +1,6 @@ $WORKING_DIR = (Get-Location).Path +$env:VCPKG_DEFAULT_TRIPLET = 'x86-windows' +cd src +vcpkg install +cd .. .\scripts\build_windows.ps1 $WORKING_DIR Release 32 diff --git a/build_win_release64.ps1 b/build_win_release64.ps1 index 82b1199..a17f4d6 100644 --- a/build_win_release64.ps1 +++ b/build_win_release64.ps1 @@ -1,2 +1,6 @@ $WORKING_DIR = (Get-Location).Path +$env:VCPKG_DEFAULT_TRIPLET = 'x64-windows' +cd src +vcpkg install +cd .. .\scripts\build_windows.ps1 $WORKING_DIR Release 64 diff --git a/docs/dev/BUILD_INSTRUCTIONS.md b/docs/dev/BUILD_INSTRUCTIONS.md index 6b3094b..dfd3d77 100644 --- a/docs/dev/BUILD_INSTRUCTIONS.md +++ b/docs/dev/BUILD_INSTRUCTIONS.md @@ -54,7 +54,7 @@ msbuild .\build\odbc\PACKAGE.vcxproj -p:Configuration=Release `OpenSearch SQL ODBC Driver--Windows--bit.msi` will be generated in the build directory. ### Testing -See [run_tests.md](run_tests.md) +See [run_tests.md](./run_tests.md) ## Mac @@ -99,7 +99,7 @@ cpack . `OpenSearch SQL ODBC Driver--Darwin.pkg` will be generated in the build directory. ### Testing -See [run_tests.md](run_tests.md) +See [run_tests.md](./run_tests.md) ## General Build Info diff --git a/docs/dev/run_tests.md b/docs/dev/run_tests.md index e94e7d3..6d7dd14 100644 --- a/docs/dev/run_tests.md +++ b/docs/dev/run_tests.md @@ -10,7 +10,7 @@ Loading a dataset requires an [OpenSearch](https://docs-beta.opensearch.org/opensearch/install/index/) service running with [OpenSearch Dashboards](https://docs-beta.opensearch.org/dashboards/index/). If either of these are missing, please refer to the documentation on how to set them up. -Note, if you wish to work with SSL/TLS, you need to configure OpenSearch and OpenSearch Dashboards to support it. See the [build instructions](BUILD_INSTRUCTIONS.md) for more info. +Note, if you wish to work with SSL/TLS, you need to configure OpenSearch and OpenSearch Dashboards to support it. See the [build instructions](./BUILD_INSTRUCTIONS.md) for more info. First load the sample datasets provided by OpenSearch Dashboards. diff --git a/docs/user/windows_configure_dsn.md b/docs/user/windows_configure_dsn.md index 3282d9c..cf49861 100644 --- a/docs/user/windows_configure_dsn.md +++ b/docs/user/windows_configure_dsn.md @@ -10,7 +10,7 @@ -3. DSN Setup window will open with default values for [configuration options](configuration_options.md). +3. DSN Setup window will open with default values for [configuration options](./configuration_options.md). diff --git a/libraries/rabbit/include/rabbit.hpp b/libraries/rabbit/include/rabbit.hpp index ea4cdde..736de5e 100644 --- a/libraries/rabbit/include/rabbit.hpp +++ b/libraries/rabbit/include/rabbit.hpp @@ -1150,10 +1150,6 @@ class basic_array : public basic_value : base_type(alloc) {} - basic_array(const basic_array& other) - : base_type(other) - {} - template basic_array(const basic_value_ref& other) : base_type(other) diff --git a/scripts/build_aws-sdk-cpp.ps1 b/scripts/build_aws-sdk-cpp.ps1 deleted file mode 100644 index 999d12f..0000000 --- a/scripts/build_aws-sdk-cpp.ps1 +++ /dev/null @@ -1,45 +0,0 @@ -$CONFIGURATION = $args[0] -$WIN_ARCH = $args[1] -$SRC_DIR = $args[2] -$BUILD_DIR = $args[3] -$INSTALL_DIR = $args[4] -$VCPKG_DIR = $args[5] -$LIBCURL_WIN_ARCH = $args[6] - -Write-Host $args - -# Clone the AWS SDK CPP repo -$SDK_VER = "1.9.199" - -git clone ` - --branch ` - $SDK_VER ` - --single-branch ` - "https://github.com/aws/aws-sdk-cpp.git" ` - --recurse-submodules ` - $SRC_DIR - -# Make and move to build directory -New-Item -Path $BUILD_DIR -ItemType Directory -Force | Out-Null -Set-Location $BUILD_DIR - -# Configure and build -cmake $SRC_DIR ` - -A $WIN_ARCH ` - -D CMAKE_VERBOSE_MAKEFILE=ON ` - -D CMAKE_INSTALL_PREFIX=$INSTALL_DIR ` - -D CMAKE_BUILD_TYPE=$CONFIGURATION ` - -D BUILD_ONLY="core" ` - -D ENABLE_UNITY_BUILD="ON" ` - -D CUSTOM_MEMORY_MANAGEMENT="OFF" ` - -D ENABLE_RTTI="OFF" ` - -D ENABLE_TESTING="OFF" ` - -D FORCE_CURL="ON" ` - -D ENABLE_CURL_CLIENT="ON" ` - -DCMAKE_TOOLCHAIN_FILE="${VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake" ` - -D CURL_LIBRARY="${VCPKG_DIR}/packages/curl_${LIBCURL_WIN_ARCH}-windows/lib" ` - -D CURL_INCLUDE_DIR="${VCPKG_DIR}/packages/curl_${LIBCURL_WIN_ARCH}-windows/include/" - -# Build AWS SDK and install to $INSTALL_DIR -msbuild ALL_BUILD.vcxproj /m /p:Configuration=$CONFIGURATION -msbuild INSTALL.vcxproj /m /p:Configuration=$CONFIGURATION diff --git a/scripts/build_driver.ps1 b/scripts/build_driver.ps1 index 1c0f8a7..7f514a0 100644 --- a/scripts/build_driver.ps1 +++ b/scripts/build_driver.ps1 @@ -2,13 +2,17 @@ $CONFIGURATION = $args[0] $WIN_ARCH = $args[1] $SRC_DIR = $args[2] $BUILD_DIR = $args[3] -$INSTALL_DIR = $args[4] +$VCPKG_INSTALLED_DIR = $args[4] + +# aws-sdk-cpp fails compilation with warning: +# "Various members of std::allocator are deprecated in C++17" +$env:CL='-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING' cmake -S $SRC_DIR ` -B $BUILD_DIR ` -A $WIN_ARCH ` -D CMAKE_BUILD_TYPE=$CONFIGURATION ` - -D CMAKE_INSTALL_PREFIX=$INSTALL_DIR ` + -D CMAKE_INSTALL_PREFIX=$VCPKG_INSTALLED_DIR ` -D BUILD_WITH_TESTS=ON # # Build Project diff --git a/scripts/build_installer.ps1 b/scripts/build_installer.ps1 index b6a8e6e..63857b4 100644 --- a/scripts/build_installer.ps1 +++ b/scripts/build_installer.ps1 @@ -6,6 +6,10 @@ $INSTALL_DIR = $args[4] Write-Host $args +# aws-sdk-cpp fails compilation with warning: +# "Various members of std::allocator are deprecated in C++17" +$env:CL='-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING' + cmake -S $SRC_DIR ` -B $BUILD_DIR ` -A $WIN_ARCH ` diff --git a/scripts/build_windows.ps1 b/scripts/build_windows.ps1 index 49b857e..f2090df 100644 --- a/scripts/build_windows.ps1 +++ b/scripts/build_windows.ps1 @@ -9,50 +9,28 @@ if ($BITNESS -eq "64") { else { $WIN_ARCH = "Win32" } -if ($BITNESS -eq "64") { - $LIBCURL_WIN_ARCH = "x64" -} -else { - $LIBCURL_WIN_ARCH = "x86" -} # Create build directory; remove if exists $BUILD_DIR = "${WORKING_DIR}\build" -# $BUILD_DIR = "${WORKING_DIR}\build\${CONFIGURATION}${BITNESS}" New-Item -Path $BUILD_DIR -ItemType Directory -Force | Out-Null -$VCPKG_DIR = $Env:VCPKG_ROOT -vcpkg.exe install curl[tool]:${LIBCURL_WIN_ARCH}-windows - -Set-Location $CURRENT_DIR - -# Build AWS SDK CPP -$SDK_SOURCE_DIR = "${WORKING_DIR}\src\aws-sdk-cpp" -$SDK_BUILD_DIR = "${BUILD_DIR}\aws-sdk\build" -$SDK_INSTALL_DIR = "${BUILD_DIR}\aws-sdk\install" - -.\scripts\build_aws-sdk-cpp.ps1 ` - $CONFIGURATION $WIN_ARCH ` - $SDK_SOURCE_DIR $SDK_BUILD_DIR $SDK_INSTALL_DIR $VCPKG_DIR ` - $LIBCURL_WIN_ARCH - Set-Location $CURRENT_DIR # Build driver $DRIVER_SOURCE_DIR = "${WORKING_DIR}\src" $DRIVER_BUILD_DIR = "${BUILD_DIR}\odbc\cmake" +$VCPKG_INSTALLED_DIR = "${DRIVER_SOURCE_DIR}\vcpkg_installed\$env:VCPKG_DEFAULT_TRIPLET" .\scripts\build_driver.ps1 ` $CONFIGURATION $WIN_ARCH ` - $DRIVER_SOURCE_DIR $DRIVER_BUILD_DIR $SDK_INSTALL_DIR + $DRIVER_SOURCE_DIR $DRIVER_BUILD_DIR $VCPKG_INSTALLED_DIR Set-Location $CURRENT_DIR # Move driver dependencies to bin directory for testing -$DRIVER_BIN_DIR = "$DRIVER_BUILD_DIR\..\bin\$CONFIGURATION" +$DRIVER_BIN_DIR = "${BUILD_DIR}\odbc\bin\$CONFIGURATION" New-Item -Path $DRIVER_BIN_DIR -ItemType Directory -Force | Out-Null -Copy-Item $SDK_BUILD_DIR\bin\$CONFIGURATION\* $DRIVER_BIN_DIR -Copy-Item $DRIVER_BUILD_DIR\bin\$CONFIGURATION\* $DRIVER_BIN_DIR +Copy-Item $VCPKG_INSTALLED_DIR\bin\* $DRIVER_BIN_DIR if ($BITNESS -eq "32") { # Strip bitness from 32bit VLD DLL dir name $BITNESS = $null diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e2555ba..93838c7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -74,21 +74,17 @@ set(PERFORMANCE_TESTS "${CMAKE_CURRENT_SOURCE_DIR}/PerformanceTests") set(UT_HELPER "${UNIT_TESTS}/UTHelper") set(IT_HELPER "${INTEGRATION_TESTS}/ITODBCHelper") set(RABBIT_SRC ${LIBRARY_DIRECTORY}/rabbit/include) -set(RAPIDJSON_SRC ${LIBRARY_DIRECTORY}/rapidjson/include) set(VLD_SRC ${LIBRARY_DIRECTORY}/VisualLeakDetector/include) - +if(WIN32) + set(RAPIDJSON_SRC ${LIBRARY_DIRECTORY}/rapidjson/include) +endif () # Without this symbols will be exporting to Unix but not Windows set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) -# Set path for AWS SDK -set(aws-cpp-sdk-base "${CMAKE_CURRENT_SOURCE_DIR}/aws-sdk-cpp") -set(aws-cpp-sdk-core_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-core") -set(aws-c-event-stream_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-event-stream/cmake") -set(aws-c-common_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-common/cmake") -set(aws-checksums_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-checksums/cmake") - -if (WIN32) - find_package(AWSSDK REQUIRED core) +find_package(aws-cpp-sdk-core CONFIG REQUIRED) +if(APPLE) + find_package(ZLIB REQUIRED) + find_package(RapidJSON CONFIG REQUIRED) endif() # General compiler definitions @@ -134,18 +130,10 @@ endif() if(BUILD_WITH_TESTS) # GTest import - include(gtest/googletest.cmake) - fetch_googletest( - ${PROJECT_SOURCE_DIR}/gtest - ${PROJECT_BINARY_DIR}/googletest - ) enable_testing() endif() # Projects to build -if (APPLE) - add_subdirectory(${aws-cpp-sdk-base}) -endif() add_subdirectory(${OPENSEARCHODBC_SRC}) add_subdirectory(${OPENSEARCHENLIST_SRC}) add_subdirectory(${INSTALL_SRC}) diff --git a/src/IntegrationTests/ITODBCAwsAuth/CMakeLists.txt b/src/IntegrationTests/ITODBCAwsAuth/CMakeLists.txt index 760ae5d..adf520e 100644 --- a/src/IntegrationTests/ITODBCAwsAuth/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCAwsAuth/CMakeLists.txt @@ -12,6 +12,9 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(itodbc_aws_auth ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies -target_link_libraries(itodbc_aws_auth sqlodbc itodbc_helper ut_helper gtest_main aws-cpp-sdk-core) +target_link_libraries(itodbc_aws_auth sqlodbc itodbc_helper ut_helper GTest::gtest_main aws-cpp-sdk-core) target_compile_definitions(itodbc_aws_auth PUBLIC _UNICODE UNICODE) diff --git a/src/IntegrationTests/ITODBCCatalog/CMakeLists.txt b/src/IntegrationTests/ITODBCCatalog/CMakeLists.txt index 657f32b..f27abdb 100644 --- a/src/IntegrationTests/ITODBCCatalog/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCCatalog/CMakeLists.txt @@ -10,7 +10,10 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(itodbc_catalog ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies target_code_coverage(itodbc_catalog PUBLIC AUTO ALL) -target_link_libraries(itodbc_catalog sqlodbc itodbc_helper ut_helper gtest_main) +target_link_libraries(itodbc_catalog sqlodbc itodbc_helper ut_helper GTest::gtest_main) target_compile_definitions(itodbc_catalog PUBLIC _UNICODE UNICODE) diff --git a/src/IntegrationTests/ITODBCCatalog/test_odbc_catalog.cpp b/src/IntegrationTests/ITODBCCatalog/test_odbc_catalog.cpp index c1f12c9..68c672a 100644 --- a/src/IntegrationTests/ITODBCCatalog/test_odbc_catalog.cpp +++ b/src/IntegrationTests/ITODBCCatalog/test_odbc_catalog.cpp @@ -3,6 +3,7 @@ #include "pch.h" #include "unit_test_helper.h" #include "it_odbc_helper.h" +#include // clang-format on // General test constants and structures diff --git a/src/IntegrationTests/ITODBCConnection/CMakeLists.txt b/src/IntegrationTests/ITODBCConnection/CMakeLists.txt index d336a9b..81a028b 100644 --- a/src/IntegrationTests/ITODBCConnection/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCConnection/CMakeLists.txt @@ -10,7 +10,10 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(itodbc_connection ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies target_code_coverage(itodbc_connection PUBLIC AUTO ALL) -target_link_libraries(itodbc_connection sqlodbc itodbc_helper ut_helper gtest_main) +target_link_libraries(itodbc_connection sqlodbc itodbc_helper ut_helper GTest::gtest_main) target_compile_definitions(itodbc_connection PUBLIC _UNICODE UNICODE) diff --git a/src/IntegrationTests/ITODBCDescriptors/CMakeLists.txt b/src/IntegrationTests/ITODBCDescriptors/CMakeLists.txt index 37e6d11..8e83be6 100644 --- a/src/IntegrationTests/ITODBCDescriptors/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCDescriptors/CMakeLists.txt @@ -10,7 +10,10 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(itodbc_descriptors ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies target_code_coverage(itodbc_descriptors PUBLIC AUTO ALL) -target_link_libraries(itodbc_descriptors sqlodbc itodbc_helper ut_helper gtest_main) +target_link_libraries(itodbc_descriptors sqlodbc itodbc_helper ut_helper GTest::gtest_main) target_compile_definitions(itodbc_descriptors PUBLIC _UNICODE UNICODE) diff --git a/src/IntegrationTests/ITODBCExecution/CMakeLists.txt b/src/IntegrationTests/ITODBCExecution/CMakeLists.txt index 4fa5d5e..0f3eeec 100644 --- a/src/IntegrationTests/ITODBCExecution/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCExecution/CMakeLists.txt @@ -10,6 +10,9 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(itodbc_execution ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies -target_link_libraries(itodbc_execution sqlodbc itodbc_helper ut_helper gtest_main) +target_link_libraries(itodbc_execution sqlodbc itodbc_helper ut_helper GTest::gtest_main) target_compile_definitions(itodbc_execution PUBLIC _UNICODE UNICODE) diff --git a/src/IntegrationTests/ITODBCHelper/CMakeLists.txt b/src/IntegrationTests/ITODBCHelper/CMakeLists.txt index 56f0bc2..61c97e5 100644 --- a/src/IntegrationTests/ITODBCHelper/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCHelper/CMakeLists.txt @@ -12,6 +12,9 @@ include_directories( # Generate dll (SHARED) add_library(itodbc_helper SHARED ${SOURCE_FILES} ${HEADER_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies -target_link_libraries(itodbc_helper sqlodbc ut_helper gtest_main) +target_link_libraries(itodbc_helper sqlodbc ut_helper GTest::gtest_main) target_compile_definitions(itodbc_helper PUBLIC _UNICODE UNICODE) diff --git a/src/IntegrationTests/ITODBCInfo/CMakeLists.txt b/src/IntegrationTests/ITODBCInfo/CMakeLists.txt index 9b96986..833df41 100644 --- a/src/IntegrationTests/ITODBCInfo/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCInfo/CMakeLists.txt @@ -10,7 +10,10 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(itodbc_info ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies target_code_coverage(itodbc_info PUBLIC AUTO ALL) -target_link_libraries(itodbc_info sqlodbc itodbc_helper ut_helper gtest_main) +target_link_libraries(itodbc_info sqlodbc itodbc_helper ut_helper GTest::gtest_main) target_compile_definitions(itodbc_info PUBLIC _UNICODE UNICODE) diff --git a/src/IntegrationTests/ITODBCPagination/CMakeLists.txt b/src/IntegrationTests/ITODBCPagination/CMakeLists.txt index 7adfd4d..ce452d5 100644 --- a/src/IntegrationTests/ITODBCPagination/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCPagination/CMakeLists.txt @@ -10,7 +10,10 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(itodbc_pagination ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies target_code_coverage(itodbc_pagination PUBLIC AUTO ALL) -target_link_libraries(itodbc_pagination sqlodbc itodbc_helper ut_helper gtest_main) +target_link_libraries(itodbc_pagination sqlodbc itodbc_helper ut_helper GTest::gtest_main) target_compile_definitions(itodbc_pagination PUBLIC _UNICODE UNICODE) diff --git a/src/IntegrationTests/ITODBCResults/CMakeLists.txt b/src/IntegrationTests/ITODBCResults/CMakeLists.txt index 1107fbf..9ea8619 100644 --- a/src/IntegrationTests/ITODBCResults/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCResults/CMakeLists.txt @@ -10,7 +10,10 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(itodbc_results ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies target_code_coverage(itodbc_results PUBLIC AUTO ALL) -target_link_libraries(itodbc_results sqlodbc itodbc_helper ut_helper gtest_main) +target_link_libraries(itodbc_results sqlodbc itodbc_helper ut_helper GTest::gtest_main) target_compile_definitions(itodbc_results PUBLIC _UNICODE UNICODE) diff --git a/src/IntegrationTests/ITODBCTableauQueries/CMakeLists.txt b/src/IntegrationTests/ITODBCTableauQueries/CMakeLists.txt index 74f8c6d..e8c13d1 100644 --- a/src/IntegrationTests/ITODBCTableauQueries/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCTableauQueries/CMakeLists.txt @@ -10,7 +10,10 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(itodbc_tableau_queries ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies target_code_coverage(itodbc_tableau_queries PUBLIC AUTO ALL) -target_link_libraries(itodbc_tableau_queries sqlodbc itodbc_helper ut_helper gtest_main) +target_link_libraries(itodbc_tableau_queries sqlodbc itodbc_helper ut_helper GTest::gtest_main) target_compile_definitions(itodbc_tableau_queries PUBLIC _UNICODE UNICODE) diff --git a/src/PerformanceTests/PTODBCInfo/CMakeLists.txt b/src/PerformanceTests/PTODBCInfo/CMakeLists.txt index 7155038..319dae7 100644 --- a/src/PerformanceTests/PTODBCInfo/CMakeLists.txt +++ b/src/PerformanceTests/PTODBCInfo/CMakeLists.txt @@ -12,6 +12,9 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(performance_info ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies -target_link_libraries(performance_info sqlodbc itodbc_helper ut_helper gtest_main) +target_link_libraries(performance_info sqlodbc itodbc_helper ut_helper GTest::gtest_main) target_compile_definitions(performance_info PUBLIC _UNICODE UNICODE) diff --git a/src/PerformanceTests/PTODBCResults/CMakeLists.txt b/src/PerformanceTests/PTODBCResults/CMakeLists.txt index e04f6b7..589e4ea 100644 --- a/src/PerformanceTests/PTODBCResults/CMakeLists.txt +++ b/src/PerformanceTests/PTODBCResults/CMakeLists.txt @@ -10,6 +10,9 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(performance_results ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies -target_link_libraries(performance_results sqlodbc itodbc_helper ut_helper gtest_main) +target_link_libraries(performance_results sqlodbc itodbc_helper ut_helper GTest::gtest_main) target_compile_definitions(performance_results PUBLIC _UNICODE UNICODE) diff --git a/src/PerformanceTests/PTODBCResults/performance_odbc_results.cpp b/src/PerformanceTests/PTODBCResults/performance_odbc_results.cpp index ed116d0..95184f8 100644 --- a/src/PerformanceTests/PTODBCResults/performance_odbc_results.cpp +++ b/src/PerformanceTests/PTODBCResults/performance_odbc_results.cpp @@ -3,6 +3,7 @@ #include "unit_test_helper.h" #include "it_odbc_helper.h" #include "chrono" +#include #include #include // clang-format on @@ -149,7 +150,6 @@ TEST_F(TestPerformance, Time_BindColumn_FetchSingleRow) { } TEST_F(TestPerformance, Time_BindColumn_Fetch5Rows) { - SQLROWSETSIZE row_count = 0; SQLSMALLINT total_columns = 0; SQLROWSETSIZE rows_fetched = 0; SQLUSMALLINT row_status[ROWSET_SIZE_5]; @@ -176,7 +176,6 @@ TEST_F(TestPerformance, Time_BindColumn_Fetch5Rows) { while (SQLExtendedFetch(m_hstmt, SQL_FETCH_NEXT, 0, &rows_fetched, row_status) == SQL_SUCCESS) { - row_count += rows_fetched; if (rows_fetched < ROWSET_SIZE_5) break; } @@ -190,7 +189,6 @@ TEST_F(TestPerformance, Time_BindColumn_Fetch5Rows) { } TEST_F(TestPerformance, Time_BindColumn_Fetch50Rows) { - SQLROWSETSIZE row_count = 0; SQLSMALLINT total_columns = 0; SQLROWSETSIZE rows_fetched = 0; SQLUSMALLINT row_status[ROWSET_SIZE_50]; @@ -217,7 +215,6 @@ TEST_F(TestPerformance, Time_BindColumn_Fetch50Rows) { while (SQLExtendedFetch(m_hstmt, SQL_FETCH_NEXT, 0, &rows_fetched, row_status) == SQL_SUCCESS) { - row_count += rows_fetched; if (rows_fetched < ROWSET_SIZE_50) break; } diff --git a/src/UnitTests/UTAwsSdkCpp/CMakeLists.txt b/src/UnitTests/UTAwsSdkCpp/CMakeLists.txt index 97d7df0..05f665a 100644 --- a/src/UnitTests/UTAwsSdkCpp/CMakeLists.txt +++ b/src/UnitTests/UTAwsSdkCpp/CMakeLists.txt @@ -9,6 +9,9 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(ut_aws_sdk_cpp ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies -target_link_libraries(ut_aws_sdk_cpp ut_helper gtest_main aws-cpp-sdk-core ${VLD}) +target_link_libraries(ut_aws_sdk_cpp ut_helper GTest::gtest_main aws-cpp-sdk-core ${VLD}) target_compile_definitions(ut_aws_sdk_cpp PUBLIC _UNICODE UNICODE) diff --git a/src/UnitTests/UTConn/CMakeLists.txt b/src/UnitTests/UTConn/CMakeLists.txt index 5d985af..0e90d8f 100644 --- a/src/UnitTests/UTConn/CMakeLists.txt +++ b/src/UnitTests/UTConn/CMakeLists.txt @@ -12,6 +12,9 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(ut_conn ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies -target_link_libraries(ut_conn sqlodbc ut_helper gtest_main) +target_link_libraries(ut_conn sqlodbc ut_helper GTest::gtest_main) target_compile_definitions(ut_conn PUBLIC _UNICODE UNICODE) diff --git a/src/UnitTests/UTCriticalSection/CMakeLists.txt b/src/UnitTests/UTCriticalSection/CMakeLists.txt index 43526f0..e806ef9 100644 --- a/src/UnitTests/UTCriticalSection/CMakeLists.txt +++ b/src/UnitTests/UTCriticalSection/CMakeLists.txt @@ -11,6 +11,9 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(ut_critical_section ${SOURCE_FILES}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies -target_link_libraries(ut_critical_section sqlodbc ut_helper gtest_main) +target_link_libraries(ut_critical_section sqlodbc ut_helper GTest::gtest_main) target_compile_definitions(ut_critical_section PUBLIC _UNICODE UNICODE) diff --git a/src/UnitTests/UTHelper/CMakeLists.txt b/src/UnitTests/UTHelper/CMakeLists.txt index f9764d3..1bfad42 100644 --- a/src/UnitTests/UTHelper/CMakeLists.txt +++ b/src/UnitTests/UTHelper/CMakeLists.txt @@ -22,6 +22,9 @@ find_library( VLD target_link_libraries(ut_helper ${VLD}) endif() +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + # Library dependencies -target_link_libraries(ut_helper sqlodbc gtest_main) +target_link_libraries(ut_helper sqlodbc GTest::gtest_main) target_compile_definitions(ut_helper PUBLIC _UNICODE UNICODE) diff --git a/src/UnitTests/UTRabbit/CMakeLists.txt b/src/UnitTests/UTRabbit/CMakeLists.txt index a5fec96..b5f638f 100644 --- a/src/UnitTests/UTRabbit/CMakeLists.txt +++ b/src/UnitTests/UTRabbit/CMakeLists.txt @@ -10,5 +10,8 @@ include_directories( ${UT_HELPER} # Generate executable add_executable(ut_rabbit ${SOURCE_FILES}) -target_link_libraries(ut_rabbit ut_helper gtest_main ${VLD}) +# Find packages from vcpkg +find_package(GTest CONFIG REQUIRED) + +target_link_libraries(ut_rabbit ut_helper GTest::gtest_main ${VLD}) target_compile_definitions(ut_rabbit PUBLIC _UNICODE UNICODE) diff --git a/src/gtest/googletest-download.cmake b/src/gtest/googletest-download.cmake deleted file mode 100644 index 0ec4d55..0000000 --- a/src/gtest/googletest-download.cmake +++ /dev/null @@ -1,20 +0,0 @@ -# code copied from https://crascit.com/2015/07/25/cmake-gtest/ -cmake_minimum_required(VERSION 3.5 FATAL_ERROR) - -project(googletest-download NONE) - -include(ExternalProject) - -ExternalProject_Add( - googletest - SOURCE_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-src" - BINARY_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-build" - GIT_REPOSITORY - https://github.com/google/googletest.git - GIT_TAG - release-1.10.0 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - ) diff --git a/src/gtest/googletest.cmake b/src/gtest/googletest.cmake deleted file mode 100644 index 5ca7090..0000000 --- a/src/gtest/googletest.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# the following code to fetch googletest -# is inspired by and adapted after https://crascit.com/2015/07/25/cmake-gtest/ -# download and unpack googletest at configure time - -macro(fetch_googletest _download_module_path _download_root) - set(GOOGLETEST_DOWNLOAD_ROOT ${_download_root}) - configure_file( - ${_download_module_path}/googletest-download.cmake - ${_download_root}/CMakeLists.txt - @ONLY - ) - unset(GOOGLETEST_DOWNLOAD_ROOT) - - execute_process( - COMMAND - "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY - ${_download_root} - ) - execute_process( - COMMAND - "${CMAKE_COMMAND}" --build . - WORKING_DIRECTORY - ${_download_root} - ) - - # adds the targers: gtest, gtest_main, gmock, gmock_main - add_subdirectory( - ${_download_root}/googletest-src - ${_download_root}/googletest-build - ) -endmacro() diff --git a/src/installer/CMakeLists.txt b/src/installer/CMakeLists.txt index 726b8f6..d172b91 100644 --- a/src/installer/CMakeLists.txt +++ b/src/installer/CMakeLists.txt @@ -90,21 +90,4 @@ install(FILES "${PROJECT_ROOT}/THIRD-PARTY" DESTINATION doc COMPONENT "Docs") # Install resource files install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/Resources/opensearch_sql_odbc.tdc" DESTINATION resources COMPONENT "Resources") -# Install AWS dependencies -if(WIN32) - set(AWS_SDK_BIN_DIR "${PROJECT_ROOT}/build/aws-sdk/install/bin") - install(DIRECTORY ${AWS_SDK_BIN_DIR} DESTINATION . COMPONENT "Driver") -endif() - -if(WIN32) - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - # We actually never build the installer for Debug - install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/libcurl-d.dll" DESTINATION bin COMPONENT "Driver") - install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/zlibd1.dll" DESTINATION bin COMPONENT "Driver") - else() # release - install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/libcurl.dll" DESTINATION bin COMPONENT "Driver") - install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/zlib1.dll" DESTINATION bin COMPONENT "Driver") - endif() -endif() - include(CPack) diff --git a/src/installer/Resources/README.txt b/src/installer/Resources/README.txt index 694cdc2..86ec3cd 100644 --- a/src/installer/Resources/README.txt +++ b/src/installer/Resources/README.txt @@ -16,4 +16,4 @@ For example, if you want to use Tableau with OpenSearch Server, 4. Click on 'Connect'. All connection attributes will be retrived. 5. Click on 'Sign In'. You will be successfully connected to OpenSearch server. -For more details, check 'https://github.com/opensearch-project/sql-odbc'. \ No newline at end of file +For more details, check 'https://github.com/opensearch-project/sql/tree/main/sql-odbc'. \ No newline at end of file diff --git a/src/sqlodbc/info.c b/src/sqlodbc/info.c index 6925f49..c40f783 100644 --- a/src/sqlodbc/info.c +++ b/src/sqlodbc/info.c @@ -33,7 +33,6 @@ RETCODE SQL_API OPENSEARCHAPI_GetInfo(HDBC hdbc, SQLUSMALLINT fInfoType, SQLSMALLINT *pcbInfoValue) { CSTR func = "OPENSEARCHAPI_GetInfo"; ConnectionClass *conn = (ConnectionClass *)hdbc; - ConnInfo *ci; const char *p = NULL; char tmp[MAX_INFO_STRING]; SQLULEN len = 0, value = 0; @@ -47,8 +46,6 @@ RETCODE SQL_API OPENSEARCHAPI_GetInfo(HDBC hdbc, SQLUSMALLINT fInfoType, return SQL_INVALID_HANDLE; } - ci = &(conn->connInfo); - switch (fInfoType) { case SQL_ACCESSIBLE_PROCEDURES: /* ODBC 1.0 */ p = "N"; diff --git a/src/sqlodbc/odbcapiw.c b/src/sqlodbc/odbcapiw.c index 6b22948..7577e05 100644 --- a/src/sqlodbc/odbcapiw.c +++ b/src/sqlodbc/odbcapiw.c @@ -19,17 +19,13 @@ RETCODE SQL_API SQLColumnsW(HSTMT StatementHandle, SQLWCHAR *CatalogName, char *ctName, *scName, *tbName, *clName; SQLLEN nmlen1, nmlen2, nmlen3, nmlen4; StatementClass *stmt = (StatementClass *)StatementHandle; - ConnectionClass *conn; BOOL lower_id; UWORD flag = PODBC_SEARCH_PUBLIC_SCHEMA; - ConnInfo *ci; MYLOG(OPENSEARCH_TRACE, "entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; - conn = SC_get_conn(stmt); - ci = &(conn->connInfo); lower_id = DEFAULT_LOWERCASEIDENTIFIER; ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id); scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id); @@ -426,14 +422,12 @@ RETCODE SQL_API SQLSpecialColumnsW( char *ctName, *scName, *tbName; SQLLEN nmlen1, nmlen2, nmlen3; StatementClass *stmt = (StatementClass *)StatementHandle; - ConnectionClass *conn; BOOL lower_id; MYLOG(OPENSEARCH_TRACE, "entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; - conn = SC_get_conn(stmt); lower_id = DEFAULT_LOWERCASEIDENTIFIER; ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id); scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id); @@ -467,14 +461,12 @@ RETCODE SQL_API SQLStatisticsW(HSTMT StatementHandle, SQLWCHAR *CatalogName, char *ctName, *scName, *tbName; SQLLEN nmlen1, nmlen2, nmlen3; StatementClass *stmt = (StatementClass *)StatementHandle; - ConnectionClass *conn; BOOL lower_id; MYLOG(OPENSEARCH_TRACE, "entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; - conn = SC_get_conn(stmt); lower_id = DEFAULT_LOWERCASEIDENTIFIER; ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id); scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id); @@ -508,7 +500,6 @@ RETCODE SQL_API SQLTablesW(HSTMT StatementHandle, SQLWCHAR *CatalogName, char *ctName, *scName, *tbName, *tbType; SQLLEN nmlen1, nmlen2, nmlen3, nmlen4; StatementClass *stmt = (StatementClass *)StatementHandle; - ConnectionClass *conn; BOOL lower_id; UWORD flag = 0; @@ -516,7 +507,6 @@ RETCODE SQL_API SQLTablesW(HSTMT StatementHandle, SQLWCHAR *CatalogName, if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; - conn = SC_get_conn(stmt); lower_id = DEFAULT_LOWERCASEIDENTIFIER; ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id); scName = ucs2_to_utf8(SchemaName, NameLength2, &nmlen2, lower_id); @@ -554,7 +544,6 @@ RETCODE SQL_API SQLColumnPrivilegesW( char *ctName, *scName, *tbName, *clName; SQLLEN nmlen1, nmlen2, nmlen3, nmlen4; StatementClass *stmt = (StatementClass *)hstmt; - ConnectionClass *conn; BOOL lower_id; UWORD flag = 0; @@ -562,7 +551,6 @@ RETCODE SQL_API SQLColumnPrivilegesW( if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; - conn = SC_get_conn(stmt); lower_id = DEFAULT_LOWERCASEIDENTIFIER; ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id); @@ -603,14 +591,12 @@ RETCODE SQL_API SQLForeignKeysW( char *ctName, *scName, *tbName, *fkctName, *fkscName, *fktbName; SQLLEN nmlen1, nmlen2, nmlen3, nmlen4, nmlen5, nmlen6; StatementClass *stmt = (StatementClass *)hstmt; - ConnectionClass *conn; BOOL lower_id; MYLOG(OPENSEARCH_TRACE, "entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; - conn = SC_get_conn(stmt); lower_id = DEFAULT_LOWERCASEIDENTIFIER; ctName = ucs2_to_utf8(szPkCatalogName, cbPkCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szPkSchemaName, cbPkSchemaName, &nmlen2, lower_id); @@ -705,14 +691,12 @@ RETCODE SQL_API SQLPrimaryKeysW(HSTMT hstmt, SQLWCHAR *szCatalogName, char *ctName, *scName, *tbName; SQLLEN nmlen1, nmlen2, nmlen3; StatementClass *stmt = (StatementClass *)hstmt; - ConnectionClass *conn; BOOL lower_id; MYLOG(OPENSEARCH_TRACE, "entering\n"); if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; - conn = SC_get_conn(stmt); lower_id = DEFAULT_LOWERCASEIDENTIFIER; ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id); @@ -744,12 +728,10 @@ RETCODE SQL_API SQLProcedureColumnsW( char *ctName, *scName, *prName, *clName; SQLLEN nmlen1, nmlen2, nmlen3, nmlen4; StatementClass *stmt = (StatementClass *)hstmt; - ConnectionClass *conn; BOOL lower_id; UWORD flag = 0; MYLOG(OPENSEARCH_TRACE, "entering\n"); - conn = SC_get_conn(stmt); lower_id = DEFAULT_LOWERCASEIDENTIFIER; ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id); @@ -787,7 +769,6 @@ RETCODE SQL_API SQLProceduresW(HSTMT hstmt, SQLWCHAR *szCatalogName, char *ctName, *scName, *prName; SQLLEN nmlen1, nmlen2, nmlen3; StatementClass *stmt = (StatementClass *)hstmt; - ConnectionClass *conn; BOOL lower_id; UWORD flag = 0; @@ -795,7 +776,6 @@ RETCODE SQL_API SQLProceduresW(HSTMT hstmt, SQLWCHAR *szCatalogName, if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; - conn = SC_get_conn(stmt); lower_id = DEFAULT_LOWERCASEIDENTIFIER; ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id); @@ -831,7 +811,6 @@ RETCODE SQL_API SQLTablePrivilegesW(HSTMT hstmt, SQLWCHAR *szCatalogName, char *ctName, *scName, *tbName; SQLLEN nmlen1, nmlen2, nmlen3; StatementClass *stmt = (StatementClass *)hstmt; - ConnectionClass *conn; BOOL lower_id; UWORD flag = 0; @@ -839,7 +818,6 @@ RETCODE SQL_API SQLTablePrivilegesW(HSTMT hstmt, SQLWCHAR *szCatalogName, if (SC_connection_lost_check(stmt, __FUNCTION__)) return SQL_ERROR; - conn = SC_get_conn(stmt); lower_id = DEFAULT_LOWERCASEIDENTIFIER; ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id); scName = ucs2_to_utf8(szSchemaName, cbSchemaName, &nmlen2, lower_id); diff --git a/src/sqlodbc/opensearch_communication.cpp b/src/sqlodbc/opensearch_communication.cpp index e3bdd73..dab46cb 100644 --- a/src/sqlodbc/opensearch_communication.cpp +++ b/src/sqlodbc/opensearch_communication.cpp @@ -398,7 +398,7 @@ OpenSearchCommunication::IssueRequest( // Set header type if (!content_type.empty()) - request->SetHeaderValue(Aws::Http::CONTENT_TYPE_HEADER, ctype); + request->SetHeaderValue(Aws::Http::CONTENT_TYPE_HEADER, Aws::String(ctype.c_str(), ctype.size())); // Set body if (!query.empty() || !cursor.empty()) { @@ -414,7 +414,7 @@ OpenSearchCommunication::IssueRequest( Aws::MakeShared< Aws::StringStream >("RabbitStream"); *aws_ss << std::string(body.str()); request->AddContentBody(aws_ss); - request->SetContentLength(std::to_string(body.str().size())); + request->SetContentLength(Aws::Utils::StringUtils::to_string(body.str().size())); } // Handle authentication @@ -424,7 +424,7 @@ OpenSearchCommunication::IssueRequest( Aws::Utils::Array< unsigned char > userpw_arr( reinterpret_cast< const unsigned char* >(userpw_str.c_str()), userpw_str.length()); - std::string hashed_userpw = + Aws::String hashed_userpw = Aws::Utils::HashingUtils::Base64Encode(userpw_arr); request->SetAuthorization("Basic " + hashed_userpw); } else if (m_rt_opts.auth.auth_type == AUTHTYPE_IAM) { diff --git a/src/sqlodbc/options.c b/src/sqlodbc/options.c index 243b938..fd100c0 100644 --- a/src/sqlodbc/options.c +++ b/src/sqlodbc/options.c @@ -13,13 +13,8 @@ static RETCODE set_statement_option(ConnectionClass *conn, StatementClass *stmt, SQLUSMALLINT fOption, SQLULEN vParam) { CSTR func = "set_statement_option"; char changed = FALSE; - ConnInfo *ci = NULL; SQLULEN setval; - if (conn) - ci = &(conn->connInfo); - else - ci = &(SC_get_conn(stmt)->connInfo); switch (fOption) { case SQL_ASYNC_ENABLE: /* ignored */ break; diff --git a/src/sqlodbc/results.c b/src/sqlodbc/results.c index 7420062..18f1cd1 100644 --- a/src/sqlodbc/results.c +++ b/src/sqlodbc/results.c @@ -111,7 +111,6 @@ RETCODE SQL_API OPENSEARCHAPI_DescribeCol(HSTMT hstmt, SQLUSMALLINT icol, SQLLEN column_size = 0; int unknown_sizes; SQLINTEGER decimal_digits = 0; - ConnInfo *ci; FIELD_INFO *fi; char buf[255]; int len = 0; @@ -125,7 +124,6 @@ RETCODE SQL_API OPENSEARCHAPI_DescribeCol(HSTMT hstmt, SQLUSMALLINT icol, } conn = SC_get_conn(stmt); - ci = &(conn->connInfo); unknown_sizes = DEFAULT_UNKNOWNSIZES; SC_clear_error(stmt); @@ -321,7 +319,6 @@ RETCODE SQL_API OPENSEARCHAPI_ColAttributes(HSTMT hstmt, SQLUSMALLINT icol, OID field_type = 0; Int2 col_idx; ConnectionClass *conn; - ConnInfo *ci; int column_size, unknown_sizes; int cols = 0; RETCODE result; @@ -349,7 +346,6 @@ RETCODE SQL_API OPENSEARCHAPI_ColAttributes(HSTMT hstmt, SQLUSMALLINT icol, *pcbDesc = 0; irdflds = SC_get_IRDF(stmt); conn = SC_get_conn(stmt); - ci = &(conn->connInfo); /* * Dont check for bookmark column. This is the responsibility of the @@ -415,8 +411,6 @@ RETCODE SQL_API OPENSEARCHAPI_ColAttributes(HSTMT hstmt, SQLUSMALLINT icol, if (FI_is_applicable(fi)) field_type = getEffectiveOid(conn, fi); else { - BOOL build_fi = FALSE; - fi = NULL; switch (fDescType) { case SQL_COLUMN_OWNER_NAME: @@ -429,7 +423,6 @@ RETCODE SQL_API OPENSEARCHAPI_ColAttributes(HSTMT hstmt, SQLUSMALLINT icol, case SQL_DESC_BASE_COLUMN_NAME: case SQL_COLUMN_UPDATABLE: case 1212: /* SQL_CA_SS_COLUMN_KEY ? */ - build_fi = TRUE; break; } diff --git a/src/sqlodbc/unicode_support.h b/src/sqlodbc/unicode_support.h index 2a481b0..e2b2a63 100644 --- a/src/sqlodbc/unicode_support.h +++ b/src/sqlodbc/unicode_support.h @@ -20,7 +20,6 @@ SQLLEN bindcol_hybrid_exec(SQLWCHAR *utf16, const char *ldt, size_t n, SQLLEN bindcol_localize_estimate(const char *utf8dt, BOOL lf_conv, char **wcsbuf); SQLLEN bindcol_localize_exec(char *ldt, size_t n, BOOL lf_conv, char **wcsbuf); -SQLLEN bindpara_msg_to_utf8(const char *ldt, char **wcsbuf, SQLLEN used); SQLLEN bindpara_wchar_to_msg(const SQLWCHAR *utf16, char **wcsbuf, SQLLEN used); SQLLEN locale_to_sqlwchar(SQLWCHAR *utf16, const char *ldt, size_t n, diff --git a/src/sqlodbc/win_unicode.c b/src/sqlodbc/win_unicode.c index 5bc03b6..706e86e 100644 --- a/src/sqlodbc/win_unicode.c +++ b/src/sqlodbc/win_unicode.c @@ -841,63 +841,6 @@ static SQLLEN c16tombs(char *c8dt, const char16_t *c16dt, size_t n) { } #endif /* __CHAR16_UTF_16__ */ -// -// SQLBindParameter SQL_C_CHAR to UTF-8 case -// the current locale => UTF-8 -// -SQLLEN bindpara_msg_to_utf8(const char *ldt, char **wcsbuf, SQLLEN used) { - SQLLEN l = (-2); - char *utf8 = NULL, *ldt_nts, *alloc_nts = NULL, ntsbuf[128]; - int count; - - if (SQL_NTS == used) { - count = (int)strlen(ldt); - ldt_nts = (char *)ldt; - } else if (used < 0) { - return -1; - } else { - count = (int)used; - if (used < (SQLLEN)sizeof(ntsbuf)) - ldt_nts = ntsbuf; - else { - if (NULL == (alloc_nts = malloc(used + 1))) - return l; - ldt_nts = alloc_nts; - } - memcpy(ldt_nts, ldt, used); - ldt_nts[used] = '\0'; - } - - get_convtype(); - MYLOG(OPENSEARCH_DEBUG, " \n"); -#if defined(__WCS_ISO10646__) - if (use_wcs) { - wchar_t *wcsdt = (wchar_t *)malloc((count + 1) * sizeof(wchar_t)); - - if ((l = msgtowstr(ldt_nts, (wchar_t *)wcsdt, count + 1)) >= 0) - utf8 = wcs_to_utf8(wcsdt, -1, &l, FALSE); - free(wcsdt); - } -#endif /* __WCS_ISO10646__ */ -#ifdef __CHAR16_UTF_16__ - if (use_c16) { - SQLWCHAR *utf16 = (SQLWCHAR *)malloc((count + 1) * sizeof(SQLWCHAR)); - - if ((l = mbstoc16_lf((char16_t *)utf16, ldt_nts, count + 1, FALSE)) - >= 0) - utf8 = ucs2_to_utf8(utf16, -1, &l, FALSE); - free(utf16); - } -#endif /* __CHAR16_UTF_16__ */ - if (l < 0 && NULL != utf8) - free(utf8); - else - *wcsbuf = (char *)utf8; - - if (NULL != alloc_nts) - free(alloc_nts); - return l; -} // // SQLBindParameter hybrid case diff --git a/src/vcpkg.json b/src/vcpkg.json new file mode 100644 index 0000000..a5903fb --- /dev/null +++ b/src/vcpkg.json @@ -0,0 +1,12 @@ +{ + "name": "sql-odbc", + "version-string": "1.1.0.1", + "dependencies": ["aws-sdk-cpp", "rapidjson", "zlib", "gtest", "curl"], + "builtin-baseline": "6ca56aeb457f033d344a7106cb3f9f1abf8f4e98", + "overrides": [ + { "name": "aws-sdk-cpp", "version": "1.8.83#2" }, + { "name": "rapidjson", "version": "2022-06-28#1" }, + { "name": "zlib", "version": "1.2.12#1" }, + { "name": "gtest", "version": "1.11.0" } + ] +}