Skip to content

Commit

Permalink
Merge branch '10.4' into 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Jan 30, 2024
2 parents 97fcafb + c75905c commit 50107c4
Show file tree
Hide file tree
Showing 55 changed files with 925 additions and 536 deletions.
142 changes: 111 additions & 31 deletions client/mysql.cc
Expand Up @@ -171,6 +171,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 @@ -1073,6 +1076,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 @@ -1209,8 +1214,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 @@ -1376,30 +1381,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 @@ -1414,27 +1424,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 @@ -1978,6 +2023,15 @@ static int get_options(int argc, char **argv)
return(0);
}


#if !defined(__WIN__) && 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)
{
#if defined(__WIN__)
Expand Down Expand Up @@ -2068,7 +2122,7 @@ static int read_and_execute(bool interactive)
size_t clen;
do
{
line= my_cgets((char*)tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen);
line= my_cgets((char*)tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen);
buffer.append(line, clen);
/*
if we got buffer fully filled than there is a chance that
Expand All @@ -2090,8 +2144,34 @@ static int read_and_execute(bool interactive)
the readline/libedit library.
*/
if (line)
{
free(line);
glob_buffer.length(0);
}
line= readline(prompt);
#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__) */

/*
Expand Down
12 changes: 6 additions & 6 deletions cmake/mysql_version.cmake
Expand Up @@ -50,12 +50,16 @@ MACRO(GET_MYSQL_VERSION)
MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_EXTRA" EXTRA_VERSION)
MYSQL_GET_CONFIG_VALUE("SERVER_MATURITY" SERVER_MATURITY)

IF(NOT "${MAJOR_VERSION}" MATCHES "[0-9]+" OR
IF(NOT "${MAJOR_VERSION}" MATCHES "[0-9]+" OR
NOT "${MINOR_VERSION}" MATCHES "[0-9]+" OR
NOT "${PATCH_VERSION}" MATCHES "[0-9]+")
MESSAGE(FATAL_ERROR "VERSION file cannot be parsed.")
ENDIF()

IF((NOT TINY_VERSION) AND (EXTRA_VERSION MATCHES "[\\-][0-9]+"))
STRING(REPLACE "-" "" TINY_VERSION "${EXTRA_VERSION}")
ELSE()
SET(TINY_VERSION "0")
ENDIF()
SET(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${EXTRA_VERSION}")
SET(SERVER_VERSION ${VERSION})
MESSAGE(STATUS "MariaDB ${VERSION}")
Expand Down Expand Up @@ -119,10 +123,6 @@ ENDIF()
IF(MSVC)
# Tiny version is used to identify the build, it can be set with cmake -DTINY_VERSION=<number>
# to bzr revno for example (in the CI builds)
IF(NOT TINY_VERSION)
SET(TINY_VERSION "0")
ENDIF()

GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)

SET(FILETYPE VFT_APP)
Expand Down
6 changes: 1 addition & 5 deletions cmake/package_name.cmake
Expand Up @@ -99,11 +99,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
3 changes: 3 additions & 0 deletions cmake/readline.cmake
Expand Up @@ -114,6 +114,9 @@ MACRO (MYSQL_FIND_SYSTEM_READLINE)
{
rl_completion_func_t *func1= (rl_completion_func_t*)0;
rl_compentry_func_t *func2= (rl_compentry_func_t*)0;
rl_on_new_line();
rl_replace_line(\"\", 0);
rl_redisplay();
}"
NEW_READLINE_INTERFACE)

Expand Down
1 change: 1 addition & 0 deletions config.h.cmake
Expand Up @@ -72,6 +72,7 @@
#cmakedefine HAVE_SYS_IOCTL_H 1
#cmakedefine HAVE_SYS_MALLOC_H 1
#cmakedefine HAVE_SYS_MMAN_H 1
#cmakedefine HAVE_SYS_MNTENT_H 1
#cmakedefine HAVE_SYS_NDIR_H 1
#cmakedefine HAVE_SYS_PTE_H 1
#cmakedefine HAVE_SYS_PTEM_H 1
Expand Down
5 changes: 5 additions & 0 deletions extra/wolfssl/user_settings.h.in
Expand Up @@ -28,6 +28,11 @@
#define NO_OLD_TIMEVAL_NAME
#define HAVE_SECURE_RENEGOTIATION
#define HAVE_EXTENDED_MASTER
/*
Following is workaround about a WolfSSL 5.6.6 bug.
The bug is about undefined sessionCtxSz during compilation.
*/
#define WOLFSSL_SESSION_ID_CTX

/* TLSv1.3 definitions (all needed to build) */
#define WOLFSSL_TLS13
Expand Down
2 changes: 1 addition & 1 deletion extra/wolfssl/wolfssl
Submodule wolfssl updated 1157 files
2 changes: 1 addition & 1 deletion libmariadb
33 changes: 33 additions & 0 deletions mysql-test/main/func_json.result
Expand Up @@ -1460,6 +1460,39 @@ f
foo
SET @@COLLATION_CONNECTION= @old_collation_connection;
#
# MDEV-32587 JSON_VALID fail to validate integer zero in scientific notation
#
select JSON_VALID(' {"number": 1E-4}');
JSON_VALID(' {"number": 1E-4}')
1
select JSON_VALID(' {"number": 0E-4}');
JSON_VALID(' {"number": 0E-4}')
1
select JSON_VALID(' {"number": 0.0}');
JSON_VALID(' {"number": 0.0}')
1
select JSON_VALID(' {"number": 0.1E-4}');
JSON_VALID(' {"number": 0.1E-4}')
1
select JSON_VALID(' {"number": 0e-4}');
JSON_VALID(' {"number": 0e-4}')
1
select JSON_VALID(' {"number": -0E-4}');
JSON_VALID(' {"number": -0E-4}')
1
select JSON_VALUE(' {"number": 0E-4}', '$.number');
JSON_VALUE(' {"number": 0E-4}', '$.number')
0E-4
select JSON_VALID(' {"number": 00E-4}');
JSON_VALID(' {"number": 00E-4}')
0
select JSON_VALID(' {"number": 01E-4}');
JSON_VALID(' {"number": 01E-4}')
0
select JSON_VALID(' {"number": 0E-4.0}');
JSON_VALID(' {"number": 0E-4.0}')
0
#
# End of 10.4 tests
#
#
Expand Down
16 changes: 16 additions & 0 deletions mysql-test/main/func_json.test
Expand Up @@ -944,6 +944,22 @@ SELECT JSON_VALUE('["foo"]', '$**[0]') AS f;

SET @@COLLATION_CONNECTION= @old_collation_connection;

--echo #
--echo # MDEV-32587 JSON_VALID fail to validate integer zero in scientific notation
--echo #
# Passing
select JSON_VALID(' {"number": 1E-4}');
select JSON_VALID(' {"number": 0E-4}');
select JSON_VALID(' {"number": 0.0}');
select JSON_VALID(' {"number": 0.1E-4}');
select JSON_VALID(' {"number": 0e-4}');
select JSON_VALID(' {"number": -0E-4}');
select JSON_VALUE(' {"number": 0E-4}', '$.number');
# Failing
select JSON_VALID(' {"number": 00E-4}');
select JSON_VALID(' {"number": 01E-4}');
select JSON_VALID(' {"number": 0E-4.0}');

--echo #
--echo # End of 10.4 tests
--echo #
Expand Down
15 changes: 15 additions & 0 deletions mysql-test/main/sp.result
Expand Up @@ -8958,5 +8958,20 @@ DROP FUNCTION f1;
DROP FUNCTION f2;
DROP FUNCTION f3;
DROP VIEW v1;
#
# MDEV-33270: Call of SP invoking another SP with a parameter
# requiring type conversion
#
SET NAMES latin1;
CREATE PROCEDURE p1 (a text) BEGIN SELECT a; END |
CREATE PROCEDURE p2 () CALL p1(concat('x',_utf8'x')) |
CALL p2();
a
xx
CALL p2();
a
xx
DROP PROCEDURE p1;
DROP PROCEDURE p2;
# End of 10.4 tests
#

0 comments on commit 50107c4

Please sign in to comment.