Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Barkov committed Oct 18, 2017
2 parents 75aabd0 + 3bc094d commit 30e7d67
Show file tree
Hide file tree
Showing 243 changed files with 10,218 additions and 1,291 deletions.
3 changes: 2 additions & 1 deletion extra/mariabackup/backup_copy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,8 @@ copy_back()
if it exists. */

ds_data = ds_create(dst_dir, DS_TYPE_LOCAL);
if (!file_exists("ib_logfile0")) {
MY_STAT stat_arg;
if (!my_stat("ib_logfile0", &stat_arg, MYF(0)) || !stat_arg.st_size) {
/* After completed --prepare, redo log files are redundant.
We must delete any redo logs at the destination, so that
the database will not jump to a different log sequence number
Expand Down
2 changes: 1 addition & 1 deletion extra/mariabackup/write_filt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ wf_incremental_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
cp->delta_buf_base = static_cast<byte *>(malloc(buf_size));
memset(cp->delta_buf_base, 0, buf_size);
cp->delta_buf = static_cast<byte *>
(ut_align(cp->delta_buf_base, UNIV_PAGE_SIZE_MAX));
(ut_align(cp->delta_buf_base, cursor->page_size.physical()));

/* write delta meta info */
snprintf(meta_name, sizeof(meta_name), "%s%s", dst_name,
Expand Down
35 changes: 22 additions & 13 deletions extra/mariabackup/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2460,7 +2460,7 @@ static os_thread_ret_t log_copying_thread(void*)

log_copying_running = false;
my_thread_end();
os_thread_exit(NULL);
os_thread_exit();

return(0);
}
Expand All @@ -2483,7 +2483,7 @@ static os_thread_ret_t io_watching_thread(void*)

io_watching_thread_running = false;

os_thread_exit(NULL);
os_thread_exit();

return(0);
}
Expand Down Expand Up @@ -2523,7 +2523,7 @@ data_copy_thread_func(
pthread_mutex_unlock(&ctxt->count_mutex);

my_thread_end();
os_thread_exit(NULL);
os_thread_exit();
OS_THREAD_DUMMY_RETURN;
}

Expand Down Expand Up @@ -4022,8 +4022,7 @@ xb_space_create_file(
}

ret = os_file_set_size(path, *file,
FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE,
false);
FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE);
if (!ret) {
msg("xtrabackup: cannot set size for file %s\n", path);
os_file_close(*file);
Expand Down Expand Up @@ -4414,13 +4413,20 @@ xtrabackup_apply_delta(
if (offset_on_page == 0xFFFFFFFFUL)
break;

uchar *buf = incremental_buffer + page_in_buffer * page_size;
const os_offset_t off = os_offset_t(offset_on_page)*page_size;

if (off == 0) {
/* Read tablespace size from page 0,
and extend the file to specified size.*/
os_offset_t n_pages = mach_read_from_4(buf + FSP_HEADER_OFFSET + FSP_SIZE);
success = os_file_set_size(dst_path, dst_file, n_pages*page_size);
if (!success)
goto error;
}

success = os_file_write(IORequestWrite,
dst_path, dst_file,
incremental_buffer +
page_in_buffer * page_size,
(offset_on_page <<
page_size_shift),
page_size);
dst_path, dst_file, buf, off, page_size);
if (!success) {
goto error;
}
Expand All @@ -4430,8 +4436,10 @@ xtrabackup_apply_delta(
}

free(incremental_buffer_base);
if (src_file != OS_FILE_CLOSED)
if (src_file != OS_FILE_CLOSED) {
os_file_close(src_file);
os_file_delete(0,src_path);
}
if (dst_file != OS_FILE_CLOSED)
os_file_close(dst_file);
return TRUE;
Expand Down Expand Up @@ -4785,7 +4793,8 @@ xtrabackup_prepare_func(char** argv)
if (!ok) goto error_cleanup;
}

srv_operation = SRV_OPERATION_RESTORE;
srv_operation = xtrabackup_export
? SRV_OPERATION_RESTORE_EXPORT : SRV_OPERATION_RESTORE;

if (innodb_init_param()) {
goto error_cleanup;
Expand Down
7 changes: 6 additions & 1 deletion mysql-test/lib/My/SafeProcess.pm
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,14 @@ sub start_kill {

sub dump_core {
my ($self)= @_;
return if IS_WINDOWS;
my $pid= $self->{SAFE_PID};
die "Can't get core from not started process" unless defined $pid;

if (IS_WINDOWS) {
system("$safe_kill $pid dump");
return 1;
}

_verbose("Sending ABRT to $self");
kill ("ABRT", $pid);
return 1;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/lib/My/SafeProcess/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ SET(INSTALL_ARGS
IF (WIN32)
MYSQL_ADD_EXECUTABLE(my_safe_process safe_process_win.cc ${INSTALL_ARGS})
MYSQL_ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc ${INSTALL_ARGS})
TARGET_LINK_LIBRARIES(my_safe_kill dbghelp psapi)
ELSE()
MYSQL_ADD_EXECUTABLE(my_safe_process safe_process.cc ${INSTALL_ARGS})
ENDIF()
Expand Down
82 changes: 80 additions & 2 deletions mysql-test/lib/My/SafeProcess/safe_kill_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,80 @@
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <psapi.h>
#include <DbgHelp.h>

static int create_dump(DWORD pid)
{
char path[MAX_PATH];
char working_dir[MAX_PATH];
int ret= -1;
HANDLE process= INVALID_HANDLE_VALUE;
HANDLE file= INVALID_HANDLE_VALUE;
char *p;

process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, (DWORD)pid);
if (!process)
{
fprintf(stderr,"safe_kill : cannot open process pid=%u to create dump, last error %u\n",
pid, GetLastError());
goto exit;
}

DWORD size = MAX_PATH;
if (QueryFullProcessImageName(process, 0, path, &size) == 0)
{
fprintf(stderr,"safe_kill : cannot read process path for pid %u, last error %u\n",
pid, GetLastError());
goto exit;
}

if ((p = strrchr(path, '.')) == 0)
p= path + strlen(path);

strncpy(p, ".dmp", path + MAX_PATH - p);

/* Create dump in current directory.*/
const char *filename= strrchr(path, '\\');
if (filename == 0)
filename = path;
else
filename++;

if (!GetCurrentDirectory(MAX_PATH, working_dir))
{
fprintf(stderr, "GetCurrentDirectory failed, last error %u",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 = %u\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 %u\n",
filename, working_dir, GetLastError());
goto exit;
}

ret = 0;
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);
return ret;
}

int main(int argc, const char** argv )
{
Expand All @@ -37,12 +111,16 @@ int main(int argc, const char** argv )
signal(SIGBREAK, SIG_IGN);
signal(SIGTERM, SIG_IGN);

if (argc != 2) {
fprintf(stderr, "safe_kill <pid>\n");
if ((argc != 2 && argc != 3) || (argc == 3 && strcmp(argv[2],"dump"))) {
fprintf(stderr, "safe_kill <pid> [dump]\n");
exit(2);
}
pid= atoi(argv[1]);

if (argc == 3)
{
return create_dump(pid);
}
_snprintf(safe_process_name, sizeof(safe_process_name),
"safe_process[%d]", pid);

Expand Down
36 changes: 30 additions & 6 deletions mysql-test/r/cte_nonrecursive.result
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ select * from t2,t where t2.c=t.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where
1 PRIMARY <derived2> ref key0 key0 5 test.t2.c 2
2 SUBQUERY t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort
2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort
explain
select * from t2, (select a, count(*) from t1 where b >= 'c' group by a) as t
where t2.c=t.a;
Expand Down Expand Up @@ -176,7 +176,7 @@ select * from t2 where c in (select c from t);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where
1 PRIMARY <derived2> ref key0 key0 8 test.t2.c 2 Using where; FirstMatch(t2)
2 SUBQUERY t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort
2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort
explain
select * from t2
where c in (select c from (select count(*) as c from t1
Expand Down Expand Up @@ -245,8 +245,8 @@ select * from t as r1, t as r2 where r1.a=r2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 8 Using where
1 PRIMARY <derived3> ref key0 key0 5 r1.a 2
3 SUBQUERY t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary
2 SUBQUERY t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary
3 DERIVED t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary
2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary
explain
select * from (select distinct a from t1 where b >= 'c') as r1,
(select distinct a from t1 where b >= 'c') as r2
Expand Down Expand Up @@ -370,7 +370,7 @@ select * from t2,t where t2.c=t.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where
1 PRIMARY <derived2> ref key0 key0 5 test.t2.c 2
2 SUBQUERY t1 ALL NULL NULL NULL NULL 8 Using where
2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using where
3 UNION t2 ALL NULL NULL NULL NULL 4 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
explain
Expand Down Expand Up @@ -598,7 +598,7 @@ select * from v2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where
1 PRIMARY <derived3> ref key0 key0 5 test.t2.c 2
3 SUBQUERY t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort
3 DERIVED t1 ALL NULL NULL NULL NULL 8 Using where; Using temporary; Using filesort
# with clause in the specification of a view that whose definition
# table alias for a with table
create view v3 as
Expand Down Expand Up @@ -1055,3 +1055,27 @@ deallocate prepare stmt1;
deallocate prepare stmt2;
drop view v1,v2;
drop table t1,t2;
#
# MDEV-13796: UNION of two materialized CTEs
#
CREATE TABLE t1 (id int, k int);
CREATE TABLE t2 (id int);
INSERT INTO t1 VALUES (3,5), (1,7), (4,3);
INSERT INTO t2 VALUES (4), (3), (2);
WITH d1 AS (SELECT SUM(k) FROM t1, t2 as t2 WHERE t1.id = t2.id),
d2 AS (SELECT SUM(k) FROM t1, t2 as t2 WHERE t1.id = t2.id)
SELECT * FROM d1 UNION SELECT * FROM d2;
SUM(k)
8
explain WITH d1 AS (SELECT SUM(k) FROM t1, t2 as t2 WHERE t1.id = t2.id),
d2 AS (SELECT SUM(k) FROM t1, t2 as t2 WHERE t1.id = t2.id)
SELECT * FROM d1 UNION SELECT * FROM d2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9
2 DERIVED t1 ALL NULL NULL NULL NULL 3
2 DERIVED t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
4 UNION <derived3> ALL NULL NULL NULL NULL 9
3 DERIVED t1 ALL NULL NULL NULL NULL 3
3 DERIVED t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union1,4> ALL NULL NULL NULL NULL NULL
DROP TABLE t1,t2;
Loading

0 comments on commit 30e7d67

Please sign in to comment.