From 0f65c1ed3feddbe57765b8b357ee44fcfddccc17 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Mon, 8 Mar 2021 17:01:34 +0000 Subject: [PATCH 01/14] Merge upstream v6.1.11. --- .gitattributes | 97 +++++++ CMakeLists.txt | 17 +- Docs/ChangeLog | 500 -------------------------------- Docs/INFO_SRC | 12 +- README | 8 +- VERSION | 2 +- cmake/install_macros.cmake | 125 ++++---- cmake/maintainer.cmake | 2 +- cmake/os/Windows.cmake | 68 +++-- libmysql/CMakeLists.txt | 26 +- libmysql/libmysql.c | 54 ++-- mysys/CMakeLists.txt | 13 +- strings/CMakeLists.txt | 12 +- support-files/mysql.spec.sh | 2 - testclients/mysql_client_test.c | 13 +- vio/CMakeLists.txt | 18 +- 16 files changed, 339 insertions(+), 630 deletions(-) create mode 100644 .gitattributes delete mode 100644 Docs/ChangeLog diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ee812ad --- /dev/null +++ b/.gitattributes @@ -0,0 +1,97 @@ +* text=auto !eol svneol=native#text/plain +*.gitattributes text svneol=native#text/plain + +# Scriptish formats +*.bat text svneol=native#text/plain +*.bsh text svneol=native#text/x-beanshell +*.cgi text svneol=native#text/plain +*.cmd text svneol=native#text/plain +*.js text svneol=native#text/javascript +*.php text svneol=native#text/x-php +*.pl text svneol=native#text/x-perl +*.pm text svneol=native#text/x-perl +*.py text svneol=native#text/x-python +*.sh eol=lf svneol=LF#text/x-sh +configure eol=lf svneol=LF#text/x-sh + +# Image formats +*.bmp binary svneol=unset#image/bmp +*.gif binary svneol=unset#image/gif +*.ico binary svneol=unset#image/ico +*.jpeg binary svneol=unset#image/jpeg +*.jpg binary svneol=unset#image/jpeg +*.png binary svneol=unset#image/png +*.tif binary svneol=unset#image/tiff +*.tiff binary svneol=unset#image/tiff +*.svg text svneol=native#image/svg%2Bxml + +# Data formats +*.pdf binary svneol=unset#application/pdf +*.avi binary svneol=unset#video/avi +*.doc binary svneol=unset#application/msword +*.dsp text svneol=crlf#text/plain +*.dsw text svneol=crlf#text/plain +*.eps binary svneol=unset#application/postscript +*.json text svneol=native#application/json +*.gz binary svneol=unset#application/gzip +*.mov binary svneol=unset#video/quicktime +*.mp3 binary svneol=unset#audio/mpeg +*.ppt binary svneol=unset#application/vnd.ms-powerpoint +*.ps binary svneol=unset#application/postscript +*.psd binary svneol=unset#application/photoshop +*.rdf binary svneol=unset#text/rdf +*.rss text svneol=unset#text/xml +*.rtf binary svneol=unset#text/rtf +*.sln text svneol=native#text/plain +*.swf binary svneol=unset#application/x-shockwave-flash +*.tgz binary svneol=unset#application/gzip +*.vcproj text svneol=native#text/xml +*.vcxproj text svneol=native#text/xml +*.vsprops text svneol=native#text/xml +*.wav binary svneol=unset#audio/wav +*.xls binary svneol=unset#application/vnd.ms-excel +*.zip binary svneol=unset#application/zip + +# Text formats +.htaccess text svneol=native#text/plain +*.bbk text svneol=native#text/xml +*.cmake text svneol=native#text/plain +*.css text svneol=native#text/css +*.dtd text svneol=native#text/xml +*.htm text svneol=native#text/html +*.html text svneol=native#text/html +*.ini text svneol=native#text/plain +*.log text svneol=native#text/plain +*.mak text svneol=native#text/plain +*.qbk text svneol=native#text/plain +*.rst text svneol=native#text/plain +*.sql text svneol=native#text/x-sql +*.txt text svneol=native#text/plain +*.xhtml text svneol=native#text/xhtml%2Bxml +*.xml text svneol=native#text/xml +*.xsd text svneol=native#text/xml +*.xsl text svneol=native#text/xml +*.xslt text svneol=native#text/xml +*.xul text svneol=native#text/xul +*.yml text svneol=native#text/plain +boost-no-inspect text svneol=native#text/plain +CHANGES text svneol=native#text/plain +COPYING text svneol=native#text/plain +INSTALL text svneol=native#text/plain +Jamfile text svneol=native#text/plain +Jamroot text svneol=native#text/plain +Jamfile.v2 text svneol=native#text/plain +Jamrules text svneol=native#text/plain +Makefile* text svneol=native#text/plain +README text svneol=native#text/plain +TODO text svneol=native#text/plain + +# Code formats +*.c text svneol=native#text/plain +*.cpp text svneol=native#text/plain +*.h text svneol=native#text/plain +*.hpp text svneol=native#text/plain +*.ipp text svneol=native#text/plain +*.tpp text svneol=native#text/plain +*.jam text svneol=native#text/plain +*.java text svneol=native#text/plain diff --git a/CMakeLists.txt b/CMakeLists.txt index 5eb1be4..77da509 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -574,10 +574,25 @@ IF(NOT INSTALL_LAYOUT MATCHES "RPM") FILES ${CMAKE_BINARY_DIR}/Docs/INFO_SRC ${CMAKE_BINARY_DIR}/Docs/INFO_BIN - ${CMAKE_SOURCE_DIR}/Docs/ChangeLog DESTINATION ${INSTALL_DOCDIR} COMPONENT Documentation ) + INSTALL(FILES LICENSE.mysql + DESTINATION ${INSTALL_DOCREADMEDIR} + RENAME LICENSE.mysql-debug + COMPONENT DebugReadme + OPTIONAL + ) + INSTALL(FILES COPYING + DESTINATION ${INSTALL_DOCREADMEDIR} + RENAME COPYING-debug + COMPONENT DebugReadme + OPTIONAL + ) + INSTALL(FILES README + DESTINATION ${INSTALL_DOCREADMEDIR} + RENAME README-debug + COMPONENT DebugReadme) ENDIF() SET(SSL_DEFINES ${SSL_DEFINES} CACHE INTERNAL "pass SSL_DEFINES to client testing utilities") diff --git a/Docs/ChangeLog b/Docs/ChangeLog deleted file mode 100644 index a3570fa..0000000 --- a/Docs/ChangeLog +++ /dev/null @@ -1,500 +0,0 @@ -MySQL Connector/C 6.1 - Release Notes / ChangeLog -Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. - -Full release notes: -http://dev.mysql.com/doc/relnotes/connector-c/en/ - - -Changes in MySQL Connector/C 6.1.9 -===================================================================== - - Security Notes - - * Connector/C 6.1.9 upgrades the linked OpenSSL library to - version 1.0.2j. Issues fixed in the new version are - described at - http://www.openssl.org/news/vulnerabilities.html - - Functionality Added or Changed - - * (Bug #22932026) - TLS version option - * (Bug #22931973) - SSL mode option - * (Bug #21040741) - GTID session tracker - - Bugs Fixed - - * (Bug #22931954) - user names longer than 16 chars - * (Bug #21040703) - support for new 5.7 error codes - - -Changes in MySQL Connector/C 6.1.8 -===================================================================== - - Security Notes - - * Connector/C 6.1.8 upgrades the linked OpenSSL library to - version 1.0.1p. Issues fixed in the new version are - described at - http://www.openssl.org/news/vulnerabilities.html - -Changes in MySQL Connector/C 6.1.7 -===================================================================== - - Security Notes - - * Connector/C 6.1.7 upgrades the linked OpenSSL library to - version 1.0.1m. Issues fixed in the new version are - described at - http://www.openssl.org/news/vulnerabilities.html. - -Changes in MySQL Connector/C 6.1.6 (2015-03-20) -===================================================================== - - Security Notes - - * Connector/C 6.1.6 upgrades the linked OpenSSL library to - version 1.0.1k. Issues fixed in the new version are - described at - http://www.openssl.org/news/vulnerabilities.html. - - Functionality Added or Changed - - * yaSSL sources included in Connector/C source packages and - used in GPL binary distributions were upgraded to version - 2.3.7. (Bug #20201864) - - Bugs Fixed - - * For source packages, it was not possible to build - Connector/C with the client protocol test trace plugin - enabled. (Bug #20316149) - - * When there is no change in session state, the OK packet - sent from server to the client contained an unneeded byte - at the end of the packet. (Bug #19625718) - - * The client protocol trace plugin did not account for the - removal of the EOF packet from the client/server protocol - in MySQL 5.7.5. (Bug #19512199) - - * The mysql_session_track_get_first() and - mysql_session_track_get_next() C API functions could - cause a client crash if passed invalid arguments. (Bug - #18769620) - - * mysql_config --libs_r produces output containing link - flags for libmysqlclient_r, even though that library was - removed in MySQL 5.5 and replaced with a symlink to the - underlying libmysqlclient library. The output now refers - directly to libmysqlclient. (The implication is that it - is no longer necessary to maintain the symlink for the - sake of being able to use mysql_config --libs_r.) (Bug - #73724, Bug #19506315) - - * Invalid memory access could occur when using prepared - statements if a mysql client connection was lost after - statement preparation was complete and there was at least - one statement that was in initialized state but not - prepared yet. (Bug #70429, Bug #17512527) - - * Client auto-reconnect did not work for clients linked - against libmysqlclient, even with MYSQL_OPT_RECONNECT - enabled. - Also, if a FEDERATED table was accessed after - wait_timeout expired, a Lost connection to MySQL server - error occurred without an attempt to re-establish the - connection. (Bug #70026, Bug #17309863, Bug #14874, Bug - #11745408) - - * mysql_real_connect() could close a file descriptor twice - if the server was not running. (Bug #69423, Bug - #19226740) - -Changes in MySQL Connector/C 6.1.5 (2014-06-17) -===================================================================== - - Connector/C 6.1.5 upgrades the linked OpenSSL library from version - 1.0.1g to version 1.0.1h. Versions of OpenSSL prior to 1.0.1g are - reported vulnerable to CVE-2014-0224. - - Functionality Added or Changed - - * The server can now report session-state changes to client - programs. Reportable session state consists of these values: - - + The default schema (database) - - + Session-specific values for system variables - - + User-defined variables - - + Temporary tables - - + Prepared statements - The MySQL client/server protocol now includes tracker - information so that session state changes can be detected. One - use for the tracker mechanism is that it provides a means for - MySQL Connectors, Fabric, and client applications to determine - whether any session context is available to ensure session - migration from one server to another. (To change connections - in a load-balanced environment, it is necessary to detect - whether there is session state to take into consideration when - deciding whether a switch can be made.) - The user interface to control the tracker and retrieve - state-change information from it has the following components, - which enable implementation of state-change tracking on the - client side: - - + Clients can request notification when there is a change - to any of the session state-related values just listed, - in the form of a flag that is set in the OK packet - received from the server after the change occurs. To - control notification, enable or disable the - session_track_state_change system variable. This variable - is disabled by default. - - + Clients can request notification of changed values for - certain specific types of session state information: - o The default schema name. To control notification, - enable or disable the session_track_schema system - variable. This variable is enabled by default. - o The session values of system variables. Notification - occurs for the system variables named by the - session_track_system_variables system variable. By - default, notification is enabled for time_zone, - autocommit, character_set_client, - character_set_results, and character_set_connection. - (The latter three variables are those affected by - SET NAMES.) - - + To enable applications to extract the state-change - information returned by the server, the MySQL C API - includes a pair of functions: - o mysql_session_track_get_first() fetches the first - state-change information received from the server. - o mysql_session_track_get_next() fetches any remaining - state-change information received from the server. - Following a successful call to - mysql_session_track_get_first(), call this function - repeatedly as long as it returns success. - o Because there are new API functions, the client - library ABI version is now 18.3. Shared library - names now include 18.3 where appropriate. - - + The mysqltest program has enable_session_track_info and - disable_session_track_info commands to enable and disable - tracking of session state-change information. - For more information, see Server System Variables - (http://dev.mysql.com/doc/refman/5.6/en/server-system-variable - s.html) and mysql_session_track_get_first() - (http://dev.mysql.com/doc/refman/5.7/en/mysql-session-track-ge - t-first.html). For information about the structure of the OK - packet used to convey state-change information, see OK_Packet - (http://dev.mysql.com/doc/internals/en/packet-OK_Packet.html). - - * Because there are new API functions - (mysql_session_track_get_first(), - mysql_session_track_get_next()), the client library ABI - version is now 18.3. Shared library names now include 18.3 - where appropriate. - - Bugs Fixed - - * Calling mysql_get_server_version() with an invalid connection - handler argument caused the client to exit. Now it returns 0 - and reports a CR_COMMANDS_OUT_OF_SYNC error. (Bug #18053212) - - * The C client library could leak memory when client plugins - were used. (Bug #17933308) - - * On Windows, calling mysql_thread_init() call without - mysql_init() caused the client to exit. windows. Now it - returns a nonzero result because it is an error to call - mysql_thread_init() before the client library is initialized - with mysql_library_init(). (Bug #17514920) - - * There was a difference in certificate handling by yaSSL and - OpenSSL (used for Community and Enterprise, respectively). - OpenSSL expected a blank certificate to be sent when not all - of the --ssl-ca, --ssl-cert, and --ssl-key options were - specified, and yaSSL did not do so. To resolve this, yaSSL has - been modified to send a blank certificate when an option is - missing. (Bug #68788, Bug #16715064) - -Changes in MySQL Connector/C 6.1.4 (2014-04-16) -===================================================================== - - Heartbleed Bug - - * Security Fix: The Heartbleed Bug is a serious vulnerability in - the popular OpenSSL cryptographic software library, which is - included in Commercial builds of Connector/C 6.1. (It is not - included in the Community version of Connector/C 6.1; see the - Note later in this section.) This vulnerability allows theft - of information protected, under normal conditions, by SSL/TLS - encryption, which provides communication security and privacy - for Internet applications such as web browsing, email, instant - messaging, and some virtual private networks. - The Heartbleed Bug allows attackers to read the memory of the - systems protected by vulnerable versions of the OpenSSL - software. This compromises the secret keys used to identify - service providers and to encrypt traffic, user names and - passwords, and content. This allows attackers to eavesdrop on - communications, to steal data directly from services and - users, and to impersonate services and users. Additional - sources of information regarding this issue are provided at - the end of this section. - Connector/C 6.1.4 upgrades the OpenSSL library used in the - Commercial versions of the Connector/C 6.1 to version 1.0.1g, - which fixes this issue. - Users of previous Connector/C 6.1 Commercial releases are - urged to upgrade to Connector/C 6.1.4 as soon as possible. - Note - This issue does not affect Connector/C 6.1 Community releases, - which use yaSSL to provide encryption services, and do not - include the OpenSSL software. For this reason, the Connector/C - 6.1.4 release is Commercial only, and contains only the fix - for the Heartbleed bug (and no other changes); users of the - Community edition of Connector/C 6.1.3 can continue to use - this version without being affected by this issue, and to - upgrade directly to Connector/C 6.1.5 when it is released. - Additional sources of information. - This issue has been identified as CVE-2014-0160 - (http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160). - Oracle customers can learn more about how this issue may - impact Connector/C and other Oracle products they are using - by reading this My Oracle Support Note (Document ID 1645479.1) - (https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=1645479.1) - (Bug #18533200, CVE-2014-0160) - -Changes in MySQL Connector/C 6.1.3 (2013-12-27) -===================================================================== - Security Notes - - * A new MYSQL_OPT_SSL_ENFORCE option is available for the - mysql_options() C API function to indicate whether to require - the connection to use SSL. If enabled, an encrypted connection - is attempted. If an encrypted connection cannot be - established, the connection attempt fails. - For more information, see mysql_options() - (http://dev.mysql.com/doc/refman/5.7/en/mysql-options.html). - - Functionality Added or Changed - - * Some dependencies between client-side plugin header files were - removed: - - + The MYSQL_PLUGIN_EXPORT macro required by plugin - declarations is now declared directly in - mysql/client_plugin.h instead of getting the definition - from mysql/plugin.h. That macro was the only thing - required by client-side plugins and declared in - server-side header mysql/plugin.h, so including - mysql/client_plugin.h in an application no longer - requires the application to also include mysql/plugin.h. - - + mysql/plugin_trace.h no longer uses C_MODE_START or - C_MODE_END. Consequently, including mysql/plugin_trace.h - in an application no longer requires the application to - also include my_global.h. - Applications might require mysql/plugin.h or my_global.h for - other reasons, of course. (Bug #17582168) - - * A new mysql_get_option() C API function is available that - returns the current value of applicable mysql_options() - options. See mysql_get_option() - (http://dev.mysql.com/doc/refman/5.7/en/mysql-get-option.html) - . - - * When a connection is returned to the thread pool plugin, the - connection thread context must be cleaned up. Previously, this - was done using COM_CHANGE_USER (which is like the - mysql_change_user() C API function). However, that operation - reauthenticates, which is unnecessary network roundtrip - overhead in this context. - Now it is possible for client connection state to be reset in - a more lightweight manner without causing reauthentication. - The API is exposed publicly through these changes: - - + A new COM_RESET_CONNECTION protocol command (defined in - mysql_com.h) - - + A new mysql_reset_connection() C API function - - + A new resetconnection command for the mysql client - Resetting a connection has effects similar to - mysql_change_user() or an auto-reconnect except that the - connection is not closed and reopened, and reauthentication is - not done. See mysql_change_user() - (http://dev.mysql.com/doc/refman/5.6/en/mysql-change-user.html - )) and see Controlling Automatic Reconnection Behavior - (http://dev.mysql.com/doc/refman/5.6/en/auto-reconnect.html)). - For more information, see mysql_reset_connection() - (http://dev.mysql.com/doc/refman/5.7/en/mysql-reset-connection - .html) and mysql --- The MySQL Command-Line Tool - (http://dev.mysql.com/doc/refman/5.6/en/mysql.html). - - * Connector/C is now included in MySQL Installer (Windows). - - * Because there are new API functions (mysql_get_option(), - mysql_reset_connection()), the library ABI version is now - 18.2. Shared library names now include 18.2 where appropriate. - - Bugs Fixed - - * It was not possible to build client-side plugins using - Connector/C because client_plugin.h referenced a macro defined - in the plugin.h file, which is not included in Connector/C - distributions. (Bug #17582228) - References: See also Bug #17582168. - - * After the fix for Bug #16409270, it was not possible to - #include following #include . (Bug - #17514554) - - * Upgrading Connector/C using the 64-bit version of the Windows - MSI package occurred in the default folder because registry - search logic was hardcoded to use the 32-bit registry. (Bug - #17515067) - - * A client crash occurred if mysql_set_server_option() or - several other C API functions were called before - mysql_real_connect(). (Bug #17338958) - -Changes in MySQL Connector/C 6.1.2 (2013-09-30) -===================================================================== - Functionality Added or Changed - - * The implementation of condition variables specific to Windows - XP and Windows Server 2003 was removed from the source code - because MySQL is not supported on those platforms as of MySQL - 5.6. - Note - This change has the following implication: Previously, - Connector/C 6.1, while not officially supported on Windows XP - or Windows Server 2003, could be used on those platforms. This - is no longer possible. - (Bug #17332056) - - * MySQL now supports the use of client-side plugins that - implement a trace of communication between a client and the - server that takes place using the client/server protocol. - Protocol trace plugins use the client plugin API (see Writing - Plugins - (http://dev.mysql.com/doc/refman/5.6/en/writing-plugins.html)) - . - In Connector/C source distributions, a test protocol trace - plugin is implemented in the test_trace_plugin.cc file in the - libmysql directory. This can be examined as a guide to writing - other protocol trace plugins. - - * Static libraries built with VS2008, VS2010, VS2012 are now - distributed as part of Connector/C packages for Windows: ZIP - and MSI. New directories named vs9, vs10, and vs11 located - under the lib directory contain static libraries and - corresponding pdb files built with VS2008, VS2010, and VS2012, - respectively. - - Bugs Fixed - - * The CLIENT_CONNECT_WITH_DB flag was improperly handled in the - C client library. This could lead to a malformed packet sent - to the server. (Bug #17351732) - - * The mysql_real_connect() C API function could leak memory if - it failed. (Bug #17337684) - - * The mysql_options() C API function could leak memory if called - more than once with the MYSQL_SET_CLIENT_IP option. (Bug - #17297012) - - * The Connector/C MSI package was missing the following files: - ChangeLog, README, LICENSE, COPYING, INFO_SRC, INFO_BIN. (Bug - #17261526) - - * The Connector/C RPM package was missing the following files: - INFO_SRC, INFO_BIN, my_print_defaults, perror. (Bug #17261610) - - * On Windows, a MySQL client program that simply used #include - could not be compiled due to missing Windows - declarations in that file. The same program would compile on - other platforms. (Bug #16409270) - - * The libmysql.dll library was missing several symbols: my_init, - mysql_client_find_plugin, mysql_client_register_plugin, - mysql_load_plugin, mysql_load_plugin_v, and - mysql_plugin_options. (Bug #69204, Bug #16797982) - -Changes in MySQL Connector/C 6.1.1 (2013-08-05) -===================================================================== - Functionality Added or Changed - - * The C API libmysqlclient shared-library .so files now - have version 18.1.0 (up from version 18.0.0 used in - 6.1.0). 18.1.0 can be used as a replacement for 18.0.0. - (Bug #16809055) - - Bugs Fixed - - * The mysql_options4 symbol was missing from libmysql.dll. (Bug - #69204, Bug #16797982) - -Changes in MySQL Connector/C 6.1.0 (2013-05-02, General Availability) -===================================================================== - Functionality Added or Changed - - * MySQL Connector/C 6.1 provides these features not present in - 6.0: - - + Support for the pluggable authentication framework that - enables implementation of authentication methods as - plugins. This framework can be used for MySQL native - authentication as well as external authentication - methods. See Pluggable Authentication - (http://dev.mysql.com/doc/refman/5.6/en/pluggable-authent - ication.html). - - + Client-side support for the SHA-256, PAM, and Windows - native authentication plugins. See The SHA-256 - Authentication Plugin - (http://dev.mysql.com/doc/refman/5.6/en/sha256-authentica - tion-plugin.html), The PAM Authentication Plugin - (http://dev.mysql.com/doc/refman/5.6/en/pam-authenticatio - n-plugin.html), and The Windows Native Authentication - Plugin - (http://dev.mysql.com/doc/refman/5.6/en/windows-authentic - ation-plugin.html). - The older MySQL Connector/C 6.0 can connect only to - accounts that use native MySQL passwords. If a client - program attempts to connect to an account that requires a - different authentication method, an "Access denied for - user" error occurs. - - + Support for connecting to accounts that have expired - passwords. See Password Expiration and Sandbox Mode - (http://dev.mysql.com/doc/refman/5.6/en/password-expirati - on.html). - - + Support for prepared CALL statements. This enables client - programs to handle stored procedures that produce - multiple result sets and to obtain the final value of OUT - and INOUT procedure parameters. See C API Support for - Prepared CALL Statements - (http://dev.mysql.com/doc/refman/5.6/en/c-api-prepared-ca - ll-statements.html). - - + Support for connecting over IPv6. See IPv6 Support - (http://dev.mysql.com/doc/refman/5.6/en/ipv6-support.html - ). - - + Support for binding client programs to a specific IP - address at connect time. See mysql_options() - (http://dev.mysql.com/doc/refman/5.6/en/mysql-options.htm - l). - - + Support for specifying connection attributes to pass to - the server at connect time. See mysql_options() - (http://dev.mysql.com/doc/refman/5.6/en/mysql-options.htm - l), and mysql_options4() - (http://dev.mysql.com/doc/refman/5.6/en/mysql-options4.ht - ml). diff --git a/Docs/INFO_SRC b/Docs/INFO_SRC index 9f080e1..cb9a20f 100644 --- a/Docs/INFO_SRC +++ b/Docs/INFO_SRC @@ -1,7 +1,7 @@ -commit: ac6dbbf0a00a071df09f850fdee3ae0aa97a33b8 -date: 2017-01-04 13:55:47 +0100 -build-date: 2017-01-04 14:06:38 +0100 -short: ac6dbbf -branch: release/6.1.9 +commit: e4e369ccc88da79f1929feb9ccea85813ffb0590 +date: 2017-06-30 11:47:57 +0200 +build-date: 2017-07-13 08:54:53 +0200 +short: e4e369c +branch: release/6.1.11 -MySQL Connector/C source 6.1.9 +MySQL Connector/C source 6.1.11 diff --git a/README b/README index c020417..a4f3961 100644 --- a/README +++ b/README @@ -51,7 +51,13 @@ DOCUMENTATION LOCATION You may also find the latest copy of the documentation on the MySQL website at - +. + +For the new features/bugfix history, see release notes at +. + +For installation instructions see +. *************************************************************** diff --git a/VERSION b/VERSION index cb6eae8..4fffaac 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=6 MYSQL_VERSION_MINOR=1 -MYSQL_VERSION_PATCH=9 +MYSQL_VERSION_PATCH=11 MYSQL_VERSION_EXTRA= diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake index cfe4783..f39dfb6 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -1,5 +1,5 @@ # Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. -# +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. @@ -11,7 +11,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake) @@ -44,31 +44,31 @@ MACRO (INSTALL_DEBUG_SYMBOLS targets) SET(comp Server) ELSE() SET(comp Debuginfo) - ENDIF() + ENDIF() # No .pdb file for static libraries. IF(NOT type MATCHES "STATIC_LIBRARY") INSTALL(FILES ${pdb_location} - DESTINATION ${INSTALL_LOCATION} COMPONENT ${comp}) + DESTINATION ${INSTALL_LOCATION} COMPONENT ${comp} OPTIONAL) ENDIF() ENDFOREACH() ENDIF() ENDMACRO() # Installs manpage for given file (either script or executable) -# +# FUNCTION(INSTALL_MANPAGE file) IF(NOT UNIX) RETURN() ENDIF() GET_FILENAME_COMPONENT(file_name "${file}" NAME) - SET(GLOB_EXPR + SET(GLOB_EXPR ${CMAKE_SOURCE_DIR}/man/*${file}man.1* ${CMAKE_SOURCE_DIR}/man/*${file}man.8* ${CMAKE_BINARY_DIR}/man/*${file}man.1* ${CMAKE_BINARY_DIR}/man/*${file}man.8* ) IF(MYSQL_DOC_DIR) - SET(GLOB_EXPR + SET(GLOB_EXPR ${MYSQL_DOC_DIR}/man/*${file}man.1* ${MYSQL_DOC_DIR}/man/*${file}man.8* ${MYSQL_DOC_DIR}/man/*${file}.1* @@ -76,7 +76,7 @@ FUNCTION(INSTALL_MANPAGE file) ${GLOB_EXPR} ) ENDIF() - + FILE(GLOB_RECURSE MANPAGES ${GLOB_EXPR}) IF(MANPAGES) LIST(GET MANPAGES 0 MANPAGE) @@ -98,7 +98,7 @@ FUNCTION(INSTALL_SCRIPT) "" ${ARGN} ) - + SET(script ${ARG_DEFAULT_ARGS}) IF(NOT ARG_DESTINATION) SET(ARG_DESTINATION ${INSTALL_BINDIR}) @@ -109,17 +109,17 @@ FUNCTION(INSTALL_SCRIPT) SET(COMP) ENDIF() - INSTALL(FILES + INSTALL(FILES ${script} DESTINATION ${ARG_DESTINATION} - PERMISSIONS OWNER_READ OWNER_WRITE + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ${COMP} ) INSTALL_MANPAGE(${script}) ENDFUNCTION() -# Install symbolic link to CMake target. +# Install symbolic link to CMake target. # We do 'cd path; ln -s target_name link_name' # We also add an INSTALL target for "${path}/${link_name}" MACRO(INSTALL_SYMLINK target target_name link_name destination component) @@ -131,20 +131,20 @@ IF(UNIX) ADD_CUSTOM_COMMAND( OUTPUT ${output} COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${output} - COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink - ${target_name} + COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink + ${target_name} ${link_name} WORKING_DIRECTORY ${path} DEPENDS ${target} ) - + ADD_CUSTOM_TARGET(symlink_${link_name} ALL DEPENDS ${output}) SET_TARGET_PROPERTIES(symlink_${link_name} PROPERTIES CLEAN_DIRECT_OUTPUT 1) IF(CMAKE_GENERATOR MATCHES "Xcode") # For Xcode, replace project config with install config - STRING(REPLACE "${CMAKE_CFG_INTDIR}" + STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" output ${output}) ENDIF() INSTALL(FILES ${output} DESTINATION ${destination} COMPONENT ${component}) @@ -155,22 +155,22 @@ IF(WIN32) OPTION(SIGNCODE "Sign executables and dlls with digital certificate" OFF) MARK_AS_ADVANCED(SIGNCODE) IF(SIGNCODE) - SET(SIGNTOOL_PARAMETERS + SET(SIGNTOOL_PARAMETERS /a /t http://timestamp.verisign.com/scripts/timstamp.dll CACHE STRING "parameters for signtool (list)") FIND_PROGRAM(SIGNTOOL_EXECUTABLE signtool) IF(NOT SIGNTOOL_EXECUTABLE) - MESSAGE(FATAL_ERROR + MESSAGE(FATAL_ERROR "signtool is not found. Signing executables not possible") ENDIF() IF(NOT DEFINED SIGNCODE_ENABLED) FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/testsign.c "int main(){return 0;}") MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/testsign) - TRY_COMPILE(RESULT ${CMAKE_CURRENT_BINARY_DIR}/testsign ${CMAKE_CURRENT_BINARY_DIR}/testsign.c + TRY_COMPILE(RESULT ${CMAKE_CURRENT_BINARY_DIR}/testsign ${CMAKE_CURRENT_BINARY_DIR}/testsign.c COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/testsign.exe ) - - EXECUTE_PROCESS(COMMAND + + EXECUTE_PROCESS(COMMAND ${SIGNTOOL_EXECUTABLE} sign ${SIGNTOOL_PARAMETERS} ${CMAKE_CURRENT_BINARY_DIR}/testsign.exe RESULT_VARIABLE ERR ERROR_QUIET OUTPUT_QUIET ) @@ -190,11 +190,11 @@ MACRO(SIGN_TARGET target) IF(target_type AND NOT target_type MATCHES "STATIC") GET_TARGET_PROPERTY(target_location ${target} LOCATION) IF(CMAKE_GENERATOR MATCHES "Visual Studio") - STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" + STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" target_location ${target_location}) ENDIF() INSTALL(CODE - "EXECUTE_PROCESS(COMMAND + "EXECUTE_PROCESS(COMMAND ${SIGNTOOL_EXECUTABLE} sign ${SIGNTOOL_PARAMETERS} ${target_location} RESULT_VARIABLE ERR) IF(NOT \${ERR} EQUAL 0) @@ -223,7 +223,7 @@ FUNCTION(MYSQL_INSTALL_TARGETS) MESSAGE(FATAL_ERROR "Need DESTINATION parameter for MYSQL_INSTALL_TARGETS") ENDIF() - + FOREACH(target ${TARGETS}) # If signing is required, sign executables before installing IF(SIGNCODE AND SIGNCODE_ENABLED) @@ -239,14 +239,15 @@ FUNCTION(MYSQL_INSTALL_TARGETS) SET(COMP COMPONENT ${ARG_COMPONENT}) ENDIF() INSTALL(TARGETS ${TARGETS} DESTINATION ${ARG_DESTINATION} ${COMP}) - # Connector/C packages should not install any debug files - #SET(INSTALL_LOCATION ${ARG_DESTINATION} ) - #INSTALL_DEBUG_SYMBOLS("${TARGETS}") + IF(CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE MATCHES "Release") + SET(INSTALL_LOCATION ${ARG_DESTINATION} ) + INSTALL_DEBUG_SYMBOLS("${TARGETS}") + ENDIF() SET(INSTALL_LOCATION) ENDFUNCTION() -# Optionally install mysqld/client/embedded from debug build run. outside of the current build dir -# (unless multi-config generator is used like Visual Studio or Xcode). +# Optionally install mysqld/client/embedded from debug build run. outside of the current build dir +# (unless multi-config generator is used like Visual Studio or Xcode). # For Makefile generators we default Debug build directory to ${buildroot}/../debug. GET_FILENAME_COMPONENT(BINARY_PARENTDIR ${CMAKE_BINARY_DIR} PATH) SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug build") @@ -254,7 +255,7 @@ SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug FUNCTION(INSTALL_DEBUG_TARGET target) MYSQL_PARSE_ARGUMENTS(ARG - "DESTINATION;RENAME;PDB_DESTINATION;COMPONENT;SUFFIX" + "DESTINATION;RENAME;PDB_DESTINATION;IMPORTLIB_DESTINATION;COMPONENT;SUFFIX" "" ${ARGN} ) @@ -273,7 +274,7 @@ FUNCTION(INSTALL_DEBUG_TARGET target) ELSE() STRING(REPLACE "${CMAKE_CFG_INTDIR}" "Debug" debug_target_location "${target_location}" ) ENDIF() - IF(ARG_SUFFIX) + IF(ARG_SUFFIX) GET_FILENAME_COMPONENT(ext ${debug_target_location} EXT) GET_FILENAME_COMPONENT(fn ${debug_target_location} NAME_WE) STRING(REPLACE "${fn}${ext}" "${fn}${ARG_SUFFIX}${ext}" @@ -282,7 +283,7 @@ FUNCTION(INSTALL_DEBUG_TARGET target) IF(NOT ARG_COMPONENT) SET(ARG_COMPONENT DebugBinaries) ENDIF() - + # Define permissions # For executable files SET(PERMISSIONS_EXECUTABLE @@ -291,12 +292,12 @@ FUNCTION(INSTALL_DEBUG_TARGET target) GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) - # Permissions for shared library (honors CMAKE_INSTALL_NO_EXE which is + # Permissions for shared library (honors CMAKE_INSTALL_NO_EXE which is # typically set on Debian) IF(CMAKE_INSTALL_SO_NO_EXE) SET(PERMISSIONS_SHARED_LIBRARY PERMISSIONS - OWNER_READ OWNER_WRITE + OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) ELSE() @@ -309,10 +310,11 @@ FUNCTION(INSTALL_DEBUG_TARGET target) # Define permissions for static library SET(PERMISSIONS_STATIC_LIBRARY PERMISSIONS - OWNER_READ OWNER_WRITE + OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + MESSAGE(STATUS "Installing \"${debug_target_location}\" into \"${ARG_DESTINATION}\" component \"${ARG_COMPONENT}\"") INSTALL(FILES ${debug_target_location} DESTINATION ${ARG_DESTINATION} ${RENAME_PARAM} @@ -323,22 +325,45 @@ FUNCTION(INSTALL_DEBUG_TARGET target) IF(MSVC) GET_FILENAME_COMPONENT(ext ${debug_target_location} EXT) - STRING(REPLACE "${ext}" ".pdb" debug_pdb_target_location "${debug_target_location}" ) - IF (RENAME_PARAM) - IF(NOT ARG_PDB_DESTINATION) - STRING(REPLACE "${ext}" ".pdb" "${ARG_RENAME}" pdb_rename) - SET(PDB_RENAME_PARAM RENAME "${pdb_rename}") - ENDIF() + + # Install the PDB file + SET(_types "PDB") + IF(target_type MATCHES "SHARED_LIBRARY") + # Also install the import library if a DLL + LIST(APPEND _types "IMPORTLIB") ENDIF() - IF(NOT ARG_PDB_DESTINATION) - SET(ARG_PDB_DESTINATION "${ARG_DESTINATION}") + + FOREACH(_type ${_types}) + IF(_type MATCHES "IMPORTLIB") + SET(_ext ".lib") + ELSE() + SET(_ext ".pdb") + ENDIF() + # File to install has the same path but a different file extension + STRING(REPLACE "${ext}" "${_ext}" _target_location "${debug_target_location}" ) + SET(_rename_param) + IF (RENAME_PARAM) + IF(NOT ARG_${_type}_DESTINATION) + STRING(REPLACE "${ext}" "${_ext}" "${ARG_RENAME}" _rename) + SET(_rename_param RENAME "${_rename}") + ENDIF() + ENDIF() + + IF(ARG_${_type}_DESTINATION) + SET(_destination "${ARG_${_type}_DESTINATION}") + ELSE() + SET(_destination "${ARG_DESTINATION}") + ENDIF() + + MESSAGE(STATUS "Installing \"${_target_location}\" into \"${_destination}\" component \"${ARG_COMPONENT}\"") + INSTALL(FILES ${_target_location} + DESTINATION ${_destination} + ${_rename_param} + CONFIGURATIONS Release RelWithDebInfo + COMPONENT ${ARG_COMPONENT} + OPTIONAL) ENDIF() - INSTALL(FILES ${debug_pdb_target_location} - DESTINATION ${ARG_PDB_DESTINATION} - ${PDB_RENAME_PARAM} - CONFIGURATIONS Release RelWithDebInfo - COMPONENT ${ARG_COMPONENT} - OPTIONAL) - ENDIF() + ENDFOREACH() + ENDFUNCTION() diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index c3cd977..0554d6e 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -22,7 +22,7 @@ ENDIF() # Common warning flags for GCC and Clang SET(MY_C_WARNING_FLAGS - "${MY_WARNING_FLAGS} -Wwrite-strings -Wdeclaration-after-statement") + "${MY_WARNING_FLAGS} -Wwrite-strings -Wdeclaration-after-statement -Wno-unused-parameter") # Common warning flags for G++ and Clang++ SET(MY_CXX_WARNING_FLAGS diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index fa30dbb..535c199 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -1,5 +1,5 @@ # Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. -# +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. @@ -11,7 +11,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # This file includes Windows specific hacks, mostly around compiler flags @@ -30,7 +30,7 @@ INCLUDE (CheckTypeSize) INCLUDE(${CMAKE_BINARY_DIR}/win/configure.data OPTIONAL) # avoid running system checks by using pre-cached check results -# system checks are expensive on VS since every tiny program is to be compiled in +# system checks are expensive on VS since every tiny program is to be compiled in # a VC solution. GET_FILENAME_COMPONENT(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) INCLUDE(${_SCRIPT_DIR}/WindowsCache.cmake) @@ -41,7 +41,7 @@ IF(NOT FORCE_UNSUPPORTED_COMPILER AND MSVC_VERSION LESS 1800) ENDIF() # OS display name (version_compile_os etc). -# Used by the test suite to ignore bugs on some platforms, +# Used by the test suite to ignore bugs on some platforms, IF(CMAKE_SIZEOF_VOID_P MATCHES 8) SET(SYSTEM_TYPE "Win64") SET(MYSQL_MACHINE_TYPE "x86_64") @@ -63,7 +63,7 @@ IF(WITH_MSCRT_DEBUG) ADD_DEFINITIONS(-DMY_MSCRT_DEBUG) ADD_DEFINITIONS(-D_CRTDBG_MAP_ALLOC) ENDIF() - + OPTION(WIN_DEBUG_NO_INLINE "Disable inlining for debug builds on Windows" OFF) IF(MSVC) @@ -73,7 +73,7 @@ IF(MSVC) SET(CMAKE_{type}_LINKER_FLAGS_RELEASE "${CMAKE_${type}_LINKER_FLAGS_RELEASE} /debug") ENDFOREACH() - + # For release types Debug Release RelWithDebInfo (but not MinSizeRel): # - Force static runtime libraries # - Choose C++ exception handling: @@ -82,6 +82,19 @@ IF(MSVC) # scope as a result of the exception. # /EHsc catches C++ exceptions only and tells the compiler to assume that # extern C functions never throw a C++ exception. + + IF(NOT WINDOWS_RUNTIME_MD) + FOREACH(flag + CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT + CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT) + STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}") + SET("${flag}" "${${flag}} /EHsc") + ENDFOREACH() + ENDIF() + + # For Debug build modes: # - Choose debugging information: # /Z7 # Produces an .obj file containing full symbolic debugging @@ -95,40 +108,37 @@ IF(MSVC) # Allowing inline reduces test time using the debug server by # 30% or so. If you do want to keep inlining off, set the # cmake flag WIN_DEBUG_NO_INLINE. - FOREACH(lang C CXX) - SET(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} /Z7") - ENDFOREACH() - IF(NOT WINDOWS_RUNTIME_MD) - FOREACH(flag - CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT - CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT) - STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}") - STRING(REPLACE "/Zi" "/Z7" "${flag}" "${${flag}}") - IF (NOT WIN_DEBUG_NO_INLINE) - STRING(REPLACE "/Ob0" "/Ob1" "${flag}" "${${flag}}") - ENDIF() - SET("${flag}" "${${flag}} /EHsc") - ENDFOREACH() - ENDIF() - + + OPTION(EMBED_DEBUG_INFO "Use /Z7 compile option to embed debug info into object files" OFF) + MARK_AS_ADVANCED(EMBED_DEBUG_INFO) + + FOREACH(flag + CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT + CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT) + IF (EMBED_DEBUG_INFO) + STRING(REPLACE "/Zi" "/Z7" "${flag}" "${${flag}}") + ENDIF() + IF (NOT WIN_DEBUG_NO_INLINE) + STRING(REPLACE "/Ob0" "/Ob1" "${flag}" "${${flag}}") + ENDIF() + ENDFOREACH(flag) + # Fix CMake's predefined huge stack size FOREACH(type EXE SHARED MODULE) STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS "${CMAKE_${type}_LINKER_FLAGS}") STRING(REGEX REPLACE "/INCREMENTAL:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO}") ENDFOREACH() - - # Mark 32 bit executables large address aware so they can + + # Mark 32 bit executables large address aware so they can # use > 2GB address space IF(CMAKE_SIZEOF_VOID_P MATCHES 4) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE") ENDIF() - + # Speed up multiprocessor build SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") - + #TODO: update the code and remove the disabled warnings SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /we4099") @@ -139,7 +149,7 @@ LINK_LIBRARIES(ws2_32) # ..also for tests SET(CMAKE_REQUIRED_LIBRARIES ws2_32) -# IPv6 constants appeared in Vista SDK first. We need to define them in any case if they are +# IPv6 constants appeared in Vista SDK first. We need to define them in any case if they are # not in headers, to handle dual mode sockets correctly. CHECK_SYMBOL_EXISTS(IPPROTO_IPV6 "winsock2.h" HAVE_IPPROTO_IPV6) IF(NOT HAVE_IPPROTO_IPV6) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index d8bbfdf..83eabd9 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -218,6 +218,12 @@ ADD_CONVENIENCE_LIBRARY(clientlib ${CLIENT_SOURCES}) DTRACE_INSTRUMENT(clientlib) ADD_DEPENDENCIES(clientlib GenError) +if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") + target_compile_options(clientlib PRIVATE + -Wno-unused-variable # libmysql.c:4517 + ) +endif() + SET(LIBS clientlib dbug strings vio mysys mysys_ssl ${ZLIB_LIBRARY} ${SSL_LIBRARIES} ${LIBDL}) # @@ -235,7 +241,11 @@ IF(STATIC_LIB_SUBDIR) SET(OLD_INSTALL_LIBDIR ${INSTALL_LIBDIR}) SET(INSTALL_LIBDIR ${INSTALL_LIBDIR}/${STATIC_LIB_SUBDIR}) ENDIF() -MERGE_LIBRARIES(mysqlclient STATIC ${LIBS} COMPONENT Development) +IF(DISABLE_STATIC) + MERGE_LIBRARIES(mysqlclient STATIC ${LIBS} COMPONENT Development NOINSTALL) +ELSE() + MERGE_LIBRARIES(mysqlclient STATIC ${LIBS} COMPONENT Development) +ENDIF() IF(STATIC_LIB_SUBDIR) SET(INSTALL_LIBDIR ${OLD_INSTALL_LIBDIR}) ENDIF() @@ -321,6 +331,20 @@ IF(NOT DISABLE_SHARED) ENDIF() ENDIF() +# Visual Studio users need debug static library for debug projects +IF(MSVC) + IF(NOT DISABLE_STATIC) + IF(STATIC_LIB_SUBDIR) + INSTALL_DEBUG_TARGET(mysqlclient DESTINATION ${INSTALL_LIBDIR}/${STATIC_LIB_SUBDIR}/debug) + ELSE() + INSTALL_DEBUG_TARGET(mysqlclient DESTINATION ${INSTALL_LIBDIR}/debug) + ENDIF() + ENDIF() + IF(NOT DISABLE_SHARED) + INSTALL_DEBUG_TARGET(libmysql DESTINATION ${INSTALL_LIBDIR}/debug) + ENDIF() +ENDIF() + # # Basic application for testing linking against dynamic client library. # diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 659ed2d..28b4702 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -262,7 +262,7 @@ mysql_debug(const char *debug MY_ATTRIBUTE((unused))) else if ((env = getenv("MYSQL_DEBUG"))) { DBUG_PUSH(env); -#if !defined(_WINVER) && !defined(WINVER) +#if !defined(USE_MESSAGEBOX) || !defined(_WINVER) && !defined(WINVER) puts("\n-------------------------------------------------------"); puts("MYSQL_DEBUG found. libmysql started with the following:"); puts(env); @@ -763,7 +763,7 @@ MYSQL_FIELD *cli_list_fields(MYSQL *mysql) MYSQL_FIELD *result; MYSQL_TRACE_STAGE(mysql, WAIT_FOR_FIELD_DEF); - query= cli_read_rows(mysql,(MYSQL_FIELD*) 0, + query= cli_read_rows(mysql,(MYSQL_FIELD*) 0, protocol_41(mysql) ? 8 : 6); MYSQL_TRACE_STAGE(mysql, READY_FOR_COMMAND); @@ -1112,10 +1112,10 @@ void my_net_local_init(NET *net) can use in a SQL statement in of the either ways: INSERT INTO blob_column VALUES (0xAABBCC); (any MySQL version) INSERT INTO blob_column VALUES (X'AABBCC'); (4.1 and higher) - + The string in "from" is encoded to a HEX string. The result is placed in "to" and a terminating null byte is appended. - + The string pointed to by "from" must be "length" bytes long. You must allocate the "to" buffer to be at least length*2+1 bytes long. Each character needs two bytes, and you need room for the terminating @@ -1132,7 +1132,7 @@ mysql_hex_string(char *to, const char *from, ulong length) { char *to0= to; const char *end; - + for (end= from + length; from < end; from++) { *to++= _dig_vec_upper[((unsigned char) *from) >> 4]; @@ -1907,7 +1907,7 @@ mysql_stmt_param_metadata(MYSQL_STMT *stmt) TODO: Fix this when server sends the information. Till then keep a dummy prototype. */ - DBUG_RETURN(0); + DBUG_RETURN(0); } @@ -2188,9 +2188,9 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) stmt->insert_id= mysql->insert_id; if (res) { - /* - Don't set stmt error if stmt->mysql is NULL, as the error in this case - has already been set by mysql_prune_stmt_list(). + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). */ if (stmt->mysql) set_stmt_errmsg(stmt, net); @@ -2233,7 +2233,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt) else { set_stmt_errmsg(stmt, net); - DBUG_RETURN(1); + DBUG_RETURN(1); } /* Reserve place for null-marker bytes */ @@ -2414,9 +2414,9 @@ stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row) buff, sizeof(buff), (uchar*) 0, 0, 1, stmt)) { - /* - Don't set stmt error if stmt->mysql is NULL, as the error in this case - has already been set by mysql_prune_stmt_list(). + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). */ if (stmt->mysql) set_stmt_errmsg(stmt, net); @@ -3110,9 +3110,9 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, buff, sizeof(buff), (uchar*) data, length, 1, stmt)) { - /* - Don't set stmt error if stmt->mysql is NULL, as the error in this case - has already been set by mysql_prune_stmt_list(). + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). */ if (stmt->mysql) set_stmt_errmsg(stmt, &mysql->net); @@ -4337,7 +4337,7 @@ int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt) ((rc= stmt_fetch_row(stmt, row)) && rc != MYSQL_DATA_TRUNCATED)) { stmt->state= MYSQL_STMT_PREPARE_DONE; /* XXX: this is buggy */ - stmt->read_row_func= (rc == MYSQL_NO_DATA) ? + stmt->read_row_func= (rc == MYSQL_NO_DATA) ? stmt_read_row_no_data : stmt_read_row_no_result_set; } else @@ -4586,9 +4586,9 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff), (uchar*) 0, 0, 1, stmt)) { - /* - Don't set stmt error if stmt->mysql is NULL, as the error in this case - has already been set by mysql_prune_stmt_list(). + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). */ if (stmt->mysql) set_stmt_errmsg(stmt, net); @@ -4852,10 +4852,14 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt) mysql->status= MYSQL_STATUS_READY; } int4store(buff, stmt->stmt_id); - if ((rc= stmt_command(mysql, COM_STMT_CLOSE, buff, 4, stmt))) - { - set_stmt_errmsg(stmt, &mysql->net); - } + /* + If stmt_command failed, it would have already raised + error using set_mysql_error. Caller should use + mysql_error() or mysql_errno() to find out details. + Memory allocated for stmt will be released regardless + of the error. + */ + rc= stmt_command(mysql, COM_STMT_CLOSE, buff, 4, stmt); } } diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 9615263..0389c92 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -74,6 +74,13 @@ IF(CMAKE_USE_PTHREADS_INIT AND CMAKE_C_FLAGS MATCHES "-fsanitize=") TARGET_LINK_LIBRARIES(mysys pthread) ENDIF() +if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") + target_compile_options(mysys PRIVATE + -Wno-unused-function # mf_keycache.c:4015 + -Wno-unused-variable # thr_lock.c:1209 + ) +endif() + if(0) ADD_EXECUTABLE(thr_lock thr_lock.c) TARGET_LINK_LIBRARIES(thr_lock mysys) @@ -88,9 +95,9 @@ SET_TARGET_PROPERTIES(base64_test PROPERTIES COMPILE_FLAGS "-DMAIN") TARGET_LINK_LIBRARIES(base64_test mysys) endif() -IF(MSVC) - INSTALL_DEBUG_TARGET(mysys DESTINATION ${INSTALL_LIBDIR}/debug) -ENDIF() +#IF(MSVC) +# INSTALL_DEBUG_TARGET(mysys DESTINATION ${INSTALL_LIBDIR}/debug) +#ENDIF() MY_CHECK_CXX_COMPILER_FLAG("-Wno-deprecated-declarations" HAVE_NO_DEPREC_CONST) diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt index b443b43..70666a8 100644 --- a/strings/CMakeLists.txt +++ b/strings/CMakeLists.txt @@ -1,14 +1,14 @@ # Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. -# +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. -# +# # This program 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 General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -33,5 +33,11 @@ ENDIF() ADD_DEFINITIONS(-DDISABLE_MYSQL_THREAD_H) ADD_CONVENIENCE_LIBRARY(strings ${STRINGS_SOURCES}) +if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") + target_compile_options(strings PRIVATE + -Wno-unused-variable # ctype-ucs2.c:2583 + ) +endif() + ADD_EXECUTABLE(conf_to_src EXCLUDE_FROM_ALL conf_to_src.c) TARGET_LINK_LIBRARIES(conf_to_src strings) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 9403bb4..4d41844 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -482,7 +482,6 @@ rm -f $RBR/%{_bindir}/perror %files -n mysql-connector-c-devel%{product_suffix} -f optional-files-devel %defattr(-, root, root, 0755) %doc %{src_dir}/README -%doc %{src_dir}/Docs/ChangeLog %doc %{license_files_server} %doc %{src_dir}/Docs/INFO_SRC* %doc release/Docs/INFO_BIN* @@ -498,7 +497,6 @@ rm -f $RBR/%{_bindir}/perror %files -n mysql-connector-c-shared%{product_suffix} %defattr(-, root, root, 0755) %doc %{src_dir}/README -%doc %{src_dir}/Docs/ChangeLog %doc %{license_files_server} %doc %{src_dir}/Docs/INFO_SRC* %doc release/Docs/INFO_BIN* diff --git a/testclients/mysql_client_test.c b/testclients/mysql_client_test.c index 1528a5e..2025bc4 100644 --- a/testclients/mysql_client_test.c +++ b/testclients/mysql_client_test.c @@ -6328,10 +6328,17 @@ static void test_temporal_param() if (!opt_silent) printf("\n%lld %f '%s'\n", bigint, real, dec); - /* Check values. */ + /* + Check values. + + Note: there is change in server behavior between 5.6.35 and 5.6.36. + In 5.6.35 the trailing zeros were not present in the string representation + of fractional seconds, in 5.6.36 they are there. Similar for 5.7 server + (did not check exact versions). + */ DIE_UNLESS(bigint == 20011020101100LL); DIE_UNLESS(real == 20011020101059.5); - DIE_UNLESS(!strcmp(dec, "20011020101059.5")); + DIE_UNLESS(!strcmp(dec, "20011020101059.500000")); mysql_stmt_close(stmt); @@ -6375,7 +6382,7 @@ static void test_temporal_param() /* Check returned values */ DIE_UNLESS(bigint == 101100); DIE_UNLESS(real == 101059.5); - DIE_UNLESS(!strcmp(dec, "101059.5")); + DIE_UNLESS(!strcmp(dec, "101059.500000")); mysql_stmt_close(stmt); } diff --git a/vio/CMakeLists.txt b/vio/CMakeLists.txt index d338ea3..ab8769d 100644 --- a/vio/CMakeLists.txt +++ b/vio/CMakeLists.txt @@ -1,19 +1,19 @@ # Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. -# +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. -# +# # This program 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 General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${SSL_INCLUDE_DIRS}) ADD_DEFINITIONS(${SSL_DEFINES}) @@ -33,3 +33,13 @@ ENDIF() ADD_CONVENIENCE_LIBRARY(vio ${VIO_SOURCES}) TARGET_LINK_LIBRARIES(vio ${LIBSOCKET}) + + +if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") + my_check_c_compiler_flag("-Wno-unused-but-set-variable" UNUSED_BUT_SET) + if (UNUSED_BUT_SET) + target_compile_options(vio PRIVATE + -Wno-unused-but-set-variable # viosocket.c:748 + ) + endif() +endif() From 3dbbd6539751460760d915d071269514fe67a834 Mon Sep 17 00:00:00 2001 From: caseymcc Date: Mon, 10 Apr 2017 10:37:34 -0500 Subject: [PATCH 02/14] fix debug build and windows --- cmake/libutils.cmake | 14 +++++++++++--- cmake/os/Windows.cmake | 17 +++-------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index fa41585..a96e857 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -134,7 +134,9 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) SET(OSLIBS) FOREACH(LIB ${LIBS_TO_MERGE}) - GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION) + GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION_${CMAKE_BUILD_TYPE}) + GET_TARGET_PROPERTY(LIB_LOCATION_DEBUG ${LIB} LOCATION_DEBUG) + GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE) IF(NOT LIB_LOCATION) # 3rd party library like libz.so. Make sure that everything @@ -145,6 +147,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) # (can be a static or shared lib) IF(LIB_TYPE STREQUAL "STATIC_LIBRARY") SET(STATIC_LIBS ${STATIC_LIBS} ${LIB_LOCATION}) + SET(STATIC_LIBS_DEBUG ${STATIC_LIBS_DEBUG} ${LIB_LOCATION_DEBUG}) ADD_DEPENDENCIES(${TARGET} ${LIB}) # Extract dependend OS libraries GET_DEPENDEND_OS_LIBS(${LIB} LIB_OSLIBS) @@ -180,10 +183,15 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) FOREACH(LIB ${STATIC_LIBS}) SET(LINKER_EXTRA_FLAGS "${LINKER_EXTRA_FLAGS} ${LIB}") ENDFOREACH() - SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS + FOREACH(LIB ${STATIC_LIBS_DEBUG}) + SET(LINKER_EXTRA_FLAGS_DEBUG "${LINKER_EXTRA_FLAGS_DEBUG} ${LIB}") + ENDFOREACH() + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS_RELEASE "${LINKER_EXTRA_FLAGS}") + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS_DEBUG + "${LINKER_EXTRA_FLAGS_DEBUG}") ELSE() - GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION) + GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION_${CMAKE_BUILD_TYPE}) IF(APPLE) # Use OSX's libtool to merge archives (ihandles universal # binaries properly) diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index 535c199..b5e4df8 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -108,20 +108,9 @@ IF(MSVC) # Allowing inline reduces test time using the debug server by # 30% or so. If you do want to keep inlining off, set the # cmake flag WIN_DEBUG_NO_INLINE. - - OPTION(EMBED_DEBUG_INFO "Use /Z7 compile option to embed debug info into object files" OFF) - MARK_AS_ADVANCED(EMBED_DEBUG_INFO) - - FOREACH(flag - CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT - CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT) - IF (EMBED_DEBUG_INFO) - STRING(REPLACE "/Zi" "/Z7" "${flag}" "${${flag}}") - ENDIF() - IF (NOT WIN_DEBUG_NO_INLINE) - STRING(REPLACE "/Ob0" "/Ob1" "${flag}" "${${flag}}") - ENDIF() - ENDFOREACH(flag) + FOREACH(lang C CXX) + SET(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} /Z7") + ENDFOREACH() # Fix CMake's predefined huge stack size FOREACH(type EXE SHARED MODULE) From 4d9ced344cc2bebb2c7c6f5942aa715f0281f7a2 Mon Sep 17 00:00:00 2001 From: Casey McCandless Date: Thu, 8 Jun 2017 16:53:14 -0500 Subject: [PATCH 03/14] add install config --- cmake/config.cmake.in | 4 ++++ libmysql/CMakeLists.txt | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 cmake/config.cmake.in diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in new file mode 100644 index 0000000..5c79c46 --- /dev/null +++ b/cmake/config.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") +check_required_components("@MYSQL_PACKAGE_NAME@") \ No newline at end of file diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 83eabd9..6bb7601 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -345,6 +345,46 @@ IF(MSVC) ENDIF() ENDIF() +# +# Install config file +# +set(MYSQL_PACKAGE_NAME "MySQL-client") +set(config_install_dir "lib/cmake/${MYSQL_PACKAGE_NAME}") +set(version_config "${CMAKE_CURRENT_BINARY_DIR}/${MYSQL_PACKAGE_NAME}ConfigVersion.cmake") +set(project_config "${CMAKE_CURRENT_BINARY_DIR}/${MYSQL_PACKAGE_NAME}Config.cmake") +set(targets_export_name "${MYSQL_PACKAGE_NAME}Targets") +set(namespace "MySQL::") + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + ${version_config} + VERSION ${VERSION} + COMPATIBILITY SameMajorVersion +) + +configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/../cmake/config.cmake.in" ${project_config} + INSTALL_DESTINATION "${config_install_dir}") + +install( + TARGETS mysqlclient + EXPORT "${targets_export_name}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "include" +) + +install( + FILES "${project_config}" "${version_config}" + DESTINATION "${config_install_dir}" +) + +install( + EXPORT "${targets_export_name}" + NAMESPACE "${namespace}" + DESTINATION "${config_install_dir}" +) + # # Basic application for testing linking against dynamic client library. # From 1d7c66e6efbf8845cf1d79b1915068e734f40ae3 Mon Sep 17 00:00:00 2001 From: caseymcc Date: Fri, 4 Aug 2017 12:22:26 -0500 Subject: [PATCH 04/14] fix conflict --- libmysql/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 6bb7601..fe92c40 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -366,7 +366,7 @@ configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/../cmake/config.cmake.i INSTALL_DESTINATION "${config_install_dir}") install( - TARGETS mysqlclient + TARGETS libmysql EXPORT "${targets_export_name}" LIBRARY DESTINATION "lib" ARCHIVE DESTINATION "lib" From 16c0cb1bc7a6db108f3cbbd3f649c48ec171c9b8 Mon Sep 17 00:00:00 2001 From: Casey McCandless Date: Thu, 13 Jul 2017 10:26:45 -0500 Subject: [PATCH 05/14] add install config --- libmysql/CMakeLists.txt | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index fe92c40..3cae09f 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -385,6 +385,46 @@ install( DESTINATION "${config_install_dir}" ) +# +# Install config file +# +set(MYSQL_PACKAGE_NAME "MySQL-client") +set(config_install_dir "lib/cmake/${MYSQL_PACKAGE_NAME}") +set(version_config "${CMAKE_CURRENT_BINARY_DIR}/${MYSQL_PACKAGE_NAME}ConfigVersion.cmake") +set(project_config "${CMAKE_CURRENT_BINARY_DIR}/${MYSQL_PACKAGE_NAME}Config.cmake") +set(targets_export_name "${MYSQL_PACKAGE_NAME}Targets") +set(namespace "MySQL::") + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + ${version_config} + VERSION ${VERSION} + COMPATIBILITY SameMajorVersion +) + +configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/../cmake/config.cmake.in" ${project_config} + INSTALL_DESTINATION "${config_install_dir}") + +install( + TARGETS libmysql + EXPORT "${targets_export_name}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "include" +) + +install( + FILES "${project_config}" "${version_config}" + DESTINATION "${config_install_dir}" +) + +install( + EXPORT "${targets_export_name}" + NAMESPACE "${namespace}" + DESTINATION "${config_install_dir}" +) + # # Basic application for testing linking against dynamic client library. # From 5918c1c5b0a49f9cd9efc7d9c491c28a741d7634 Mon Sep 17 00:00:00 2001 From: caseymcc Date: Mon, 29 Oct 2018 12:45:36 -0500 Subject: [PATCH 06/14] modified for msvc --- cmake/libutils.cmake | 61 +++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index a96e857..ddec72a 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -133,20 +133,33 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME}) SET(OSLIBS) - FOREACH(LIB ${LIBS_TO_MERGE}) - GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION_${CMAKE_BUILD_TYPE}) - GET_TARGET_PROPERTY(LIB_LOCATION_DEBUG ${LIB} LOCATION_DEBUG) + FOREACH(LIB ${LIBS_TO_MERGE}) + IF(CMAKE_CONFIGURATION_TYPES) + FOREACH(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + GET_TARGET_PROPERTY(LIB_LOCATION_${CONFIG_TYPE} ${LIB} LOCATION_${CONFIG_TYPE}) + ENDFOREACH() + ELSE() + GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION_${CMAKE_BUILD_TYPE}) + ENDIF() + GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE) IF(NOT LIB_LOCATION) - # 3rd party library like libz.so. Make sure that everything - # that links to our library links to this one as well. - LIST(APPEND OSLIBS ${LIB}) + # 3rd party library like libz.so. Make sure that everything + # that links to our library links to this one as well. + LIST(APPEND OSLIBS ${LIB}) ELSE() # This is a target in current project # (can be a static or shared lib) IF(LIB_TYPE STREQUAL "STATIC_LIBRARY") - SET(STATIC_LIBS ${STATIC_LIBS} ${LIB_LOCATION}) + IF(CMAKE_CONFIGURATION_TYPES) + FOREACH(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + SET(STATIC_LIBS_${CONFIG_TYPE} ${STATIC_LIBS_${CONFIG_TYPE}} ${LIB_LOCATION_${CONFIG_TYPE}}) + ENDFOREACH() + ELSE() + SET(STATIC_LIBS ${STATIC_LIBS} ${LIB_LOCATION}) + ENDIF() + SET(STATIC_LIBS_DEBUG ${STATIC_LIBS_DEBUG} ${LIB_LOCATION_DEBUG}) ADD_DEPENDENCIES(${TARGET} ${LIB}) # Extract dependend OS libraries @@ -158,6 +171,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) ENDIF() ENDIF() ENDFOREACH() + IF(OSLIBS) LIST(REMOVE_DUPLICATES OSLIBS) @@ -179,17 +193,28 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) IF(MSVC) # To merge libs, just pass them to lib.exe command line. - SET(LINKER_EXTRA_FLAGS "") - FOREACH(LIB ${STATIC_LIBS}) - SET(LINKER_EXTRA_FLAGS "${LINKER_EXTRA_FLAGS} ${LIB}") - ENDFOREACH() - FOREACH(LIB ${STATIC_LIBS_DEBUG}) - SET(LINKER_EXTRA_FLAGS_DEBUG "${LINKER_EXTRA_FLAGS_DEBUG} ${LIB}") - ENDFOREACH() - SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS_RELEASE - "${LINKER_EXTRA_FLAGS}") - SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS_DEBUG - "${LINKER_EXTRA_FLAGS_DEBUG}") + #set each config flags + IF(CMAKE_CONFIGURATION_TYPES) + FOREACH(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + SET(LINKER_EXTRA_FLAGS_${CONFIG_TYPE} "") + + FOREACH(LIB ${STATIC_LIBS}) + SET(LINKER_EXTRA_FLAGS_${CONFIG_TYPE} "${LINKER_EXTRA_FLAGS_${CONFIG_TYPE}} ${LIB}") + ENDFOREACH() + + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS_${CONFIG_TYPE} + "${LINKER_EXTRA_FLAGS__${CONFIG_TYPE}}") + ENDFOREACH() + ELSE() + SET(LINKER_EXTRA_FLAGS_${CMAKE_BUILD_TYPE} "") + + FOREACH(LIB ${STATIC_LIBS}) + SET(LINKER_EXTRA_FLAGS_${CMAKE_BUILD_TYPE} "${LINKER_EXTRA_FLAGS_${CMAKE_BUILD_TYPE}} ${LIB}") + ENDFOREACH() + + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS_${CMAKE_BUILD_TYPE} + "${LINKER_EXTRA_FLAGS__${CMAKE_BUILD_TYPE}}") + ENDIF() ELSE() GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION_${CMAKE_BUILD_TYPE}) IF(APPLE) From 07656c66c7cf1b450f809c33f893d1cb30be953c Mon Sep 17 00:00:00 2001 From: caseymcc Date: Thu, 1 Nov 2018 13:15:17 -0500 Subject: [PATCH 07/14] fix multi-configurations and ignore gcc warnings --- cmake/libutils.cmake | 154 +++++++++++++++++++--------------------- libmysql/CMakeLists.txt | 4 ++ strings/CMakeLists.txt | 4 ++ 3 files changed, 82 insertions(+), 80 deletions(-) diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index ddec72a..fcb5d5e 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -128,39 +128,48 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) # To produce a library we need at least one source file. # It is created by ADD_CUSTOM_COMMAND below and will # also help to track dependencies. + IF(CMAKE_CONFIGURATION_TYPES) + FOREACH(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + STRING(TOUPPER ${CONFIG_TYPE} CONFIG_TYPE) + SET(CONFIGURATION_TYPES ${CONFIGURATION_TYPES} ${CONFIG_TYPE}) + ENDFOREACH() + ELSE() + STRING(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE) + SET(CONFIGURATION_TYPES ${BUILD_TYPE}) + ENDIF() + SET(SOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_depends.c) ADD_LIBRARY(${TARGET} STATIC ${SOURCE_FILE}) SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME}) - SET(OSLIBS) + # Make the generated dummy source file depended on all static input + # libs. If input lib changes,the source file is touched + # which causes the desired effect (relink). + ADD_CUSTOM_COMMAND( + OUTPUT ${SOURCE_FILE} + COMMAND ${CMAKE_COMMAND} -E touch ${SOURCE_FILE} + DEPENDS ${STATIC_LIBS}) + + FOREACH(CONFIG_TYPE ${CONFIGURATION_TYPES}) + SET(STATIC_LIBS_${CONFIG_TYPE}) + ENDFOREACH() + SET(OSLIBS) FOREACH(LIB ${LIBS_TO_MERGE}) - IF(CMAKE_CONFIGURATION_TYPES) - FOREACH(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - GET_TARGET_PROPERTY(LIB_LOCATION_${CONFIG_TYPE} ${LIB} LOCATION_${CONFIG_TYPE}) - ENDFOREACH() - ELSE() - GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION_${CMAKE_BUILD_TYPE}) - ENDIF() - GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE) + GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION) IF(NOT LIB_LOCATION) - # 3rd party library like libz.so. Make sure that everything - # that links to our library links to this one as well. - LIST(APPEND OSLIBS ${LIB}) + # 3rd party library like libz.so. Make sure that everything + # that links to our library links to this one as well. + LIST(APPEND OSLIBS ${LIB}) ELSE() # This is a target in current project # (can be a static or shared lib) IF(LIB_TYPE STREQUAL "STATIC_LIBRARY") - IF(CMAKE_CONFIGURATION_TYPES) - FOREACH(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - SET(STATIC_LIBS_${CONFIG_TYPE} ${STATIC_LIBS_${CONFIG_TYPE}} ${LIB_LOCATION_${CONFIG_TYPE}}) - ENDFOREACH() - ELSE() - SET(STATIC_LIBS ${STATIC_LIBS} ${LIB_LOCATION}) - ENDIF() - - SET(STATIC_LIBS_DEBUG ${STATIC_LIBS_DEBUG} ${LIB_LOCATION_DEBUG}) + FOREACH(CONFIG_TYPE ${CONFIGURATION_TYPES}) + GET_TARGET_PROPERTY(LIB_LOCATION_${CONFIG_TYPE} ${LIB} LOCATION_${CONFIG_TYPE}) + SET(STATIC_LIBS_${CONFIG_TYPE} ${STATIC_LIBS_${CONFIG_TYPE}} ${LIB_LOCATION_${CONFIG_TYPE}}) + ENDFOREACH() ADD_DEPENDENCIES(${TARGET} ${LIB}) # Extract dependend OS libraries GET_DEPENDEND_OS_LIBS(${LIB} LIB_OSLIBS) @@ -171,76 +180,61 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) ENDIF() ENDIF() ENDFOREACH() - IF(OSLIBS) LIST(REMOVE_DUPLICATES OSLIBS) TARGET_LINK_LIBRARIES(${TARGET} ${OSLIBS}) MESSAGE(STATUS "Library ${TARGET} depends on OSLIBS ${OSLIBS}") ENDIF() - - IF(STATIC_LIBS) - LIST(REMOVE_DUPLICATES STATIC_LIBS) - ENDIF() - - # Make the generated dummy source file depended on all static input - # libs. If input lib changes,the source file is touched - # which causes the desired effect (relink). - ADD_CUSTOM_COMMAND( - OUTPUT ${SOURCE_FILE} - COMMAND ${CMAKE_COMMAND} -E touch ${SOURCE_FILE} - DEPENDS ${STATIC_LIBS}) + + FOREACH(CONFIG_TYPE ${CONFIGURATION_TYPES}) + IF(STATIC_LIBS_${CONFIG_TYPE}) + LIST(REMOVE_DUPLICATES STATIC_LIBS_${CONFIG_TYPE}) + ENDIF() + ENDFOREACH() IF(MSVC) - # To merge libs, just pass them to lib.exe command line. - #set each config flags - IF(CMAKE_CONFIGURATION_TYPES) - FOREACH(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - SET(LINKER_EXTRA_FLAGS_${CONFIG_TYPE} "") - - FOREACH(LIB ${STATIC_LIBS}) - SET(LINKER_EXTRA_FLAGS_${CONFIG_TYPE} "${LINKER_EXTRA_FLAGS_${CONFIG_TYPE}} ${LIB}") - ENDFOREACH() - - SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS_${CONFIG_TYPE} - "${LINKER_EXTRA_FLAGS__${CONFIG_TYPE}}") - ENDFOREACH() - ELSE() - SET(LINKER_EXTRA_FLAGS_${CMAKE_BUILD_TYPE} "") - - FOREACH(LIB ${STATIC_LIBS}) - SET(LINKER_EXTRA_FLAGS_${CMAKE_BUILD_TYPE} "${LINKER_EXTRA_FLAGS_${CMAKE_BUILD_TYPE}} ${LIB}") + # To merge libs, just pass them to lib.exe command line, per build type + FOREACH(CONFIG_TYPE ${CONFIGURATION_TYPES}) + message(STATUS "${CONFIG_TYPE}: ${STATIC_LIBS_${CONFIG_TYPE}}") + SET(LINKER_EXTRA_FLAGS "") + FOREACH(LIB ${STATIC_LIBS_${CONFIG_TYPE}}) + SET(LINKER_EXTRA_FLAGS "${LINKER_EXTRA_FLAGS} ${LIB}") ENDFOREACH() + message(STATUS "${CONFIG_TYPE}: ${LINKER_EXTRA_FLAGS}") + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS_${CONFIG_TYPE} "${LINKER_EXTRA_FLAGS}") - SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS_${CMAKE_BUILD_TYPE} - "${LINKER_EXTRA_FLAGS__${CMAKE_BUILD_TYPE}}") - ENDIF() + ENDFOREACH() ELSE() - GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION_${CMAKE_BUILD_TYPE}) - IF(APPLE) - # Use OSX's libtool to merge archives (ihandles universal - # binaries properly) - ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD - COMMAND rm ${TARGET_LOCATION} - COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION} - ${STATIC_LIBS} - ) - ELSE() - # Generic Unix or MinGW. In post-build step, call - # script, that extracts objects from archives with "ar x" - # and repacks them with "ar r" - SET(TARGET ${TARGET}) - CONFIGURE_FILE( - ${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake - @ONLY - ) - ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD - COMMAND rm ${TARGET_LOCATION} - COMMAND ${CMAKE_COMMAND} -P - ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake - ) - ENDIF() + FOREACH(CONFIG_TYPE ${CONFIGURATION_TYPES}) + GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION_${CONFIG_TYPE}) + SET(STATIC_LIBS ${STATIC_LIBS_${CONFIG_TYPE}}) + + IF(APPLE) + # Use OSX's libtool to merge archives (ihandles universal + # binaries properly) + ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD + COMMAND rm ${TARGET_LOCATION} + COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION} + ${STATIC_LIBS_${CONFIG_TYPE}} + ) + ELSE() + # Generic Unix or MinGW. In post-build step, call + # script, that extracts objects from archives with "ar x" + # and repacks them with "ar r" + SET(TARGET ${TARGET}) + CONFIGURE_FILE( + ${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake + @ONLY + ) + ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD + COMMAND rm ${TARGET_LOCATION} + COMMAND ${CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake + ) + ENDIF() + ENDFOREACH() ENDIF() ENDMACRO() diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 3cae09f..5d1eac2 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -224,6 +224,10 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") ) endif() +IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + target_compile_options(clientlib PRIVATE "-Wno-implicit-fallthrough") +ENDIF() + SET(LIBS clientlib dbug strings vio mysys mysys_ssl ${ZLIB_LIBRARY} ${SSL_LIBRARIES} ${LIBDL}) # diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt index 70666a8..2c65917 100644 --- a/strings/CMakeLists.txt +++ b/strings/CMakeLists.txt @@ -39,5 +39,9 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") ) endif() +IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + target_compile_options(strings PRIVATE "-Wno-implicit-fallthrough") +ENDIF() + ADD_EXECUTABLE(conf_to_src EXCLUDE_FROM_ALL conf_to_src.c) TARGET_LINK_LIBRARIES(conf_to_src strings) From 1f1e22e939d162354c504fe52f24c36dcae2c803 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Mon, 8 Mar 2021 18:11:57 +0000 Subject: [PATCH 08/14] Fixups after rebase of hunter changes on top of merged upstream. --- .gitattributes | 3 +++ cmake/os/Windows.cmake | 17 ++++++++++++++--- libmysql/CMakeLists.txt | 41 ----------------------------------------- 3 files changed, 17 insertions(+), 44 deletions(-) diff --git a/.gitattributes b/.gitattributes index ee812ad..ab88e5b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,9 @@ * text=auto !eol svneol=native#text/plain *.gitattributes text svneol=native#text/plain +# This file must be LF only +sql/share/errmsg-utf8.txt eol=lf + # Scriptish formats *.bat text svneol=native#text/plain *.bsh text svneol=native#text/x-beanshell diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index b5e4df8..535c199 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -108,9 +108,20 @@ IF(MSVC) # Allowing inline reduces test time using the debug server by # 30% or so. If you do want to keep inlining off, set the # cmake flag WIN_DEBUG_NO_INLINE. - FOREACH(lang C CXX) - SET(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} /Z7") - ENDFOREACH() + + OPTION(EMBED_DEBUG_INFO "Use /Z7 compile option to embed debug info into object files" OFF) + MARK_AS_ADVANCED(EMBED_DEBUG_INFO) + + FOREACH(flag + CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT + CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT) + IF (EMBED_DEBUG_INFO) + STRING(REPLACE "/Zi" "/Z7" "${flag}" "${${flag}}") + ENDIF() + IF (NOT WIN_DEBUG_NO_INLINE) + STRING(REPLACE "/Ob0" "/Ob1" "${flag}" "${${flag}}") + ENDIF() + ENDFOREACH(flag) # Fix CMake's predefined huge stack size FOREACH(type EXE SHARED MODULE) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 5d1eac2..64ff9b4 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -388,47 +388,6 @@ install( NAMESPACE "${namespace}" DESTINATION "${config_install_dir}" ) - -# -# Install config file -# -set(MYSQL_PACKAGE_NAME "MySQL-client") -set(config_install_dir "lib/cmake/${MYSQL_PACKAGE_NAME}") -set(version_config "${CMAKE_CURRENT_BINARY_DIR}/${MYSQL_PACKAGE_NAME}ConfigVersion.cmake") -set(project_config "${CMAKE_CURRENT_BINARY_DIR}/${MYSQL_PACKAGE_NAME}Config.cmake") -set(targets_export_name "${MYSQL_PACKAGE_NAME}Targets") -set(namespace "MySQL::") - -include(CMakePackageConfigHelpers) -write_basic_package_version_file( - ${version_config} - VERSION ${VERSION} - COMPATIBILITY SameMajorVersion -) - -configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/../cmake/config.cmake.in" ${project_config} - INSTALL_DESTINATION "${config_install_dir}") - -install( - TARGETS libmysql - EXPORT "${targets_export_name}" - LIBRARY DESTINATION "lib" - ARCHIVE DESTINATION "lib" - RUNTIME DESTINATION "bin" - INCLUDES DESTINATION "include" -) - -install( - FILES "${project_config}" "${version_config}" - DESTINATION "${config_install_dir}" -) - -install( - EXPORT "${targets_export_name}" - NAMESPACE "${namespace}" - DESTINATION "${config_install_dir}" -) - # # Basic application for testing linking against dynamic client library. # From 20241c542a9957916cf6216fcbe5e48e4bb154b3 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Mon, 8 Mar 2021 18:33:20 +0000 Subject: [PATCH 09/14] Add a static library target to exports in addition to shared library target. --- libmysql/CMakeLists.txt | 47 ++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 64ff9b4..af7c7c0 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -286,7 +286,7 @@ ENDIF() IF(NOT DISABLE_SHARED) # Merge several convenience libraries into one big mysqlclient # and link them together into shared library. - MERGE_LIBRARIES(libmysql SHARED ${LIBS} + MERGE_LIBRARIES(mysql_shared SHARED ${LIBS} EXPORTS ${CLIENT_API_FUNCTIONS} ${CLIENT_API_FUNCTIONS_UNDOCUMENTED} COMPONENT SharedLibraries) IF(UNIX) @@ -298,25 +298,25 @@ IF(NOT DISABLE_SHARED) "${SHARED_LIB_MAJOR_VERSION}.${SHARED_LIB_MINOR_VERSION}.${SHARED_LIB_PATCH_VERSION}") ENDIF() # Name of shared library is mysqlclient on Unix - SET_TARGET_PROPERTIES(libmysql PROPERTIES + SET_TARGET_PROPERTIES(mysql_shared PROPERTIES OUTPUT_NAME mysqlclient VERSION "${OS_SHARED_LIB_VERSION}" SOVERSION "${SHARED_LIB_MAJOR_VERSION}") CONFIGURE_FILE(libmysql.ver.in ${CMAKE_CURRENT_BINARY_DIR}/libmysql.ver) IF(APPLE) - SET_TARGET_PROPERTIES(libmysql PROPERTIES + SET_TARGET_PROPERTIES(mysql_shared PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}" ) ENDIF() - GET_TARGET_PROPERTY(libmysql_link_flags libmysql LINK_FLAGS) + GET_TARGET_PROPERTY(libmysql_link_flags mysql_shared LINK_FLAGS) IF(NOT libmysql_link_flag) SET(libmysql_link_flags) ENDIF() SET(libmysql_link_flags "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${libmysql_link_flags}") - SET_TARGET_PROPERTIES(libmysql + SET_TARGET_PROPERTIES(mysql_shared PROPERTIES LINK_FLAGS "${libmysql_link_flags}") IF(LINK_FLAG_NO_UNDEFINED) @@ -324,17 +324,44 @@ IF(NOT DISABLE_SHARED) "${libmysql_link_flags} ${LINK_FLAG_NO_UNDEFINED}") SET(libmysql_link_flags "${libmysql_link_flags} -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/libmysql.ver") - SET_TARGET_PROPERTIES(libmysql + SET_TARGET_PROPERTIES(mysql_shared PROPERTIES LINK_FLAGS "${libmysql_link_flags}") ENDIF() # clean direct output needs to be set several targets have the same name #(mysqlclient in this case) SET_TARGET_PROPERTIES(mysqlclient PROPERTIES CLEAN_DIRECT_OUTPUT 1) - SET_TARGET_PROPERTIES(libmysql PROPERTIES CLEAN_DIRECT_OUTPUT 1) + SET_TARGET_PROPERTIES(mysql_shared PROPERTIES CLEAN_DIRECT_OUTPUT 1) ENDIF() ENDIF() +# Merge several convenience libraries into one big mysqlclient +# and link them together into static library. +MERGE_LIBRARIES(mysql_static STATIC ${LIBS} + COMPONENT StaticLibraries) +IF(UNIX) + # Name of shared library is mysqlclient on Unix + SET_TARGET_PROPERTIES(mysql_static PROPERTIES + OUTPUT_NAME mysql_static + ) + + IF(APPLE) + SET_TARGET_PROPERTIES(mysql_static PROPERTIES + INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}" + ) + ENDIF() + + GET_TARGET_PROPERTY(libmysql_link_flags mysql_static LINK_FLAGS) + IF(NOT libmysql_link_flag) + SET(libmysql_link_flags) + ENDIF() + SET(libmysql_link_flags + "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${libmysql_link_flags}") + SET_TARGET_PROPERTIES(mysql_static + PROPERTIES LINK_FLAGS "${libmysql_link_flags}") + +ENDIF() + # Visual Studio users need debug static library for debug projects IF(MSVC) IF(NOT DISABLE_STATIC) @@ -370,7 +397,7 @@ configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/../cmake/config.cmake.i INSTALL_DESTINATION "${config_install_dir}") install( - TARGETS libmysql + TARGETS mysql_shared mysql_static EXPORT "${targets_export_name}" LIBRARY DESTINATION "lib" ARCHIVE DESTINATION "lib" @@ -419,7 +446,7 @@ IF(LIBRT) ENDIF() IF(DISABLE_SHARED) - TARGET_LINK_LIBRARIES(libmysql_api_test ${LIBS}) + TARGET_LINK_LIBRARIES(libmysql_api_test mysql_static) ELSE() - TARGET_LINK_LIBRARIES(libmysql_api_test libmysql) + TARGET_LINK_LIBRARIES(libmysql_api_test mysql_shared) ENDIF() From eb23a2993f1c11556c5c555bf2af766d32a1a846 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Thu, 16 Dec 2021 17:32:08 +0000 Subject: [PATCH 10/14] Fix bad cmake which is causing cmake 3.22 to puke. --- cmake/install_macros.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake index f39dfb6..8a1bb16 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -362,8 +362,8 @@ FUNCTION(INSTALL_DEBUG_TARGET target) CONFIGURATIONS Release RelWithDebInfo COMPONENT ${ARG_COMPONENT} OPTIONAL) - ENDIF() - ENDFOREACH() + ENDFOREACH() + ENDIF() ENDFUNCTION() From b399fe4d32cc213caa80617e82066e77cc300d78 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Fri, 8 Apr 2022 18:28:30 +0100 Subject: [PATCH 11/14] Add compatibility with externally supplied OpenSSL 1.1. --- mysys_ssl/my_aes_openssl.cc | 36 ++++++++++++++++------------- sql-common/client_authentication.cc | 2 +- vio/viosslfactories.c | 4 ++++ 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/mysys_ssl/my_aes_openssl.cc b/mysys_ssl/my_aes_openssl.cc index 261ba8a..719f7d0 100644 --- a/mysys_ssl/my_aes_openssl.cc +++ b/mysys_ssl/my_aes_openssl.cc @@ -122,7 +122,7 @@ int my_aes_encrypt(const unsigned char *source, uint32 source_length, enum my_aes_opmode mode, const unsigned char *iv, bool padding) { - EVP_CIPHER_CTX ctx; + EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); const EVP_CIPHER *cipher= aes_evp_type(mode); int u_len, f_len; /* The real key to be used for encryption */ @@ -132,23 +132,25 @@ int my_aes_encrypt(const unsigned char *source, uint32 source_length, if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv)) return MY_AES_BAD_DATA; - if (!EVP_EncryptInit(&ctx, cipher, rkey, iv)) + if (!EVP_EncryptInit(ctx, cipher, rkey, iv)) goto aes_error; /* Error */ - if (!EVP_CIPHER_CTX_set_padding(&ctx, padding)) + if (!EVP_CIPHER_CTX_set_padding(ctx, padding)) goto aes_error; /* Error */ - if (!EVP_EncryptUpdate(&ctx, dest, &u_len, source, source_length)) + if (!EVP_EncryptUpdate(ctx, dest, &u_len, source, source_length)) goto aes_error; /* Error */ - if (!EVP_EncryptFinal(&ctx, dest + u_len, &f_len)) + if (!EVP_EncryptFinal(ctx, dest + u_len, &f_len)) goto aes_error; /* Error */ - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_cleanup(ctx); + EVP_CIPHER_CTX_free(ctx); return u_len + f_len; aes_error: /* need to explicitly clean up the error if we want to ignore it */ ERR_clear_error(); - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_cleanup(ctx); + EVP_CIPHER_CTX_free(ctx); return MY_AES_BAD_DATA; } @@ -159,8 +161,8 @@ int my_aes_decrypt(const unsigned char *source, uint32 source_length, bool padding) { - EVP_CIPHER_CTX ctx; - const EVP_CIPHER *cipher= aes_evp_type(mode); + EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); + const EVP_CIPHER* cipher = aes_evp_type(mode); int u_len, f_len; /* The real key to be used for decryption */ @@ -170,24 +172,26 @@ int my_aes_decrypt(const unsigned char *source, uint32 source_length, if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv)) return MY_AES_BAD_DATA; - EVP_CIPHER_CTX_init(&ctx); + EVP_CIPHER_CTX_init(ctx); - if (!EVP_DecryptInit(&ctx, aes_evp_type(mode), rkey, iv)) + if (!EVP_DecryptInit(ctx, aes_evp_type(mode), rkey, iv)) goto aes_error; /* Error */ - if (!EVP_CIPHER_CTX_set_padding(&ctx, padding)) + if (!EVP_CIPHER_CTX_set_padding(ctx, padding)) goto aes_error; /* Error */ - if (!EVP_DecryptUpdate(&ctx, dest, &u_len, source, source_length)) + if (!EVP_DecryptUpdate(ctx, dest, &u_len, source, source_length)) goto aes_error; /* Error */ - if (!EVP_DecryptFinal_ex(&ctx, dest + u_len, &f_len)) + if (!EVP_DecryptFinal_ex(ctx, dest + u_len, &f_len)) goto aes_error; /* Error */ - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_cleanup(ctx); + EVP_CIPHER_CTX_free(ctx); return u_len + f_len; aes_error: /* need to explicitly clean up the error if we want to ignore it */ ERR_clear_error(); - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_cleanup(ctx); + EVP_CIPHER_CTX_free(ctx); return MY_AES_BAD_DATA; } diff --git a/sql-common/client_authentication.cc b/sql-common/client_authentication.cc index a6ff23e..0ffd612 100644 --- a/sql-common/client_authentication.cc +++ b/sql-common/client_authentication.cc @@ -83,7 +83,7 @@ RSA *rsa_init(MYSQL *mysql) if (mysql->options.extension != NULL && mysql->options.extension->server_public_key_path != NULL && - mysql->options.extension->server_public_key_path != '\0') + *mysql->options.extension->server_public_key_path != '\0') { pub_key_file= fopen(mysql->options.extension->server_public_key_path, "r"); diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c index da5449a..b526653 100644 --- a/vio/viosslfactories.c +++ b/vio/viosslfactories.c @@ -121,6 +121,9 @@ static DH *get_dh2048(void) DH *dh; if ((dh=DH_new())) { +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + DH_set0_pqg(dh, BN_bin2bn(dh2048_p, sizeof(dh2048_p), NULL), NULL, BN_bin2bn(dh2048_g, sizeof(dh2048_g), NULL)); +#else dh->p=BN_bin2bn(dh2048_p,sizeof(dh2048_p),NULL); dh->g=BN_bin2bn(dh2048_g,sizeof(dh2048_g),NULL); if (! dh->p || ! dh->g) @@ -128,6 +131,7 @@ static DH *get_dh2048(void) DH_free(dh); dh=0; } +#endif } return(dh); } From c191af22be5daa14b84e85b44c35784bad5faf14 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Mon, 11 Apr 2022 16:50:21 +0100 Subject: [PATCH 12/14] Link to threading library, as if supplying external OpenSSL libraries to use won't link otherwise. --- mysys_ssl/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysys_ssl/CMakeLists.txt b/mysys_ssl/CMakeLists.txt index e78a529..ed7637d 100644 --- a/mysys_ssl/CMakeLists.txt +++ b/mysys_ssl/CMakeLists.txt @@ -43,7 +43,8 @@ SET(MYSYS_SSL_SOURCES ) ADD_CONVENIENCE_LIBRARY(mysys_ssl ${MYSYS_SSL_SOURCES}) -TARGET_LINK_LIBRARIES(mysys_ssl dbug strings ${SSL_LIBRARIES} ${ZLIB_LIBRARY}) +find_package(Threads) +TARGET_LINK_LIBRARIES(mysys_ssl dbug strings ${SSL_LIBRARIES} ${ZLIB_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) # Needed to resolve OpenSSL dependency on Windows IF(WIN32 AND NOT WITH_SSL STREQUAL "bundled") TARGET_LINK_LIBRARIES(mysys_ssl crypt32) From 51c998777b330396c8ef2cd0d0882893840153c5 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Wed, 11 May 2022 21:19:04 +0100 Subject: [PATCH 13/14] If WITH_SSL is specified to cmake, do not bind in a copy of the SSL libraries to the MySQL static library as this will produce symbol collisions in anything consuming the MySQL library and the SSL libraries. Also fix a build failure in debug builds if WITH_SSL is specified. --- cmake/libutils.cmake | 11 ++++++++++- cmake/ssl.cmake | 5 +++-- vio/viossl.c | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index fcb5d5e..c1d6ccf 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -183,7 +183,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) IF(OSLIBS) LIST(REMOVE_DUPLICATES OSLIBS) - TARGET_LINK_LIBRARIES(${TARGET} ${OSLIBS}) + TARGET_LINK_LIBRARIES(${TARGET} PUBLIC ${OSLIBS}) MESSAGE(STATUS "Library ${TARGET} depends on OSLIBS ${OSLIBS}") ENDIF() @@ -255,10 +255,19 @@ MACRO(MERGE_LIBRARIES) SET(LIBS ${ARG_DEFAULT_ARGS}) LIST(REMOVE_AT LIBS 0) IF(ARG_STATIC) + IF(WITH_SSL) + list(REMOVE_ITEM LIBS ${SSL_LIBRARIES}) + endif() IF (NOT ARG_OUTPUT_NAME) SET(ARG_OUTPUT_NAME ${TARGET}) ENDIF() MERGE_STATIC_LIBS(${TARGET} ${ARG_OUTPUT_NAME} "${LIBS}") + if(WITH_SSL) + target_link_libraries(${TARGET} PUBLIC ${SSL_LIBRARIES}) + if(NOT WIN32) + target_link_libraries(${TARGET} PUBLIC pthread) + endif() + endif() ELSEIF(ARG_SHARED OR ARG_MODULE) IF(ARG_SHARED) SET(LIBTYPE SHARED) diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake index 19ac9a6..78c3131 100644 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -152,10 +152,10 @@ MACRO (MYSQL_CHECK_SSL) MESSAGE(STATUS "suffixes <${CMAKE_FIND_LIBRARY_SUFFIXES}>") ENDIF() FIND_LIBRARY(OPENSSL_LIBRARY - NAMES ssl ssleay32 ssleay32MD + NAMES ssl ssleay32 ssleay32MD libssl HINTS ${OPENSSL_ROOT_DIR}/lib) FIND_LIBRARY(CRYPTO_LIBRARY - NAMES crypto libeay32 + NAMES crypto libeay32 libcrypto HINTS ${OPENSSL_ROOT_DIR}/lib) IF (WITH_SSL_PATH) LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES) @@ -207,6 +207,7 @@ MACRO (MYSQL_CHECK_SSL) ENDIF() ENDIF() + MESSAGE(STATUS "OPENSSL_ROOT_DIR = ${OPENSSL_ROOT_DIR}") MESSAGE(STATUS "OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}") MESSAGE(STATUS "OPENSSL_LIBRARY = ${OPENSSL_LIBRARY}") MESSAGE(STATUS "CRYPTO_LIBRARY = ${CRYPTO_LIBRARY}") diff --git a/vio/viossl.c b/vio/viossl.c index 5622cb7..bec3acf 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -407,7 +407,7 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout, sk_SSL_COMP_zero(SSL_COMP_get_compression_methods()); #endif -#if !defined(HAVE_YASSL) && !defined(DBUG_OFF) +#if 0 // !defined(HAVE_YASSL) && !defined(DBUG_OFF) { STACK_OF(SSL_COMP) *ssl_comp_methods = NULL; ssl_comp_methods = SSL_COMP_get_compression_methods(); From 2a7d29e06c283c5d08bcfed9b74ac6f8466923f1 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Mon, 21 Nov 2022 16:44:51 +0000 Subject: [PATCH 14/14] Update cmake to support use with OpenSSL v3 --- cmake/ssl.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 cmake/ssl.cmake diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake old mode 100644 new mode 100755 index 78c3131..50f8671 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -166,17 +166,17 @@ MACRO (MYSQL_CHECK_SSL) # Encoded as MNNFFPPS: major minor fix patch status FILE(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" OPENSSL_VERSION_NUMBER - REGEX "^#[ ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x[0-9].*" + REGEX "^#[ ]*define[\t ]+OPENSSL_VERSION_MAJOR[\t ]+[0-9].*" ) STRING(REGEX REPLACE - "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9]).*$" "\\1" + "^.*OPENSSL_VERSION_MAJOR[\t ]+([0-9]).*$" "\\1" OPENSSL_MAJOR_VERSION "${OPENSSL_VERSION_NUMBER}" ) IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARY AND CRYPTO_LIBRARY AND - OPENSSL_MAJOR_VERSION STREQUAL "1" + OPENSSL_MAJOR_VERSION MATCHES "[2-3]" ) SET(OPENSSL_FOUND TRUE) ELSE()