Skip to content

Commit 83c4523

Browse files
committed
Merge 10.4 into 10.5
2 parents 88f3866 + 69bd2c8 commit 83c4523

File tree

14 files changed

+318
-308
lines changed

14 files changed

+318
-308
lines changed

client/mysqltest.cc

Lines changed: 47 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ static my_bool non_blocking_api_enabled= 0;
7272
#include "../tests/nonblock-wrappers.h"
7373
#endif
7474

75-
/* Use cygwin for --exec and --system before 5.0 */
76-
#if MYSQL_VERSION_ID < 50000
77-
#define USE_CYGWIN
78-
#endif
7975

8076
#define MAX_VAR_NAME_LENGTH 256
8177
#define MAX_COLUMNS 256
@@ -620,7 +616,6 @@ const char *get_errname_from_code (uint error_code);
620616
int multi_reg_replace(struct st_replace_regex* r,char* val);
621617

622618
#ifdef _WIN32
623-
void free_tmp_sh_file();
624619
void free_win_path_patterns();
625620
#endif
626621

@@ -1458,7 +1453,6 @@ void free_used_memory()
14581453
free_re();
14591454
my_free(read_command_buf);
14601455
#ifdef _WIN32
1461-
free_tmp_sh_file();
14621456
free_win_path_patterns();
14631457
#endif
14641458
DBUG_VOID_RETURN;
@@ -3190,33 +3184,6 @@ void do_source(struct st_command *command)
31903184
}
31913185

31923186

3193-
#if defined _WIN32
3194-
3195-
#ifdef USE_CYGWIN
3196-
/* Variables used for temporary sh files used for emulating Unix on Windows */
3197-
char tmp_sh_name[64], tmp_sh_cmd[70];
3198-
#endif
3199-
3200-
void init_tmp_sh_file()
3201-
{
3202-
#ifdef USE_CYGWIN
3203-
/* Format a name for the tmp sh file that is unique for this process */
3204-
my_snprintf(tmp_sh_name, sizeof(tmp_sh_name), "tmp_%d.sh", getpid());
3205-
/* Format the command to execute in order to run the script */
3206-
my_snprintf(tmp_sh_cmd, sizeof(tmp_sh_cmd), "sh %s", tmp_sh_name);
3207-
#endif
3208-
}
3209-
3210-
3211-
void free_tmp_sh_file()
3212-
{
3213-
#ifdef USE_CYGWIN
3214-
my_delete(tmp_sh_name, MYF(0));
3215-
#endif
3216-
}
3217-
#endif
3218-
3219-
32203187
static void init_builtin_echo(void)
32213188
{
32223189
#ifdef _WIN32
@@ -3332,14 +3299,12 @@ void do_exec(struct st_command *command)
33323299
}
33333300

33343301
#ifdef _WIN32
3335-
#ifndef USE_CYGWIN
33363302
/* Replace /dev/null with NUL */
33373303
while(replace(&ds_cmd, "/dev/null", 9, "NUL", 3) == 0)
33383304
;
33393305
/* Replace "closed stdout" with non existing output fd */
33403306
while(replace(&ds_cmd, ">&-", 3, ">&4", 3) == 0)
33413307
;
3342-
#endif
33433308
#endif
33443309

33453310
if (disable_result_log)
@@ -3498,13 +3463,7 @@ int do_modify_var(struct st_command *command,
34983463

34993464
int my_system(DYNAMIC_STRING* ds_cmd)
35003465
{
3501-
#if defined _WIN32 && defined USE_CYGWIN
3502-
/* Dump the command into a sh script file and execute with system */
3503-
str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length);
3504-
return system(tmp_sh_cmd);
3505-
#else
35063466
return system(ds_cmd->str);
3507-
#endif
35083467
}
35093468

35103469

@@ -3538,12 +3497,10 @@ void do_system(struct st_command *command)
35383497
do_eval(&ds_cmd, command->first_argument, command->end, !is_windows);
35393498

35403499
#ifdef _WIN32
3541-
#ifndef USE_CYGWIN
35423500
/* Replace /dev/null with NUL */
35433501
while(replace(&ds_cmd, "/dev/null", 9, "NUL", 3) == 0)
35443502
;
35453503
#endif
3546-
#endif
35473504

35483505

35493506
DBUG_PRINT("info", ("running system command '%s' as '%s'",
@@ -5012,13 +4969,34 @@ int query_get_string(MYSQL* mysql, const char* query,
50124969
}
50134970

50144971

4972+
#ifdef _WIN32
4973+
#define SIGKILL 9
4974+
#include <my_minidump.h>
50154975
static int my_kill(int pid, int sig)
50164976
{
5017-
DBUG_PRINT("info", ("Killing server, pid: %d", pid));
5018-
#ifdef _WIN32
5019-
#define SIGKILL 9 /* ignored anyway, see below */
50204977
HANDLE proc;
5021-
if ((proc= OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pid)) == NULL)
4978+
if (sig == SIGABRT)
4979+
{
4980+
/*
4981+
Create a minidump. If process is being debugged, debug break
4982+
Otherwise, terminate.
4983+
*/
4984+
verbose_msg("Aborting %d",pid);
4985+
my_create_minidump(pid,TRUE);
4986+
proc= OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
4987+
if(!proc)
4988+
return -1;
4989+
BOOL debugger_present;
4990+
if (CheckRemoteDebuggerPresent(proc,&debugger_present) && debugger_present)
4991+
{
4992+
if (DebugBreakProcess(proc))
4993+
{
4994+
CloseHandle(proc);
4995+
return 0;
4996+
}
4997+
}
4998+
}
4999+
else if ((proc= OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pid)) == NULL)
50225000
return -1;
50235001
if (sig == 0)
50245002
{
@@ -5029,12 +5007,30 @@ static int my_kill(int pid, int sig)
50295007
(void)TerminateProcess(proc, 201);
50305008
CloseHandle(proc);
50315009
return 1;
5032-
#else
5033-
return kill(pid, sig);
5034-
#endif
50355010
}
50365011

50375012

5013+
/* Wait until process is gone, with timeout */
5014+
static int wait_until_dead(int pid, int timeout)
5015+
{
5016+
HANDLE proc= OpenProcess(SYNCHRONIZE, FALSE, pid);
5017+
if (!proc)
5018+
return 0; /* already dead */
5019+
DBUG_ASSERT(timeout >= 0);
5020+
DBUG_ASSERT(timeout <= UINT_MAX/1000);
5021+
DWORD wait_result= WaitForSingleObject(proc, (DWORD)timeout*1000);
5022+
CloseHandle(proc);
5023+
return (int)wait_result;
5024+
}
5025+
5026+
#else /* !_WIN32 */
5027+
5028+
5029+
static int my_kill(int pid, int sig)
5030+
{
5031+
DBUG_PRINT("info", ("Killing server, pid: %d", pid));
5032+
return kill(pid, sig);
5033+
}
50385034

50395035
/*
50405036
Shutdown the server of current connection and
@@ -5069,6 +5065,7 @@ static int wait_until_dead(int pid, int timeout)
50695065
}
50705066
DBUG_RETURN(1); // Did not die
50715067
}
5068+
#endif /* _WIN32 */
50725069

50735070

50745071
void do_shutdown_server(struct st_command *command)
@@ -9185,10 +9182,7 @@ int main(int argc, char **argv)
91859182

91869183
init_builtin_echo();
91879184
#ifdef _WIN32
9188-
#ifndef USE_CYGWIN
91899185
is_windows= 1;
9190-
#endif
9191-
init_tmp_sh_file();
91929186
init_win_path_patterns();
91939187
#endif
91949188

include/my_minidump.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* Copyright (c) 2021, MariaDB Corporation
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
15+
16+
#include <windows.h>
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
BOOL my_create_minidump(DWORD pid, BOOL verbose);
22+
23+
#ifdef __cplusplus
24+
}
25+
#endif

libmariadb

mysql-test/lib/My/SafeProcess/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
1919
IF (WIN32)
2020
ADD_EXECUTABLE(my_safe_process safe_process_win.cc)
2121
ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc)
22-
TARGET_LINK_LIBRARIES(my_safe_kill dbghelp psapi)
22+
TARGET_INCLUDE_DIRECTORIES(my_safe_kill PRIVATE ${CMAKE_SOURCE_DIR}/include)
23+
TARGET_LINK_LIBRARIES(my_safe_kill mysys psapi)
2324
ELSE()
2425
ADD_EXECUTABLE(my_safe_process safe_process.cc)
2526
ENDIF()

mysql-test/lib/My/SafeProcess/safe_kill_win.cc

Lines changed: 2 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,7 @@
2626
#include <signal.h>
2727
#include <stdlib.h>
2828
#include <psapi.h>
29-
30-
#ifdef _MSC_VER
31-
/* Silence warning in OS header dbghelp.h */
32-
#pragma warning(push)
33-
#pragma warning(disable : 4091)
34-
#endif
35-
36-
#include <dbghelp.h>
37-
38-
#ifdef _MSC_VER
39-
/* Silence warning in OS header dbghelp.h */
40-
#pragma warning(pop)
41-
#endif
29+
#include <my_minidump.h>
4230

4331
#include <tlhelp32.h>
4432
#include <vector>
@@ -64,106 +52,13 @@ static std::vector<DWORD> find_children(DWORD pid)
6452
return children;
6553
}
6654

67-
void dump_single_process(DWORD pid)
68-
{
69-
HANDLE file = 0;
70-
HANDLE process= 0;
71-
DWORD size= MAX_PATH;
72-
char path[MAX_PATH];
73-
char working_dir[MAX_PATH];
74-
char tmpname[MAX_PATH];
75-
char *filename= 0;
76-
77-
process= OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
78-
if (!process)
79-
{
80-
fprintf(stderr, "safe_kill : cannot open process pid=%lu to create dump, last error %lu\n",
81-
pid, GetLastError());
82-
goto exit;
83-
}
84-
85-
if (QueryFullProcessImageName(process, 0, path, &size) == 0)
86-
{
87-
fprintf(stderr, "safe_kill : cannot read process path for pid %lu, last error %lu\n",
88-
pid, GetLastError());
89-
goto exit;
90-
}
91-
92-
filename= strrchr(path, '\\');
93-
if (filename)
94-
{
95-
filename++;
96-
// We are not interested in dump of some proceses (my_safe_process.exe,cmd.exe)
97-
// since they are only used to start up other programs.
98-
// We're interested however in their children;
99-
const char *exclude_programs[] = {"my_safe_process.exe","cmd.exe", 0};
100-
for(size_t i=0; exclude_programs[i]; i++)
101-
if (_stricmp(filename, exclude_programs[i]) == 0)
102-
goto exit;
103-
}
104-
else
105-
filename= path;
106-
107-
// Add .dmp extension
108-
char *p;
109-
if ((p= strrchr(filename, '.')) == 0)
110-
p= filename + strlen(filename);
111-
112-
strncpy(p, ".dmp", path + MAX_PATH - p);
113-
114-
// Íf file with this name exist, generate unique name with .dmp extension
115-
if (GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES)
116-
{
117-
if (!GetTempFileName(".", filename, 0, tmpname))
118-
{
119-
fprintf(stderr, "GetTempFileName failed, last error %lu", GetLastError());
120-
goto exit;
121-
}
122-
strncat_s(tmpname, ".dmp", sizeof(tmpname));
123-
filename= tmpname;
124-
}
125-
126-
127-
if (!GetCurrentDirectory(MAX_PATH, working_dir))
128-
{
129-
fprintf(stderr, "GetCurrentDirectory failed, last error %lu", GetLastError());
130-
goto exit;
131-
}
132-
133-
file= CreateFile(filename, GENERIC_READ | GENERIC_WRITE,
134-
0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
135-
136-
if (file == INVALID_HANDLE_VALUE)
137-
{
138-
fprintf(stderr, "safe_kill : CreateFile() failed for file %s, working dir %s, last error = %lu\n",
139-
filename, working_dir, GetLastError());
140-
goto exit;
141-
}
142-
143-
if (!MiniDumpWriteDump(process, pid, file, MiniDumpNormal, 0, 0, 0))
144-
{
145-
fprintf(stderr, "Failed to write minidump to %s, working dir %s, last error %lu\n",
146-
filename, working_dir, GetLastError());
147-
goto exit;
148-
}
149-
150-
fprintf(stderr, "Minidump written to %s, directory %s\n", filename, working_dir);
151-
152-
exit:
153-
if (process != 0 && process != INVALID_HANDLE_VALUE)
154-
CloseHandle(process);
155-
156-
if (file != 0 && file != INVALID_HANDLE_VALUE)
157-
CloseHandle(file);
158-
}
159-
16055

16156
static int create_dump(DWORD pid, int recursion_depth= 5)
16257
{
16358
if (recursion_depth < 0)
16459
return 0;
16560

166-
dump_single_process(pid);
61+
my_create_minidump(pid, TRUE);
16762
std::vector<DWORD> children= find_children(pid);
16863
for(size_t i=0; i < children.size(); i++)
16964
create_dump(children[i], recursion_depth -1);

mysql-test/suite/galera/r/galera_fulltext.result

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,6 @@ DROP TABLE t1;
3838
DROP TABLE ten;
3939
connection node_1;
4040
SET @value=REPEAT (1,5001);
41-
CREATE TABLE t (a VARCHAR(5000),FULLTEXT (a)) engine=innodb;
42-
INSERT IGNORE INTO t VALUES(@value);
43-
Warnings:
44-
Warning 1265 Data truncated for column 'a' at row 1
45-
SELECT COUNT(*) FROM t;
46-
COUNT(*)
47-
1
48-
connection node_2;
49-
SELECT COUNT(*) FROM t;
50-
COUNT(*)
51-
1
52-
connection node_1;
53-
DROP TABLE t;
54-
CREATE TABLE t (a VARCHAR(5000)) engine=innodb;
55-
INSERT IGNORE INTO t VALUES(@value);
56-
Warnings:
57-
Warning 1265 Data truncated for column 'a' at row 1
58-
SELECT COUNT(*) FROM t;
59-
COUNT(*)
60-
1
61-
connection node_2;
62-
SELECT COUNT(*) FROM t;
63-
COUNT(*)
64-
1
65-
connection node_1;
66-
DROP TABLE t;
67-
connection node_1;
68-
SET @value=REPEAT (1,5001);
6941
CREATE TABLE t (a VARCHAR(5000),FULLTEXT (a)) engine=innodb DEFAULT CHARSET=utf8;
7042
INSERT IGNORE INTO t VALUES(@value);
7143
Warnings:

0 commit comments

Comments
 (0)