pax_global_header00006660000000000000000000000064150155446220014516gustar00rootroot0000000000000052 comment=7942b8ac1b232abe23ee6b839c2e630675f6a13c mariadb-connector-odbc-3.2.6/000077500000000000000000000000001501554462200160225ustar00rootroot00000000000000mariadb-connector-odbc-3.2.6/BUILD.md000066400000000000000000000037401501554462200172070ustar00rootroot00000000000000# Building the Connector/ODBC Following are build instructions for various operating systems. Paths and filenames are given for example, and may be different on your system of for your purposes. ## Windows Prior to start building on Windows you need to have following tools installed: - Microsoft Visual Studio https://visualstudio.microsoft.com/downloads/ - Git https://git-scm.com/download/win - cmake https://cmake.org/download/ If you need msi package to be generated by the build process, you also need: - WiX Toolset https://wixtoolset.org/releases/ and provide WIX_DIR parameter for cmake with path to WiX binaries, or set WIX env variable with path to WiX installation directory. If you need 32bit(or 64bit) build, you may need to give cmake -A Win32 parameter(or -A Win64), or specify correct cmake generator name using option -G ``` git clone https://github.com/MariaDB/mariadb-connector-odbc.git cd mariadb-connector-odbc cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCONC_WITH_MSI=OFF -DWITH_SSL=SCHANNEL -DWIX_DIR="C:\Program Files (x86)\WiX Toolset v3.11\bin\" . cmake --build . --config RelWithDebInfo msiexec.exe /i wininstall\mariadb-connector-odbc-3.0.6-win32.msi ``` ## CentOS ``` sudo yum -y install git cmake make gcc openssl-devel unixODBC unixODBC-devel git clone https://github.com/MariaDB/mariadb-connector-odbc.git mkdir build && cd build cmake ../mariadb-connector-odbc/ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_SSL=OPENSSL cmake --build . --config RelWithDebInfo sudo make install ``` ## Debian & Ubuntu ``` sudo apt-get update sudo sh apt-get install -y git cmake make gcc libssl-dev unixodbc-dev git clone https://github.com/MariaDB/mariadb-connector-odbc.git mkdir build && cd build cmake ../mariadb-connector-odbc/ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_SSL=OPENSSL cmake --build . --config RelWithDebInfo sudo make install ``` mariadb-connector-odbc-3.2.6/CMakeLists.txt000066400000000000000000000347741501554462200206010ustar00rootroot00000000000000# ************************************************************************************ # Copyright (C) 2013,2025 MariaDB Corporation plc # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not see # or write to the Free Software Foundation, Inc., # 51 Franklin St., Fifth Floor, Boston, MA 02110, USA # *************************************************************************************/ CMAKE_MINIMUM_REQUIRED(VERSION 3.12.0) IF(NOT ${CMAKE_VERSION} VERSION_LESS "3.20.0") CMAKE_POLICY(SET CMP0115 NEW) ENDIF() CMAKE_POLICY(SET CMP0048 NEW) CMAKE_POLICY(SET CMP0040 NEW) CMAKE_POLICY(SET CMP0057 NEW) CMAKE_POLICY(SET CMP0054 NEW) PROJECT(mariadb_connector_odbc VERSION 3.2.6 LANGUAGES CXX C) SET(CMAKE_CXX_STANDARD 11) SET(CMAKE_CXX_STANDARD_REQUIRED ON) GET_PROPERTY(MAODBC_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) # We don't need RC for what we need MAODBC_LANGUAGES for LIST(REMOVE_ITEM MAODBC_LANGUAGES "RC") SET(MARIADB_ODBC_VERSION_QUALITY "ga") SET(MARIADB_ODBC_VERSION "03.02.0006") IF(CMAKE_VERSION VERSION_LESS "3.1") IF(CMAKE_C_COMPILER_ID STREQUAL "GNU") SET (CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=gnu99 ${CMAKE_C_FLAGS}") ENDIF() ELSE() SET(CMAKE_C_STANDARD 99) ENDIF() SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) SET(MARIADB_DEFAULT_PLUGINS_SUBDIR "plugin") SET(DSN_DIALOG_FILES ${CMAKE_SOURCE_DIR}/dsn/odbc_dsn.c ${CMAKE_SOURCE_DIR}/dsn/odbc_dsn.rc ${CMAKE_SOURCE_DIR}/dsn/resource.h ma_dsn.c ma_common.c) MACRO(ADD_OPTION _name _text _default) IF(NOT DEFINED ${_name}) OPTION(${OPT}${_name} "${_text}" "${_default}") ELSE() OPTION(${OPT}${_name} "${_text}" "${${_name}}") ENDIF() ENDMACRO() INCLUDE(check_compiler_flag) IF(WITH_ASAN) IF(MSVC) MA_SET_COMPILER_FLAG("-fsanitize=address" DEBUG RELWITHDEBINFO) SET(MAODBC_LINKER_FLAGS ${MAODBC_LINKER_FLAGS} /INCREMENTAL:NO) MA_SET_LINKER_FLAG("${MAODBC_LINKER_FLAGS}" DEBUG RELWITHDEBINFO) ELSE() MY_CHECK_AND_SET_COMPILER_FLAG("-U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO) MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=address -fPIC" DEBUG RELWITHDEBINFO) SET(WITH_ASAN_OK 1) FOREACH(lang ${MAODBC_LANGUAGES}) IF(NOT ${have_${lang}__fsanitize_address__fPIC}) SET(WITH_ASAN_OK 0) ENDIF() ENDFOREACH() IF(WITH_ASAN_OK) OPTION(WITH_ASAN_SCOPE "Enable -fsanitize-address-use-after-scope" OFF) IF(WITH_ASAN_SCOPE) MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=address -fsanitize-address-use-after-scope" DEBUG RELWITHDEBINFO) ENDIF() ELSE() MESSAGE(FATAL_ERROR "Do not know how to enable address sanitizer") ENDIF() ENDIF() ENDIF() IF (WITH_UBSAN) MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=undefined -fno-sanitize=alignment -U_FORTIFY_SOURCE -DWITH_UBSAN" DEBUG RELWITHDEBINFO) ENDIF() IF (WITH_MSAN) MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=memory -fsanitize-memory-track-origins -U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO) ENDIF() # This has to be before C/C's cmake run, or it will build with /MD IF(WIN32) IF (MSVC) SET(CONFIG_TYPES "DEBUG" "RELEASE" "RELWITHDEBINFO" "MINSIZEREL") FOREACH(BUILD_TYPE ${CONFIG_TYPES}) FOREACH(COMPILER ${MAODBC_LANGUAGES}) SET(COMPILER_FLAGS "${CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}}") IF (NOT COMPILER_FLAGS STREQUAL "") IF(NOT WITH_ASAN) STRING(REPLACE "/MD" "/MT" COMPILER_FLAGS ${COMPILER_FLAGS}) IF (BUILD_TYPE STREQUAL "DEBUG")#OR BUILD_TYPE STREQUAL "RELWITHDEBINFO") SET(COMPILER_FLAGS "${COMPILER_FLAGS} /RTC1") # STL does not like /RTCc ENDIF() STRING(REPLACE "/Zi" "/ZI" COMPILER_FLAGS ${COMPILER_FLAGS}) ENDIF(NOT WITH_ASAN) MESSAGE (STATUS "CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}= ${COMPILER_FLAGS}") SET(CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE} ${COMPILER_FLAGS} CACHE STRING "Overwritten by mariadb-odbc" FORCE) ENDIF() ENDFOREACH() ENDFOREACH() ENDIF() ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)# -DWIN32_LEAN_AND_MEAN) SET(INSTALL_PLUGINDIR "${MARIADB_DEFAULT_PLUGINS_SUBDIR}") ENDIF() INCLUDE(SearchLibrary) INCLUDE(SetValueMacro) ### Build options, initial settings and platform defaults INCLUDE("options_defaults") ### Setting installation paths - should go before C/C subproject sets its own. We need to have control over those INCLUDE("install") IF(WIN32 OR WITH_OPENSSL OR "${WITH_SSL}" STREQUAL "OPENSSL") # If C/C is linked dynamically, we don't need link C/ODBC against encryption library IF (NOT MARIADB_LINK_DYNAMIC) IF(WITH_OPENSSL OR "${WITH_SSL}" STREQUAL "OPENSSL") FIND_PACKAGE(OpenSSL) IF(OPENSSL_FOUND) MESSAGE(STATUS "Configuring to build with OpenSSL ${OPENSSL_LIBRARIES}") ADD_DEFINITIONS(-DHAVE_OPENSSL) SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES}) SET(PLATFORM_DEPENDENCIES ${PLATFORM_DEPENDENCIES} ${SSL_LIBRARIES}) ELSE() MESSAGE(FATAL_ERROR "OpenSSL not found. Please install OpenSSL or disable SSL support via option -DWITH_OPENSSL=Off") ENDIF() ELSE() MESSAGE(STATUS "Configuring SSL support using SChannel") SET(PLATFORM_DEPENDENCIES ${PLATFORM_DEPENDENCIES} version.lib) ENDIF() ENDIF() ELSE() MESSAGE(STATUS "Configuring to build without SSL support") ENDIF() ADD_CUSTOM_TARGET(DEPENDENCIES_FOR_PACKAGE) ### Including C/C subproject IF(NOT USE_SYSTEM_INSTALLED_LIB) IF(GIT_BUILD_SRCPKG) # We don't want with conn/c (wrong) src pkg to be built. SET(GIT_BUILD_SRCPKG FALSE) SET(ODBC_GIT_BUILD_SRCPKG TRUE) ENDIF() MESSAGE(STATUS "Running C/C cmake scripts") INCLUDE(connector_c) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/driver ${CMAKE_SOURCE_DIR}/libmariadb/include) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/driver ${CMAKE_BINARY_DIR}/libmariadb/include) SET(PLUGINS_LIST dialog caching_sha2_password auth_gssapi_client sha256_password mysql_clear_password client_ed25519) IF(APPLE) SET_TARGET_PROPERTIES(${PLUGINS_LIST} PROPERTIES XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--timestamp -f" ) IF(WITH_SIGNCODE) SET_TARGET_PROPERTIES(${PLUGINS_LIST} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Developer ID Application: ${DEVELOPER_ID}") ELSE() SET_TARGET_PROPERTIES(${PLUGINS_LIST} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") ENDIF() ELSE() INSTALL(FILES $ DESTINATION "${INSTALL_LIBDIR}" COMPONENT ConCLib) MESSAGE(STATUS "Configuring to install libmariadb to ${INSTALL_LIBDIR}") IF(NOT ALL_PLUGINS_STATIC) SET(OWN_PLUGINS_LIST mysql_clear_password dialog client_ed25519 sha256_password caching_sha2_password) IF (PLUGINS_DYNAMIC) # The list from CC is visible for us SET(PLUGINS_LIST ${PLUGINS_DYNAMIC}) ELSE() SET(PLUGINS_LIST ${OWN_PLUGINS_LIST}) ENDIF() FOREACH(CC_PLUGIN ${PLUGINS_LIST}) IF(NOT PLUGINS_DYNAMIC OR "${PLUGIN_${CC_PLUGIN}_TYPE}" STREQUAL "MARIADB_CLIENT_PLUGIN_AUTH") MESSAGE(STATUS "Configuring to install ${CC_PLUGIN} to ${INSTALL_PLUGINDIR}") ADD_DEPENDENCIES(DEPENDENCIES_FOR_PACKAGE ${CC_PLUGIN}) INSTALL(FILES $ DESTINATION ${INSTALL_PLUGINDIR} COMPONENT ConCPlugins) ENDIF() ENDFOREACH() ENDIF() ENDIF() ELSE() # Adding mariadb subdirs of standard include locations INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} "/usr/include/mariadb") INCLUDE_DIRECTORIES("/usr/local/include/mariadb") MESSAGE(STATUS "Linking against libmariadb installed on the system") ENDIF() IF(WITH_SIGNCODE) IF(WIN32 AND NOT SIGN_OPTIONS) SET(SIGN_OPTIONS /a /t http://timestamp.verisign.com/scripts/timstamp.dll) ELSE() SEPARATE_ARGUMENTS(SIGN_OPTIONS) ENDIF() MARK_AS_ADVANCED(SIGN_OPTIONS) ENDIF() #Debug log is controlled by connection option solely ADD_DEFINITIONS(-DMAODBC_DEBUG) IF(WIN32) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/dsn) SET(ODBC_LIBS odbc32) SET(ODBC_INSTLIBS odbccp32) SET(PLATFORM_DEPENDENCIES ws2_32 Shlwapi Pathcch) IF (MSVC) MESSAGE(STATUS "MSVC_VERSION= ${MSVC_VERSION}") IF (NOT(MSVC_VERSION LESS 1900)) MESSAGE(STATUS "Configuring to link connector against legacy_stdio_definitions") SET(LEGACY_STDIO legacy_stdio_definitions) SET(PLATFORM_DEPENDENCIES ${PLATFORM_DEPENDENCIES} ${LEGACY_STDIO}) ENDIF() ENDIF() ELSE() SEARCH_LIBRARY(LIB_MATH floor m) SET(PLATFORM_DEPENDENCIES ${PLATFORM_DEPENDENCIES} ${LIB_MATH}) ENDIF() IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "RelWithDebInfo") ENDIF() IF(NOT WIN32) # Looking for DM(UnixODBC) files INCLUDE(FindDM) IF(DM_FOUND) INCLUDE_DIRECTORIES(${ODBC_INCLUDE_DIR}) LINK_DIRECTORIES(${ODBC_LIB_DIR}) ELSE() MESSAGE(FATAL_ERROR "Driver Manager was not found") ENDIF() ENDIF() IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES AIX) IF(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 20) SET(ICONV_LIBRARIES "-liconv") SET(PLATFORM_DEPENDENCIES ${PLATFORM_DEPENDENCIES} ${ICONV_LIBRARIES}) ELSE() # Looking for iconv files INCLUDE(FindIconv) IF(ICONV_FOUND) INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR}) SET(PLATFORM_DEPENDENCIES ${PLATFORM_DEPENDENCIES} ${ICONV_LIBRARIES}) ELSE() MESSAGE(FATAL_ERROR "iconv was not found") ENDIF() ENDIF() ENDIF() INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) # By now we have everything needed by tests. If we need to build them only - firing config now and exit # There is "normal" tests config below IF(BUILD_TESTS_ONLY) ADD_SUBDIRECTORY(test) IF(NOT WIN32) # Configuring ini files for testing with UnixODBC MESSAGE(STATUS "Configurig Test Driver: ${TEST_DRIVER}, Test DSN: ${TEST_DSN}, tcp://${TEST_UID}@${TEST_SERVER}:${TEST_PORT}/${TEST_SCHEMA} socket: ${TEST_SOCKET}") # Should it really libmaodbc_prefix be here? SET(DRIVER_LIB_LOCATION "${libmaodbc_prefix}/${INSTALL_LIBDIR}") CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/test/odbcinst.ini.in ${CMAKE_BINARY_DIR}/test/odbcinst.ini) SET(TEST_DRIVER "${DRIVER_LIB_LOCATION}") CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/test/odbc.ini.in ${CMAKE_BINARY_DIR}/test/odbc.ini) ENDIF() RETURN() ENDIF() # We need to determine the last parameter for SQLColAttribute: # Older UnixODBC version expect SQLPOINTER while Windows expects SQLLEN * # Windows DM uses SQLPOINTER form 32b, but SQLLEN* for 64b, which is... nice :-\ TRY_COMPILE(COMPILE_OK ${CMAKE_BINARY_DIR} SOURCES ${CMAKE_SOURCE_DIR}/cmake/sqlcolattribute.c OUTPUT_VARIABLE TRYCOMPILEOUTPUT) IF (WIN32) STRING(FIND "${TRYCOMPILEOUTPUT}" "warning C4028: formal parameter 7 different from declaration" WARNINGFOUND) IF (NOT WARNINGFOUND EQUAL -1) SET(COMPILE_OK FALSE) ENDIF() ENDIF() MESSAGE(STATUS "Checking if SQLColAttribute expects SQLPOINTER ${COMPILE_OK}") #MESSAGE(STATUS "${TRYCOMPILEOUTPUT} ${WARNINGFOUND}") IF(COMPILE_OK) ADD_DEFINITIONS(-DSQLCOLATTRIB_SQLPOINTER) ELSE() ADD_DEFINITIONS(-DSQLCOLATTRIB_SQLLEN_PTR) ENDIF() IF(WIN32) SET(UNICODE "W") ELSE() IF (DIRECT_LINK_TESTS) ADD_DEFINITIONS(-DHAVE_UNICODE) ENDIF() ENDIF() SET(LIBRARY_NAME "maodbc") ADD_SUBDIRECTORY(driver) ADD_SUBDIRECTORY(include) ####### MAODBCS ####### ADD_SUBDIRECTORY(dsn) ADD_SUBDIRECTORY("dsn_test") # "set/append array" - append a set of strings, separated by a space MACRO(SETA var) FOREACH(v ${ARGN}) SET(${var} "${${var}} ${v}") ENDFOREACH() ENDMACRO(SETA) IF(WIN32) IF(WITH_MSI) ADD_SUBDIRECTORY(packaging/windows) ELSE() MESSAGE(STATUS "MSI package won't be generated - WITH_MSI=${WITH_MSI}") ENDIF() ADD_EXECUTABLE(install_driver packaging/macos/install_driver.c) TARGET_LINK_LIBRARIES(install_driver ${PLATFORM_DEPENDENCIES} ${ODBC_INSTLIBS}) ELSE() IF(APPLE) MESSAGE(STATUS "Configuring to generate PKG package") ADD_SUBDIRECTORY(packaging/macos) ELSE() CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libmaodbc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libmaodbc.pc @ONLY) # RPM adds dependency on pkg-config, that we do not want. With later versions of cmake looks like we can deal with that MESSAGE(STATUS "Configuring to install libmaodbc.pc") INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmaodbc.pc DESTINATION "${INSTALL_PCDIR}" COMPONENT Development) # Not doing this with MacOS(iOdbc). So far, at least CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/packaging/linux/maodbc.ini.in ${CMAKE_BINARY_DIR}/packaging/linux/maodbc.ini @ONLY) INSTALL(FILES ${CMAKE_BINARY_DIR}/packaging/linux/maodbc.ini DESTINATION "${INSTALL_DOCDIR}" COMPONENT Documentation) IF(RPM OR DEB) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/packaging/linux/postinstall.in ${CMAKE_BINARY_DIR}/packaging/linux/postinstall @ONLY) ENDIF() ENDIF() INSTALL(FILES ${CMAKE_SOURCE_DIR}/README DESTINATION "${INSTALL_DOCDIR}" COMPONENT Documentation) INSTALL(FILES ${CMAKE_SOURCE_DIR}/COPYING DESTINATION "${INSTALL_LICENSEDIR}" COMPONENT Documentation) ENDIF() # Tests. Checking if we have them. May be not the case if we are building from source package IF(EXISTS "${CMAKE_SOURCE_DIR}/test/CMakeLists.txt") IF(WITH_UNIT_TESTS) ADD_SUBDIRECTORY(test) #!!! Creation of ini files for testing is configured in the driver's cmake, as that is custom command for that target ENDIF() ENDIF() # Packaging INCLUDE(packaging) MESSAGE(STATUS "License File: ${CPACK_RESOURCE_FILE_LICENSE}") MESSAGE(STATUS "ReadMe File: ${CPACK_PACKAGE_DESCRIPTION_FILE}") MESSAGE(STATUS "Source Package Filename: ${CPACK_SOURCE_PACKAGE_FILE_NAME}.${CPACK_SOURCE_GENERATOR}") mariadb-connector-odbc-3.2.6/COPYING000066400000000000000000000636421501554462200170700ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! mariadb-connector-odbc-3.2.6/README000066400000000000000000000004431501554462200167030ustar00rootroot00000000000000MariaDB Connector/ODBC 3.2 GA This is a GA release of the MariaDB Connector/ODBC. MariaDB Connector/ODBC is released under version 2.1 of the GNU Lesser Public License. License information can be found in the COPYING file. To report issues: https://jira.mariadb.org/projects/ODBC/issues/ mariadb-connector-odbc-3.2.6/README.md000066400000000000000000000017751501554462200173130ustar00rootroot00000000000000# MariaDB Connector/ODBC 3.2

## Status [![License (LGPL version 2.1)](https://img.shields.io/badge/license-GNU%20LGPL%20version%202.1-green.svg?style=flat-square)](http://opensource.org/licenses/LGPL-2.1) [![Linux Build](https://app.travis-ci.com/mariadb-corporation/mariadb-connector-odbc.svg?branch=master)](https://app.travis-ci.com/github/mariadb-corporation/mariadb-connector-odbc/) This is a GA release of the MariaDB Connector/ODBC. MariaDB Connector/ODBC is released under version 2.1 of the GNU Lesser Public License. License information can be found in the COPYING file. Tracker link https://jira.mariadb.org/projects/ODBC/issues/ ## Documentation For a Getting started guide, API docs, recipes, etc. see the [About MariaDB connector/ODBC](https://mariadb.com/kb/en/mariadb/about-mariadb-connector-odbc/) mariadb-connector-odbc-3.2.6/appveyor-download.bat000066400000000000000000000006751501554462200221740ustar00rootroot00000000000000@echo off set archive=http://ftp.hosteurope.de/mirror/archive.mariadb.org//mariadb-%DB%/winx64-packages/mariadb-%DB%-winx64.msi set last=http://mirror.i3d.net/pub/mariadb//mariadb-%DB%/winx64-packages/mariadb-%DB%-winx64.msi curl -fLsS -o server.msi %archive% if %ERRORLEVEL% == 0 goto end curl -fLsS -o server.msi %last% if %ERRORLEVEL% == 0 goto end echo Failure Reason Given is %errorlevel% exit /b %errorlevel% :end echo "File found". mariadb-connector-odbc-3.2.6/appveyor.yml000066400000000000000000000071171501554462200204200ustar00rootroot00000000000000environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 DB: 10.11.7 CMAKE_PARAM_G: 'Visual Studio 17 2022' # scripts that are called at very beginning, before repo cloning init: - git config --global core.autocrlf input - wmic cpu get NumberOfCores - wmic ComputerSystem get TotalPhysicalMemory clone_folder: c:\maodbc platform: x64 configuration: Release build_script: # build libmariadb separately first because otherwise the Wix installer build might look for files that aren't available yet - cd libmariadb - cmake --build . --config RelWithDebInfo --parallel 2 # build odbc - cd .. - cmake --build . --config RelWithDebInfo --parallel 2 # scripts to run before build before_build: - cd c:\maodbc - git submodule init - git submodule update - rm -rf win64 - mkdir win64 - cd win64 - cmake .. -G "%CMAKE_PARAM_G%" -DCONC_WITH_MSI=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SIGNCODE=0 -DWITH_SSL=SCHANNEL after_build: # download and install MariaDB Server - cmd: appveyor-download.bat - msiexec /i server.msi INSTALLDIR=c:\mariadb-server SERVICENAME=mariadb /qn # create test database - c:\mariadb-server\bin\mysql.exe -e "CREATE DATABASE odbc_test" --user=root # install built odbc driver - ps: $msifile = Get-ChildItem $env:APPVEYOR_BUILD_FOLDER\win64\wininstall\mariadb-connector-odbc*.msi | Select-Object -First 1 - ps: Push-AppveyorArtifact $msifile.FullName -FileName $msifile.Name - ps: Write $msifile - ps: msiexec /i $msifile INSTALLDIR=c:\mariadb-odbc /qn # add ODBC DSN with the built driver # notice that it isn't possible to currently use Add-OdbcDsn in PowerShell. It will give an error because of missing properties. Therefore the # DSN is added to registry below. #- ps: Add-OdbcDsn -Name "test" -DriverName "MariaDB ODBC 3.1 Driver" -DsnType "System" -SetPropertyValue @("Server=localhost", "PORT=3306", "Database=odbc_test") - ps: New-Item -Path "HKCU:\Software\ODBC" - ps: New-Item -Path "HKCU:\Software\ODBC\ODBC.INI" - ps: $regPath = "HKCU:\Software\ODBC\ODBC.INI\test" - ps: New-Item -Path $regPath - ps: New-ItemProperty -Path $regPath -Name "CONN_TIMEOUT" -Value "0" - ps: New-ItemProperty -Path $regPath -Name "DATABASE" -Value "odbc_test" - ps: New-ItemProperty -Path $regPath -Name "DESCRIPTION" -Value "MariaDB ODBC test" - ps: New-ItemProperty -Path $regPath -Name "Driver" -Value "MariaDB ODBC 3.1 Driver" - ps: New-ItemProperty -Path $regPath -Name "OPTIONS" -Value "0" - ps: New-ItemProperty -Path $regPath -Name "PORT" -Value "0" - ps: New-ItemProperty -Path $regPath -Name "PWD" -Value "" - ps: New-ItemProperty -Path $regPath -Name "SERVER" -Value "localhost" - ps: New-ItemProperty -Path $regPath -Name "SSLVERIFY" -Value "0" - ps: New-ItemProperty -Path $regPath -Name "TCPIP" -Value "1" - ps: New-ItemProperty -Path $regPath -Name "UID" -Value "root" - ps: New-Item -Path "HKCU:\Software\ODBC\ODBC.INI\ODBC Data Sources" - ps: New-ItemProperty -Path "HKCU:\Software\ODBC\ODBC.INI\ODBC Data Sources" -Name "test" -Value "MariaDB ODBC 3.1 Driver" - timeout /T 1 # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - cd test - ctest -V on_finish: # - dir # - dir RelWithDebInfo # - dir wininstall # - dir libmariadb\RelWithDebInfo # - dir release # - dir libmariadb # - dir libmariadb\release # - dir wininstall # - type wininstall\mariadb_odbc.xml mariadb-connector-odbc-3.2.6/azure-pipelines.yml000066400000000000000000000261111501554462200216620ustar00rootroot00000000000000resources: containers: - container: ubuntu-1804 image: ubuntu:18.04 options: "--name ubuntu-1804 --add-host=mariadb.example.com:127.0.0.1 -v /usr/bin/docker:/tmp/docker:ro" jobs: - job: SSLFiles displayName: 'Creating SSL Files' pool: vmImage: 'ubuntu-16.04' container: $[ variables['containerImage'] ] steps: - script: | java --version mkdir tmp chmod 777 .travis/gen-ssl.sh .travis/gen-ssl.sh mariadb.example.com tmp cp -R tmp $BUILD_ARTIFACTSTAGINGDIRECTORY displayName: 'create SSL certificates' - task: PublishPipelineArtifact@0 inputs: targetPath: '$(Build.ArtifactStagingDirectory)' artifactName: ssl_certs - job: windowsTest displayName: 'test windows' pool: vmImage: 'windows-2019' dependsOn: - SSLFiles steps: - task: DownloadPipelineArtifact@2 displayName: 'Download SSL files' inputs: artifactName: ssl_certs targetPath: $(System.DefaultWorkingDirectory) - task: DownloadPipelineArtifact@2 displayName: 'Download 10.4 server' inputs: buildType: 'specific' project: '550599d3-6165-4abd-8c86-e3f7e53a1847' definition: '3' buildVersionToDownload: 'latestFromBranch' branchName: 'refs/heads/10.4-enterprise' artifactName: 'Windows-Release' targetPath: '$(System.DefaultWorkingDirectory)' - script: | for /f %%a in ('dir /B $(System.DefaultWorkingDirectory)\win_build\mariadb-enterprise-10.*-winx64.msi') do set servername=$(System.DefaultWorkingDirectory)\win_build\%%a echo %servername% msiexec /i %servername% INSTALLDIR=c:\projects\server SERVICENAME=mariadb ALLOWREMOTEROOTACCESS=true /qn c:\projects\server\bin\mysql.exe -e "create database testo" --user=root c:\projects\server\bin\mysql.exe -e "GRANT ALL on *.* to 'someUser'@'%' identified by 'Passw@rd2' with grant option;" --user=root displayName: 'install server' - script: | echo 127.0.0.1 mariadb.example.com >> %WINDIR%\System32\Drivers\Etc\Hosts displayName: 'set hostname' - script: | git submodule init git submodule update displayName: 'update submodule' - script: | cd libmariadb cmake -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build . --config RelWithDebInfo cd .. cmake -G "Visual Studio 16 2019" -DCONC_WITH_MSI=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SIGNCODE=0 -DWITH_SSL=SCHANNEL -DWITH_OPENSSL=OFF cmake --build . --config RelWithDebInfo displayName: 'build connector' - task: CopyFiles@2 inputs: contents: 'wininstall/**.msi' targetFolder: $(Build.ArtifactStagingDirectory) - task: PublishPipelineArtifact@1 inputs: targetPath: '$(Build.ArtifactStagingDirectory)' artifactName: msi_package - task: PowerShell@2 inputs: targetType: inline script: | New-Item -Path "HKCU:\Software\ODBC" New-Item -Path "HKCU:\Software\ODBC\ODBC.INI" $regPath = "HKCU:\Software\ODBC\ODBC.INI\test" New-Item -Path $regPath New-ItemProperty -Path $regPath -Name "CONN_TIMEOUT" -Value "0" New-ItemProperty -Path $regPath -Name "DATABASE" -Value "test" New-ItemProperty -Path $regPath -Name "DESCRIPTION" -Value "MariaDB ODBC test" New-ItemProperty -Path $regPath -Name "Driver" -Value "MariaDB ODBC 3.1 Driver" New-ItemProperty -Path $regPath -Name "OPTIONS" -Value "0" New-ItemProperty -Path $regPath -Name "PORT" -Value "3306" New-ItemProperty -Path $regPath -Name "PWD" -Value "Passw@rd2" New-ItemProperty -Path $regPath -Name "SERVER" -Value "mariadb.example.com" New-ItemProperty -Path $regPath -Name "SSLVERIFY" -Value "0" New-ItemProperty -Path $regPath -Name "TCPIP" -Value "1" New-ItemProperty -Path $regPath -Name "UID" -Value "someUser" New-Item -Path "HKCU:\Software\ODBC\ODBC.INI\ODBC Data Sources" New-ItemProperty -Path "HKCU:\Software\ODBC\ODBC.INI\ODBC Data Sources" -Name "test" -Value "MariaDB ODBC 3.1 Driver" displayName: 'set registry' - task: PowerShell@2 inputs: targetType: inline script: | $msifile = Get-ChildItem $env:$(System.DefaultWorkingDirectory)\wininstall\mariadb-connector-odbc*.msi | Select-Object -First 1 Write $msifile msiexec /i $msifile.fullname INSTALLDIR=c:\mariadb-odbc /qn displayName: 'install odbc' - script: | set MARIADB_PLUGIN_DIR=$(System.DefaultWorkingDirectory)\libmariadb\plugins\lib\RelWithDebInfo SET TEST_SCHEMA=test timeout /T 1 cd test ctest -V if %ERRORLEVEL% EQU 0 ( echo Success ) else ( echo exit code is %errorlevel% exit /b %errorlevel% ) displayName: 'run tests' - job: RunInContainer pool: vmImage: 'ubuntu-16.04' displayName: 'test ubuntu bionic' dependsOn: - SSLFiles strategy: matrix: ubuntu-1804: containerImage: ubuntu-1804 containerName: bionic container: $[variables['containerImage']] steps: - task: DownloadPipelineArtifact@2 inputs: artifactName: ssl_certs targetPath: $(System.DefaultWorkingDirectory) - script: /tmp/docker exec -t -u 0 $(containerImage) sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y install sudo" displayName: Set up sudo - task: DownloadPipelineArtifact@2 displayName: 'Download 10.4 enterprise server artifact files' inputs: source: 'specific' project: '550599d3-6165-4abd-8c86-e3f7e53a1847' artifact: '$(containerImage)' runVersion: 'latestFromBranch' runBranch: 'refs/heads/10.4-enterprise' downloadPath: $(System.DefaultWorkingDirectory) - task: DownloadPipelineArtifact@2 displayName: 'Download galera server artifact files' inputs: source: 'specific' project: '550599d3-6165-4abd-8c86-e3f7e53a1847' artifact: $(containerImage) runVersion: 'latestFromBranch' runBranch: 'refs/heads/es-mariadb-4.x' downloadPath: $(System.DefaultWorkingDirectory) - script: | tar xf mariadb-enterprise* sudo ln -fs /usr/share/zoneinfo/UTC /etc/localtime sudo apt-get update && sudo apt-get install -y --no-install-recommends apt-transport-https ca-certificates tzdata pwgen export DEBIAN_FRONTEND="noninteractive" sudo debconf-set-selections <<< "mariadb-server-10.4 mysql-server/root_password password P4ssw@rd" sudo debconf-set-selections <<< "mariadb-server-10.4 mysql-server/root_password_again password P4ssw@rd" sudo apt-get update -y sudo apt-get install --allow-unauthenticated -f -y git libssl-dev libaio1 libaio-dev libxml2 libcurl4 curl libc-dev linux-libc-dev libc-dev-bin libdbi-perl rsync socat libnuma1 zlib1g-dev libreadline5 libjemalloc1 libsnappy1v5 libcrack2 gawk lsof psmisc perl libreadline5 sudo apt-get install --allow-unauthenticated -y --force-yes -m unixodbc-dev cd mariadb-enterprise*/ sudo groupadd mysql sudo useradd -g mysql mysql export PROJ_PATH=`pwd` echo $PROJ_PATH cat <> my.cnf [mysqld] port=3306 max_allowed_packet=16M datadir=$PROJ_PATH/data socket=/tmp/mysql.sock user=mysql ssl-ca=$(System.DefaultWorkingDirectory)/tmp/ca.crt ssl-cert=$(System.DefaultWorkingDirectory)/tmp/server.crt ssl-key=$(System.DefaultWorkingDirectory)/tmp/server.key EOT sudo chown mysql $PROJ_PATH/my.cnf sudo tail -n 5000 $PROJ_PATH/my.cnf sudo chmod 777 $PROJ_PATH sudo ln -s $PROJ_PATH /usr/local/mysql sudo ./scripts/mysql_install_db --defaults-file=$PROJ_PATH/my.cnf --user=mysql sudo chown -R root . sudo chown -R mysql data export PATH=$PATH:$PROJ_PATH/bin/ env: WORKING_DIR: $(System.DefaultWorkingDirectory) displayName: 'install server' - script: | git submodule init git submodule update displayName: 'update submodule' - script: | sudo apt-get install -f -y make cmake #cd libmariadb #cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SSL=OPENSSL -DCERT_PATH=$(System.DefaultWorkingDirectory)/tmp #make #cd .. export TEST_SCHEMA=testo export TEST_DRIVER=maodbc_test export TEST_DSN=maodbc_test export TEST_SERVER=mariadb.example.com export TEST_UID=someUser export TEST_PASSWORD=Passw@rd2 cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_OPENSSL=ON -DWITH_SSL=OPENSSL . cmake --build . --config RelWithDebInfo displayName: 'Build' - script: | cd mariadb-enterprise*/ sudo ./bin/mysqld --defaults-file=./my.cnf & for i in {30..0}; do if sudo ./bin/mysql -e "SELECT 1" &> /dev/null; then echo 'MySQL connected...' break fi echo 'MySQL init process in progress...' sleep 1 done if [ "$i" = 0 ]; then echo >&2 'MySQL init process failed.' sudo ./bin/mysql -e "SELECT 1" exit 1 fi sudo ./bin/mysql -e "CREATE USER 'someUser'@'%' identified by 'Passw@rd2';" sudo ./bin/mysql -e "GRANT ALL on *.* to 'someUser'@'%' identified by 'Passw@rd2' with grant option;" sudo ./bin/mysql -e "CREATE DATABASE testo;" echo "Running tests" cd ../test export ODBCINI="$(System.DefaultWorkingDirectory)/test/odbc.ini" export ODBCSYSINI=$(System.DefaultWorkingDirectory)/test cat $ODBCINI cat $ODBCSYSINI/odbcinst.ini ctest -V if [ $? -ne 0 ]; then exit 1 fi cd $(System.DefaultWorkingDirectory)/mariadb-enterprise*/ sudo ./bin/mysqladmin shutdown env: TEST_DRIVER: maodbc_test TEST_DSN: maodbc_test TEST_SERVER: mariadb.example.com TEST_SOCKET: TEST_SCHEMA: testo TEST_UID: someUser TEST_PASSWORD: Passw@rd2 TEST_SSL_CA_FILE: "$(System.DefaultWorkingDirectory)/tmp/server.crt" TEST_SSL_CLIENT_KEY_FILE: "$(System.DefaultWorkingDirectory)/tmp/client.key" TEST_SSL_CLIENT_CERT_FILE: "$(System.DefaultWorkingDirectory)/tmp/client.crt" TEST_SSL_CLIENT_KEYSTORE_FILE: "$(System.DefaultWorkingDirectory)/tmp/client-keystore.p12" displayName: 'run tests' mariadb-connector-odbc-3.2.6/class/000077500000000000000000000000001501554462200171275ustar00rootroot00000000000000mariadb-connector-odbc-3.2.6/class/lru/000077500000000000000000000000001501554462200177315ustar00rootroot00000000000000mariadb-connector-odbc-3.2.6/class/lru/lrucache.h000066400000000000000000000066631501554462200217030ustar00rootroot00000000000000/************************************************************************************ Copyright (C) 2023 MariaDB Corporation plc This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not see or write to the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor, Boston, MA 02110, USA *************************************************************************************/ #ifndef _LRUCACHE_H_ #define _LRUCACHE_H_ #include #include #include namespace mariadb { template struct Cache { virtual ~Cache() {} virtual VT* put(const KT& key, VT* obj2cache) {return nullptr;} virtual VT* get(const KT& key) {return nullptr;} virtual void clear() {} }; template struct DefaultRemover { void operator()(T* removedCacheEntry) { delete removedCacheEntry; } }; // This does not care about the fate of obbjects removed from cache template > class LruCache : public Cache { std::mutex lock; typedef std::list> ListType; typedef typename ListType::iterator ListIterator; std::size_t maxSize; ListType lu; std::unordered_map cache; protected: virtual void remove(ListIterator& it) { Remover()(it->second); cache.erase(it->first); } virtual ListIterator removeEldestEntry() { auto victim= lu.end(); --victim; remove(victim); lu.splice(lu.begin(), lu, victim); return victim; } public: virtual ~LruCache() {} LruCache(std::size_t maxCacheSize) : maxSize(maxCacheSize) { cache.reserve(maxSize); } virtual VT* put(const KT& key, VT* obj2cache) { std::lock_guard localScopeLock(lock); auto cached= cache.find(key); if (cached != cache.end()) { return cached->second->second; } ListIterator it; if (cache.size() == maxSize) { it= removeEldestEntry(); it->first= key; it->second= obj2cache; } else { lu.emplace_front(key, obj2cache); it= lu.begin(); } cache.emplace(key, it); return nullptr; } virtual VT* get(const KT& key) { std::lock_guard localScopeLock(lock); auto cached= cache.find(key); if (cached != cache.end()) { lu.splice(lu.begin(), lu, cached->second); return cached->second->second; } return nullptr; } virtual void clear() { std::lock_guard localScopeLock(lock); cache.clear(); for (auto it= lu.begin(); it != lu.end();++it) { if (it->second != nullptr) { Remover()(it->second); } } lu.clear(); } }; } #endif mariadb-connector-odbc-3.2.6/class/lru/pscache.h000066400000000000000000000045251501554462200215160ustar00rootroot00000000000000/************************************************************************************ Copyright (C) 2023 MariaDB Corporation plc This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not see or write to the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor, Boston, MA 02110, USA *************************************************************************************/ #ifndef _PSCACHE_H_ #define _PSCACHE_H_ #include #include "lrucache.h" namespace mariadb { template struct PsRemover { // std::mutex lock; void operator()(T* removedCacheEntry) { if (removedCacheEntry->canBeDeallocate()) { delete removedCacheEntry; } else { removedCacheEntry->decrementShareCounter(); } } }; template class PsCache : public LruCache> { typedef LruCache> parentLru; std::size_t maxKeyLen; public: virtual ~PsCache() { } PsCache(std::size_t maxCacheSize, std::size_t _maxKeyLen= static_cast(-1)) : parentLru(maxCacheSize) , maxKeyLen(_maxKeyLen) { } virtual VT* put(const std::string& key, VT* obj2cache) { if (key.length() > maxKeyLen) { return nullptr; } VT* hadCached= this->parentLru::put(key, obj2cache); if (hadCached == nullptr) { // Putting to cache creates additional reference obj2cache->incrementShareCounter(); } return hadCached; } virtual VT* get(const std::string& key) { auto result= this->parentLru::get(key); if (result != nullptr) { result->incrementShareCounter(); } return result; } }; } #endif mariadb-connector-odbc-3.2.6/cmake/000077500000000000000000000000001501554462200171025ustar00rootroot00000000000000mariadb-connector-odbc-3.2.6/cmake/COPYING-CMAKE-SCRIPTS000066400000000000000000000024571501554462200221100ustar00rootroot00000000000000Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. mariadb-connector-odbc-3.2.6/cmake/ConfigureFile.cmake000066400000000000000000000000551501554462200226250ustar00rootroot00000000000000CONFIGURE_FILE(${FILE_IN} ${FILE_OUT} @ONLY) mariadb-connector-odbc-3.2.6/cmake/ConnectorName.cmake000066400000000000000000000025641501554462200226460ustar00rootroot00000000000000# # Copyright (C) 2013-2022 MariaDB Corporation AB # # Redistribution and use is allowed according to the terms of the New # BSD license. # For details see the COPYING-CMAKE-SCRIPTS file. # MACRO(GET_CONNECTOR_PACKAGE_NAME name base_name) # check if we have 64bit IF(SIZEOF_VOIDP EQUAL 8) SET(IS64 1) ENDIF() SET (PLATFORM_NAME ${SYSTEM_NAME}) SET (MACHINE_NAME ${CMAKE_SYSTEM_PROCESSOR}) SET (CONCAT_SIGN "-") IF(CMAKE_SYSTEM_NAME MATCHES "Windows") SET(PLATFORM_NAME "win") SET(CONCAT_SIGN "") IF(IS64) IF(CMAKE_C_COMPILER_ARCHITECTURE_ID) STRING(TOLOWER "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MACHINE_NAME) ELSE() SET(MACHINE_NAME x64) ENDIF() ELSE() SET(MACHINE_NAME "32") ENDIF() ENDIF() # Get revision number IF(WITH_REVNO) EXECUTE_PROCESS(COMMAND git log -n 1 --pretty="%h" OUTPUT_VARIABLE revno) STRING(REPLACE "\n" "" revno ${revno}) ENDIF() IF(${revno}) SET(product_name "${base_name}-${CPACK_PACKAGE_VERSION}-r${revno}-${PLATFORM_NAME}${CONCAT_SIGN}${MACHINE_NAME}") ELSE() IF(PACKAGE_PLATFORM_SUFFIX) SET(product_name "${base_name}-${CPACK_PACKAGE_VERSION}${QUALITY_SUFFIX}-${PACKAGE_PLATFORM_SUFFIX}") ELSE() SET(product_name "${base_name}-${CPACK_PACKAGE_VERSION}${QUALITY_SUFFIX}-${PLATFORM_NAME}${CONCAT_SIGN}${MACHINE_NAME}") ENDIF() ENDIF() STRING(TOLOWER ${product_name} ${name}) ENDMACRO() mariadb-connector-odbc-3.2.6/cmake/FindDM.cmake000077500000000000000000000117731501554462200212210ustar00rootroot00000000000000# Copyright (C) 2015,2020 MariaDB Corporation AB # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not see # or write to the Free Software Foundation, Inc., # 51 Franklin St., Fifth Floor, Boston, MA 02110, USA # FindDM.cmake # # Cmake script to look for driver manager includes and libraries on platforms others than Windows # We expect that the driver manager is UnixODBC IF(WITH_IODBC) SET(ODBC_CONFIG_EXEC iodbc-config) SET(ODBC_CONFIG_INCLUDES --cflags) SET(ODBC_CONFIG_LIBS --libs) SET(ODBC_LIBS iodbc) SET(ODBC_INSTLIBS iodbcinst) ELSE() #UnixODBC SET(ODBC_CONFIG_EXEC odbc_config) SET(ODBC_CONFIG_INCLUDES --include-prefix) SET(ODBC_CONFIG_LIBS --lib-prefix) SET(ODBC_LIBS odbc) SET(ODBC_INSTLIBS odbcinst) ENDIF() IF(ODBC_LIB_DIR AND ODBC_INCLUDE_DIR) MESSAGE(STATUS "Using preset values for DM dirs") ELSE() FIND_PROGRAM(ODBC_CONFIG ${ODBC_CONFIG_EXEC} PATH /usr/bin ${DM_DIR} "${DM_DIR}/bin" ) IF(ODBC_CONFIG) MESSAGE(STATUS "Found ${ODBC_CONFIG_EXEC}: ${ODBC_CONFIG}") EXECUTE_PROCESS(COMMAND ${ODBC_CONFIG} ${ODBC_CONFIG_INCLUDES} OUTPUT_VARIABLE result) STRING(REPLACE "\n" "" ODBC_INCLUDE_DIR ${result}) EXECUTE_PROCESS(COMMAND ${ODBC_CONFIG} ${ODBC_CONFIG_LIBS} OUTPUT_VARIABLE result) STRING(REPLACE "\n" "" ODBC_LIB_DIR ${result}) IF(WITH_IODBC) STRING(REPLACE "-I" "" ODBC_INCLUDE_DIR ${ODBC_INCLUDE_DIR}) STRING(REPLACE "-L" "" ODBC_LIB_DIR ${ODBC_LIB_DIR}) STRING(REGEX REPLACE " +-liodbc -liodbcinst" "" ODBC_LIB_DIR ${ODBC_LIB_DIR}) ENDIF() ELSE() MESSAGE(STATUS "${ODBC_CONFIG_EXEC} is not found ") # Try to find the include directory, giving precedence to special variables SET(LIB_PATHS /usr/local /usr /usr/local/Cellar/libiodbc/3.52.12 /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}) SET(LIB_SUFFIX "${CMAKE_LIBRARY_ARCHITECTURE}") IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") SET(LIB_PATHS "${LIB_PATHS}" "/usr/lib/x86_64-linux-gnu") IF(EXISTS "/usr/lib64/") SET(LIB_PATHS "${LIB_PATHS}" "/usr/lib64") SET(LIB_SUFFIX "${LIB_SUFFIX}" "lib64" "x86_64-linux-gnu") ELSE() SET(LIB_PATHS "${LIB_PATHS}" "/usr/lib") SET(LIB_SUFFIX "${LIB_SUFFIX}" "lib" "x86_64-linux-gnu") ENDIF() ELSE() SET(LIB_PATHS "${LIB_PATHS}" "/usr/local/lib/i386-linux-gnu" "/usr/lib/i386-linux-gnu" "/usr/local/lib/i686-linux-gnu" "/usr/lib/i686-linux-gnu") SET(LIB_SUFFIX "${LIB_SUFFIX}" "lib" "i386-linux-gnu" "i686-linux-gnu") ENDIF() FIND_PATH(ODBC_INCLUDE_DIR sql.h HINTS ${DM_INCLUDE_DIR} ${DM_DIR} ENV DM_INCLUDE_DIR ENV DM_DIR PATHS /usr/local /usr /usr/local/Cellar/libiodbc/3.52.12 PATH_SUFFIXES include include/iodbc NO_DEFAULT_PATH DOC "Driver Manager Includes") # Giving chance to cmake_(environment)path FIND_PATH(ODBC_INCLUDE_DIR sql.h DOC "Driver Manager Includes") IF(ODBC_INCLUDE_DIR) MESSAGE(STATUS "Found ODBC Driver Manager includes: ${ODBC_INCLUDE_DIR}") ENDIF() # Try to find DM libraries, giving precedence to special variables FIND_PATH(ODBC_LIB_DIR "lib${ODBC_LIBS}.so" HINTS ${DM_LIB_DIR} ${DM_DIR} ENV DM_LIB_DIR ENV DM_DIR PATHS ${LIB_PATHS} PATH_SUFFIXES ${LIB_SUFFIX} NO_DEFAULT_PATH DOC "Driver Manager Libraries") FIND_PATH(ODBC_LIB_DIR "lib${ODBC_LIBS}.so" DOC "Driver Manager Libraries") FIND_PATH(ODBCINST_LIB_DIR "lib${ODBC_INSTLIBS}.so" HINTS ${DM_LIB_DIR} ${DM_DIR} ENV DM_LIB_DIR ENV DM_DIR PATHS ${LIB_PATHS} PATH_SUFFIXES ${LIB_SUFFIX} NO_DEFAULT_PATH DOC "Driver Manager Libraries") FIND_PATH(ODBCINST_LIB_DIR "lib${ODBC_INSTLIBS}.so" DOC "Driver Manager Libraries") ENDIF() ENDIF() IF(ODBC_LIB_DIR AND ODBC_INCLUDE_DIR) MESSAGE(STATUS "Found ODBC Driver Manager libraries: ${ODBC_LIB_DIR} ${ODBCINST_LIB_DIR}") # Just to add automatically dependency on package containing DM headers to source RPM FIND_FILE(ODBCHEADER sql.h HINTS ${ODBC_INCLUDE_DIR}) IF(NOT ${ODBCHEADER} STREQUAL "ODBCHEADER-NOTFOUND") MESSAGE(STATUS "Found DM header: ${ODBCHEADER}") ENDIF() SET(DM_FOUND TRUE) ENDIF() mariadb-connector-odbc-3.2.6/cmake/FindIconv.cmake000066400000000000000000000036331501554462200217700ustar00rootroot00000000000000# Copyright (c) 2010 Michael Bell if (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) # Already in cache, be silent set(ICONV_FIND_QUIETLY TRUE) endif (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) IF(APPLE) find_path(ICONV_INCLUDE_DIR iconv.h PATHS /opt/local/include/ /usr/include/ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ NO_CMAKE_SYSTEM_PATH) ELSE() find_path(ICONV_INCLUDE_DIR iconv.h) ENDIF() IF(APPLE) find_library(ICONV_LIBRARIES NAMES iconv libiconv c PATHS /opt/local/lib/ /usr/lib/ NO_CMAKE_SYSTEM_PATH) SET(ICONV_EXTERNAL TRUE) ELSE() find_library(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2) IF(ICONV_LIBRARIES) SET(ICONV_EXTERNAL TRUE) ELSE() find_library(ICONV_LIBRARIES NAMES c) ENDIF() ENDIF() if (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) set (ICONV_FOUND TRUE) endif (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) IF(ICONV_EXTERNAL) set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) ENDIF() if (ICONV_FOUND) include(CheckCSourceCompiles) CHECK_C_SOURCE_COMPILES(" #include int main(){ iconv_t conv = 0; const char* in = 0; size_t ilen = 0; char* out = 0; size_t olen = 0; iconv(conv, &in, &ilen, &out, &olen); return 0; } " ICONV_SECOND_ARGUMENT_IS_CONST ) endif (ICONV_FOUND) set (CMAKE_REQUIRED_INCLUDES) set (CMAKE_REQUIRED_LIBRARIES) if (ICONV_FOUND) if (NOT ICONV_FIND_QUIETLY) message (STATUS "Found Iconv: ${ICONV_LIBRARIES}") endif (NOT ICONV_FIND_QUIETLY) else (ICONV_FOUND) if (Iconv_FIND_REQUIRED) message (FATAL_ERROR "Could not find Iconv") endif (Iconv_FIND_REQUIRED) endif (ICONV_FOUND) MARK_AS_ADVANCED( ICONV_INCLUDE_DIR ICONV_LIBRARIES ICONV_EXTERNAL ICONV_SECOND_ARGUMENT_IS_CONST ) mariadb-connector-odbc-3.2.6/cmake/SearchLibrary.cmake000066400000000000000000000012071501554462200226360ustar00rootroot00000000000000INCLUDE(CheckFunctionExists) INCLUDE(CheckLibraryExists) FUNCTION(SEARCH_LIBRARY library_name function liblist) IF(${${library_name}}) RETURN() ENDIF() CHECK_FUNCTION_EXISTS(${function} ${function}_IS_SYS_FUNC) # check if function is part of libc IF(HAVE_${function}_IS_SYS_FUNC) SET(${library_name} "" PARENT_SCOPE) RETURN() ENDIF() FOREACH(lib ${liblist}) CHECK_LIBRARY_EXISTS(${lib} ${function} "" HAVE_${function}_IN_${lib}) IF(HAVE_${function}_IN_${lib}) SET(${library_name} ${lib} PARENT_SCOPE) SET(HAVE_${library_name} 1 PARENT_SCOPE) RETURN() ENDIF() ENDFOREACH() ENDFUNCTION() mariadb-connector-odbc-3.2.6/cmake/SetValueMacro.cmake000066400000000000000000000005341501554462200226200ustar00rootroot00000000000000# Macro that checks if variable is defined, otherwise checks env for same name, otherwise uses default value MACRO(SET_VALUE _variable _default_value) IF (NOT ${_variable}) IF(DEFINED ENV{${_variable}}) SET(${_variable} $ENV{${_variable}}) ELSE() SET(${_variable} ${_default_value}) ENDIF() ENDIF() ENDMACRO(SET_VALUE) mariadb-connector-odbc-3.2.6/cmake/build_depends.cmake000066400000000000000000000030001501554462200226760ustar00rootroot00000000000000IF(RPM) MACRO(FIND_DEP V) SET(out ${V}_DEP) IF (NOT DEFINED ${out}) IF(EXISTS ${${V}} AND NOT IS_DIRECTORY ${${V}}) EXECUTE_PROCESS(COMMAND ${ARGN} RESULT_VARIABLE res OUTPUT_VARIABLE O OUTPUT_STRIP_TRAILING_WHITESPACE) ELSE() SET(res 1) ENDIF() IF (res) SET(O) ELSE() MESSAGE(STATUS "Need ${O} for ${${V}}") ENDIF() SET(${out} ${O} CACHE INTERNAL "Package that contains ${${V}}" FORCE) ENDIF() ENDMACRO() # FindBoost.cmake doesn't leave any trace, do it here IF (Boost_INCLUDE_DIR) FIND_FILE(Boost_config_hpp boost/config.hpp PATHS ${Boost_INCLUDE_DIR}) ENDIF() GET_CMAKE_PROPERTY(ALL_VARS CACHE_VARIABLES) FOREACH (V ${ALL_VARS}) GET_PROPERTY(H CACHE ${V} PROPERTY HELPSTRING) IF (H MATCHES "^Have library [^/]" AND ${V}) STRING(REGEX REPLACE "^Have library " "" L ${H}) SET(V ${L}_LIBRARY) FIND_LIBRARY(${V} ${L}) ENDIF() GET_PROPERTY(T CACHE ${V} PROPERTY TYPE) IF ((T STREQUAL FILEPATH OR V MATCHES "^CMAKE_COMMAND$") AND ${V} MATCHES "^/") IF (RPM) FIND_DEP(${V} rpm -q --qf "%{NAME}" -f ${${V}}) ELSE() # must be DEB MESSAGE(FATAL_ERROR "Not implemented") ENDIF () SET(BUILD_DEPS ${BUILD_DEPS} ${${V}_DEP}) ENDIF() ENDFOREACH() IF (BUILD_DEPS) SET(BUILD_DEPS "${CPACK_RPM_BUILDREQUIRES}" "${BUILD_DEPS}") LIST(REMOVE_DUPLICATES BUILD_DEPS) STRING(REPLACE ";" " " CPACK_RPM_BUILDREQUIRES "${BUILD_DEPS}") ENDIF() ENDIF(RPM) mariadb-connector-odbc-3.2.6/cmake/check_compiler_flag.cmake000066400000000000000000000116411501554462200240470ustar00rootroot00000000000000include(CheckCSourceCompiles) include(CheckCXXSourceCompiles) # We need some extra FAIL_REGEX patterns # Note that CHECK_C_SOURCE_COMPILES is a misnomer, it will also link. SET(fail_patterns FAIL_REGEX "argument unused during compilation" FAIL_REGEX "unsupported .*option" FAIL_REGEX "unknown .*option" FAIL_REGEX "unrecognized .*option" FAIL_REGEX "ignoring unknown option" FAIL_REGEX "warning:.*ignored" FAIL_REGEX "warning:.*is valid for.*but not for" FAIL_REGEX "warning:.*redefined" FAIL_REGEX "[Ww]arning: [Oo]ption" ) #The regex patterns above are not localized, thus LANG=C SET(ENV{LANG} C) MACRO (MY_CHECK_C_COMPILER_FLAG flag) STRING(REGEX REPLACE "[-,= +]" "_" result "have_C_${flag}") SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${result} ${fail_patterns}) SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}") ENDMACRO() MACRO (MY_CHECK_CXX_COMPILER_FLAG flag) STRING(REGEX REPLACE "[-,= +]" "_" result "have_CXX_${flag}") SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}") CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${result} ${fail_patterns}) SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}") ENDMACRO() FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag_to_set) # At the moment this is gcc-only. # Let's avoid expensive compiler tests on Windows: IF(WIN32) RETURN() ENDIF() STRING(REGEX REPLACE "^-Wno-" "-W" flag_to_check ${flag_to_set}) LIST(FIND MAODBC_LANGUAGES "C" LANGIDX) IF(NOT LANGIDX EQUAL -1) MY_CHECK_C_COMPILER_FLAG(${flag_to_check}) ENDIF() LIST(FIND MAODBC_LANGUAGES "CXX" LANGIDX) IF(NOT LANGIDX EQUAL -1) MY_CHECK_CXX_COMPILER_FLAG(${flag_to_check}) ENDIF() STRING(REGEX REPLACE "[-,= +]" "_" result "${flag_to_check}") MESSAGE(STATUS "Langs: ${MAODBC_LANGUAGES}") FOREACH(lang ${MAODBC_LANGUAGES}) IF (have_${lang}_${result}) IF(ARGN) FOREACH(type ${ARGN}) SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${flag_to_set}" PARENT_SCOPE) ENDFOREACH() ELSE() SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${flag_to_set}" PARENT_SCOPE) ENDIF() ENDIF() ENDFOREACH() ENDFUNCTION() FUNCTION(MA_SET_COMPILER_FLAG flag_to_set) IF(MSVC) STRING(REGEX REPLACE "-" "/" result_flag "${flag_to_set}") ENDIF() FOREACH(lang ${MAODBC_LANGUAGES}) IF(ARGN) FOREACH(type ${ARGN}) STRING(REGEX REPLACE "${result_flag}" "" CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}}") SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${result_flag}" PARENT_SCOPE) ENDFOREACH() ELSE() STRING(REGEX REPLACE "${result_flag}" "" CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}") SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${result_flag}" PARENT_SCOPE) ENDIF() ENDFOREACH() ENDFUNCTION() FUNCTION(MA_SET_LINKER_FLAG flag_to_set) IF(MSVC) STRING(REGEX REPLACE ":NO" "" flag_to_check ${flag_to_set}) STRING(REGEX REPLACE "-" "/" result_flag "${flag_to_set}") ELSE() STRING(REGEX REPLACE "^-Wno-" "-W" flag_to_check ${flag_to_set}) SET(result_flag "${flag_to_set}") ENDIF() IF(ARGN) FOREACH(type ${ARGN}) # LIST(REMOVE_ITEM could be better here and in similar places above STRING(REGEX REPLACE "${flag_to_set}" "" CMAKE_EXE_LINKER_FLAGS_${type} "${CMAKE_EXE_LINKER_FLAGS_${type}}") STRING(REGEX REPLACE "${flag_to_set}" "" CMAKE_SHARED_LINKER_FLAGS_${type} "${CMAKE_SHARED_LINKER_FLAGS_${type}}") STRING(REGEX REPLACE "${flag_to_set}" "" CMAKE_MODULE_LINKER_FLAGS_${type} "${CMAKE_MODULE_LINKER_FLAGS_${type}}") STRING(REGEX REPLACE "${flag_to_check}" "" CMAKE_EXE_LINKER_FLAGS_${type} "${CMAKE_EXE_LINKER_FLAGS_${type}}") STRING(REGEX REPLACE "${flag_to_check}" "" CMAKE_SHARED_LINKER_FLAGS_${type} "${CMAKE_SHARED_LINKER_FLAGS_${type}}") STRING(REGEX REPLACE "${flag_to_check}" "" CMAKE_MODULE_LINKER_FLAGS_${type} "${CMAKE_MODULE_LINKER_FLAGS_${type}}") #MESSAGE(STATUS "Before: ${CMAKE_EXE_LINKER_FLAGS_${type}} ${CMAKE_SHARED_LINKER_FLAGS_${type}} ${CMAKE_MODULE_LINKER_FLAGS_${type}}") SET(CMAKE_EXE_LINKER_FLAGS_${type} "${CMAKE_EXE_LINKER_FLAGS_${type}} ${result_flag}" PARENT_SCOPE) SET(CMAKE_SHARED_LINKER_FLAGS_${type} "${CMAKE_SHARED_LINKER_FLAGS_${type}} ${result_flag}" PARENT_SCOPE) SET(CMAKE_MODULE_LINKER_FLAGS_${type} "${CMAKE_MODULE_LINKER_FLAGS_${type}} ${result_flag}" PARENT_SCOPE) #MESSAGE(STATUS "After: ${CMAKE_EXE_LINKER_FLAGS_${type}} ${CMAKE_SHARED_LINKER_FLAGS_${type}} ${CMAKE_MODULE_LINKER_FLAGS_${type}}, Expected: ${CMAKE_SHARED_LINKER_FLAGS_${type}} ${result_flag}") ENDFOREACH() ELSE() SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${result_flag}" PARENT_SCOPE) ENDIF() ENDFUNCTION() mariadb-connector-odbc-3.2.6/cmake/connector_c.cmake000066400000000000000000000024001501554462200223740ustar00rootroot00000000000000CMAKE_POLICY(SET CMP0054 NEW) INCLUDE(FindGit) IF(NOT EXISTS ${CMAKE_SOURCE_DIR}/libmariadb/CMakeLists.txt AND GIT_EXECUTABLE) EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule init WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") ENDIF() IF(NOT EXISTS ${CMAKE_SOURCE_DIR}/libmariadb/CMakeLists.txt) MESSAGE(FATAL_ERROR "No MariaDB Connector/C! Run git submodule init git submodule update Then restart the build. ") ENDIF() SET(OPT CONC_) IF (CMAKE_BUILD_TYPE STREQUAL "Debug") SET(CONC_WITH_RTC ON) ENDIF() SET(CONC_WITH_SIGNCODE ${SIGNCODE}) SET(SIGN_OPTIONS ${SIGNTOOL_PARAMETERS}) IF(TARGET zlib) GET_PROPERTY(ZLIB_LIBRARY_LOCATION TARGET zlib PROPERTY LOCATION) ELSE() SET(ZLIB_LIBRARY_LOCATION ${ZLIB_LIBRARY}) ENDIF() SET(CONC_WITH_CURL OFF) SET(CONC_WITH_MYSQLCOMPAT ON) IF (INSTALL_LAYOUT STREQUAL "RPM") SET(CONC_INSTALL_LAYOUT "RPM") ELSE() SET(CONC_INSTALL_LAYOUT "DEFAULT") ENDIF() SET(PLUGIN_INSTALL_DIR ${INSTALL_PLUGINDIR}) SET(MARIADB_UNIX_ADDR ${MYSQL_UNIX_ADDR}) MESSAGE("== Configuring MariaDB Connector/C") ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN) ADD_SUBDIRECTORY(libmariadb EXCLUDE_FROM_ALL) mariadb-connector-odbc-3.2.6/cmake/install.cmake000066400000000000000000000123101501554462200215470ustar00rootroot00000000000000# # Copyright (C) 2013-2016 MariaDB Corporation AB # # Redistribution and use is allowed according to the terms of the New # BSD license. # For details see the COPYING-CMAKE-SCRIPTS file. # # # This file contains settings for the following layouts: # # - RPM # Built with default prefix=/usr # # # The following variables are used and can be overwritten # # INSTALL_LAYOUT installation layout (DEFAULT = standard for tar.gz and zip packages # RPM packages # # INSTALL_BINDIR location of binaries () # INSTALL_LIBDIR location of libraries # INSTALL_PLUGINDIR location of plugins # INSTALL_DOCDIR location of docs # INSTALL_LICENSEDIR location of license #Sets platform specific CMAKE_INSTALL_XXXDIR values INCLUDE(GNUInstallDirs) IF(DEB) SET(INSTALL_LAYOUT "DEB") ENDIF() IF(RPM) SET(INSTALL_LAYOUT "RPM") ENDIF() IF(NOT INSTALL_LAYOUT) SET(INSTALL_LAYOUT "DEFAULT") ENDIF() SET(INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE STRING "Installation layout. Currently supported options are DEFAULT (tar.gz and zip), RPM and DEB") # On Windows we only provide zip and .msi. Latter one uses a different packager. IF(UNIX) IF(INSTALL_LAYOUT MATCHES "RPM|DEB") SET(libmaodbc_prefix "/usr") ELSEIF(INSTALL_LAYOUT STREQUAL "DEFAULT") SET(libmaodbc_prefix ${CMAKE_INSTALL_PREFIX}) ENDIF() ENDIF() IF(CMAKE_DEFAULT_PREFIX_INITIALIZED_BY_DEFAULT) SET(CMAKE_DEFAULT_PREFIX ${libmariadb_prefix} CACHE PATH "Installation prefix" FORCE) ENDIF() # check if the specified installation layout is valid SET(VALID_INSTALL_LAYOUTS "DEFAULT" "RPM" "DEB") LIST(FIND VALID_INSTALL_LAYOUTS "${INSTALL_LAYOUT}" layout_no) IF(layout_no EQUAL -1) MESSAGE(FATAL_ERROR "Invalid installation layout ${INSTALL_LAYOUT}. Please specify one of the following layouts: ${VALID_INSTALL_LAYOUTS}") ENDIF() # This has been done before C/C cmake scripts are included IF(NOT DEFINED INSTALL_LIB_SUFFIX) SET(INSTALL_LIB_SUFFIX "lib" CACHE STRING "Directory, under which to install libraries, e.g. lib or lib64") IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8" AND EXISTS "/usr/lib64/" AND "${INSTALL_LAYOUT}" EQUAL "RPM") SET(INSTALL_LIB_SUFFIX "lib64") ENDIF() ENDIF() IF(NOT INSTALL_LAYOUT STREQUAL "DEFAULT") IF(APPLE) SET(CMAKE_INSTALL_PREFIX "/") # /usr/local ? ELSE() SET(CMAKE_INSTALL_PREFIX "/usr") ENDIF() ENDIF() # # DEFAULT layout # SET(INSTALL_BINDIR_DEFAULT "bin") SET(INSTALL_LIBDIR_DEFAULT "${INSTALL_LIB_SUFFIX}/mariadb") SET(INSTALL_PCDIR_DEFAULT "${INSTALL_LIB_SUFFIX}/pkgconfig") SET(INSTALL_INCLUDEDIR_DEFAULT "include/mariadb") SET(INSTALL_DOCDIR_DEFAULT "docs") SET(INSTALL_LICENSEDIR_DEFAULT ${INSTALL_DOCDIR_DEFAULT}) SET(INSTALL_PLUGINDIR_DEFAULT "${INSTALL_LIB_SUFFIX}/mariadb/plugin") SET(LIBMARIADB_STATIC_DEFAULT "mariadbclient") # # RPM layout # SET(INSTALL_BINDIR_RPM "${CMAKE_INSTALL_BINDIR}") SET(INSTALL_LIBDIR_RPM "${CMAKE_INSTALL_LIBDIR}") SET(INSTALL_PCDIR_RPM "${CMAKE_INSTALL_LIBDIR}/pkgconfig") SET(INSTALL_PLUGINDIR_RPM "${CMAKE_INSTALL_LIBDIR}/mariadb/plugin") SET(INSTALL_INCLUDEDIR_RPM "${CMAKE_INSTALL_INCLUDEDIR}/mariadb") SET(INSTALL_DOCDIR_RPM "${CMAKE_INSTALL_DOCDIR}/mariadbodbc") SET(INSTALL_LICENSEDIR_RPM ${INSTALL_DOCDIR_RPM}) SET(LIBMARIADB_STATIC_RPM "mariadbclient") # # DEB layout # SET(INSTALL_BINDIR_DEB "${CMAKE_INSTALL_BINDIR}") SET(INSTALL_LIBDIR_DEB "${CMAKE_INSTALL_LIBDIR}/${CMAKE_LIBRARY_ARCHITECTURE}") SET(INSTALL_PCDIR_DEB "${INSTALL_LIBDIR_DEB}/pkgconfig") SET(INSTALL_PLUGINDIR_DEB "${INSTALL_LIBDIR_DEB}/libmariadb${CPACK_PACKAGE_VERSION_MAJOR}/plugin") SET(INSTALL_INCLUDEDIR_DEB "${CMAKE_INSTALL_INCLUDEDIR}/mariadb") SET(INSTALL_DOCDIR_DEB "${CMAKE_INSTALL_DOCDIR}") SET(INSTALL_LICENSEDIR_DEB "${INSTALL_DOCDIR_DEB}") SET(LIBMARIADB_STATIC_DEB "mariadb") # # Overwrite defaults # IF(INSTALL_LIBDIR) SET(INSTALL_LIBDIR_${INSTALL_LAYOUT} ${INSTALL_LIBDIR}) ENDIF() IF(INSTALL_PCDIR) SET(INSTALL_PCDIR_${INSTALL_LAYOUT} ${INSTALL_PCDIR}) ENDIF() IF(INSTALL_PLUGINDIR) SET(INSTALL_PLUGINDIR_${INSTALL_LAYOUT} ${INSTALL_PLUGINDIR}) ENDIF() IF(INSTALL_DOCDIR) SET(INSTALL_DOCDIR_${INSTALL_LAYOUT} ${INSTALL_DOCDIR}) ENDIF() IF(INSTALL_LICENSEDIR) SET(INSTALL_LICENSEDIR_${INSTALL_LAYOUT} ${INSTALL_LICENSEDIR}) ENDIF() # Extra INSTALL_PLUGINDIR_CLIENT that overrides any INSTALL_PLUGINDIR override IF(INSTALL_PLUGINDIR_CLIENT) SET(INSTALL_PLUGINDIR_${INSTALL_LAYOUT} ${INSTALL_PLUGINDIR_CLIENT}) ENDIF() IF(INSTALL_INCLUDEDIR) SET(INSTALL_INCLUDEDIR_${INSTALL_LAYOUT} ${INSTALL_INCLUDEDIR}) ENDIF() IF(INSTALL_BINDIR) SET(INSTALL_BINDIR_${INSTALL_LAYOUT} ${INSTALL_BINDIR}) ENDIF() IF(NOT INSTALL_PREFIXDIR) SET(INSTALL_PREFIXDIR_${INSTALL_LAYOUT} ${libmariadb_prefix}) ELSE() SET(INSTALL_PREFIXDIR_${INSTALL_LAYOUT} ${INSTALL_PREFIXDIR}) ENDIF() IF(DEFINED INSTALL_SUFFIXDIR) SET(INSTALL_SUFFIXDIR_${INSTALL_LAYOUT} ${INSTALL_SUFFIXDIR}) ENDIF() FOREACH(dir "BIN" "LIB" "PC" "INCLUDE" "DOC" "LICENSE" "PLUGIN") SET(INSTALL_${dir}DIR ${INSTALL_${dir}DIR_${INSTALL_LAYOUT}}) MARK_AS_ADVANCED(INSTALL_${dir}DIR) MESSAGE(STATUS "MariaDB Connector ODBC: INSTALL_${dir}DIR=${INSTALL_${dir}DIR}") ENDFOREACH() SET(INSTALL_PLUGINDIR_CLIENT ${INSTALL_PLUGINDIR}) MESSAGE(STATUS "MariaDB Connector ODBC: INSTALL_PLUGINDIR_CLIENT=${INSTALL_PLUGINDIR_CLIENT}") mariadb-connector-odbc-3.2.6/cmake/linux_x86_toolchain.cmake000066400000000000000000000005531501554462200240130ustar00rootroot00000000000000# toolchain file for building a 32bit version on a 64bit host # Usage: # cmake -DCMAKE_TOOLCHAIN_FILE=linux_86.toolchain.cmake set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_VERSION 1) set(CMAKE_SYSTEM_PROCESSOR "i686") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags") mariadb-connector-odbc-3.2.6/cmake/options_defaults.cmake000066400000000000000000000071371501554462200234760ustar00rootroot00000000000000# # Copyright (C) 2021,2023 MariaDB Corporation AB # # Redistribution and use is allowed according to the terms of the New # BSD license. # For details see the COPYING-CMAKE-SCRIPTS file. # OPTION(BUILD_INTERACTIVE_TESTS "Build test(s) requiring user interaction" OFF) OPTION(USE_INTERACTIVE_TESTS "Run interactive test(s) with ctest" OFF) OPTION(CONC_WITH_UNIT_TESTS "Build C/C unit tests" OFF) OPTION(WITH_ASAN "Compile with ASAN" OFF) OPTION(WITH_UBSAN "Enable undefined behavior sanitizer" OFF) OPTION(WITH_MSAN "Enable memory sanitizer" OFF) IF(WIN32) OPTION(WITH_MSI "Build MSI installation package" ON) OPTION(CONC_WITH_MSI "Build C/C MSI installation package" OFF) OPTION(WITH_SIGNCODE "Digitally sign files" OFF) OPTION(MARIADB_LINK_DYNAMIC "Link Connector/C library dynamically" OFF) OPTION(ALL_PLUGINS_STATIC "Compile all plugins in, i.e. make them static" ON) SET(CLIENT_PLUGIN_PVIO_NPIPE "STATIC") # We don't provide its support in ODBC yet, thus there is no need to bloat the library size #SET(CLIENT_PLUGIN_PVIO_SHMEM "STATIC") SET(WITH_UBSAN OFF) SET(WITH_MSAN OFF) ELSE() IF(APPLE) OPTION(MARIADB_LINK_DYNAMIC "Link Connector/C library dynamically" OFF) ELSE() OPTION(MARIADB_LINK_DYNAMIC "Link Connector/C library dynamically" ON) ENDIF() SET(BUILD_INTERACTIVE_TESTS OFF) SET(USE_INTERACTIVE_TESTS OFF) OPTION(ALL_PLUGINS_STATIC "Compile all plugins in, i.e. make them static" OFF) ENDIF() IF(USE_INTERACTIVE_TESTS) SET(BUILD_INTERACTIVE_TESTS ON) ENDIF() OPTION(WITH_SSL "Enables use of TLS/SSL library" ON) OPTION(USE_SYSTEM_INSTALLED_LIB "Use installed in the system C/C library and do not build one" OFF) OPTION(DIRECT_LINK_TESTS "Link tests directly against driver library(bypass DM)" OFF) # This is to be used for some testing scenarious, obviously. e.g. testing of the connector installation. OPTION(BUILD_TESTS_ONLY "Build only tests and nothing else" OFF) OPTION(WITH_UNIT_TESTS "Build unit tests" ON) IF(BUILD_TESTS_ONLY) SET(WITH_UNIT_TESTS ON) ENDIF() IF(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") SET(WITH_UNIT_TESTS OFF) ENDIF() IF(NOT EXISTS ${CMAKE_SOURCE_DIR}/libmariadb) SET(USE_SYSTEM_INSTALLED_LIB ON) ENDIF() SET(MAODBC_LINKER_FLAGS "") IF(APPLE) SET(CMAKE_SKIP_BUILD_RPATH FALSE) SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) OPTION(WITH_IODBC "Build with iOdbc" ON) CMAKE_POLICY(SET CMP0042 NEW) CMAKE_POLICY(SET CMP0068 NEW) SET(CMAKE_INSTALL_RPATH "") SET(CMAKE_INSTALL_NAME_DIR "") SET(CMAKE_MACOSX_RPATH ON) ELSE() OPTION(WITH_IODBC "Build with iOdbc" OFF) ENDIF() IF(WIN32) # Currently limiting this feature to Windows only, where it's most probably going to be only used IF(ALL_PLUGINS_STATIC) SET(CLIENT_PLUGIN_AUTH_GSSAPI_CLIENT "STATIC") SET(CLIENT_PLUGIN_DIALOG "STATIC") SET(CLIENT_PLUGIN_CLIENT_ED25519 "STATIC") SET(CLIENT_PLUGIN_CACHING_SHA2_PASSWORD "STATIC") SET(CLIENT_PLUGIN_SHA256_PASSWORD "STATIC") SET(CLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD "STATIC") SET(CLIENT_PLUGIN_MYSQL_OLD_PASSWORD "STATIC") SET(MARIADB_LINK_DYNAMIC OFF) ENDIF() ELSE() SET(WITH_MSI OFF) SET(CONC_WITH_MSI OFF) # Defaults for creating odbc(inst).ini for tests with Unix/iOdbc IF(WITH_UNIT_TESTS) SET_VALUE(TEST_DRIVER "maodbc_test") SET_VALUE(TEST_DSN "maodbc_test") SET_VALUE(TEST_PORT "3306") SET_VALUE(TEST_SERVER "localhost") SET_VALUE(TEST_SOCKET "") SET_VALUE(TEST_SCHEMA "test") SET_VALUE(TEST_UID "root") SET_VALUE(TEST_PASSWORD "") SET_VALUE(TEST_USETLS "0") #SET_VALUE(TEST_SSLVERIFY "0") ENDIF() ENDIF() mariadb-connector-odbc-3.2.6/cmake/packaging.cmake000066400000000000000000000207611501554462200220360ustar00rootroot00000000000000INCLUDE(cmake/ConnectorName.cmake) SET(CPACK_PACKAGE_NAME "mariadb-connector-odbc") SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) IF(NOT CPACK_PACKAGE_RELEASE) SET(CPACK_PACKAGE_RELEASE 1) ENDIF() SET(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1) SET(CPACK_PACKAGE_VENDOR "MariaDB Corporation plc") SET(CPACK_PACKAGE_CONTACT "info@mariadb.com") SET(CPACK_PACKAGE_DESCRIPTION "MariaDB Connector/ODBC. ODBC driver library for connecting to MariaDB and MySQL servers") SET(CPACK_PACKAGE_LICENSE "LGPLv2.1") SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") SET(CPACK_PACKAGE_API_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/") IF(INSTALL_LAYOUT STREQUAL "DEFAULT") SET(CPACK_COMPONENTS_ALL ClientPlugins ODBCLibs Documentation Development) #ConnectorC ELSEIF(INSTALL_LAYOUT STREQUAL "PKG") SET(CPACK_COMPONENTS_ALL ClientPlugins ODBCLibs Documentation Development) ELSE() SET(CPACK_COMPONENTS_ALL ODBCLibs Documentation Development) ENDIF() SET(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1) IF(NOT SYSTEM_NAME) STRING(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME) ENDIF() SET(QUALITY_SUFFIX "") IF (MARIADB_ODBC_VERSION_QUALITY AND NOT "${MARIADB_ODBC_VERSION_QUALITY}" STREQUAL "ga" AND NOT "${MARIADB_ODBC_VERSION_QUALITY}" STREQUAL "GA") SET(QUALITY_SUFFIX "-${MARIADB_ODBC_VERSION_QUALITY}") ENDIF() SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-connector-odbc-${CPACK_PACKAGE_VERSION}${QUALITY_SUFFIX}-src") GET_CONNECTOR_PACKAGE_NAME(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}") #IF(PACKAGE_PLATFORM_SUFFIX) # SET(CPACK_PACKAGE_FILE_NAME "mariadb-connector-odbc-${CPACK_PACKAGE_VERSION}-${PACKAGE_PLATFORM_SUFFIX}") #ELSE() # SET(CPACK_PACKAGE_FILE_NAME "mariadb-connector-odbc-${CPACK_PACKAGE_VERSION}${QUALITY_SUFFIX}-${system_name}-${CMAKE_SYSTEM_PROCESSOR}") #ENDIF() SET(CPACK_SOURCE_IGNORE_FILES /test/ /.git/ .gitignore .gitmodules .gitattributes CMakeCache.txt cmake_dist.cmake CPackSourceConfig.cmake CPackConfig.cmake /.build/ cmake_install.cmake CTestTestfile.cmake /CMakeFiles/ /version_resources/ .*vcxproj .*gz$ .*zip$ .*so$ .*so.2 .*so.3 .*dll$ .*a$ .*pdb$ .*sln$ .*sdf$ install_manifest_*txt Makefile$ /autom4te.cache/ /.travis/ .travis.yml /libmariadb/ /_CPack_Packages/ ) # Build source packages IF(GIT_BUILD_SRCPKG OR ODBC_GIT_BUILD_SRCPKG) IF(WIN32) EXECUTE_PROCESS(COMMAND git archive --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip --worktree-attributes -v HEAD) ELSE() EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip -v HEAD) EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=tar --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar -v HEAD) EXECUTE_PROCESS(COMMAND gzip -9 -f ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar) ENDIF() ENDIF() IF(WIN32) SET(DEFAULT_GENERATOR "ZIP") ELSE() SET(DEFAULT_GENERATOR "TGZ") ENDIF() IF(NOT CPACK_GENERATOR) SET(CPACK_GENERATOR "${DEFAULT_GENERATOR}") ENDIF() IF(NOT CPACK_SOURCE_GENERATOR) SET(CPACK_SOURCE_GENERATOR "${DEFAULT_GENERATOR}") ENDIF() IF(0)#PKG) We don't use it for PKG so far SET(CPACK_GENERATOR "productbuild") CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/osxinstall/resources/WELCOME.html.in ${CMAKE_BINARY_DIR}/osxinstall/resources/WELCOME.html @ONLY) SET(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_BINARY_DIR}/osxinstall/resources/WELCOME.html") SET(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/osxinstall/resources/README.html") SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/osxinstall/resources/LICENSE.html") SET(CPACK_PRODUCTBUILD_IDENTIFIER "com.mariadb.connector.odbc") SET(CPACK_PRODUCTBUILD_DOMAINS ON) SET(CPACK_PRODUCTBUILD_DOMAINS_USER ON) SET(CPACK_POSTFLIGHT_CONNECTORODBC_SCRIPT "${CMAKE_SOURCE_DIR}/osxinstall/postinstall") #SET(CPACK_POSTFLIGHT_PUBLICAPI_SCRIPT "${CMAKE_SOURCE_DIR}/osxinstall/papipostinstall") SET(CPACK_PRODUCTBUILD_RESOURCES_DIR "${CMAKE_SOURCE_DIR}/osxinstall/resources") SET(CPACK_PRODUCTBUILD_BACKGROUND "mdb-dialog-popup.png") SET(CPACK_PRODUCTBUILD_BACKGROUND_ALIGNMENT "left") CPACK_ADD_COMPONENT(ConnectorCpp DISPLAY_NAME "Connector Library" DESCRIPTION "Connector Dynamic Library.") CPACK_ADD_COMPONENT(Plugins DISPLAY_NAME "Authentication Plugins" DESCRIPTION "Set of Connector/C Authentication Plugin Libraries.") CPACK_ADD_COMPONENT(PublicApi DISPLAY_NAME "Public API" DESCRIPTION "Connector's Public API Headers.") CPACK_ADD_COMPONENT(Documentation DISPLAY_NAME "Documentation" DESCRIPTION "Connector License and Readme files.") #SET(PRODUCT_SERIES "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") IF(WITH_SIGNCODE) # SET(SIGN_WITH_DEVID "--sign \"Developer ID Installer: ${DEVELOPER_ID}\"") SET(CPACK_PRODUCTBUILD_IDENTITY_NAME "Developer ID Installer: ${DEVELOPER_ID}") ELSE() # SET(SIGN_WITH_DEVID "") ENDIF() #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/distribution.plist.in # ${CMAKE_CURRENT_BINARY_DIR}/distribution.plist @ONLY) ENDIF() # "set/append array" - append a set of strings, separated by a space MACRO(SETA var) FOREACH(v ${ARGN}) SET(${var} "${${var}} ${v}") ENDFOREACH() ENDMACRO(SETA) ######################### # DEB and RPM packaging # ######################### IF(RPM OR DEB) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/packaging/linux/postinstall.in ${CMAKE_BINARY_DIR}/packaging/linux/postinstall @ONLY) ENDIF() IF(DEB) SET(CPACK_GENERATOR "DEB") SET(CPACK_DEBIAN_PACKAGE_SECTION "devel") SET(CPACK_DEBIAN_PACKAGE_NAME ${CPACK_PACKAGE_NAME}) SET(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") SET(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") SET(CPACK_DEBIAN_PACKAGE_DEBUG ON) SET(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) SET(CPACK_DEB_COMPONENT_INSTALL ON) SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) SET(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION ON) EXECUTE_PROCESS(COMMAND lsb_release -sc OUTPUT_VARIABLE DIST OUTPUT_STRIP_TRAILING_WHITESPACE) IF(NOT DIST) SET(DIST ${DEB}) ENDIF() SET(CPACK_DEBIAN_PACKAGE_RELEASE "${CPACK_PACKAGE_RELEASE}+maria~${DIST}") SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/packaging/linux/postinstall") ENDIF() IF(RPM) SET(CPACK_GENERATOR "RPM") SET(CPACK_RPM_PACKAGE_DEBUG ON) SET(CPACK_RPM_PACKAGE_GROUP "Development/Libraries") # deprecated SET(CPACK_RPM_COMPONENT_INSTALL ON) SET(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_BINARY_DIR}/packaging/linux/postinstall) SET(CPACK_RPM_SPEC_MORE_DEFINE " %define __requires_exclude .*pkg-config ") SET(CPACK_RPM_Development_USER_FILELIST "%ignore ${CMAKE_INSTALL_PREFIX}/${INSTALL_PCDIR}") # I guess this line works, and the previous does not. Keeping both as I am not sure SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION ${CMAKE_INSTALL_PREFIX}/${INSTALL_PCDIR}) IF(CMAKE_VERSION VERSION_LESS "3.6.0") SET(CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME}) EXECUTE_PROCESS(COMMAND rpm --eval %dist OUTPUT_VARIABLE DIST OUTPUT_STRIP_TRAILING_WHITESPACE) SET(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}${DIST}-${CMAKE_SYSTEM_PROCESSOR}") ELSE() SET(CPACK_RPM_FILE_NAME "RPM-DEFAULT") SET(CPACK_RPM_PACKAGE_RELEASE_DIST ON) OPTION(CPACK_RPM_DEBUGINFO_PACKAGE "" ON) SET(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}") ENDIF() IF(CMAKE_VERSION VERSION_GREATER "3.9.99") SET(CPACK_SOURCE_GENERATOR "RPM") SETA(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS "-DRPM=${RPM}") MACRO(ADDIF var) IF(DEFINED ${var}) SETA(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS "-D${var}=${${var}}") ENDIF() ENDMACRO() ADDIF(CMAKE_BUILD_TYPE) ADDIF(BUILD_CONFIG) ADDIF(MARIADB_LINK_DYNAMIC) INCLUDE(build_depends) ENDIF() IF(CMAKE_VERSION VERSION_GREATER "3.21.99") SET(CPACK_RPM_REQUIRES_EXCLUDE_FROM ".*pkg-config") MESSAGE(STATUS "Excluding pkg-config from RPM dependencies") ENDIF() MESSAGE(STATUS "Build dependencies of the source RPM are: ${CPACK_RPM_BUILDREQUIRES}") MESSAGE(STATUS "Cmake params for build from source RPM: ${CPACK_RPM_SOURCE_PKG_BUILD_PARAMS}") ENDIF() MESSAGE(STATUS "Package Name: ${CPACK_PACKAGE_FILE_NAME} Generator: ${CPACK_GENERATOR}") INCLUDE(CPack) mariadb-connector-odbc-3.2.6/cmake/sqlcancelhandle.c000066400000000000000000000004031501554462200223640ustar00rootroot00000000000000#ifdef _WIN32 # include #endif #include #include #ifdef __cplusplus extern "C" { #endif SQLRETURN Cancel(HDBC Dbc) { return SQLCancelHandle(SQL_HANDLE_DBC, Dbc); } int main() { return 0; } #ifdef __cplusplus } #endif mariadb-connector-odbc-3.2.6/cmake/sqlcolattribute.c000066400000000000000000000013171501554462200224710ustar00rootroot00000000000000#ifdef _WIN32 # include #endif #include #include #ifdef __cplusplus extern "C" { #endif SQLRETURN SQL_API SQLColAttribute(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, SQLPOINTER CharacterAttributePtr, SQLSMALLINT BufferLength, SQLSMALLINT *StringLengthPtr, // SQLLEN *NumericAttributePtr ) SQLPOINTER NumericAttributePtr ) { return SQL_SUCCESS; } int main() { return 0; } #ifdef __cplusplus } #endif mariadb-connector-odbc-3.2.6/driver/000077500000000000000000000000001501554462200173155ustar00rootroot00000000000000mariadb-connector-odbc-3.2.6/driver/CMakeLists.txt000066400000000000000000000411231501554462200220560ustar00rootroot00000000000000# ************************************************************************************ # Copyright (C) 2020,2025 MariaDB Corporation plc # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not see # or write to the Free Software Foundation, Inc., # 51 Franklin St., Fifth Floor, Boston, MA 02110, USA # *************************************************************************************/ IF(NOT ${CMAKE_VERSION} VERSION_LESS "3.20.0") CMAKE_POLICY(SET CMP0115 NEW) ENDIF() CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ma_odbc_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/ma_odbc_version.h) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/maodbcu.rc.in ${CMAKE_CURRENT_BINARY_DIR}/maodbcu.rc) SET (MARIADB_ODBC_SOURCES odbc_3_api.cpp ma_api_internal.cpp ma_error.cpp ma_connection.cpp ma_helper.cpp ma_debug.cpp ma_dsn.c ma_driver.cpp ma_info.cpp ma_environment.cpp ma_parse.cpp ma_catalog.cpp ma_statement.cpp ma_desc.cpp ma_string.cpp ma_result.cpp ma_common.c ma_server.cpp ma_legacy_helpers.cpp ma_typeconv.cpp ma_bulk.cpp ma_codec.cpp # class/SQLString.cpp class/Results.cpp class/TextRow.cpp class/BinRow.cpp class/ClientSidePreparedStatement.cpp class/ServerSidePreparedStatement.cpp class/SSPSDirectExec.cpp class/ClientPrepareResult.cpp class/ServerPrepareResult.cpp class/CmdInformationSingle.cpp class/CmdInformationMultiple.cpp class/CmdInformationBatch.cpp class/ColumnDefinition.cpp class/ResultSetText.cpp class/ResultSetBin.cpp class/ResultSetMetaData.cpp class/Parameter.cpp class/Protocol.cpp interface/PreparedStatement.cpp interface/Row.cpp interface/ResultSet.cpp interface/PrepareResult.cpp interface/Exception.cpp template/CArray.cpp ) IF(WIN32) SET(ODBC_LIBS odbc32) SET(ODBC_INSTLIBS odbccp32) SET(MARIADB_ODBC_SOURCES ${MARIADB_ODBC_SOURCES} ma_dll.c ma_platform_win32.cpp ma_error.h ma_connection.h ma_helper.h ma_debug.h ma_dsn.h ma_driver.h ma_info.h ma_environment.h ma_parse.h ma_catalog.h ma_statement.h ma_desc.h ma_string.h ma_odbc.h ma_api_internal.h ${CMAKE_CURRENT_BINARY_DIR}/ma_odbc_version.h ma_result.h ma_server.h ma_legacy_helpers.h ma_typeconv.h ma_bulk.h ma_codec.h ma_c_stuff.h class/SQLString.h class/Results.h class/TextRow.h class/BinRow.h class/ClientSidePreparedStatement.h class/ServerSidePreparedStatement.h class/SSPSDirectExec.h class/ClientPrepareResult.h class/ServerPrepareResult.h class/CmdInformationSingle.h class/CmdInformationMultiple.h class/CmdInformationBatch.h class/ColumnDefinition.h class/ResultSetText.h class/ResultSetBin.h class/ResultSetMetaData.h class/Parameter.h class/Protocol.h interface/PreparedStatement.h interface/PrepareResult.h interface/Row.h interface/ResultSet.h interface/CmdInformation.h interface/Exception.h template/CArray.h ) SOURCE_GROUP(Classes REGULAR_EXPRESSION "class/") SOURCE_GROUP(Interfaces REGULAR_EXPRESSION "interface/") SOURCE_GROUP(Templates REGULAR_EXPRESSION "template/") ELSE() SET (MARIADB_ODBC_SOURCES ${MARIADB_ODBC_SOURCES} ma_platform_posix.cpp ma_conv_charset.cpp) ENDIF() INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/interface" "${CMAKE_CURRENT_SOURCE_DIR}/template" "${CMAKE_CURRENT_SOURCE_DIR}/class" "${CMAKE_CURRENT_BINARY_DIR}") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/class) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/driver/mariadb-odbc-driver.def.in ${CMAKE_BINARY_DIR}/driver/mariadb-odbc-driver-uni.def) IF(MARIADB_LINK_DYNAMIC)# OR USE_SYSTEM_INSTALLED_LIB) IF(USE_SYSTEM_INSTALLED_LIB) FIND_LIBRARY(CCLIB libmariadb.so) IF (${CCLIB} STREQUAL "CCLIB-NOTFOUND") # It won't be found by linker either unless user does some magic before build, so we actually could stop here with error MESSAGE(STATUS "C/C library has not been found") SET(MARIADB_CLIENT_TARGET_NAME mariadb) ELSE() MESSAGE(STATUS "C/C library found here ${CCLIB}") SET(MARIADB_CLIENT_TARGET_NAME ${CCLIB}) ENDIF() FIND_FILE(CCHEADER NAMES "mysql.h" PATHS /usr/include/mariadb /usr/include/mysql /usr/local/include/mariadb /usr/local/include/mysql) #PATH_SUFFIXES mariadb mysql) IF (${CCHEADER} STREQUAL "CCHEADER-NOTFOUND") # Again should probably stop MESSAGE(STATUS "C/C headers have not been found") INCLUDE_DIRECTORIES(/usr/include/mariadb /usr/include/mysql) SET(CCHEADERDIR "/usr/include/mariadb /usr/include/mysql") ELSE() GET_FILENAME_COMPONENT(CCHEADERDIR ${CCHEADER} DIRECTORY) MESSAGE(STATUS "C/C headers have been found here ${CCHEADERDIR}") INCLUDE_DIRECTORIES(${CCHEADERDIR}) ENDIF() SET(CCHEADERDIR "${CCHEADERDIR}" PARENT_SCOPE) ELSE() SET(MARIADB_CLIENT_TARGET_NAME libmariadb) ENDIF() MESSAGE(STATUS "Linking Connector/C library dynamically(${MARIADB_CLIENT_TARGET_NAME})") ELSE() SET(MARIADB_CLIENT_TARGET_NAME mariadbclient) MESSAGE(STATUS "Linking Connector/C library statically(${MARIADB_CLIENT_TARGET_NAME})") ENDIF() IF(WIN32) ADD_LIBRARY(${LIBRARY_NAME} SHARED ${MARIADB_ODBC_SOURCES} ${CMAKE_BINARY_DIR}/driver/mariadb-odbc-driver-uni.def ${CMAKE_BINARY_DIR}/driver/maodbcu.rc) ELSE() MESSAGE(STATUS "Version script: ${CMAKE_SOURCE_DIR}/driver/maodbc.def") ADD_LIBRARY(${LIBRARY_NAME} SHARED ${MARIADB_ODBC_SOURCES} maodbcu.rc) IF(APPLE) SET(MAODBC_INSTALL_RPATH "${ODBC_LIB_DIR}" "@loader_path" "/usr/local/opt/libiodbc" "/usr/local/iODBC/lib" "/usr/local/opt/openssl@1.1/lib" "/usr/local/opt/libressl/lib") SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-Wl" INSTALL_RPATH_USE_LINK_PATH 0 BUILD_WITH_INSTALL_RPATH 1 XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--timestamp -f" INSTALL_RPATH "${MAODBC_INSTALL_RPATH}") IF(WITH_SIGNCODE) SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Developer ID Application: ${DEVELOPER_ID}") ELSE() SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") ENDIF() ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/osxpostbuild.sh ARGS $ ) ELSEIF(NOT CMAKE_SYSTEM_NAME MATCHES AIX) SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/driver/maodbc.def") ENDIF() ENDIF() SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" # Specifically on Windows, to have implib in the same place as the dll ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" LANGUAGE CXX) MESSAGE(STATUS "All linked targets/external dependencies: ${MARIADB_CLIENT_TARGET_NAME} ${ODBC_INSTLIBS} ${PLATFORM_DEPENDENCIES}") TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${MARIADB_CLIENT_TARGET_NAME} ${ODBC_INSTLIBS} ${PLATFORM_DEPENDENCIES}) ADD_DEPENDENCIES(${LIBRARY_NAME} DEPENDENCIES_FOR_PACKAGE) IF(WITH_MSI) IF(ALL_PLUGINS_STATIC) ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -DDRIVER_LIB_DIR=$ -DPLUGINS_LIB_DIR="" # Implib may be in diff directory as dll. We currently care to have it in the same folder, but let this just stay -DIMPORT_LIB_DIR=$ -DINSTALLER_TOOLS_DIR=$ -DPLUGINS_SUBDIR_NAME=${MARIADB_DEFAULT_PLUGINS_SUBDIR} -DSOURCE_ROOT_DIR=${CMAKE_SOURCE_DIR} -DFILE_IN=${CMAKE_SOURCE_DIR}/packaging/windows/binaries_dir.xml.in -DFILE_OUT=${CMAKE_BINARY_DIR}/packaging/windows/binaries_dir.xml -P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake) ELSE() ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -DDRIVER_LIB_DIR=$ -DPLUGINS_LIB_DIR=$ # Implib may be in diff directory as dll. We currently care to have it in the same folder, but let this just stay -DIMPORT_LIB_DIR=$ -DINSTALLER_TOOLS_DIR=$ -DPLUGINS_SUBDIR_NAME=${MARIADB_DEFAULT_PLUGINS_SUBDIR} -DSOURCE_ROOT_DIR=${CMAKE_SOURCE_DIR} -DFILE_IN=${CMAKE_SOURCE_DIR}/packaging/windows/binaries_dir.xml.in -DFILE_OUT=${CMAKE_BINARY_DIR}/packaging/windows/binaries_dir.xml -P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake) ENDIF() ELSEIF(APPLE) ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/osxpostbuild.sh ARGS $ ) ENDIF() # Configuring ini files for testing IF(EXISTS "${CMAKE_SOURCE_DIR}/test/CMakeLists.txt") IF(WITH_UNIT_TESTS) IF(NOT WIN32) # Configuring ini files for testing with UnixODBC SET_VALUE(TEST_DRIVER "maodbc_test") SET_VALUE(TEST_DSN "maodbc_test") SET_VALUE(TEST_PORT "3306") SET_VALUE(TEST_SERVER "localhost") SET_VALUE(TEST_SOCKET "") SET_VALUE(TEST_SCHEMA "test") SET_VALUE(TEST_UID "root") SET_VALUE(TEST_PASSWORD "") # Configuring ini files for testing with UnixODBC MESSAGE(STATUS "Configurig Test Driver: ${TEST_DRIVER}, Test DSN: ${TEST_DSN}, tcp://${TEST_UID}@${TEST_SERVER}:${TEST_PORT}/${TEST_SCHEMA} socket: ${TEST_SOCKET}") # If deb or rpm package is built, we configure tests to use the driver installed with the packages IF(DEB OR RPM) ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -DDRIVER_LIB_LOCATION=${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}/lib${LIBRARY_NAME}.so -DTEST_DRIVER=${TEST_DRIVER} -DFILE_IN=${CMAKE_SOURCE_DIR}/test/odbcinst.ini.in -DFILE_OUT=${CMAKE_BINARY_DIR}/test/odbcinst.ini -P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake ) ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -DTEST_DRIVER=${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}/lib${LIBRARY_NAME}.so -DTEST_DSN=${TEST_DSN} -DTEST_PORT=${TEST_PORT} -DTEST_SERVER=${TEST_SERVER} -DTEST_SOCKET=${TEST_SOCKET} -DTEST_SCHEMA=${TEST_SCHEMA} -DTEST_UID=${TEST_UID} -DTEST_PASSWORD="${TEST_PASSWORD}" -DTEST_USETLS=${TEST_USETLS} #-DTEST_SSLVERIFY=${TEST_SSLVERIFY} -DFILE_IN=${CMAKE_SOURCE_DIR}/test/odbc.ini.in -DFILE_OUT=${CMAKE_BINARY_DIR}/test/odbc.ini -P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake ) ELSE() ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -DDRIVER_LIB_LOCATION=$ -DTEST_DRIVER=${TEST_DRIVER} -DFILE_IN=${CMAKE_SOURCE_DIR}/test/odbcinst.ini.in -DFILE_OUT=${CMAKE_BINARY_DIR}/test/odbcinst.ini -P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake ) ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -DTEST_DRIVER=$ -DTEST_DSN=${TEST_DSN} -DTEST_PORT=${TEST_PORT} -DTEST_SERVER=${TEST_SERVER} -DTEST_SOCKET=${TEST_SOCKET} -DTEST_SCHEMA=${TEST_SCHEMA} -DTEST_UID=${TEST_UID} -DTEST_PASSWORD=${TEST_PASSWORD} -DTEST_USETLS=${TEST_USETLS} #-DTEST_SSLVERIFY=${TEST_SSLVERIFY} -DFILE_IN=${CMAKE_SOURCE_DIR}/test/odbc.ini.in -DFILE_OUT=${CMAKE_BINARY_DIR}/test/odbc.ini -P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake ) ENDIF() ENDIF() ENDIF() ENDIF() INSTALL(TARGETS ${LIBRARY_NAME} LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT ODBCLibs) mariadb-connector-odbc-3.2.6/driver/class/000077500000000000000000000000001501554462200204225ustar00rootroot00000000000000mariadb-connector-odbc-3.2.6/driver/class/BinRow.cpp000066400000000000000000000776041501554462200223440ustar00rootroot00000000000000/************************************************************************************ Copyright (C) 2022, 2024 MariaDB Corporation AB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not see or write to the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor, Boston, MA 02110, USA *************************************************************************************/ #include #include "BinRow.h" #include "ColumnDefinition.h" #include "Exception.h" namespace mariadb { /** * Constructor. * * @param columnInformation column information. * @param columnInformationLength number of columns * @param maxFieldSize max field size * @param options connection options */ BinRow::BinRow( const std::vector& _columnInformation, int32_t _columnInformationLength, MYSQL_STMT* capiStmtHandle) : Row() , stmt(capiStmtHandle) , columnInformation(_columnInformation) , columnInformationLength(_columnInformationLength) { bind.reserve(mysql_stmt_field_count(stmt)); for (auto& columnInfo : columnInformation) { length= columnInfo.getLength(); bind.emplace_back(); ColumnDefinition::fieldDeafaultBind(columnInfo, bind.back()); } } BinRow::~BinRow() { for (auto& columnBind : bind) { //delete[] (uint8_t*)columnBind.buffer; } } /** * Set length and pos indicator to requested index. * * @param newIndex index (0 is first). * @see Resultset row protocol * documentation */ void BinRow::setPosition(int32_t newIndex) { index= newIndex; pos= 0; if (buf != nullptr) { fieldBuf.wrap((*buf)[index], (*buf)[index].size()); this->lastValueNull= fieldBuf ? BIT_LAST_FIELD_NOT_NULL : BIT_LAST_FIELD_NULL; length= static_cast(fieldBuf.size()); } else { length= bind[index].length_value; fieldBuf.wrap(static_cast(bind[index].buffer), length); this->lastValueNull= bind[index].is_null_value ? BIT_LAST_FIELD_NULL : BIT_LAST_FIELD_NOT_NULL; } } int32_t BinRow::fetchNext() { return mysql_stmt_fetch(stmt); } void BinRow::installCursorAtPosition(int32_t rowPtr) { mysql_stmt_data_seek(stmt, static_cast(rowPtr)); //fetchNext(); } SQLString BinRow::convertToString(const char* asChar, const ColumnDefinition* columnInfo) { if ((lastValueNull & BIT_LAST_FIELD_NULL)!=0) { return emptyStr; } switch (columnInfo->getColumnType()) { case MYSQL_TYPE_STRING: if (getLengthMaxFieldSize() > 0) { return SQLString(asChar, getLengthMaxFieldSize()); /*buf, pos, std::min(getMaxFieldSize()*3, length), UTF_8) .substr(0, std::min(getMaxFieldSize(), length));*/ } return SQLString(asChar);// UTF_8); case MYSQL_TYPE_BIT: return SQLString(std::to_string(parseBit())); case MYSQL_TYPE_TINY: return SQLString(zeroFillingIfNeeded(std::to_string(getInternalTinyInt(columnInfo)), columnInfo)); case MYSQL_TYPE_SHORT: return SQLString(zeroFillingIfNeeded(std::to_string(getInternalSmallInt(columnInfo)), columnInfo)); case MYSQL_TYPE_LONG: case MYSQL_TYPE_INT24: return SQLString(zeroFillingIfNeeded(std::to_string(getInternalMediumInt(columnInfo)), columnInfo)); case MYSQL_TYPE_LONGLONG: if (!columnInfo->isSigned()) { return SQLString(zeroFillingIfNeeded(std::to_string(getInternalULong(columnInfo)), columnInfo)); } return SQLString(zeroFillingIfNeeded(std::to_string(getInternalLong(columnInfo)), columnInfo)); case MYSQL_TYPE_DOUBLE: return SQLString(zeroFillingIfNeeded(std::to_string(getInternalDouble(columnInfo)), columnInfo)); case MYSQL_TYPE_FLOAT: return SQLString(zeroFillingIfNeeded(std::to_string(getInternalFloat(columnInfo)), columnInfo)); case MYSQL_TYPE_TIME: return SQLString(getInternalTimeString(columnInfo)); case MYSQL_TYPE_DATE: { Date date= getInternalDate(columnInfo);// , cal, timeZone); if (date.empty() || date.compare(nullDate) == 0) { return emptyStr; } return date; } case MYSQL_TYPE_YEAR: { int32_t year= getInternalSmallInt(columnInfo); if (year < 10) { SQLString result("0"); return result.append(std::to_string(year)); } else { return std::to_string(year); } } case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_DATETIME: { return getInternalTimestamp(columnInfo); } case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_GEOMETRY: return SQLString(asChar, getLengthMaxFieldSize()); case MYSQL_TYPE_NULL: return nullptr; default: if (getLengthMaxFieldSize() > 0) { return SQLString(asChar, getLengthMaxFieldSize()); } return SQLString(asChar); } } /** * Get string from raw binary format. * * @param columnInfo column information * @param cal calendar * @param timeZone time zone * @return String value of raw bytes * @throws SQLException if conversion failed */ SQLString BinRow::getInternalString(const ColumnDefinition* columnInfo) { return std::move(convertToString(fieldBuf.arr, columnInfo)); } /** * Get int from raw binary format. * * @param columnInfo column information * @return int value * @throws SQLException if column is not numeric or is not in Integer bounds. */ int32_t BinRow::getInternalInt(const ColumnDefinition* columnInfo) { if (lastValueWasNull()) { return 0; } int64_t value; switch (columnInfo->getColumnType()) { case MYSQL_TYPE_BIT: value= parseBit(); break; case MYSQL_TYPE_TINY: value= getInternalTinyInt(columnInfo); break; case MYSQL_TYPE_SHORT: case MYSQL_TYPE_YEAR: value= getInternalSmallInt(columnInfo); break; case MYSQL_TYPE_LONG: case MYSQL_TYPE_INT24: if (columnInfo->isSigned()) { return *reinterpret_cast(fieldBuf.arr); } else { value= *reinterpret_cast(fieldBuf.arr); } break; case MYSQL_TYPE_LONGLONG: value= getInternalLong(columnInfo); break; case MYSQL_TYPE_FLOAT: value= static_cast(getInternalFloat(columnInfo)); break; case MYSQL_TYPE_DOUBLE: value= static_cast(getInternalDouble(columnInfo)); break; case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_DECIMAL: value= getInternalLong(columnInfo); break; case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_STRING: value= safer_strtoll(fieldBuf.arr, length); // Common parent for std::invalid_argument and std::out_of_range /*catch (std::logic_error&) { throw SQLException( "Out of range value for column '" + columnInfo->getName() + "' : value " + SQLString(fieldBuf.arr, length), "22003", 1264); }*/ break; default: throw SQLException( "getInt not available for data field type " + std::to_string(columnInfo->getColumnType())); } // TODO: dirty hack(INT32_MAX->UINT32_MAX to make ODBC happy atm). Maybe it's not that dirty after all... rangeCheck("int32_t", INT32_MIN, UINT32_MAX, value, columnInfo); return static_cast(value); } /** * Get long from raw binary format. * * @param columnInfo column information * @return long value * @throws SQLException if column is not numeric or is not in Long bounds (for big unsigned * values) */ int64_t BinRow::getInternalLong(const ColumnDefinition* columnInfo) { if (lastValueWasNull()) { return 0; } int64_t value; try { switch (columnInfo->getColumnType()) { case MYSQL_TYPE_BIT: return parseBit(); case MYSQL_TYPE_TINY: value= getInternalTinyInt(columnInfo); break; case MYSQL_TYPE_SHORT: case MYSQL_TYPE_YEAR: { value= getInternalSmallInt(columnInfo); break; } case MYSQL_TYPE_LONG: case MYSQL_TYPE_INT24: { value= getInternalMediumInt(columnInfo); break; } case MYSQL_TYPE_LONGLONG: { value= *reinterpret_cast(fieldBuf.arr); if (columnInfo->isSigned()) { return value; } uint64_t unsignedValue= *reinterpret_cast(fieldBuf.arr); if (unsignedValue > static_cast(INT64_MAX)) { throw SQLException( "Out of range value for column '" + columnInfo->getName() + "' : value " + std::to_string(unsignedValue) + " is not in int64_t range", "22003", 1264); } return unsignedValue; } case MYSQL_TYPE_FLOAT: { float floatValue= getInternalFloat(columnInfo); if (floatValue > static_cast(INT64_MAX)) { throw SQLException( "Out of range value for column '" + columnInfo->getName() + "' : value " + std::to_string(floatValue) + " is not in int64_t range", "22003", 1264); } return static_cast(floatValue); } case MYSQL_TYPE_DOUBLE: { long double doubleValue= getInternalDouble(columnInfo); if (doubleValue > static_cast(INT64_MAX)) { throw SQLException( "Out of range value for column '" + columnInfo->getName() + "' : value " + std::to_string(doubleValue) + " is not in int64_t range", "22003", 1264); } return static_cast(doubleValue); } case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_DECIMAL: { //rangeCheck("BigDecimal", static_cast(buf)); return std::stoll(getInternalBigDecimal(columnInfo)); } case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_STRING: { return safer_strtoll(fieldBuf.arr, length); } default: throw SQLException( "getLong not available for data field type " + std::to_string(columnInfo->getColumnType())); } } // stoll may throw. Catching common parent for std::invalid_argument and std::out_of_range catch (std::logic_error&) { throw SQLException( "Out of range value for column '" + columnInfo->getName() + "' : value " + std::to_string(value), "22003", 1264); } return value; } uint64_t BinRow::getInternalULong(const ColumnDefinition* columnInfo) { if (lastValueWasNull()) { return 0; } int64_t value; switch (columnInfo->getColumnType()) { case MYSQL_TYPE_BIT: return static_cast(parseBit()); case MYSQL_TYPE_TINY: value= getInternalTinyInt(columnInfo); break; case MYSQL_TYPE_SHORT: case MYSQL_TYPE_YEAR: { value= getInternalSmallInt(columnInfo); break; } case MYSQL_TYPE_LONG: case MYSQL_TYPE_INT24: { value= getInternalMediumInt(columnInfo); break; } case MYSQL_TYPE_LONGLONG: { value= *reinterpret_cast(fieldBuf.arr); break; } case MYSQL_TYPE_FLOAT: { float floatValue= getInternalFloat(columnInfo); if (floatValue < 0 || floatValue > static_cast(UINT64_MAX)) { throw SQLException( "Out of range value for column '" + columnInfo->getName() + "' : value " + std::to_string(floatValue) + " is not in int64_t range", "22003", 1264); } return static_cast(floatValue); } case MYSQL_TYPE_DOUBLE: { long double doubleValue= getInternalDouble(columnInfo); if (doubleValue < 0 || doubleValue > static_cast(UINT64_MAX)) { throw SQLException( "Out of range value for column '" + columnInfo->getName() + "' : value " + std::to_string(doubleValue) + " is not in int64_t range", "22003", 1264); } return static_cast(doubleValue); } case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_DECIMAL: { //rangeCheck("BigDecimal", static_cast(buf)); return mariadb::stoull(getInternalBigDecimal(columnInfo)); } case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_STRING: { std::string str(fieldBuf.arr, length); try { return mariadb::stoull(str); } // Common parent for std::invalid_argument and std::out_of_range catch (std::logic_error&) { throw SQLException( "Out of range value for column '" + columnInfo->getName() + "' : value " + str + " is not in int64_t range", "22003", 1264); } } default: throw SQLException( "getLong not available for data field type " + std::to_string(columnInfo->getColumnType())); } if (columnInfo->isSigned() && value < 0) { throw SQLException( "Out of range value for column '" + columnInfo->getName() + "' : value " + std::to_string(value) + " is not in int64_t range", "22003", 1264); } return static_cast(value); } /** * Get float from raw binary format. * * @param columnInfo column information * @return float value * @throws SQLException if column is not numeric or is not in Float bounds. */ float BinRow::getInternalFloat(const ColumnDefinition* columnInfo) { if (lastValueWasNull()) { return 0; } int64_t value; switch (columnInfo->getColumnType()) { case MYSQL_TYPE_BIT: return static_cast(parseBit()); case MYSQL_TYPE_TINY: value= getInternalTinyInt(columnInfo); break; case MYSQL_TYPE_SHORT: case MYSQL_TYPE_YEAR: value= getInternalSmallInt(columnInfo); break; case MYSQL_TYPE_LONG: case MYSQL_TYPE_INT24: value= getInternalMediumInt(columnInfo); break; case MYSQL_TYPE_LONGLONG: { if (columnInfo->isSigned()) { return static_cast(*reinterpret_cast(fieldBuf.arr)); } uint64_t unsignedValue= *reinterpret_cast(fieldBuf.arr); return static_cast(unsignedValue); } case MYSQL_TYPE_FLOAT: return *reinterpret_cast(fieldBuf.arr); case MYSQL_TYPE_DOUBLE: return static_cast(getInternalDouble(columnInfo)); case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_STRING: case MYSQL_TYPE_DECIMAL: try { char* end; return std::strtof(fieldBuf.arr, &end); // if (errno == ERANGE) ? } // Common parent for std::invalid_argument and std::out_of_range catch (std::logic_error& nfe) { throw SQLException( "Incorrect format for getFloat for data field with type " + std::to_string(columnInfo->getColumnType()), "22003", 1264, &nfe); } default: throw SQLException( "getFloat not available for data field type " + std::to_string(columnInfo->getColumnType())); } return static_cast(value); } /** * Get double from raw binary format. * * @param columnInfo column information * @return double value * @throws SQLException if column is not numeric or is not in Double bounds (unsigned columns). */ long double BinRow::getInternalDouble(const ColumnDefinition* columnInfo) { if (lastValueWasNull()) { return 0; } switch (columnInfo->getColumnType()) { case MYSQL_TYPE_BIT: return static_cast(parseBit()); case MYSQL_TYPE_TINY: return getInternalTinyInt(columnInfo); case MYSQL_TYPE_SHORT: case MYSQL_TYPE_YEAR: return getInternalSmallInt(columnInfo); case MYSQL_TYPE_LONG: case MYSQL_TYPE_INT24: return static_cast(getInternalMediumInt(columnInfo)); case MYSQL_TYPE_LONGLONG: { if (columnInfo->isSigned()) { return static_cast(*reinterpret_cast(fieldBuf.arr)); } return static_cast(*reinterpret_cast(fieldBuf.arr)); } case MYSQL_TYPE_FLOAT: return getInternalFloat(columnInfo); case MYSQL_TYPE_DOUBLE: return *reinterpret_cast(fieldBuf.arr); case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_STRING: case MYSQL_TYPE_DECIMAL: try { return safer_strtod(fieldBuf.arr, length); } // Common parent for std::invalid_argument and std::out_of_range catch (std::logic_error& nfe) { throw SQLException( "Incorrect format for getDouble for data field with type " + std::to_string(columnInfo->getColumnType()), "22003", 1264, &nfe); } default: throw SQLException( "getDouble not available for data field type " + std::to_string(columnInfo->getColumnType())); } } /** * Get BigDecimal from raw binary format. * * @param columnInfo column information * @return BigDecimal value * @throws SQLException if column is not numeric */ BigDecimal BinRow::getInternalBigDecimal(const ColumnDefinition* columnInfo) { if (lastValueWasNull()) { return emptyStr; } switch (columnInfo->getColumnType()) { case MYSQL_TYPE_BIT: case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_YEAR: case MYSQL_TYPE_LONG: case MYSQL_TYPE_INT24: case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_DOUBLE: case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_NEWDECIMAL: return getInternalString(columnInfo); case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_STRING: { if (length > 0) { const char *asChar= fieldBuf.arr, *ptr= asChar, *end= asChar + length; if (*ptr == '+' || *ptr == '-') { ++ptr; } //TODO: make it better while (ptr < end && ( *ptr == '.' || isdigit(*ptr))) ++ptr; return SQLString(asChar, ptr - asChar); } } default: throw SQLException( "getBigDecimal not available for data field type " + std::to_string(columnInfo->getColumnType())); } } bool isNullTimeStruct(const MYSQL_TIME* mt, enum_field_types type) { bool isNull= (mt->year == 0 && mt->month == 0 && mt->day == 0); switch (type) { case MYSQL_TYPE_TIME: return false; case MYSQL_TYPE_DATE: return isNull; case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_DATETIME: return (isNull && mt->hour == 0 && mt->minute == 0 && mt->second == 0 && mt->second_part == 0); default: return false; } return false; } SQLString makeStringFromTimeStruct(const MYSQL_TIME* mt, enum_field_types type, size_t decimals) { std::ostringstream out; if (mt->neg != 0) { out << "-"; } switch (type) { case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_DATE: out << mt->year << "-" << (mt->month < 10 ? "0" : "") << mt->month << "-" << (mt->day < 10 ? "0" : "") << mt->day; if (type == MYSQL_TYPE_DATE) { break; } out << " "; case MYSQL_TYPE_TIME: out << (mt->hour < 10 ? "0" : "") << mt->hour << ":" << (mt->minute < 10 ? "0" : "") << mt->minute << ":" << (mt->second < 10 ? "0" : "") << mt->second; if (mt->second_part != 0 && decimals > 0) { SQLString digits(std::to_string(mt->second_part)); if (digits.length() > std::min(decimals, (size_t)6U)) { digits= digits.substr(0, 6); } size_t padZeros= std::min(decimals, 6 - digits.length()); out << "."; if (digits.length() + padZeros > 6) { digits= digits.substr(0, 6 - padZeros); } while (padZeros--) { out << "0"; } out << digits.c_str(); } break; default: // clang likes options for all enum members. Other types should not normally happen here. Probably would be better to throw here an exception return emptyStr; } return out.str(); } Date BinRow::getInternalDate(const ColumnDefinition* columnInfo) { if (lastValueWasNull()) { return nullDate; } switch (columnInfo->getColumnType()) { case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_DATE: { const MYSQL_TIME* mt= reinterpret_cast(fieldBuf.arr); if (isNullTimeStruct(mt, MYSQL_TYPE_DATE)) { lastValueNull |= BIT_LAST_ZERO_DATE; return nullDate; } return makeStringFromTimeStruct(mt, MYSQL_TYPE_DATE, columnInfo->getDecimals()); } case MYSQL_TYPE_TIME: throw SQLException("Cannot read Date using a Types::TIME field"); case MYSQL_TYPE_STRING: { SQLString rawValue(fieldBuf.arr, length); if (rawValue.compare(nullDate) == 0) { lastValueNull |= BIT_LAST_ZERO_DATE; return nullDate; } return Date(rawValue); } case MYSQL_TYPE_YEAR: { int32_t year= *reinterpret_cast(fieldBuf.arr); if (length == 2 && columnInfo->getLength() == 2) { if (year < 70) { year += 2000; } else { year += 1900; } } std::ostringstream result; result << year << "-01-01"; return result.str(); } default: throw SQLException( "getDate not available for data field type " + std::to_string(columnInfo->getColumnType())); } } void padZeroMicros(SQLString& time, uint32_t decimals) { if (decimals > 0) { time.reserve(time.length() + 1 + decimals); time.append(1, '.'); while (decimals-- > 0) { time.append(1, '0'); } } } /** * Get time from raw binary format. * * @param columnInfo column information * @param cal calendar * @param timeZone time zone * @return Time value * @throws SQLException if column cannot be converted to Time */ Time BinRow::getInternalTime(const ColumnDefinition* columnInfo, MYSQL_TIME* dest) { std::reference_wrapper