Skip to content

Commit 79580f4

Browse files
committed
Merge branch '11.1' into 11.2
2 parents 985e3df + b6680e0 commit 79580f4

File tree

371 files changed

+8527
-2453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

371 files changed

+8527
-2453
lines changed

THIRDPARTY

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,3 +1712,32 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
17121712
POSSIBILITY OF SUCH DAMAGE.
17131713

17141714
***************************************************************************
1715+
1716+
%%The following software may be included in this product:
1717+
socketpair.c
1718+
1719+
Copyright 2007, 2010 by Nathan C. Myers <ncm@cantrip.org>
1720+
Redistribution and use in source and binary forms, with or without modification,
1721+
are permitted provided that the following conditions are met:
1722+
1723+
Redistributions of source code must retain the above copyright notice, this
1724+
list of conditions and the following disclaimer.
1725+
1726+
Redistributions in binary form must reproduce the above copyright notice,
1727+
this list of conditions and the following disclaimer in the documentation
1728+
and/or other materials provided with the distribution.
1729+
1730+
The name of the author must not be used to endorse or promote products
1731+
derived from this software without specific prior written permission.
1732+
1733+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1734+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1735+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1736+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1737+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1738+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1739+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1740+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1741+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1742+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1743+
*/

client/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
INCLUDE_DIRECTORIES(
1818
${CMAKE_SOURCE_DIR}/include
19-
${PCRE_INCLUDES}
19+
${PCRE_INCLUDE_DIRS}
2020
${CMAKE_SOURCE_DIR}/mysys_ssl
2121
${ZLIB_INCLUDE_DIR}
2222
${SSL_INCLUDE_DIRS}

client/mysql.cc

Lines changed: 108 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ static int connect_flag=CLIENT_INTERACTIVE;
261261
static my_bool opt_binary_mode= FALSE;
262262
static my_bool opt_connect_expired_password= FALSE;
263263
static int interrupted_query= 0;
264+
#ifdef USE_LIBEDIT_INTERFACE
265+
static int sigint_received= 0;
266+
#endif
264267
static char *current_host,*current_db,*current_user=0,*opt_password=0,
265268
*current_prompt=0, *delimiter_str= 0,
266269
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME,
@@ -1166,6 +1169,8 @@ extern "C" sig_handler handle_sigint(int sig);
11661169
static sig_handler window_resize(int sig);
11671170
#endif
11681171

1172+
static void end_in_sig_handler(int sig);
1173+
static bool kill_query(const char *reason);
11691174

11701175
const char DELIMITER_NAME[]= "delimiter";
11711176
const uint DELIMITER_NAME_LEN= sizeof(DELIMITER_NAME) - 1;
@@ -1305,8 +1310,8 @@ int main(int argc,char *argv[])
13051310
if (opt_sigint_ignore)
13061311
signal(SIGINT, SIG_IGN);
13071312
else
1308-
signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
1309-
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up
1313+
signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
1314+
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up
13101315

13111316
#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
13121317
/* Readline will call this if it installs a handler */
@@ -1528,30 +1533,35 @@ static bool do_connect(MYSQL *mysql, const char *host, const char *user,
15281533
}
15291534

15301535

1531-
/*
1532-
This function handles sigint calls
1533-
If query is in process, kill query
1534-
If 'source' is executed, abort source command
1535-
no query in process, terminate like previous behavior
1536-
*/
1536+
void end_in_sig_handler(int sig)
1537+
{
1538+
#ifdef _WIN32
1539+
/*
1540+
When SIGINT is raised on Windows, the OS creates a new thread to handle the
1541+
interrupt. Once that thread completes, the main thread continues running
1542+
only to find that it's resources have already been free'd when the sigint
1543+
handler called mysql_end().
1544+
*/
1545+
mysql_thread_end();
1546+
#else
1547+
mysql_end(sig);
1548+
#endif
1549+
}
15371550

1538-
sig_handler handle_sigint(int sig)
1551+
1552+
/*
1553+
Kill a running query. Returns true if we were unable to connect to the server.
1554+
*/
1555+
bool kill_query(const char *reason)
15391556
{
15401557
char kill_buffer[40];
15411558
MYSQL *kill_mysql= NULL;
15421559

1543-
/* terminate if no query being executed, or we already tried interrupting */
1544-
if (!executing_query || (interrupted_query == 2))
1545-
{
1546-
tee_fprintf(stdout, "Ctrl-C -- exit!\n");
1547-
goto err;
1548-
}
1549-
15501560
kill_mysql= mysql_init(kill_mysql);
15511561
if (!do_connect(kill_mysql,current_host, current_user, opt_password, "", 0))
15521562
{
1553-
tee_fprintf(stdout, "Ctrl-C -- sorry, cannot connect to server to kill query, giving up ...\n");
1554-
goto err;
1563+
tee_fprintf(stdout, "%s -- sorry, cannot connect to server to kill query, giving up ...\n", reason);
1564+
return true;
15551565
}
15561566

15571567
/* First time try to kill the query, second time the connection */
@@ -1566,27 +1576,62 @@ sig_handler handle_sigint(int sig)
15661576
(interrupted_query == 1) ? "QUERY " : "",
15671577
mysql_thread_id(&mysql));
15681578
if (verbose)
1569-
tee_fprintf(stdout, "Ctrl-C -- sending \"%s\" to server ...\n",
1579+
tee_fprintf(stdout, "%s -- sending \"%s\" to server ...\n", reason,
15701580
kill_buffer);
15711581
mysql_real_query(kill_mysql, kill_buffer, (uint) strlen(kill_buffer));
15721582
mysql_close(kill_mysql);
1573-
tee_fprintf(stdout, "Ctrl-C -- query killed. Continuing normally.\n");
1583+
if (interrupted_query == 1)
1584+
tee_fprintf(stdout, "%s -- query killed.\n", reason);
1585+
else
1586+
tee_fprintf(stdout, "%s -- connection killed.\n", reason);
1587+
15741588
if (in_com_source)
15751589
aborted= 1; // Abort source command
1576-
return;
1590+
return false;
1591+
}
15771592

1578-
err:
1579-
#ifdef _WIN32
1593+
/*
1594+
This function handles sigint calls
1595+
If query is in process, kill query
1596+
If 'source' is executed, abort source command
1597+
no query in process, regenerate prompt.
1598+
*/
1599+
sig_handler handle_sigint(int sig)
1600+
{
15801601
/*
1581-
When SIGINT is raised on Windows, the OS creates a new thread to handle the
1582-
interrupt. Once that thread completes, the main thread continues running
1583-
only to find that it's resources have already been free'd when the sigint
1584-
handler called mysql_end().
1602+
On Unix only, if no query is being executed just clear the prompt,
1603+
don't exit. On Windows we exit.
15851604
*/
1586-
mysql_thread_end();
1605+
if (!executing_query)
1606+
{
1607+
#ifndef _WIN32
1608+
tee_fprintf(stdout, "^C\n");
1609+
#ifdef USE_LIBEDIT_INTERFACE
1610+
/* Libedit will regenerate it outside of the signal handler. */
1611+
sigint_received= 1;
15871612
#else
1588-
mysql_end(sig);
1589-
#endif
1613+
rl_on_new_line(); // Regenerate the prompt on a newline
1614+
rl_replace_line("", 0); // Clear the previous text
1615+
rl_redisplay();
1616+
#endif
1617+
#else // WIN32
1618+
tee_fprintf(stdout, "Ctrl-C -- exit!\n");
1619+
end_in_sig_handler(sig);
1620+
#endif
1621+
return;
1622+
}
1623+
1624+
/*
1625+
When executing a query, this newline makes the prompt look like so:
1626+
^C
1627+
Ctrl-C -- query killed.
1628+
*/
1629+
tee_fprintf(stdout, "\n");
1630+
if (kill_query("Ctrl-C"))
1631+
{
1632+
aborted= 1;
1633+
end_in_sig_handler(sig);
1634+
}
15901635
}
15911636

15921637

@@ -2157,6 +2202,15 @@ static int get_options(int argc, char **argv)
21572202
return(0);
21582203
}
21592204

2205+
2206+
#if !defined(_WIN32) && defined(USE_LIBEDIT_INTERFACE)
2207+
static inline void reset_prompt(char *in_string, bool *ml_comment) {
2208+
glob_buffer.length(0);
2209+
*ml_comment = false;
2210+
*in_string = 0;
2211+
}
2212+
#endif
2213+
21602214
static int read_and_execute(bool interactive)
21612215
{
21622216
char *line= NULL;
@@ -2248,7 +2302,30 @@ static int read_and_execute(bool interactive)
22482302
if (line)
22492303
free(line);
22502304
line= readline(prompt);
2251-
#endif /* defined(_WIN32) */
2305+
#ifdef USE_LIBEDIT_INTERFACE
2306+
/*
2307+
libedit handles interrupts different than libreadline.
2308+
libreadline has its own signal handlers, thus a sigint during readline
2309+
doesn't force readline to return null string.
2310+
2311+
However libedit returns null if the interrupt signal is raised.
2312+
We can also get an empty string when ctrl+d is pressed (EoF).
2313+
2314+
We need this sigint_received flag, to differentiate between the two
2315+
cases. This flag is only set during our handle_sigint function when
2316+
LIBEDIT_INTERFACE is used.
2317+
*/
2318+
if (!line && sigint_received)
2319+
{
2320+
// User asked to clear the input.
2321+
sigint_received= 0;
2322+
reset_prompt(&in_string, &ml_comment);
2323+
continue;
2324+
}
2325+
// For safety, we always mark this as cleared.
2326+
sigint_received= 0;
2327+
#endif
2328+
#endif /* defined(__WIN__) */
22522329

22532330
/*
22542331
When Ctrl+d or Ctrl+z is pressed, the line may be NULL on some OS

client/mysqltest.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4698,15 +4698,11 @@ void do_perl(struct st_command *command)
46984698

46994699
/* Check for error code that indicates perl could not be started */
47004700
int exstat= WEXITSTATUS(error);
4701-
#ifdef _WIN32
4702-
if (exstat == 1)
4703-
/* Text must begin 'perl not found' as mtr looks for it */
4704-
abort_not_supported_test("perl not found in path or did not start");
4705-
#else
4701+
#ifndef _WIN32
47064702
if (exstat == 127)
47074703
abort_not_supported_test("perl not found in path");
4708-
#endif
47094704
else
4705+
#endif
47104706
handle_command_error(command, exstat, my_errno);
47114707
}
47124708
dynstr_free(&ds_delimiter);

cmake/libfmt.cmake

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
INCLUDE (CheckCXXSourceCompiles)
1+
INCLUDE (CheckCXXSourceRuns)
22
INCLUDE (ExternalProject)
33

44
SET(WITH_LIBFMT "auto" CACHE STRING
@@ -27,17 +27,15 @@ ENDMACRO()
2727
MACRO (CHECK_LIBFMT)
2828
IF(WITH_LIBFMT STREQUAL "system" OR WITH_LIBFMT STREQUAL "auto")
2929
SET(CMAKE_REQUIRED_INCLUDES ${LIBFMT_INCLUDE_DIR})
30-
CHECK_CXX_SOURCE_COMPILES(
30+
CHECK_CXX_SOURCE_RUNS(
3131
"#define FMT_STATIC_THOUSANDS_SEPARATOR ','
3232
#define FMT_HEADER_ONLY 1
3333
#include <fmt/format-inl.h>
34-
#include <iostream>
3534
int main() {
36-
int answer= 42;
35+
int answer= 4321;
3736
fmt::format_args::format_arg arg=
3837
fmt::detail::make_arg<fmt::format_context>(answer);
39-
std::cout << fmt::vformat(\"The answer is {}.\",
40-
fmt::format_args(&arg, 1));
38+
return fmt::vformat(\"{:L}\", fmt::format_args(&arg, 1)).compare(\"4,321\");
4139
}" HAVE_SYSTEM_LIBFMT)
4240
SET(CMAKE_REQUIRED_INCLUDES)
4341
ENDIF()

cmake/os/AIX.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@ ELSE()
3434
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -maix64 -pthread -mcmodel=large")
3535
ENDIF()
3636

37+
# fcntl(fd, F_SETFL, O_DIRECT) is not supported; O_DIRECT is an open(2) flag
38+
SET(HAVE_FCNTL_DIRECT 0 CACHE INTERNAL "")
39+
3740
# make it WARN by default, not AUTO (that implies -Werror)
3841
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)")

cmake/os/SunOS.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ INCLUDE(CheckSymbolExists)
1717
INCLUDE(CheckCSourceRuns)
1818
INCLUDE(CheckCSourceCompiles)
1919

20+
# fcntl(fd, F_SETFL, O_DIRECT) is not supported,
21+
# and directio(3C) would only work on UFS or NFS, not ZFS.
22+
SET(HAVE_FCNTL_DIRECT 0 CACHE INTERNAL "")
23+
2024
# Enable 64 bit file offsets
2125
SET(_FILE_OFFSET_BITS 64)
2226

cmake/os/WindowsCache.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ SET(HAVE_EXECINFO_H CACHE INTERNAL "")
4444
SET(HAVE_FCHMOD CACHE INTERNAL "")
4545
SET(HAVE_FCNTL CACHE INTERNAL "")
4646
SET(HAVE_FCNTL_H 1 CACHE INTERNAL "")
47+
SET(HAVE_FCNTL_DIRECT 0 CACHE INTERNAL "")
4748
SET(HAVE_FCNTL_NONBLOCK CACHE INTERNAL "")
4849
SET(HAVE_FDATASYNC CACHE INTERNAL "")
4950
SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "")
@@ -242,7 +243,6 @@ SET(HAVE_TERMCAP_H CACHE INTERNAL "")
242243
SET(HAVE_TERMIOS_H CACHE INTERNAL "")
243244
SET(HAVE_TERMIO_H CACHE INTERNAL "")
244245
SET(HAVE_TERM_H CACHE INTERNAL "")
245-
SET(HAVE_THR_SETCONCURRENCY CACHE INTERNAL "")
246246
SET(HAVE_THR_YIELD CACHE INTERNAL "")
247247
SET(HAVE_TIME 1 CACHE INTERNAL "")
248248
SET(HAVE_TIMES CACHE INTERNAL "")

cmake/package_name.cmake

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ IF(NOT VERSION)
102102
SET(DEFAULT_MACHINE "${CMAKE_OSX_ARCHITECTURES}")
103103
ENDIF()
104104
ELSE()
105-
IF(64BIT)
106-
SET(DEFAULT_MACHINE "x86_64")
107-
ELSE()
108-
SET(DEFAULT_MACHINE "i386")
109-
ENDIF()
105+
SET(DEFAULT_MACHINE ${CMAKE_SYSTEM_PROCESSOR})
110106
ENDIF()
111107

112108
IF(DEFAULT_MACHINE MATCHES "i386")

cmake/pcre.cmake

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
INCLUDE (CheckCSourceRuns)
21
INCLUDE (ExternalProject)
32

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

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

7878
MACRO (CHECK_PCRE)
79-
IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto")
80-
CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "" HAVE_PCRE2)
81-
ENDIF()
82-
IF(NOT HAVE_PCRE2 OR WITH_PCRE STREQUAL "bundled")
83-
IF (WITH_PCRE STREQUAL "system")
84-
MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable")
79+
IF (NOT TARGET pcre2 AND NOT PCRE_FOUND)
80+
IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto")
81+
FIND_PACKAGE(PkgConfig QUIET)
82+
PKG_CHECK_MODULES(PCRE libpcre2-8)
83+
# in case pkg-config or libpcre2-8.pc is not installed:
84+
CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "${PCRE_LIBRARY_DIRS}" HAVE_PCRE2_MATCH_8)
8585
ENDIF()
86-
BUNDLE_PCRE2()
87-
ELSE()
88-
CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "" NEEDS_PCRE2_DEBIAN_HACK)
89-
IF(NEEDS_PCRE2_DEBIAN_HACK)
90-
SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree")
86+
IF(NOT HAVE_PCRE2_MATCH_8 OR WITH_PCRE STREQUAL "bundled")
87+
IF (WITH_PCRE STREQUAL "system")
88+
MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable")
89+
ENDIF()
90+
BUNDLE_PCRE2()
91+
ELSE()
92+
CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "${PCRE_LIBRARY_DIRS}" NEEDS_PCRE2_DEBIAN_HACK)
93+
IF(NEEDS_PCRE2_DEBIAN_HACK)
94+
SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree")
95+
ENDIF()
9196
ENDIF()
9297
ENDIF()
9398
ENDMACRO()

0 commit comments

Comments
 (0)