Commit 9dc81d2a authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.3 into 10.4

parents 890e0278 77cbaa96
......@@ -61,19 +61,19 @@ MYSQL_ADD_EXECUTABLE(mariabackup
xtrabackup.cc
innobackupex.cc
changed_page_bitmap.cc
datasink.c
ds_buffer.c
ds_compress.c
datasink.cc
ds_buffer.cc
ds_compress.cc
ds_local.cc
ds_stdout.c
ds_tmpfile.c
ds_xbstream.c
ds_stdout.cc
ds_tmpfile.cc
ds_xbstream.cc
fil_cur.cc
quicklz/quicklz.c
read_filt.cc
write_filt.cc
wsrep.cc
xbstream_write.c
xbstream_write.cc
backup_mysql.cc
backup_copy.cc
encryption_plugin.cc
......@@ -100,13 +100,13 @@ ENDIF()
# xbstream binary
########################################################################
MYSQL_ADD_EXECUTABLE(mbstream
ds_buffer.c
ds_buffer.cc
ds_local.cc
ds_stdout.c
datasink.c
xbstream.c
xbstream_read.c
xbstream_write.c
ds_stdout.cc
datasink.cc
xbstream.cc
xbstream_read.cc
xbstream_write.cc
COMPONENT backup
)
......
This diff is collapsed.
This diff is collapsed.
......@@ -203,7 +203,7 @@ log_online_read_bitmap_page(
/* The following call prints an error message */
os_file_get_last_error(TRUE);
msg("InnoDB: Warning: failed reading changed page bitmap "
"file \'%s\'\n", bitmap_file->name);
"file \'%s\'", bitmap_file->name);
return FALSE;
}
......@@ -282,7 +282,7 @@ log_online_setup_bitmap_file_range(
bitmap_dir = os_file_opendir(srv_data_home, FALSE);
if (UNIV_UNLIKELY(!bitmap_dir)) {
msg("InnoDB: Error: failed to open bitmap directory \'%s\'\n",
msg("InnoDB: Error: failed to open bitmap directory \'%s\'",
srv_data_home);
return FALSE;
}
......@@ -332,7 +332,7 @@ log_online_setup_bitmap_file_range(
if (UNIV_UNLIKELY(os_file_closedir(bitmap_dir))) {
os_file_get_last_error(TRUE);
msg("InnoDB: Error: cannot close \'%s\'\n",srv_data_home);
msg("InnoDB: Error: cannot close \'%s\'",srv_data_home);
return FALSE;
}
......@@ -349,7 +349,7 @@ log_online_setup_bitmap_file_range(
bitmap_dir = os_file_opendir(srv_data_home, FALSE);
if (UNIV_UNLIKELY(!bitmap_dir)) {
msg("InnoDB: Error: failed to open bitmap directory \'%s\'\n",
msg("InnoDB: Error: failed to open bitmap directory \'%s\'",
srv_data_home);
return FALSE;
}
......@@ -380,7 +380,7 @@ log_online_setup_bitmap_file_range(
if (UNIV_UNLIKELY(array_pos >= bitmap_files->count)) {
msg("InnoDB: Error: inconsistent bitmap file "
"directory\n");
"directory");
free(bitmap_files->files);
return FALSE;
}
......@@ -400,7 +400,7 @@ log_online_setup_bitmap_file_range(
if (UNIV_UNLIKELY(os_file_closedir(bitmap_dir))) {
os_file_get_last_error(TRUE);
msg("InnoDB: Error: cannot close \'%s\'\n", srv_data_home);
msg("InnoDB: Error: cannot close \'%s\'", srv_data_home);
free(bitmap_files->files);
return FALSE;
}
......@@ -451,7 +451,7 @@ log_online_open_bitmap_file_read_only(
/* Here and below assume that bitmap file names do not
contain apostrophes, thus no need for ut_print_filename(). */
msg("InnoDB: Warning: error opening the changed page "
"bitmap \'%s\'\n", bitmap_file->name);
"bitmap \'%s\'", bitmap_file->name);
return success;
}
......@@ -495,7 +495,7 @@ log_online_diagnose_bitmap_eof(
itself. */
msg("InnoDB: Warning: junk at the end of changed "
"page bitmap file \'%s\'.\n", bitmap_file->name);
"page bitmap file \'%s\'.", bitmap_file->name);
}
if (UNIV_UNLIKELY(!last_page_in_run)) {
......@@ -506,7 +506,7 @@ log_online_diagnose_bitmap_eof(
for the whole server */
msg("InnoDB: Warning: changed page bitmap "
"file \'%s\' does not contain a complete run "
"at the end.\n", bitmap_file->name);
"at the end.", bitmap_file->name);
return FALSE;
}
}
......@@ -537,7 +537,7 @@ xb_msg_missing_lsn_data(
lsn_t missing_interval_end) /*!<in: interval end */
{
msg("mariabackup: warning: changed page data missing for LSNs between "
LSN_PF " and " LSN_PF "\n", missing_interval_start,
LSN_PF " and " LSN_PF, missing_interval_start,
missing_interval_end);
}
......@@ -615,7 +615,7 @@ xb_page_bitmap_init(void)
msg("mariabackup: incremental backup LSN " LSN_PF
" is larger than than the last checkpoint LSN " LSN_PF
"\n", bmp_start_lsn, bmp_end_lsn);
, bmp_start_lsn, bmp_end_lsn);
return NULL;
}
......@@ -699,7 +699,7 @@ xb_page_bitmap_init(void)
bmp_start_lsn))) {
msg("mariabackup: Warning: changed page bitmap file "
"\'%s\' corrupted\n", bitmap_file.name);
"\'%s\' corrupted", bitmap_file.name);
rbt_free(result);
free(bitmap_files.files);
os_file_close(bitmap_file.file);
......@@ -804,7 +804,7 @@ xb_page_bitmap_init(void)
if (UNIV_UNLIKELY(!last_page_ok)) {
msg("mariabackup: warning: changed page bitmap file "
"\'%s\' corrupted.\n", bitmap_file.name);
"\'%s\' corrupted.", bitmap_file.name);
rbt_free(result);
free(bitmap_files.files);
os_file_close(bitmap_file.file);
......
......@@ -72,7 +72,7 @@ static inline int asprintf(char **strp, const char *fmt,...)
#define xb_a(expr) \
do { \
if (!(expr)) { \
msg("Assertion \"%s\" failed at %s:%lu\n", \
fprintf(stderr,"Assertion \"%s\" failed at %s:%lu\n", \
#expr, __FILE__, (ulong) __LINE__); \
abort(); \
} \
......@@ -86,42 +86,55 @@ static inline int asprintf(char **strp, const char *fmt,...)
#define XB_DELTA_INFO_SUFFIX ".meta"
static inline int msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
static inline int msg(const char *fmt, ...)
static inline int msg1(uint thread_num, const char *prefix, const char *fmt, va_list args)
{
int result;
va_list args;
va_start(args, fmt);
result = vfprintf(stderr, fmt, args);
va_end(args);
return result;
int result;
time_t t = time(NULL);
char date[100];
char *line;
strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&t));
result = vasprintf(&line, fmt, args);
if (result != -1) {
if (fmt && fmt[strlen(fmt)] != '\n')
result = fprintf(stderr, "[%02u] %s%s %s\n", thread_num, prefix, date, line);
else
result = fprintf(stderr, "[%02u] %s%s %s", thread_num, prefix, date, line);
free(line);
}
return result;
}
static inline int msg_ts(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
static inline int msg_ts(const char *fmt, ...)
static inline ATTRIBUTE_FORMAT(printf, 2, 3) int msg(unsigned int thread_num, const char *fmt, ...)
{
int result;
time_t t = time(NULL);
char date[100];
char *line;
va_list args;
strftime(date, sizeof(date), "%y%m%d %H:%M:%S", localtime(&t));
va_start(args, fmt);
result = vasprintf(&line, fmt, args);
va_end(args);
int result;
va_list args;
va_start(args, fmt);
result = msg1(thread_num,"", fmt, args);
va_end(args);
return result;
}
if (result != -1) {
result = fprintf(stderr, "%s %s", date, line);
free(line);
}
static inline ATTRIBUTE_FORMAT(printf, 1, 2) int msg(const char *fmt, ...)
{
int result;
va_list args;
va_start(args, fmt);
result = msg1(0, "", fmt, args);
va_end(args);
return result;
}
return result;
static inline ATTRIBUTE_FORMAT(printf, 1,2) ATTRIBUTE_NORETURN void die(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
msg1(0, "FATAL ERROR: ", fmt, args);
va_end(args);
fflush(stderr);
_exit(EXIT_FAILURE);
}
/* Use POSIX_FADV_NORMAL when available */
#ifdef POSIX_FADV_NORMAL
......
......@@ -49,8 +49,7 @@ ds_create(const char *root, ds_type_t type)
#ifdef HAVE_LIBARCHIVE
ds = &datasink_archive;
#else
msg("Error : mariabackup was built without libarchive support");
exit(EXIT_FAILURE);
die("mariabackup was built without libarchive support");
#endif
break;
case DS_TYPE_XBSTREAM:
......@@ -61,8 +60,7 @@ ds_create(const char *root, ds_type_t type)
break;
case DS_TYPE_ENCRYPT:
case DS_TYPE_DECRYPT:
msg("Error : mariabackup does not support encrypted backups.");
exit(EXIT_FAILURE);
die("mariabackup does not support encrypted backups.");
break;
case DS_TYPE_TMPFILE:
......@@ -72,7 +70,7 @@ ds_create(const char *root, ds_type_t type)
ds = &datasink_buffer;
break;
default:
msg("Unknown datasink type: %d\n", type);
msg("Unknown datasink type: %d", type);
xb_ad(0);
return NULL;
}
......@@ -81,8 +79,7 @@ ds_create(const char *root, ds_type_t type)
if (ctxt != NULL) {
ctxt->datasink = ds;
} else {
msg("Error: failed to initialize datasink.\n");
exit(EXIT_FAILURE);
die("failed to initialize datasink.");
}
return ctxt;
......
......@@ -71,7 +71,7 @@ buffer_init(const char *root)
ds_ctxt_t *ctxt;
ds_buffer_ctxt_t *buffer_ctxt;
ctxt = my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_buffer_ctxt_t),
ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_buffer_ctxt_t),
MYF(MY_FAE));
buffer_ctxt = (ds_buffer_ctxt_t *) (ctxt + 1);
buffer_ctxt->buffer_size = DS_DEFAULT_BUFFER_SIZE;
......@@ -96,7 +96,7 @@ buffer_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat)
dst_file = ds_open(pipe_ctxt, path, mystat);
if (dst_file == NULL) {
exit(EXIT_FAILURE);
die("ds_open(%s) failed", path);
}
buffer_ctxt = (ds_buffer_ctxt_t *) ctxt->ptr;
......
......@@ -96,7 +96,7 @@ compress_init(const char *root)
/* Create and initialize the worker threads */
threads = create_worker_threads(xtrabackup_compress_threads);
if (threads == NULL) {
msg("compress: failed to create worker threads.\n");
msg("compress: failed to create worker threads.");
return NULL;
}
......@@ -244,7 +244,7 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len)
write_uint64_le(dest_file,
comp_file->bytes_processed)) {
msg("compress: write to the destination stream "
"failed.\n");
"failed.");
return 1;
}
......@@ -254,7 +254,7 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len)
ds_write(dest_file, threads[i].to,
threads[i].to_len)) {
msg("compress: write to the destination stream "
"failed.\n");
"failed.");
return 1;
}
......@@ -368,7 +368,7 @@ create_worker_threads(uint n)
if (pthread_create(&thd->id, NULL, compress_worker_thread_func,
thd)) {
msg("compress: pthread_create() failed: "
"errno = %d\n", errno);
"errno = %d", errno);
goto err;
}
}
......
......@@ -49,7 +49,7 @@ stdout_init(const char *root)
{
ds_ctxt_t *ctxt;
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));
......
......@@ -61,7 +61,7 @@ tmpfile_init(const char *root)
ds_ctxt_t *ctxt;
ds_tmpfile_ctxt_t *tmpfile_ctxt;
ctxt = my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_tmpfile_ctxt_t),
ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_tmpfile_ctxt_t),
MYF(MY_FAE));
tmpfile_ctxt = (ds_tmpfile_ctxt_t *) (ctxt + 1);
tmpfile_ctxt->file_list = NULL;
......@@ -178,12 +178,11 @@ tmpfile_deinit(ds_ctxt_t *ctxt)
/* Walk the files in the order they have been added */
list = list_reverse(list);
while (list != NULL) {
tmp_file = list->data;
tmp_file = (ds_tmp_file_t *)list->data;
/* Stat the file to replace size and mtime on the original
* mystat struct */
if (my_fstat(tmp_file->fd, &mystat, MYF(0))) {
msg("error: my_fstat() failed.\n");
exit(EXIT_FAILURE);
die("my_fstat() failed.");
}
tmp_file->mystat.st_size = mystat.st_size;
tmp_file->mystat.st_mtime = mystat.st_mtime;
......@@ -191,32 +190,29 @@ tmpfile_deinit(ds_ctxt_t *ctxt)
dst_file = ds_open(pipe_ctxt, tmp_file->orig_path,
&tmp_file->mystat);
if (dst_file == NULL) {
msg("error: could not stream a temporary file to "
"'%s'\n", tmp_file->orig_path);
exit(EXIT_FAILURE);
die("could not stream a temporary file to "
"'%s'", tmp_file->orig_path);
}
/* copy to the destination datasink */
posix_fadvise(tmp_file->fd, 0, 0, POSIX_FADV_SEQUENTIAL);
if (my_seek(tmp_file->fd, 0, SEEK_SET, MYF(0)) ==
MY_FILEPOS_ERROR) {
msg("error: my_seek() failed for '%s', errno = %d.\n",
die("my_seek() failed for '%s', errno = %d.",
tmp_file->file->path, my_errno);
exit(EXIT_FAILURE);
}
offset = 0;
while ((bytes = my_read(tmp_file->fd, buf, buf_size,
while ((bytes = my_read(tmp_file->fd, (unsigned char *)buf, buf_size,
MYF(MY_WME))) > 0) {
posix_fadvise(tmp_file->fd, offset, buf_size, POSIX_FADV_DONTNEED);
offset += buf_size;
if (ds_write(dst_file, buf, bytes)) {
msg("error: cannot write to stream for '%s'.\n",
die("cannot write to stream for '%s'.",
tmp_file->orig_path);
exit(EXIT_FAILURE);
}
}
if (bytes == (size_t) -1) {
exit(EXIT_FAILURE);
die("my_read failed for %s", tmp_file->orig_path);
}
my_close(tmp_file->fd, MYF(MY_WME));
......
......@@ -79,18 +79,18 @@ xbstream_init(const char *root __attribute__((unused)))
ds_stream_ctxt_t *stream_ctxt;
xb_wstream_t *xbstream;
ctxt = my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_stream_ctxt_t),
ctxt = (ds_ctxt_t *)my_malloc(sizeof(ds_ctxt_t) + sizeof(ds_stream_ctxt_t),
MYF(MY_FAE));
stream_ctxt = (ds_stream_ctxt_t *)(ctxt + 1);
if (pthread_mutex_init(&stream_ctxt->mutex, NULL)) {
msg("xbstream_init: pthread_mutex_init() failed.\n");
msg("xbstream_init: pthread_mutex_init() failed.");
goto err;
}
xbstream = xb_stream_write_new();
if (xbstream == NULL) {
msg("xb_stream_write_new() failed.\n");
msg("xb_stream_write_new() failed.");
goto err;
}
stream_ctxt->xbstream = xbstream;
......@@ -143,7 +143,7 @@ xbstream_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat)
my_xbstream_write_callback);
if (xbstream_file == NULL) {
msg("xb_stream_write_open() failed.\n");
msg("xb_stream_write_open() failed.");
goto err;
}
......@@ -177,7 +177,7 @@ xbstream_write(ds_file_t *file, const uchar *buf, size_t len)
xbstream_file = stream_file->xbstream_file;
if (xb_stream_write_data(xbstream_file, buf, len)) {
msg("xb_stream_write_data() failed.\n");
msg("xb_stream_write_data() failed.");
return 1;
}
......@@ -209,7 +209,7 @@ xbstream_deinit(ds_ctxt_t *ctxt)
stream_ctxt = (ds_stream_ctxt_t *) ctxt->ptr;
if (xb_stream_write_done(stream_ctxt->xbstream)) {
msg("xb_stream_done() failed.\n");
msg("xb_stream_done() failed.");
}
if (stream_ctxt->dest_file) {
......
......@@ -61,8 +61,7 @@ static std::string get_encryption_plugin_from_cnf()
FILE *f = fopen("backup-my.cnf", "r");
if (!f)
{
msg("cannot open backup-my.cnf for reading\n");
exit(EXIT_FAILURE);
die("Can't open backup-my.cnf for reading");
}
char line[512];
std::string plugin_load;
......@@ -183,7 +182,7 @@ void encryption_plugin_prepare_init(int argc, char **argv)
std::string plugin_load= get_encryption_plugin_from_cnf();
if (plugin_load.size())
{
msg("Loading encryption plugin from %s\n", plugin_load.c_str());
msg("Loading encryption plugin from %s", plugin_load.c_str());
}
else
{
......@@ -210,9 +209,9 @@ static void encryption_plugin_init(int argc, char **argv)
/* Patch optional and mandatory plugins, we only need to load the one in xb_plugin_load. */
mysql_optional_plugins[0] = mysql_mandatory_plugins[0] = 0;
plugin_maturity = MariaDB_PLUGIN_MATURITY_UNKNOWN; /* mariabackup accepts all plugins */
msg("Loading encryption plugin\n");
msg("Loading encryption plugin");
for (int i= 1; i < argc; i++)
msg("\t Encryption plugin parameter : '%s'\n", argv[i]);
msg("\t Encryption plugin parameter : '%s'", argv[i]);
plugin_init(&argc, argv, PLUGIN_INIT_SKIP_PLUGIN_TABLE);
}
......@@ -173,9 +173,8 @@ xb_fil_cur_open(
/* The following call prints an error message */
os_file_get_last_error(TRUE);
msg("[%02u] mariabackup: error: cannot open "
"tablespace %s\n",
thread_n, cursor->abs_path);
msg(thread_n, "mariabackup: error: cannot open "
"tablespace %s", cursor->abs_path);
return(XB_FIL_CUR_SKIP);
}
......@@ -216,8 +215,8 @@ xb_fil_cur_open(
cursor->statinfo.st_size = (ulonglong)max_file_size;
}
if (err) {
msg("[%02u] mariabackup: error: cannot fstat %s\n",
thread_n, cursor->abs_path);
msg(thread_n, "mariabackup: error: cannot fstat %s",
cursor->abs_path);
xb_fil_cur_close(cursor);
......@@ -261,8 +260,6 @@ xb_fil_cur_open(
mutex_exit(&fil_system.mutex);
}
/*msg("crypt: %s,%u\n", node->name, node->space->crypt_data->type);*/
cursor->space_size = (ulint)(cursor->statinfo.st_size
/ page_size.physical());
......@@ -412,14 +409,8 @@ xb_fil_cur_read(
&& offset + to_read == cursor->statinfo.st_size) {
if (to_read < (ib_int64_t) page_size) {
msg("[%02u] mariabackup: Warning: junk at the end of "
"%s:\n", cursor->thread_n, cursor->abs_path);
msg("[%02u] mariabackup: Warning: offset = %llu, "
"to_read = %llu\n",
cursor->thread_n,
(unsigned long long) offset,
(unsigned long long) to_read);
msg(cursor->thread_n, "Warning: junk at the end of "
"%s, offset = %llu, to_read = %llu",cursor->abs_path, (ulonglong) offset, (ulonglong) to_read);
return(XB_FIL_CUR_EOF);
}
......@@ -463,20 +454,17 @@ xb_fil_cur_read(
retry_count--;
if (retry_count == 0) {
msg("[%02u] mariabackup: "
msg(cursor->thread_n,
"Error: failed to read page after "
"10 retries. File %s seems to be "
"corrupted.\n", cursor->thread_n,
cursor->abs_path);
"corrupted.", cursor->abs_path);
ret = XB_FIL_CUR_ERROR;
buf_page_print(page, cursor->page_size);
break;
}
msg("[%02u] mariabackup: "
"Database page corruption detected at page "
ULINTPF ", retrying...\n", cursor->thread_n,
msg(cursor->thread_n, "Database page corruption detected at page "
ULINTPF ", retrying...",
page_no);
os_thread_sleep(100000);
goto read_retry;
}
......
......@@ -738,7 +738,7 @@ ibx_get_one_option(int optid,
exit(0);
break;
case 'v':
msg("innobackupex version %s %s (%s)\n",
printf("innobackupex version %s %s (%s)",
MYSQL_SERVER_VERSION,
SYSTEM_TYPE, MACHINE_TYPE);
exit(0);
......
......@@ -80,9 +80,8 @@ wf_incremental_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
cp->delta_buf = (unsigned char *)os_mem_alloc_large(&cp->delta_buf_size);
if (!cp->delta_buf) {
msg("[%02u] mariabackup: Error: "
"cannot allocate %zu bytes\n",
cursor->thread_n, (size_t) cp->delta_buf_size);
msg(cursor->thread_n,"Can't allocate %zu bytes",
(size_t) cp->delta_buf_size);
return (FALSE);
}
......@@ -91,9 +90,9 @@ wf_incremental_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
XB_DELTA_INFO_SUFFIX);
const xb_delta_info_t info(cursor->page_size, cursor->space_id);
if (!xb_write_delta_metadata(meta_name, &info)) {
msg("[%02u] mariabackup: Error: "
"failed to write meta info for %s\n",
cursor->thread_n, cursor->rel_path);
msg(cursor->thread_n,"Error: "
"failed to write meta info for %s",
cursor->rel_path);
return(FALSE);
}
......
......@@ -92,7 +92,7 @@ xb_write_galera_info(bool incremental_prepare)
fp = fopen(XB_GALERA_INFO_FILENAME, "w");
if (fp == NULL) {
msg("mariabackup: error: "
die(
"could not create " XB_GALERA_INFO_FILENAME
", errno = %d\n",
errno);
......@@ -106,11 +106,10 @@ xb_write_galera_info(bool incremental_prepare)
if (fprintf(fp, "%s:%lld", uuid_str, (long long) seqno) < 0) {
msg("mariabackup: error: "
die(
"could not write to " XB_GALERA_INFO_FILENAME
", errno = %d\n",
errno);
exit(EXIT_FAILURE);
errno);;
}
fclose(fp);
......
......@@ -45,7 +45,6 @@ datasink_t datasink_archive;
datasink_t datasink_xbstream;
datasink_t datasink_compress;
datasink_t datasink_tmpfile;
datasink_t datasink_buffer;
static run_mode_t opt_mode;
static char * opt_directory = NULL;
......@@ -106,7 +105,7 @@ main(int argc, char **argv)
}
if (opt_mode == RUN_MODE_NONE) {
msg("%s: either -c or -x must be specified.\n", my_progname);
msg("%s: either -c or -x must be specified.", my_progname);
goto err;
}
......@@ -184,7 +183,7 @@ int
set_run_mode(run_mode_t mode)
{
if (opt_mode != RUN_MODE_NONE) {
msg("%s: can't set specify both -c and -x.\n", my_progname);
msg("%s: can't set specify both -c and -x.", my_progname);
return 1;
}
......@@ -233,7 +232,7 @@ stream_one_file(File file, xb_wstream_file_t *xbfile)
while ((bytes = (ssize_t)my_read(file, buf, XBSTREAM_BUFFER_SIZE,
MYF(MY_WME))) > 0) {
if (xb_stream_write_data(xbfile, buf, bytes)) {
msg("%s: xb_stream_write_data() failed.\n",
msg("%s: xb_stream_write_data() failed.",
my_progname);
my_free(buf);
return 1;
......@@ -262,13 +261,13 @@ mode_create(int argc, char **argv)
xb_wstream_t *stream;
if (argc < 1) {
msg("%s: no files are specified.\n", my_progname);
msg("%s: no files are specified.", my_progname);
return 1;
}
stream = xb_stream_write_new();
if (stream == NULL) {
msg("%s: xb_stream_write_new() failed.\n", my_progname);
msg("%s: xb_stream_write_new() failed.", my_progname);
return 1;
}
......@@ -281,13 +280,13 @@ mode_create(int argc, char **argv)
goto err;
}
if (!MY_S_ISREG(mystat.st_mode)) {
msg("%s: %s is not a regular file, exiting.\n",
msg("%s: %s is not a regular file, exiting.",
my_progname, filepath);
goto err;
}
if ((src_file = my_open(filepath, O_RDONLY, MYF(MY_WME))) < 0) {
msg("%s: failed to open %s.\n", my_progname, filepath);
msg("%s: failed to open %s.", my_progname, filepath);
goto err;
}
......@@ -297,7 +296,7 @@ mode_create(int argc, char **argv)
}
if (opt_verbose) {
msg("%s\n", filepath);
msg("%s", filepath);
}
if (stream_one_file(src_file, file) ||
......@@ -338,12 +337,12 @@ file_entry_new(extract_ctxt_t *ctxt, const char *path, uint pathlen)
file = ds_open(ctxt->ds_ctxt, path, NULL);
if (file == NULL) {
msg("%s: failed to create file.\n", my_progname);
msg("%s: failed to create file.", my_progname);
goto err;
}
if (opt_verbose) {
msg("%s\n", entry->path);
msg("%s", entry->path);
}
entry->file = file;
......@@ -425,7 +424,7 @@ extract_worker_thread_func(void *arg)
break;
}
if (my_hash_insert(ctxt->filehash, (uchar *) entry)) {
msg("%s: my_hash_insert() failed.\n",
msg("%s: my_hash_insert() failed.",
my_progname);
pthread_mutex_unlock(ctxt->mutex);
break;
......@@ -454,7 +453,7 @@ extract_worker_thread_func(void *arg)
if (entry->offset != chunk.offset) {
msg("%s: out-of-order chunk: real offset = 0x%llx, "
"expected offset = 0x%llx\n", my_progname,
"expected offset = 0x%llx", my_progname,
chunk.offset, entry->offset);
pthread_mutex_unlock(&entry->mutex);
res = XB_STREAM_READ_ERROR;
......@@ -462,7 +461,7 @@ extract_worker_thread_func(void *arg)
}
if (ds_write(entry->file, chunk.data, chunk.length)) {
msg("%s: my_write() failed.\n", my_progname);
msg("%s: my_write() failed.", my_progname);
pthread_mutex_unlock(&entry->mutex);
res = XB_STREAM_READ_ERROR;
break;
......@@ -500,12 +499,12 @@ mode_extract(int n_threads, int argc __attribute__((unused)),
if (my_hash_init(&filehash, &my_charset_bin, START_FILE_HASH_SIZE,
0, 0, (my_hash_get_key) get_file_entry_key,
(my_hash_free_key) file_entry_free, MYF(0))) {
msg("%s: failed to initialize file hash.\n", my_progname);
msg("%s: failed to initialize file hash.", my_progname);
return 1;
}
if (pthread_mutex_init(&mutex, NULL)) {
msg("%s: failed to initialize mutex.\n", my_progname);
msg("%s: failed to initialize mutex.", my_progname);
my_hash_free(&filehash);
return 1;
}
......@@ -520,7 +519,7 @@ mode_extract(int n_threads, int argc __attribute__((unused)),
stream = xb_stream_read_new();
if (stream == NULL) {
msg("%s: xb_stream_read_new() failed.\n", my_progname);
msg("%s: xb_stream_read_new() failed.", my_progname);
pthread_mutex_destroy(&mutex);
ret = 1;
goto exit;
......@@ -531,8 +530,8 @@ mode_extract(int n_threads, int argc __attribute__((unused)),
ctxt.ds_ctxt = ds_ctxt;
ctxt.mutex = &mutex;
tids = calloc(n_threads, sizeof(pthread_t));
retvals = calloc(n_threads, sizeof(void*));
tids = (pthread_t *)calloc(n_threads, sizeof(pthread_t));
retvals = (void **)calloc(n_threads, sizeof(void*));
for (i = 0; i < n_threads; i++)
pthread_create(tids + i, NULL, extract_worker_thread_func,
......
......@@ -101,6 +101,6 @@ xb_rstream_result_t xb_stream_read_chunk(xb_rstream_t *stream,
int xb_stream_read_done(xb_rstream_t *stream);
int xb_stream_validate_checksum(xb_rstream_chunk_t *chunk);
xb_rstream_result_t xb_stream_validate_checksum(xb_rstream_chunk_t *chunk);
#endif
......@@ -67,15 +67,15 @@ validate_chunk_type(uchar code)
}
}
int
xb_rstream_result_t
xb_stream_validate_checksum(xb_rstream_chunk_t *chunk)
{
ulong checksum;
checksum = crc32_iso3309(0, chunk->data, (uint)chunk->length);
checksum = crc32_iso3309(0, (unsigned char *)chunk->data, (uint)chunk->length);
if (checksum != chunk->checksum) {
msg("xb_stream_read_chunk(): invalid checksum at offset "
"0x%llx: expected 0x%lx, read 0x%lx.\n",
"0x%llx: expected 0x%lx, read 0x%lx.",
(ulonglong) chunk->checksum_offset, chunk->checksum,
checksum);
return XB_STREAM_READ_ERROR;
......@@ -86,8 +86,8 @@ xb_stream_validate_checksum(xb_rstream_chunk_t *chunk)
#define F_READ(buf,len) \
do { \
if (xb_read_full(fd, buf, len) < len) { \
msg("xb_stream_read_chunk(): my_read() failed.\n"); \
if (xb_read_full(fd, (uchar *)buf, len) < len) { \
msg("xb_stream_read_chunk(): my_read() failed."); \
goto err; \
} \
} while (0)
......@@ -111,7 +111,7 @@ xb_stream_read_chunk(xb_rstream_t *stream, xb_rstream_chunk_t *chunk)
return XB_STREAM_READ_EOF;
} else if (tbytes < CHUNK_HEADER_CONSTANT_LEN) {
msg("xb_stream_read_chunk(): unexpected end of stream at "
"offset 0x%llx.\n", stream->offset);
"offset 0x%llx.", stream->offset);
goto err;
}
......@@ -120,7 +120,7 @@ xb_stream_read_chunk(xb_rstream_t *stream, xb_rstream_chunk_t *chunk)
/* Chunk magic value */
if (memcmp(tmpbuf, XB_STREAM_CHUNK_MAGIC, 8)) {
msg("xb_stream_read_chunk(): wrong chunk magic at offset "
"0x%llx.\n", (ulonglong) stream->offset);
"0x%llx.", (ulonglong) stream->offset);
goto err;
}
ptr += 8;
......@@ -135,7 +135,7 @@ xb_stream_read_chunk(xb_rstream_t *stream, xb_rstream_chunk_t *chunk)
if (chunk->type == XB_CHUNK_TYPE_UNKNOWN &&
!(chunk->flags & XB_STREAM_FLAG_IGNORABLE)) {
msg("xb_stream_read_chunk(): unknown chunk type 0x%lu at "
"offset 0x%llx.\n", (ulong) *ptr,
"offset 0x%llx.", (ulong) *ptr,
(ulonglong) stream->offset);
goto err;
}
......@@ -146,7 +146,7 @@ xb_stream_read_chunk(xb_rstream_t *stream, xb_rstream_chunk_t *chunk)
pathlen = uint4korr(ptr);
if (pathlen >= FN_REFLEN) {
msg("xb_stream_read_chunk(): path length (%lu) is too large at "
"offset 0x%llx.\n", (ulong) pathlen, stream->offset);
"offset 0x%llx.", (ulong) pathlen, stream->offset);
goto err;
}
chunk->pathlen = pathlen;
......@@ -170,7 +170,7 @@ xb_stream_read_chunk(xb_rstream_t *stream, xb_rstream_chunk_t *chunk)
ullval = uint8korr(tmpbuf);
if (ullval > (ulonglong) SIZE_T_MAX) {
msg("xb_stream_read_chunk(): chunk length is too large at "
"offset 0x%llx: 0x%llx.\n", (ulonglong) stream->offset,
"offset 0x%llx: 0x%llx.", (ulonglong) stream->offset,
ullval);
goto err;
}
......@@ -181,7 +181,7 @@ xb_stream_read_chunk(xb_rstream_t *stream, xb_rstream_chunk_t *chunk)
ullval = uint8korr(tmpbuf + 8);
if (ullval > (ulonglong) MY_OFF_T_MAX) {
msg("xb_stream_read_chunk(): chunk offset is too large at "
"offset 0x%llx: 0x%llx.\n", (ulonglong) stream->offset,
"offset 0x%llx: 0x%llx.", (ulonglong) stream->offset,
ullval);
goto err;
}
......@@ -194,7 +194,7 @@ xb_stream_read_chunk(xb_rstream_t *stream, xb_rstream_chunk_t *chunk)
MYF(MY_WME | MY_ALLOW_ZERO_PTR));
if (chunk->data == NULL) {
msg("xb_stream_read_chunk(): failed to increase buffer "
"to %lu bytes.\n", (ulong) chunk->length);
"to %lu bytes.", (ulong) chunk->length);
goto err;
}
chunk->buflen = chunk->length;
......
......@@ -55,7 +55,7 @@ xb_stream_default_write_callback(xb_wstream_file_t *file __attribute__((unused))
void *userdata __attribute__((unused)),
const void *buf, size_t len)
{
if (my_write(my_fileno(stdout), buf, len, MYF(MY_WME | MY_NABP)))
if (my_write(my_fileno(stdout), (const uchar *)buf, len, MYF(MY_WME | MY_NABP)))
return -1;
return len;
}
......@@ -83,7 +83,7 @@ xb_stream_write_open(xb_wstream_t *stream, const char *path,
path_len = strlen(path);
if (path_len > FN_REFLEN) {
msg("xb_stream_write_open(): file path is too long.\n");
msg("xb_stream_write_open(): file path is too long.");
return NULL;
}
......@@ -216,7 +216,7 @@ xb_stream_write_chunk(xb_wstream_file_t *file, const void *buf, size_t len)
int8store(ptr, len); /* Payload length */
ptr += 8;
checksum = crc32_iso3309(0, buf, (uint)len); /* checksum */
checksum = crc32_iso3309(0, (const uchar *)buf, (uint)len); /* checksum */
pthread_mutex_lock(&stream->mutex);
......
This diff is collapsed.
......@@ -71,7 +71,7 @@ extern char *xtrabackup_databases_file;
extern char *xtrabackup_tables_exclude;
extern char *xtrabackup_databases_exclude;
extern ibool xtrabackup_compress;
extern uint xtrabackup_compress;
extern my_bool xtrabackup_backup;
extern my_bool xtrabackup_prepare;
......@@ -86,14 +86,10 @@ extern int xtrabackup_parallel;
extern my_bool xb_close_files;
extern const char *xtrabackup_compress_alg;
#ifdef __cplusplus
extern "C"{
#endif
extern uint xtrabackup_compress_threads;
extern ulonglong xtrabackup_compress_chunk_size;
#ifdef __cplusplus
}
#endif
extern uint xtrabackup_compress_threads;
extern ulonglong xtrabackup_compress_chunk_size;
extern my_bool xtrabackup_export;
extern char *xtrabackup_extra_lsndir;
extern ulint xtrabackup_log_copy_interval;
......
......@@ -333,7 +333,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2
Note 1003 /* select#1 */ select (/* select#2 */ select 1 from dual where !(1 is not null and <in_optimizer>(1,1 in ( <materialize> (/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` is not null ), <primary_index_lookup>(1 in <temporary table> on distinct_key where 1 = `<subquery3>`.`c`))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
Note 1003 /* select#1 */ select (/* select#2 */ select 1 from dual where !(1 is not null and <in_optimizer>(1,1 in (<primary_index_lookup>(1 in <temporary table> on distinct_key where 1 = `<subquery3>`.`c`))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
SELECT ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1;
( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )
1
......@@ -347,7 +347,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2
Note 1003 /* select#1 */ select (/* select#2 */ select 1 from dual where !(1 is not null and <in_optimizer>(1,1 in ( <materialize> (/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` is not null ), <primary_index_lookup>(1 in <temporary table> on distinct_key where 1 = `<subquery3>`.`c`))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
Note 1003 /* select#1 */ select (/* select#2 */ select 1 from dual where !(1 is not null and <in_optimizer>(1,1 in (<primary_index_lookup>(1 in <temporary table> on distinct_key where 1 = `<subquery3>`.`c`))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
SELECT ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1;
( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )
1
......
......@@ -2165,6 +2165,44 @@ select @advertAcctId as a from dual union all select 1.0 from dual;
a
1000003.0
1.0
#
# MDEV-13784: query causes seg fault
#
CREATE TABLE t1 (`bug_id` int NOT NULL PRIMARY KEY, `product_id` int NOT NULL);
INSERT INTO t1 VALUES (45199,1184);
CREATE TABLE t2 (`product_id` int NOT NULL,`userid` int NOT NULL, PRIMARY KEY (`product_id`,`userid`));
INSERT INTO t2 VALUES (1184,103),(1184,624),(1184,1577),(1184,1582);
CREATE TABLE t3 (`id` int NOT NULL PRIMARY KEY,`name` varchar(64));
CREATE TABLE t4 ( `userid` int NOT NULL PRIMARY KEY, `login_name` varchar(255));
INSERT INTO t4 VALUES (103,'foo'),(624,'foo'),(1577,'foo'),(1582,'foo');
CREATE TABLE t5 (`id` int NOT NULL PRIMARY KEY, `name` varchar(64));
explain select
(
select login_name from t4 where userId = (
select userid from t2 where product_id = t1.product_id
union
select userid from t2 where product_id = (
select id from t5 where name = (select name from t3 where id = t1.product_id)) limit 1 )
) as x from t1 where (t1.bug_id=45199);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
2 SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 func 1 Using where
3 SUBQUERY t2 ref PRIMARY PRIMARY 4 const 3 Using index
4 UNION t2 ref PRIMARY PRIMARY 4 func 1 Using where; Using index
5 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
6 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
select
(
select login_name from t4 where userId = (
select userid from t2 where product_id = t1.product_id
union
select userid from t2 where product_id = (
select id from t5 where name = (select name from t3 where id = t1.product_id)) limit 1 )
) as x from t1 where (t1.bug_id=45199);
x
foo
drop table t1, t2, t3, t4, t5;
End of 5.5 tests
#
# WL#1763 Avoid creating temporary table in UNION ALL
......
......@@ -1495,6 +1495,41 @@ eval SET NAMES $old_charset;
SET @advertAcctId = 1000003;
select @advertAcctId as a from dual union all select 1.0 from dual;
--echo #
--echo # MDEV-13784: query causes seg fault
--echo #
CREATE TABLE t1 (`bug_id` int NOT NULL PRIMARY KEY, `product_id` int NOT NULL);
INSERT INTO t1 VALUES (45199,1184);
CREATE TABLE t2 (`product_id` int NOT NULL,`userid` int NOT NULL, PRIMARY KEY (`product_id`,`userid`));
INSERT INTO t2 VALUES (1184,103),(1184,624),(1184,1577),(1184,1582);
CREATE TABLE t3 (`id` int NOT NULL PRIMARY KEY,`name` varchar(64));
CREATE TABLE t4 ( `userid` int NOT NULL PRIMARY KEY, `login_name` varchar(255));
INSERT INTO t4 VALUES (103,'foo'),(624,'foo'),(1577,'foo'),(1582,'foo');
CREATE TABLE t5 (`id` int NOT NULL PRIMARY KEY, `name` varchar(64));
explain select
(
select login_name from t4 where userId = (
select userid from t2 where product_id = t1.product_id
union
select userid from t2 where product_id = (
select id from t5 where name = (select name from t3 where id = t1.product_id)) limit 1 )
) as x from t1 where (t1.bug_id=45199);
select
(
select login_name from t4 where userId = (
select userid from t2 where product_id = t1.product_id
union
select userid from t2 where product_id = (
select id from t5 where name = (select name from t3 where id = t1.product_id)) limit 1 )
) as x from t1 where (t1.bug_id=45199);
drop table t1, t2, t3, t4, t5;
--echo End of 5.5 tests
--echo #
......
......@@ -4624,7 +4624,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where !<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(/* select#2 */ select NULL from `test`.`t4` where `test`.`t4`.`a` >= `test`.`t1`.`a` and trigcond(<cache>(10) = NULL or <cache>(NULL is null)) having trigcond(NULL is null))))
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where !<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(/* select#2 */ select NULL from `test`.`t4` where `test`.`t4`.`a` >= `test`.`t1`.`a` and trigcond(<cache>(10) = NULL or 1) having trigcond(NULL is null))))
SELECT * FROM t1, t2
WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a)
WHERE t4.a >= t1.a);
......@@ -4640,7 +4640,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'v1.a' of SELECT #2 was resolved in SELECT #1
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where !<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(/* select#2 */ select NULL from `test`.`t4` where `test`.`t4`.`a` >= `test`.`t1`.`a` and trigcond(<cache>(10) = NULL or <cache>(NULL is null)) having trigcond(NULL is null))))
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where !<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(/* select#2 */ select NULL from `test`.`t4` where `test`.`t4`.`a` >= `test`.`t1`.`a` and trigcond(<cache>(10) = NULL or 1) having trigcond(NULL is null))))
SELECT * FROM v1, t2
WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a)
WHERE t4.a >= v1.a);
......
......@@ -77,7 +77,6 @@ t2 CREATE TABLE `t2` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4;
ERROR HY000: Can't create table `test`.`t3` (errno: 140 "Wrong create options")
SHOW WARNINGS;
......@@ -85,3 +84,30 @@ Level Code Message
Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1
Error 1005 Can't create table `test`.`t3` (errno: 140 "Wrong create options")
Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
FLUSH TABLES;
create table t1(f1 int not null, f2 int not null)engine=innodb encrypted=yes;
insert into t1 values(1, 2), (2, 3), (4, 5), (5, 6), (7, 8);
insert into t1 select * from t1;
BEGIN;
INSERT INTO t2 VALUES (1);
connect con1, localhost, root;
SET DEBUG_SYNC = 'row_log_table_apply2_before SIGNAL done WAIT_FOR ever';
alter table t1 force;
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR done';
SET GLOBAL innodb_flush_log_at_trx_commit=1;
COMMIT;
disconnect con1;
select * from t1;
f1 f2
1 2
2 3
4 5
5 6
7 8
1 2
2 3
4 5
5 6
7 8
drop table t1,t2;
-- source include/have_innodb.inc
-- source include/have_debug.inc
-- source include/have_debug_sync.inc
-- source include/have_file_key_management_plugin.inc
#
# MDEV-8817: Failing assertion: new_state->key_version != ENCRYPTION_KEY_VERSION_INVALID
#
let $encrypt_tables = `SELECT @@innodb_encrypt_tables`;
let $threads = `SELECT @@innodb_encryption_threads`;
SET GLOBAL innodb_encrypt_tables = ON;
SET GLOBAL innodb_encryption_threads = 4;
......@@ -99,14 +98,35 @@ ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY;
--replace_regex /#sql-[0-9a-f_]*`/#sql-temporary`/
SHOW WARNINGS;
SHOW CREATE TABLE t2;
DROP TABLE t2;
--error ER_CANT_CREATE_TABLE
CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4;
SHOW WARNINGS;
# reset system
--disable_query_log
EVAL SET GLOBAL innodb_encrypt_tables = $encrypt_tables;
EVAL SET GLOBAL innodb_encryption_threads = $threads;
--enable_query_log
FLUSH TABLES;
create table t1(f1 int not null, f2 int not null)engine=innodb encrypted=yes;
insert into t1 values(1, 2), (2, 3), (4, 5), (5, 6), (7, 8);
insert into t1 select * from t1;
BEGIN;
INSERT INTO t2 VALUES (1);
connect con1, localhost, root;
SET DEBUG_SYNC = 'row_log_table_apply2_before SIGNAL done WAIT_FOR ever';
send alter table t1 force;
connection default;
SET DEBUG_SYNC = 'now WAIT_FOR done';
SET GLOBAL innodb_flush_log_at_trx_commit=1;
COMMIT;
--let $shutdown_timeout= 0
--source include/restart_mysqld.inc
disconnect con1;
select * from t1;
drop table t1,t2;
# Work around missing crash recovery at the SQL layer.
let $datadir= `select @@datadir`;
--remove_files_wildcard $datadir/test #sql-*.frm
......@@ -150,6 +150,7 @@ connection node_3;
connection node_2;
STOP SLAVE;
RESET SLAVE ALL;
set global gtid_slave_pos="";
reset master;
#Connection 3
connection node_3;
......
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/galera_cluster.inc
#
# This test will reproduce regressions of bugs
# https://github.com/codership/mysql-wsrep/issues/335
# https://github.com/codership/mysql-wsrep/issues/336
#
# The test will issue duplicate inserts into a table, which has foreign key
# constraint for a parent table.
# The inserts happen in separate nodes, and the
# The test outline is as follows:
# 1. in node 1, an update is done for the FK parent row, in a transaction,
# which is left open. The purpose of this is just to establish a X lock on
# the parent row.
# 2. in node 1, an insert for the child table is sent. The insert will have to wait
# for the parent row X lock, because it needs S lock on the same row.
# However, we have set an DBUG sync point just before the insert will call for
# innodb suspend
# 3. in node 2, a similar insert is issued. This will replicate to node 1 and try to
# abort the conflicting update and blocked insert
# 4. the inserts dbug sync point is relased, and insert should continue and abort
# gracefully
# 5. update is continued to commit, and it should also observe the deadlock
#
# This test is run in 3 phases:
#
# 1. with plain SQL statement
# 2. as SQL prepared statements
# 3. as SQl stored procedures
#
# The test phase 3 is for reproducing the issue in bug #336 specifically
#
#
# create the test tables and foreign key constraint between them
#
CREATE TABLE user(id int primary key, j int) ENGINE=InnoDB;
CREATE TABLE user_session(id int primary key, fk1 int, fk2 int) ENGINE=InnoDB;
alter table user_session add foreign key (fk1) references user(id);
# populate a few initial rows
INSERT INTO user values (1,0), (2,0), (3,0), (4,0);
INSERT INTO user_session values (1,1,1);
#
# prepare test connections, for:
# update of parent row in node1
# insert of child row in node1
# insert of child row in node2
--connect node_1_u, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connect node_1_i, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connect node_2_i, 127.0.0.1, root, , test, $NODE_MYPORT_2
#
# test phase 1: plain SQL statements
#
--echo "Phase 1: plain SQL statements"
--connection node_1
let $counter=10;
let $sleep_period=1;
while($counter > 0)
{
--connection node_1_u
begin;
update user set j = j + 1 WHERE id > 0;
--connection node_1_i
set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins';
send insert into user_session(id,fk1,fk2) values (2, 2, 2);
--connection node_1
set debug_sync='now WAIT_FOR ins_waiting';
--connection node_2_i
insert into user_session(id,fk1,fk2) values (2, 2, 3);
--connection node_1
set debug_sync='now SIGNAL cont_ins';
--connection node_1_i
--error 0,ER_LOCK_DEADLOCK,ER_DUP_ENTRY
reap;
--connection node_1_u
--error 0,ER_LOCK_DEADLOCK
commit;
--connection node_1
--error 0,ER_LOCK_DEADLOCK
truncate user_session;
set debug_sync = reset;
dec $counter;
}
#
# test phase 2: prepared statements
#
--echo "Phase 2: prepared statements"
--connection node_1_u
prepare upd from 'update user set j = j + 1 WHERE id > 0';
--connection node_1_i
prepare ins1 from 'insert into user_session(id,fk1,fk2) values (2, 2, 2)';
--connection node_2_i
prepare ins2 from 'insert into user_session(id,fk1,fk2) values (2, 2, 3)';
--connection node_1
let $counter=10;
let $sleep_period=1;
while($counter > 0)
{
--connection node_1_u
begin;
execute upd;
#update user set j = j + 1 WHERE id > 0;
--connection node_1_i
set debug_sync='lock_wait_suspend_thread_enter SIGNAL ins_waiting WAIT_FOR cont_ins';
send execute ins1;
--connection node_1
set debug_sync='now WAIT_FOR ins_waiting';
--connection node_2_i
execute ins2;
--connection node_1
set debug_sync='now SIGNAL cont_ins';
--connection node_1_i
--error 0,ER_LOCK_DEADLOCK,ER_DUP_ENTRY
reap;
--connection node_1_u
--error 0,ER_LOCK_DEADLOCK
commit;
--connection node_1
--error 0,ER_LOCK_DEADLOCK
truncate user_session;
set debug_sync = reset;
dec $counter;
}
--connection node_1
drop table user_session,user;
......@@ -196,6 +196,9 @@ DROP TABLE t2,t1;
--connection node_2
STOP SLAVE;
RESET SLAVE ALL;
--disable_warnings
set global gtid_slave_pos="";
--enable_warnings
reset master;
--echo #Connection 3
......
......@@ -330,3 +330,16 @@ term uw_id plan wdraw_rsn admit_term
1035 2 CSM ACAD 1009
drop table grad_degree;
drop table gso_grad_supr;
CREATE TABLE t1 (a INT, b CHAR(12), c INT AS (a) VIRTUAL, FULLTEXT KEY(b)) ENGINE=InnoDB;
INSERT INTO t1 (a,b) VALUES (1,'foo');
SELECT * FROM t1;
a b c
1 foo 1
DROP TABLE t1;
CREATE TABLE t1 (a INT, b CHAR(12), c INT AS (a) VIRTUAL) ENGINE=InnoDB;
INSERT INTO t1 (a,b) VALUES (1,'foo');
ALTER TABLE t1 ADD FULLTEXT KEY(b);
SELECT * FROM t1;
a b c
1 foo 1
DROP TABLE t1;
......@@ -306,3 +306,14 @@ select * from gso_grad_supr;
drop table grad_degree;
drop table gso_grad_supr;
CREATE TABLE t1 (a INT, b CHAR(12), c INT AS (a) VIRTUAL, FULLTEXT KEY(b)) ENGINE=InnoDB;
INSERT INTO t1 (a,b) VALUES (1,'foo');
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INT, b CHAR(12), c INT AS (a) VIRTUAL) ENGINE=InnoDB;
INSERT INTO t1 (a,b) VALUES (1,'foo');
ALTER TABLE t1 ADD FULLTEXT KEY(b);
SELECT * FROM t1;
DROP TABLE t1;
......@@ -4165,7 +4165,7 @@ VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of cached table definitions
NUMERIC_MIN_VALUE 400
NUMERIC_MAX_VALUE 524288
NUMERIC_MAX_VALUE 2097152
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
......
......@@ -5131,7 +5131,7 @@ VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of cached table definitions
NUMERIC_MIN_VALUE 400
NUMERIC_MAX_VALUE 524288
NUMERIC_MAX_VALUE 2097152
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
......
......@@ -28,14 +28,14 @@ Warning 1292 Truncated incorrect table_definition_cache value: '2'
SELECT @@global.table_definition_cache;
@@global.table_definition_cache
400
SET @@global.table_definition_cache = 524287;
SET @@global.table_definition_cache = 2097151;
SELECT @@global.table_definition_cache;
@@global.table_definition_cache
524287
SET @@global.table_definition_cache = 524288;
2097151
SET @@global.table_definition_cache = 2097152;
SELECT @@global.table_definition_cache;
@@global.table_definition_cache
524288
2097152
'#--------------------FN_DYNVARS_019_04-------------------------#'
SET @@global.table_definition_cache = 0;
Warnings:
......@@ -49,18 +49,18 @@ Warning 1292 Truncated incorrect table_definition_cache value: '-1024'
SELECT @@global.table_definition_cache;
@@global.table_definition_cache
400
SET @@global.table_definition_cache = 524289;
SET @@global.table_definition_cache = 2097153;
Warnings:
Warning 1292 Truncated incorrect table_definition_cache value: '524289'
Warning 1292 Truncated incorrect table_definition_cache value: '2097153'
SELECT @@global.table_definition_cache;
@@global.table_definition_cache
524288
2097152
SET @@global.table_definition_cache = 42949672950;
Warnings:
Warning 1292 Truncated incorrect table_definition_cache value: '42949672950'
SELECT @@global.table_definition_cache;
@@global.table_definition_cache
524288
2097152
SET @@global.table_definition_cache = 21221204.10;
ERROR 42000: Incorrect argument type to variable 'table_definition_cache'
SET @@global.table_definition_cache = ON;
......
......@@ -64,9 +64,9 @@ SET @@global.table_definition_cache = 1;
SELECT @@global.table_definition_cache;
SET @@global.table_definition_cache = 2;
SELECT @@global.table_definition_cache;
SET @@global.table_definition_cache = 524287;
SET @@global.table_definition_cache = 2097151;
SELECT @@global.table_definition_cache;
SET @@global.table_definition_cache = 524288;
SET @@global.table_definition_cache = 2097152;
SELECT @@global.table_definition_cache;
......@@ -79,7 +79,7 @@ SET @@global.table_definition_cache = 0;
SELECT @@global.table_definition_cache;
SET @@global.table_definition_cache = -1024;
SELECT @@global.table_definition_cache;
SET @@global.table_definition_cache = 524289;
SET @@global.table_definition_cache = 2097153;
SELECT @@global.table_definition_cache;
SET @@global.table_definition_cache = 42949672950;
SELECT @@global.table_definition_cache;
......
......@@ -285,8 +285,8 @@ static void warn(const char *format,...)
va_list args;
DBUG_PRINT("error", ("%s", format));
va_start(args,format);
fflush(stderr);
vfprintf(stderr, format, args);
fflush(stderr);
va_end(args);
#ifdef HAVE_BACKTRACE
......@@ -319,7 +319,7 @@ static int bad_ptr(const char *where, void *ptr)
if (irem->marker != MAGICSTART)
{
DBUG_PRINT("error",("Unallocated data or underrun buffer %p", ptr));
warn("Error: %s unallocated data or underrun buffer %p", ptr, where);
warn("Error: %s unallocated data or underrun buffer %p", where, ptr);
return 1;
}
......
......@@ -1517,6 +1517,7 @@ void THD::cleanup(void)
auto_inc_intervals_in_cur_stmt_for_binlog.empty();
mysql_ull_cleanup(this);
stmt_map.reset();
/* All metadata locks must have been released by now. */
DBUG_ASSERT(!mdl_context.has_locks());
......@@ -3994,11 +3995,13 @@ void Statement_map::erase(Statement *statement)
void Statement_map::reset()
{
/* Must be first, hash_free will reset st_hash.records */
mysql_mutex_lock(&LOCK_prepared_stmt_count);
DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
prepared_stmt_count-= st_hash.records;
mysql_mutex_unlock(&LOCK_prepared_stmt_count);
if (st_hash.records)
{
mysql_mutex_lock(&LOCK_prepared_stmt_count);
DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
prepared_stmt_count-= st_hash.records;
mysql_mutex_unlock(&LOCK_prepared_stmt_count);
}
my_hash_reset(&names_hash);
my_hash_reset(&st_hash);
last_found_statement= 0;
......@@ -4007,12 +4010,8 @@ void Statement_map::reset()
Statement_map::~Statement_map()
{
/* Must go first, hash_free will reset st_hash.records */
mysql_mutex_lock(&LOCK_prepared_stmt_count);
DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
prepared_stmt_count-= st_hash.records;
mysql_mutex_unlock(&LOCK_prepared_stmt_count);
/* Statement_map::reset() should be called prior to destructor. */
DBUG_ASSERT(!st_hash.records);
my_hash_free(&names_hash);
my_hash_free(&st_hash);
}
......
......@@ -4138,6 +4138,7 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only)
inner_join->select_options|= SELECT_DESCRIBE;
}
res= inner_join->optimize();
sl->update_used_tables();
sl->update_correlated_cache();
is_correlated_unit|= sl->is_correlated;
inner_join->select_options= save_options;
......
......@@ -3497,11 +3497,15 @@ static Sys_var_charptr Sys_system_time_zone(
CMD_LINE_HELP_ONLY,
IN_SYSTEM_CHARSET, DEFAULT(system_time_zone));
/*
If One use views with prepared statements this should be bigger than
table_open_cache (now we allow 2 times bigger value)
*/
static Sys_var_ulong Sys_table_def_size(
"table_definition_cache",
"The number of cached table definitions",
GLOBAL_VAR(tdc_size), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(TABLE_DEF_CACHE_MIN, 512*1024),
VALID_RANGE(TABLE_DEF_CACHE_MIN, 2*1024*1024),
DEFAULT(TABLE_DEF_CACHE_DEFAULT), BLOCK_SIZE(1));
......@@ -3513,7 +3517,7 @@ static bool fix_table_open_cache(sys_var *, THD *, enum_var_type)
return false;
}
/* Check the table_definition_cache comment if makes changes */
static Sys_var_ulong Sys_table_cache_size(
"table_open_cache", "The number of cached open tables",
GLOBAL_VAR(tc_size), CMD_LINE(REQUIRED_ARG),
......
......@@ -495,10 +495,12 @@ fil_parse_write_crypt_data(
uint len = mach_read_from_1(ptr);
ptr += 1;
ut_a(type == CRYPT_SCHEME_UNENCRYPTED ||
type == CRYPT_SCHEME_1); // only supported
if ((type != CRYPT_SCHEME_1 && type != CRYPT_SCHEME_UNENCRYPTED)
|| len != CRYPT_SCHEME_1_IV_LEN) {
*err = DB_CORRUPTION;
return NULL;
}
ut_a(len == CRYPT_SCHEME_1_IV_LEN); // only supported
uint min_key_version = mach_read_from_4(ptr);
ptr += 4;
......@@ -517,6 +519,7 @@ fil_parse_write_crypt_data(
crypt_data->page0_offset = offset;
crypt_data->min_key_version = min_key_version;
crypt_data->encryption = encryption;
crypt_data->type = type;
memcpy(crypt_data->iv, ptr, len);
ptr += len;
......@@ -2363,7 +2366,7 @@ fil_space_crypt_close_tablespace(
{
fil_space_crypt_t* crypt_data = space->crypt_data;
if (!crypt_data) {
if (!crypt_data || srv_n_fil_crypt_threads == 0) {
return;
}
......
......@@ -1454,6 +1454,9 @@ class buf_page_t {
/** Page id. Protected by buf_pool mutex. */
page_id_t id;
buf_page_t* hash; /*!< node used in chaining to
buf_pool->page_hash or
buf_pool->zip_hash */
/** Page size. Protected by buf_pool mutex. */
page_size_t size;
......@@ -1501,9 +1504,6 @@ class buf_page_t {
buf_tmp_buffer_t* slot; /*!< Slot for temporary memory
used for encryption/compression
or NULL */
buf_page_t* hash; /*!< node used in chaining to
buf_pool->page_hash or
buf_pool->zip_hash */
#ifdef UNIV_DEBUG
ibool in_page_hash; /*!< TRUE if in buf_pool->page_hash */
ibool in_zip_hash; /*!< TRUE if in buf_pool->zip_hash */
......
......@@ -1777,6 +1777,12 @@ struct dict_table_t {
public:
/** Id of the table. */
table_id_t id;
/** Hash chain node. */
hash_node_t id_hash;
/** Table name. */
table_name_t name;
/** Hash chain node. */
hash_node_t name_hash;
/** Memory heap. If you allocate from this heap after the table has
been created then be sure to account the allocation into
......@@ -1789,9 +1795,6 @@ struct dict_table_t {
dict_sys->size += new_size - old_size. */
mem_heap_t* heap;
/** Table name. */
table_name_t name;
/** NULL or the directory path specified by DATA DIRECTORY. */
char* data_dir_path;
......@@ -1912,12 +1915,6 @@ struct dict_table_t {
/*!< !DICT_FRM_CONSISTENT==0 if data
dictionary information and
MySQL FRM information mismatch. */
/** Hash chain node. */
hash_node_t name_hash;
/** Hash chain node. */
hash_node_t id_hash;
/** The FTS_DOC_ID_INDEX, or NULL if no fulltext indexes exist */
dict_index_t* fts_doc_id_index;
......
......@@ -73,8 +73,9 @@ struct fil_node_t;
/** Tablespace or log data space */
struct fil_space_t {
char* name; /*!< Tablespace name */
ulint id; /*!< space id */
hash_node_t hash; /*!< hash chain node */
char* name; /*!< Tablespace name */
lsn_t max_lsn;
/*!< LSN of the most recent
fil_names_write_if_was_clean().
......@@ -142,7 +143,6 @@ struct fil_space_t {
Note that fil_node_t::n_pending tracks actual pending I/O requests.
Protected by fil_system.mutex and std::atomic. */
std::atomic<ulint> n_pending_ios;
hash_node_t hash; /*!< hash chain node */
rw_lock_t latch; /*!< latch protecting the file space storage
allocation */
UT_LIST_NODE_T(fil_space_t) unflushed_spaces;
......
......@@ -591,12 +591,14 @@ typedef void* os_thread_ret_t;
#include "ut0ut.h"
#include "sync0types.h"
#include <my_valgrind.h>
/* define UNIV macros in terms of my_valgrind.h */
#define UNIV_MEM_INVALID(addr, size) MEM_UNDEFINED(addr, size)
#define UNIV_MEM_FREE(addr, size) MEM_NOACCESS(addr, size)
#define UNIV_MEM_ALLOC(addr, size) UNIV_MEM_INVALID(addr, size)
#ifdef UNIV_DEBUG_VALGRIND
# include <valgrind/memcheck.h>
# define UNIV_MEM_VALID(addr, size) VALGRIND_MAKE_MEM_DEFINED(addr, size)
# define UNIV_MEM_INVALID(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size)
# define UNIV_MEM_FREE(addr, size) VALGRIND_MAKE_MEM_NOACCESS(addr, size)
# define UNIV_MEM_ALLOC(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size)
# define UNIV_MEM_DESC(addr, size) VALGRIND_CREATE_BLOCK(addr, size, #addr)
# define UNIV_MEM_UNDESC(b) VALGRIND_DISCARD(b)
# define UNIV_MEM_ASSERT_RW_LOW(addr, size, should_abort) do { \
......@@ -631,9 +633,6 @@ typedef void* os_thread_ret_t;
} while (0)
#else
# define UNIV_MEM_VALID(addr, size) do {} while(0)
# define UNIV_MEM_INVALID(addr, size) do {} while(0)
# define UNIV_MEM_FREE(addr, size) do {} while(0)
# define UNIV_MEM_ALLOC(addr, size) do {} while(0)
# define UNIV_MEM_DESC(addr, size) do {} while(0)
# define UNIV_MEM_UNDESC(b) do {} while(0)
# define UNIV_MEM_ASSERT_RW_LOW(addr, size, should_abort) do {} while(0)
......
......@@ -160,7 +160,6 @@ os_mem_free_large(
#if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX
if (os_use_large_pages && os_large_page_size && !shmdt(ptr)) {
os_total_large_mem_allocated -= size;
UNIV_MEM_FREE(ptr, size);
return;
}
#endif /* HAVE_LINUX_LARGE_PAGES && UNIV_LINUX */
......@@ -172,7 +171,6 @@ os_mem_free_large(
<< ") failed; Windows error " << GetLastError();
} else {
os_total_large_mem_allocated -= size;
UNIV_MEM_FREE(ptr, size);
}
#elif !defined OS_MAP_ANON
ut_free(ptr);
......@@ -186,7 +184,6 @@ os_mem_free_large(
" errno " << errno;
} else {
os_total_large_mem_allocated -= size;
UNIV_MEM_FREE(ptr, size);
}
#endif
}
/*****************************************************************************
Copyright (c) 2010, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2018, MariaDB Corporation.
Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -905,7 +905,7 @@ DECLARE_THREAD(fts_parallel_tokenization)(
goto func_exit;
}
UNIV_MEM_INVALID(block[t_ctx.buf_used][0], srv_sort_buf_size);
UNIV_MEM_INVALID(block[t_ctx.buf_used], srv_sort_buf_size);
buf[t_ctx.buf_used] = row_merge_buf_empty(buf[t_ctx.buf_used]);
mycount[t_ctx.buf_used] += t_ctx.rows_added[t_ctx.buf_used];
t_ctx.rows_added[t_ctx.buf_used] = 0;
......@@ -999,12 +999,11 @@ DECLARE_THREAD(fts_parallel_tokenization)(
goto func_exit;
}
UNIV_MEM_INVALID(block[i][0],
srv_sort_buf_size);
UNIV_MEM_INVALID(block[i], srv_sort_buf_size);
if (crypt_block[i]) {
UNIV_MEM_INVALID(crypt_block[i][0],
srv_sort_buf_size);
UNIV_MEM_INVALID(crypt_block[i],
srv_sort_buf_size);
}
}
......
Markdown is supported
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