Commit 7c477360 authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

New upstream version 10.1.34

parent 5a2d9853
...@@ -1111,6 +1111,9 @@ CHECK_INCLUDE_FILE(ucontext.h HAVE_UCONTEXT_H) ...@@ -1111,6 +1111,9 @@ CHECK_INCLUDE_FILE(ucontext.h HAVE_UCONTEXT_H)
IF(NOT HAVE_UCONTEXT_H) IF(NOT HAVE_UCONTEXT_H)
CHECK_INCLUDE_FILE(sys/ucontext.h HAVE_UCONTEXT_H) CHECK_INCLUDE_FILE(sys/ucontext.h HAVE_UCONTEXT_H)
ENDIF() ENDIF()
IF(HAVE_UCONTEXT_H)
CHECK_FUNCTION_EXISTS(makecontext HAVE_UCONTEXT_H)
ENDIF()
CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_sec "time.h" STRUCT_TIMESPEC_HAS_TV_SEC) CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_sec "time.h" STRUCT_TIMESPEC_HAS_TV_SEC)
CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_nsec "time.h" STRUCT_TIMESPEC_HAS_TV_NSEC) CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_nsec "time.h" STRUCT_TIMESPEC_HAS_TV_NSEC)
......
...@@ -52,7 +52,7 @@ ELSE() ...@@ -52,7 +52,7 @@ ELSE()
SET(NT_SERVICE_SOURCE) SET(NT_SERVICE_SOURCE)
ENDIF() ENDIF()
ADD_DEFINITIONS(-DPCRE_STATIC=1) ADD_DEFINITIONS(-DPCRE_STATIC=1 -DHAVE_OPENSSL=1)
MYSQL_ADD_EXECUTABLE(mariabackup MYSQL_ADD_EXECUTABLE(mariabackup
xtrabackup.cc xtrabackup.cc
...@@ -61,7 +61,7 @@ MYSQL_ADD_EXECUTABLE(mariabackup ...@@ -61,7 +61,7 @@ MYSQL_ADD_EXECUTABLE(mariabackup
datasink.c datasink.c
ds_buffer.c ds_buffer.c
ds_compress.c ds_compress.c
ds_local.c ds_local.cc
ds_stdout.c ds_stdout.c
ds_tmpfile.c ds_tmpfile.c
ds_xbstream.c ds_xbstream.c
...@@ -98,7 +98,7 @@ ENDIF() ...@@ -98,7 +98,7 @@ ENDIF()
######################################################################## ########################################################################
MYSQL_ADD_EXECUTABLE(mbstream MYSQL_ADD_EXECUTABLE(mbstream
ds_buffer.c ds_buffer.c
ds_local.c ds_local.cc
ds_stdout.c ds_stdout.c
datasink.c datasink.c
xbstream.c xbstream.c
...@@ -112,6 +112,7 @@ TARGET_LINK_LIBRARIES(mbstream ...@@ -112,6 +112,7 @@ TARGET_LINK_LIBRARIES(mbstream
mysys mysys
crc crc
) )
ADD_DEPENDENCIES(mbstream GenError)
IF(MSVC) IF(MSVC)
SET_TARGET_PROPERTIES(mbstream PROPERTIES LINK_FLAGS setargv.obj) SET_TARGET_PROPERTIES(mbstream PROPERTIES LINK_FLAGS setargv.obj)
......
...@@ -975,6 +975,9 @@ copy_file(ds_ctxt_t *datasink, ...@@ -975,6 +975,9 @@ copy_file(ds_ctxt_t *datasink,
datafile_cur_t cursor; datafile_cur_t cursor;
xb_fil_cur_result_t res; xb_fil_cur_result_t res;
const char *action; const char *action;
const char *dst_path =
(xtrabackup_copy_back || xtrabackup_move_back)?
dst_file_path : trim_dotslash(dst_file_path);
if (!datafile_open(src_file_path, &cursor, thread_n)) { if (!datafile_open(src_file_path, &cursor, thread_n)) {
goto error_close; goto error_close;
...@@ -982,8 +985,7 @@ copy_file(ds_ctxt_t *datasink, ...@@ -982,8 +985,7 @@ copy_file(ds_ctxt_t *datasink,
strncpy(dst_name, cursor.rel_path, sizeof(dst_name)); strncpy(dst_name, cursor.rel_path, sizeof(dst_name));
dstfile = ds_open(datasink, trim_dotslash(dst_file_path), dstfile = ds_open(datasink, dst_path, &cursor.statinfo);
&cursor.statinfo);
if (dstfile == NULL) { if (dstfile == NULL) {
msg("[%02u] error: " msg("[%02u] error: "
"cannot open the destination stream for %s\n", "cannot open the destination stream for %s\n",
......
...@@ -91,7 +91,7 @@ time_t history_lock_time; ...@@ -91,7 +91,7 @@ time_t history_lock_time;
MYSQL *mysql_connection; MYSQL *mysql_connection;
my_bool opt_ssl_verify_server_cert; extern my_bool opt_ssl_verify_server_cert, opt_use_ssl;
MYSQL * MYSQL *
xb_mysql_connect() xb_mysql_connect()
...@@ -477,7 +477,7 @@ get_mysql_vars(MYSQL *connection) ...@@ -477,7 +477,7 @@ get_mysql_vars(MYSQL *connection)
innodb_data_file_path_var, MYF(MY_FAE)); innodb_data_file_path_var, MYF(MY_FAE));
} }
if (innodb_data_home_dir_var && *innodb_data_home_dir_var) { if (innodb_data_home_dir_var) {
innobase_data_home_dir = my_strdup( innobase_data_home_dir = my_strdup(
innodb_data_home_dir_var, MYF(MY_FAE)); innodb_data_home_dir_var, MYF(MY_FAE));
} }
...@@ -1521,6 +1521,44 @@ write_xtrabackup_info(MYSQL *connection) ...@@ -1521,6 +1521,44 @@ write_xtrabackup_info(MYSQL *connection)
extern const char *innodb_checksum_algorithm_names[]; extern const char *innodb_checksum_algorithm_names[];
#ifdef _WIN32
#include <algorithm>
#endif
static std::string make_local_paths(const char *data_file_path)
{
if (strchr(data_file_path, '/') == 0
#ifdef _WIN32
&& strchr(data_file_path, '\\') == 0
#endif
){
return std::string(data_file_path);
}
std::ostringstream buf;
char *dup = strdup(innobase_data_file_path);
ut_a(dup);
char *p;
char * token = strtok_r(dup, ";", &p);
while (token) {
if (buf.tellp())
buf << ";";
char *fname = strrchr(token, '/');
#ifdef _WIN32
fname = std::max(fname,strrchr(token, '\\'));
#endif
if (fname)
buf << fname + 1;
else
buf << token;
token = strtok_r(NULL, ";", &p);
}
free(dup);
return buf.str();
}
bool write_backup_config_file() bool write_backup_config_file()
{ {
int rc= backup_file_printf("backup-my.cnf", int rc= backup_file_printf("backup-my.cnf",
...@@ -1541,7 +1579,7 @@ bool write_backup_config_file() ...@@ -1541,7 +1579,7 @@ bool write_backup_config_file()
"%s\n", "%s\n",
innodb_checksum_algorithm_names[srv_checksum_algorithm], innodb_checksum_algorithm_names[srv_checksum_algorithm],
innodb_checksum_algorithm_names[srv_log_checksum_algorithm], innodb_checksum_algorithm_names[srv_log_checksum_algorithm],
innobase_data_file_path, make_local_paths(innobase_data_file_path).c_str(),
srv_n_log_files, srv_n_log_files,
innobase_log_file_size, innobase_log_file_size,
srv_page_size, srv_page_size,
......
...@@ -27,7 +27,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ...@@ -27,7 +27,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include <stdarg.h> #include <stdarg.h>
# define fil_is_user_tablespace_id(i) ((i) > srv_undo_tablespaces_open) /** Determine if (i) is a user tablespace id or not. */
# define fil_is_user_tablespace_id(i) (i != 0 \
&& !srv_is_undo_tablespace(i))
#ifdef _MSC_VER #ifdef _MSC_VER
#define stat _stati64 #define stat _stati64
......
...@@ -108,7 +108,7 @@ Write to a datasink file. ...@@ -108,7 +108,7 @@ Write to a datasink file.
int int
ds_write(ds_file_t *file, const void *buf, size_t len) ds_write(ds_file_t *file, const void *buf, size_t len)
{ {
return file->datasink->write(file, buf, len); return file->datasink->write(file, (const uchar *)buf, len);
} }
/************************************************************************ /************************************************************************
......
...@@ -48,7 +48,7 @@ typedef struct { ...@@ -48,7 +48,7 @@ typedef struct {
struct datasink_struct { struct datasink_struct {
ds_ctxt_t *(*init)(const char *root); ds_ctxt_t *(*init)(const char *root);
ds_file_t *(*open)(ds_ctxt_t *ctxt, const char *path, MY_STAT *stat); ds_file_t *(*open)(ds_ctxt_t *ctxt, const char *path, MY_STAT *stat);
int (*write)(ds_file_t *file, const void *buf, size_t len); int (*write)(ds_file_t *file, const unsigned char *buf, size_t len);
int (*close)(ds_file_t *file); int (*close)(ds_file_t *file);
void (*deinit)(ds_ctxt_t *ctxt); void (*deinit)(ds_ctxt_t *ctxt);
}; };
......
...@@ -45,7 +45,7 @@ typedef struct { ...@@ -45,7 +45,7 @@ typedef struct {
static ds_ctxt_t *buffer_init(const char *root); static ds_ctxt_t *buffer_init(const char *root);
static ds_file_t *buffer_open(ds_ctxt_t *ctxt, const char *path, static ds_file_t *buffer_open(ds_ctxt_t *ctxt, const char *path,
MY_STAT *mystat); MY_STAT *mystat);
static int buffer_write(ds_file_t *file, const void *buf, size_t len); static int buffer_write(ds_file_t *file, const uchar *buf, size_t len);
static int buffer_close(ds_file_t *file); static int buffer_close(ds_file_t *file);
static void buffer_deinit(ds_ctxt_t *ctxt); static void buffer_deinit(ds_ctxt_t *ctxt);
...@@ -119,7 +119,7 @@ buffer_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat) ...@@ -119,7 +119,7 @@ buffer_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat)
} }
static int static int
buffer_write(ds_file_t *file, const void *buf, size_t len) buffer_write(ds_file_t *file, const uchar *buf, size_t len)
{ {
ds_buffer_file_t *buffer_file; ds_buffer_file_t *buffer_file;
...@@ -142,7 +142,7 @@ buffer_write(ds_file_t *file, const void *buf, size_t len) ...@@ -142,7 +142,7 @@ buffer_write(ds_file_t *file, const void *buf, size_t len)
buffer_file->pos = 0; buffer_file->pos = 0;
buf = (const char *) buf + bytes; buf += bytes;
len -= bytes; len -= bytes;
} else { } else {
/* We don't have any buffered bytes, just write /* We don't have any buffered bytes, just write
......
...@@ -65,7 +65,7 @@ extern ulonglong xtrabackup_compress_chunk_size; ...@@ -65,7 +65,7 @@ extern ulonglong xtrabackup_compress_chunk_size;
static ds_ctxt_t *compress_init(const char *root); static ds_ctxt_t *compress_init(const char *root);
static ds_file_t *compress_open(ds_ctxt_t *ctxt, const char *path, static ds_file_t *compress_open(ds_ctxt_t *ctxt, const char *path,
MY_STAT *mystat); MY_STAT *mystat);
static int compress_write(ds_file_t *file, const void *buf, size_t len); static int compress_write(ds_file_t *file, const uchar *buf, size_t len);
static int compress_close(ds_file_t *file); static int compress_close(ds_file_t *file);
static void compress_deinit(ds_ctxt_t *ctxt); static void compress_deinit(ds_ctxt_t *ctxt);
...@@ -178,7 +178,7 @@ compress_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat) ...@@ -178,7 +178,7 @@ compress_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat)
static static
int int
compress_write(ds_file_t *file, const void *buf, size_t len) compress_write(ds_file_t *file, const uchar *buf, size_t len)
{ {
ds_compress_file_t *comp_file; ds_compress_file_t *comp_file;
ds_compress_ctxt_t *comp_ctxt; ds_compress_ctxt_t *comp_ctxt;
......
...@@ -18,23 +18,34 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ...@@ -18,23 +18,34 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*******************************************************/ *******************************************************/
#include <my_config.h>
#include <mysql_version.h> #include <mysql_version.h>
#include <my_base.h> #include <my_base.h>
#include <mysys_err.h> #include <mysys_err.h>
#include "common.h" #include "common.h"
#include "datasink.h" #include "datasink.h"
#include "univ.i"
#include "fsp0fsp.h"
#ifdef _WIN32
#include <winioctl.h>
#endif
typedef struct { typedef struct {
File fd; File fd;
my_bool init_ibd_done;
my_bool is_ibd;
my_bool compressed;
size_t pagesize;
} ds_local_file_t; } ds_local_file_t;
static ds_ctxt_t *local_init(const char *root); static ds_ctxt_t *local_init(const char *root);
static ds_file_t *local_open(ds_ctxt_t *ctxt, const char *path, static ds_file_t *local_open(ds_ctxt_t *ctxt, const char *path,
MY_STAT *mystat); MY_STAT *mystat);
static int local_write(ds_file_t *file, const void *buf, size_t len); static int local_write(ds_file_t *file, const uchar *buf, size_t len);
static int local_close(ds_file_t *file); static int local_close(ds_file_t *file);
static void local_deinit(ds_ctxt_t *ctxt); static void local_deinit(ds_ctxt_t *ctxt);
extern "C" {
datasink_t datasink_local = { datasink_t datasink_local = {
&local_init, &local_init,
&local_open, &local_open,
...@@ -42,6 +53,7 @@ datasink_t datasink_local = { ...@@ -42,6 +53,7 @@ datasink_t datasink_local = {
&local_close, &local_close,
&local_deinit &local_deinit
}; };
}
static static
ds_ctxt_t * ds_ctxt_t *
...@@ -59,7 +71,7 @@ local_init(const char *root) ...@@ -59,7 +71,7 @@ local_init(const char *root)
return NULL; return NULL;
} }
ctxt = my_malloc(sizeof(ds_ctxt_t), MYF(MY_FAE)); ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t), MYF(MY_FAE));
ctxt->root = my_strdup(root, MYF(MY_FAE)); ctxt->root = my_strdup(root, MYF(MY_FAE));
...@@ -106,7 +118,10 @@ local_open(ds_ctxt_t *ctxt, const char *path, ...@@ -106,7 +118,10 @@ local_open(ds_ctxt_t *ctxt, const char *path,
local_file = (ds_local_file_t *) (file + 1); local_file = (ds_local_file_t *) (file + 1);
local_file->fd = fd; local_file->fd = fd;
local_file->init_ibd_done = 0;
local_file->is_ibd = (path_len > 5) && !strcmp(fullpath + path_len - 5, ".ibd");
local_file->compressed = 0;
local_file->pagesize = 0;
file->path = (char *) local_file + sizeof(ds_local_file_t); file->path = (char *) local_file + sizeof(ds_local_file_t);
memcpy(file->path, fullpath, path_len); memcpy(file->path, fullpath, path_len);
...@@ -115,31 +130,124 @@ local_open(ds_ctxt_t *ctxt, const char *path, ...@@ -115,31 +130,124 @@ local_open(ds_ctxt_t *ctxt, const char *path,
return file; return file;
} }
/* Calculate size of data without trailing zero bytes. */
static size_t trim_binary_zeros(uchar *buf, size_t pagesize)
{
size_t i;
for (i = pagesize; (i > 0) && (buf[i - 1] == 0); i--) {};
return i;
}
/* Write data to the output file, and punch "holes" if needed. */
static int write_compressed(File fd, uchar *data, size_t len, size_t pagesize)
{
uchar *ptr = data;
for (size_t written= 0; written < len;)
{
size_t n_bytes = MY_MIN(pagesize, len - written);
size_t datasize= trim_binary_zeros(ptr,n_bytes);
if (datasize > 0) {
if (!my_write(fd, ptr, datasize, MYF(MY_WME | MY_NABP)))
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
else
return 1;
}
if (datasize < n_bytes) {
/* This punches a "hole" in the file. */
size_t hole_bytes = n_bytes - datasize;
if (my_seek(fd, hole_bytes, MY_SEEK_CUR, MYF(MY_WME | MY_NABP))
== MY_FILEPOS_ERROR)
return 1;
}
written += n_bytes;
ptr += n_bytes;
}
return 0;
}
/* Calculate Innodb tablespace specific data, when first page is written.
We're interested in page compression and page size.
*/
static void init_ibd_data(ds_local_file_t *local_file, const uchar *buf, size_t len)
{
if (len < FIL_PAGE_DATA + FSP_SPACE_FLAGS) {
/* Weird, bail out.*/
return;
}
ulint flags = mach_read_from_4(&buf[FIL_PAGE_DATA + FSP_SPACE_FLAGS]);
ulint ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
local_file->pagesize= ssize == 0 ? UNIV_PAGE_SIZE_ORIG : ((UNIV_ZIP_SIZE_MIN >> 1) << ssize);
local_file->compressed = (my_bool)FSP_FLAGS_HAS_PAGE_COMPRESSION(flags);
#if defined(_WIN32) && (MYSQL_VERSION_ID > 100200)
/* Make compressed file sparse, on Windows.
In 10.1, we do not use sparse files. */
if (local_file->compressed) {
HANDLE handle= my_get_osfhandle(local_file->fd);
if (!DeviceIoControl(handle, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, NULL, 0)) {
fprintf(stderr, "Warning: cannot make file sparse");
local_file->compressed = 0;
}
}
#endif
}
static static
int int
local_write(ds_file_t *file, const void *buf, size_t len) local_write(ds_file_t *file, const uchar *buf, size_t len)
{ {
File fd = ((ds_local_file_t *) file->ptr)->fd; uchar *b = (uchar*)buf;
ds_local_file_t *local_file= (ds_local_file_t *)file->ptr;
File fd = local_file->fd;
if (local_file->is_ibd && !local_file->init_ibd_done) {
init_ibd_data(local_file, b , len);
local_file->init_ibd_done= 1;
}
if (local_file->compressed) {
return write_compressed(fd, b, len, local_file->pagesize);
}
if (!my_write(fd, buf, len, MYF(MY_WME | MY_NABP))) { if (!my_write(fd, b , len, MYF(MY_WME | MY_NABP))) {
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
return 0; return 0;
} }
return 1; return 1;
} }
/* Set EOF at file's current position.*/
static int set_eof(File fd)
{
#ifdef _WIN32
return !SetEndOfFile(my_get_osfhandle(fd));
#elif defined(HAVE_FTRUNCATE)
return ftruncate(fd, my_tell(fd, MYF(MY_WME)));
#else
#error no ftruncate
#endif
}
static static
int int
local_close(ds_file_t *file) local_close(ds_file_t *file)
{ {
File fd = ((ds_local_file_t *) file->ptr)->fd; ds_local_file_t *local_file= (ds_local_file_t *)file->ptr;
File fd = local_file->fd;
int ret= 0;
my_free(file); if (local_file->compressed) {
ret = set_eof(fd);
my_sync(fd, MYF(MY_WME)); }
return my_close(fd, MYF(MY_WME)); my_close(fd, MYF(MY_WME));
my_free(file);
return ret;
} }
static static
......
...@@ -23,6 +23,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ...@@ -23,6 +23,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "datasink.h" #include "datasink.h"
extern datasink_t datasink_local; #ifdef __cplusplus
extern "C"
#else
extern
#endif
datasink_t datasink_local;
#endif #endif
...@@ -30,7 +30,7 @@ typedef struct { ...@@ -30,7 +30,7 @@ typedef struct {
static ds_ctxt_t *stdout_init(const char *root); static ds_ctxt_t *stdout_init(const char *root);
static ds_file_t *stdout_open(ds_ctxt_t *ctxt, const char *path, static ds_file_t *stdout_open(ds_ctxt_t *ctxt, const char *path,
MY_STAT *mystat); MY_STAT *mystat);
static int stdout_write(ds_file_t *file, const void *buf, size_t len); static int stdout_write(ds_file_t *file, const uchar *buf, size_t len);
static int stdout_close(ds_file_t *file); static int stdout_close(ds_file_t *file);
static void stdout_deinit(ds_ctxt_t *ctxt); static void stdout_deinit(ds_ctxt_t *ctxt);
...@@ -91,7 +91,7 @@ stdout_open(ds_ctxt_t *ctxt __attribute__((unused)), ...@@ -91,7 +91,7 @@ stdout_open(ds_ctxt_t *ctxt __attribute__((unused)),
static static
int int
stdout_write(ds_file_t *file, const void *buf, size_t len) stdout_write(ds_file_t *file, const uchar *buf, size_t len)
{ {
File fd = ((ds_stdout_file_t *) file->ptr)->fd; File fd = ((ds_stdout_file_t *) file->ptr)->fd;
......
...@@ -41,7 +41,7 @@ typedef struct { ...@@ -41,7 +41,7 @@ typedef struct {
static ds_ctxt_t *tmpfile_init(const char *root); static ds_ctxt_t *tmpfile_init(const char *root);
static ds_file_t *tmpfile_open(ds_ctxt_t *ctxt, const char *path, static ds_file_t *tmpfile_open(ds_ctxt_t *ctxt, const char *path,
MY_STAT *mystat); MY_STAT *mystat);
static int tmpfile_write(ds_file_t *file, const void *buf, size_t len); static int tmpfile_write(ds_file_t *file, const uchar *buf, size_t len);
static int tmpfile_close(ds_file_t *file); static int tmpfile_close(ds_file_t *file);
static void tmpfile_deinit(ds_ctxt_t *ctxt); static void tmpfile_deinit(ds_ctxt_t *ctxt);
...@@ -143,7 +143,7 @@ tmpfile_open(ds_ctxt_t *ctxt, const char *path, ...@@ -143,7 +143,7 @@ tmpfile_open(ds_ctxt_t *ctxt, const char *path,
} }
static int static int
tmpfile_write(ds_file_t *file, const void *buf, size_t len) tmpfile_write(ds_file_t *file, const uchar *buf, size_t len)
{ {
File fd = ((ds_tmp_file_t *) file->ptr)->fd; File fd = ((ds_tmp_file_t *) file->ptr)->fd;
......
...@@ -41,7 +41,7 @@ General streaming interface */ ...@@ -41,7 +41,7 @@ General streaming interface */
static ds_ctxt_t *xbstream_init(const char *root); static ds_ctxt_t *xbstream_init(const char *root);
static ds_file_t *xbstream_open(ds_ctxt_t *ctxt, const char *path, static ds_file_t *xbstream_open(ds_ctxt_t *ctxt, const char *path,
MY_STAT *mystat); MY_STAT *mystat);
static int xbstream_write(ds_file_t *file, const void *buf, size_t len); static int xbstream_write(ds_file_t *file, const uchar *buf, size_t len);
static int xbstream_close(ds_file_t *file); static int xbstream_close(ds_file_t *file);
static void xbstream_deinit(ds_ctxt_t *ctxt); static void xbstream_deinit(ds_ctxt_t *ctxt);
...@@ -166,7 +166,7 @@ xbstream_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat) ...@@ -166,7 +166,7 @@ xbstream_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat)
static static
int int
xbstream_write(ds_file_t *file, const void *buf, size_t len) xbstream_write(ds_file_t *file, const uchar *buf, size_t len)
{ {
ds_stream_file_t *stream_file; ds_stream_file_t *stream_file;
xb_wstream_file_t *xbstream_file; xb_wstream_file_t *xbstream_file;
......
...@@ -255,7 +255,7 @@ static struct my_option ibx_long_options[] = ...@@ -255,7 +255,7 @@ static struct my_option ibx_long_options[] =
{"galera-info", OPT_GALERA_INFO, "This options creates the " {"galera-info", OPT_GALERA_INFO, "This options creates the "
"xtrabackup_galera_info file which contains the local node state at " "xtrabackup_galera_info file which contains the local node state at "
"the time of the backup. Option should be used when performing the " "the time of the backup. Option should be used when performing the "
"backup of Percona-XtraDB-Cluster. Has no effect when backup locks " "backup of MariaDB Galera Cluster. Has no effect when backup locks "
"are used to create the backup.", "are used to create the backup.",
(uchar *) &opt_ibx_galera_info, (uchar *) &opt_ibx_galera_info, 0, (uchar *) &opt_ibx_galera_info, (uchar *) &opt_ibx_galera_info, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
......
...@@ -443,9 +443,7 @@ int parse_args(int argc, char **argv) ...@@ -443,9 +443,7 @@ int parse_args(int argc, char **argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (load_defaults("my", load_default_groups, &argc, &argv)) { load_defaults_or_exit("my", load_default_groups, &argc, &argv);
exit(EXIT_FAILURE);
}
if (handle_options(&argc, &argv, my_long_options, get_one_option)) { if (handle_options(&argc, &argv, my_long_options, get_one_option)) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
...@@ -203,6 +203,10 @@ static ulong max_buf_pool_modified_pct; ...@@ -203,6 +203,10 @@ static ulong max_buf_pool_modified_pct;
/* Ignored option (--log) for MySQL option compatibility */ /* Ignored option (--log) for MySQL option compatibility */
char* log_ignored_opt = NULL; char* log_ignored_opt = NULL;
extern my_bool opt_use_ssl;
my_bool opt_ssl_verify_server_cert;
/* === metadata of backup === */ /* === metadata of backup === */
#define XTRABACKUP_METADATA_FILENAME "xtrabackup_checkpoints" #define XTRABACKUP_METADATA_FILENAME "xtrabackup_checkpoints"
char metadata_type[30] = ""; /*[full-backuped|log-applied| char metadata_type[30] = ""; /*[full-backuped|log-applied|
...@@ -360,9 +364,6 @@ uint opt_safe_slave_backup_timeout = 0; ...@@ -360,9 +364,6 @@ uint opt_safe_slave_backup_timeout = 0;
const char *opt_history = NULL; const char *opt_history = NULL;
#if defined(HAVE_OPENSSL)
my_bool opt_ssl_verify_server_cert = FALSE;
#endif
/* Whether xtrabackup_binlog_info should be created on recovery */ /* Whether xtrabackup_binlog_info should be created on recovery */
static bool recover_binlog_info; static bool recover_binlog_info;
...@@ -453,6 +454,7 @@ typedef struct { ...@@ -453,6 +454,7 @@ typedef struct {
} data_thread_ctxt_t; } data_thread_ctxt_t;
/* ======== for option and variables ======== */ /* ======== for option and variables ======== */
#include <../../client/client_priv.h>
enum options_xtrabackup enum options_xtrabackup
{ {
...@@ -528,8 +530,6 @@ enum options_xtrabackup ...@@ -528,8 +530,6 @@ enum options_xtrabackup
OPT_INNODB_LOG_CHECKSUM_ALGORITHM, OPT_INNODB_LOG_CHECKSUM_ALGORITHM,
OPT_XTRA_INCREMENTAL_FORCE_SCAN, OPT_XTRA_INCREMENTAL_FORCE_SCAN,
OPT_DEFAULTS_GROUP, OPT_DEFAULTS_GROUP,
OPT_OPEN_FILES_LIMIT,
OPT_PLUGIN_DIR,
OPT_PLUGIN_LOAD, OPT_PLUGIN_LOAD,
OPT_INNODB_ENCRYPT_LOG, OPT_INNODB_ENCRYPT_LOG,
OPT_CLOSE_FILES, OPT_CLOSE_FILES,
...@@ -694,7 +694,7 @@ struct my_option xb_client_options[] = ...@@ -694,7 +694,7 @@ struct my_option xb_client_options[] =
{"galera-info", OPT_GALERA_INFO, "This options creates the " {"galera-info", OPT_GALERA_INFO, "This options creates the "
"xtrabackup_galera_info file which contains the local node state at " "xtrabackup_galera_info file which contains the local node state at "
"the time of the backup. Option should be used when performing the " "the time of the backup. Option should be used when performing the "
"backup of Percona-XtraDB-Cluster. Has no effect when backup locks " "backup of MariaDB Galera Cluster. Has no effect when backup locks "
"are used to create the backup.", "are used to create the backup.",
(uchar *) &opt_galera_info, (uchar *) &opt_galera_info, 0, (uchar *) &opt_galera_info, (uchar *) &opt_galera_info, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
...@@ -915,9 +915,9 @@ struct my_option xb_client_options[] = ...@@ -915,9 +915,9 @@ struct my_option xb_client_options[] =
{"secure-auth", OPT_XB_SECURE_AUTH, "Refuse client connecting to server if it" {"secure-auth", OPT_XB_SECURE_AUTH, "Refuse client connecting to server if it"
" uses old (pre-4.1.1) protocol.", &opt_secure_auth, " uses old (pre-4.1.1) protocol.", &opt_secure_auth,
&opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, &opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
#define MYSQL_CLIENT
#include "sslopt-longopts.h" #include "sslopt-longopts.h"
#undef MYSQL_CLIENT
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
...@@ -1388,7 +1388,9 @@ xb_get_one_option(int optid, ...@@ -1388,7 +1388,9 @@ xb_get_one_option(int optid,
} }
} }
break; break;
#define MYSQL_CLIENT
#include "sslopt-case.h" #include "sslopt-case.h"
#undef MYSQL_CLIENT
case '?': case '?':
usage(); usage();
...@@ -3079,6 +3081,85 @@ xb_fil_io_init(void) ...@@ -3079,6 +3081,85 @@ xb_fil_io_init(void)
fsp_init(); fsp_init();
} }
/** Assign srv_undo_space_id_start variable if there are undo tablespace present.
Read the TRX_SYS page from ibdata1 file and get the minimum space id from
the first slot rollback segments of TRX_SYS_PAGE_NO.
@retval DB_ERROR if file open or page read failed.
@retval DB_SUCCESS if srv_undo_space_id assigned successfully. */
static dberr_t xb_assign_undo_space_start()
{
ulint dirnamelen;
char name[1000];
pfs_os_file_t file;
byte* buf;
byte* page;
ibool ret;
dberr_t error = DB_SUCCESS;
ulint space, page_no;
if (srv_undo_tablespaces == 0) {
return error;
}
srv_normalize_path_for_win(srv_data_home);
dirnamelen = strlen(srv_data_home);
memcpy(name, srv_data_home, dirnamelen);
if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
name[dirnamelen++] = SRV_PATH_SEPARATOR;
}
ut_snprintf(name + dirnamelen, (sizeof name) - dirnamelen,
"%s", "ibdata1");
file = os_file_create(innodb_file_data_key, name, OS_FILE_OPEN,
OS_FILE_NORMAL, OS_DATA_FILE, &ret, 0);
if (ret == FALSE) {
fprintf(stderr, "InnoDB: Error in opening %s\n", name);
return DB_ERROR;
}
buf = static_cast<byte*>(ut_malloc(2 * UNIV_PAGE_SIZE));
page = static_cast<byte*>(ut_align(buf, UNIV_PAGE_SIZE));
retry:
ret = os_file_read(file, page, TRX_SYS_PAGE_NO * UNIV_PAGE_SIZE,
UNIV_PAGE_SIZE);
if (!ret) {
fprintf(stderr, "InnoDB: Reading TRX_SYS page failed.");
error = DB_ERROR;
goto func_exit;
}
/* TRX_SYS page can't be compressed or encrypted. */
if (buf_page_is_corrupted(false, page, 0, NULL)) {
goto retry;
}
/* 0th slot always points to system tablespace.
1st slot should point to first undotablespace which is minimum. */
page_no = mach_read_ulint(TRX_SYS + TRX_SYS_RSEGS
+ TRX_SYS_RSEG_SLOT_SIZE
+ TRX_SYS_RSEG_PAGE_NO + page, MLOG_4BYTES);
ut_ad(page_no != FIL_NULL);
space = mach_read_ulint(TRX_SYS + TRX_SYS_RSEGS
+ TRX_SYS_RSEG_SLOT_SIZE
+ TRX_SYS_RSEG_SPACE + page, MLOG_4BYTES);
srv_undo_space_id_start = space;
func_exit:
ut_free(buf);
ret = os_file_close(file);
ut_a(ret);
return error;
}
/**************************************************************************** /****************************************************************************
Populates the tablespace memory cache by scanning for and opening data files. Populates the tablespace memory cache by scanning for and opening data files.
@returns DB_SUCCESS or error code.*/ @returns DB_SUCCESS or error code.*/
...@@ -3132,6 +3213,12 @@ xb_load_tablespaces(void) ...@@ -3132,6 +3213,12 @@ xb_load_tablespaces(void)
/* Add separate undo tablespaces to fil_system */ /* Add separate undo tablespaces to fil_system */
err = xb_assign_undo_space_start();
if (err != DB_SUCCESS) {
return err;
}
err = srv_undo_tablespaces_init(FALSE, err = srv_undo_tablespaces_init(FALSE,
TRUE, TRUE,
srv_undo_tablespaces, srv_undo_tablespaces,
...@@ -4881,8 +4968,6 @@ xtrabackup_apply_delta( ...@@ -4881,8 +4968,6 @@ xtrabackup_apply_delta(
posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL); posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL);
os_file_set_nocache(src_file, src_path, "OPEN");
dst_file = xb_delta_open_matching_space( dst_file = xb_delta_open_matching_space(
dbname, space_name, info.space_id, info.zip_size, dbname, space_name, info.space_id, info.zip_size,
dst_path, sizeof(dst_path), &success); dst_path, sizeof(dst_path), &success);
...@@ -4893,8 +4978,6 @@ xtrabackup_apply_delta( ...@@ -4893,8 +4978,6 @@ xtrabackup_apply_delta(
posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED); posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED);
os_file_set_nocache(dst_file, dst_path, "OPEN");
/* allocate buffer for incremental backup (4096 pages) */ /* allocate buffer for incremental backup (4096 pages) */
incremental_buffer_base = static_cast<byte *> incremental_buffer_base = static_cast<byte *>
(ut_malloc((page_size / 4 + 1) * (ut_malloc((page_size / 4 + 1) *
...@@ -4994,6 +5077,13 @@ xtrabackup_apply_delta( ...@@ -4994,6 +5077,13 @@ xtrabackup_apply_delta(
} }
} }
/* Free file system buffer cache after the batch was written. */
#ifdef __linux__
os_file_flush_func(dst_file);
#endif
posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED);
incremental_buffers++; incremental_buffers++;
} }
...@@ -6350,10 +6440,8 @@ handle_options(int argc, char **argv, char ***argv_client, char ***argv_server) ...@@ -6350,10 +6440,8 @@ handle_options(int argc, char **argv, char ***argv_client, char ***argv_server)
*argv_client = argv; *argv_client = argv;
*argv_server = argv; *argv_server = argv;
if (load_defaults(conf_file, xb_server_default_groups, load_defaults_or_exit(conf_file, xb_server_default_groups,
&argc_server, argv_server)) { &argc_server, argv_server);
exit(EXIT_FAILURE);
}
int n; int n;
for (n = 0; (*argv_server)[n]; n++) {}; for (n = 0; (*argv_server)[n]; n++) {};
...@@ -6403,10 +6491,8 @@ handle_options(int argc, char **argv, char ***argv_client, char ***argv_server) ...@@ -6403,10 +6491,8 @@ handle_options(int argc, char **argv, char ***argv_client, char ***argv_server)
xb_server_options, xb_get_one_option))) xb_server_options, xb_get_one_option)))
exit(ho_error); exit(ho_error);
if (load_defaults(conf_file, xb_client_default_groups, load_defaults_or_exit(conf_file, xb_client_default_groups,
&argc_client, argv_client)) { &argc_client, argv_client);
exit(EXIT_FAILURE);
}
for (n = 0; (*argv_client)[n]; n++) {}; for (n = 0; (*argv_client)[n]; n++) {};
argc_client = n; argc_client = n;
...@@ -6618,6 +6704,10 @@ int main(int argc, char **argv) ...@@ -6618,6 +6704,10 @@ int main(int argc, char **argv)
xtrabackup_incremental = NULL; xtrabackup_incremental = NULL;
} }
if (xtrabackup_stream && !xtrabackup_backup) {
msg("Warning: --stream parameter is ignored, it only works together with --backup.\n");
}
if (!xb_init()) { if (!xb_init()) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
......
...@@ -206,6 +206,9 @@ int main(int argc, char **argv) ...@@ -206,6 +206,9 @@ int main(int argc, char **argv)
if ((error= load_defaults(config_file, (const char **) load_default_groups, if ((error= load_defaults(config_file, (const char **) load_default_groups,
&count, &arguments))) &count, &arguments)))
{ {
my_end(0);
if (error == 4)
return 0;
if (verbose && opt_defaults_file_used) if (verbose && opt_defaults_file_used)
{ {
if (error == 1) if (error == 1)
...@@ -216,8 +219,7 @@ int main(int argc, char **argv) ...@@ -216,8 +219,7 @@ int main(int argc, char **argv)
fprintf(stderr, "WARNING: Defaults file '%s' is not a regular file!\n", fprintf(stderr, "WARNING: Defaults file '%s' is not a regular file!\n",
config_file); config_file);
} }
error= 2; return 2;
exit(error);
} }
for (argument= arguments+1 ; *argument ; argument++) for (argument= arguments+1 ; *argument ; argument++)
......
...@@ -788,6 +788,16 @@ int DoProcessReply(SSL& ssl) ...@@ -788,6 +788,16 @@ int DoProcessReply(SSL& ssl)
needHdr = true; needHdr = true;
else { else {
buffer >> hdr; buffer >> hdr;
/*
According to RFC 4346 (see "7.4.1.3. Server Hello"), the Server Hello
packet needs to specify the highest supported TLS version, but not
higher than what client requests. YaSSL highest supported version is
TLSv1.1 (=3.2) - if the client requests a higher version, downgrade it
here to 3.2.
See also Appendix E of RFC 5246 (TLS 1.2)
*/
if (hdr.version_.major_ == 3 && hdr.version_.minor_ > 2)
hdr.version_.minor_ = 2;
ssl.verifyState(hdr); ssl.verifyState(hdr);
} }
......
...@@ -144,6 +144,7 @@ typedef struct st_heap_share ...@@ -144,6 +144,7 @@ typedef struct st_heap_share
uint key_version; /* Updated on key change */ uint key_version; /* Updated on key change */
uint file_version; /* Update on clear */ uint file_version; /* Update on clear */
uint reclength; /* Length of one record */ uint reclength; /* Length of one record */
uint visible; /* Offset to the visible/deleted mark */
uint changed; uint changed;
uint keys,max_key_length; uint keys,max_key_length;
uint currently_disabled_keys; /* saved value from "keys" when disabled */ uint currently_disabled_keys; /* saved value from "keys" when disabled */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment