Commit 4768db8a authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

Update upstream source from tag 'upstream/10.1.34'

Update to upstream version '10.1.34'
with Debian dir 4b26ffc88bd634f8403c4707b28cee52312ddd15
parents 840ab6db 7c477360
...@@ -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}
}; };
...@@ -1103,11 +1103,13 @@ Disable with --skip-innodb-doublewrite.", (G_PTR*) &innobase_use_doublewrite, ...@@ -1103,11 +1103,13 @@ Disable with --skip-innodb-doublewrite.", (G_PTR*) &innobase_use_doublewrite,
(G_PTR*) &defaults_group, (G_PTR*) &defaults_group, (G_PTR*) &defaults_group, (G_PTR*) &defaults_group,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"plugin-dir", OPT_PLUGIN_DIR, "Server plugin directory", {"plugin-dir", OPT_PLUGIN_DIR,
"Server plugin directory. Used to load encryption plugin during 'prepare' phase."
"Has no effect in the 'backup' phase (plugin directory during backup is the same as server's)",
&xb_plugin_dir, &xb_plugin_dir, &xb_plugin_dir, &xb_plugin_dir,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "plugin-load", OPT_PLUGIN_LOAD, "encrypton plugin to load", { "plugin-load", OPT_PLUGIN_LOAD, "encrypton plugin to load during 'prepare' phase.",
&xb_plugin_load, &xb_plugin_load, &xb_plugin_load, &xb_plugin_load,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
...@@ -1181,10 +1183,10 @@ debug_sync_point(const char *name) ...@@ -1181,10 +1183,10 @@ debug_sync_point(const char *name)
} }
static const char *xb_client_default_groups[]= static const char *xb_client_default_groups[]=
{ "xtrabackup", "client", 0, 0, 0 }; { "xtrabackup", "mariabackup", "client", 0, 0, 0 };
static const char *xb_server_default_groups[]= static const char *xb_server_default_groups[]=
{ "xtrabackup", "mysqld", 0, 0, 0 }; { "xtrabackup", "mariabackup", "mysqld", 0, 0, 0 };
static void print_version(void) static void print_version(void)
{ {
...@@ -1211,7 +1213,7 @@ GNU General Public License for more details.\n\ ...@@ -1211,7 +1213,7 @@ GNU General Public License for more details.\n\
\n\ \n\
You can download full text of the license on http://www.gnu.org/licenses/gpl-2.0.txt\n"); You can download full text of the license on http://www.gnu.org/licenses/gpl-2.0.txt\n");
printf("Usage: [%s [--defaults-file=#] --backup | %s [--defaults-file=#] --prepare] [OPTIONS]\n",my_progname,my_progname); printf("Usage: %s [--defaults-file=#] [--backup | --prepare | --copy-back | --move-back] [OPTIONS]\n",my_progname);
print_defaults("my", xb_server_default_groups); print_defaults("my", xb_server_default_groups);
my_print_help(xb_client_options); my_print_help(xb_client_options);
my_print_help(xb_server_options); my_print_help(xb_server_options);
...@@ -1378,11 +1380,17 @@ xb_get_one_option(int optid, ...@@ -1378,11 +1380,17 @@ xb_get_one_option(int optid,
case OPT_PROTOCOL: case OPT_PROTOCOL:
if (argument) if (argument)
{ {
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
opt->name); opt->name)) <= 0)
{
sf_leaking_memory= 1; /* no memory leak reports here */
exit(1);
}
} }
break; break;
#define MYSQL_CLIENT
#include "sslopt-case.h" #include "sslopt-case.h"
#undef MYSQL_CLIENT
case '?': case '?':
usage(); usage();
...@@ -2555,8 +2563,9 @@ xtrabackup_scan_log_recs( ...@@ -2555,8 +2563,9 @@ xtrabackup_scan_log_recs(
to this lsn */ to this lsn */
lsn_t* group_scanned_lsn,/*!< out: scanning succeeded up to lsn_t* group_scanned_lsn,/*!< out: scanning succeeded up to
this lsn */ this lsn */
bool* finished) /*!< out: false if is not able to scan bool* finished, /*!< out: false if is not able to scan
any more in this log group */ any more in this log group */
bool* must_reread_log) /*!< out: should re-read buffer from disk, incomplete read*/
{ {
lsn_t scanned_lsn; lsn_t scanned_lsn;
ulint data_len; ulint data_len;
...@@ -2566,6 +2575,7 @@ xtrabackup_scan_log_recs( ...@@ -2566,6 +2575,7 @@ xtrabackup_scan_log_recs(
ulint scanned_checkpoint_no = 0; ulint scanned_checkpoint_no = 0;
*finished = false; *finished = false;
*must_reread_log = false;
scanned_lsn = start_lsn; scanned_lsn = start_lsn;
log_block = log_sys->buf; log_block = log_sys->buf;
...@@ -2622,8 +2632,10 @@ xtrabackup_scan_log_recs( ...@@ -2622,8 +2632,10 @@ xtrabackup_scan_log_recs(
msg("mariabackup: warning: this is possible when the " msg("mariabackup: warning: this is possible when the "
"log block has not been fully written by the " "log block has not been fully written by the "
"server, will retry later.\n"); "server, will retry later.\n");
*finished = true; *finished = false;
break; *must_reread_log = true;
my_sleep(1000);
return false;
} }
if (log_block_get_flush_bit(log_block)) { if (log_block_get_flush_bit(log_block)) {
...@@ -2688,7 +2700,7 @@ xtrabackup_scan_log_recs( ...@@ -2688,7 +2700,7 @@ xtrabackup_scan_log_recs(
if (srv_encrypt_log) { if (srv_encrypt_log) {
log_encrypt_before_write(scanned_checkpoint_no, log_encrypt_before_write(scanned_checkpoint_no,
log_sys->buf, write_size); log_sys->buf, start_lsn, write_size);
} }
if (ds_write(dst_log_file, log_sys->buf, write_size)) { if (ds_write(dst_log_file, log_sys->buf, write_size)) {
...@@ -2735,14 +2747,23 @@ xtrabackup_copy_logfile(lsn_t from_lsn, my_bool is_last) ...@@ -2735,14 +2747,23 @@ xtrabackup_copy_logfile(lsn_t from_lsn, my_bool is_last)
mutex_enter(&log_sys->mutex); mutex_enter(&log_sys->mutex);
log_group_read_log_seg(LOG_RECOVER, log_sys->buf, bool scan_ok = false;
group, start_lsn, end_lsn, false); bool must_reread_log;
int retries = 0;
do {
log_group_read_log_seg(LOG_RECOVER, log_sys->buf,
group, start_lsn, end_lsn, false);
scan_ok = xtrabackup_scan_log_recs(group, is_last,
start_lsn, &contiguous_lsn, &group_scanned_lsn,
&finished, &must_reread_log);
} while (!scan_ok && must_reread_log && retries++ < 100);
if (!xtrabackup_scan_log_recs(group, is_last, if (!scan_ok) {
start_lsn, &contiguous_lsn, &group_scanned_lsn,
&finished)) {
goto error; goto error;
} }
mutex_exit(&log_sys->mutex); mutex_exit(&log_sys->mutex);
...@@ -3060,6 +3081,85 @@ xb_fil_io_init(void) ...@@ -3060,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.*/
...@@ -3113,6 +3213,12 @@ xb_load_tablespaces(void) ...@@ -3113,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,
...@@ -4227,16 +4333,11 @@ xtrabackup_init_temp_log(void) ...@@ -4227,16 +4333,11 @@ xtrabackup_init_temp_log(void)
ib_int64_t file_size; ib_int64_t file_size;
lsn_t max_no; lsn_t max_no = 0;
lsn_t max_lsn; lsn_t max_lsn = 0;
lsn_t checkpoint_no;
ulint fold; ulint fold;
bool checkpoint_found;
max_no = 0;
if (!log_buf) { if (!log_buf) {
goto error; goto error;
} }
...@@ -4335,35 +4436,29 @@ xtrabackup_init_temp_log(void) ...@@ -4335,35 +4436,29 @@ xtrabackup_init_temp_log(void)
// ' ', 4); // ' ', 4);
} }
checkpoint_found = false;
/* read last checkpoint lsn */ /* read last checkpoint lsn */
for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2; for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2;
field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) { field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) {
if (!recv_check_cp_is_consistent(const_cast<const byte *> if (!recv_check_cp_is_consistent(const_cast<const byte *>
(log_buf + field))) (log_buf + field)))
goto not_consistent; continue;
checkpoint_no = mach_read_from_8(log_buf + field + lsn_t checkpoint_no = mach_read_from_8(log_buf + field +
LOG_CHECKPOINT_NO); LOG_CHECKPOINT_NO);
if (checkpoint_no >= max_no) { if (checkpoint_no >= max_no) {
max_no = checkpoint_no; max_no = checkpoint_no;
max_lsn = mach_read_from_8(log_buf + field + max_lsn = mach_read_from_8(log_buf + field +
LOG_CHECKPOINT_LSN); LOG_CHECKPOINT_LSN);
checkpoint_found = true;
} }
not_consistent:
;
} }
if (!checkpoint_found) { if (!max_lsn) {
msg("mariabackup: No valid checkpoint found.\n"); msg("mariabackup: No valid checkpoint found.\n");
goto error; goto error;
} }
/* It seems to be needed to overwrite the both checkpoint area. */ /* It seems to be needed to overwrite the both checkpoint area. */
mach_write_to_8(log_buf + LOG_CHECKPOINT_1 + LOG_CHECKPOINT_LSN, mach_write_to_8(log_buf + LOG_CHECKPOINT_1 + LOG_CHECKPOINT_LSN,
max_lsn); max_lsn);
...@@ -4873,8 +4968,6 @@ xtrabackup_apply_delta( ...@@ -4873,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);
...@@ -4885,8 +4978,6 @@ xtrabackup_apply_delta( ...@@ -4885,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) *
...@@ -4955,10 +5046,29 @@ xtrabackup_apply_delta( ...@@ -4955,10 +5046,29 @@ xtrabackup_apply_delta(
const os_offset_t off = os_offset_t(offset_on_page)*page_size; const os_offset_t off = os_offset_t(offset_on_page)*page_size;
if (off == 0) { if (off == 0) {
/* Fix tablespace size. */ /* Read tablespace size from page 0,
os_offset_t n_pages = fsp_get_size_low(static_cast<ib_page_t *>(buf)); extend the tablespace to specified size. */
if (!os_file_set_size(dst_path, dst_file, n_pages*page_size)) os_offset_t n_pages = mach_read_from_4(buf + FSP_HEADER_OFFSET + FSP_SIZE);
goto error; ulint space_id = mach_read_from_4(buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
if (space_id != TRX_SYS_SPACE) {
if (!os_file_set_size(dst_path, dst_file, n_pages*page_size))
goto error;
} else {
/* System tablespace needs special handling , since
it can consist of multiple files. The first one has full
tablespace size in page 0, but only last file should be extended. */
mutex_enter(&fil_system->mutex);
fil_space_t* space = fil_space_get_by_id(space_id);
mutex_exit(&fil_system->mutex);
DBUG_ASSERT(space);
fil_node_t* n = UT_LIST_GET_FIRST(space->chain);
if(strcmp(n->name, dst_path) == 0) {
/* Got first tablespace file, with correct size */
ulint actual_size;
if (!fil_extend_space_to_desired_size(&actual_size, 0, (ulint)n_pages))
goto error;
}
}
} }
success = os_file_write(dst_path, dst_file, buf, off, page_size); success = os_file_write(dst_path, dst_file, buf, off, page_size);
...@@ -4967,6 +5077,13 @@ xtrabackup_apply_delta( ...@@ -4967,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++;
} }
...@@ -5421,7 +5538,12 @@ xb_export_cfg_write_table( ...@@ -5421,7 +5538,12 @@ xb_export_cfg_write_table(
mach_write_to_4(ptr, col->len); mach_write_to_4(ptr, col->len);
ptr += sizeof(ib_uint32_t); ptr += sizeof(ib_uint32_t);
mach_write_to_4(ptr, col->mbminmaxlen); /* FIXME: This will not work if mbminlen>4.
This field is also redundant, because the lengths
are a property of the character set encoding, which
in turn is encodedin prtype above. */
mach_write_to_4(ptr, col->mbmaxlen * 5 + col->mbminlen);
ptr += sizeof(ib_uint32_t); ptr += sizeof(ib_uint32_t);
mach_write_to_4(ptr, col->ind); mach_write_to_4(ptr, col->ind);
...@@ -6127,9 +6249,19 @@ xb_init() ...@@ -6127,9 +6249,19 @@ xb_init()
return(false); return(false);
} }
if (opt_rsync && xtrabackup_stream_fmt) { if (xtrabackup_backup && opt_rsync)
msg("Error: --rsync doesn't work with --stream\n"); {
return(false); if (xtrabackup_stream_fmt)
{
msg("Error: --rsync doesn't work with --stream\n");
return(false);
}
bool have_rsync = IF_WIN(false, (system("rsync --version > /dev/null 2>&1") == 0));
if (!have_rsync)
{
msg("Error: rsync executable not found, cannot run backup with --rsync\n");
return false;
}
} }
n_mixed_options = 0; n_mixed_options = 0;
...@@ -6308,10 +6440,8 @@ handle_options(int argc, char **argv, char ***argv_client, char ***argv_server) ...@@ -6308,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++) {};
...@@ -6361,10 +6491,8 @@ handle_options(int argc, char **argv, char ***argv_client, char ***argv_server) ...@@ -6361,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;
...@@ -6576,6 +6704,10 @@ int main(int argc, char **argv) ...@@ -6576,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 */
......
...@@ -64,15 +64,6 @@ ...@@ -64,15 +64,6 @@
extern "C" { extern "C" {
#endif #endif
/*
my_str_malloc(), my_str_realloc() and my_str_free() are assigned to
implementations in strings/alloc.c, but can be overridden in
the calling program.
*/
extern void *(*my_str_malloc)(size_t);
extern void *(*my_str_realloc)(void *, size_t);
extern void (*my_str_free)(void *);
#ifdef DBUG_OFF #ifdef DBUG_OFF
#if defined(HAVE_STPCPY) && MY_GNUC_PREREQ(3, 4) && !defined(__INTEL_COMPILER) #if defined(HAVE_STPCPY) && MY_GNUC_PREREQ(3, 4) && !defined(__INTEL_COMPILER)
#define strmov(A,B) __builtin_stpcpy((A),(B)) #define strmov(A,B) __builtin_stpcpy((A),(B))
......
...@@ -63,6 +63,15 @@ typedef struct st_mysql_lex_string LEX_STRING; ...@@ -63,6 +63,15 @@ typedef struct st_mysql_lex_string LEX_STRING;
/* NO and OK is the same used just to show semantics */ /* NO and OK is the same used just to show semantics */
#define ER_DYNCOL_NO ER_DYNCOL_OK #define ER_DYNCOL_NO ER_DYNCOL_OK
#ifdef HAVE_CHARSET_utf8mb4
#define DYNCOL_UTF (&my_charset_utf8mb4_general_ci)
#else
#define DYNCOL_UTF (&my_charset_utf8_general_ci)
#endif
/* escape json strings */
#define DYNCOL_JSON_ESC ((char)1)
enum enum_dyncol_func_result enum enum_dyncol_func_result
{ {
ER_DYNCOL_OK= 0, ER_DYNCOL_OK= 0,
......
...@@ -91,17 +91,19 @@ typedef struct st_HA_KEYSEG /* Key-portion */ ...@@ -91,17 +91,19 @@ typedef struct st_HA_KEYSEG /* Key-portion */
#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3) #define size_to_store_key_length(length) ((length) < 255 ? 1 : 3)
#define get_rec_bits(bit_ptr, bit_ofs, bit_len) \ static inline uint16 get_rec_bits(const uchar *ptr, uchar ofs, uint len)
(((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \ {
((1 << (bit_len)) - 1)) uint16 val= ptr[0];
if (ofs + len > 8)
#define set_rec_bits(bits, bit_ptr, bit_ofs, bit_len) \ val|= (uint16)(ptr[1]) << 8;
{ \ return (val >> ofs) & ((1 << len) - 1);
(bit_ptr)[0]= ((bit_ptr)[0] & ~(((1 << (bit_len)) - 1) << (bit_ofs))) | \ }
((bits) << (bit_ofs)); \
if ((bit_ofs) + (bit_len) > 8) \ static inline void set_rec_bits(uint16 bits, uchar *ptr, uchar ofs, uint len)
(bit_ptr)[1]= ((bit_ptr)[1] & ~((1 << ((bit_len) - 8 + (bit_ofs))) - 1)) | \ {
((bits) >> (8 - (bit_ofs))); \ ptr[0]= (ptr[0] & ~(((1 << len) - 1) << ofs)) | (bits << ofs);
if (ofs + len > 8)
ptr[1]= (ptr[1] & ~((1 << (len - 8 + ofs)) - 1)) | (bits >> (8 - ofs));
} }
#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \ #define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
......
...@@ -45,6 +45,13 @@ extern void free_defaults(char **argv); ...@@ -45,6 +45,13 @@ extern void free_defaults(char **argv);
extern void my_print_default_files(const char *conf_file); extern void my_print_default_files(const char *conf_file);
extern void print_defaults(const char *conf_file, const char **groups); extern void print_defaults(const char *conf_file, const char **groups);
/** Simplify load_defaults() common use */
#define load_defaults_or_exit(A, B, C, D) switch (load_defaults(A, B, C, D)) { \
case 0: break; \
case 4: my_end(0); exit(0); \
default: my_end(0); exit(1); }
C_MODE_END C_MODE_END
#endif /* MY_DEFAULT_INCLUDED */ #endif /* MY_DEFAULT_INCLUDED */
...@@ -593,8 +593,15 @@ typedef SOCKET_SIZE_TYPE size_socket; ...@@ -593,8 +593,15 @@ typedef SOCKET_SIZE_TYPE size_socket;
#ifndef O_CLOEXEC #ifndef O_CLOEXEC
#define O_CLOEXEC 0 #define O_CLOEXEC 0
#endif #endif
#ifdef __GLIBC__
#define STR_O_CLOEXEC "e"
#else
#define STR_O_CLOEXEC ""
#endif
#ifndef SOCK_CLOEXEC #ifndef SOCK_CLOEXEC
#define SOCK_CLOEXEC 0 #define SOCK_CLOEXEC 0
#else
#define HAVE_SOCK_CLOEXEC
#endif #endif
/* additional file share flags for win32 */ /* additional file share flags for win32 */
...@@ -1091,11 +1098,19 @@ static inline char *dlerror(void) ...@@ -1091,11 +1098,19 @@ static inline char *dlerror(void)
#ifndef HAVE_DLERROR #ifndef HAVE_DLERROR
#define dlerror() "" #define dlerror() ""
#endif #endif
#ifndef HAVE_DLADDR
#define dladdr(A, B) 0
/* Dummy definition in case we're missing dladdr() */
typedef struct { const char *dli_fname, dli_fbase; } Dl_info;
#endif
#else #else
#define dlerror() "No support for dynamic loading (static build?)" #define dlerror() "No support for dynamic loading (static build?)"
#define dlopen(A,B) 0 #define dlopen(A,B) 0
#define dlsym(A,B) 0 #define dlsym(A,B) 0
#define dlclose(A) 0 #define dlclose(A) 0
#define dladdr(A, B) 0
/* Dummy definition in case we're missing dladdr() */
typedef struct { const char *dli_fname, dli_fbase; } Dl_info;
#endif #endif
/* /*
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
*/ */
#ifndef MY_SYSTEMD_INCLUDED #ifndef MY_SERVICE_MANAGER_INCLUDED
#define MY_SYSTEMD_INCLUDED #define MY_SERVICE_MANAGER_INCLUDED
#if defined(HAVE_SYSTEMD) && !defined(EMBEDDED_LIBRARY) #if defined(HAVE_SYSTEMD) && !defined(EMBEDDED_LIBRARY)
/* /*
...@@ -26,9 +26,14 @@ ...@@ -26,9 +26,14 @@
*/ */
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#include <systemd/sd-daemon.h> #include <systemd/sd-daemon.h>
/** INTERVAL in seconds followed by printf style status */
#define service_manager_extend_timeout(INTERVAL, FMTSTR, ...) \
sd_notifyf(0, "STATUS=" FMTSTR "\nEXTEND_TIMEOUT_USEC=%u\n", ##__VA_ARGS__, INTERVAL * 1000000)
#else #else
#define sd_notify(X, Y) #define sd_notify(X, Y)
#define sd_notifyf(E, F, ...) #define sd_notifyf(E, F, ...)
#define service_manager_extend_timeout(I, FMTSTR, ...)
#endif #endif
#endif /* MY_SYSTEMD_INCLUDED */ #endif /* MY_SERVICE_MANAGER_INCLUDED */
...@@ -112,6 +112,7 @@ typedef struct my_aio_result { ...@@ -112,6 +112,7 @@ typedef struct my_aio_result {
#define ME_JUST_INFO 1024 /**< not error but just info */ #define ME_JUST_INFO 1024 /**< not error but just info */
#define ME_JUST_WARNING 2048 /**< not error but just warning */ #define ME_JUST_WARNING 2048 /**< not error but just warning */
#define ME_FATALERROR 4096 /* Fatal statement error */ #define ME_FATALERROR 4096 /* Fatal statement error */
#define ME_LOG_AS_WARN 8192 /* is error but error-logged as warning */
/* Bits in last argument to fn_format */ /* Bits in last argument to fn_format */
#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */ #define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
......
...@@ -13,6 +13,14 @@ ...@@ -13,6 +13,14 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
/* clang -> gcc */
#ifndef __has_feature
# define __has_feature(x) 0
#endif
#if __has_feature(address_sanitizer)
# define __SANITIZE_ADDRESS__ 1
#endif
#ifdef HAVE_valgrind #ifdef HAVE_valgrind
#define IF_VALGRIND(A,B) A #define IF_VALGRIND(A,B) A
#else #else
...@@ -25,7 +33,15 @@ ...@@ -25,7 +33,15 @@
# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len) # define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
# define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len) # define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len)
# define MEM_CHECK_DEFINED(a,len) VALGRIND_CHECK_MEM_IS_DEFINED(a,len) # define MEM_CHECK_DEFINED(a,len) VALGRIND_CHECK_MEM_IS_DEFINED(a,len)
#else /* HAVE_VALGRIND */ #elif defined(__SANITIZE_ADDRESS__)
# include <sanitizer/asan_interface.h>
/* How to do manual poisoning:
https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_UNDEFINED(a,len) ASAN_UNPOISON_MEMORY_REGION(a,len)
# define MEM_NOACCESS(a,len) ASAN_POISON_MEMORY_REGION(a,len)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
#else
# define MEM_UNDEFINED(a,len) ((void) 0) # define MEM_UNDEFINED(a,len) ((void) 0)
# define MEM_NOACCESS(a,len) ((void) 0) # define MEM_NOACCESS(a,len) ((void) 0)
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0) # define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
...@@ -33,11 +49,9 @@ ...@@ -33,11 +49,9 @@
#endif /* HAVE_VALGRIND */ #endif /* HAVE_VALGRIND */
#ifndef DBUG_OFF #ifndef DBUG_OFF
#define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); memset(A, C, trash_tmp); MEM_UNDEFINED(A, trash_tmp); } while (0) #define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_UNDEFINED(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
#else #else
#define TRASH_FILL(A,B,C) do{ const size_t trash_tmp __attribute__((unused)) = (B) ; MEM_CHECK_ADDRESSABLE(A,trash_tmp);MEM_UNDEFINED(A,trash_tmp);} while (0) #define TRASH_FILL(A,B,C) do { const size_t trash_tmp __attribute__((unused))= (B); MEM_UNDEFINED(A,trash_tmp); } while (0)
#endif #endif
#define TRASH_ALLOC(A,B) TRASH_FILL(A,B,0xA5) #define TRASH_ALLOC(A,B) do { TRASH_FILL(A,B,0xA5); MEM_UNDEFINED(A,B); } while(0)
#define TRASH_FREE(A,B) TRASH_FILL(A,B,0x8F) #define TRASH_FREE(A,B) do { TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)
#define TRASH(A,B) TRASH_FREE(A,B)
...@@ -221,8 +221,6 @@ typedef struct st_typelib { ...@@ -221,8 +221,6 @@ typedef struct st_typelib {
extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position); extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
extern int find_type_with_warning(const char *x, TYPELIB *typelib, extern int find_type_with_warning(const char *x, TYPELIB *typelib,
const char *option); const char *option);
extern int find_type_or_exit(const char *x, TYPELIB *typelib,
const char *option);
extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags); extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags);
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib); extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
extern const char *get_type(TYPELIB *typelib,unsigned int nr); extern const char *get_type(TYPELIB *typelib,unsigned int nr);
......
...@@ -562,6 +562,12 @@ inline_mysql_socket_socket ...@@ -562,6 +562,12 @@ inline_mysql_socket_socket
(key, (const my_socket*)&mysql_socket.fd, NULL, 0); (key, (const my_socket*)&mysql_socket.fd, NULL, 0);
} }
#endif #endif
/* SOCK_CLOEXEC isn't always a number - can't preprocessor compare */
#if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) && !defined(HAVE_SOCK_CLOEXEC)
(void) fcntl(mysql_socket.fd, F_SETFD, FD_CLOEXEC);
#endif
return mysql_socket; return mysql_socket;
} }
......
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. /* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
Copyright (c) 2010, 2013, Monty Program Ab Copyright (c) 2010, 2018, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
#ifndef SQL_COMMON_INCLUDED #ifndef SQL_COMMON_INCLUDED
#define SQL_COMMON_INCLUDED #define SQL_COMMON_INCLUDED
/* Copyright (c) 2003, 2012, Oracle and/or its affiliates. /* Copyright (c) 2003, 2012, Oracle and/or its affiliates.
Copyright (c) 2010, 2012, Monty Program Ab Copyright (c) 2010, 2018, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
......
...@@ -29,8 +29,6 @@ typedef struct st_typelib { /* Different types saved here */ ...@@ -29,8 +29,6 @@ typedef struct st_typelib { /* Different types saved here */
extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position); extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
extern int find_type_with_warning(const char *x, TYPELIB *typelib, extern int find_type_with_warning(const char *x, TYPELIB *typelib,
const char *option); const char *option);
extern int find_type_or_exit(const char *x, TYPELIB *typelib,
const char *option);
#define FIND_TYPE_BASIC 0 #define FIND_TYPE_BASIC 0
/** makes @c find_type() require the whole name, no prefix */ /** makes @c find_type() require the whole name, no prefix */
#define FIND_TYPE_NO_PREFIX (1 << 0) #define FIND_TYPE_NO_PREFIX (1 << 0)
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#ifndef _welcome_copyright_notice_h_ #ifndef _welcome_copyright_notice_h_
#define _welcome_copyright_notice_h_ #define _welcome_copyright_notice_h_
#define COPYRIGHT_NOTICE_CURRENT_YEAR "2017" #define COPYRIGHT_NOTICE_CURRENT_YEAR "2018"
/* /*
This define specifies copyright notice which is displayed by every MySQL This define specifies copyright notice which is displayed by every MySQL
......
...@@ -500,14 +500,14 @@ IF(NOT DISABLE_SHARED) ...@@ -500,14 +500,14 @@ IF(NOT DISABLE_SHARED)
OUTPUT_NAME mysqlclient OUTPUT_NAME mysqlclient
VERSION "${OS_SHARED_LIB_VERSION}" VERSION "${OS_SHARED_LIB_VERSION}"
SOVERSION "${SHARED_LIB_MAJOR_VERSION}") SOVERSION "${SHARED_LIB_MAJOR_VERSION}")
IF(LINK_FLAG_NO_UNDEFINED OR VERSION_SCRIPT_LINK_FLAGS) IF(VERSION_SCRIPT_LINK_FLAGS)
GET_TARGET_PROPERTY(libmysql_link_flags libmysql LINK_FLAGS) GET_TARGET_PROPERTY(libmysql_link_flags libmysql LINK_FLAGS)
IF(NOT libmysql_link_flags) IF(NOT libmysql_link_flags)
# Avoid libmysql_link_flags-NOTFOUND # Avoid libmysql_link_flags-NOTFOUND
SET(libmysql_link_flags) SET(libmysql_link_flags)
ENDIF() ENDIF()
SET_TARGET_PROPERTIES(libmysql PROPERTIES LINK_FLAGS SET_TARGET_PROPERTIES(libmysql PROPERTIES LINK_FLAGS
"${libmysql_link_flags} ${LINK_FLAG_NO_UNDEFINED} ${VERSION_SCRIPT_LINK_FLAGS}") "${libmysql_link_flags} ${VERSION_SCRIPT_LINK_FLAGS}")
ENDIF() ENDIF()
# clean direct output needs to be set several targets have the same name # clean direct output needs to be set several targets have the same name
#(mysqlclient in this case) #(mysqlclient in this case)
......
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