1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge 10.5 into 10.6

This commit is contained in:
Marko Mäkelä
2021-09-30 10:38:44 +03:00
49 changed files with 819 additions and 600 deletions

View File

@@ -71,10 +71,6 @@ static my_bool non_blocking_api_enabled= 0;
#include "../tests/nonblock-wrappers.h" #include "../tests/nonblock-wrappers.h"
#endif #endif
/* Use cygwin for --exec and --system before 5.0 */
#if MYSQL_VERSION_ID < 50000
#define USE_CYGWIN
#endif
#define MAX_VAR_NAME_LENGTH 256 #define MAX_VAR_NAME_LENGTH 256
#define MAX_COLUMNS 256 #define MAX_COLUMNS 256
@@ -619,7 +615,6 @@ const char *get_errname_from_code (uint error_code);
int multi_reg_replace(struct st_replace_regex* r,char* val); int multi_reg_replace(struct st_replace_regex* r,char* val);
#ifdef _WIN32 #ifdef _WIN32
void free_tmp_sh_file();
void free_win_path_patterns(); void free_win_path_patterns();
#endif #endif
@@ -1457,7 +1452,6 @@ void free_used_memory()
free_re(); free_re();
my_free(read_command_buf); my_free(read_command_buf);
#ifdef _WIN32 #ifdef _WIN32
free_tmp_sh_file();
free_win_path_patterns(); free_win_path_patterns();
#endif #endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
@@ -3199,33 +3193,6 @@ void do_source(struct st_command *command)
} }
#if defined _WIN32
#ifdef USE_CYGWIN
/* Variables used for temporary sh files used for emulating Unix on Windows */
char tmp_sh_name[64], tmp_sh_cmd[70];
#endif
void init_tmp_sh_file()
{
#ifdef USE_CYGWIN
/* Format a name for the tmp sh file that is unique for this process */
my_snprintf(tmp_sh_name, sizeof(tmp_sh_name), "tmp_%d.sh", getpid());
/* Format the command to execute in order to run the script */
my_snprintf(tmp_sh_cmd, sizeof(tmp_sh_cmd), "sh %s", tmp_sh_name);
#endif
}
void free_tmp_sh_file()
{
#ifdef USE_CYGWIN
my_delete(tmp_sh_name, MYF(0));
#endif
}
#endif
static void init_builtin_echo(void) static void init_builtin_echo(void)
{ {
#ifdef _WIN32 #ifdef _WIN32
@@ -3341,14 +3308,12 @@ void do_exec(struct st_command *command)
} }
#ifdef _WIN32 #ifdef _WIN32
#ifndef USE_CYGWIN
/* Replace /dev/null with NUL */ /* Replace /dev/null with NUL */
while(replace(&ds_cmd, "/dev/null", 9, "NUL", 3) == 0) while(replace(&ds_cmd, "/dev/null", 9, "NUL", 3) == 0)
; ;
/* Replace "closed stdout" with non existing output fd */ /* Replace "closed stdout" with non existing output fd */
while(replace(&ds_cmd, ">&-", 3, ">&4", 3) == 0) while(replace(&ds_cmd, ">&-", 3, ">&4", 3) == 0)
; ;
#endif
#endif #endif
if (disable_result_log) if (disable_result_log)
@@ -3507,13 +3472,7 @@ int do_modify_var(struct st_command *command,
int my_system(DYNAMIC_STRING* ds_cmd) int my_system(DYNAMIC_STRING* ds_cmd)
{ {
#if defined _WIN32 && defined USE_CYGWIN
/* Dump the command into a sh script file and execute with system */
str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length);
return system(tmp_sh_cmd);
#else
return system(ds_cmd->str); return system(ds_cmd->str);
#endif
} }
@@ -3547,12 +3506,10 @@ void do_system(struct st_command *command)
do_eval(&ds_cmd, command->first_argument, command->end, !is_windows); do_eval(&ds_cmd, command->first_argument, command->end, !is_windows);
#ifdef _WIN32 #ifdef _WIN32
#ifndef USE_CYGWIN
/* Replace /dev/null with NUL */ /* Replace /dev/null with NUL */
while(replace(&ds_cmd, "/dev/null", 9, "NUL", 3) == 0) while(replace(&ds_cmd, "/dev/null", 9, "NUL", 3) == 0)
; ;
#endif #endif
#endif
DBUG_PRINT("info", ("running system command '%s' as '%s'", DBUG_PRINT("info", ("running system command '%s' as '%s'",
@@ -5022,13 +4979,34 @@ int query_get_string(MYSQL* mysql, const char* query,
} }
#ifdef _WIN32
#define SIGKILL 9
#include <my_minidump.h>
static int my_kill(int pid, int sig) static int my_kill(int pid, int sig)
{ {
DBUG_PRINT("info", ("Killing server, pid: %d", pid));
#ifdef _WIN32
#define SIGKILL 9 /* ignored anyway, see below */
HANDLE proc; HANDLE proc;
if ((proc= OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pid)) == NULL) if (sig == SIGABRT)
{
/*
Create a minidump. If process is being debugged, debug break
Otherwise, terminate.
*/
verbose_msg("Aborting %d",pid);
my_create_minidump(pid,TRUE);
proc= OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if(!proc)
return -1;
BOOL debugger_present;
if (CheckRemoteDebuggerPresent(proc,&debugger_present) && debugger_present)
{
if (DebugBreakProcess(proc))
{
CloseHandle(proc);
return 0;
}
}
}
else if ((proc= OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pid)) == NULL)
return -1; return -1;
if (sig == 0) if (sig == 0)
{ {
@@ -5039,12 +5017,30 @@ static int my_kill(int pid, int sig)
(void)TerminateProcess(proc, 201); (void)TerminateProcess(proc, 201);
CloseHandle(proc); CloseHandle(proc);
return 1; return 1;
#else
return kill(pid, sig);
#endif
} }
/* Wait until process is gone, with timeout */
static int wait_until_dead(int pid, int timeout)
{
HANDLE proc= OpenProcess(SYNCHRONIZE, FALSE, pid);
if (!proc)
return 0; /* already dead */
DBUG_ASSERT(timeout >= 0);
DBUG_ASSERT(timeout <= UINT_MAX/1000);
DWORD wait_result= WaitForSingleObject(proc, (DWORD)timeout*1000);
CloseHandle(proc);
return (int)wait_result;
}
#else /* !_WIN32 */
static int my_kill(int pid, int sig)
{
DBUG_PRINT("info", ("Killing server, pid: %d", pid));
return kill(pid, sig);
}
/* /*
Shutdown the server of current connection and Shutdown the server of current connection and
@@ -5079,6 +5075,7 @@ static int wait_until_dead(int pid, int timeout)
} }
DBUG_RETURN(1); // Did not die DBUG_RETURN(1); // Did not die
} }
#endif /* _WIN32 */
void do_shutdown_server(struct st_command *command) void do_shutdown_server(struct st_command *command)
@@ -9231,10 +9228,7 @@ int main(int argc, char **argv)
init_builtin_echo(); init_builtin_echo();
#ifdef _WIN32 #ifdef _WIN32
#ifndef USE_CYGWIN
is_windows= 1; is_windows= 1;
#endif
init_tmp_sh_file();
init_win_path_patterns(); init_win_path_patterns();
#endif #endif

25
include/my_minidump.h Normal file
View File

@@ -0,0 +1,25 @@
/* Copyright (c) 2021, MariaDB Corporation
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-1335 USA */
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
BOOL my_create_minidump(DWORD pid, BOOL verbose);
#ifdef __cplusplus
}
#endif

View File

@@ -145,6 +145,9 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
ADD_CONVENIENCE_LIBRARY(sql_embedded ${SQL_EMBEDDED_SOURCES}) ADD_CONVENIENCE_LIBRARY(sql_embedded ${SQL_EMBEDDED_SOURCES})
DTRACE_INSTRUMENT(sql_embedded) DTRACE_INSTRUMENT(sql_embedded)
ADD_DEPENDENCIES(sql_embedded GenError GenServerSource) ADD_DEPENDENCIES(sql_embedded GenError GenServerSource)
IF(TARGET pcre2)
ADD_DEPENDENCIES(sql_embedded pcre2)
ENDIF()
# On Windows, static embedded server library is called mysqlserver.lib # On Windows, static embedded server library is called mysqlserver.lib
# On Unix, it is libmysqld.a # On Unix, it is libmysqld.a

View File

@@ -19,7 +19,8 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
IF (WIN32) IF (WIN32)
ADD_EXECUTABLE(my_safe_process safe_process_win.cc) ADD_EXECUTABLE(my_safe_process safe_process_win.cc)
ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc) ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc)
TARGET_LINK_LIBRARIES(my_safe_kill dbghelp psapi) TARGET_INCLUDE_DIRECTORIES(my_safe_kill PRIVATE ${CMAKE_SOURCE_DIR}/include)
TARGET_LINK_LIBRARIES(my_safe_kill mysys psapi)
ELSE() ELSE()
ADD_EXECUTABLE(my_safe_process safe_process.cc) ADD_EXECUTABLE(my_safe_process safe_process.cc)
ENDIF() ENDIF()

View File

@@ -26,19 +26,7 @@
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <psapi.h> #include <psapi.h>
#include <my_minidump.h>
#ifdef _MSC_VER
/* Silence warning in OS header dbghelp.h */
#pragma warning(push)
#pragma warning(disable : 4091)
#endif
#include <dbghelp.h>
#ifdef _MSC_VER
/* Silence warning in OS header dbghelp.h */
#pragma warning(pop)
#endif
#include <tlhelp32.h> #include <tlhelp32.h>
#include <vector> #include <vector>
@@ -64,106 +52,13 @@ static std::vector<DWORD> find_children(DWORD pid)
return children; return children;
} }
void dump_single_process(DWORD pid)
{
HANDLE file = 0;
HANDLE process= 0;
DWORD size= MAX_PATH;
char path[MAX_PATH];
char working_dir[MAX_PATH];
char tmpname[MAX_PATH];
char *filename= 0;
process= OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
if (!process)
{
fprintf(stderr, "safe_kill : cannot open process pid=%lu to create dump, last error %lu\n",
pid, GetLastError());
goto exit;
}
if (QueryFullProcessImageName(process, 0, path, &size) == 0)
{
fprintf(stderr, "safe_kill : cannot read process path for pid %lu, last error %lu\n",
pid, GetLastError());
goto exit;
}
filename= strrchr(path, '\\');
if (filename)
{
filename++;
// We are not interested in dump of some proceses (my_safe_process.exe,cmd.exe)
// since they are only used to start up other programs.
// We're interested however in their children;
const char *exclude_programs[] = {"my_safe_process.exe","cmd.exe", 0};
for(size_t i=0; exclude_programs[i]; i++)
if (_stricmp(filename, exclude_programs[i]) == 0)
goto exit;
}
else
filename= path;
// Add .dmp extension
char *p;
if ((p= strrchr(filename, '.')) == 0)
p= filename + strlen(filename);
strncpy(p, ".dmp", path + MAX_PATH - p);
// Íf file with this name exist, generate unique name with .dmp extension
if (GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES)
{
if (!GetTempFileName(".", filename, 0, tmpname))
{
fprintf(stderr, "GetTempFileName failed, last error %lu", GetLastError());
goto exit;
}
strncat_s(tmpname, ".dmp", sizeof(tmpname));
filename= tmpname;
}
if (!GetCurrentDirectory(MAX_PATH, working_dir))
{
fprintf(stderr, "GetCurrentDirectory failed, last error %lu", GetLastError());
goto exit;
}
file= CreateFile(filename, GENERIC_READ | GENERIC_WRITE,
0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (file == INVALID_HANDLE_VALUE)
{
fprintf(stderr, "safe_kill : CreateFile() failed for file %s, working dir %s, last error = %lu\n",
filename, working_dir, GetLastError());
goto exit;
}
if (!MiniDumpWriteDump(process, pid, file, MiniDumpNormal, 0, 0, 0))
{
fprintf(stderr, "Failed to write minidump to %s, working dir %s, last error %lu\n",
filename, working_dir, GetLastError());
goto exit;
}
fprintf(stderr, "Minidump written to %s, directory %s\n", filename, working_dir);
exit:
if (process != 0 && process != INVALID_HANDLE_VALUE)
CloseHandle(process);
if (file != 0 && file != INVALID_HANDLE_VALUE)
CloseHandle(file);
}
static int create_dump(DWORD pid, int recursion_depth= 5) static int create_dump(DWORD pid, int recursion_depth= 5)
{ {
if (recursion_depth < 0) if (recursion_depth < 0)
return 0; return 0;
dump_single_process(pid); my_create_minidump(pid, TRUE);
std::vector<DWORD> children= find_children(pid); std::vector<DWORD> children= find_children(pid);
for(size_t i=0; i < children.size(); i++) for(size_t i=0; i < children.size(); i++)
create_dump(children[i], recursion_depth -1); create_dump(children[i], recursion_depth -1);

View File

@@ -224,10 +224,10 @@ SELECT 4;
END IF ; END IF ;
END"where name = "P1"; END"where name = "P1";
show create procedure P1; show create procedure P1;
ERROR HY000: Failed to load routine test.P1 (internal code -6). For more details, run SHOW WARNINGS ERROR 42000: Undeclared variable: foo
show warnings; show warnings;
Level Code Message Level Code Message
Error 1327 Undeclared variable: foo Error 1327 Undeclared variable: foo
Error 1457 Failed to load routine test.P1 (internal code -6). For more details, run SHOW WARNINGS Error 1305 PROCEDURE P1 does not exist
drop procedure P1; drop procedure P1;
# End of 10.4 tests # End of 10.4 tests

View File

@@ -275,7 +275,7 @@ SELECT 4;
END IF ; END IF ;
END"where name = "P1"; END"where name = "P1";
--error ER_SP_PROC_TABLE_CORRUPT --error ER_SP_UNDECLARED_VAR
show create procedure P1; show create procedure P1;
show warnings; show warnings;

View File

@@ -221,6 +221,8 @@ end|
# called below. # called below.
# #
connection con1; connection con1;
set @save_dbug=@@debug_dbug;
set debug_dbug="+d,cache_sp_in_show_create";
# Cache all functions used in the tests below so statements # Cache all functions used in the tests below so statements
# calling them won't need to open and lock mysql.proc table # calling them won't need to open and lock mysql.proc table
# and we can assume that each statement locks its tables # and we can assume that each statement locks its tables
@@ -245,6 +247,7 @@ show create function f14;
show create function f15; show create function f15;
show create function f16; show create function f16;
show create function f17; show create function f17;
set debug_dbug=@save_dbug;
connection default; connection default;
# #
# 1. Statements that read tables and do not use subqueries. # 1. Statements that read tables and do not use subqueries.

View File

@@ -235,6 +235,8 @@ let $con_aux2= con2;
let $table= t1; let $table= t1;
connection con1; connection con1;
set @save_dbug=@@debug_dbug;
set debug_dbug="+d,cache_sp_in_show_create";
--echo # Cache all functions used in the tests below so statements --echo # Cache all functions used in the tests below so statements
--echo # calling them won't need to open and lock mysql.proc table --echo # calling them won't need to open and lock mysql.proc table
--echo # and we can assume that each statement locks its tables --echo # and we can assume that each statement locks its tables
@@ -260,6 +262,7 @@ show create function f14;
show create function f15; show create function f15;
show create function f16; show create function f16;
show create function f17; show create function f17;
set debug_dbug=@save_dbug;
--enable_result_log --enable_result_log
connection default; connection default;

View File

@@ -168,7 +168,7 @@ RETURN 0;
END latin1 latin1_swedish_ci latin1_swedish_ci END latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION TESTF_bug11763507; SHOW CREATE FUNCTION TESTF_bug11763507;
Function sql_mode Create Function character_set_client collation_connection Database Collation Function sql_mode Create Function character_set_client collation_connection Database Collation
testf_bug11763507 CREATE DEFINER=`root`@`localhost` FUNCTION `testf_bug11763507`() RETURNS int(11) TESTF_bug11763507 CREATE DEFINER=`root`@`localhost` FUNCTION `TESTF_bug11763507`() RETURNS int(11)
BEGIN BEGIN
RETURN 0; RETURN 0;
END latin1 latin1_swedish_ci latin1_swedish_ci END latin1 latin1_swedish_ci latin1_swedish_ci
@@ -198,7 +198,7 @@ SELECT "PROCEDURE testp_bug11763507";
END latin1 latin1_swedish_ci latin1_swedish_ci END latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE PROCEDURE TESTP_bug11763507; SHOW CREATE PROCEDURE TESTP_bug11763507;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
testp_bug11763507 CREATE DEFINER=`root`@`localhost` PROCEDURE `testp_bug11763507`() TESTP_bug11763507 CREATE DEFINER=`root`@`localhost` PROCEDURE `TESTP_bug11763507`()
BEGIN BEGIN
SELECT "PROCEDURE testp_bug11763507"; SELECT "PROCEDURE testp_bug11763507";
END latin1 latin1_swedish_ci latin1_swedish_ci END latin1 latin1_swedish_ci latin1_swedish_ci

View File

@@ -703,9 +703,6 @@ connection default;
# #
# SHOW CREATE PROCEDURE p1 called from p1, after p1 was altered # SHOW CREATE PROCEDURE p1 called from p1, after p1 was altered
# #
# We are just covering the existing behaviour with tests. The
# results are not necessarily correct."
#
CREATE PROCEDURE p1() CREATE PROCEDURE p1()
BEGIN BEGIN
SELECT get_lock("test", 10); SELECT get_lock("test", 10);
@@ -736,10 +733,7 @@ get_lock("test", 10)
1 1
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() p1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
BEGIN BEGIN END latin1 latin1_swedish_ci latin1_swedish_ci
SELECT get_lock("test", 10);
SHOW CREATE PROCEDURE p1;
END latin1 latin1_swedish_ci latin1_swedish_ci
connection con3; connection con3;
disconnect con3; disconnect con3;
connection con2; connection con2;

View File

@@ -807,9 +807,6 @@ connection default;
--echo # --echo #
--echo # SHOW CREATE PROCEDURE p1 called from p1, after p1 was altered --echo # SHOW CREATE PROCEDURE p1 called from p1, after p1 was altered
--echo # --echo #
--echo # We are just covering the existing behaviour with tests. The
--echo # results are not necessarily correct."
--echo #
delimiter |; delimiter |;
CREATE PROCEDURE p1() CREATE PROCEDURE p1()

View File

@@ -8869,6 +8869,25 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
BEGIN BEGIN
RETURN ''; RETURN '';
END' at line 2 END' at line 2
SELECT VARIABLE_VALUE into @global_mem_used FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='MEMORY_USED';
SELECT VARIABLE_VALUE into @local_mem_used FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='MEMORY_USED';
CREATE PROCEDURE sp0() SELECT 1;
SHOW CREATE PROCEDURE sp0;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
sp0 STRICT_ALL_TABLES CREATE DEFINER=`root`@`localhost` PROCEDURE `sp0`()
SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci
DROP PROCEDURE sp0;
SELECT VARIABLE_VALUE into @global_mem_used FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='MEMORY_USED';
SELECT VARIABLE_VALUE into @local_mem_used FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='MEMORY_USED';
CREATE PROCEDURE sp1() SELECT 1;
SHOW CREATE PROCEDURE sp1;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
sp1 STRICT_ALL_TABLES CREATE DEFINER=`root`@`localhost` PROCEDURE `sp1`()
SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE-@local_mem_used FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='MEMORY_USED';
VARIABLE_VALUE-@local_mem_used
0
DROP PROCEDURE sp1;
# End of 10.3 tests # End of 10.3 tests
# #
# Start of 10.4 tests # Start of 10.4 tests

View File

@@ -10417,6 +10417,24 @@ END;
$$ $$
DELIMITER ;$$ DELIMITER ;$$
# MDEV-20699 do not cache SP in SHOW CREATE
# Warmup round, this might allocate some memory for session variable
# and the output
SELECT VARIABLE_VALUE into @global_mem_used FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='MEMORY_USED';
SELECT VARIABLE_VALUE into @local_mem_used FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='MEMORY_USED';
CREATE PROCEDURE sp0() SELECT 1;
SHOW CREATE PROCEDURE sp0;
DROP PROCEDURE sp0;
#Check that CREATE/SHOW does not use memory in caches.
SELECT VARIABLE_VALUE into @global_mem_used FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='MEMORY_USED';
SELECT VARIABLE_VALUE into @local_mem_used FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='MEMORY_USED';
CREATE PROCEDURE sp1() SELECT 1;
SHOW CREATE PROCEDURE sp1;
SELECT VARIABLE_VALUE-@local_mem_used FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='MEMORY_USED';
# 10.5 FIXME: This occasionally shows 56 or 64 bytes of difference!
#SELECT VARIABLE_VALUE-@global_mem_used FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='MEMORY_USED';
DROP PROCEDURE sp1;
--echo # End of 10.3 tests --echo # End of 10.3 tests

View File

@@ -6792,6 +6792,49 @@ sum(z)
DROP TABLE t1; DROP TABLE t1;
DROP VIEW v1; DROP VIEW v1;
# #
# MDEV-24454: Crash at change_item_tree
#
CREATE TABLE t1(f0 INT);
CREATE VIEW v1 AS
SELECT
f0 AS f1
FROM t1;
CREATE VIEW v2 AS
SELECT
(SELECT GROUP_CONCAT(v1.f1 SEPARATOR ', ')
FROM v1 n) AS f2,
GROUP_CONCAT('' SEPARATOR ', ') AS f3
FROM v1;
CREATE VIEW v3 AS
SELECT 1 as f4 FROM v2;
CREATE PROCEDURE p1()
SELECT * FROM v3;
CALL p1();
f4
1
CALL p1();
f4
1
drop procedure p1;
drop view v1,v2,v3;
drop table t1;
#
# MDEV-25631: Crash in st_select_lex::mark_as_dependent with
# VIEW, aggregate and subquery
#
CREATE TABLE t1 (i1 int);
insert into t1 values (1),(2),(3);
CREATE VIEW v1 AS
SELECT t1.i1 FROM (t1 a JOIN t1 ON (t1.i1 = (SELECT t1.i1 FROM t1 b)));
SELECT 1 FROM (SELECT count(((SELECT i1 FROM v1))) FROM v1) dt ;
ERROR 21000: Subquery returns more than 1 row
delete from t1 where i1 > 1;
SELECT 1 FROM (SELECT count(((SELECT i1 FROM v1))) FROM v1) dt ;
1
1
drop view v1;
drop table t1;
#
# End of 10.2 tests # End of 10.2 tests
# #
# #

View File

@@ -6511,6 +6511,55 @@ SELECT sum(z) FROM v1;
DROP TABLE t1; DROP TABLE t1;
DROP VIEW v1; DROP VIEW v1;
--echo #
--echo # MDEV-24454: Crash at change_item_tree
--echo #
CREATE TABLE t1(f0 INT);
CREATE VIEW v1 AS
SELECT
f0 AS f1
FROM t1;
CREATE VIEW v2 AS
SELECT
(SELECT GROUP_CONCAT(v1.f1 SEPARATOR ', ')
FROM v1 n) AS f2,
GROUP_CONCAT('' SEPARATOR ', ') AS f3
FROM v1;
CREATE VIEW v3 AS
SELECT 1 as f4 FROM v2;
CREATE PROCEDURE p1()
SELECT * FROM v3;
CALL p1();
CALL p1();
drop procedure p1;
drop view v1,v2,v3;
drop table t1;
--echo #
--echo # MDEV-25631: Crash in st_select_lex::mark_as_dependent with
--echo # VIEW, aggregate and subquery
--echo #
CREATE TABLE t1 (i1 int);
insert into t1 values (1),(2),(3); #not important
CREATE VIEW v1 AS
SELECT t1.i1 FROM (t1 a JOIN t1 ON (t1.i1 = (SELECT t1.i1 FROM t1 b)));
--error ER_SUBQUERY_NO_1_ROW
SELECT 1 FROM (SELECT count(((SELECT i1 FROM v1))) FROM v1) dt ;
delete from t1 where i1 > 1;
SELECT 1 FROM (SELECT count(((SELECT i1 FROM v1))) FROM v1) dt ;
drop view v1;
drop table t1;
--echo # --echo #
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --echo #

View File

@@ -725,6 +725,10 @@ END
character_set_client latin1 character_set_client latin1
collation_connection latin1_swedish_ci collation_connection latin1_swedish_ci
Database Collation latin1_swedish_ci Database Collation latin1_swedish_ci
Warnings:
Level Note
Code 1585
Message This function 'concat' has the same name as a native function
SHOW CREATE PACKAGE BODY test2; SHOW CREATE PACKAGE BODY test2;
Package body test2 Package body test2
sql_mode PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT sql_mode PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT
@@ -745,6 +749,10 @@ END
character_set_client latin1 character_set_client latin1
collation_connection latin1_swedish_ci collation_connection latin1_swedish_ci
Database Collation latin1_swedish_ci Database Collation latin1_swedish_ci
Warnings:
Level Note
Code 1585
Message This function 'concat' has the same name as a native function
DROP PACKAGE BODY test2; DROP PACKAGE BODY test2;
SELECT test2.f1(); SELECT test2.f1();
ERROR 42000: FUNCTION test.test2.f1 does not exist ERROR 42000: FUNCTION test.test2.f1 does not exist

View File

@@ -39,7 +39,6 @@ galera_toi_truncate : MDEV-22996 Hang on galera_toi_truncate test case
galera_trigger : MDEV-24048 galera.galera_trigger MTR fails: Result content mismatch galera_trigger : MDEV-24048 galera.galera_trigger MTR fails: Result content mismatch
galera_unicode_identifiers : MDEV-26500 : galera.galera_unicode_identifiers MTR failed: InnoDB: innodb_fatal_semaphore_wait_threshold was exceeded for dict_sys.mutex galera_unicode_identifiers : MDEV-26500 : galera.galera_unicode_identifiers MTR failed: InnoDB: innodb_fatal_semaphore_wait_threshold was exceeded for dict_sys.mutex
galera_var_dirty_reads : MDEV-25615 Galera test failure on galera_var_dirty_reads galera_var_dirty_reads : MDEV-25615 Galera test failure on galera_var_dirty_reads
galera_var_ignore_apply_errors : MDEV-20451: Lock wait timeout exceeded in galera_var_ignore_apply_errors
galera_var_node_address : MDEV-20485 Galera test failure galera_var_node_address : MDEV-20485 Galera test failure
galera_var_notify_cmd : MDEV-21905 Galera test galera_var_notify_cmd causes hang galera_var_notify_cmd : MDEV-21905 Galera test galera_var_notify_cmd causes hang
galera_var_reject_queries : assertion in inline_mysql_socket_send galera_var_reject_queries : assertion in inline_mysql_socket_send

View File

@@ -36,59 +36,3 @@ COUNT(f1) = 1000
1 1
DROP TABLE t1; DROP TABLE t1;
DROP TABLE ten; DROP TABLE ten;
connection node_1;
SET @value=REPEAT (1,5001);
CREATE TABLE t (a VARCHAR(5000),FULLTEXT (a)) engine=innodb;
INSERT IGNORE INTO t VALUES(@value);
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
SELECT COUNT(*) FROM t;
COUNT(*)
1
connection node_2;
SELECT COUNT(*) FROM t;
COUNT(*)
1
connection node_1;
DROP TABLE t;
CREATE TABLE t (a VARCHAR(5000)) engine=innodb;
INSERT IGNORE INTO t VALUES(@value);
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
SELECT COUNT(*) FROM t;
COUNT(*)
1
connection node_2;
SELECT COUNT(*) FROM t;
COUNT(*)
1
connection node_1;
DROP TABLE t;
connection node_1;
SET @value=REPEAT (1,5001);
CREATE TABLE t (a VARCHAR(5000),FULLTEXT (a)) engine=innodb DEFAULT CHARSET=utf8;
INSERT IGNORE INTO t VALUES(@value);
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
SELECT COUNT(*) FROM t;
COUNT(*)
1
connection node_2;
SELECT COUNT(*) FROM t;
COUNT(*)
1
connection node_1;
DROP TABLE t;
CREATE TABLE t (a VARCHAR(5000)) engine=innodb DEFAULT CHARSET=utf8;
INSERT IGNORE INTO t VALUES(@value);
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
SELECT COUNT(*) FROM t;
COUNT(*)
1
connection node_2;
SELECT COUNT(*) FROM t;
COUNT(*)
1
connection node_1;
DROP TABLE t;

View File

@@ -424,3 +424,5 @@ connection node_4;
connection node_1; connection node_1;
DROP TABLE t1; DROP TABLE t1;
DROP PROCEDURE p1; DROP PROCEDURE p1;
disconnect node_3;
disconnect node_4;

View File

@@ -1,6 +1,4 @@
--source include/big_test.inc
--source include/galera_cluster.inc --source include/galera_cluster.inc
--source include/have_innodb.inc
# #
# InnoDB FULLTEXT indexes # InnoDB FULLTEXT indexes
@@ -60,50 +58,28 @@ SELECT COUNT(f1) = 1000 FROM t1 WHERE MATCH(f1) AGAINST ('abcdefjhk');
DROP TABLE t1; DROP TABLE t1;
DROP TABLE ten; DROP TABLE ten;
#
# MDEV-24978 : SIGABRT in __libc_message
#
--connection node_1
SET @value=REPEAT (1,5001);
CREATE TABLE t (a VARCHAR(5000),FULLTEXT (a)) engine=innodb;
INSERT IGNORE INTO t VALUES(@value);
SELECT COUNT(*) FROM t;
--connection node_2
SELECT COUNT(*) FROM t;
--connection node_1
DROP TABLE t;
CREATE TABLE t (a VARCHAR(5000)) engine=innodb;
INSERT IGNORE INTO t VALUES(@value);
SELECT COUNT(*) FROM t;
--connection node_2
SELECT COUNT(*) FROM t;
--connection node_1
DROP TABLE t;
# #
# Case 2: UTF-8 # Case 2: UTF-8
# TODO: MDEV-24978
# #
--connection node_1 #--connection node_1
SET @value=REPEAT (1,5001); #SET @value=REPEAT (1,5001);
CREATE TABLE t (a VARCHAR(5000),FULLTEXT (a)) engine=innodb DEFAULT CHARSET=utf8; #CREATE TABLE t (a VARCHAR(5000),FULLTEXT (a)) engine=innodb DEFAULT CHARSET=utf8;
INSERT IGNORE INTO t VALUES(@value); #INSERT IGNORE INTO t VALUES(@value);
SELECT COUNT(*) FROM t; #SELECT COUNT(*) FROM t;
#
--connection node_2 #--connection node_2
SELECT COUNT(*) FROM t; #SELECT COUNT(*) FROM t;
#
--connection node_1 #--connection node_1
DROP TABLE t; #DROP TABLE t;
CREATE TABLE t (a VARCHAR(5000)) engine=innodb DEFAULT CHARSET=utf8; #CREATE TABLE t (a VARCHAR(5000)) engine=innodb DEFAULT CHARSET=utf8;
INSERT IGNORE INTO t VALUES(@value); #INSERT IGNORE INTO t VALUES(@value);
SELECT COUNT(*) FROM t; #SELECT COUNT(*) FROM t;
#
--connection node_2 #--connection node_2
SELECT COUNT(*) FROM t; #SELECT COUNT(*) FROM t;
#
--connection node_1 #--connection node_1
DROP TABLE t; #DROP TABLE t;

View File

@@ -3,16 +3,20 @@
[mysqld.1] [mysqld.1]
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M;gmcast.segment=1' wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M;gmcast.segment=1'
wsrep_slave_threads=10 wsrep_slave_threads=10
wsrep_debug=1
[mysqld.2] [mysqld.2]
wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=10M;gmcast.segment=1' wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=10M;gmcast.segment=1'
wsrep_slave_threads=10 wsrep_slave_threads=10
wsrep_debug=1
[mysqld.3] [mysqld.3]
wsrep_provider_options='base_port=@mysqld.3.#galera_port;gcache.size=10M;gmcast.segment=2' wsrep_provider_options='base_port=@mysqld.3.#galera_port;gcache.size=10M;gmcast.segment=2'
wsrep_slave_threads=10 wsrep_slave_threads=10
wsrep_debug=1
[mysqld.4] [mysqld.4]
wsrep_provider_options='base_port=@mysqld.4.#galera_port;gcache.size=10M;gmcast.segment=3' wsrep_provider_options='base_port=@mysqld.4.#galera_port;gcache.size=10M;gmcast.segment=3'
wsrep_slave_threads=10 wsrep_slave_threads=10
wsrep_debug=1

View File

@@ -11,6 +11,8 @@ call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4 --connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4
--connection node_1 --connection node_1
--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
CREATE TABLE t1( CREATE TABLE t1(
id bigint unsigned NOT NULL AUTO_INCREMENT, id bigint unsigned NOT NULL AUTO_INCREMENT,
@@ -449,3 +451,7 @@ reap;
DROP TABLE t1; DROP TABLE t1;
DROP PROCEDURE p1; DROP PROCEDURE p1;
--disconnect node_3
--disconnect node_4

View File

@@ -0,0 +1,7 @@
!include ../galera_2nodes.cnf
[mysqld.1]
wsrep_debug=1
[mysqld.2]
wsrep_debug=1

View File

@@ -3,7 +3,6 @@
# #
--source include/galera_cluster.inc --source include/galera_cluster.inc
--source include/have_innodb.inc
# #
@@ -73,11 +72,15 @@ SET GLOBAL wsrep_on = ON;
DELETE FROM t1 WHERE f1 = 1; DELETE FROM t1 WHERE f1 = 1;
--connection node_1 --connection node_1
--let $wait_condition = SELECT COUNT(*) = 0 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) as expect_0 FROM t1; SELECT COUNT(*) as expect_0 FROM t1;
--connection node_2 --connection node_2
--source include/galera_wait_ready.inc --source include/galera_wait_ready.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc --source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 0 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) as expect_0 FROM t1; SELECT COUNT(*) as expect_0 FROM t1;
DROP TABLE t1; DROP TABLE t1;
@@ -97,11 +100,15 @@ DELETE FROM t1 WHERE f1 = 2;
COMMIT; COMMIT;
--connection node_1 --connection node_1
--let $wait_condition = SELECT COUNT(*) = 1 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) as expect_1 FROM t1; SELECT COUNT(*) as expect_1 FROM t1;
--connection node_2 --connection node_2
--source include/galera_wait_ready.inc --source include/galera_wait_ready.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc --source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 1 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) as expect_1 FROM t1; SELECT COUNT(*) as expect_1 FROM t1;
DROP TABLE t1; DROP TABLE t1;
@@ -132,6 +139,8 @@ SELECT COUNT(*) as expect_0 FROM t1;
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; --let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc --source include/wait_condition.inc
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--let $wait_condition = SELECT COUNT(*) = 0 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) as expect_0 FROM t1; SELECT COUNT(*) as expect_0 FROM t1;
DROP TABLE t1; DROP TABLE t1;
@@ -171,6 +180,8 @@ SELECT COUNT(*) as expect_0 FROM t1;
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; --let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc --source include/wait_condition.inc
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--let $wait_condition = SELECT COUNT(*) = 0 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) as expect_0 FROM t1; SELECT COUNT(*) as expect_0 FROM t1;
DROP TABLE t1; DROP TABLE t1;
@@ -205,6 +216,8 @@ SELECT COUNT(*) as expect_0 FROM t1;
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; --let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc --source include/wait_condition.inc
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--let $wait_condition = SELECT COUNT(*) = 0 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) as expect_0 FROM t1; SELECT COUNT(*) as expect_0 FROM t1;
DROP TABLE t1,t2; DROP TABLE t1,t2;
@@ -239,6 +252,10 @@ SELECT COUNT(*) as expect_0 FROM child;
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; --let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc --source include/wait_condition.inc
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--let $wait_condition = SELECT COUNT(*) = 0 FROM parent;
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 0 FROM child;
--source include/wait_condition.inc
SELECT COUNT(*) as expect_0 FROM parent; SELECT COUNT(*) as expect_0 FROM parent;
SELECT COUNT(*) as expect_0 FROM child; SELECT COUNT(*) as expect_0 FROM child;
DROP TABLE child, parent; DROP TABLE child, parent;

View File

@@ -3,118 +3,115 @@ DELETE FROM mysql.innodb_index_stats;
# Create table. # Create table.
CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256),
KEY SECOND(a, b)) ENGINE=INNODB STATS_PERSISTENT=0; KEY SECOND(a, b)) ENGINE=INNODB STATS_PERSISTENT=0;
INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_1_to_1024; INSERT INTO t1 SELECT 100*FLOOR(seq/70)+seq%70, REPEAT('A', 256)
FROM seq_1_to_1024;
# Not enough page splits to trigger persistent stats write yet. # Not enough page splits to trigger persistent stats write yet.
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); SELECT * FROM mysql.innodb_index_stats;
count(stat_value) = 0 database_name table_name index_name last_update stat_name stat_value sample_size stat_description
1 INSERT INTO t1 SELECT 100*FLOOR(seq/70)+seq%70, REPEAT('A', 256)
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); FROM seq_1025_to_1433;
count(stat_value) = 0
1
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag');
count(stat_value) = 0
1
INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_1025_to_2048;
# Persistent stats recorded.
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split');
count(stat_value) > 0
1
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed');
count(stat_value) = 0
1
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag');
count(stat_value) > 0
1
# Delete some rows.
BEGIN; BEGIN;
delete from t1 where a between 100 * 20 and 100 * 20 + 30; INSERT INTO t1 SELECT 100*20+seq, REPEAT('A', 256)
delete from t1 where a between 100 * 19 and 100 * 19 + 30; FROM seq_70_to_99;
delete from t1 where a between 100 * 18 and 100 * 18 + 30; INSERT INTO t1 SELECT 100*19+seq, REPEAT('A', 256)
delete from t1 where a between 100 * 17 and 100 * 17 + 30; FROM seq_70_to_99;
delete from t1 where a between 100 * 16 and 100 * 16 + 30; INSERT INTO t1 SELECT 100*18+seq, REPEAT('A', 256)
delete from t1 where a between 100 * 15 and 100 * 15 + 30; FROM seq_70_to_99;
delete from t1 where a between 100 * 14 and 100 * 14 + 30; INSERT INTO t1 SELECT 100*17+seq, REPEAT('A', 256)
delete from t1 where a between 100 * 13 and 100 * 13 + 30; FROM seq_70_to_99;
delete from t1 where a between 100 * 12 and 100 * 12 + 30; INSERT INTO t1 SELECT 100*16+seq, REPEAT('A', 256)
delete from t1 where a between 100 * 11 and 100 * 11 + 30; FROM seq_70_to_99;
delete from t1 where a between 100 * 10 and 100 * 10 + 30; INSERT INTO t1 SELECT 100*15+seq, REPEAT('A', 256)
delete from t1 where a between 100 * 9 and 100 * 9 + 30; FROM seq_70_to_99;
delete from t1 where a between 100 * 8 and 100 * 8 + 30; INSERT INTO t1 SELECT 100*14+seq, REPEAT('A', 256)
delete from t1 where a between 100 * 7 and 100 * 7 + 30; FROM seq_70_to_99;
delete from t1 where a between 100 * 6 and 100 * 6 + 30; INSERT INTO t1 SELECT 100*13+seq, REPEAT('A', 256)
delete from t1 where a between 100 * 5 and 100 * 5 + 30; FROM seq_70_to_99;
delete from t1 where a between 100 * 4 and 100 * 4 + 30; INSERT INTO t1 SELECT 100*12+seq, REPEAT('A', 256)
delete from t1 where a between 100 * 3 and 100 * 3 + 30; FROM seq_70_to_99;
delete from t1 where a between 100 * 2 and 100 * 2 + 30; INSERT INTO t1 SELECT 100*11+seq, REPEAT('A', 256)
delete from t1 where a between 100 * 1 and 100 * 1 + 30; FROM seq_70_to_99;
COMMIT; INSERT INTO t1 SELECT 100*10+seq, REPEAT('A', 256)
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); FROM seq_70_to_99;
count(stat_value) > 0 INSERT INTO t1 SELECT 100*9+seq, REPEAT('A', 256)
1 FROM seq_70_to_99;
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); INSERT INTO t1 SELECT 100*8+seq, REPEAT('A', 256)
count(stat_value) = 0 FROM seq_70_to_99;
1 INSERT INTO t1 SELECT 100*7+seq, REPEAT('A', 256)
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); FROM seq_70_to_99;
count(stat_value) > 0 INSERT INTO t1 SELECT 100*6+seq, REPEAT('A', 256)
FROM seq_70_to_99;
INSERT INTO t1 SELECT 100*5+seq, REPEAT('A', 256)
FROM seq_70_to_99;
INSERT INTO t1 SELECT 100*4+seq, REPEAT('A', 256)
FROM seq_70_to_99;
INSERT INTO t1 SELECT 100*3+seq, REPEAT('A', 256)
FROM seq_70_to_99;
INSERT INTO t1 SELECT 100*2+seq, REPEAT('A', 256)
FROM seq_70_to_99;
INSERT INTO t1 SELECT 100*1+seq, REPEAT('A', 256)
FROM seq_70_to_99;
ROLLBACK;
SELECT @@GLOBAL.innodb_force_recovery<2 "have background defragmentation";
have background defragmentation
1 1
SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
table_name index_name stat_name
t1 PRIMARY n_leaf_pages_defrag
t1 PRIMARY n_leaf_pages_reserved
t1 PRIMARY n_page_split
t1 SECOND n_leaf_pages_defrag
t1 SECOND n_leaf_pages_reserved
t1 SECOND n_page_split
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status OK test.t1 optimize status OK
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
count(stat_value) > 0 table_name index_name stat_name
1 t1 PRIMARY n_leaf_pages_defrag
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); t1 PRIMARY n_leaf_pages_reserved
count(stat_value) > 0 t1 PRIMARY n_page_split
1 t1 PRIMARY n_pages_freed
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); t1 SECOND n_leaf_pages_defrag
count(stat_value) > 0 t1 SECOND n_leaf_pages_reserved
1 t1 SECOND n_page_split
t1 SECOND n_pages_freed
set global innodb_defragment_stats_accuracy = 40; set global innodb_defragment_stats_accuracy = 40;
INSERT INTO t1 (b) SELECT b from t1; INSERT INTO t1 (b) SELECT b from t1;
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
count(stat_value) > 0 table_name index_name stat_name
1 t1 PRIMARY n_leaf_pages_defrag
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); t1 PRIMARY n_leaf_pages_reserved
count(stat_value) > 0 t1 PRIMARY n_page_split
1 t1 PRIMARY n_pages_freed
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); t1 SECOND n_leaf_pages_defrag
count(stat_value) > 0 t1 SECOND n_leaf_pages_reserved
1 t1 SECOND n_page_split
t1 SECOND n_pages_freed
INSERT INTO t1 (b) SELECT b from t1; INSERT INTO t1 (b) SELECT b from t1;
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); SELECT stat_name FROM mysql.innodb_index_stats WHERE table_name='t1';
count(stat_value) > 0 stat_name
1 n_leaf_pages_defrag
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); n_leaf_pages_defrag
count(stat_value) > 0 n_leaf_pages_reserved
1 n_leaf_pages_reserved
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); n_page_split
count(stat_value) > 0 n_page_split
1 n_pages_freed
n_pages_freed
# Table rename should cause stats rename. # Table rename should cause stats rename.
rename table t1 to t2; rename table t1 to t2;
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
count(stat_value) = 0 table_name index_name stat_name
1 t2 PRIMARY n_leaf_pages_defrag
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); t2 PRIMARY n_leaf_pages_reserved
count(stat_value) = 0 t2 PRIMARY n_page_split
1 t2 PRIMARY n_pages_freed
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); t2 SECOND n_leaf_pages_defrag
count(stat_value) = 0 t2 SECOND n_leaf_pages_reserved
1 t2 SECOND n_page_split
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_page_split'); t2 SECOND n_pages_freed
count(stat_value) > 0
1
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed');
count(stat_value) > 0
1
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_leaf_pages_defrag');
count(stat_value) > 0
1
# Drop index should cause stats drop, but will not.
drop index SECOND on t2; drop index SECOND on t2;
SELECT stat_name, stat_value>0 FROM mysql.innodb_index_stats
WHERE table_name like '%t2%' AND index_name='SECOND';
stat_name stat_value>0
# #
# MDEV-26636: Statistics must not be written for temporary tables # MDEV-26636: Statistics must not be written for temporary tables
# #
@@ -123,15 +120,12 @@ CREATE TEMPORARY TABLE t (a INT PRIMARY KEY, c CHAR(255) NOT NULL)
ENGINE=InnoDB; ENGINE=InnoDB;
INSERT INTO t SELECT seq, '' FROM seq_1_to_100; INSERT INTO t SELECT seq, '' FROM seq_1_to_100;
# restart # restart
SELECT * FROM mysql.innodb_index_stats where table_name like '%t1%'; SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
database_name table_name index_name last_update stat_name stat_value sample_size stat_description table_name index_name stat_name
SELECT table_name, index_name, stat_name, stat_value>0 t2 PRIMARY n_leaf_pages_defrag
FROM mysql.innodb_index_stats; t2 PRIMARY n_leaf_pages_reserved
table_name index_name stat_name stat_value>0 t2 PRIMARY n_page_split
t2 PRIMARY n_leaf_pages_defrag 1 t2 PRIMARY n_pages_freed
t2 PRIMARY n_leaf_pages_reserved 1
t2 PRIMARY n_page_split 1
t2 PRIMARY n_pages_freed 0
# Clean up # Clean up
ALTER TABLE t2 STATS_PERSISTENT=1; ALTER TABLE t2 STATS_PERSISTENT=1;
DROP TABLE t2; DROP TABLE t2;

View File

@@ -11,74 +11,60 @@ DELETE FROM mysql.innodb_index_stats;
CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256),
KEY SECOND(a, b)) ENGINE=INNODB STATS_PERSISTENT=0; KEY SECOND(a, b)) ENGINE=INNODB STATS_PERSISTENT=0;
INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_1_to_1024; INSERT INTO t1 SELECT 100*FLOOR(seq/70)+seq%70, REPEAT('A', 256)
FROM seq_1_to_1024;
--echo # Not enough page splits to trigger persistent stats write yet. --echo # Not enough page splits to trigger persistent stats write yet.
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); SELECT * FROM mysql.innodb_index_stats;
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed');
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag');
INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_1025_to_2048; INSERT INTO t1 SELECT 100*FLOOR(seq/70)+seq%70, REPEAT('A', 256)
FROM seq_1025_to_1433;
--echo # Persistent stats recorded.
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split');
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed');
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag');
--echo # Delete some rows.
BEGIN; BEGIN;
let $num_delete = 20; let $num_delete = 20;
while ($num_delete) while ($num_delete)
{ {
let $j = 100 * $num_delete; eval INSERT INTO t1 SELECT 100*$num_delete+seq, REPEAT('A', 256)
eval delete from t1 where a between $j and $j + 30; FROM seq_70_to_99;
dec $num_delete; dec $num_delete;
} }
COMMIT; ROLLBACK;
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); SELECT @@GLOBAL.innodb_force_recovery<2 "have background defragmentation";
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed');
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); # Wait for defrag_pool to be processed.
let $wait_timeout=30;
let $wait_condition = SELECT COUNT(*)>0 FROM mysql.innodb_index_stats;
--source include/wait_condition.inc
--sorted_result
SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
optimize table t1; optimize table t1;
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); --sorted_result
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag');
set global innodb_defragment_stats_accuracy = 40; set global innodb_defragment_stats_accuracy = 40;
INSERT INTO t1 (b) SELECT b from t1; INSERT INTO t1 (b) SELECT b from t1;
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); --sorted_result
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag');
INSERT INTO t1 (b) SELECT b from t1; INSERT INTO t1 (b) SELECT b from t1;
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); --sorted_result
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); SELECT stat_name FROM mysql.innodb_index_stats WHERE table_name='t1';
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag');
--echo # Table rename should cause stats rename. --echo # Table rename should cause stats rename.
rename table t1 to t2; rename table t1 to t2;
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split');
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed');
select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag');
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_page_split');
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed');
select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_leaf_pages_defrag');
--echo # Drop index should cause stats drop, but will not.
drop index SECOND on t2;
--sorted_result --sorted_result
SELECT stat_name, stat_value>0 FROM mysql.innodb_index_stats SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
WHERE table_name like '%t2%' AND index_name='SECOND';
drop index SECOND on t2;
--echo # --echo #
--echo # MDEV-26636: Statistics must not be written for temporary tables --echo # MDEV-26636: Statistics must not be written for temporary tables
@@ -90,14 +76,12 @@ INSERT INTO t SELECT seq, '' FROM seq_1_to_100;
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
SELECT * FROM mysql.innodb_index_stats where table_name like '%t1%';
--sorted_result --sorted_result
SELECT table_name, index_name, stat_name, stat_value>0 SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
FROM mysql.innodb_index_stats;
--echo # Clean up --echo # Clean up
# DROP TABLE will not touch persistent statistics if the table has none! # Starting with 10.6, DROP TABLE will not touch persistent statistics
# (not defragmentation statistics either) if the table has none!
ALTER TABLE t2 STATS_PERSISTENT=1; ALTER TABLE t2 STATS_PERSISTENT=1;
DROP TABLE t2; DROP TABLE t2;

View File

@@ -54,7 +54,7 @@ let $trx_after= `select substr('$trx_after',9)`;
drop table t1, t2; drop table t1, t2;
if ($trx_before != $trx_after) if ($trx_before > $trx_after)
{ {
echo Transaction sequence mismatch: $trx_before != $trx_after; echo Transaction sequence mismatch: $trx_before > $trx_after;
} }

View File

@@ -24,3 +24,19 @@ VARIABLE_VALUE>0 VARIABLE_NAME
1 Collation used utf8mb3_bin 1 Collation used utf8mb3_bin
1 Collation used utf8mb3_general_ci 1 Collation used utf8mb3_general_ci
1 Collation used utf8mb4_bin 1 Collation used utf8mb4_bin
prepare stmt from "SELECT VARIABLE_VALUE>0, VARIABLE_NAME FROM INFORMATION_SCHEMA.FEEDBACK WHERE VARIABLE_NAME LIKE 'Collation used %' ORDER BY VARIABLE_NAME";
execute stmt;
VARIABLE_VALUE>0 VARIABLE_NAME
1 Collation used binary
1 Collation used latin1_swedish_ci
1 Collation used utf8mb3_bin
1 Collation used utf8mb3_general_ci
1 Collation used utf8mb4_bin
execute stmt;
VARIABLE_VALUE>0 VARIABLE_NAME
1 Collation used binary
1 Collation used latin1_swedish_ci
1 Collation used utf8mb3_bin
1 Collation used utf8mb3_general_ci
1 Collation used utf8mb4_bin
deallocate prepare stmt;

View File

@@ -42,3 +42,10 @@ if (`SELECT VERSION() LIKE '%embedded%'`)
SELECT VARIABLE_VALUE>0, VARIABLE_NAME FROM INFORMATION_SCHEMA.FEEDBACK SELECT VARIABLE_VALUE>0, VARIABLE_NAME FROM INFORMATION_SCHEMA.FEEDBACK
WHERE VARIABLE_NAME LIKE 'Collation used %' WHERE VARIABLE_NAME LIKE 'Collation used %'
ORDER BY VARIABLE_NAME; ORDER BY VARIABLE_NAME;
prepare stmt from "SELECT VARIABLE_VALUE>0, VARIABLE_NAME FROM INFORMATION_SCHEMA.FEEDBACK WHERE VARIABLE_NAME LIKE 'Collation used %' ORDER BY VARIABLE_NAME";
execute stmt;
execute stmt;
deallocate prepare stmt;

View File

@@ -55,6 +55,7 @@ IF (WIN32)
my_winerr.c my_winerr.c
my_winfile.c my_winfile.c
my_conio.c my_conio.c
my_minidump.cc
my_win_popen.cc) my_win_popen.cc)
ENDIF() ENDIF()
@@ -173,7 +174,7 @@ IF(HAVE_BFD_H)
ENDIF(HAVE_BFD_H) ENDIF(HAVE_BFD_H)
IF (WIN32) IF (WIN32)
TARGET_LINK_LIBRARIES(mysys IPHLPAPI) TARGET_LINK_LIBRARIES(mysys iphlpapi dbghelp)
ENDIF(WIN32) ENDIF(WIN32)
# Need explicit pthread for gcc -fsanitize=address # Need explicit pthread for gcc -fsanitize=address

115
mysys/my_minidump.cc Normal file
View File

@@ -0,0 +1,115 @@
/* Copyright (c) 2021, MariaDB Corporation
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-1335 USA */
#include <windows.h>
#include <dbghelp.h>
#include <stdio.h>
#include <my_minidump.h>
#define VERBOSE(fmt,...) \
if (verbose) { fprintf(stderr, "my_create_minidump : " fmt,__VA_ARGS__); }
extern "C" BOOL my_create_minidump(DWORD pid, BOOL verbose)
{
HANDLE file = 0;
HANDLE process= 0;
DWORD size= MAX_PATH;
char path[MAX_PATH];
char working_dir[MAX_PATH];
char tmpname[MAX_PATH];
char *filename= 0;
bool ret= FALSE;
process= OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
if (!process)
{
VERBOSE("cannot open process pid=%lu to create dump, last error %lu\n",
pid, GetLastError());
goto exit;
}
if (QueryFullProcessImageName(process, 0, path, &size) == 0)
{
VERBOSE("cannot read process path for pid %lu, last error %lu\n",
pid, GetLastError());
goto exit;
}
filename= strrchr(path, '\\');
if (filename)
{
filename++;
// We are not interested in dump of some proceses (my_safe_process.exe,cmd.exe)
// since they are only used to start up other programs.
// We're interested however in their children;
const char *exclude_programs[] = {"my_safe_process.exe","cmd.exe", 0};
for(size_t i=0; exclude_programs[i]; i++)
if (_stricmp(filename, exclude_programs[i]) == 0)
goto exit;
}
else
filename= path;
// Add .dmp extension
char *p;
if ((p= strrchr(filename, '.')) == 0)
p= filename + strlen(filename);
strncpy(p, ".dmp", path + MAX_PATH - p);
// Íf file with this name exist, generate unique name with .dmp extension
if (GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES)
{
if (!GetTempFileName(".", filename, 0, tmpname))
{
fprintf(stderr, "GetTempFileName failed, last error %lu", GetLastError());
goto exit;
}
strncat_s(tmpname, ".dmp", sizeof(tmpname));
filename= tmpname;
}
if (!GetCurrentDirectory(MAX_PATH, working_dir))
{
VERBOSE("GetCurrentDirectory failed, last error %lu", GetLastError());
goto exit;
}
file= CreateFile(filename, GENERIC_READ | GENERIC_WRITE,
0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (file == INVALID_HANDLE_VALUE)
{
VERBOSE("CreateFile() failed for file %s, working dir %s, last error = %lu\n",
filename, working_dir, GetLastError());
goto exit;
}
if (!MiniDumpWriteDump(process, pid, file, MiniDumpNormal, 0, 0, 0))
{
VERBOSE("Failed to write minidump to %s, working dir %s, last error %lu\n",
filename, working_dir, GetLastError());
goto exit;
}
VERBOSE("Minidump written to %s, directory %s\n", filename, working_dir);
ret= TRUE;
exit:
if (process != 0 && process != INVALID_HANDLE_VALUE)
CloseHandle(process);
if (file != 0 && file != INVALID_HANDLE_VALUE)
CloseHandle(file);
return ret;
}

View File

@@ -92,17 +92,19 @@ static COND * const OOM= (COND*)1;
static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter) static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter)
{ {
Item_cond_or *res= NULL; Item_cond_or *res= NULL;
Name_resolution_context nrc; /* A reference to this context will be stored in Item_field */
Name_resolution_context *nrc= new (thd->mem_root) Name_resolution_context;
LEX_CSTRING &db= tables->db; LEX_CSTRING &db= tables->db;
LEX_CSTRING &table= tables->alias; LEX_CSTRING &table= tables->alias;
LEX_CSTRING &field= tables->table->field[0]->field_name; LEX_CSTRING &field= tables->table->field[0]->field_name;
CHARSET_INFO *cs= &my_charset_latin1; CHARSET_INFO *cs= &my_charset_latin1;
if (!filter->str) if (!filter->str || !nrc)
return 0; return 0;
nrc.init(); nrc->init();
nrc.resolve_in_table_list_only(tables); nrc->resolve_in_table_list_only(tables);
nrc->select_lex= tables->select_lex;
res= new (thd->mem_root) Item_cond_or(thd); res= new (thd->mem_root) Item_cond_or(thd);
if (!res) if (!res)
@@ -110,7 +112,7 @@ static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter)
for (; filter->str; filter++) for (; filter->str; filter++)
{ {
Item_field *fld= new (thd->mem_root) Item_field(thd, &nrc, db, table, Item_field *fld= new (thd->mem_root) Item_field(thd, nrc, db, table,
field); field);
Item_string *pattern= new (thd->mem_root) Item_string(thd, filter->str, Item_string *pattern= new (thd->mem_root) Item_string(thd, filter->str,
(uint) filter->length, cs); (uint) filter->length, cs);

View File

@@ -1065,8 +1065,9 @@ check_for_dhparams()
# #
verify_ca_matches_cert() verify_ca_matches_cert()
{ {
local ca_path="$1" local ca="$1"
local cert_path="$2" local cert="$2"
local path=${3:-0}
# If the openssl utility is not installed, then # If the openssl utility is not installed, then
# we will not do this certificate check: # we will not do this certificate check:
@@ -1075,8 +1076,15 @@ verify_ca_matches_cert()
return return
fi fi
if ! "$OPENSSL_BINARY" verify -verbose -CAfile "$ca_path" "$cert_path" >/dev/null 2>&1 local not_match=0
then
if [ $path -eq 0 ]; then
"$OPENSSL_BINARY" verify -verbose -CAfile "$ca" "$cert" >/dev/null 2>&1 || not_match=1
else
"$OPENSSL_BINARY" verify -verbose -CApath "$ca" "$cert" >/dev/null 2>&1 || not_match=1
fi
if [ $not_match -eq 1 ]; then
wsrep_log_error "******** FATAL ERROR ********************************************" wsrep_log_error "******** FATAL ERROR ********************************************"
wsrep_log_error "* The certifcate and CA (certificate authority) do not match. *" wsrep_log_error "* The certifcate and CA (certificate authority) do not match. *"
wsrep_log_error "* It does not appear that the certificate was issued by the CA. *" wsrep_log_error "* It does not appear that the certificate was issued by the CA. *"

View File

@@ -34,6 +34,7 @@ ssyslog=""
ssystag="" ssystag=""
BACKUP_PID="" BACKUP_PID=""
tcert="" tcert=""
tpath=0
tpem="" tpem=""
tkey="" tkey=""
tmode="DISABLED" tmode="DISABLED"
@@ -85,7 +86,6 @@ readonly SECRET_TAG="secret"
# Required for backup locks # Required for backup locks
# For backup locks it is 1 sent by joiner # For backup locks it is 1 sent by joiner
# 5.6.21 PXC and later can't donate to an older joiner
sst_ver=1 sst_ver=1
if [ -n "$(command -v pv)" ] && pv --help | grep -qw -- '-F'; then if [ -n "$(command -v pv)" ] && pv --help | grep -qw -- '-F'; then
@@ -339,64 +339,83 @@ get_transfer()
fi fi
fi fi
CN_option=",commonname=''"
if [ $encrypt -eq 2 ]; then if [ $encrypt -eq 2 ]; then
wsrep_log_info "Using openssl based encryption with socat: with crt and pem" wsrep_log_info "Using openssl based encryption with socat: with crt and pem"
if [ -z "$tpem" -o -z "$tcert" ]; then if [ -z "$tpem" -o -z "$tcert" ]; then
wsrep_log_error "Both PEM and CRT files required" wsrep_log_error \
"Both PEM file and CRT file (or path) are required"
exit 22 exit 22
fi fi
if [ ! -r "$tpem" -o ! -r "$tcert" ]; then if [ ! -r "$tpem" -o ! -r "$tcert" ]; then
wsrep_log_error "Both PEM and CRT files must be readable" wsrep_log_error \
"Both PEM file and CRT file (or path) must be readable"
exit 22 exit 22
fi fi
verify_ca_matches_cert "$tcert" "$tpem" verify_ca_matches_cert "$tcert" "$tpem" $tpath
tcmd="$tcmd,cert='$tpem',cafile='$tcert'$sockopt" if [ $tpath -eq 0 ]; then
tcmd="$tcmd,cert='$tpem',cafile='$tcert'"
else
tcmd="$tcmd,cert='$tpem',capath='$tcert'"
fi
stagemsg="$stagemsg-OpenSSL-Encrypted-2" stagemsg="$stagemsg-OpenSSL-Encrypted-2"
wsrep_log_info "$action with cert=$tpem, cafile=$tcert" wsrep_log_info "$action with cert=$tpem, ca=$tcert"
elif [ $encrypt -eq 3 -o $encrypt -eq 4 ]; then elif [ $encrypt -eq 3 -o $encrypt -eq 4 ]; then
wsrep_log_info "Using openssl based encryption with socat: with key and crt" wsrep_log_info "Using openssl based encryption with socat: with key and crt"
if [ -z "$tpem" -o -z "$tkey" ]; then if [ -z "$tpem" -o -z "$tkey" ]; then
wsrep_log_error "Both certificate and key files required" wsrep_log_error "Both certificate file (or path) " \
"and key file are required"
exit 22 exit 22
fi fi
if [ ! -r "$tpem" -o ! -r "$tkey" ]; then if [ ! -r "$tpem" -o ! -r "$tkey" ]; then
wsrep_log_error "Both certificate and key files must be readable" wsrep_log_error "Both certificate file (or path) " \
"and key file must be readable"
exit 22 exit 22
fi fi
verify_cert_matches_key "$tpem" "$tkey" verify_cert_matches_key "$tpem" "$tkey"
stagemsg="$stagemsg-OpenSSL-Encrypted-3" stagemsg="$stagemsg-OpenSSL-Encrypted-3"
if [ -z "$tcert" ]; then if [ -z "$tcert" ]; then
if [ $encrypt -eq 4 ]; then if [ $encrypt -eq 4 ]; then
wsrep_log_error "Peer certificate required if encrypt=4" wsrep_log_error \
"Peer certificate file (or path) required if encrypt=4"
exit 22 exit 22
fi fi
# no verification # no verification
tcmd="$tcmd,cert='$tpem',key='$tkey',verify=0$sockopt" CN_option=""
tcmd="$tcmd,cert='$tpem',key='$tkey',verify=0"
wsrep_log_info "$action with cert=$tpem, key=$tkey, verify=0" wsrep_log_info "$action with cert=$tpem, key=$tkey, verify=0"
else else
# CA verification # CA verification
if [ ! -r "$tcert" ]; then if [ ! -r "$tcert" ]; then
wsrep_log_error "Certificate file must be readable" wsrep_log_error "Certificate file or path must be readable"
exit 22 exit 22
fi fi
verify_ca_matches_cert "$tcert" "$tpem" verify_ca_matches_cert "$tcert" "$tpem" $tpath
if [ -n "$WSREP_SST_OPT_REMOTE_USER" ]; then if [ -n "$WSREP_SST_OPT_REMOTE_USER" ]; then
CN_option=",commonname='$WSREP_SST_OPT_REMOTE_USER'" CN_option=",commonname='$WSREP_SST_OPT_REMOTE_USER'"
elif [ $encrypt -eq 4 ]; then elif [ "$WSREP_SST_OPT_ROLE" = 'joiner' -o $encrypt -eq 4 ]
then
CN_option=",commonname=''" CN_option=",commonname=''"
elif is_local_ip "$WSREP_SST_OPT_HOST_UNESCAPED"; then elif is_local_ip "$WSREP_SST_OPT_HOST_UNESCAPED"; then
CN_option=',commonname=localhost' CN_option=',commonname=localhost'
else else
CN_option=",commonname='$WSREP_SST_OPT_HOST_UNESCAPED'" CN_option=",commonname='$WSREP_SST_OPT_HOST_UNESCAPED'"
fi fi
tcmd="$tcmd,cert='$tpem',key='$tkey',cafile='$tcert'$CN_option$sockopt" if [ $tpath -eq 0 ]; then
wsrep_log_info "$action with cert=$tpem, key=$tkey, cafile=$tcert" tcmd="$tcmd,cert='$tpem',key='$tkey',cafile='$tcert'"
else
tcmd="$tcmd,cert='$tpem',key='$tkey',capath='$tcert'"
fi
wsrep_log_info "$action with cert=$tpem, key=$tkey, ca=$tcert"
fi fi
else else
wsrep_log_info "Unknown encryption mode: encrypt=$encrypt" wsrep_log_info "Unknown encryption mode: encrypt=$encrypt"
exit 22 exit 22
fi fi
tcmd="$tcmd$CN_option$sockopt"
if [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then if [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then
tcmd="$tcmd stdio" tcmd="$tcmd stdio"
fi fi
@@ -473,6 +492,12 @@ check_server_ssl_config()
"of the tca, tcert and/or tkey in the [sst] section" "of the tca, tcert and/or tkey in the [sst] section"
fi fi
fi fi
if [ -n "$tcert" ]; then
tcert=$(trim_string "$tcert")
if [ "${tcert%/}" != "$tcert" ]; then
tpath=1
fi
fi
} }
read_cnf() read_cnf()

View File

@@ -236,11 +236,18 @@ check_server_ssl_config()
SSLMODE=$(parse_cnf "$SST_SECTIONS" 'ssl-mode' | tr [:lower:] [:upper:]) SSLMODE=$(parse_cnf "$SST_SECTIONS" 'ssl-mode' | tr [:lower:] [:upper:])
# no old-style SSL config in [sst], check for new one: # no old-style SSL config in [sst], check for new one:
if [ -z "$SSTKEY" -a -z "$SSTCERT" -a -z "$SSTCA" ] if [ -z "$SSTKEY" -a -z "$SSTCERT" -a -z "$SSTCA" ]; then
then
check_server_ssl_config check_server_ssl_config
fi fi
SSTPATH=0
if [ -n "$SSTCA" ]; then
SSTCA=$(trim_string "$SSTCA")
if [ "${SSTCA%/}" != "$SSTCA" ]; then
SSTPATH=1
fi
fi
if [ -z "$SSLMODE" ]; then if [ -z "$SSLMODE" ]; then
# Implicit verification if CA is set and the SSL mode # Implicit verification if CA is set and the SSL mode
# is not specified by user: # is not specified by user:
@@ -254,9 +261,19 @@ if [ -z "$SSLMODE" ]; then
fi fi
fi fi
if [ -n "$SSTCA" ] if [ -n "$SSTCERT" -a -n "$SSTKEY" ]; then
then verify_cert_matches_key "$SSTCERT" "$SSTKEY"
fi
if [ -n "$SSTCA" ]; then
if [ $SSTPATH -eq 0 ]; then
CAFILE_OPT="CAfile = $SSTCA" CAFILE_OPT="CAfile = $SSTCA"
else
CAFILE_OPT="CApath = $SSTCA"
fi
if [ -n "$SSTCERT" ]; then
verify_ca_matches_cert "$SSTCA" "$SSTCERT" $SSTPATH
fi
else else
CAFILE_OPT="" CAFILE_OPT=""
fi fi
@@ -272,9 +289,19 @@ then
;; ;;
'VERIFY_CA') 'VERIFY_CA')
VERIFY_OPT='verifyChain = yes' VERIFY_OPT='verifyChain = yes'
;;
*)
wsrep_log_error "Unrecognized ssl-mode option: '$SSLMODE'"
exit 22 # EINVAL
;;
esac
if [ -z "$SSTCA" ]; then
wsrep_log_error "Can't have ssl-mode='$SSLMODE' without CA file or path"
exit 22 # EINVAL
fi
if [ -n "$WSREP_SST_OPT_REMOTE_USER" ]; then if [ -n "$WSREP_SST_OPT_REMOTE_USER" ]; then
CHECK_OPT="checkHost = $WSREP_SST_OPT_REMOTE_USER" CHECK_OPT="checkHost = $WSREP_SST_OPT_REMOTE_USER"
else elif [ "$WSREP_SST_OPT_ROLE" = 'donor' ]; then
# check if the address is an ip-address (v4 or v6): # check if the address is an ip-address (v4 or v6):
if echo "$WSREP_SST_OPT_HOST_UNESCAPED" | \ if echo "$WSREP_SST_OPT_HOST_UNESCAPED" | \
grep -q -E '^([0-9]+(\.[0-9]+){3}|[0-9a-fA-F]*(\:[0-9a-fA-F]*)+)$' grep -q -E '^([0-9]+(\.[0-9]+){3}|[0-9a-fA-F]*(\:[0-9a-fA-F]*)+)$'
@@ -287,23 +314,13 @@ then
CHECK_OPT_LOCAL="checkHost = localhost" CHECK_OPT_LOCAL="checkHost = localhost"
fi fi
fi fi
;;
*)
wsrep_log_error "Unrecognized ssl-mode option: '$SSLMODE'"
exit 22 # EINVAL
;;
esac
if [ -z "$CAFILE_OPT" ]; then
wsrep_log_error "Can't have ssl-mode='$SSLMODE' without CA file"
exit 22 # EINVAL
fi
fi fi
STUNNEL="" STUNNEL=""
if [ -n "$SSLMODE" -a "$SSLMODE" != 'DISABLED' ]; then if [ -n "$SSLMODE" -a "$SSLMODE" != 'DISABLED' ]; then
STUNNEL_BIN="$(command -v stunnel)" STUNNEL_BIN="$(command -v stunnel)"
if [ -n "$STUNNEL_BIN" ]; then if [ -n "$STUNNEL_BIN" ]; then
wsrep_log_info "Using stunnel for SSL encryption: CAfile: '$SSTCA', ssl-mode='$SSLMODE'" wsrep_log_info "Using stunnel for SSL encryption: CA: '$SSTCA', ssl-mode='$SSLMODE'"
STUNNEL="$STUNNEL_BIN $STUNNEL_CONF" STUNNEL="$STUNNEL_BIN $STUNNEL_CONF"
fi fi
fi fi

View File

@@ -71,11 +71,12 @@ bool cmp_items(Item *a, Item *b)
/** /**
Set max_sum_func_level if it is needed Set max_sum_func_level if it is needed
*/ */
inline void set_max_sum_func_level(THD *thd, SELECT_LEX *select) inline void set_max_sum_func_level(SELECT_LEX *select)
{ {
if (thd->lex->in_sum_func && LEX *lex_s= select->parent_lex;
thd->lex->in_sum_func->nest_level >= select->nest_level) if (lex_s->in_sum_func &&
set_if_bigger(thd->lex->in_sum_func->max_sum_func_level, lex_s->in_sum_func->nest_level >= select->nest_level)
set_if_bigger(lex_s->in_sum_func->max_sum_func_level,
select->nest_level - 1); select->nest_level - 1);
} }
@@ -654,6 +655,7 @@ Item_ident::Item_ident(THD *thd, Name_resolution_context *context_arg,
can_be_depended(TRUE), alias_name_used(FALSE) can_be_depended(TRUE), alias_name_used(FALSE)
{ {
name= field_name_arg; name= field_name_arg;
DBUG_ASSERT(!context || context->select_lex);
} }
@@ -671,6 +673,7 @@ Item_ident::Item_ident(THD *thd, TABLE_LIST *view_arg,
can_be_depended(TRUE), alias_name_used(FALSE) can_be_depended(TRUE), alias_name_used(FALSE)
{ {
name= field_name_arg; name= field_name_arg;
DBUG_ASSERT(!context || context->select_lex);
} }
@@ -692,7 +695,9 @@ Item_ident::Item_ident(THD *thd, Item_ident *item)
cached_field_index(item->cached_field_index), cached_field_index(item->cached_field_index),
can_be_depended(item->can_be_depended), can_be_depended(item->can_be_depended),
alias_name_used(item->alias_name_used) alias_name_used(item->alias_name_used)
{} {
DBUG_ASSERT(!context || context->select_lex);
}
void Item_ident::cleanup() void Item_ident::cleanup()
{ {
@@ -5533,6 +5538,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
Name_resolution_context *last_checked_context= context; Name_resolution_context *last_checked_context= context;
Item **ref= (Item **) not_found_item; Item **ref= (Item **) not_found_item;
SELECT_LEX *current_sel= context->select_lex; SELECT_LEX *current_sel= context->select_lex;
LEX *lex_s= current_sel->parent_lex;
Name_resolution_context *outer_context= 0; Name_resolution_context *outer_context= 0;
SELECT_LEX *select= 0; SELECT_LEX *select= 0;
@@ -5634,18 +5640,18 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
return -1; return -1;
thd->change_item_tree(reference, rf); thd->change_item_tree(reference, rf);
select->inner_refs_list.push_back(rf, thd->mem_root); select->inner_refs_list.push_back(rf, thd->mem_root);
rf->in_sum_func= thd->lex->in_sum_func; rf->in_sum_func= lex_s->in_sum_func;
} }
/* /*
A reference is resolved to a nest level that's outer or the same as A reference is resolved to a nest level that's outer or the same as
the nest level of the enclosing set function : adjust the value of the nest level of the enclosing set function : adjust the value of
max_arg_level for the function if it's needed. max_arg_level for the function if it's needed.
*/ */
if (thd->lex->in_sum_func && if (lex_s->in_sum_func &&
thd->lex->in_sum_func->nest_level >= select->nest_level) lex_s->in_sum_func->nest_level >= select->nest_level)
{ {
Item::Type ref_type= (*reference)->type(); Item::Type ref_type= (*reference)->type();
set_if_bigger(thd->lex->in_sum_func->max_arg_level, set_if_bigger(lex_s->in_sum_func->max_arg_level,
select->nest_level); select->nest_level);
set_field(*from_field); set_field(*from_field);
base_flags|= item_base_t::FIXED; base_flags|= item_base_t::FIXED;
@@ -5666,10 +5672,10 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
((ref_type == REF_ITEM || ref_type == FIELD_ITEM) ? ((ref_type == REF_ITEM || ref_type == FIELD_ITEM) ?
(Item_ident*) (*reference) : (Item_ident*) (*reference) :
0), false); 0), false);
if (thd->lex->in_sum_func && if (lex_s->in_sum_func &&
thd->lex->in_sum_func->nest_level >= select->nest_level) lex_s->in_sum_func->nest_level >= select->nest_level)
{ {
set_if_bigger(thd->lex->in_sum_func->max_arg_level, set_if_bigger(lex_s->in_sum_func->max_arg_level,
select->nest_level); select->nest_level);
} }
/* /*
@@ -5762,7 +5768,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
{ {
outer_context->select_lex->inner_refs_list.push_back((Item_outer_ref*)rf, outer_context->select_lex->inner_refs_list.push_back((Item_outer_ref*)rf,
thd->mem_root); thd->mem_root);
((Item_outer_ref*)rf)->in_sum_func= thd->lex->in_sum_func; ((Item_outer_ref*)rf)->in_sum_func= lex_s->in_sum_func;
} }
thd->change_item_tree(reference, rf); thd->change_item_tree(reference, rf);
/* /*
@@ -5777,7 +5783,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
We can not "move" aggregate function in the place where We can not "move" aggregate function in the place where
its arguments are not defined. its arguments are not defined.
*/ */
set_max_sum_func_level(thd, select); set_max_sum_func_level(select);
mark_as_dependent(thd, last_checked_context->select_lex, mark_as_dependent(thd, last_checked_context->select_lex,
context->select_lex, rf, context->select_lex, rf,
rf, false); rf, false);
@@ -5790,7 +5796,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
We can not "move" aggregate function in the place where We can not "move" aggregate function in the place where
its arguments are not defined. its arguments are not defined.
*/ */
set_max_sum_func_level(thd, select); set_max_sum_func_level(select);
mark_as_dependent(thd, last_checked_context->select_lex, mark_as_dependent(thd, last_checked_context->select_lex,
context->select_lex, context->select_lex,
this, (Item_ident*)*reference, false); this, (Item_ident*)*reference, false);
@@ -5869,7 +5875,20 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
DBUG_ASSERT(fixed() == 0); DBUG_ASSERT(fixed() == 0);
Field *from_field= (Field *)not_found_field; Field *from_field= (Field *)not_found_field;
bool outer_fixed= false; bool outer_fixed= false;
SELECT_LEX *select= context->select_lex; SELECT_LEX *select;
LEX *lex_s;
if (context)
{
select= context->select_lex;
lex_s= context->select_lex->parent_lex;
}
else
{
// No real name resolution, used somewhere in SP
DBUG_ASSERT(field);
select= NULL;
lex_s= NULL;
}
if (select && select->in_tvc) if (select && select->in_tvc)
{ {
@@ -5938,7 +5957,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
We can not "move" aggregate function in the place where We can not "move" aggregate function in the place where
its arguments are not defined. its arguments are not defined.
*/ */
set_max_sum_func_level(thd, select); set_max_sum_func_level(select);
set_field(new_field); set_field(new_field);
depended_from= (*((Item_field**)res))->depended_from; depended_from= (*((Item_field**)res))->depended_from;
return 0; return 0;
@@ -5967,7 +5986,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
We can not "move" aggregate function in the place where We can not "move" aggregate function in the place where
its arguments are not defined. its arguments are not defined.
*/ */
set_max_sum_func_level(thd, select); set_max_sum_func_level(select);
return FALSE; return FALSE;
} }
} }
@@ -6004,10 +6023,11 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
goto mark_non_agg_field; goto mark_non_agg_field;
} }
if (thd->lex->in_sum_func && if (lex_s &&
thd->lex->in_sum_func->nest_level == lex_s->in_sum_func &&
lex_s->in_sum_func->nest_level ==
select->nest_level) select->nest_level)
set_if_bigger(thd->lex->in_sum_func->max_arg_level, set_if_bigger(lex_s->in_sum_func->max_arg_level,
select->nest_level); select->nest_level);
/* /*
if it is not expression from merged VIEW we will set this field. if it is not expression from merged VIEW we will set this field.
@@ -6073,8 +6093,9 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
if (field->vcol_info) if (field->vcol_info)
fix_session_vcol_expr_for_read(thd, field, field->vcol_info); fix_session_vcol_expr_for_read(thd, field, field->vcol_info);
if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY && if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
!outer_fixed && !thd->lex->in_sum_func && !outer_fixed &&
select && select &&
!lex_s->in_sum_func &&
select->cur_pos_in_select_list != UNDEF_POS && select->cur_pos_in_select_list != UNDEF_POS &&
select->join) select->join)
{ {
@@ -6109,13 +6130,13 @@ mark_non_agg_field:
*/ */
select_lex= context->select_lex; select_lex= context->select_lex;
} }
if (!thd->lex->in_sum_func) if (!lex_s || !lex_s->in_sum_func)
select_lex->set_non_agg_field_used(true); select_lex->set_non_agg_field_used(true);
else else
{ {
if (outer_fixed) if (outer_fixed)
thd->lex->in_sum_func->outer_fields.push_back(this, thd->mem_root); lex_s->in_sum_func->outer_fields.push_back(this, thd->mem_root);
else if (thd->lex->in_sum_func->nest_level != else if (lex_s->in_sum_func->nest_level !=
select->nest_level) select->nest_level)
select_lex->set_non_agg_field_used(true); select_lex->set_non_agg_field_used(true);
} }
@@ -7572,6 +7593,12 @@ Item *get_field_item_for_having(THD *thd, Item *item, st_select_lex *sel)
return NULL; return NULL;
} }
Item *Item_ident::derived_field_transformer_for_having(THD *thd, uchar *arg)
{
st_select_lex *sel= (st_select_lex *)arg;
context= &sel->context;
return this;
}
Item *Item_field::derived_field_transformer_for_having(THD *thd, uchar *arg) Item *Item_field::derived_field_transformer_for_having(THD *thd, uchar *arg)
{ {
@@ -7591,12 +7618,13 @@ Item *Item_field::derived_field_transformer_for_having(THD *thd, uchar *arg)
Item *Item_direct_view_ref::derived_field_transformer_for_having(THD *thd, Item *Item_direct_view_ref::derived_field_transformer_for_having(THD *thd,
uchar *arg) uchar *arg)
{ {
st_select_lex *sel= (st_select_lex *)arg;
context= &sel->context;
if ((*ref)->marker & MARKER_SUBSTITUTION) if ((*ref)->marker & MARKER_SUBSTITUTION)
{ {
this->marker|= MARKER_SUBSTITUTION; this->marker|= MARKER_SUBSTITUTION;
return this; return this;
} }
st_select_lex *sel= (st_select_lex *)arg;
table_map tab_map= sel->master_unit()->derived->table->map; table_map tab_map= sel->master_unit()->derived->table->map;
if ((item_equal && !(item_equal->used_tables() & tab_map)) || if ((item_equal && !(item_equal->used_tables() & tab_map)) ||
!item_equal) !item_equal)
@@ -7859,7 +7887,9 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
{ {
enum_parsing_place place= NO_MATTER; enum_parsing_place place= NO_MATTER;
DBUG_ASSERT(fixed() == 0); DBUG_ASSERT(fixed() == 0);
SELECT_LEX *current_sel= thd->lex->current_select;
SELECT_LEX *current_sel= context->select_lex;
LEX *lex_s= context->select_lex->parent_lex;
if (set_properties_only) if (set_properties_only)
{ {
@@ -8021,10 +8051,10 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
the nest level of the enclosing set function : adjust the value of the nest level of the enclosing set function : adjust the value of
max_arg_level for the function if it's needed. max_arg_level for the function if it's needed.
*/ */
if (thd->lex->in_sum_func && if (lex_s->in_sum_func &&
thd->lex->in_sum_func->nest_level >= lex_s->in_sum_func->nest_level >=
last_checked_context->select_lex->nest_level) last_checked_context->select_lex->nest_level)
set_if_bigger(thd->lex->in_sum_func->max_arg_level, set_if_bigger(lex_s->in_sum_func->max_arg_level,
last_checked_context->select_lex->nest_level); last_checked_context->select_lex->nest_level);
return FALSE; return FALSE;
} }
@@ -8044,10 +8074,10 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
the nest level of the enclosing set function : adjust the value of the nest level of the enclosing set function : adjust the value of
max_arg_level for the function if it's needed. max_arg_level for the function if it's needed.
*/ */
if (thd->lex->in_sum_func && if (lex_s->in_sum_func &&
thd->lex->in_sum_func->nest_level >= lex_s->in_sum_func->nest_level >=
last_checked_context->select_lex->nest_level) last_checked_context->select_lex->nest_level)
set_if_bigger(thd->lex->in_sum_func->max_arg_level, set_if_bigger(lex_s->in_sum_func->max_arg_level,
last_checked_context->select_lex->nest_level); last_checked_context->select_lex->nest_level);
} }
} }

View File

@@ -3504,6 +3504,7 @@ public:
Collect outer references Collect outer references
*/ */
bool collect_outer_ref_processor(void *arg) override; bool collect_outer_ref_processor(void *arg) override;
Item *derived_field_transformer_for_having(THD *thd, uchar *arg) override;
friend bool insert_fields(THD *thd, Name_resolution_context *context, friend bool insert_fields(THD *thd, Name_resolution_context *context,
const char *db_name, const char *db_name,
const char *table_name, List_iterator<Item> *it, const char *table_name, List_iterator<Item> *it,

View File

@@ -5307,6 +5307,7 @@ bool subselect_hash_sj_engine::make_semi_join_conds()
context= new (thd->mem_root) Name_resolution_context; context= new (thd->mem_root) Name_resolution_context;
context->init(); context->init();
context->select_lex= item_in->unit->first_select();
context->first_name_resolution_table= context->first_name_resolution_table=
context->last_name_resolution_table= tmp_table_ref; context->last_name_resolution_table= tmp_table_ref;
semi_join_conds_context= context; semi_join_conds_context= context;

View File

@@ -92,6 +92,7 @@ static void store_bit_fields_as_bigint_in_tempory_table(List<Item> *list)
bool Item_sum::init_sum_func_check(THD *thd) bool Item_sum::init_sum_func_check(THD *thd)
{ {
SELECT_LEX *curr_sel= thd->lex->current_select; SELECT_LEX *curr_sel= thd->lex->current_select;
LEX *lex_s= (curr_sel ? curr_sel->parent_lex : thd->lex);
if (curr_sel && curr_sel->name_visibility_map.is_clear_all()) if (curr_sel && curr_sel->name_visibility_map.is_clear_all())
{ {
for (SELECT_LEX *sl= curr_sel; sl; sl= sl->context.outer_select()) for (SELECT_LEX *sl= curr_sel; sl; sl= sl->context.outer_select())
@@ -107,9 +108,9 @@ bool Item_sum::init_sum_func_check(THD *thd)
return TRUE; return TRUE;
} }
/* Set a reference to the nesting set function if there is any */ /* Set a reference to the nesting set function if there is any */
in_sum_func= thd->lex->in_sum_func; in_sum_func= lex_s->in_sum_func;
/* Save a pointer to object to be used in items for nested set functions */ /* Save a pointer to object to be used in items for nested set functions */
thd->lex->in_sum_func= this; lex_s->in_sum_func= this;
nest_level= thd->lex->current_select->nest_level; nest_level= thd->lex->current_select->nest_level;
ref_by= 0; ref_by= 0;
aggr_level= -1; aggr_level= -1;
@@ -176,6 +177,7 @@ bool Item_sum::init_sum_func_check(THD *thd)
bool Item_sum::check_sum_func(THD *thd, Item **ref) bool Item_sum::check_sum_func(THD *thd, Item **ref)
{ {
SELECT_LEX *curr_sel= thd->lex->current_select; SELECT_LEX *curr_sel= thd->lex->current_select;
LEX *lex_s= curr_sel->parent_lex;
nesting_map allow_sum_func(thd->lex->allow_sum_func); nesting_map allow_sum_func(thd->lex->allow_sum_func);
allow_sum_func.intersect(curr_sel->name_visibility_map); allow_sum_func.intersect(curr_sel->name_visibility_map);
bool invalid= FALSE; bool invalid= FALSE;
@@ -338,7 +340,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
if (sum_func() == SP_AGGREGATE_FUNC) if (sum_func() == SP_AGGREGATE_FUNC)
aggr_sel->set_custom_agg_func_used(true); aggr_sel->set_custom_agg_func_used(true);
update_used_tables(); update_used_tables();
thd->lex->in_sum_func= in_sum_func; lex_s->in_sum_func= in_sum_func;
return FALSE; return FALSE;
} }

View File

@@ -269,7 +269,7 @@ void stop_mysqld_service()
} }
/* /*
Remeber initial state of the service, we will restore it on Remember initial state of the service, we will restore it on
exit. exit.
*/ */
if(initial_service_state == UINT_MAX) if(initial_service_state == UINT_MAX)
@@ -490,8 +490,10 @@ int main(int argc, char **argv)
CopyFile(service_properties.inifile, my_ini_bck, FALSE); CopyFile(service_properties.inifile, my_ini_bck, FALSE);
upgrade_config_file(service_properties.inifile); upgrade_config_file(service_properties.inifile);
log("Phase %d/%d: Ensuring innodb slow shutdown%s", ++phase, max_phases, bool do_start_stop_server = old_mysqld_exe_exists && initial_service_state != SERVICE_RUNNING;
old_mysqld_exe_exists?",this can take some time":"(skipped)");
log("Phase %d/%d: Start and stop server in the old version, to avoid crash recovery %s", ++phase, max_phases,
do_start_stop_server?",this can take some time":"(skipped)");
char socket_param[FN_REFLEN]; char socket_param[FN_REFLEN];
sprintf_s(socket_param, "--socket=mysql_upgrade_service_%u", sprintf_s(socket_param, "--socket=mysql_upgrade_service_%u",
@@ -499,11 +501,11 @@ int main(int argc, char **argv)
DWORD start_duration_ms = 0; DWORD start_duration_ms = 0;
if (old_mysqld_exe_exists) if (do_start_stop_server)
{ {
/* Start/stop server with --loose-innodb-fast-shutdown=0 */ /* Start/stop server with --loose-innodb-fast-shutdown=1 */
mysqld_process = (HANDLE)run_tool(P_NOWAIT, service_properties.mysqld_exe, mysqld_process = (HANDLE)run_tool(P_NOWAIT, service_properties.mysqld_exe,
defaults_file_param, "--loose-innodb-fast-shutdown=0", "--skip-networking", defaults_file_param, "--loose-innodb-fast-shutdown=1", "--skip-networking",
"--enable-named-pipe", socket_param, "--skip-slave-start", NULL); "--enable-named-pipe", socket_param, "--skip-slave-start", NULL);
if (mysqld_process == INVALID_HANDLE_VALUE) if (mysqld_process == INVALID_HANDLE_VALUE)

View File

@@ -1930,8 +1930,6 @@ bool
Sp_handler::sp_show_create_routine(THD *thd, Sp_handler::sp_show_create_routine(THD *thd,
const Database_qualified_name *name) const const Database_qualified_name *name) const
{ {
sp_head *sp;
DBUG_ENTER("sp_show_create_routine"); DBUG_ENTER("sp_show_create_routine");
DBUG_PRINT("enter", ("type: %s name: %.*s", DBUG_PRINT("enter", ("type: %s name: %.*s",
type_str(), type_str(),
@@ -1944,20 +1942,28 @@ Sp_handler::sp_show_create_routine(THD *thd,
It is "safe" to do as long as it doesn't affect the results It is "safe" to do as long as it doesn't affect the results
of the binary log or the query cache, which currently it does not. of the binary log or the query cache, which currently it does not.
*/ */
if (sp_cache_routine(thd, name, false, &sp)) sp_head *sp= 0;
DBUG_RETURN(TRUE);
if (sp == NULL || sp->show_create_routine(thd, this)) DBUG_EXECUTE_IF("cache_sp_in_show_create",
/* Some tests need just need a way to cache SP without other side-effects.*/
sp_cache_routine(thd, name, false, &sp);
sp->show_create_routine(thd, this);
DBUG_RETURN(false);
);
bool free_sp= db_find_routine(thd, name, &sp) == SP_OK;
bool ret= !sp || sp->show_create_routine(thd, this);
if (ret)
{ {
/* /*
If we have insufficient privileges, pretend the routine If we have insufficient privileges, pretend the routine
does not exist. does not exist.
*/ */
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), type_str(), name->m_name.str); my_error(ER_SP_DOES_NOT_EXIST, MYF(0), type_str(), name->m_name.str);
DBUG_RETURN(TRUE);
} }
if (free_sp)
DBUG_RETURN(FALSE); sp_head::destroy(sp);
DBUG_RETURN(ret);
} }

View File

@@ -6894,6 +6894,7 @@ set_new_item_local_context(THD *thd, Item_ident *item, TABLE_LIST *table_ref)
if (!(context= new (thd->mem_root) Name_resolution_context)) if (!(context= new (thd->mem_root) Name_resolution_context))
return TRUE; return TRUE;
context->init(); context->init();
context->select_lex= table_ref->select_lex;
context->first_name_resolution_table= context->first_name_resolution_table=
context->last_name_resolution_table= table_ref; context->last_name_resolution_table= table_ref;
item->context= context; item->context= context;

View File

@@ -3137,6 +3137,7 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
} }
for (; sl; sl= sl->next_select_in_list()) for (; sl; sl= sl->next_select_in_list())
{ {
sl->parent_lex->in_sum_func= NULL;
if (sl->changed_elements & TOUCHED_SEL_COND) if (sl->changed_elements & TOUCHED_SEL_COND)
{ {
/* remove option which was put by mysql_explain_union() */ /* remove option which was put by mysql_explain_union() */
@@ -3271,7 +3272,6 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
lex->result->set_thd(thd); lex->result->set_thd(thd);
} }
lex->allow_sum_func.clear_all(); lex->allow_sum_func.clear_all();
lex->in_sum_func= NULL;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }

View File

@@ -289,7 +289,14 @@ static int open_table(THD* thd,
NULL, lock_type); NULL, lock_type);
thd->lex->query_tables_own_last= 0; thd->lex->query_tables_own_last= 0;
if (!open_n_lock_single_table(thd, &tables, tables.lock_type, flags)) { // No need to open table if the query was bf aborted,
// thd client will get ER_LOCK_DEADLOCK in the end.
const bool interrupted= thd->killed ||
(thd->is_error() &&
(thd->get_stmt_da()->sql_errno() == ER_QUERY_INTERRUPTED));
if (interrupted ||
!open_n_lock_single_table(thd, &tables, tables.lock_type, flags)) {
close_thread_tables(thd); close_thread_tables(thd);
DBUG_RETURN(1); DBUG_RETURN(1);
} }

View File

@@ -94,13 +94,22 @@ bool fil_space_t::try_to_close(bool print_info)
if (const auto n= space.set_closing()) if (const auto n= space.set_closing())
{ {
if (print_info) if (!print_info)
ib::info() << "Cannot close file " << node->name continue;
<< " because of " print_info= false;
<< (n & PENDING) const time_t now= time(nullptr);
<< ((n & NEEDS_FSYNC) if (now - fil_system.n_open_exceeded_time < 5)
? " pending operations and pending fsync" continue; /* We display messages at most once in 5 seconds. */
: " pending operations"); fil_system.n_open_exceeded_time= now;
if (n & PENDING)
sql_print_information("InnoDB: Cannot close file %s because of "
UINT32PF " pending operations%s", node->name,
n & PENDING,
(n & NEEDS_FSYNC) ? " and pending fsync" : "");
else if (n & NEEDS_FSYNC)
sql_print_information("InnoDB: Cannot close file %s because of "
"pending fsync", node->name);
continue; continue;
} }
@@ -416,15 +425,18 @@ static bool fil_node_open_file(fil_node_t *node)
ut_ad(node->space->purpose != FIL_TYPE_TEMPORARY); ut_ad(node->space->purpose != FIL_TYPE_TEMPORARY);
ut_ad(node->space->referenced()); ut_ad(node->space->referenced());
const auto old_time= fil_system.n_open_exceeded_time;
for (ulint count= 0; fil_system.n_open >= srv_max_n_open_files; count++) for (ulint count= 0; fil_system.n_open >= srv_max_n_open_files; count++)
{ {
if (fil_space_t::try_to_close(count > 1)) if (fil_space_t::try_to_close(count > 1))
count= 0; count= 0;
else if (count >= 2) else if (count >= 2)
{ {
ib::warn() << "innodb_open_files=" << srv_max_n_open_files if (old_time != fil_system.n_open_exceeded_time)
<< " is exceeded (" << fil_system.n_open sql_print_warning("InnoDB: innodb_open_files=" ULINTPF
<< ") files stay open)"; " is exceeded (" ULINTPF " files stay open)",
srv_max_n_open_files, fil_system.n_open);
break; break;
} }
else else
@@ -1439,8 +1451,7 @@ fil_space_t *fil_space_t::get(ulint id)
if (n & STOPPING) if (n & STOPPING)
space= nullptr; space= nullptr;
else if ((n & CLOSING) && !space->prepare())
if ((n & CLOSING) && !space->prepare())
space= nullptr; space= nullptr;
return space; return space;

View File

@@ -6307,8 +6307,8 @@ wsrep_innobase_mysql_sort(
case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_VARCHAR:
{ {
uchar *tmp_str; uchar tmp_str[REC_VERSION_56_MAX_INDEX_COL_LEN] = {'\0'};
ulint tmp_length; ulint tmp_length = REC_VERSION_56_MAX_INDEX_COL_LEN;
/* Use the charset number to pick the right charset struct for /* Use the charset number to pick the right charset struct for
the comparison. Since the MySQL function get_charset may be the comparison. Since the MySQL function get_charset may be
@@ -6331,12 +6331,7 @@ wsrep_innobase_mysql_sort(
} }
} }
// Note that strnxfrm may change length of string ut_a(str_length <= tmp_length);
tmp_length= charset->coll->strnxfrmlen(charset, str_length);
tmp_length= tmp_length * charset->mbmaxlen;
tmp_length= ut_max(str_length, tmp_length) + charset->mbmaxlen;
tmp_str= static_cast<uchar *>(ut_malloc_nokey(tmp_length));
ut_ad(str_length <= tmp_length);
memcpy(tmp_str, str, str_length); memcpy(tmp_str, str, str_length);
tmp_length = charset->strnxfrm(str, str_length, tmp_length = charset->strnxfrm(str, str_length,
@@ -6360,7 +6355,6 @@ wsrep_innobase_mysql_sort(
ret_length = tmp_length; ret_length = tmp_length;
} }
ut_free(tmp_str);
break; break;
} }
case MYSQL_TYPE_DECIMAL : case MYSQL_TYPE_DECIMAL :
@@ -6706,7 +6700,7 @@ wsrep_store_key_val_for_row(
THD* thd, THD* thd,
TABLE* table, TABLE* table,
uint keynr, /*!< in: key number */ uint keynr, /*!< in: key number */
uchar* buff, /*!< in/out: buffer for the key value (in MySQL char* buff, /*!< in/out: buffer for the key value (in MySQL
format) */ format) */
uint buff_len,/*!< in: buffer length */ uint buff_len,/*!< in: buffer length */
const uchar* record, const uchar* record,
@@ -6715,7 +6709,7 @@ wsrep_store_key_val_for_row(
KEY* key_info = table->key_info + keynr; KEY* key_info = table->key_info + keynr;
KEY_PART_INFO* key_part = key_info->key_part; KEY_PART_INFO* key_part = key_info->key_part;
KEY_PART_INFO* end = key_part + key_info->user_defined_key_parts; KEY_PART_INFO* end = key_part + key_info->user_defined_key_parts;
uchar* buff_start = buff; char* buff_start = buff;
enum_field_types mysql_type; enum_field_types mysql_type;
Field* field; Field* field;
ulint buff_space = buff_len; ulint buff_space = buff_len;
@@ -6726,7 +6720,7 @@ wsrep_store_key_val_for_row(
*key_is_null = true; *key_is_null = true;
for (; key_part != end; key_part++) { for (; key_part != end; key_part++) {
uchar *sorted = nullptr; uchar sorted[REC_VERSION_56_MAX_INDEX_COL_LEN] = {'\0'};
bool part_is_null = false; bool part_is_null = false;
if (key_part->null_bit) { if (key_part->null_bit) {
@@ -6805,14 +6799,10 @@ wsrep_store_key_val_for_row(
true_len = key_len; true_len = key_len;
} }
const ulint max_len = true_len;
sorted= static_cast<uchar *>(ut_malloc_nokey(max_len+1));
memcpy(sorted, data, true_len); memcpy(sorted, data, true_len);
true_len = wsrep_innobase_mysql_sort( true_len = wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len, mysql_type, cs->number, sorted, true_len,
max_len); REC_VERSION_56_MAX_INDEX_COL_LEN);
ut_ad(true_len <= max_len);
if (wsrep_protocol_version > 1) { if (wsrep_protocol_version > 1) {
/* Note that we always reserve the maximum possible /* Note that we always reserve the maximum possible
length of the true VARCHAR in the key value, though length of the true VARCHAR in the key value, though
@@ -6897,13 +6887,11 @@ wsrep_store_key_val_for_row(
true_len = key_len; true_len = key_len;
} }
const ulint max_len= true_len;
sorted= static_cast<uchar *>(ut_malloc_nokey(max_len+1));
memcpy(sorted, blob_data, true_len); memcpy(sorted, blob_data, true_len);
true_len = wsrep_innobase_mysql_sort( true_len = wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len, mysql_type, cs->number, sorted, true_len,
max_len); REC_VERSION_56_MAX_INDEX_COL_LEN);
ut_ad(true_len <= max_len);
/* Note that we always reserve the maximum possible /* Note that we always reserve the maximum possible
length of the BLOB prefix in the key value. */ length of the BLOB prefix in the key value. */
@@ -6979,14 +6967,10 @@ wsrep_store_key_val_for_row(
cs->mbmaxlen), cs->mbmaxlen),
&error); &error);
} }
const ulint max_len = true_len;
sorted= static_cast<uchar *>(ut_malloc_nokey(max_len+1));
memcpy(sorted, src_start, true_len); memcpy(sorted, src_start, true_len);
true_len = wsrep_innobase_mysql_sort( true_len = wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len, mysql_type, cs->number, sorted, true_len,
max_len); REC_VERSION_56_MAX_INDEX_COL_LEN);
ut_ad(true_len <= max_len);
if (true_len > buff_space) { if (true_len > buff_space) {
fprintf (stderr, fprintf (stderr,
@@ -7001,11 +6985,6 @@ wsrep_store_key_val_for_row(
buff += true_len; buff += true_len;
buff_space -= true_len; buff_space -= true_len;
} }
if (sorted) {
ut_free(sorted);
sorted= NULL;
}
} }
ut_a(buff <= buff_start + buff_len); ut_a(buff <= buff_start + buff_len);
@@ -10046,7 +10025,7 @@ wsrep_append_key(
THD *thd, THD *thd,
trx_t *trx, trx_t *trx,
TABLE_SHARE *table_share, TABLE_SHARE *table_share,
const uchar* key, const char* key,
uint16_t key_len, uint16_t key_len,
Wsrep_service_key_type key_type /*!< in: access type of this key Wsrep_service_key_type key_type /*!< in: access type of this key
(shared, exclusive, semi...) */ (shared, exclusive, semi...) */
@@ -10157,8 +10136,8 @@ ha_innobase::wsrep_append_keys(
} }
if (wsrep_protocol_version == 0) { if (wsrep_protocol_version == 0) {
uchar keyval[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'}; char keyval[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'};
uchar *key = &keyval[0]; char *key = &keyval[0];
bool is_null; bool is_null;
auto len = wsrep_store_key_val_for_row( auto len = wsrep_store_key_val_for_row(
@@ -10199,12 +10178,12 @@ ha_innobase::wsrep_append_keys(
/* keyval[] shall contain an ordinal number at byte 0 /* keyval[] shall contain an ordinal number at byte 0
and the actual key data shall be written at byte 1. and the actual key data shall be written at byte 1.
Hence the total data length is the key length + 1 */ Hence the total data length is the key length + 1 */
uchar keyval0[WSREP_MAX_SUPPORTED_KEY_LENGTH+1]= {'\0'}; char keyval0[WSREP_MAX_SUPPORTED_KEY_LENGTH+1]= {'\0'};
uchar keyval1[WSREP_MAX_SUPPORTED_KEY_LENGTH+1]= {'\0'}; char keyval1[WSREP_MAX_SUPPORTED_KEY_LENGTH+1]= {'\0'};
keyval0[0] = (uchar)i; keyval0[0] = (char)i;
keyval1[0] = (uchar)i; keyval1[0] = (char)i;
uchar* key0 = &keyval0[1]; char* key0 = &keyval0[1];
uchar* key1 = &keyval1[1]; char* key1 = &keyval1[1];
if (!tab) { if (!tab) {
WSREP_WARN("MariaDB-InnoDB key mismatch %s %s", WSREP_WARN("MariaDB-InnoDB key mismatch %s %s",
@@ -10284,15 +10263,17 @@ ha_innobase::wsrep_append_keys(
wsrep_calc_row_hash(digest, record0, table, m_prebuilt); wsrep_calc_row_hash(digest, record0, table, m_prebuilt);
if (int rcode = wsrep_append_key(thd, trx, table_share, if (int rcode = wsrep_append_key(thd, trx, table_share,
digest, 16, key_type)) { reinterpret_cast<char*>
(digest), 16, key_type)) {
DBUG_RETURN(rcode); DBUG_RETURN(rcode);
} }
if (record1) { if (record1) {
wsrep_calc_row_hash( wsrep_calc_row_hash(
digest, record1, table, m_prebuilt); digest, record1, table, m_prebuilt);
if (int rcode = wsrep_append_key(thd, trx, table_share, if (int rcode = wsrep_append_key(
digest, 16, thd, trx, table_share,
reinterpret_cast<char*>(digest), 16,
key_type)) { key_type)) {
DBUG_RETURN(rcode); DBUG_RETURN(rcode);
} }

View File

@@ -1445,6 +1445,8 @@ public:
sized_ilist<fil_space_t, unflushed_spaces_tag_t> unflushed_spaces; sized_ilist<fil_space_t, unflushed_spaces_tag_t> unflushed_spaces;
/** number of currently open files; protected by mutex */ /** number of currently open files; protected by mutex */
ulint n_open; ulint n_open;
/** last time we noted n_open exceeding the limit; protected by mutex */
time_t n_open_exceeded_time;
ulint max_assigned_id;/*!< maximum space id in the existing ulint max_assigned_id;/*!< maximum space id in the existing
tables, or assigned during the time tables, or assigned during the time
mysqld has been up; at an InnoDB mysqld has been up; at an InnoDB

View File

@@ -91,16 +91,15 @@ datadir_set=
# #
# Use LSB init script functions for printing messages, if possible # Use LSB init script functions for printing messages, if possible
# # Include non-LSB RedHat init functions to make systemctl redirect work
init_functions="/etc/init.d/functions"
lsb_functions="/lib/lsb/init-functions" lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions; then if test -f $lsb_functions; then
. $lsb_functions . $lsb_functions
else fi
# Include non-LSB RedHat init functions to make systemctl redirect work
init_functions="/etc/init.d/functions"
if test -f $init_functions; then if test -f $init_functions; then
. $init_functions . $init_functions
fi
log_success_msg() log_success_msg()
{ {
echo " SUCCESS! $@" echo " SUCCESS! $@"