Skip to content

Commit

Permalink
Merge 10.5 into 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Feb 8, 2024
2 parents b2654ba + 0381921 commit 466069b
Show file tree
Hide file tree
Showing 32 changed files with 1,075 additions and 197 deletions.
78 changes: 46 additions & 32 deletions client/mysqldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1251,8 +1251,9 @@ static int get_options(int *argc, char ***argv)
if (opt_slave_data)
{
opt_lock_all_tables= !opt_single_transaction;
opt_master_data= 0;
opt_delete_master_logs= 0;
if (opt_slave_data != MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL)
opt_master_data= 0;
}

/* Ensure consistency of the set of binlog & locking options */
Expand All @@ -1265,10 +1266,7 @@ static int get_options(int *argc, char ***argv)
return(EX_USAGE);
}
if (opt_master_data)
{
opt_lock_all_tables= !opt_single_transaction;
opt_slave_data= 0;
}
if (opt_single_transaction || opt_lock_all_tables)
lock_tables= 0;
if (enclosed && opt_enclosed)
Expand Down Expand Up @@ -6077,17 +6075,12 @@ static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos,

}

/* SHOW MASTER STATUS reports file and position */
print_comment(md_result_file, 0,
"\n--\n-- Position to start replication or point-in-time "
"recovery from\n--\n\n");
fprintf(md_result_file,
"%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n",
(use_gtid ? "-- " : comment_prefix), file, offset);
/* gtid */
if (have_mariadb_gtid)
{
print_comment(md_result_file, 0,
"\n--\n-- GTID to start replication from\n--\n\n");
"\n-- Preferably use GTID to start replication from GTID "
"position:\n\n");
if (use_gtid)
fprintf(md_result_file,
"%sCHANGE MASTER TO MASTER_USE_GTID=slave_pos;\n",
Expand All @@ -6096,6 +6089,19 @@ static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos,
"%sSET GLOBAL gtid_slave_pos='%s';\n",
(!use_gtid ? "-- " : comment_prefix), gtid_pos);
}

/* SHOW MASTER STATUS reports file and position */
print_comment(md_result_file, 0,
"\n--\n-- Alternately, following is the position of the binary "
"logging from SHOW MASTER STATUS at point of backup."
"\n-- Use this when creating a replica of the primary server "
"where the backup was made."
"\n-- The new server will be connecting to the primary server "
"where the backup was taken."
"\n--\n\n");
fprintf(md_result_file,
"%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n",
(use_gtid ? "-- " : comment_prefix), file, offset);
check_io(md_result_file);

if (!consistent_binlog_pos)
Expand Down Expand Up @@ -6174,7 +6180,6 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
(opt_slave_data == MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL) ? "-- " : "";
const char *gtid_comment_prefix= (use_gtid ? comment_prefix : "-- ");
const char *nogtid_comment_prefix= (!use_gtid ? comment_prefix : "-- ");
int set_gtid_done= 0;

if (mysql_query_with_error_report(mysql_con, &slave,
multi_source ?
Expand All @@ -6190,23 +6195,36 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
return 1;
}

while ((row= mysql_fetch_row(slave)))
print_comment(md_result_file, 0,
"\n--\n-- The following is the SQL position of the replication "
"taken from SHOW SLAVE STATUS at the time of backup.\n"
"-- Use this position when creating a clone of, or replacement "
"server, from where the backup was taken."
"\n-- This new server will connects to the same primary "
"server%s.\n--\n",
multi_source ? "(s)" : "");

if (multi_source)
{
if (multi_source && !set_gtid_done)
char gtid_pos[MAX_GTID_LENGTH];
if (have_mariadb_gtid && get_gtid_pos(gtid_pos, 0))
{
char gtid_pos[MAX_GTID_LENGTH];
if (have_mariadb_gtid && get_gtid_pos(gtid_pos, 0))
{
mysql_free_result(slave);
return 1;
}
if (opt_comments)
fprintf(md_result_file, "\n--\n-- Gtid position to start replication "
"from\n--\n\n");
fprintf(md_result_file, "%sSET GLOBAL gtid_slave_pos='%s';\n",
gtid_comment_prefix, gtid_pos);
set_gtid_done= 1;
mysql_free_result(slave);
return 1;
}
print_comment(md_result_file, 0,
"-- GTID position to start replication:\n");
fprintf(md_result_file, "%sSET GLOBAL gtid_slave_pos='%s';\n",
gtid_comment_prefix, gtid_pos);
}
if (use_gtid)
print_comment(md_result_file, 0,
"\n-- Use only the MASTER_USE_GTID=slave_pos or "
"MASTER_LOG_FILE/MASTER_LOG_POS in the statements below."
"\n\n");

while ((row= mysql_fetch_row(slave)))
{
if (row[9 + multi_source] && row[21 + multi_source])
{
if (use_gtid)
Expand All @@ -6220,11 +6238,6 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
}

/* SHOW MASTER STATUS reports file and position */
if (opt_comments)
fprintf(md_result_file,
"\n--\n-- Position to start replication or point-in-time "
"recovery from (the master of this slave)\n--\n\n");

if (multi_source)
fprintf(md_result_file, "%sCHANGE MASTER '%.80s' TO ",
nogtid_comment_prefix, row[0]);
Expand All @@ -6245,6 +6258,7 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
check_io(md_result_file);
}
}
fprintf(md_result_file, "\n");
mysql_free_result(slave);
return 0;
}
Expand Down
44 changes: 44 additions & 0 deletions include/mysql/service_print_check_msg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* Copyright (c) 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 Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */

#pragma once

/**
@file include/mysql/service_print_check_msg.h
This service provides functions to write messages for check or repair
*/

#ifdef __cplusplus
extern "C" {
#endif


extern struct print_check_msg_service_st {
void (*print_check_msg)(MYSQL_THD, const char *db_name, const char *table_name,
const char *op, const char *msg_type, const char *message,
my_bool print_to_log);
} *print_check_msg_service;

#ifdef MYSQL_DYNAMIC_PLUGIN
# define print_check_msg_context(_THD) print_check_msg_service->print_check_msg
#else
extern void print_check_msg(MYSQL_THD, const char *db_name, const char *table_name,
const char *op, const char *msg_type, const char *message,
my_bool print_to_log);
#endif

#ifdef __cplusplus
}
#endif
1 change: 1 addition & 0 deletions include/service_versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@
#define VERSION_json 0x0100
#define VERSION_sql_service 0x0100
#define VERSION_thd_mdl 0x0100
#define VERSION_print_check_msg 0x0100
1 change: 1 addition & 0 deletions libservices/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ SET(MYSQLSERVICES_SOURCES
my_crypt_service.c
my_md5_service.c
my_print_error_service.c
print_check_msg_service.c
my_sha1_service.c
my_sha2_service.c
my_snprintf_service.c
Expand Down
18 changes: 18 additions & 0 deletions libservices/print_check_msg_service.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Copyright (c) 2024, MariaDB Plc
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 Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <service_versions.h>
SERVICE_VERSION print_check_msg_context= (void*) VERSION_print_check_msg;
Loading

0 comments on commit 466069b

Please sign in to comment.