Skip to content

Commit 25c0806

Browse files
committed
Merge branch '10.5' into 10.6
2 parents 4dbf55b + 50107c4 commit 25c0806

Some content is hidden

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

70 files changed

+1401
-698
lines changed

client/mysql.cc

Lines changed: 112 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ static int connect_flag=CLIENT_INTERACTIVE;
171171
static my_bool opt_binary_mode= FALSE;
172172
static my_bool opt_connect_expired_password= FALSE;
173173
static int interrupted_query= 0;
174+
#ifdef USE_LIBEDIT_INTERFACE
175+
static int sigint_received= 0;
176+
#endif
174177
static char *current_host,*current_db,*current_user=0,*opt_password=0,
175178
*current_prompt=0, *delimiter_str= 0,
176179
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME,
@@ -1073,6 +1076,8 @@ extern "C" sig_handler handle_sigint(int sig);
10731076
static sig_handler window_resize(int sig);
10741077
#endif
10751078

1079+
static void end_in_sig_handler(int sig);
1080+
static bool kill_query(const char *reason);
10761081

10771082
const char DELIMITER_NAME[]= "delimiter";
10781083
const uint DELIMITER_NAME_LEN= sizeof(DELIMITER_NAME) - 1;
@@ -1212,8 +1217,8 @@ int main(int argc,char *argv[])
12121217
if (opt_sigint_ignore)
12131218
signal(SIGINT, SIG_IGN);
12141219
else
1215-
signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
1216-
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up
1220+
signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
1221+
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up
12171222

12181223
#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
12191224
/* Readline will call this if it installs a handler */
@@ -1379,30 +1384,35 @@ static bool do_connect(MYSQL *mysql, const char *host, const char *user,
13791384
}
13801385

13811386

1382-
/*
1383-
This function handles sigint calls
1384-
If query is in process, kill query
1385-
If 'source' is executed, abort source command
1386-
no query in process, terminate like previous behavior
1387-
*/
1387+
void end_in_sig_handler(int sig)
1388+
{
1389+
#ifdef _WIN32
1390+
/*
1391+
When SIGINT is raised on Windows, the OS creates a new thread to handle the
1392+
interrupt. Once that thread completes, the main thread continues running
1393+
only to find that it's resources have already been free'd when the sigint
1394+
handler called mysql_end().
1395+
*/
1396+
mysql_thread_end();
1397+
#else
1398+
mysql_end(sig);
1399+
#endif
1400+
}
13881401

1389-
sig_handler handle_sigint(int sig)
1402+
1403+
/*
1404+
Kill a running query. Returns true if we were unable to connect to the server.
1405+
*/
1406+
bool kill_query(const char *reason)
13901407
{
13911408
char kill_buffer[40];
13921409
MYSQL *kill_mysql= NULL;
13931410

1394-
/* terminate if no query being executed, or we already tried interrupting */
1395-
if (!executing_query || (interrupted_query == 2))
1396-
{
1397-
tee_fprintf(stdout, "Ctrl-C -- exit!\n");
1398-
goto err;
1399-
}
1400-
14011411
kill_mysql= mysql_init(kill_mysql);
14021412
if (!do_connect(kill_mysql,current_host, current_user, opt_password, "", 0))
14031413
{
1404-
tee_fprintf(stdout, "Ctrl-C -- sorry, cannot connect to server to kill query, giving up ...\n");
1405-
goto err;
1414+
tee_fprintf(stdout, "%s -- sorry, cannot connect to server to kill query, giving up ...\n", reason);
1415+
return true;
14061416
}
14071417

14081418
/* First time try to kill the query, second time the connection */
@@ -1417,27 +1427,62 @@ sig_handler handle_sigint(int sig)
14171427
(interrupted_query == 1) ? "QUERY " : "",
14181428
mysql_thread_id(&mysql));
14191429
if (verbose)
1420-
tee_fprintf(stdout, "Ctrl-C -- sending \"%s\" to server ...\n",
1430+
tee_fprintf(stdout, "%s -- sending \"%s\" to server ...\n", reason,
14211431
kill_buffer);
14221432
mysql_real_query(kill_mysql, kill_buffer, (uint) strlen(kill_buffer));
14231433
mysql_close(kill_mysql);
1424-
tee_fprintf(stdout, "Ctrl-C -- query killed. Continuing normally.\n");
1434+
if (interrupted_query == 1)
1435+
tee_fprintf(stdout, "%s -- query killed.\n", reason);
1436+
else
1437+
tee_fprintf(stdout, "%s -- connection killed.\n", reason);
1438+
14251439
if (in_com_source)
14261440
aborted= 1; // Abort source command
1427-
return;
1441+
return false;
1442+
}
14281443

1429-
err:
1430-
#ifdef _WIN32
1444+
/*
1445+
This function handles sigint calls
1446+
If query is in process, kill query
1447+
If 'source' is executed, abort source command
1448+
no query in process, regenerate prompt.
1449+
*/
1450+
sig_handler handle_sigint(int sig)
1451+
{
14311452
/*
1432-
When SIGINT is raised on Windows, the OS creates a new thread to handle the
1433-
interrupt. Once that thread completes, the main thread continues running
1434-
only to find that it's resources have already been free'd when the sigint
1435-
handler called mysql_end().
1453+
On Unix only, if no query is being executed just clear the prompt,
1454+
don't exit. On Windows we exit.
14361455
*/
1437-
mysql_thread_end();
1456+
if (!executing_query)
1457+
{
1458+
#ifndef _WIN32
1459+
tee_fprintf(stdout, "^C\n");
1460+
#ifdef USE_LIBEDIT_INTERFACE
1461+
/* Libedit will regenerate it outside of the signal handler. */
1462+
sigint_received= 1;
14381463
#else
1439-
mysql_end(sig);
1440-
#endif
1464+
rl_on_new_line(); // Regenerate the prompt on a newline
1465+
rl_replace_line("", 0); // Clear the previous text
1466+
rl_redisplay();
1467+
#endif
1468+
#else // WIN32
1469+
tee_fprintf(stdout, "Ctrl-C -- exit!\n");
1470+
end_in_sig_handler(sig);
1471+
#endif
1472+
return;
1473+
}
1474+
1475+
/*
1476+
When executing a query, this newline makes the prompt look like so:
1477+
^C
1478+
Ctrl-C -- query killed.
1479+
*/
1480+
tee_fprintf(stdout, "\n");
1481+
if (kill_query("Ctrl-C"))
1482+
{
1483+
aborted= 1;
1484+
end_in_sig_handler(sig);
1485+
}
14411486
}
14421487

14431488

@@ -2004,6 +2049,15 @@ static int get_options(int argc, char **argv)
20042049
return(0);
20052050
}
20062051

2052+
2053+
#if !defined(_WIN32) && defined(USE_LIBEDIT_INTERFACE)
2054+
static inline void reset_prompt(char *in_string, bool *ml_comment) {
2055+
glob_buffer.length(0);
2056+
*ml_comment = false;
2057+
*in_string = 0;
2058+
}
2059+
#endif
2060+
20072061
static int read_and_execute(bool interactive)
20082062
{
20092063
#if defined(_WIN32)
@@ -2095,7 +2149,7 @@ static int read_and_execute(bool interactive)
20952149
size_t clen;
20962150
do
20972151
{
2098-
line= my_cgets((char*)tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen);
2152+
line= my_cgets((char*)tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen);
20992153
buffer.append(line, clen);
21002154
/*
21012155
if we got buffer fully filled than there is a chance that
@@ -2117,9 +2171,35 @@ static int read_and_execute(bool interactive)
21172171
the readline/libedit library.
21182172
*/
21192173
if (line)
2174+
{
21202175
free(line);
2176+
glob_buffer.length(0);
2177+
}
21212178
line= readline(prompt);
2122-
#endif /* defined(_WIN32) */
2179+
#ifdef USE_LIBEDIT_INTERFACE
2180+
/*
2181+
libedit handles interrupts different than libreadline.
2182+
libreadline has its own signal handlers, thus a sigint during readline
2183+
doesn't force readline to return null string.
2184+
2185+
However libedit returns null if the interrupt signal is raised.
2186+
We can also get an empty string when ctrl+d is pressed (EoF).
2187+
2188+
We need this sigint_received flag, to differentiate between the two
2189+
cases. This flag is only set during our handle_sigint function when
2190+
LIBEDIT_INTERFACE is used.
2191+
*/
2192+
if (!line && sigint_received)
2193+
{
2194+
// User asked to clear the input.
2195+
sigint_received= 0;
2196+
reset_prompt(&in_string, &ml_comment);
2197+
continue;
2198+
}
2199+
// For safety, we always mark this as cleared.
2200+
sigint_received= 0;
2201+
#endif
2202+
#endif /* defined(__WIN__) */
21232203

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

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/readline.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ MACRO (MYSQL_FIND_SYSTEM_READLINE)
114114
{
115115
rl_completion_func_t *func1= (rl_completion_func_t*)0;
116116
rl_compentry_func_t *func2= (rl_compentry_func_t*)0;
117+
rl_on_new_line();
118+
rl_replace_line(\"\", 0);
119+
rl_redisplay();
117120
}"
118121
NEW_READLINE_INTERFACE)
119122

config.h.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#cmakedefine HAVE_SYS_IOCTL_H 1
7474
#cmakedefine HAVE_SYS_MALLOC_H 1
7575
#cmakedefine HAVE_SYS_MMAN_H 1
76+
#cmakedefine HAVE_SYS_MNTENT_H 1
7677
#cmakedefine HAVE_SYS_NDIR_H 1
7778
#cmakedefine HAVE_SYS_PTE_H 1
7879
#cmakedefine HAVE_SYS_PTEM_H 1

extra/wolfssl/user_settings.h.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
#define NO_OLD_TIMEVAL_NAME
2929
#define HAVE_SECURE_RENEGOTIATION
3030
#define HAVE_EXTENDED_MASTER
31+
/*
32+
Following is workaround about a WolfSSL 5.6.6 bug.
33+
The bug is about undefined sessionCtxSz during compilation.
34+
*/
35+
#define WOLFSSL_SESSION_ID_CTX
3136

3237
/* TLSv1.3 definitions (all needed to build) */
3338
#define WOLFSSL_TLS13

extra/wolfssl/wolfssl

Submodule wolfssl updated 1157 files

mysql-test/main/func_json.result

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,39 @@ f
14601460
foo
14611461
SET @@COLLATION_CONNECTION= @old_collation_connection;
14621462
#
1463+
# MDEV-32587 JSON_VALID fail to validate integer zero in scientific notation
1464+
#
1465+
select JSON_VALID(' {"number": 1E-4}');
1466+
JSON_VALID(' {"number": 1E-4}')
1467+
1
1468+
select JSON_VALID(' {"number": 0E-4}');
1469+
JSON_VALID(' {"number": 0E-4}')
1470+
1
1471+
select JSON_VALID(' {"number": 0.0}');
1472+
JSON_VALID(' {"number": 0.0}')
1473+
1
1474+
select JSON_VALID(' {"number": 0.1E-4}');
1475+
JSON_VALID(' {"number": 0.1E-4}')
1476+
1
1477+
select JSON_VALID(' {"number": 0e-4}');
1478+
JSON_VALID(' {"number": 0e-4}')
1479+
1
1480+
select JSON_VALID(' {"number": -0E-4}');
1481+
JSON_VALID(' {"number": -0E-4}')
1482+
1
1483+
select JSON_VALUE(' {"number": 0E-4}', '$.number');
1484+
JSON_VALUE(' {"number": 0E-4}', '$.number')
1485+
0E-4
1486+
select JSON_VALID(' {"number": 00E-4}');
1487+
JSON_VALID(' {"number": 00E-4}')
1488+
0
1489+
select JSON_VALID(' {"number": 01E-4}');
1490+
JSON_VALID(' {"number": 01E-4}')
1491+
0
1492+
select JSON_VALID(' {"number": 0E-4.0}');
1493+
JSON_VALID(' {"number": 0E-4.0}')
1494+
0
1495+
#
14631496
# End of 10.4 tests
14641497
#
14651498
#

mysql-test/main/func_json.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,22 @@ SELECT JSON_VALUE('["foo"]', '$**[0]') AS f;
947947

948948
SET @@COLLATION_CONNECTION= @old_collation_connection;
949949

950+
--echo #
951+
--echo # MDEV-32587 JSON_VALID fail to validate integer zero in scientific notation
952+
--echo #
953+
# Passing
954+
select JSON_VALID(' {"number": 1E-4}');
955+
select JSON_VALID(' {"number": 0E-4}');
956+
select JSON_VALID(' {"number": 0.0}');
957+
select JSON_VALID(' {"number": 0.1E-4}');
958+
select JSON_VALID(' {"number": 0e-4}');
959+
select JSON_VALID(' {"number": -0E-4}');
960+
select JSON_VALUE(' {"number": 0E-4}', '$.number');
961+
# Failing
962+
select JSON_VALID(' {"number": 00E-4}');
963+
select JSON_VALID(' {"number": 01E-4}');
964+
select JSON_VALID(' {"number": 0E-4.0}');
965+
950966
--echo #
951967
--echo # End of 10.4 tests
952968
--echo #

mysql-test/main/func_str.result

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5286,3 +5286,30 @@ ERROR 42000: Incorrect parameter count in the call to native function 'DECODE'
52865286
#
52875287
# End of 10.4 tests
52885288
#
5289+
#
5290+
# Start of 10.5 tests
5291+
#
5292+
#
5293+
# MDEV-28651 quote(NULL) returns incorrect result in view ('NU' instead of 'NULL')
5294+
#
5295+
CREATE VIEW v1 AS SELECT quote(NULL);
5296+
SELECT * FROM v1;
5297+
quote(NULL)
5298+
NULL
5299+
DESCRIBE v1;
5300+
Field Type Null Key Default Extra
5301+
quote(NULL) varbinary(4) YES NULL
5302+
CREATE TABLE t1 AS SELECT * FROM v1;
5303+
SHOW CREATE TABLE t1;
5304+
Table Create Table
5305+
t1 CREATE TABLE `t1` (
5306+
`quote(NULL)` varbinary(4) DEFAULT NULL
5307+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
5308+
SELECT * FROM t1;
5309+
quote(NULL)
5310+
NULL
5311+
DROP TABLE t1;
5312+
DROP VIEW v1;
5313+
#
5314+
# End of 10.5 tests
5315+
#

mysql-test/main/func_str.test

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,3 +2335,25 @@ SELECT DECODE(NULL, NULL, NULL);
23352335
--echo #
23362336
--echo # End of 10.4 tests
23372337
--echo #
2338+
2339+
--echo #
2340+
--echo # Start of 10.5 tests
2341+
--echo #
2342+
2343+
--echo #
2344+
--echo # MDEV-28651 quote(NULL) returns incorrect result in view ('NU' instead of 'NULL')
2345+
--echo #
2346+
2347+
CREATE VIEW v1 AS SELECT quote(NULL);
2348+
SELECT * FROM v1;
2349+
DESCRIBE v1;
2350+
CREATE TABLE t1 AS SELECT * FROM v1;
2351+
SHOW CREATE TABLE t1;
2352+
SELECT * FROM t1;
2353+
DROP TABLE t1;
2354+
DROP VIEW v1;
2355+
2356+
2357+
--echo #
2358+
--echo # End of 10.5 tests
2359+
--echo #

0 commit comments

Comments
 (0)