Skip to content

Commit

Permalink
Merge branch '11.3' into 11.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Feb 15, 2024
2 parents 3ae6680 + 068a681 commit fa69b08
Show file tree
Hide file tree
Showing 400 changed files with 10,550 additions and 2,521 deletions.
29 changes: 29 additions & 0 deletions THIRDPARTY
Expand Up @@ -1712,3 +1712,32 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

***************************************************************************

%%The following software may be included in this product:
socketpair.c

Copyright 2007, 2010 by Nathan C. Myers <ncm@cantrip.org>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

The name of the author must not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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.
*/
4 changes: 2 additions & 2 deletions VERSION
@@ -1,4 +1,4 @@
MYSQL_VERSION_MAJOR=11
MYSQL_VERSION_MINOR=4
MYSQL_VERSION_PATCH=0
SERVER_MATURITY=alpha
MYSQL_VERSION_PATCH=1
SERVER_MATURITY=gamma
2 changes: 1 addition & 1 deletion client/CMakeLists.txt
Expand Up @@ -16,7 +16,7 @@

INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
${PCRE_INCLUDES}
${PCRE_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/mysys_ssl
${ZLIB_INCLUDE_DIR}
${SSL_INCLUDE_DIRS}
Expand Down
139 changes: 108 additions & 31 deletions client/mysql.cc
Expand Up @@ -261,6 +261,9 @@ static int connect_flag=CLIENT_INTERACTIVE;
static my_bool opt_binary_mode= FALSE;
static my_bool opt_connect_expired_password= FALSE;
static int interrupted_query= 0;
#ifdef USE_LIBEDIT_INTERFACE
static int sigint_received= 0;
#endif
static char *current_host,*current_db,*current_user=0,*opt_password=0,
*current_prompt=0, *delimiter_str= 0,
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME,
Expand Down Expand Up @@ -1166,6 +1169,8 @@ extern "C" sig_handler handle_sigint(int sig);
static sig_handler window_resize(int sig);
#endif

static void end_in_sig_handler(int sig);
static bool kill_query(const char *reason);

const char DELIMITER_NAME[]= "delimiter";
const uint DELIMITER_NAME_LEN= sizeof(DELIMITER_NAME) - 1;
Expand Down Expand Up @@ -1306,8 +1311,8 @@ int main(int argc,char *argv[])
if (opt_sigint_ignore)
signal(SIGINT, SIG_IGN);
else
signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up
signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up

#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
/* Readline will call this if it installs a handler */
Expand Down Expand Up @@ -1518,30 +1523,35 @@ static bool do_connect(MYSQL *mysql, const char *host, const char *user,
}


/*
This function handles sigint calls
If query is in process, kill query
If 'source' is executed, abort source command
no query in process, terminate like previous behavior
*/
void end_in_sig_handler(int sig)
{
#ifdef _WIN32
/*
When SIGINT is raised on Windows, the OS creates a new thread to handle the
interrupt. Once that thread completes, the main thread continues running
only to find that it's resources have already been free'd when the sigint
handler called mysql_end().
*/
mysql_thread_end();
#else
mysql_end(sig);
#endif
}

sig_handler handle_sigint(int sig)

/*
Kill a running query. Returns true if we were unable to connect to the server.
*/
bool kill_query(const char *reason)
{
char kill_buffer[40];
MYSQL *kill_mysql= NULL;

/* terminate if no query being executed, or we already tried interrupting */
if (!executing_query || (interrupted_query == 2))
{
tee_fprintf(stdout, "Ctrl-C -- exit!\n");
goto err;
}

kill_mysql= mysql_init(kill_mysql);
if (!do_connect(kill_mysql,current_host, current_user, opt_password, "", 0))
{
tee_fprintf(stdout, "Ctrl-C -- sorry, cannot connect to server to kill query, giving up ...\n");
goto err;
tee_fprintf(stdout, "%s -- sorry, cannot connect to server to kill query, giving up ...\n", reason);
return true;
}

/* First time try to kill the query, second time the connection */
Expand All @@ -1556,27 +1566,62 @@ sig_handler handle_sigint(int sig)
(interrupted_query == 1) ? "QUERY " : "",
mysql_thread_id(&mysql));
if (verbose)
tee_fprintf(stdout, "Ctrl-C -- sending \"%s\" to server ...\n",
tee_fprintf(stdout, "%s -- sending \"%s\" to server ...\n", reason,
kill_buffer);
mysql_real_query(kill_mysql, kill_buffer, (uint) strlen(kill_buffer));
mysql_close(kill_mysql);
tee_fprintf(stdout, "Ctrl-C -- query killed. Continuing normally.\n");
if (interrupted_query == 1)
tee_fprintf(stdout, "%s -- query killed.\n", reason);
else
tee_fprintf(stdout, "%s -- connection killed.\n", reason);

if (in_com_source)
aborted= 1; // Abort source command
return;
return false;
}

err:
#ifdef _WIN32
/*
This function handles sigint calls
If query is in process, kill query
If 'source' is executed, abort source command
no query in process, regenerate prompt.
*/
sig_handler handle_sigint(int sig)
{
/*
When SIGINT is raised on Windows, the OS creates a new thread to handle the
interrupt. Once that thread completes, the main thread continues running
only to find that it's resources have already been free'd when the sigint
handler called mysql_end().
On Unix only, if no query is being executed just clear the prompt,
don't exit. On Windows we exit.
*/
mysql_thread_end();
if (!executing_query)
{
#ifndef _WIN32
tee_fprintf(stdout, "^C\n");
#ifdef USE_LIBEDIT_INTERFACE
/* Libedit will regenerate it outside of the signal handler. */
sigint_received= 1;
#else
mysql_end(sig);
#endif
rl_on_new_line(); // Regenerate the prompt on a newline
rl_replace_line("", 0); // Clear the previous text
rl_redisplay();
#endif
#else // WIN32
tee_fprintf(stdout, "Ctrl-C -- exit!\n");
end_in_sig_handler(sig);
#endif
return;
}

/*
When executing a query, this newline makes the prompt look like so:
^C
Ctrl-C -- query killed.
*/
tee_fprintf(stdout, "\n");
if (kill_query("Ctrl-C"))
{
aborted= 1;
end_in_sig_handler(sig);
}
}


Expand Down Expand Up @@ -2147,6 +2192,15 @@ static int get_options(int argc, char **argv)
return(0);
}


#if !defined(_WIN32) && defined(USE_LIBEDIT_INTERFACE)
static inline void reset_prompt(char *in_string, bool *ml_comment) {
glob_buffer.length(0);
*ml_comment = false;
*in_string = 0;
}
#endif

static int read_and_execute(bool interactive)
{
char *line= NULL;
Expand Down Expand Up @@ -2238,7 +2292,30 @@ static int read_and_execute(bool interactive)
if (line)
free(line);
line= readline(prompt);
#endif /* defined(_WIN32) */
#ifdef USE_LIBEDIT_INTERFACE
/*
libedit handles interrupts different than libreadline.
libreadline has its own signal handlers, thus a sigint during readline
doesn't force readline to return null string.
However libedit returns null if the interrupt signal is raised.
We can also get an empty string when ctrl+d is pressed (EoF).
We need this sigint_received flag, to differentiate between the two
cases. This flag is only set during our handle_sigint function when
LIBEDIT_INTERFACE is used.
*/
if (!line && sigint_received)
{
// User asked to clear the input.
sigint_received= 0;
reset_prompt(&in_string, &ml_comment);
continue;
}
// For safety, we always mark this as cleared.
sigint_received= 0;
#endif
#endif /* defined(__WIN__) */

/*
When Ctrl+d or Ctrl+z is pressed, the line may be NULL on some OS
Expand Down
8 changes: 2 additions & 6 deletions client/mysqltest.cc
Expand Up @@ -4706,15 +4706,11 @@ void do_perl(struct st_command *command)

/* Check for error code that indicates perl could not be started */
int exstat= WEXITSTATUS(error);
#ifdef _WIN32
if (exstat == 1)
/* Text must begin 'perl not found' as mtr looks for it */
abort_not_supported_test("perl not found in path or did not start");
#else
#ifndef _WIN32
if (exstat == 127)
abort_not_supported_test("perl not found in path");
#endif
else
#endif
handle_command_error(command, exstat, my_errno);
}
dynstr_free(&ds_delimiter);
Expand Down
10 changes: 4 additions & 6 deletions cmake/libfmt.cmake
@@ -1,4 +1,4 @@
INCLUDE (CheckCXXSourceCompiles)
INCLUDE (CheckCXXSourceRuns)
INCLUDE (ExternalProject)

SET(WITH_LIBFMT "auto" CACHE STRING
Expand Down Expand Up @@ -27,17 +27,15 @@ ENDMACRO()
MACRO (CHECK_LIBFMT)
IF(WITH_LIBFMT STREQUAL "system" OR WITH_LIBFMT STREQUAL "auto")
SET(CMAKE_REQUIRED_INCLUDES ${LIBFMT_INCLUDE_DIR})
CHECK_CXX_SOURCE_COMPILES(
CHECK_CXX_SOURCE_RUNS(
"#define FMT_STATIC_THOUSANDS_SEPARATOR ','
#define FMT_HEADER_ONLY 1
#include <fmt/format-inl.h>
#include <iostream>
int main() {
int answer= 42;
int answer= 4321;
fmt::format_args::format_arg arg=
fmt::detail::make_arg<fmt::format_context>(answer);
std::cout << fmt::vformat(\"The answer is {}.\",
fmt::format_args(&arg, 1));
return fmt::vformat(\"{:L}\", fmt::format_args(&arg, 1)).compare(\"4,321\");
}" HAVE_SYSTEM_LIBFMT)
SET(CMAKE_REQUIRED_INCLUDES)
ENDIF()
Expand Down
3 changes: 3 additions & 0 deletions cmake/os/AIX.cmake
Expand Up @@ -34,5 +34,8 @@ ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -maix64 -pthread -mcmodel=large")
ENDIF()

# fcntl(fd, F_SETFL, O_DIRECT) is not supported; O_DIRECT is an open(2) flag
SET(HAVE_FCNTL_DIRECT 0 CACHE INTERNAL "")

# make it WARN by default, not AUTO (that implies -Werror)
SET(MYSQL_MAINTAINER_MODE "WARN" CACHE STRING "Enable MariaDB maintainer-specific warnings. One of: NO (warnings are disabled) WARN (warnings are enabled) ERR (warnings are errors) AUTO (warnings are errors in Debug only)")
4 changes: 4 additions & 0 deletions cmake/os/SunOS.cmake
Expand Up @@ -17,6 +17,10 @@ INCLUDE(CheckSymbolExists)
INCLUDE(CheckCSourceRuns)
INCLUDE(CheckCSourceCompiles)

# fcntl(fd, F_SETFL, O_DIRECT) is not supported,
# and directio(3C) would only work on UFS or NFS, not ZFS.
SET(HAVE_FCNTL_DIRECT 0 CACHE INTERNAL "")

# Enable 64 bit file offsets
SET(_FILE_OFFSET_BITS 64)

Expand Down
2 changes: 1 addition & 1 deletion cmake/os/WindowsCache.cmake
Expand Up @@ -43,6 +43,7 @@ SET(HAVE_EXECINFO_H CACHE INTERNAL "")
SET(HAVE_FCHMOD CACHE INTERNAL "")
SET(HAVE_FCNTL CACHE INTERNAL "")
SET(HAVE_FCNTL_H 1 CACHE INTERNAL "")
SET(HAVE_FCNTL_DIRECT 0 CACHE INTERNAL "")
SET(HAVE_FCNTL_NONBLOCK CACHE INTERNAL "")
SET(HAVE_FDATASYNC CACHE INTERNAL "")
SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "")
Expand Down Expand Up @@ -241,7 +242,6 @@ SET(HAVE_TERMCAP_H CACHE INTERNAL "")
SET(HAVE_TERMIOS_H CACHE INTERNAL "")
SET(HAVE_TERMIO_H CACHE INTERNAL "")
SET(HAVE_TERM_H CACHE INTERNAL "")
SET(HAVE_THR_SETCONCURRENCY CACHE INTERNAL "")
SET(HAVE_THR_YIELD CACHE INTERNAL "")
SET(HAVE_TIME 1 CACHE INTERNAL "")
SET(HAVE_TIMES CACHE INTERNAL "")
Expand Down
6 changes: 1 addition & 5 deletions cmake/package_name.cmake
Expand Up @@ -102,11 +102,7 @@ IF(NOT VERSION)
SET(DEFAULT_MACHINE "${CMAKE_OSX_ARCHITECTURES}")
ENDIF()
ELSE()
IF(64BIT)
SET(DEFAULT_MACHINE "x86_64")
ELSE()
SET(DEFAULT_MACHINE "i386")
ENDIF()
SET(DEFAULT_MACHINE ${CMAKE_SYSTEM_PROCESSOR})
ENDIF()

IF(DEFAULT_MACHINE MATCHES "i386")
Expand Down
31 changes: 18 additions & 13 deletions cmake/pcre.cmake
@@ -1,12 +1,12 @@
INCLUDE (CheckCSourceRuns)
INCLUDE (ExternalProject)

SET(WITH_PCRE "auto" CACHE STRING
"Which pcre to use (possible values are 'bundled', 'system', or 'auto')")

MACRO(BUNDLE_PCRE2)
SET(dir "${CMAKE_BINARY_DIR}/extra/pcre2")
SET(PCRE_INCLUDES ${dir}/src/pcre2-build ${dir}/src/pcre2/src)
SET(PCRE_INCLUDE_DIRS ${dir}/src/pcre2-build ${dir}/src/pcre2/src)
MESSAGE(STATUS "Will download and bundle pcre2")
SET(byproducts)
FOREACH(lib pcre2-posix pcre2-8)
ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL)
Expand Down Expand Up @@ -76,18 +76,23 @@ SET_TARGET_PROPERTIES(pcre2 PROPERTIES EXCLUDE_FROM_ALL TRUE)
ENDMACRO()

MACRO (CHECK_PCRE)
IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto")
CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "" HAVE_PCRE2)
ENDIF()
IF(NOT HAVE_PCRE2 OR WITH_PCRE STREQUAL "bundled")
IF (WITH_PCRE STREQUAL "system")
MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable")
IF (NOT TARGET pcre2 AND NOT PCRE_FOUND)
IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto")
FIND_PACKAGE(PkgConfig QUIET)
PKG_CHECK_MODULES(PCRE libpcre2-8)
# in case pkg-config or libpcre2-8.pc is not installed:
CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "${PCRE_LIBRARY_DIRS}" HAVE_PCRE2_MATCH_8)
ENDIF()
BUNDLE_PCRE2()
ELSE()
CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "" NEEDS_PCRE2_DEBIAN_HACK)
IF(NEEDS_PCRE2_DEBIAN_HACK)
SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree")
IF(NOT HAVE_PCRE2_MATCH_8 OR WITH_PCRE STREQUAL "bundled")
IF (WITH_PCRE STREQUAL "system")
MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable")
ENDIF()
BUNDLE_PCRE2()
ELSE()
CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "${PCRE_LIBRARY_DIRS}" NEEDS_PCRE2_DEBIAN_HACK)
IF(NEEDS_PCRE2_DEBIAN_HACK)
SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree")
ENDIF()
ENDIF()
ENDIF()
ENDMACRO()
Expand Down

0 comments on commit fa69b08

Please sign in to comment.